Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added JSON-RPC back-end to Project API and removed deprecated VFS classes #6726

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
b224fa2
initial commit
Sep 28, 2017
d98cefb
fixes and refactoring
Oct 2, 2017
f87e47c
fixed bugs, rearranged packages, moved guice conf to separate module …
Oct 2, 2017
12ced53
more refactoring
Oct 4, 2017
13028b6
bug fixes for project importing
Oct 4, 2017
0db87aa
fix for selenium tests
Oct 4, 2017
98ca8cf
refactoring, bug fixing, added unit tests
Oct 9, 2017
98e3dd2
rebased and added several unit tests
Oct 12, 2017
7e5c6dd
added new unit tests, fixed some old unit tests, refactoring
Oct 13, 2017
9394cbc
fixed formatting
Oct 17, 2017
bcdebec
fixed import project from zip
Oct 19, 2017
013c55e
small fix
Oct 19, 2017
55f9c56
Merged che6
Oct 20, 2017
d57c173
fixed format
Oct 20, 2017
af43740
remove unused dependency
Oct 20, 2017
e1aed64
fix folder unzip validation
Oct 20, 2017
8247b69
Fix URL build, don't create folder before import in tests
vparfonov Oct 20, 2017
fa5a1bf
Merge branch 'che6' into che#6122
Oct 20, 2017
7e9c475
fixed getTree method and uri building
Oct 23, 2017
8d22669
Merge branch 'che6' into che#6122
Oct 23, 2017
52fbfd0
fixes for proper import of maven multimodule projects
Oct 27, 2017
bee5dc6
Merge branch 'che6' into che#6122
Oct 27, 2017
a9bf7a6
Merge branch 'che6' into che#6122
Oct 30, 2017
5d01f90
minor fixes
Oct 30, 2017
4f991f4
Merge branch 'che6' into che#6122
Oct 30, 2017
cbb7085
fix for maven archetype generator
Oct 31, 2017
0603d9d
Merge branch 'che6' into che#6122
Oct 31, 2017
615fa13
more fixes to project attributes
Oct 31, 2017
49333d5
formatting fix
Nov 1, 2017
37bc3d2
Merge branch 'che6' into che#6122
Nov 1, 2017
b289c35
fixed compilation error
Nov 1, 2017
bcdc476
fixed assisted inject parameter having null value in some cases
Nov 2, 2017
08f02a8
Merge branch 'che6' into che#6122
Nov 3, 2017
2ffc085
fixes for getting closest project, lucene indexer reader to string tr…
Nov 3, 2017
b2b7adb
Merge branch 'che6' into che#6122
Nov 5, 2017
a6c0652
fix for getting name of root
Nov 6, 2017
0e0db99
added json rpc project api back end
Nov 6, 2017
97fcb69
small fix
Nov 7, 2017
94451a2
added proper dealing with ending slash in workspace pathes
Nov 7, 2017
5795490
fixed project importing subscription
Nov 7, 2017
67f01e4
Revert "fixed project importing subscription"
Nov 7, 2017
6509fc0
tried to fix project importing subscription
Nov 7, 2017
e5f94b5
disabled file watcher suspension
Nov 7, 2017
63729b3
test fixes
Nov 7, 2017
4678f93
yet another extremely important fix
Nov 7, 2017
e1379c6
fixed git detectors
Nov 8, 2017
1865e56
fixed file watcher media type exclude matcher for directories and del…
Nov 8, 2017
eca4ca4
fixed ProjectItemModifiedEvent event publishing
Nov 8, 2017
50b4e91
Merge branch 'che6' into che#6122
Nov 8, 2017
0e51f1e
more fixes to media type filter
Nov 8, 2017
b778678
temprorary disabled media types exclude matcher unit test
Nov 8, 2017
df40015
removed media type exclude filter for file watcher operations
Nov 9, 2017
a3fb600
fixed DI for zend debugger
Nov 9, 2017
b89fb4e
fixed selenium test timeout for newly added files
Nov 9, 2017
607c49a
fixed recursive project and subprojects removal
Nov 9, 2017
812671c
formatting was not excellent
Nov 9, 2017
18cb4de
Fix PHP test
tolusha Nov 10, 2017
1664473
minor clean up
Nov 10, 2017
9089de2
added some javadocs
Nov 13, 2017
7dd03fe
fixed creating of a project in a sub-directory of another project
Nov 14, 2017
b5fffc2
Merge branch 'che6' into che#6122
Nov 14, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ public BasicWebSocketMessageTransmitter(

@Override
public synchronized void transmit(String endpointId, String message) {
final Optional<Session> sessionOptional = registry.get(endpointId);
Optional<Session> sessionOptional = registry.get(endpointId);

if (!sessionOptional.isPresent()) {
sessionOptional = registry.getByPartialMatch(endpointId).stream().findFirst();
}

if (!sessionOptional.isPresent() || !sessionOptional.get().isOpen()) {
LOG.debug("Session is not registered or closed, adding message to pending");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public interface AppContext {
*
* @return identifier
*/
Optional<String> getApplicationWebsocketId();
Optional<String> getApplicationId();

/**
* Sets web application identifier. Most obvious use - to distinguish web applications on server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,9 @@ private void internalInitialize() {
separator
+ "token="
+ token
+ appContext
.getApplicationWebsocketId()
.map(id -> "&clientId=" + id)
.orElse("");
+ appContext.getApplicationId().map(id -> "&clientId=" + id).orElse("");
Set<Runnable> initActions =
appContext.getApplicationWebsocketId().isPresent()
appContext.getApplicationId().isPresent()
? emptySet()
: singleton(WorkspaceMasterJsonRpcInitializer.this::processWsId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public String getWsAgentServerApiEndpoint() {
}

@Override
public Optional<String> getApplicationWebsocketId() {
public Optional<String> getApplicationId() {
return Optional.ofNullable(applicationWebsocketId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ private void internalInitialize() {
String separator = wsAgentWebSocketUrl.contains("?") ? "&" : "?";
String queryParams =
appContext
.getApplicationWebsocketId()
.getApplicationId()
.map(id -> separator + "clientId=" + id)
.orElse("");
Set<Runnable> initActions =
appContext.getApplicationWebsocketId().isPresent()
appContext.getApplicationId().isPresent()
? emptySet()
: singleton(this::processWsId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void initialize() {
}

char separator = url.contains("?") ? '&' : '?';
Optional<String> appWebSocketId = appContext.getApplicationWebsocketId();
Optional<String> appWebSocketId = appContext.getApplicationId();
String queryParams =
separator
+ "token="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.eclipse.che.ide.api.project.type.wizard.ProjectWizardRegistrar;
import org.eclipse.che.ide.api.project.wizard.ImportWizardRegistrar;
import org.eclipse.che.ide.projectimport.InitialProjectImporter;
import org.eclipse.che.ide.projectimport.ProjectImportNotificationSubscriber;
import org.eclipse.che.ide.projectimport.wizard.ImportProjectNotificationSubscriberFactory;
import org.eclipse.che.ide.projectimport.wizard.ImportWizardFactory;
import org.eclipse.che.ide.projectimport.wizard.ProjectImportOutputJsonRpcNotifier;
Expand Down Expand Up @@ -75,8 +74,6 @@ protected void configure() {
ProjectNotificationSubscriber.class, ProjectImportOutputJsonRpcNotifier.class)
.build(ImportProjectNotificationSubscriberFactory.class));

bind(ProjectImportNotificationSubscriber.class).asEagerSingleton();

bind(WorkspaceProjectsSyncer.class).asEagerSingleton();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ public Promise<List<SourceEstimation>> resolveSources(Path path) {
public Promise<Void> importProject(Path path, SourceStorageDto source) {
String url = getBaseUrl() + IMPORT + encodePath(path);

url += url.contains("?") ? "&" : "?";
url += "clientId=" + appContext.getApplicationId().orElse("");

return reqFactory.createPostRequest(url, source).header(CONTENT_TYPE, APPLICATION_JSON).send();
}

Expand Down Expand Up @@ -230,6 +233,7 @@ public Promise<ProjectConfigDto> createProject(
for (String key : options.keySet()) {
urlBuilder.setParameter(key, options.get(key));
}
urlBuilder.setParameter("clientId", appContext.getApplicationId().orElse(""));
return reqFactory
.createPostRequest(urlBuilder.buildString(), configuration)
.header(ACCEPT, APPLICATION_JSON)
Expand Down Expand Up @@ -259,7 +263,11 @@ public Promise<ProjectConfigDto> createProject(
*/
public Promise<List<ProjectConfigDto>> createBatchProjects(
List<NewProjectConfigDto> configurations) {
final String url = getBaseUrl() + BATCH_PROJECTS;
String url = getBaseUrl() + BATCH_PROJECTS;

url += url.contains("?") ? "&" : "?";
url += "clientId=" + appContext.getApplicationId().orElse("");

final String loaderMessage =
configurations.size() > 1 ? "Creating the batch of projects..." : "Creating project...";
return reqFactory
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import static com.google.common.base.Strings.nullToEmpty;
import static org.eclipse.che.api.project.shared.Constants.EVENT_IMPORT_OUTPUT_PROGRESS;
import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE;
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.PROGRESS;
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.SUCCESS;
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.*;

import com.google.inject.Inject;
import com.google.web.bindery.event.shared.EventBus;
Expand Down Expand Up @@ -59,7 +57,7 @@ public ProjectImportOutputJsonRpcNotifier(
eventBus.addHandler(
WsAgentServerStoppedEvent.TYPE,
e -> {
requestHandlerManager.deregister(EVENT_IMPORT_OUTPUT_PROGRESS + "/" + projectName);
requestHandlerManager.deregister(EVENT_IMPORT_OUTPUT_PROGRESS);
if (singletonNotification != null) {
singletonNotification.setStatus(FAIL);
singletonNotification.setContent("");
Expand All @@ -72,17 +70,19 @@ public void subscribe(String projectName, StatusNotification notification) {
this.projectName = projectName;
this.singletonNotification = notification;

configurator
.newConfiguration()
.methodName(EVENT_IMPORT_OUTPUT_PROGRESS + "/" + projectName)
.paramsAsDto(ImportProgressRecordDto.class)
.noResult()
.withConsumer(
progressRecord -> {
singletonNotification.setTitle(
locale.importingProject(ProjectImportOutputJsonRpcNotifier.this.projectName));
singletonNotification.setContent(nullToEmpty(progressRecord.getLine()));
});
if (!requestHandlerManager.isRegistered(EVENT_IMPORT_OUTPUT_PROGRESS)) {
configurator
.newConfiguration()
.methodName(EVENT_IMPORT_OUTPUT_PROGRESS)
.paramsAsDto(ImportProgressRecordDto.class)
.noResult()
.withConsumer(
progressRecord -> {
singletonNotification.setTitle(
locale.importingProject(ProjectImportOutputJsonRpcNotifier.this.projectName));
singletonNotification.setContent(nullToEmpty(progressRecord.getLine()));
});
}
}

@Override
Expand All @@ -94,7 +94,7 @@ public void subscribe(String projectName) {

@Override
public void onSuccess() {
requestHandlerManager.deregister(EVENT_IMPORT_OUTPUT_PROGRESS + "/" + projectName);
requestHandlerManager.deregister(EVENT_IMPORT_OUTPUT_PROGRESS);

singletonNotification.setStatus(SUCCESS);
singletonNotification.setTitle(locale.importProjectMessageSuccess(projectName));
Expand All @@ -103,7 +103,7 @@ public void onSuccess() {

@Override
public void onFailure(String errorMessage) {
requestHandlerManager.deregister(EVENT_IMPORT_OUTPUT_PROGRESS + "/" + projectName);
requestHandlerManager.deregister(EVENT_IMPORT_OUTPUT_PROGRESS);

singletonNotification.setStatus(FAIL);
singletonNotification.setContent(errorMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ public void complete(@NotNull final CompleteCallback callback) {
.then(onComplete(callback))
.catchError(onFailure(callback));
} else if (mode == UPDATE) {
String path =
dataObject.getPath().startsWith("/")
? dataObject.getPath().substring(1)
: dataObject.getPath();

appContext
.getWorkspaceRoot()
.getContainer(Path.valueOf(dataObject.getPath()))
.getContainer(Path.valueOf(path))
.then(
optContainer -> {
checkState(optContainer.isPresent(), "Failed to update non existed path");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
import static org.eclipse.che.ide.rest.HTTPHeader.ACCEPT;
import static org.eclipse.che.ide.rest.HTTPHeader.CONTENT_TYPE;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
Expand Down Expand Up @@ -110,9 +110,7 @@ public void setUp() throws Exception {
new ProjectServiceClient(
loaderFactory, requestFactory, dtoFactory, unmarshaller, appContext);

when(appContext.getWsAgentServerApiEndpoint()).thenReturn("http://127.0.0.3/api");

when(loaderFactory.newLoader(any())).thenReturn(messageLoader);
when(loaderFactory.newLoader(any(String.class))).thenReturn(messageLoader);
when(asyncRequest.loader(messageLoader)).thenReturn(asyncRequest);
when(asyncRequest.data(any(String.class))).thenReturn(asyncRequest);
when(asyncRequest.send(unmarshallableItemRef)).thenReturn(itemRefPromise);
Expand Down Expand Up @@ -177,7 +175,7 @@ public void shouldReturnListProjects() {
client.getProjects();

verify(requestFactory).createGetRequest(any());
verify(asyncRequest).header(ACCEPT, MimeType.APPLICATION_JSON);
verify(asyncRequest).header(ACCEPT, APPLICATION_JSON);
verify(unmarshaller).newListUnmarshaller(ProjectConfigDto.class);
verify(asyncRequest).send(unmarshallablePrjsConf);
}
Expand All @@ -189,7 +187,7 @@ public void shouldEncodeUrlAndEstimateProject() {
client.estimate(resourcePath, prjType);

verify(requestFactory).createGetRequest(any());
verify(asyncRequest).header(ACCEPT, MimeType.APPLICATION_JSON);
verify(asyncRequest).header(ACCEPT, APPLICATION_JSON);
verify(loaderFactory).newLoader("Estimating project...");
verify(asyncRequest).loader(messageLoader);
verify(asyncRequest).send(unmarshallbleSourceEstimation);
Expand All @@ -200,7 +198,7 @@ public void shouldEncodeUrlAndResolveProjectSources() {
client.resolveSources(resourcePath);

verify(requestFactory).createGetRequest(any());
verify(asyncRequest).header(ACCEPT, MimeType.APPLICATION_JSON);
verify(asyncRequest).header(ACCEPT, APPLICATION_JSON);
verify(loaderFactory).newLoader("Resolving sources...");
verify(asyncRequest).loader(messageLoader);
verify(unmarshaller).newListUnmarshaller(SourceEstimation.class);
Expand Down Expand Up @@ -229,7 +227,7 @@ public void shouldEncodeUrlAndSearchResourceReferences() {
client.search(expression);

verify(requestFactory).createGetRequest(any());
verify(asyncRequest).header(ACCEPT, MimeType.APPLICATION_JSON);
verify(asyncRequest).header(ACCEPT, APPLICATION_JSON);
verify(loaderFactory).newLoader("Searching...");
verify(asyncRequest).loader(messageLoader);
verify(unmarshaller).newUnmarshaller(ProjectSearchResponseDto.class);
Expand All @@ -243,7 +241,7 @@ public void shouldCreateOneProjectByBatch() {
client.createBatchProjects(configs);

verify(requestFactory).createPostRequest(anyString(), prjsArgCaptor.capture());
verify(asyncRequest).header(ACCEPT, MimeType.APPLICATION_JSON);
verify(asyncRequest).header(ACCEPT, APPLICATION_JSON);
verify(loaderFactory).newLoader("Creating project...");
verify(asyncRequest).loader(messageLoader);
verify(asyncRequest).send(unmarshallablePrjsConf);
Expand All @@ -259,7 +257,7 @@ public void shouldCreateFewProjectByBatch() {
client.createBatchProjects(configs);

verify(requestFactory).createPostRequest(anyString(), prjsArgCaptor.capture());
verify(asyncRequest).header(ACCEPT, MimeType.APPLICATION_JSON);
verify(asyncRequest).header(ACCEPT, APPLICATION_JSON);
verify(loaderFactory).newLoader("Creating the batch of projects...");
verify(asyncRequest).loader(messageLoader);
verify(asyncRequest).send(unmarshallablePrjsConf);
Expand Down Expand Up @@ -355,7 +353,7 @@ public void shouldEncodeUrlAndGetTree() {
client.getTree(resourcePath, 2, true);

verify(requestFactory).createGetRequest(any());
verify(asyncRequest).header(ACCEPT, MimeType.APPLICATION_JSON);
verify(asyncRequest).header(ACCEPT, APPLICATION_JSON);
verify(unmarshaller).newUnmarshaller(TreeElement.class);
verify(asyncRequest).send(unmarshallableTreeElem);
}
Expand All @@ -365,7 +363,7 @@ public void shouldEncodeUrlAndGetItem() {
client.getItem(resourcePath);

verify(requestFactory).createGetRequest(any());
verify(asyncRequest).header(ACCEPT, MimeType.APPLICATION_JSON);
verify(asyncRequest).header(ACCEPT, APPLICATION_JSON);
verify(loaderFactory).newLoader("Getting item...");
verify(unmarshaller).newUnmarshaller(ItemReference.class);
verify(asyncRequest).send(unmarshallableItemRef);
Expand All @@ -376,7 +374,7 @@ public void shouldEncodeUrlAndGetProject() {
client.getProject(Path.valueOf(TEXT));

verify(requestFactory).createGetRequest(any());
verify(asyncRequest).header(ACCEPT, MimeType.APPLICATION_JSON);
verify(asyncRequest).header(ACCEPT, APPLICATION_JSON);
verify(loaderFactory).newLoader("Getting project...");
verify(asyncRequest).loader(messageLoader);
verify(unmarshaller).newUnmarshaller(ProjectConfigDto.class);
Expand All @@ -393,8 +391,8 @@ public void shouldEncodeUrlAndUpdateProject() {
client.updateProject(prjConfig1);

verify(requestFactory).createRequest(eq(PUT), anyString(), eq(prjConfig1), eq(false));
verify(asyncRequest).header(CONTENT_TYPE, MimeType.APPLICATION_JSON);
verify(asyncRequest).header(ACCEPT, MimeType.APPLICATION_JSON);
verify(asyncRequest).header(CONTENT_TYPE, APPLICATION_JSON);
verify(asyncRequest).header(ACCEPT, APPLICATION_JSON);
verify(loaderFactory).newLoader("Updating project...");
verify(asyncRequest).loader(messageLoader);
verify(unmarshaller).newUnmarshaller(ProjectConfigDto.class);
Expand Down
Loading