diff --git a/assembly/assembly-ide-war/pom.xml b/assembly/assembly-ide-war/pom.xml index a9b5bcd9dd..444a322b02 100644 --- a/assembly/assembly-ide-war/pom.xml +++ b/assembly/assembly-ide-war/pom.xml @@ -343,8 +343,7 @@ - - revision = ${revision} + revision = ${revision} buildTime = ${timestamp} version = ${project.version} diff --git a/assembly/assembly-wsagent-war/src/main/webapp/WEB-INF/web.xml b/assembly/assembly-wsagent-war/src/main/webapp/WEB-INF/web.xml index b262c6ad01..a85dfe67d9 100644 --- a/assembly/assembly-wsagent-war/src/main/webapp/WEB-INF/web.xml +++ b/assembly/assembly-wsagent-war/src/main/webapp/WEB-INF/web.xml @@ -21,6 +21,14 @@ org.everrest.websocket.context /ext + + org.eclipse.che.websocket.endpoint + /ws + + + org.eclipse.che.eventbus.endpoint + /eventbus/ + org.eclipse.che.inject.CheBootstrap diff --git a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/web.xml b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/web.xml index c68b5b4af2..495678193b 100644 --- a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/web.xml +++ b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/web.xml @@ -21,6 +21,14 @@ org.everrest.websocket.context /api + + org.eclipse.che.websocket.endpoint + /ws/{ws-id} + + + org.eclipse.che.eventbus.endpoint + /eventbus/ + IDE diff --git a/core/che-core-api-core/src/main/java/org/eclipse/che/everrest/ServerContainerInitializeListener.java b/core/che-core-api-core/src/main/java/org/eclipse/che/everrest/ServerContainerInitializeListener.java index b518bb303e..da8be20950 100644 --- a/core/che-core-api-core/src/main/java/org/eclipse/che/everrest/ServerContainerInitializeListener.java +++ b/core/che-core-api-core/src/main/java/org/eclipse/che/everrest/ServerContainerInitializeListener.java @@ -73,11 +73,15 @@ public class ServerContainerInitializeListener implements ServletContextListener private ServerEndpointConfig wsServerEndpointConfig; private ServerEndpointConfig eventbusServerEndpointConfig; private String websocketContext; + private String websocketEndPoint; + private String eventBusEndPoint; @Override public final void contextInitialized(ServletContextEvent sce) { final ServletContext servletContext = sce.getServletContext(); websocketContext = MoreObjects.firstNonNull(servletContext.getInitParameter("org.everrest.websocket.context"), ""); + websocketEndPoint = MoreObjects.firstNonNull(servletContext.getInitParameter("org.eclipse.che.websocket.endpoint"), ""); + eventBusEndPoint = MoreObjects.firstNonNull(servletContext.getInitParameter("org.eclipse.che.eventbus.endpoint"), ""); webApplicationDeclaredRoles = new WebApplicationDeclaredRoles(servletContext); everrestConfiguration = (EverrestConfiguration)servletContext.getAttribute(EVERREST_CONFIG_ATTRIBUTE); if (everrestConfiguration == null) { @@ -115,7 +119,7 @@ public class ServerContainerInitializeListener implements ServletContextListener final List> decoders = new LinkedList<>(); encoders.add(OutputMessageEncoder.class); decoders.add(InputMessageDecoder.class); - final ServerEndpointConfig endpointConfig = create(CheWSConnection.class, websocketContext+"/ws/{ws-id}") + final ServerEndpointConfig endpointConfig = create(CheWSConnection.class, websocketContext + websocketEndPoint) .configurator(createConfigurator()).encoders(encoders).decoders(decoders).build(); endpointConfig.getUserProperties().put(EVERREST_PROCESSOR_ATTRIBUTE, getEverrestProcessor(servletContext)); endpointConfig.getUserProperties().put(EVERREST_CONFIG_ATTRIBUTE, getEverrestConfiguration(servletContext)); @@ -128,7 +132,7 @@ public class ServerContainerInitializeListener implements ServletContextListener final List> decoders = new LinkedList<>(); encoders.add(OutputMessageEncoder.class); decoders.add(InputMessageDecoder.class); - final ServerEndpointConfig endpointConfig = create(CheWSConnection.class, websocketContext+"/eventbus/") + final ServerEndpointConfig endpointConfig = create(CheWSConnection.class, websocketContext + eventBusEndPoint) .configurator(createConfigurator()).encoders(encoders).decoders(decoders).build(); endpointConfig.getUserProperties().put(EVERREST_PROCESSOR_ATTRIBUTE, getEverrestProcessor(servletContext)); endpointConfig.getUserProperties().put(EVERREST_CONFIG_ATTRIBUTE, getEverrestConfiguration(servletContext)); diff --git a/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/debug/DebuggerServiceClientImpl.java b/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/debug/DebuggerServiceClientImpl.java index 5b4194ae42..6830109ac0 100644 --- a/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/debug/DebuggerServiceClientImpl.java +++ b/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/debug/DebuggerServiceClientImpl.java @@ -66,7 +66,7 @@ public class DebuggerServiceClientImpl implements DebuggerServiceClient { @Override public Promise connect(String debuggerType, Map connectionProperties) { - final String requestUrl = getBaseUrl() + "?type=" + debuggerType; + final String requestUrl = getBaseUrl(null) + "?type=" + debuggerType; return asyncRequestFactory.createPostRequest(requestUrl, null) .header(CONTENT_TYPE, APPLICATION_JSON) .data(JsonHelper.toJson(connectionProperties)) @@ -75,7 +75,7 @@ public class DebuggerServiceClientImpl implements DebuggerServiceClient { @Override public Promise disconnect(String id) { - final String requestUrl = getBaseUrl() + "/" + id; + final String requestUrl = getBaseUrl(id); return asyncRequestFactory.createDeleteRequest(requestUrl) .loader(loaderFactory.newLoader()) .send(); @@ -83,7 +83,7 @@ public class DebuggerServiceClientImpl implements DebuggerServiceClient { @Override public Promise getSessionInfo(String id) { - final String requestUrl = getBaseUrl() + "/" + id; + final String requestUrl = getBaseUrl(id); return asyncRequestFactory.createGetRequest(requestUrl) .send(dtoUnmarshallerFactory.newUnmarshaller(DebugSessionDto.class)); } @@ -95,7 +95,7 @@ public class DebuggerServiceClientImpl implements DebuggerServiceClient { @Override public Promise addBreakpoint(String id, BreakpointDto breakpointDto) { - final String requestUrl = getBaseUrl() + "/" + id + "/breakpoint"; + final String requestUrl = getBaseUrl(id) + "/breakpoint"; return asyncRequestFactory.createPostRequest(requestUrl, breakpointDto) .loader(loaderFactory.newLoader()) .send(); @@ -103,7 +103,7 @@ public class DebuggerServiceClientImpl implements DebuggerServiceClient { @Override public Promise> getAllBreakpoints(String id) { - final String requestUrl = getBaseUrl() + "/" + id + "/breakpoint"; + final String requestUrl = getBaseUrl(id) + "/breakpoint"; return asyncRequestFactory.createGetRequest(requestUrl) .loader(loaderFactory.newLoader()) .send(dtoUnmarshallerFactory.newListUnmarshaller(BreakpointDto.class)); @@ -111,20 +111,20 @@ public class DebuggerServiceClientImpl implements DebuggerServiceClient { @Override public Promise deleteBreakpoint(String id, LocationDto locationDto) { - final String requestUrl = getBaseUrl() + "/" + id + "/breakpoint"; + final String requestUrl = getBaseUrl(id) + "/breakpoint"; final String params = "?target=" + locationDto.getTarget() + "&line=" + locationDto.getLineNumber(); return asyncRequestFactory.createDeleteRequest(requestUrl + params).send(); } @Override public Promise deleteAllBreakpoints(String id) { - final String requestUrl = getBaseUrl() + "/" + id + "/breakpoint"; + final String requestUrl = getBaseUrl(id) + "/breakpoint"; return asyncRequestFactory.createDeleteRequest(requestUrl).send(); } @Override public Promise getStackFrameDump(String id) { - final String requestUrl = getBaseUrl() + "/" + id + "/dump"; + final String requestUrl = getBaseUrl(id) + "/dump"; return asyncRequestFactory.createGetRequest(requestUrl) .loader(loaderFactory.newLoader()) .send(dtoUnmarshallerFactory.newUnmarshaller(StackFrameDumpDto.class)); @@ -137,7 +137,7 @@ public class DebuggerServiceClientImpl implements DebuggerServiceClient { @Override public Promise getValue(String id, VariableDto variableDto) { - final String requestUrl = getBaseUrl() + "/" + id + "/value"; + final String requestUrl = getBaseUrl(id) + "/value"; List path = variableDto.getVariablePath().getPath(); StringBuilder params = new StringBuilder(); @@ -156,7 +156,7 @@ public class DebuggerServiceClientImpl implements DebuggerServiceClient { @Override public Promise setValue(String id, VariableDto variableDto) { - final String requestUrl = getBaseUrl() + "/" + id + "/value"; + final String requestUrl = getBaseUrl(id) + "/value"; return asyncRequestFactory.createPutRequest(requestUrl, variableDto) .loader(loaderFactory.newLoader()) .send(); @@ -179,20 +179,23 @@ public class DebuggerServiceClientImpl implements DebuggerServiceClient { @Override public Promise evaluate(String id, String expression) { - String requestUrl = getBaseUrl() + "/" + id + "/evaluation"; + String requestUrl = getBaseUrl(id) + "/evaluation"; String params = "?expression=" + URL.encodeQueryString(expression); return asyncRequestFactory.createGetRequest(requestUrl + params) .loader(loaderFactory.newLoader()) .send(new StringUnmarshaller()); } - private String getBaseUrl() { - DevMachine devMachine = appContext.getDevMachine(); - return devMachine.getWsAgentBaseUrl() + "/debugger/" + devMachine.getWorkspace(); + private String getBaseUrl(String id) { + final String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/debugger"; + if (id != null) { + return url + "/" + id; + } + return url; } protected Promise performAction(String id, ActionDto actionDto) { - final String requestUrl = getBaseUrl() + "/" + id; + final String requestUrl = getBaseUrl(id); return asyncRequestFactory.createPostRequest(requestUrl, actionDto) .loader(loaderFactory.newLoader()) .send(); diff --git a/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/DevMachine.java b/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/DevMachine.java index 17f21db7e0..9f060b59ea 100644 --- a/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/DevMachine.java +++ b/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/machine/DevMachine.java @@ -71,10 +71,7 @@ public class DevMachine { String url = server.getUrl(); String extUrl = url.substring(url.indexOf(':'), url.length()); final String protocol = Window.Location.getProtocol().equals("https:") ? "wss" : "ws"; - return protocol - + extUrl - + (extUrl.endsWith("/") ? "ws/" : "/ws/") - + getWorkspace(); + return protocol + extUrl + (extUrl.endsWith("/") ? "ws" : "/ws"); } else { //should not be String message = "Reference " + Constants.WSAGENT_REFERENCE + " not found in DevMachine description"; diff --git a/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectImportersServiceClientImpl.java b/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectImportersServiceClientImpl.java index 180375f069..a52df51268 100644 --- a/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectImportersServiceClientImpl.java +++ b/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectImportersServiceClientImpl.java @@ -33,7 +33,7 @@ public class ProjectImportersServiceClientImpl implements ProjectImportersServic @Override public void getProjectImporters(DevMachine devMachine, AsyncRequestCallback callback) { - asyncRequestFactory.createGetRequest(devMachine.getWsAgentBaseUrl() + "/project-importers/" + devMachine.getWorkspace()) + asyncRequestFactory.createGetRequest(devMachine.getWsAgentBaseUrl() + "/project-importers") .header(HTTPHeader.CONTENT_TYPE, MimeType.APPLICATION_JSON) .send(callback); } diff --git a/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectServiceClient.java b/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectServiceClient.java index f64a4d2bcb..a0878f7342 100644 --- a/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectServiceClient.java +++ b/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectServiceClient.java @@ -33,8 +33,8 @@ public interface ProjectServiceClient { /** * Get all projects in current workspace. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param callback * the callback to use for the response */ @@ -43,8 +43,8 @@ public interface ProjectServiceClient { /** * Get all projects in current workspace. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @return a promise that will provide a list of {@link ProjectConfigDto}s, or rejects with an error */ Promise> getProjects(DevMachine devMachine); @@ -52,8 +52,8 @@ public interface ProjectServiceClient { /** * Get project. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to the project to get * @param callback @@ -64,6 +64,8 @@ public interface ProjectServiceClient { /** * Get project. * + * @param devMachine + * of current devMachine * @param path * path to the project * @return a promise that resolves to the {@link ProjectConfigDto}, or rejects with an error @@ -73,8 +75,8 @@ public interface ProjectServiceClient { /** * Get item. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to the item to get * @param callback @@ -85,8 +87,8 @@ public interface ProjectServiceClient { /** * Create project. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param projectConfig * descriptor of the project to create * @param callback @@ -98,8 +100,8 @@ public interface ProjectServiceClient { /** * Estimates if the folder supposed to be project of certain type. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path of the project to estimate * @param projectType @@ -113,8 +115,8 @@ public interface ProjectServiceClient { /** * Gets list of {@link SourceEstimation} for all supposed project types. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path of the project to resolve * @param callback @@ -127,8 +129,8 @@ public interface ProjectServiceClient { /** * Gets list of {@link SourceEstimation} for all supposed project types. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path of the project to resolve * @return a promise that will provide a list of {@code SourceEstimation} for the given {@code workspaceId} and {@code path}, @@ -136,40 +138,11 @@ public interface ProjectServiceClient { */ Promise> resolveSources(DevMachine devMachine, String path); - /** - * Get sub-project. - * - * @param workspaceId - * id of current workspace - * @param path - * path to the parent project - * @param callback - * the callback to use for the response - */ - void getModules(DevMachine devMachine, String path, AsyncRequestCallback> callback); - - /** - * Create sub-project. - * - * @param workspaceId - * id of current workspace - * @param parentProjectPath - * path to the parent project - * @param projectConfig - * descriptor of the project to create - * @param callback - * the callback to use for the response - */ - void createModule(DevMachine devMachine, - String parentProjectPath, - ProjectConfigDto projectConfig, - AsyncRequestCallback callback); - /** * Update project. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to the project to get * @param descriptor @@ -184,8 +157,8 @@ public interface ProjectServiceClient { /** * Update project. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to the project to get * @param descriptor @@ -198,8 +171,8 @@ public interface ProjectServiceClient { /** * Create new file in the specified folder. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param parentPath * path to parent for new file * @param name @@ -214,8 +187,8 @@ public interface ProjectServiceClient { /** * Get file content. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to file * @param callback @@ -226,8 +199,8 @@ public interface ProjectServiceClient { /** * Update file content. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to file * @param content @@ -240,8 +213,8 @@ public interface ProjectServiceClient { /** * Create new folder in the specified folder. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to parent for new folder * @param callback @@ -252,8 +225,8 @@ public interface ProjectServiceClient { /** * Delete item. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to item to delete * @param callback @@ -261,25 +234,11 @@ public interface ProjectServiceClient { */ void delete(DevMachine devMachine, String path, AsyncRequestCallback callback); - /** - * Delete module. - * - * @param workspaceId - * id of current workspace - * @param pathToParent - * path to module's parent - * @param modulePath - * path to module to delete - * @param callback - * the callback to use for the response - */ - void deleteModule(DevMachine devMachine, String pathToParent, String modulePath, AsyncRequestCallback callback); - - /** + /** * Copy an item with new name to the specified target path. Original item name is used if new name isn't set. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to the item to copy * @param newParentPath @@ -294,8 +253,8 @@ public interface ProjectServiceClient { /** * Move an item to the specified target path. Set new name to rename the resource when moving. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to the item to move * @param newParentPath @@ -310,8 +269,8 @@ public interface ProjectServiceClient { /** * Rename and/or set new media type for item. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to the item to rename * @param newName @@ -326,8 +285,8 @@ public interface ProjectServiceClient { /** * Import sources into project. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to the project to import sources * @param force @@ -342,8 +301,8 @@ public interface ProjectServiceClient { /** * Import sources into project. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to the project to import sources * @param force @@ -357,8 +316,8 @@ public interface ProjectServiceClient { /** * Get children for the specified path. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to get its children * @param callback @@ -369,8 +328,8 @@ public interface ProjectServiceClient { /** * Get folders tree starts from the specified path. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param path * path to get its folder tree * @param depth @@ -383,8 +342,8 @@ public interface ProjectServiceClient { /** * Search an item(s) by the specified criteria. * - * @param workspaceId - * id of current workspace + * @param devMachine + * of current devMachine * @param expression * search query expression * @return a promise that will provide a list of {@link ItemReference}s, or rejects with an error diff --git a/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectServiceClientImpl.java b/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectServiceClientImpl.java index cbe1206d7d..87311c6d62 100644 --- a/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectServiceClientImpl.java +++ b/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectServiceClientImpl.java @@ -83,7 +83,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public void getProjects(DevMachine devMachine, AsyncRequestCallback> callback) { - String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace(); + String requestUrl = devMachine.getWsAgentBaseUrl() + "/project"; asyncRequestFactory.createGetRequest(requestUrl) .header(ACCEPT, MimeType.APPLICATION_JSON) .loader(loaderFactory.newLoader("Getting projects...")) @@ -102,7 +102,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public void getProject(DevMachine devMachine, String path, AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + normalizePath(path); + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + normalizePath(path); asyncRequestFactory.createGetRequest(requestUrl) .header(ACCEPT, MimeType.APPLICATION_JSON) .loader(loaderFactory.newLoader("Getting project...")) @@ -111,7 +111,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public Promise getProject(DevMachine devMachine, String path) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + normalizePath(path); + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project" + normalizePath(path); return asyncRequestFactory.createGetRequest(requestUrl) .header(ACCEPT, MimeType.APPLICATION_JSON) .loader(loaderFactory.newLoader("Getting project...")) @@ -120,7 +120,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public void getItem(DevMachine devMachine, String path, AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/item" + normalizePath(path); + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/item" + normalizePath(path); asyncRequestFactory.createGetRequest(requestUrl) .header(ACCEPT, MimeType.APPLICATION_JSON) .loader(loaderFactory.newLoader("Getting item...")) @@ -131,7 +131,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { public void createProject(DevMachine devMachine, ProjectConfigDto projectConfig, AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace(); + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project"; asyncRequestFactory.createPostRequest(requestUrl, projectConfig) .header(ACCEPT, MimeType.APPLICATION_JSON) .loader(loaderFactory.newLoader("Creating project...")) @@ -143,7 +143,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { String path, String projectType, AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/estimate" + normalizePath(path) + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/estimate" + normalizePath(path) + "?type=" + projectType; asyncRequestFactory.createGetRequest(requestUrl) .header(ACCEPT, MimeType.APPLICATION_JSON) @@ -153,7 +153,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public void resolveSources(DevMachine devMachine, String path, AsyncRequestCallback> callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/resolve" + normalizePath(path); + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/resolve" + normalizePath(path); asyncRequestFactory.createGetRequest(requestUrl) .header(ACCEPT, MimeType.APPLICATION_JSON) .loader(loaderFactory.newLoader("Resolving sources...")) @@ -162,7 +162,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public Promise> resolveSources(DevMachine devMachine, String path) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/resolve" + normalizePath(path); + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/resolve" + normalizePath(path); return asyncRequestFactory.createGetRequest(requestUrl) .header(ACCEPT, MimeType.APPLICATION_JSON) .loader(loaderFactory.newLoader("Resolving sources...")) @@ -170,33 +170,12 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { } - @Override - public void getModules(DevMachine devMachine, String path, AsyncRequestCallback> callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/modules" + normalizePath(path); - asyncRequestFactory.createGetRequest(requestUrl) - .header(ACCEPT, MimeType.APPLICATION_JSON) - .loader(loaderFactory.newLoader("Getting modules...")) - .send(callback); - } - - @Override - public void createModule(DevMachine devMachine, - String parentProjectPath, - ProjectConfigDto projectConfig, - AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + normalizePath(parentProjectPath); - asyncRequestFactory.createPostRequest(requestUrl, projectConfig) - .header(ACCEPT, MimeType.APPLICATION_JSON) - .loader(loaderFactory.newLoader("Creating module...")) - .send(callback); - } - @Override public void updateProject(DevMachine devMachine, String path, ProjectConfigDto projectConfig, AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + normalizePath(path); + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project" + normalizePath(path); asyncRequestFactory.createRequest(PUT, requestUrl, projectConfig, false) .header(CONTENT_TYPE, MimeType.APPLICATION_JSON) .header(ACCEPT, MimeType.APPLICATION_JSON) @@ -206,7 +185,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public Promise updateProject(DevMachine devMachine, String path, ProjectConfigDto projectConfig) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + normalizePath(path); + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project" + normalizePath(path); return asyncRequestFactory.createRequest(PUT, requestUrl, projectConfig, false) .header(CONTENT_TYPE, MimeType.APPLICATION_JSON) .header(ACCEPT, MimeType.APPLICATION_JSON) @@ -220,7 +199,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { String name, String content, AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/file" + normalizePath(parentPath) + + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/file" + normalizePath(parentPath) + "?name=" + name; asyncRequestFactory.createPostRequest(requestUrl, null) .data(content) @@ -230,7 +209,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public void getFileContent(DevMachine devMachine, String path, AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/file" + normalizePath(path); + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/file" + normalizePath(path); asyncRequestFactory.createGetRequest(requestUrl) .loader(loaderFactory.newLoader("Loading file content...")) .send(callback); @@ -238,7 +217,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public void updateFile(DevMachine devMachine, String path, String content, AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/file" + normalizePath(path); + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/file" + normalizePath(path); asyncRequestFactory.createRequest(PUT, requestUrl, null, false) .data(content) .loader(loaderFactory.newLoader("Updating file...")) @@ -247,7 +226,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public void createFolder(DevMachine devMachine, String path, AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/folder" + normalizePath(path); + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/folder" + normalizePath(path); asyncRequestFactory.createPostRequest(requestUrl, null) .loader(loaderFactory.newLoader("Creating folder...")) .send(callback); @@ -255,24 +234,15 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public void delete(DevMachine devMachine, String path, AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + normalizePath(path); + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project" + normalizePath(path); asyncRequestFactory.createRequest(DELETE, requestUrl, null, false) .loader(loaderFactory.newLoader("Deleting project...")) .send(callback); } - @Override - public void deleteModule(DevMachine devMachine, String pathToParent, String modulePath, AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/module" + normalizePath(pathToParent) - + "?module=" + modulePath; - asyncRequestFactory.createRequest(DELETE, requestUrl, null, false) - .loader(loaderFactory.newLoader("Deleting module...")) - .send(callback); - } - @Override public void copy(DevMachine devMachine, String path, String newParentPath, String newName, AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/copy" + normalizePath(path) + + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/copy" + normalizePath(path) + "?to=" + newParentPath; final CopyOptions copyOptions = dtoFactory.createDto(CopyOptions.class); @@ -286,7 +256,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public void move(DevMachine devMachine, String path, String newParentPath, String newName, AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/move" + normalizePath(path) + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/move" + normalizePath(path) + "?to=" + newParentPath; final MoveOptions moveOptions = dtoFactory.createDto(MoveOptions.class); @@ -311,7 +281,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { boolean force, SourceStorageDto sourceStorage, RequestCallback callback) { - final StringBuilder requestUrl = new StringBuilder("/project/" + devMachine.getWorkspace()); + final StringBuilder requestUrl = new StringBuilder("/project"); requestUrl.append("/import").append(normalizePath(path)); if (force) { requestUrl.append("?force=true"); @@ -335,7 +305,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { return PromiseHelper.newPromise(new AsyncPromiseHelper.RequestCall() { @Override public void makeCall(final AsyncCallback callback) { - final StringBuilder requestUrl = new StringBuilder("/project/" + devMachine.getWorkspace()); + final StringBuilder requestUrl = new StringBuilder("/project"); requestUrl.append("/import").append(normalizePath(path)); if (force) { requestUrl.append("?force=true"); @@ -388,7 +358,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public void getChildren(DevMachine devMachine, String path, AsyncRequestCallback> callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/children" + normalizePath(path); + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/children" + normalizePath(path); asyncRequestFactory.createGetRequest(requestUrl) .header(ACCEPT, MimeType.APPLICATION_JSON) .send(callback); @@ -396,7 +366,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public void getTree(DevMachine devMachine, String path, int depth, AsyncRequestCallback callback) { - final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/tree" + normalizePath(path) + + final String requestUrl = devMachine.getWsAgentBaseUrl() + "/project/tree" + normalizePath(path) + "?depth=" + depth; asyncRequestFactory.createGetRequest(requestUrl) .header(ACCEPT, MimeType.APPLICATION_JSON) @@ -406,7 +376,7 @@ public class ProjectServiceClientImpl implements ProjectServiceClient { @Override public Promise> search(DevMachine devMachine, QueryExpression expression) { - StringBuilder requestUrl = new StringBuilder(devMachine.getWsAgentBaseUrl() + "/project/" + devMachine.getWorkspace() + "/search"); + StringBuilder requestUrl = new StringBuilder(devMachine.getWsAgentBaseUrl() + "/project/search"); if (expression.getPath() != null) { requestUrl.append(normalizePath(expression.getPath())); } else { diff --git a/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectTypeServiceClientImpl.java b/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectTypeServiceClientImpl.java index 4f7c2420cd..8768973b9f 100644 --- a/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectTypeServiceClientImpl.java +++ b/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/ProjectTypeServiceClientImpl.java @@ -71,7 +71,7 @@ public class ProjectTypeServiceClientImpl implements ProjectTypeServiceClient { } private void getProjectTypes(DevMachine devMachine, @NotNull AsyncCallback> callback) { - final String url = devMachine.getWsAgentBaseUrl() + "/project-type/" + devMachine.getWorkspace(); + final String url = devMachine.getWsAgentBaseUrl() + "/project-type"; asyncRequestFactory.createGetRequest(url) .header(ACCEPT, APPLICATION_JSON) .loader(loaderFactory.newLoader("Getting info about registered project types...")) @@ -89,7 +89,7 @@ public class ProjectTypeServiceClientImpl implements ProjectTypeServiceClient { } private void getProjectType(@NotNull DevMachine devMachine, @NotNull String id, @NotNull AsyncCallback callback) { - final String url = devMachine.getWsAgentBaseUrl() + "/project-type/" + devMachine.getWorkspace() + '/' + id; + final String url = devMachine.getWsAgentBaseUrl() + "/project-type/" + id; asyncRequestFactory.createGetRequest(url) .header(ACCEPT, APPLICATION_JSON) .loader(loaderFactory.newLoader("Getting info about project type...")) diff --git a/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/tree/generic/ProjectNode.java b/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/tree/generic/ProjectNode.java index a4ea7f3e77..763a954737 100644 --- a/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/tree/generic/ProjectNode.java +++ b/core/ide/che-core-ide-api/src/main/java/org/eclipse/che/ide/api/project/tree/generic/ProjectNode.java @@ -169,56 +169,9 @@ public class ProjectNode extends AbstractTreeNode implements S /** {@inheritDoc} */ @Override public void refreshChildren(final AsyncCallback> callback) { - getModules(getData(), new AsyncCallback>() { - @Override - public void onSuccess(final List modules) { - getChildren(getData().getPath(), new AsyncCallback>() { - @Override - public void onSuccess(List childItems) { - setChildren(getChildNodesForItems(childItems, modules)); - callback.onSuccess(ProjectNode.this); - } - - @Override - public void onFailure(Throwable caught) { - callback.onFailure(caught); - } - }); - } - - @Override - public void onFailure(Throwable caught) { - //can be if pom.xml not found - getChildren(getData().getPath(), new AsyncCallback>() { - @Override - public void onSuccess(List childItems) { - callback.onSuccess(ProjectNode.this); - } - - @Override - public void onFailure(Throwable caught) { - callback.onFailure(caught); - } - }); - callback.onFailure(caught); - } - }); } - protected void getModules(ProjectConfigDto project, final AsyncCallback> callback) { - final Unmarshallable> unmarshaller = dtoUnmarshallerFactory.newListUnmarshaller(ProjectConfigDto.class); - projectServiceClient.getModules(appContext.getDevMachine(), project.getPath(), new AsyncRequestCallback>(unmarshaller) { - @Override - protected void onSuccess(List result) { - callback.onSuccess(result); - } - @Override - protected void onFailure(Throwable exception) { - callback.onFailure(exception); - } - }); - } private List> getChildNodesForItems(List childItems, List modules) { List> oldChildren = getChildren(); diff --git a/core/ide/che-core-ide-api/src/main/resources/org/eclipse/che/ide/Api.gwt.xml b/core/ide/che-core-ide-api/src/main/resources/org/eclipse/che/ide/Api.gwt.xml index 4b92809cfe..e3bec5dbb2 100644 --- a/core/ide/che-core-ide-api/src/main/resources/org/eclipse/che/ide/Api.gwt.xml +++ b/core/ide/che-core-ide-api/src/main/resources/org/eclipse/che/ide/Api.gwt.xml @@ -22,6 +22,7 @@ + diff --git a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/actions/DeleteItemAction.java b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/actions/DeleteItemAction.java index b299ff6260..032e397c52 100644 --- a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/actions/DeleteItemAction.java +++ b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/actions/DeleteItemAction.java @@ -79,7 +79,6 @@ public class DeleteItemAction extends AbstractPerspectiveAction implements Promi private final GitServiceClient gitService; private final CoreLocalizationConstant locale; private final NotificationManager notificationManager; - private final String workspaceId; private Callback actionCompletedCallBack; @@ -109,8 +108,6 @@ public class DeleteItemAction extends AbstractPerspectiveAction implements Promi this.gitService = gitServiceClient; this.locale = coreLocalizationConstant; this.notificationManager = notificationManager; - - this.workspaceId = appContext.getWorkspaceId(); } /** {@inheritDoc} */ diff --git a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/actions/DownloadAsZipAction.java b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/actions/DownloadAsZipAction.java index 4cfdf15b83..df43cb31c5 100644 --- a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/actions/DownloadAsZipAction.java +++ b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/actions/DownloadAsZipAction.java @@ -62,7 +62,7 @@ public class DownloadAsZipAction extends AbstractPerspectiveAction { /** {@inheritDoc} */ @Override public void actionPerformed(ActionEvent e) { - String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/project/" + appContext.getWorkspaceId() + "/export/" + getPath(); + String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/project/export/" + getPath(); downloadContainer.setUrl(url); } diff --git a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/actions/RenameItemAction.java b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/actions/RenameItemAction.java index 192402b96a..190460c134 100644 --- a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/actions/RenameItemAction.java +++ b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/actions/RenameItemAction.java @@ -24,7 +24,6 @@ import org.eclipse.che.ide.api.selection.Selection; import org.eclipse.che.ide.api.selection.SelectionAgent; import org.eclipse.che.ide.project.node.FileReferenceNode; import org.eclipse.che.ide.project.node.FolderReferenceNode; -import org.eclipse.che.ide.project.node.ModuleNode; import org.eclipse.che.ide.project.node.ProjectNode; import org.eclipse.che.ide.project.node.ResourceBasedNode; import org.eclipse.che.ide.api.dialogs.CancelCallback; @@ -111,10 +110,9 @@ public class RenameItemAction extends AbstractPerspectiveAction { final Object possibleNode = selection.getHeadElement(); - boolean isModuleNode = possibleNode instanceof ModuleNode; boolean isSupportRename = possibleNode instanceof SupportRename; - boolean enable = !isModuleNode && isSupportRename && ((SupportRename)possibleNode).getRenameProcessor() != null; + boolean enable = isSupportRename && ((SupportRename)possibleNode).getRenameProcessor() != null; e.getPresentation().setEnabled(enable); } diff --git a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java index 04168906cb..a4df114119 100644 --- a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java +++ b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/editor/EditorAgentImpl.java @@ -56,7 +56,6 @@ import org.eclipse.che.ide.project.event.ResourceNodeRenamedEvent; import org.eclipse.che.ide.project.node.FileReferenceNode; import org.eclipse.che.ide.project.node.FolderReferenceNode; import org.eclipse.che.ide.project.node.ItemReferenceBasedNode; -import org.eclipse.che.ide.project.node.ModuleNode; import org.eclipse.che.ide.project.node.NodeManager; import org.eclipse.che.ide.project.node.ResourceBasedNode; import org.eclipse.che.ide.resource.Path; @@ -180,23 +179,6 @@ public class EditorAgentImpl implements EditorAgent { eventBus.fireEvent(new FileEvent(editor.getEditorInput().getFile(), CLOSE)); } } - } else if (node instanceof ModuleNode) { - for (EditorPartPresenter editor : openedEditors) { - VirtualFile virtualFile = editor.getEditorInput().getFile(); - if (moduleHasFile(node.getProjectConfig(), virtualFile)) { - eventBus.fireEvent(new FileEvent(virtualFile, CLOSE)); - } - if (node.getParent() == null || !(node.getParent() instanceof HasStorablePath)) { - return; - } - - String parentPath = ((HasStorablePath)node.getParent()).getStorablePath(); - String openFileName = virtualFile.getName(); - String openFilePath = virtualFile.getPath(); - if (openFilePath.contains(parentPath) && openFileName.equals("modules")) { - eventBus.fireEvent(new FileContentUpdateEvent(openFilePath)); - } - } } } }); @@ -217,15 +199,10 @@ public class EditorAgentImpl implements EditorAgent { public void onResourceRenamedEvent(ResourceNodeRenamedEvent event) { ResourceBasedNode resourceBaseNode = event.getNode(); - if (resourceBaseNode instanceof FolderReferenceNode || resourceBaseNode instanceof ModuleNode) { + if (resourceBaseNode instanceof FolderReferenceNode) { HasStorablePath renamedTargetStoragePath = ((HasStorablePath)resourceBaseNode); final String oldTargetPath = renamedTargetStoragePath.getStorablePath(); - final String newTargetPath; - if (resourceBaseNode instanceof FolderReferenceNode) { - newTargetPath = ((ItemReference)event.getNewDataObject()).getPath(); - } else { - newTargetPath = ((ProjectConfigDto)event.getNewDataObject()).getPath(); - } + final String newTargetPath = ((ItemReference)event.getNewDataObject()).getPath(); final Unmarshallable unmarshaller = unmarshallerFactory.newUnmarshaller(ItemReference.class); updateEditorPartsAfterRename(new LinkedList<>(openedEditors), oldTargetPath, diff --git a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/part/explorer/project/ProjectExplorerPresenter.java b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/part/explorer/project/ProjectExplorerPresenter.java index 9fd7351abe..b0330d791c 100644 --- a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/part/explorer/project/ProjectExplorerPresenter.java +++ b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/part/explorer/project/ProjectExplorerPresenter.java @@ -71,7 +71,6 @@ import org.eclipse.che.ide.project.event.ResourceNodeRenamedEvent.ResourceNodeRe import org.eclipse.che.ide.project.node.FileReferenceNode; import org.eclipse.che.ide.project.node.FolderReferenceNode; import org.eclipse.che.ide.project.node.ItemReferenceBasedNode; -import org.eclipse.che.ide.project.node.ModuleNode; import org.eclipse.che.ide.project.node.NodeManager; import org.eclipse.che.ide.project.node.ProjectNode; import org.eclipse.che.ide.projecttype.wizard.presenter.ProjectWizardPresenter; @@ -398,13 +397,8 @@ public class ProjectExplorerPresenter extends BasePresenter implements ActionDel editorAgentProvider.get().updateEditorNode(node.getData().getPath(), (FileReferenceNode)wrapped); } - node.setData(newDTO); - } else if (event.getNode() instanceof ModuleNode) { - ProjectConfigDto newDTO = (ProjectConfigDto)event.getNewDataObject(); - ModuleNode node = (ModuleNode)event.getNode(); node.setData(newDTO); } - if (!view.reIndex(oldNodeId, event.getNode())) { Log.info(getClass(), "Node wasn't re-indexed"); } diff --git a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/project/node/ModuleNode.java b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/project/node/ModuleNode.java deleted file mode 100644 index 5096b2cb84..0000000000 --- a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/project/node/ModuleNode.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.project.node; - -import com.google.inject.Inject; -import com.google.inject.assistedinject.Assisted; -import com.google.web.bindery.event.shared.EventBus; - -import org.eclipse.che.api.promises.client.Promise; -import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; -import org.eclipse.che.commons.annotation.Nullable; -import org.eclipse.che.ide.api.project.node.HasStorablePath; -import org.eclipse.che.ide.api.project.node.Node; -import org.eclipse.che.ide.api.project.node.resource.DeleteProcessor; -import org.eclipse.che.ide.api.project.node.resource.RenameProcessor; -import org.eclipse.che.ide.api.project.node.settings.NodeSettings; -import org.eclipse.che.ide.project.node.resource.ModuleConfigProcessor; -import org.eclipse.che.ide.ui.smartTree.presentation.NodePresentation; - -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * @author Vlad Zhukovskiy - * @author Dmitry Shnurenko - * @deprecated will be removed after release GA - */ -@Deprecated -public class ModuleNode extends ResourceBasedNode implements HasStorablePath { - - private final ModuleConfigProcessor resourceProcessor; - private final ProjectConfigDto projectConfigDto; - - @Inject - public ModuleNode(@Assisted ProjectConfigDto projectConfigDto, - @Assisted NodeSettings nodeSettings, - EventBus eventBus, - NodeManager nodeManager, - ModuleConfigProcessor resourceProcessor) { - super(projectConfigDto, projectConfigDto, nodeSettings, eventBus, nodeManager); - this.resourceProcessor = resourceProcessor; - this.projectConfigDto = projectConfigDto; - } - - @NotNull - @Override - protected Promise> getChildrenImpl() { - return nodeManager.getChildren(projectConfigDto.getPath(), getProjectConfig(), getSettings()); - } - - @Override - public void updatePresentation(@NotNull NodePresentation presentation) { - presentation.setPresentableText(getData().getName()); - presentation.setPresentableIcon(nodeManager.getNodesResources().moduleFolder()); - presentation.setPresentableTextCss("font-weight:bold"); - } - - @NotNull - @Override - public String getName() { - return getData().getName(); - } - - @Override - public boolean isLeaf() { - return false; - } - - @Nullable - @Override - public DeleteProcessor getDeleteProcessor() { - return resourceProcessor; - } - - @Nullable - @Override - public RenameProcessor getRenameProcessor() { - return resourceProcessor; - } - - @NotNull - @Override - public String getStorablePath() { - if (getParent() == null || !(getParent() instanceof HasStorablePath)) { - return getData().getPath(); - } - - return ((HasStorablePath)getParent()).getStorablePath() + "/" + getData().getName(); - } - - @Override - public boolean supportGoInto() { - return true; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof HasStorablePath)) return false; - - HasStorablePath that = (HasStorablePath)o; - - if (!getStorablePath().equals(that.getStorablePath())) return false; - - return true; - } - - @Override - public int hashCode() { - return getStorablePath().hashCode(); - } -} diff --git a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/project/node/NodeManager.java b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/project/node/NodeManager.java index 0679548b27..62d1dd966b 100644 --- a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/project/node/NodeManager.java +++ b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/project/node/NodeManager.java @@ -325,7 +325,7 @@ public class NodeManager { @Deprecated public static boolean isProjectOrModuleNode(Node node) { - return node instanceof ProjectNode || node instanceof ModuleNode; + return node instanceof ProjectNode; } protected Function> self() { diff --git a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/project/node/resource/ModuleConfigProcessor.java b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/project/node/resource/ModuleConfigProcessor.java deleted file mode 100644 index f171968aa2..0000000000 --- a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/project/node/resource/ModuleConfigProcessor.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.ide.project.node.resource; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.inject.Inject; -import com.google.web.bindery.event.shared.EventBus; - -import org.eclipse.che.ide.api.project.ProjectServiceClient; -import org.eclipse.che.api.promises.client.Promise; -import org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper; -import org.eclipse.che.api.promises.client.js.JsPromiseError; -import org.eclipse.che.api.promises.client.js.Promises; -import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; -import org.eclipse.che.ide.api.app.AppContext; -import org.eclipse.che.ide.api.project.node.HasDataObject; -import org.eclipse.che.ide.api.project.node.HasProjectConfig; -import org.eclipse.che.ide.api.project.node.HasStorablePath; -import org.eclipse.che.ide.api.project.node.Node; -import org.eclipse.che.ide.project.node.ModuleNode; -import org.eclipse.che.ide.rest.AsyncRequestCallback; -import org.eclipse.che.ide.rest.DtoUnmarshallerFactory; - -/** - * @author Dmitry Shnurenko - * @deprecated will be removed after release GA - */ -@Deprecated -public class ModuleConfigProcessor extends AbstractResourceProcessor { - - private final AppContext appContext; - - @Inject - public ModuleConfigProcessor(EventBus eventBus, - ProjectServiceClient projectServiceClient, - AppContext appContext, - DtoUnmarshallerFactory unmarshallerFactory) { - super(eventBus, projectServiceClient, unmarshallerFactory); - this.appContext = appContext; - } - - - @Override - public Promise delete(final HasDataObject node) { - if (node instanceof ModuleNode) { - Node parent = ((ModuleNode)node).getParent(); - if (!(parent instanceof HasProjectConfig)) { - return Promises.reject(JsPromiseError.create("Failed to search parent project descriptor")); - } - - final String parentPath = ((HasProjectConfig)parent).getProjectConfig().getPath(); - final String modulePath = node.getData().getPath(); - - return AsyncPromiseHelper.createFromAsyncRequest(new AsyncPromiseHelper.RequestCall() { - @Override - public void makeCall(final AsyncCallback callback) { - projectService.deleteModule(appContext.getDevMachine(), parentPath, modulePath, new AsyncRequestCallback() { - @Override - protected void onSuccess(Void result) { - callback.onSuccess(node.getData()); - } - - @Override - protected void onFailure(Throwable exception) { - callback.onFailure(exception); - } - }); - } - }); - } - return Promises.reject(JsPromiseError.create("Internal error")); - } - - @Override - public Promise rename(HasStorablePath parent, - HasDataObject node, - String newName) { - return Promises.reject(JsPromiseError.create("")); - } -} diff --git a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/projecttype/wizard/ProjectWizard.java b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/projecttype/wizard/ProjectWizard.java index f99ccc0939..4b9542068b 100644 --- a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/projecttype/wizard/ProjectWizard.java +++ b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/projecttype/wizard/ProjectWizard.java @@ -63,7 +63,6 @@ public class ProjectWizard extends AbstractWizard { private final SelectionAgent selectionAgent; private final ProjectImporter importer; private final ProjectUpdater updater; - private final String workspaceId; private final CoreLocalizationConstant locale; @Inject @@ -92,7 +91,6 @@ public class ProjectWizard extends AbstractWizard { this.importer = importer; this.updater = updater; this.locale = locale; - this.workspaceId = appContext.getWorkspaceId(); context.put(WIZARD_MODE_KEY, mode.toString()); context.put(PROJECT_NAME_KEY, dataObject.getName()); diff --git a/core/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projectimport/wizard/ProjectImporterTest.java b/core/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projectimport/wizard/ProjectImporterTest.java index c01a564b9e..62758f9fba 100644 --- a/core/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projectimport/wizard/ProjectImporterTest.java +++ b/core/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projectimport/wizard/ProjectImporterTest.java @@ -87,7 +87,6 @@ public class ProjectImporterTest { @Before public void setUp() { - when(appContext.getWorkspaceId()).thenReturn(ID); when(appContext.getDevMachine()).thenReturn(devMachine); when(devMachine.getWsAgentBaseUrl()).thenReturn("/ext"); when(projectConfig.getName()).thenReturn(PROJECT_NAME); diff --git a/core/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projectimport/wizard/ProjectUpdaterTest.java b/core/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projectimport/wizard/ProjectUpdaterTest.java index 63bc031beb..1167c07d9b 100644 --- a/core/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projectimport/wizard/ProjectUpdaterTest.java +++ b/core/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projectimport/wizard/ProjectUpdaterTest.java @@ -104,7 +104,6 @@ public class ProjectUpdaterTest { @Before @SuppressWarnings("unchecked") public void setUp() { - when(appContext.getWorkspaceId()).thenReturn(WORKSPACE_ID); when(appContext.getWorkspace()).thenReturn(usersWorkspaceDtoMock); when(appContext.getDevMachine()).thenReturn(devMachine); when(devMachine.getWsAgentBaseUrl()).thenReturn("/ext"); diff --git a/core/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projecttype/wizard/ProjectWizardTest.java b/core/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projecttype/wizard/ProjectWizardTest.java index 6dddf64028..7132cf1104 100644 --- a/core/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projecttype/wizard/ProjectWizardTest.java +++ b/core/ide/che-core-ide-app/src/test/java/org/eclipse/che/ide/projecttype/wizard/ProjectWizardTest.java @@ -124,7 +124,6 @@ public class ProjectWizardTest { @Before public void setUp() { - when(appContext.getWorkspaceId()).thenReturn(WORKSPACE_ID); when(appContext.getDevMachine()).thenReturn(devMachine); when(dataObject.getName()).thenReturn(PROJECT_NAME); when(dataObject.getSource()).thenReturn(storage); diff --git a/dashboard/src/app/projects/create-project/create-project.controller.js b/dashboard/src/app/projects/create-project/create-project.controller.js index edb78db30f..bcb7a2559c 100755 --- a/dashboard/src/app/projects/create-project/create-project.controller.js +++ b/dashboard/src/app/projects/create-project/create-project.controller.js @@ -472,7 +472,7 @@ export class CreateProjectCtrl { let deferredResolve = this.$q.defer(); let deferredResolvePromise = deferredResolve.promise; - let importPromise = this.cheAPI.getWorkspace().getWorkspaceAgent(workspaceId).getProject().importProject(workspaceId, projectName, projectData.source); + let importPromise = this.cheAPI.getWorkspace().getWorkspaceAgent(workspaceId).getProject().importProject(projectName, projectData.source); importPromise.then(() => { // add commands if there are some that have been defined @@ -528,20 +528,20 @@ export class CreateProjectCtrl { let projectTypeService = this.cheAPI.getWorkspace().getWorkspaceAgent(workspaceId).getProjectType(); if (projectDetails.type) { - let updateProjectPromise = projectService.updateProject(workspaceId, projectName, projectDetails); + let updateProjectPromise = projectService.updateProject(projectName, projectDetails); updateProjectPromise.then(() => { deferredResolve.resolve(); }); return; } - let resolvePromise = projectService.fetchResolve(workspaceId, projectName); + let resolvePromise = projectService.fetchResolve(projectName); resolvePromise.then(() => { - let resultResolve = projectService.getResolve(workspaceId, projectName); + let resultResolve = projectService.getResolve(projectName); // get project-types - let fetchTypePromise = projectTypeService.fetchTypes(workspaceId); + let fetchTypePromise = projectTypeService.fetchTypes(); fetchTypePromise.then(() => { - let projectTypesByCategory = projectTypeService.getProjectTypesIDs(workspaceId); + let projectTypesByCategory = projectTypeService.getProjectTypesIDs(); // now try the estimate for each source let deferredEstimate = this.$q.defer(); let deferredEstimatePromise = deferredResolve.promise; @@ -559,7 +559,7 @@ export class CreateProjectCtrl { let projectType = projectTypesByCategory.get(sourceResolve.type); if (projectType.primaryable) { // call estimate - let estimatePromise = projectService.fetchEstimate(workspaceId, projectName, sourceResolve.type); + let estimatePromise = projectService.fetchEstimate(projectName, sourceResolve.type); estimatePromises.push(estimatePromise); estimateTypes.push(sourceResolve.type); } @@ -573,7 +573,7 @@ export class CreateProjectCtrl { var firstMatchingType; var firstMatchingResult; estimateTypes.forEach((type) => { - let resultEstimate = projectService.getEstimate(workspaceId, projectName, type); + let resultEstimate = projectService.getEstimate(projectName, type); // add attributes // there is a matching estimate if (Object.keys(resultEstimate.attributes).length > 0 && 'java' !== type && !firstMatchingType) { @@ -585,7 +585,7 @@ export class CreateProjectCtrl { if (firstMatchingType) { projectDetails.attributes = firstMatchingResult; projectDetails.type = firstMatchingType; - let updateProjectPromise = projectService.updateProject(workspaceId, projectName, projectDetails); + let updateProjectPromise = projectService.updateProject(projectName, projectDetails); updateProjectPromise.then(() => { deferredResolve.resolve(); }); diff --git a/dashboard/src/app/projects/list-projects/list-projects.controller.js b/dashboard/src/app/projects/list-projects/list-projects.controller.js index 033d495347..10c5f030cd 100644 --- a/dashboard/src/app/projects/list-projects/list-projects.controller.js +++ b/dashboard/src/app/projects/list-projects/list-projects.controller.js @@ -192,7 +192,7 @@ export class ListProjectsCtrl { let wsagent = this.cheAPI.getWorkspace().getWorkspaceAgent(workspaceId); if (wsagent) { - return wsagent.getProject().remove(workspaceId, projectPath); + return wsagent.getProject().remove(projectPath); } else { return this.cheAPI.getWorkspace().deleteProject(workspaceId, projectPath); } diff --git a/dashboard/src/app/projects/project-details/project-details.controller.js b/dashboard/src/app/projects/project-details/project-details.controller.js index 7429976cf8..bbbfa4d4b7 100644 --- a/dashboard/src/app/projects/project-details/project-details.controller.js +++ b/dashboard/src/app/projects/project-details/project-details.controller.js @@ -60,7 +60,7 @@ export class ProjectDetailsCtrl { fetchProjectDetails() { this.projectService = this.cheAPI.getWorkspace().getWorkspaceAgent(this.workspaceId).getProject(); - if (!this.projectService.getProjectDetailsByKey(this.workspaceId, this.projectPath)) { + if (!this.projectService.getProjectDetailsByKey(this.projectPath)) { let promise = this.projectService.fetchProjectDetails(this.workspaceId, this.projectPath); promise.then(() => { this.updateProjectDetails(); @@ -91,7 +91,7 @@ export class ProjectDetailsCtrl { } updateProjectDetails() { - this.projectDetails = this.projectService.getProjectDetailsByKey(this.workspaceId, this.projectPath); + this.projectDetails = this.projectService.getProjectDetailsByKey(this.projectPath); this.projectName = angular.copy(this.projectDetails.name); this.projectDescription = angular.copy(this.projectDetails.description); this.loading = false; @@ -111,7 +111,7 @@ export class ProjectDetailsCtrl { this.cheNotification.showInfo('Project information successfully updated.'); this.updateLocation(); if (this.isNameChanged()) { - this.projectService.fetchProjectDetails(this.workspaceId, this.projectPath).then(() => { + this.projectService.fetchProjectDetails(this.projectPath).then(() => { this.updateProjectDetails(); }); } else { @@ -147,10 +147,10 @@ export class ProjectDetailsCtrl { } if (this.isNameChanged()) { - let promise = this.projectService.rename(this.projectDetails.workspaceId, this.projectName, this.projectDetails.name); + let promise = this.projectService.rename(this.projectName, this.projectDetails.name); promise.then(() => { - this.projectService.removeProjectDetailsByKey(this.workspaceId, this.projectPath); + this.projectService.removeProjectDetailsByKey(this.projectPath); if (!this.isDescriptionChanged()) { this.cheNotification.showInfo('Project information successfully updated.'); this.updateLocation(); @@ -181,7 +181,7 @@ export class ProjectDetailsCtrl { .targetEvent(event); this.$mdDialog.show(confirm).then(() => { // remove it ! - let promise = this.projectService.remove(this.projectDetails.workspaceId, this.projectDetails.name); + let promise = this.projectService.remove(this.projectDetails.name); promise.then(() => { this.$location.path('/projects'); }, (error) => { diff --git a/dashboard/src/app/projects/project-details/repository/project-repository.controller.js b/dashboard/src/app/projects/project-details/repository/project-repository.controller.js index 6c881e366f..7a388de9b8 100644 --- a/dashboard/src/app/projects/project-details/repository/project-repository.controller.js +++ b/dashboard/src/app/projects/project-details/repository/project-repository.controller.js @@ -33,15 +33,15 @@ export class ProjectRepositoryCtrl { this.wsagent = this.cheAPI.getWorkspace().getWorkspaceAgent(workspaceId); - if (!this.wsagent.getProject().getProjectDetailsByKey(workspaceId, projectPath)) { + if (!this.wsagent.getProject().getProjectDetailsByKey(projectPath)) { let promise = this.wsagent.getProject().fetchProjectDetails(workspaceId, projectPath); promise.then(() => { - var projectDetails = this.wsagent.getProject().getProjectDetailsByKey(workspaceId, projectPath); + var projectDetails = this.wsagent.getProject().getProjectDetailsByKey(projectPath); this.updateRepositories(projectDetails); }); } else { - var projectDetails = this.wsagent.getProject().getProjectDetailsByKey(workspaceId, projectPath); + var projectDetails = this.wsagent.getProject().getProjectDetailsByKey(projectPath); this.updateRepositories(projectDetails); } @@ -68,25 +68,25 @@ export class ProjectRepositoryCtrl { if (projectDetails.mixins.indexOf(gitMixinId) !== -1) { //update git local url - if (!this.wsagent.getGit().getLocalUrlByKey(projectDetails.workspaceId, projectDetails.path)) { - let promise = this.wsagent.getGit().fetchLocalUrl(projectDetails.workspaceId, projectDetails.path); + if (!this.wsagent.getGit().getLocalUrlByKey(projectDetails.path)) { + let promise = this.wsagent.getGit().fetchLocalUrl(projectDetails.path); promise.then(() => { - this.localGitRepository = this.wsagent.getGit().getLocalUrlByKey(projectDetails.workspaceId, projectDetails.path); + this.localGitRepository = this.wsagent.getGit().getLocalUrlByKey(projectDetails.path); }); } else { - this.localGitRepository = this.wsagent.getGit().getLocalUrlByKey(projectDetails.workspaceId, projectDetails.path); + this.localGitRepository = this.wsagent.getGit().getLocalUrlByKey(projectDetails.path); } //update git remote urls - if (!this.wsagent.getGit().getRemoteUrlArrayByKey(projectDetails.workspaceId, projectDetails.path)) { - let promise = this.wsagent.getGit().fetchRemoteUrlArray(projectDetails.workspaceId, projectDetails.path); + if (!this.wsagent.getGit().getRemoteUrlArrayByKey(projectDetails.path)) { + let promise = this.wsagent.getGit().fetchRemoteUrlArray(projectDetails.path); promise.then(() => { - this.remoteGitRepositories = this.wsagent.getGit().getRemoteUrlArrayByKey(projectDetails.workspaceId, projectDetails.path); + this.remoteGitRepositories = this.wsagent.getGit().getRemoteUrlArrayByKey(projectDetails.path); }); } else { - this.remoteGitRepositories = this.wsagent.getGit().getRemoteUrlArrayByKey(projectDetails.workspaceId, projectDetails.path); + this.remoteGitRepositories = this.wsagent.getGit().getRemoteUrlArrayByKey(projectDetails.path); } } diff --git a/dashboard/src/app/workspaces/workspace-details/export-workspace/dialog/export-workspace-dialog.controller.js b/dashboard/src/app/workspaces/workspace-details/export-workspace/dialog/export-workspace-dialog.controller.js index bb001dbe46..240c2cbe24 100644 --- a/dashboard/src/app/workspaces/workspace-details/export-workspace/dialog/export-workspace-dialog.controller.js +++ b/dashboard/src/app/workspaces/workspace-details/export-workspace/dialog/export-workspace-dialog.controller.js @@ -184,11 +184,11 @@ export class ExportWorkspaceDialogController { let deferred = this.$q.defer(); let deferredPromise = deferred.promise; projectPromises.push(deferredPromise); - let importProjectPromise = remoteProjectAPI.importProject(workspace.id, project.name, project.source); + let importProjectPromise = remoteProjectAPI.importProject(project.name, project.source); importProjectPromise.then(() => { this.exportInCloudSteps += 'Importing project ' + project.name + '...
'; - let updateProjectPromise = remoteProjectAPI.updateProject(workspace.id, project.name, project); + let updateProjectPromise = remoteProjectAPI.updateProject(project.name, project); updateProjectPromise.then(() => { deferred.resolve(workspace); }, (error) => { diff --git a/dashboard/src/components/api/che-git.js b/dashboard/src/components/api/che-git.js index c33da4d6ae..ac505948f3 100644 --- a/dashboard/src/components/api/che-git.js +++ b/dashboard/src/components/api/che-git.js @@ -29,19 +29,17 @@ export class CheGit { // remote call this.remoteGitAPI = this.$resource(wsagentPath + '/git', {}, { - getLocalUrl: {method: 'GET', url: wsagentPath + '/git/:workspaceId/read-only-url?projectPath=:path', isArray: false}, - getRemoteUrlArray: {method: 'POST', url: wsagentPath + '/git/:workspaceId/remote-list?projectPath=:path', isArray: true} + getLocalUrl: {method: 'GET', url: wsagentPath + '/git/read-only-url?projectPath=:path', isArray: false}, + getRemoteUrlArray: {method: 'POST', url: wsagentPath + '/git/remote-list?projectPath=:path', isArray: true} }); } /** * Ask for loading local repository url for the given project - * @param workspaceId * @param projectPath */ - fetchLocalUrl(workspaceId, projectPath) { + fetchLocalUrl(projectPath) { let promise = this.remoteGitAPI.getLocalUrl({ - workspaceId: workspaceId, path: projectPath }, null).$promise; @@ -58,7 +56,7 @@ export class CheGit { } }); } - this.localGitUrlsMap.set(workspaceId + projectPath, localUrl); + this.localGitUrlsMap.set(projectPath, localUrl); }); return parsedResultPromise; @@ -66,31 +64,29 @@ export class CheGit { /** * Ask for loading remote repository urls for the given project - * @param workspaceId * @param projectPath */ - fetchRemoteUrlArray(workspaceId, projectPath) { + fetchRemoteUrlArray(projectPath) { var data = {remote: null, verbose: true, attributes: {}}; let promise = this.remoteGitAPI.getRemoteUrlArray({ - workspaceId: workspaceId, path: projectPath }, data).$promise; // check if it was OK or not let parsedResultPromise = promise.then((remoteArray) => { - this.remoteGitUrlArraysMap.set(workspaceId + projectPath, remoteArray); + this.remoteGitUrlArraysMap.set(projectPath, remoteArray); }); return parsedResultPromise; } - getRemoteUrlArrayByKey(workspaceId, projectPath) { - return this.remoteGitUrlArraysMap.get(workspaceId + projectPath); + getRemoteUrlArrayByKey(projectPath) { + return this.remoteGitUrlArraysMap.get(projectPath); } - getLocalUrlByKey(workspaceId, projectPath) { - return this.localGitUrlsMap.get(workspaceId + projectPath); + getLocalUrlByKey(projectPath) { + return this.localGitUrlsMap.get(projectPath); } } diff --git a/dashboard/src/components/api/che-git.spec.js b/dashboard/src/components/api/che-git.spec.js index e58454e452..ce4da8205a 100644 --- a/dashboard/src/components/api/che-git.spec.js +++ b/dashboard/src/components/api/che-git.spec.js @@ -93,16 +93,16 @@ describe('CheGit', function () { cheBackend.getLocalGitUrl(workspaceId, encodeURIComponent(projectPath)); // fetch localUrl - factory.fetchLocalUrl(workspaceId, projectPath); + factory.fetchLocalUrl(projectPath); // expecting GETs - httpBackend.expectGET(agentUrl + '/git/' + workspaceId + '/read-only-url?projectPath=' + encodeURIComponent(projectPath)); + httpBackend.expectGET(agentUrl + '/git/read-only-url?projectPath=' + encodeURIComponent(projectPath)); // flush command httpBackend.flush(); // now, check url - var url = factory.getLocalUrlByKey(workspaceId, projectPath); + var url = factory.getLocalUrlByKey(projectPath); // check local url expect(localUrl).toEqual(url); @@ -148,16 +148,16 @@ describe('CheGit', function () { cheBackend.getRemoteGitUrlArray(workspaceId, encodeURIComponent(projectPath)); // fetch localUrl - factory.fetchRemoteUrlArray(workspaceId, projectPath); + factory.fetchRemoteUrlArray(projectPath); // expecting POSTs - httpBackend.expectPOST(agentUrl + '/git/' + workspaceId + '/remote-list?projectPath=' + encodeURIComponent(projectPath)); + httpBackend.expectPOST(agentUrl + '/git/remote-list?projectPath=' + encodeURIComponent(projectPath)); // flush command httpBackend.flush(); // now, check url - var urlArray = factory.getRemoteUrlArrayByKey(workspaceId, projectPath); + var urlArray = factory.getRemoteUrlArrayByKey(projectPath); remoteArray.sort(function (a, b) { if (a.name > b.name) { return 1; diff --git a/dashboard/src/components/api/che-project-type.js b/dashboard/src/components/api/che-project-type.js index ecf874443f..193a40496c 100644 --- a/dashboard/src/components/api/che-project-type.js +++ b/dashboard/src/components/api/che-project-type.js @@ -25,44 +25,28 @@ export class CheProjectType { this.$resource = $resource; // types per category per workspace ID : workspace ID ==> map - this.typesIdPerWorkspace = new Map(); + this.typesIds = new Map(); // project types per workspace ID - this.typesWorkspaces = new Map(); + this.workspaceTypes = []; // remote call - this.remoteProjectTypeAPI = this.$resource(wsagentPath + '/project-type/:workspaceId'); + this.remoteProjectTypeAPI = this.$resource(wsagentPath + '/project-type'); } /** * Fetch the project types */ - fetchTypes(workspaceId) { + fetchTypes() { var defer = this.$q.defer(); - let promise = this.remoteProjectTypeAPI.query({workspaceId: workspaceId}).$promise; + let promise = this.remoteProjectTypeAPI.query().$promise; let updatedPromise = promise.then((projectTypes) => { - var idProjectTypesMap = this.typesIdPerWorkspace.get(workspaceId); - if (!idProjectTypesMap) { - idProjectTypesMap = new Map(); - this.typesIdPerWorkspace.set(workspaceId, idProjectTypesMap); - } - - var typesWorkspace = this.typesWorkspaces.get(workspaceId); - if (!typesWorkspace) { - typesWorkspace = []; - this.typesWorkspaces.set(workspaceId, typesWorkspace); - } - // reset global list - typesWorkspace.length = 0; + this.workspaceTypes = projectTypes; projectTypes.forEach((projectType) => { - var id = projectType.id; - // add in map - idProjectTypesMap.set(id, projectType); - // add in global list - typesWorkspace.push(projectType); + this.typesIds.set(projectType.id, projectType); }); defer.resolve(); }, (error) => { @@ -76,25 +60,20 @@ export class CheProjectType { return defer.promise; } - - /** * Gets all project types * @returns {Array} */ - getAllProjectTypes(workspaceId) { - let val = this.typesWorkspaces.get(workspaceId); - return !val ? [] : val; + getAllProjectTypes() { + return this.workspaceTypes; } /** * The types per category * @returns {CheProjectType.typesPerCategory|*} */ - getProjectTypesIDs(workspaceId) { - let val = this.typesIdPerWorkspace.get(workspaceId); - return !val ? {} : val; + getProjectTypesIDs() { + return this.typesIds; } - } diff --git a/dashboard/src/components/api/che-project-type.spec.js b/dashboard/src/components/api/che-project-type.spec.js index e44ebd5a65..d4d3e2680c 100644 --- a/dashboard/src/components/api/che-project-type.spec.js +++ b/dashboard/src/components/api/che-project-type.spec.js @@ -99,25 +99,25 @@ describe('CheProjectType', function(){ var factory = workspace.getWorkspaceAgent(workspaceId).getProjectType(); // no types now on factory - expect(factory.getAllProjectTypes(workspaceId).length).toEqual(0); + expect(factory.getAllProjectTypes().length).toEqual(0); // fetch types - factory.fetchTypes(workspaceId); + factory.fetchTypes(); // expecting a GET - httpBackend.expectGET(agentUrl + '/project-type/' + workspaceId); + httpBackend.expectGET(agentUrl + '/project-type'); // flush command httpBackend.flush(); - expect(factory.getAllProjectTypes(workspaceId).length).toEqual(2); + expect(factory.getAllProjectTypes().length).toEqual(2); // now, check types - var projectTypes = factory.getAllProjectTypes(workspaceId); + var projectTypes = factory.getAllProjectTypes(); // check we have 2 PT expect(projectTypes.length).toEqual(2); - var typesIds = factory.getProjectTypesIDs(workspaceId); + var typesIds = factory.getProjectTypesIDs(); expect(typesIds.size).toEqual(2); var firstType = typesIds.get('maven'); diff --git a/dashboard/src/components/api/che-project.js b/dashboard/src/components/api/che-project.js index 972dab09b0..c46d970b54 100644 --- a/dashboard/src/components/api/che-project.js +++ b/dashboard/src/components/api/che-project.js @@ -30,54 +30,52 @@ export class CheProject { this.$q = $q; - // project details map with key = workspaceId+projectPath + // project details map with key projectPath this.projectDetailsMap = new Map(); - // map of estimate per workspace Id + project + project type: --> Estimate + // map of estimate per project + project type: --> Estimate this.estimateMap = new Map(); - // map of resolve per workspace Id/project --> Source Estimation + // map of resolve per project --> Source Estimation this.resolveMap = new Map(); // remote call - this.remoteProjectsAPI = this.$resource(wsagentPath + '/project/:workspaceId', {workspaceId: '@id'}, { - import: {method: 'POST', url: wsagentPath + '/project/:workspaceId/import/:path'}, - create: {method: 'POST', url: wsagentPath + '/project/:workspaceId?name=:path'}, - details: {method: 'GET', url: wsagentPath + '/project/:workspaceId/:path'}, - estimate: {method: 'GET', url: wsagentPath + '/project/:workspaceId/estimate/:path?type=:type'}, - rename: {method: 'POST', url: wsagentPath + '/project/:workspaceId/rename/:path?name=:name'}, - remove: {method: 'DELETE', url: wsagentPath + '/project/:workspaceId/:path'}, - resolve: {method: 'GET', url: wsagentPath + '/project/:workspaceId/resolve/:path', isArray: true}, - update: {method: 'PUT', url: wsagentPath + '/project/:workspaceId/:path'} + this.remoteProjectsAPI = this.$resource(wsagentPath + '/project', {}, { + import: {method: 'POST', url: wsagentPath + '/project/import/:path'}, + create: {method: 'POST', url: wsagentPath + '/project?name=:path'}, + details: {method: 'GET', url: wsagentPath + '/project/:path'}, + estimate: {method: 'GET', url: wsagentPath + '/project/estimate/:path?type=:type'}, + rename: {method: 'POST', url: wsagentPath + '/project/rename/:path?name=:name'}, + remove: {method: 'DELETE', url: wsagentPath + '/project/:path'}, + resolve: {method: 'GET', url: wsagentPath + '/project/resolve/:path', isArray: true}, + update: {method: 'PUT', url: wsagentPath + '/project/:path'} }); } /** - * Import a project based located on the given workspace id and path - * @param workspaceId the workspace ID to use + * Import a project based located on the given path * @param path the path of the project * @param data the project body description * @returns {$promise|*|T.$promise} */ - importProject(workspaceId, path, data) { + importProject(path, data) { // remove unused description because we cannot set project description without project type if ((!data.type || data.type.length === 0) && data.description) { delete(data.description); } - let promise = this.remoteProjectsAPI.import({workspaceId: workspaceId, path: path}, data).$promise; + let promise = this.remoteProjectsAPI.import({path: path}, data).$promise; return promise; } /** - * Create a project based located on the given workspace id and path - * @param workspaceId the workspace ID to use + * Create a project based located on the given path * @param path the path of the project * @param data the project body description * @returns {$promise|*|T.$promise} */ - createProject(workspaceId, path, data) { - let promise = this.remoteProjectsAPI.create({workspaceId: workspaceId, path: path}, data).$promise; + createProject(path, data) { + let promise = this.remoteProjectsAPI.create({path: path}, data).$promise; return promise; } @@ -100,111 +98,107 @@ export class CheProject { } /** - * Fetch project details on the given workspace id and path - * @param workspaceId the workspace ID to use + * Fetch project details on the given path * @param projectPath the path of the project */ fetchProjectDetails(workspaceId, projectPath) { //TODO why we cannot use project path var projectName = projectPath[0] === '/' ? projectPath.slice(1) : projectPath; - let promise = this.remoteProjectsAPI.details({workspaceId: workspaceId, path: projectName}).$promise; + let promise = this.remoteProjectsAPI.details({path: projectName}).$promise; // check if it was OK or not let parsedResultPromise = promise.then((projectDetails) => { if (projectDetails) { projectDetails.workspaceId = workspaceId; - this.projectDetailsMap.set(workspaceId + projectPath, projectDetails); + this.projectDetailsMap.set(projectPath, projectDetails); } }); return parsedResultPromise; } - getProjectDetailsByKey(workspaceId, projectPath) { - return this.projectDetailsMap.get(workspaceId + projectPath); + getProjectDetailsByKey(projectPath) { + return this.projectDetailsMap.get(projectPath); } - removeProjectDetailsByKey(workspaceId, projectPath) { - this.projectDetailsMap.delete(workspaceId + projectPath); + removeProjectDetailsByKey(projectPath) { + this.projectDetailsMap.delete(projectPath); } updateProjectDetails(projectDetails) { - return this.updateProject(projectDetails.workspaceId, projectDetails.name, projectDetails); + return this.updateProject(projectDetails.name, projectDetails); } - updateProject(workspaceId, path, projectDetails) { + updateProject(path, projectDetails) { let newProjectDetails = angular.copy(projectDetails); if(newProjectDetails.workspaceId){ delete(newProjectDetails.workspaceId); } let promiseUpdateProjectDetails = this.remoteProjectsAPI.update({ - workspaceId: workspaceId, path: path }, newProjectDetails).$promise; return promiseUpdateProjectDetails; } - rename(workspaceId, projectName, newProjectName) { - let promise = this.remoteProjectsAPI.rename({workspaceId: workspaceId, path: projectName, name: newProjectName}, null).$promise; + rename(projectName, newProjectName) { + let promise = this.remoteProjectsAPI.rename({path: projectName, name: newProjectName}, null).$promise; return promise; } - remove(workspaceId, projectName) { - let promiseDelete = this.remoteProjectsAPI.remove({workspaceId: workspaceId, path: projectName}).$promise; + remove(projectName) { + let promiseDelete = this.remoteProjectsAPI.remove({path: projectName}).$promise; return promiseDelete; } /** * Fetch estimate and return promise for this estimate - * @param workspaceId the workspace ID of the project * @param projectPath the path to the project in the workspace * @param projectType the project type in the list of available types * @returns {Promise} */ - fetchEstimate(workspaceId, projectPath, projectType) { + fetchEstimate(projectPath, projectType) { let projectName = projectPath[0] === '/' ? projectPath.slice(1) : projectPath; - let promise = this.remoteProjectsAPI.estimate({workspaceId: workspaceId, path: projectName, type: projectType}).$promise; + let promise = this.remoteProjectsAPI.estimate({path: projectName, type: projectType}).$promise; let parsedResultPromise = promise.then((estimate) => { if (estimate) { - this.estimateMap.set(workspaceId + projectName + projectType, estimate); + this.estimateMap.set(projectName + projectType, estimate); } }); return parsedResultPromise; } /** - * @return the estimation based on the given 3 inputs : workspace ID, project path and project type + * @return the estimation based on the given 2 inputs : project path and project type */ - getEstimate(workspaceId, projectPath, projectType) { + getEstimate(projectPath, projectType) { let projectName = projectPath[0] === '/' ? projectPath.slice(1) : projectPath; - return this.estimateMap.get(workspaceId + projectName + projectType); + return this.estimateMap.get(projectName + projectType); } /** * Fetch resolve and return promise for this resolution - * @param workspaceId the workspace ID of the project * @param projectPath the path to the project in the workspace * @returns {Promise} */ - fetchResolve(workspaceId, projectPath) { + fetchResolve(projectPath) { let projectName = projectPath[0] === '/' ? projectPath.slice(1) : projectPath; - let promise = this.remoteProjectsAPI.resolve({workspaceId: workspaceId, path: projectName}).$promise; + let promise = this.remoteProjectsAPI.resolve({path: projectName}).$promise; let parsedResultPromise = promise.then((resolve) => { if (resolve) { - this.resolveMap.set(workspaceId + projectName, resolve); + this.resolveMap.set(projectName, resolve); } }); return parsedResultPromise; } /** - * @return the estimation based on the given 2 inputs : workspace ID, project path + * @return the estimation based on the given input : project path */ - getResolve(workspaceId, projectPath) { + getResolve(projectPath) { let projectName = projectPath[0] === '/' ? projectPath.slice(1) : projectPath; - return this.resolveMap.get(workspaceId + projectName); + return this.resolveMap.get(projectName); } } diff --git a/dashboard/src/components/api/che-project.spec.js b/dashboard/src/components/api/che-project.spec.js index c3454c9018..26bb26a420 100644 --- a/dashboard/src/components/api/che-project.spec.js +++ b/dashboard/src/components/api/che-project.spec.js @@ -98,13 +98,13 @@ describe('CheProject', function () { factory.fetchProjectDetails(testProjectDetails.workspaceId, '/' + testProjectDetails.name); // expecting GET - httpBackend.expectGET(agentUrl + '/project/' + testProjectDetails.workspaceId + '/' + testProjectDetails.name); + httpBackend.expectGET(agentUrl + '/project/' + testProjectDetails.name); // flush command httpBackend.flush(); // now, check - var projectDetails = factory.getProjectDetailsByKey(testProjectDetails.workspaceId, '/' + testProjectDetails.name); + var projectDetails = factory.getProjectDetailsByKey('/' + testProjectDetails.name); // check project details expect(projectDetails.name).toEqual(testProjectDetails.name); diff --git a/dashboard/src/components/api/che-workspace.factory.js b/dashboard/src/components/api/che-workspace.factory.js index 9c61bffeb3..3cc9ff6d89 100644 --- a/dashboard/src/components/api/che-workspace.factory.js +++ b/dashboard/src/components/api/che-workspace.factory.js @@ -334,26 +334,17 @@ export class CheWorkspace { */ getWebsocketUrl(workspaceId) { let workspace = this.workspacesById.get(workspaceId); - if (!workspace || !workspace.runtime) { + if (!workspace || !workspace.runtime || !workspace.runtime.links) { return ''; } - let runtimeData = workspace.runtime; - // extract the Websocket URL of the runtime - let servers = runtimeData.devMachine.runtime.servers; - - var wsagentServerAddress; - for (var key in servers) { - let server = servers[key]; - if ('wsagent' === server.ref) { - wsagentServerAddress = server.address; + for (let i = 0; i < workspace.runtime.links.length; i++) { + let link = workspace.runtime.links[i]; + if (link.rel === 'wsagent.websocket') { + return link.href; } } - let endpoint = runtimeData.devMachine.runtime.envVariables.CHE_API_ENDPOINT; - - var contextPath; - - return 'ws://' + wsagentServerAddress + '/wsagent/ext/ws/' + workspaceId; + return ''; } getIdeUrl(workspaceName) { diff --git a/dashboard/src/components/api/remote/che-remote-project.js b/dashboard/src/components/api/remote/che-remote-project.js index bd44584392..d2fa1fa1a7 100644 --- a/dashboard/src/components/api/remote/che-remote-project.js +++ b/dashboard/src/components/api/remote/che-remote-project.js @@ -24,33 +24,31 @@ export class CheRemoteProject { this.authData = authData; // remote call - this.remoteProjectsAPI = this.$resource('', {workspaceId: '@id'}, { - import: {method: 'POST', url: authData.url + '/project/:workspaceId/import/:path?token=' + authData.token}, - update: {method: 'PUT', url: authData.url + '/project/:workspaceId/:path?token=' + authData.token} + this.remoteProjectsAPI = this.$resource('', {}, { + import: {method: 'POST', url: authData.url + '/project/import/:path?token=' + authData.token}, + update: {method: 'PUT', url: authData.url + '/project/:path?token=' + authData.token} }); } /** - * Import a project based located on the given workspace id and path - * @param workspaceId the workspace ID to use + * Import a project based located on the given path * @param path the path of the project * @param data the project body description * @returns {$promise|*|T.$promise} */ - importProject(workspaceId, path, data) { + importProject(path, data) { // remove unused description because we cannot set project description without project type if ((!data.type || data.type.length === 0) && data.description) { delete(data.description); } - return this.remoteProjectsAPI.import({workspaceId: workspaceId, path: path}, data).$promise; + return this.remoteProjectsAPI.import({path: path}, data).$promise; } - updateProject(workspaceId, path, projectDetails) { + updateProject(path, projectDetails) { return this.remoteProjectsAPI.update({ - workspaceId: workspaceId, path: path }, projectDetails).$promise; } diff --git a/dashboard/src/components/api/test/che-http-backend.js b/dashboard/src/components/api/test/che-http-backend.js index c26c43601e..00bc8605c9 100644 --- a/dashboard/src/components/api/test/che-http-backend.js +++ b/dashboard/src/components/api/test/che-http-backend.js @@ -62,7 +62,7 @@ export class CheHttpBackend { var projectTypeKeys = this.projectTypesWorkspaces.keys(); for (let key of projectTypeKeys) { - this.httpBackend.when('GET', this.workspaceAgentMap.get(key) + '/project-type/' + key).respond(this.projectTypesWorkspaces.get(key)); + this.httpBackend.when('GET', this.workspaceAgentMap.get(key) + '/project-type').respond(this.projectTypesWorkspaces.get(key)); } //memberships: @@ -95,7 +95,8 @@ export class CheHttpBackend { var projectDetailsKeys = this.projectDetailsMap.keys(); for (let projectKey of projectDetailsKeys) { let workspaceKey = projectKey.split('/')[0]; - this.httpBackend.when('GET', this.workspaceAgentMap.get(workspaceKey) + '/project/' + projectKey).respond(this.projectDetailsMap.get(projectKey)); + let projectId = projectKey.split('/')[1]; + this.httpBackend.when('GET', this.workspaceAgentMap.get(workspaceKey) + '/project/' + projectId).respond(this.projectDetailsMap.get(projectKey)); } // branding @@ -164,7 +165,7 @@ export class CheHttpBackend { ); // add call to the backend - this.httpBackend.when('GET', this.workspaceAgentMap.get(workspace.id) + '/project/' + workspace.id).respond(this.projectsPerWorkspace.get(workspace.id)); + this.httpBackend.when('GET', this.workspaceAgentMap.get(workspace.id) + '/project/').respond(this.projectsPerWorkspace.get(workspace.id)); } @@ -308,7 +309,7 @@ export class CheHttpBackend { * @param projectName the project name */ addFetchProjectDetails(workspaceId, projectName) { - this.httpBackend.when('GET', '/project/' + workspaceId + '/' + projectName) + this.httpBackend.when('GET', '/project/' + projectName) .respond(this.projectDetailsMap.get(workspaceId + '/' + projectName)); } @@ -319,7 +320,7 @@ export class CheHttpBackend { * @param newProjectName the new project name */ addUpdatedProjectName(workspaceId, projectName, newProjectName) { - this.httpBackend.when('POST', '/project/' + workspaceId + '/rename/' + projectName + '?name=' + newProjectName).respond(newProjectName); + this.httpBackend.when('POST', '/project/rename/' + projectName + '?name=' + newProjectName).respond(newProjectName); } /** @@ -358,7 +359,7 @@ export class CheHttpBackend { * @param projectPath */ getLocalGitUrl(workspaceId, projectPath) { - this.httpBackend.when('GET', this.workspaceAgentMap.get(workspaceId) + '/git/' + workspaceId + '/read-only-url?projectPath=' + projectPath) + this.httpBackend.when('GET', this.workspaceAgentMap.get(workspaceId) + '/git/read-only-url?projectPath=' + projectPath) .respond(this.localGitUrlsMap.get(workspaceId + projectPath)); } @@ -368,7 +369,7 @@ export class CheHttpBackend { * @param projectPath */ getRemoteGitUrlArray(workspaceId, projectPath) { - this.httpBackend.when('POST', this.workspaceAgentMap.get(workspaceId) + '/git/' + workspaceId + '/remote-list?projectPath=' + projectPath) + this.httpBackend.when('POST', this.workspaceAgentMap.get(workspaceId) + '/git/remote-list?projectPath=' + projectPath) .respond(this.remoteGitUrlArraysMap.get(workspaceId + projectPath)); } diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/GitExtension.java b/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/GitExtension.java index d66160e582..58cad24486 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/GitExtension.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/main/java/org/eclipse/che/ide/ext/git/client/GitExtension.java @@ -138,7 +138,6 @@ public class GitExtension { historyGroup.add(historyAction); actionManager.registerAction("gitStatus", showStatusAction); historyGroup.add(showStatusAction); - actionManager.registerAction("gitPush", pushAction); remoteGroup.add(pushAction); actionManager.registerAction("gitFetch", fetchAction); diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/BaseTest.java b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/BaseTest.java index 46c00613fa..1b648c9488 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/BaseTest.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/BaseTest.java @@ -99,7 +99,6 @@ public abstract class BaseTest { @Before public void disarm() { - when(appContext.getWorkspaceId()).thenReturn("id"); when(appContext.getCurrentProject()).thenReturn(currentProject); when(currentProject.getProjectConfig()).thenReturn(projectConfig); diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/add/AddToIndexPresenterTest.java b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/add/AddToIndexPresenterTest.java index e0f62553a2..50ff856eaf 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/add/AddToIndexPresenterTest.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/add/AddToIndexPresenterTest.java @@ -75,7 +75,6 @@ public class AddToIndexPresenterTest extends BaseTest { @Override public void disarm() { super.disarm(); - when(appContext.getWorkspaceId()).thenReturn("id"); presenter = new AddToIndexPresenter(view, appContext, dtoUnmarshallerFactory, diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/branch/BranchPresenterTest.java b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/branch/BranchPresenterTest.java index ccafef9ca2..f88c80bd00 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/branch/BranchPresenterTest.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/branch/BranchPresenterTest.java @@ -113,7 +113,6 @@ public class BranchPresenterTest extends BaseTest { public void disarm() { super.disarm(); - when(appContext.getWorkspaceId()).thenReturn("id"); presenter = new BranchPresenter(view, dtoFactory, editorAgent, diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/commit/CommitPresenterTest.java b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/commit/CommitPresenterTest.java index 00e1b49102..82dd74b61a 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/commit/CommitPresenterTest.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/commit/CommitPresenterTest.java @@ -64,8 +64,6 @@ public class CommitPresenterTest extends BaseTest { public void disarm() { super.disarm(); - when(appContext.getWorkspaceId()).thenReturn("id"); - presenter = new CommitPresenter(view, service, constant, diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/fetch/FetchPresenterTest.java b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/fetch/FetchPresenterTest.java index ccdfdc0a9f..f5a5f2a7ce 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/fetch/FetchPresenterTest.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/fetch/FetchPresenterTest.java @@ -60,7 +60,6 @@ public class FetchPresenterTest extends BaseTest { @Override public void disarm() { super.disarm(); - when(appContext.getWorkspaceId()).thenReturn("id"); presenter = new FetchPresenter(dtoFactory, view, service, diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/history/HistoryPresenterTest.java b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/history/HistoryPresenterTest.java index eb70661d17..845c8201fe 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/history/HistoryPresenterTest.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/history/HistoryPresenterTest.java @@ -87,9 +87,6 @@ public class HistoryPresenterTest extends BaseTest { @Override public void disarm() { super.disarm(); - - when(appContext.getWorkspaceId()).thenReturn("id"); - presenter = new HistoryPresenter(view, eventBus, resources, diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/merge/MergePresenterTest.java b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/merge/MergePresenterTest.java index f4b5357f36..fd4250a9b5 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/merge/MergePresenterTest.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/merge/MergePresenterTest.java @@ -69,7 +69,6 @@ public class MergePresenterTest extends BaseTest { @Override public void disarm() { super.disarm(); - when(appContext.getWorkspaceId()).thenReturn("id"); presenter = new MergePresenter(view, eventBus, editorAgent, diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/pull/PullPresenterTest.java b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/pull/PullPresenterTest.java index dca031a6d0..b487460e35 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/pull/PullPresenterTest.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/pull/PullPresenterTest.java @@ -80,9 +80,6 @@ public class PullPresenterTest extends BaseTest { @Override public void disarm() { super.disarm(); - - when(appContext.getWorkspaceId()).thenReturn("id"); - List partPresenterList = new ArrayList<>(); partPresenterList.add(partPresenter); diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/push/PushToRemotePresenterTest.java b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/push/PushToRemotePresenterTest.java index 489587d8d7..3b82af7707 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/push/PushToRemotePresenterTest.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/push/PushToRemotePresenterTest.java @@ -89,9 +89,6 @@ public class PushToRemotePresenterTest extends BaseTest { public void disarm() { super.disarm(); - - when(appContext.getWorkspaceId()).thenReturn("id"); - when(view.getRepository()).thenReturn(REPOSITORY_NAME); when(view.getLocalBranch()).thenReturn(LOCAL_BRANCH); when(view.getRemoteBranch()).thenReturn(REMOTE_BRANCH); diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/reset/commit/ResetToCommitPresenterTest.java b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/reset/commit/ResetToCommitPresenterTest.java index 4bd9f58c78..02c15c5cc1 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/reset/commit/ResetToCommitPresenterTest.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/reset/commit/ResetToCommitPresenterTest.java @@ -71,8 +71,6 @@ public class ResetToCommitPresenterTest extends BaseTest { @Override public void disarm() { super.disarm(); - when(appContext.getWorkspaceId()).thenReturn("id"); - presenter = new ResetToCommitPresenter(view, service, constant, diff --git a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/reset/files/ResetFilesPresenterTest.java b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/reset/files/ResetFilesPresenterTest.java index fbf6645097..1eef2c96a3 100644 --- a/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/reset/files/ResetFilesPresenterTest.java +++ b/plugins/plugin-git/che-plugin-git-ext-git/src/test/java/org/eclipse/che/ide/ext/git/client/reset/files/ResetFilesPresenterTest.java @@ -51,9 +51,6 @@ public class ResetFilesPresenterTest extends BaseTest { @Override public void disarm() { super.disarm(); - - when(appContext.getWorkspaceId()).thenReturn("id"); - presenter = new ResetFilesPresenter(view, service, appContext, diff --git a/plugins/plugin-github/che-plugin-github-ide/src/main/java/org/eclipse/che/plugin/github/ide/GitHubClientServiceImpl.java b/plugins/plugin-github/che-plugin-github-ide/src/main/java/org/eclipse/che/plugin/github/ide/GitHubClientServiceImpl.java index f3ac263e31..0d278b8ac5 100644 --- a/plugins/plugin-github/che-plugin-github-ide/src/main/java/org/eclipse/che/plugin/github/ide/GitHubClientServiceImpl.java +++ b/plugins/plugin-github/che-plugin-github-ide/src/main/java/org/eclipse/che/plugin/github/ide/GitHubClientServiceImpl.java @@ -76,7 +76,7 @@ public class GitHubClientServiceImpl implements GitHubClientService { private String baseUrl() { - return appContext.getDevMachine().getWsAgentBaseUrl() + "/github/" + appContext.getWorkspaceId(); + return appContext.getDevMachine().getWsAgentBaseUrl() + "/github"; } @Override diff --git a/plugins/plugin-github/che-plugin-github-server/src/main/java/org/eclipse/che/plugin/github/server/rest/GitHubService.java b/plugins/plugin-github/che-plugin-github-server/src/main/java/org/eclipse/che/plugin/github/server/rest/GitHubService.java index 0507cda489..b06dfec8f9 100644 --- a/plugins/plugin-github/che-plugin-github-server/src/main/java/org/eclipse/che/plugin/github/server/rest/GitHubService.java +++ b/plugins/plugin-github/che-plugin-github-server/src/main/java/org/eclipse/che/plugin/github/server/rest/GitHubService.java @@ -62,7 +62,7 @@ import static org.eclipse.che.dto.server.DtoFactory.newDto; * @author Kevin Pollet * @author Igor vinokur */ -@Path("/github/{ws-id}") +@Path("/github") public class GitHubService { @Inject private GitHubFactory gitHubFactory; diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/JdtGuiceModule.java b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/JdtGuiceModule.java index 4e13779f58..2f6a33706a 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/JdtGuiceModule.java +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/JdtGuiceModule.java @@ -23,6 +23,7 @@ import org.eclipse.che.jdt.rest.CompilerSetupService; import org.eclipse.che.jdt.rest.FormatService; import org.eclipse.che.jdt.rest.JavaNavigationService; import org.eclipse.che.jdt.rest.JavaReconcileService; +import org.eclipse.che.jdt.rest.JavadocService; import org.eclipse.che.jdt.rest.JdtExceptionMapper; import org.eclipse.che.jdt.rest.RefactoringService; import org.eclipse.che.jdt.rest.SearchService; diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/CodeAssistService.java b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/CodeAssistService.java index 667b7f75b7..1dc688443d 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/CodeAssistService.java +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/CodeAssistService.java @@ -40,7 +40,7 @@ import java.util.List; /** * @author Evgen Vidolob */ -@Path("jdt/{wsId}/code-assist") +@Path("jdt/code-assist") public class CodeAssistService { private static final JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel(); diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/CompilerSetupService.java b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/CompilerSetupService.java index 6b3510c383..8d0def4167 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/CompilerSetupService.java +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/CompilerSetupService.java @@ -35,7 +35,7 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON; * * @author Dmitry Shnurenko */ -@Path("/jdt/{wsId}/compiler-settings") +@Path("/jdt/compiler-settings") public class CompilerSetupService { private static final JavaModel JAVA_MODEL = JavaModelManager.getJavaModelManager().getJavaModel(); diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/FormatService.java b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/FormatService.java index 59838a5d0c..71b6a32c99 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/FormatService.java +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/FormatService.java @@ -27,7 +27,7 @@ import java.util.List; /** * @author Roman Nikitenko */ -@Path("code-formatting/{wsId}") +@Path("code-formatting") public class FormatService { private Formatter formatter; diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavaClasspathService.java b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavaClasspathService.java index b7db78a43a..b4c584d3f1 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavaClasspathService.java +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavaClasspathService.java @@ -28,12 +28,10 @@ import java.util.concurrent.ExecutionException; * * @author Evgen Vidolob */ -@Path("jdt/{wsId}/classpath") +@Path("jdt/classpath") public class JavaClasspathService { @Inject private ClassPathBuilder classPathBuilder; - @PathParam("wsId") - private String workspaceId; /** * Update dependencies. @@ -47,6 +45,6 @@ public class JavaClasspathService { @GET public ClassPathBuilderResult update(@QueryParam("projectpath") final String projectPath) throws ExecutionException, InterruptedException { - return classPathBuilder.buildClassPath(workspaceId, projectPath); + return classPathBuilder.buildClassPath(projectPath); } } diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavaNavigationService.java b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavaNavigationService.java index f3ee1bd725..49f496025c 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavaNavigationService.java +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavaNavigationService.java @@ -37,7 +37,7 @@ import java.util.List; /** * @author Evgen Vidolob */ -@Path("jdt/{wsId}/navigation") +@Path("jdt/navigation") public class JavaNavigationService { JavaModel MODEL = JavaModelManager.getJavaModelManager().getJavaModel(); diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavaReconcileService.java b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavaReconcileService.java index 4dcbf3c608..ab77140d42 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavaReconcileService.java +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavaReconcileService.java @@ -28,7 +28,7 @@ import javax.ws.rs.QueryParam; /** * @author Evgen Vidolob */ -@Path("jdt/{wsId}/reconcile") +@Path("jdt/reconcile") public class JavaReconcileService { private static final JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel(); diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/JavadocService.java b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavadocService.java similarity index 89% rename from plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/JavadocService.java rename to plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavadocService.java index 981b0a69dd..3954155090 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/JavadocService.java +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/JavadocService.java @@ -8,15 +8,15 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.jdt; +package org.eclipse.che.jdt.rest; +import org.eclipse.che.jdt.JavadocFinder; import org.eclipse.jdt.internal.core.JavaModelManager; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaModelException; import javax.ws.rs.GET; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; @@ -26,13 +26,9 @@ import javax.ws.rs.core.UriInfo; /** * @author Evgen Vidolob */ -@Path("jdt/{wsId}/javadoc") +@Path("jdt/javadoc") public class JavadocService { - @PathParam("wsId") - private String wsId; - - @Path("find") @GET @Produces("text/html") @@ -53,7 +49,7 @@ public class JavadocService { } private String getUrlPart(String projectPath, UriBuilder uriBuilder) { - return uriBuilder.clone().path(JavadocService.class).path(JavadocService.class, "get").build(wsId).toString() + "?projectpath=" + projectPath + "&handle="; + return uriBuilder.clone().path(JavadocService.class).path(JavadocService.class, "get").build().toString() + "?projectpath=" + projectPath + "&handle="; } } diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/RefactoringService.java b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/RefactoringService.java index 201487f4d4..5e2fa6c6fc 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/RefactoringService.java +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/RefactoringService.java @@ -56,7 +56,7 @@ import java.util.function.Function; * * @author Evgen Vidolob */ -@Path("/jdt/{ws-id}/refactoring") +@Path("/jdt/refactoring") public class RefactoringService { private static final JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel(); private RefactoringManager manager; diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/SearchService.java b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/SearchService.java index 3605d6b0d8..61190c4960 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/SearchService.java +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/che-jdt-ext-machine/src/main/java/org/eclipse/che/jdt/rest/SearchService.java @@ -33,7 +33,7 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON; * * @author Evgen Vidolob */ -@Path("jdt/{ws-id}/search") +@Path("jdt/search") public class SearchService { @Inject diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/dependenciesupdater/JavaClasspathServiceClientImpl.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/dependenciesupdater/JavaClasspathServiceClientImpl.java index d9cc5cba0a..71a90f2eed 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/dependenciesupdater/JavaClasspathServiceClientImpl.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/dependenciesupdater/JavaClasspathServiceClientImpl.java @@ -45,7 +45,7 @@ public class JavaClasspathServiceClientImpl implements JavaClasspathServiceClien protected JavaClasspathServiceClientImpl(AppContext appContext, WsAgentStateController wsAgentStateController) { this.wsAgentStateController = wsAgentStateController; - this.baseHttpUrl = "/jdt/" + appContext.getWorkspace().getId(); + this.baseHttpUrl = "/jdt/"; } /** {@inheritDoc} */ diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaCodeAssistClient.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaCodeAssistClient.java index 7c0b10442c..fcdb5c1476 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaCodeAssistClient.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaCodeAssistClient.java @@ -47,7 +47,6 @@ public class JavaCodeAssistClient { private final DtoUnmarshallerFactory unmarshallerFactory; private final AsyncRequestFactory asyncRequestFactory; - private final String workspaceId; private final MessageLoader loader; private final AppContext appContext; @@ -57,21 +56,20 @@ public class JavaCodeAssistClient { LoaderFactory loaderFactory, AsyncRequestFactory asyncRequestFactory) { this.appContext = appContext; - this.workspaceId = appContext.getWorkspaceId(); this.unmarshallerFactory = unmarshallerFactory; this.loader = loaderFactory.newLoader(); this.asyncRequestFactory = asyncRequestFactory; } public void computeProposals(String projectPath, String fqn, int offset, String contents, AsyncRequestCallback callback) { - String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + "/code-assist/compute/completion" + "/?projectpath=" + + String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/code-assist/compute/completion" + "/?projectpath=" + projectPath + "&fqn=" + fqn + "&offset=" + offset; asyncRequestFactory.createPostRequest(url, null).data(contents).send(callback); } public void computeAssistProposals(String projectPath, String fqn, int offset, List problems, AsyncRequestCallback callback) { - String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + "/code-assist/compute/assist" + "/?projectpath=" + + String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/code-assist/compute/assist" + "/?projectpath=" + projectPath + "&fqn=" + fqn + "&offset=" + offset; List prob = new ArrayList<>(); prob.addAll(problems); @@ -80,7 +78,7 @@ public class JavaCodeAssistClient { public void applyProposal(String sessionId, int index, boolean insert, final AsyncCallback callback) { - String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + "/code-assist/apply/completion/?sessionid=" + + String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/code-assist/apply/completion/?sessionid=" + sessionId + "&index=" + index + "&insert=" + insert; Unmarshallable unmarshaller = unmarshallerFactory.newUnmarshaller(ProposalApplyResult.class); @@ -98,7 +96,7 @@ public class JavaCodeAssistClient { } public String getProposalDocUrl(int id, String sessionId) { - return appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + "/code-assist/compute/info?sessionid=" + sessionId + + return appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/code-assist/compute/info?sessionid=" + sessionId + "&index=" + id; } @@ -118,7 +116,7 @@ public class JavaCodeAssistClient { return newPromise(new AsyncPromiseHelper.RequestCall>() { @Override public void makeCall(AsyncCallback> callback) { - String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/code-formatting/" + workspaceId + "/format?offset=" + offset + + String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/code-formatting/format?offset=" + offset + "&length=" + length; asyncRequestFactory.createPostRequest(url, null) .header(CONTENT_TYPE, MimeType.TEXT_PLAIN) @@ -148,9 +146,7 @@ public class JavaCodeAssistClient { */ public Promise> organizeImports(String projectPath, String fqn) { String url = appContext.getDevMachine().getWsAgentBaseUrl() + - "/jdt/" + - workspaceId + - "/code-assist/organize-imports?projectpath=" + projectPath + + "/jdt/code-assist/organize-imports?projectpath=" + projectPath + "&fqn=" + fqn; return asyncRequestFactory.createPostRequest(url, null) @@ -168,9 +164,7 @@ public class JavaCodeAssistClient { */ public Promise applyChosenImports(String projectPath, String fqn, ConflictImportDTO chosen) { String url = appContext.getDevMachine().getWsAgentBaseUrl() + - "/jdt/" + - workspaceId + - "/code-assist/apply-imports?projectpath=" + projectPath + + "/jdt/code-assist/apply-imports?projectpath=" + projectPath + "&fqn=" + fqn; return asyncRequestFactory.createPostRequest(url, chosen) diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaReconcileClient.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaReconcileClient.java index 93f55331c7..8e9ab26181 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaReconcileClient.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/editor/JavaReconcileClient.java @@ -40,7 +40,7 @@ public class JavaReconcileClient { } public void reconcile(String projectPath, String fqn, final ReconcileCallback callback) { - String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + appContext.getWorkspaceId() + "/reconcile/?projectpath=" + projectPath + "&fqn=" + fqn; + String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/reconcile/?projectpath=" + projectPath + "&fqn=" + fqn; asyncRequestFactory.createGetRequest(url) .send(new AsyncRequestCallback(dtoUnmarshallerFactory.newUnmarshaller(ReconcileResult.class)) { @Override diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/service/JavaNavigationServiceImpl.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/service/JavaNavigationServiceImpl.java index 17cc65246f..a374ce88e3 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/service/JavaNavigationServiceImpl.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/navigation/service/JavaNavigationServiceImpl.java @@ -47,7 +47,6 @@ public class JavaNavigationServiceImpl implements JavaNavigationService { private final AppContext appContext; private final LoaderFactory loaderFactory; private final AsyncRequestFactory requestFactory; - private final String workspaceId; private final DtoUnmarshallerFactory unmarshallerFactory; @Inject @@ -58,40 +57,39 @@ public class JavaNavigationServiceImpl implements JavaNavigationService { this.appContext = appContext; this.loaderFactory = loaderFactory; this.requestFactory = asyncRequestFactory; - this.workspaceId = appContext.getWorkspaceId(); this.unmarshallerFactory = unmarshallerFactory; } @Override public void findDeclaration(String projectPath, String fqn, int offset, AsyncRequestCallback callback) { - String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + "/navigation/find-declaration" + + String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/navigation/find-declaration" + "?projectpath=" + projectPath + "&fqn=" + fqn + "&offset=" + offset; requestFactory.createGetRequest(url).send(callback); } public void getExternalLibraries(String projectPath, AsyncRequestCallback> callback) { String url = - appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + "/navigation/libraries?projectpath=" + projectPath; + appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/navigation/libraries?projectpath=" + projectPath; requestFactory.createGetRequest(url).send(callback); } @Override public void getLibraryChildren(String projectPath, int libId, AsyncRequestCallback> callback) { - String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + "/navigation/lib/children" + + String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/navigation/lib/children" + "?projectpath=" + projectPath + "&root=" + libId; requestFactory.createGetRequest(url).send(callback); } @Override public void getChildren(String projectPath, int libId, String path, AsyncRequestCallback> callback) { - String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + "/navigation/children" + + String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/navigation/children" + "?projectpath=" + projectPath + "&root=" + libId + "&path=" + path; requestFactory.createGetRequest(url).send(callback); } @Override public void getEntry(String projectPath, int libId, String path, AsyncRequestCallback callback) { - String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + "/navigation/entry" + + String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/navigation/entry" + "?projectpath=" + projectPath + "&root=" + libId + "&path=" + path; requestFactory.createGetRequest(url).send(callback); } @@ -105,14 +103,14 @@ public class JavaNavigationServiceImpl implements JavaNavigationService { @Override public void getContent(String projectPath, String fqn, AsyncRequestCallback callback) { - String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + "/navigation/contentbyfqn?projectpath=" + projectPath + "&fqn=" + fqn; + String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/navigation/contentbyfqn?projectpath=" + projectPath + "&fqn=" + fqn; requestFactory.createGetRequest(url).send(callback); } /** {@inheritDoc} */ @Override public Promise getCompilationUnit(String projectPath, String fqn, boolean showInherited) { - final String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + "/navigation/compilation-unit" + + final String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/navigation/compilation-unit" + "?projectpath=" + projectPath + "&fqn=" + fqn + "&showinherited=" + showInherited; return newPromise(new AsyncPromiseHelper.RequestCall() { @@ -127,7 +125,7 @@ public class JavaNavigationServiceImpl implements JavaNavigationService { @Override public Promise getImplementations(String projectPath, String fqn, int offset) { - final String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + "/navigation/implementations" + + final String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/navigation/implementations" + "?projectpath=" + projectPath + "&fqn=" + fqn + "&offset=" + offset; return requestFactory.createGetRequest(url) @@ -138,8 +136,7 @@ public class JavaNavigationServiceImpl implements JavaNavigationService { @Override public Promise> getProjectsAndPackages(boolean includePackage) { - final String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + - "/navigation/get/projects/and/packages" + final String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/navigation/get/projects/and/packages" + "?includepackages=" + includePackage; return newPromise(new AsyncPromiseHelper.RequestCall>() { @@ -156,13 +153,13 @@ public class JavaNavigationServiceImpl implements JavaNavigationService { @Override public String getContentUrl(String projectPath, int libId, String path) { - return appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + "/navigation/content" + + return appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/navigation/content" + "?projectpath=" + projectPath + "&root=" + libId + "&path=" + path; } @Override public Promise> getMethodParametersHints(String projectPath, String fqn, int offset, int lineStartOffset) { - String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + workspaceId + "/navigation/parameters" + + String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/navigation/parameters" + "?projectpath=" + projectPath + "&fqn=" + fqn + "&offset=" + offset + "&lineStart=" + lineStartOffset; return requestFactory.createGetRequest(url) diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/project/classpath/service/ClasspathServiceClientImpl.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/project/classpath/service/ClasspathServiceClientImpl.java index 86c98263cd..f439c06aaa 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/project/classpath/service/ClasspathServiceClientImpl.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/project/classpath/service/ClasspathServiceClientImpl.java @@ -47,7 +47,7 @@ public class ClasspathServiceClientImpl implements ClasspathServiceClient { this.appContext = appContext; this.loader = loaderFactory.newLoader(); - this.pathToService = "/jdt/" + appContext.getWorkspaceId() + "/classpath"; + this.pathToService = "/jdt/classpath"; } @Override diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/project/interceptor/AbstractExternalLibrariesNodeInterceptor.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/project/interceptor/AbstractExternalLibrariesNodeInterceptor.java index 1721fcd5aa..19610426c9 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/project/interceptor/AbstractExternalLibrariesNodeInterceptor.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/project/interceptor/AbstractExternalLibrariesNodeInterceptor.java @@ -46,7 +46,7 @@ public abstract class AbstractExternalLibrariesNodeInterceptor implements NodeIn @Override public Promise> intercept(Node parent, List children) { - if (!(isProjectOrModuleNode(parent)/* || isJavaProject(parent)*/)) { + if (!isProjectOrModuleNode(parent)) { return Promises.resolve(children); } diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/refactoring/service/RefactoringServiceClientImpl.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/refactoring/service/RefactoringServiceClientImpl.java index 837acc141e..9dd34d2da7 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/refactoring/service/RefactoringServiceClientImpl.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/refactoring/service/RefactoringServiceClientImpl.java @@ -68,7 +68,7 @@ final class RefactoringServiceClientImpl implements RefactoringServiceClient { this.unmarshallerFactory = unmarshallerFactory; this.appContext = appContext; this.loader = loaderFactory.newLoader(); - this.pathToService = "/jdt/" + appContext.getWorkspaceId() + "/refactoring/"; + this.pathToService = "/jdt/refactoring/"; } /** {@inheritDoc} */ diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/search/JavaSearchServiceRest.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/search/JavaSearchServiceRest.java index 5d5190a50c..09cc54c78c 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/search/JavaSearchServiceRest.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/search/JavaSearchServiceRest.java @@ -52,7 +52,7 @@ public class JavaSearchServiceRest implements JavaSearchService { this.unmarshallerFactory = unmarshallerFactory; this.appContext = appContext; this.loader = loaderFactory.newLoader(); - this.pathToService = "/jdt/" + appContext.getWorkspaceId() + "/search/"; + this.pathToService = "/jdt/search/find/usages"; } @Override @@ -61,7 +61,7 @@ public class JavaSearchServiceRest implements JavaSearchService { @Override public void makeCall(AsyncCallback callback) { - asyncRequestFactory.createPostRequest(appContext.getDevMachine().getWsAgentBaseUrl() + pathToService + "find/usages", request) + asyncRequestFactory.createPostRequest(appContext.getDevMachine().getWsAgentBaseUrl() + pathToService, request) .header(CONTENT_TYPE, APPLICATION_JSON) .loader(loader) .send(newCallback(callback, unmarshallerFactory.newUnmarshaller(FindUsagesResponse.class))); diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/search/JavaSearchServiceWS.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/search/JavaSearchServiceWS.java index 97d1e3a517..be3615f854 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/search/JavaSearchServiceWS.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/search/JavaSearchServiceWS.java @@ -59,7 +59,7 @@ public class JavaSearchServiceWS implements JavaSearchService { this.dtoFactory = dtoFactory; this.loader = loaderFactory.newLoader(); this.unmarshallerFactory = unmarshallerFactory; - this.pathToService = "/jdt/" + appContext.getWorkspace().getId() + "/search/"; + this.pathToService = "/jdt/search/"; } @Override diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/settings/service/SettingsServiceClientImpl.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/settings/service/SettingsServiceClientImpl.java index c63e212740..a56fe4e5a9 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/settings/service/SettingsServiceClientImpl.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/main/java/org/eclipse/che/ide/ext/java/client/settings/service/SettingsServiceClientImpl.java @@ -44,7 +44,7 @@ public class SettingsServiceClientImpl implements SettingsServiceClient { /** {@inheritDoc} */ @Override public Promise applyCompileParameters(@NotNull final Map parameters) { - String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + appContext.getWorkspaceId() + "/compiler-settings/set"; + String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/compiler-settings/set"; JsonSerializable data = new JsonSerializable() { @Override @@ -62,7 +62,7 @@ public class SettingsServiceClientImpl implements SettingsServiceClient { /** {@inheritDoc} */ @Override public Promise> getCompileParameters() { - String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/" + appContext.getWorkspaceId() + "/compiler-settings/all"; + String url = appContext.getDevMachine().getWsAgentBaseUrl() + "/jdt/compiler-settings/all"; return asyncRequestFactory.createGetRequest(url) .header(ACCEPT, APPLICATION_JSON) diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/test/java/org/eclipse/che/ide/ext/java/client/organizeimports/OrganizeImportsPresenterTest.java b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/test/java/org/eclipse/che/ide/ext/java/client/organizeimports/OrganizeImportsPresenterTest.java index db5a4b6484..9d7114c59a 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-client/src/test/java/org/eclipse/che/ide/ext/java/client/organizeimports/OrganizeImportsPresenterTest.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-client/src/test/java/org/eclipse/che/ide/ext/java/client/organizeimports/OrganizeImportsPresenterTest.java @@ -107,9 +107,6 @@ public class OrganizeImportsPresenterTest { when(projectConfigDto.getPath()).thenReturn(PATH); when(file.getName()).thenReturn("A.java"); when(file.getPath()).thenReturn(PATH); - - when(appContext.getWorkspaceId()).thenReturn(WS_ID); - when(javaCodeAssistClient.organizeImports(anyString(), anyString())).thenReturn(importsPromise); when(importsPromise.then(Matchers.>>anyObject())).thenReturn(importsPromise); diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-server/src/main/java/org/eclipse/che/plugin/java/server/classpath/ClassPathBuilder.java b/plugins/plugin-java/che-plugin-java-ext-lang-server/src/main/java/org/eclipse/che/plugin/java/server/classpath/ClassPathBuilder.java index dcc3a1b16c..74e5f256c7 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-server/src/main/java/org/eclipse/che/plugin/java/server/classpath/ClassPathBuilder.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-server/src/main/java/org/eclipse/che/plugin/java/server/classpath/ClassPathBuilder.java @@ -25,8 +25,6 @@ public interface ClassPathBuilder { /** * Builds classpath for the current project. * - * @param workspaceId - * id of current workspace * @param projectPath * relative path to current project from the workspace * @return information about building project classpath @@ -35,5 +33,5 @@ public interface ClassPathBuilder { * @throws InterruptedException * if the current thread was interrupted */ - ClassPathBuilderResult buildClassPath(String workspaceId, String projectPath) throws ExecutionException, InterruptedException; + ClassPathBuilderResult buildClassPath(String projectPath) throws ExecutionException, InterruptedException; } diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-server/src/main/java/org/eclipse/che/plugin/java/server/rest/ClasspathService.java b/plugins/plugin-java/che-plugin-java-ext-lang-server/src/main/java/org/eclipse/che/plugin/java/server/rest/ClasspathService.java index 20f30933ff..518cd0ca47 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-server/src/main/java/org/eclipse/che/plugin/java/server/rest/ClasspathService.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-server/src/main/java/org/eclipse/che/plugin/java/server/rest/ClasspathService.java @@ -33,7 +33,7 @@ import static java.util.Collections.emptyList; * * @author Valeriy Svydenko */ -@Path("jdt/{wsId}/classpath/") +@Path("jdt/classpath/") public class ClasspathService { private static final JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel(); diff --git a/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-ide/src/main/java/org/eclipse/che/plugin/java/plain/client/service/ClasspathUpdaterServiceClientImpl.java b/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-ide/src/main/java/org/eclipse/che/plugin/java/plain/client/service/ClasspathUpdaterServiceClientImpl.java index 2672405be6..aa30b533a6 100644 --- a/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-ide/src/main/java/org/eclipse/che/plugin/java/plain/client/service/ClasspathUpdaterServiceClientImpl.java +++ b/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-ide/src/main/java/org/eclipse/che/plugin/java/plain/client/service/ClasspathUpdaterServiceClientImpl.java @@ -43,7 +43,7 @@ public class ClasspathUpdaterServiceClientImpl implements ClasspathUpdaterServic this.appContext = appContext; this.loader = loaderFactory.newLoader(); - this.pathToService = "/jdt/" + appContext.getWorkspaceId() + "/classpath/"; + this.pathToService = "/jdt/classpath/"; } @Override diff --git a/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/main/java/org/eclipse/che/plugin/java/plain/server/rest/ClasspathUpdaterService.java b/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/main/java/org/eclipse/che/plugin/java/plain/server/rest/ClasspathUpdaterService.java index 2fbb1d960b..e29b02c9ba 100644 --- a/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/main/java/org/eclipse/che/plugin/java/plain/server/rest/ClasspathUpdaterService.java +++ b/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/main/java/org/eclipse/che/plugin/java/plain/server/rest/ClasspathUpdaterService.java @@ -50,7 +50,7 @@ import static org.eclipse.jdt.core.JavaCore.newVariableEntry; * * @author Valeriy Svydenko */ -@Path("jdt/{wsId}/classpath/update") +@Path("jdt/classpath/update") public class ClasspathUpdaterService { private static final JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel(); diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/actions/CreateMavenModuleAction.java b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/actions/CreateMavenModuleAction.java deleted file mode 100644 index 0135d7c319..0000000000 --- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/actions/CreateMavenModuleAction.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.maven.client.actions; - -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import org.eclipse.che.ide.api.action.AbstractPerspectiveAction; -import org.eclipse.che.ide.api.action.ActionEvent; -import org.eclipse.che.ide.api.action.Presentation; -import org.eclipse.che.ide.api.app.AppContext; -import org.eclipse.che.ide.api.app.CurrentProject; -import org.eclipse.che.plugin.maven.client.MavenLocalizationConstant; -import org.eclipse.che.plugin.maven.client.MavenResources; -import org.eclipse.che.plugin.maven.client.module.CreateMavenModulePresenter; -import org.eclipse.che.plugin.maven.shared.MavenAttributes; - -import javax.validation.constraints.NotNull; -import java.util.Collections; - -import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID; - -/** - * Action for creating Maven module. - * - * @author Evgen Vidolob - * @author Artem Zatsarynnyi - */ -@Singleton -public class CreateMavenModuleAction extends AbstractPerspectiveAction { - - private final AppContext appContext; - private final CreateMavenModulePresenter presenter; - - @Inject - public CreateMavenModuleAction(MavenLocalizationConstant constant, - CreateMavenModulePresenter presenter, - AppContext appContext, - MavenResources mavenResources) { - super(Collections.singletonList(PROJECT_PERSPECTIVE_ID), - constant.actionCreateMavenModuleText(), - constant.actionCreateMavenModuleDescription(), - null, - mavenResources.maven()); - this.presenter = presenter; - this.appContext = appContext; - } - - @Override - public void actionPerformed(ActionEvent e) { - if (appContext.getCurrentProject() != null) { - presenter.showDialog(appContext.getCurrentProject()); - } - } - - @Override - public void updateInPerspective(@NotNull ActionEvent event) { - final Presentation presentation = event.getPresentation(); - final CurrentProject currentProject = appContext.getCurrentProject(); - if (currentProject == null) { - presentation.setEnabledAndVisible(false); - return; - } - - presentation.setVisible(MavenAttributes.MAVEN_ID.equals(currentProject.getRootProject().getType())); - presentation.setEnabled("pom".equals(currentProject.getAttributeValue(MavenAttributes.PACKAGING))); - } -} diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModulePresenter.java b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModulePresenter.java deleted file mode 100644 index 0d2b855f56..0000000000 --- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModulePresenter.java +++ /dev/null @@ -1,265 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.maven.client.module; - -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import org.eclipse.che.ide.api.project.ProjectServiceClient; -import org.eclipse.che.api.project.shared.dto.GeneratorDescription; -import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; -import org.eclipse.che.ide.api.app.AppContext; -import org.eclipse.che.ide.api.app.CurrentProject; -import org.eclipse.che.ide.api.project.node.HasStorablePath; -import org.eclipse.che.ide.api.selection.Selection; -import org.eclipse.che.ide.api.selection.SelectionAgent; -import org.eclipse.che.ide.dto.DtoFactory; -import org.eclipse.che.plugin.maven.client.MavenArchetype; -import org.eclipse.che.plugin.maven.client.MavenExtension; -import org.eclipse.che.plugin.maven.client.MavenLocalizationConstant; -import org.eclipse.che.ide.part.explorer.project.ProjectExplorerPresenter; -import org.eclipse.che.ide.project.node.ModuleNode; -import org.eclipse.che.ide.project.node.ProjectNode; -import org.eclipse.che.ide.rest.AsyncRequestCallback; -import org.eclipse.che.ide.rest.DtoUnmarshallerFactory; -import org.eclipse.che.ide.api.dialogs.DialogFactory; -import org.eclipse.che.ide.util.NameUtils; -import org.eclipse.che.ide.util.loging.Log; - -import javax.validation.constraints.NotNull; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.eclipse.che.plugin.maven.shared.MavenAttributes.ARCHETYPE_GENERATION_STRATEGY; -import static org.eclipse.che.plugin.maven.shared.MavenAttributes.ARTIFACT_ID; -import static org.eclipse.che.plugin.maven.shared.MavenAttributes.GROUP_ID; -import static org.eclipse.che.plugin.maven.shared.MavenAttributes.MAVEN_ID; -import static org.eclipse.che.plugin.maven.shared.MavenAttributes.PACKAGING; -import static org.eclipse.che.plugin.maven.shared.MavenAttributes.PARENT_ARTIFACT_ID; -import static org.eclipse.che.plugin.maven.shared.MavenAttributes.PARENT_GROUP_ID; -import static org.eclipse.che.plugin.maven.shared.MavenAttributes.PARENT_VERSION; -import static org.eclipse.che.plugin.maven.shared.MavenAttributes.VERSION; - -/** - * @author Evgen Vidolob - * @author Dmitry Shnurenko - */ -@Singleton -public class CreateMavenModulePresenter implements CreateMavenModuleView.ActionDelegate { - - private final AppContext appContext; - private final CreateMavenModuleView view; - private final ProjectServiceClient projectService; - private final DtoFactory dtoFactory; - private final DialogFactory dialogFactory; - private final ProjectExplorerPresenter projectExplorer; - private final MavenLocalizationConstant locale; - private final SelectionAgent selectionAgent; - private final DtoUnmarshallerFactory unmarshallerFactory; - - private String moduleName; - - private String artifactId; - private CurrentProject parentProject; - - @Inject - public CreateMavenModulePresenter(AppContext appContext, - CreateMavenModuleView view, - ProjectServiceClient projectServiceClient, - DtoFactory dtoFactory, - DialogFactory dialogFactory, - ProjectExplorerPresenter projectExplorer, - MavenLocalizationConstant locale, - SelectionAgent selectionAgent, - DtoUnmarshallerFactory unmarshallerFactory) { - this.view = view; - this.view.setDelegate(this); - - this.appContext = appContext; - this.projectService = projectServiceClient; - this.dtoFactory = dtoFactory; - this.dialogFactory = dialogFactory; - this.projectExplorer = projectExplorer; - this.locale = locale; - this.selectionAgent = selectionAgent; - this.unmarshallerFactory = unmarshallerFactory; - } - - public void showDialog(@NotNull CurrentProject project) { - parentProject = project; - view.setParentArtifactId(project.getAttributeValue(ARTIFACT_ID)); - view.setGroupId(project.getAttributeValue(GROUP_ID)); - view.setVersion(project.getAttributeValue(VERSION)); - view.reset(); - view.show(); - updateViewState(); - } - - @Override - public void onClose() { - } - - @Override - public void create() { - ProjectConfigDto projectConfig = dtoFactory.createDto(ProjectConfigDto.class); - projectConfig.setType(MAVEN_ID); - - Map> attributes = new HashMap<>(); - attributes.put(ARTIFACT_ID, Arrays.asList(artifactId)); - attributes.put(GROUP_ID, Arrays.asList(view.getGroupId())); - attributes.put(VERSION, Arrays.asList(view.getVersion())); - attributes.put(PACKAGING, Arrays.asList(view.getPackaging())); - attributes.put(PARENT_ARTIFACT_ID, Arrays.asList(parentProject.getAttributeValue(ARTIFACT_ID))); - attributes.put(PARENT_GROUP_ID, Arrays.asList(parentProject.getAttributeValue(GROUP_ID))); - attributes.put(PARENT_VERSION, Arrays.asList(parentProject.getAttributeValue(VERSION))); - - projectConfig.setAttributes(attributes); - projectConfig.setName(view.getName()); - - view.showButtonLoader(true); - - String pathToSelectedNode = getPathToSelectedNode(); - - if (pathToSelectedNode.isEmpty()) { - showErrorDialog(locale.mavenCreateModuleMultySelectionError()); - - return; - } - - projectService.createModule(appContext.getDevMachine(), - pathToSelectedNode, - projectConfig, - new AsyncRequestCallback( - unmarshallerFactory.newUnmarshaller(ProjectConfigDto.class)) { - @Override - protected void onSuccess(ProjectConfigDto addedModule) { - view.close(); - view.showButtonLoader(false); - - Selection selection = selectionAgent.getSelection(); - - HasStorablePath parentFolder = (HasStorablePath)selection.getHeadElement(); - - boolean isModule = parentFolder instanceof ModuleNode; - boolean isProject = parentFolder instanceof ProjectNode; - - // TODO: rework after new Project API - ProjectConfigDto projectConfigDto = appContext.getCurrentProject().getProjectConfig(); - -// ProjectConfigDto parentConfig = -// projectConfigDto.findModule(parentFolder.getStorablePath()); - -// if (parentConfig == null) { -// throw new IllegalArgumentException("Parent folder not found for " + addedModule.getPath()); -// } - -// parentConfig.getModules().add(addedModule); - - if (isModule) { - projectExplorer.reloadChildren((ModuleNode)parentFolder); - } - - if (isProject) { - projectExplorer.reloadChildren((ProjectNode)parentFolder); - } - } - - @Override - protected void onFailure(Throwable exception) { - showErrorDialog(exception.getMessage()); - } - }); - } - - private String getPathToSelectedNode() { - Selection selection = projectExplorer.getSelection(); - - if (selection.isMultiSelection() || selection.isEmpty()) { - return ""; - } - - Object selectedElement = selection.getHeadElement(); - - if (selectedElement instanceof HasStorablePath) { - return ((HasStorablePath)selectedElement).getStorablePath(); - } - - return ""; - } - - private void showErrorDialog(String error) { - view.showButtonLoader(false); - dialogFactory.createMessageDialog("", error, null).show(); - Log.error(CreateMavenModulePresenter.class, error); - } - - @Override - public void projectNameChanged(String name) { - if (NameUtils.checkProjectName(name)) { - moduleName = name; - } else { - moduleName = null; - } - updateViewState(); - } - - private void updateViewState() { - if (moduleName == null) { - view.setNameError(true); - view.setCreateButtonEnabled(false); - } else { - view.setNameError(false); - if (artifactId == null) { - view.setArtifactIdError(true); - view.setCreateButtonEnabled(false); - } else { - view.setArtifactIdError(false); - view.setCreateButtonEnabled(true); - } - } - view.enableArchetypes(view.isGenerateFromArchetypeSelected()); - view.setPackagingVisibility(!view.isGenerateFromArchetypeSelected()); - } - - @Override - public void artifactIdChanged(String artifactId) { - if (NameUtils.checkProjectName(artifactId)) { - this.artifactId = artifactId; - } else { - this.artifactId = null; - } - updateViewState(); - } - - @Override - public void generateFromArchetypeChanged(boolean isGenerateFromArchetype) { - updateViewState(); - if (!isGenerateFromArchetype) { - view.clearArchetypes(); - } else { - view.setArchetypes(MavenExtension.getAvailableArchetypes()); - } - } - - private GeneratorDescription getGeneratorDescription(MavenArchetype archetype) { - HashMap options = new HashMap<>(); - options.put("type", ARCHETYPE_GENERATION_STRATEGY); - options.put("archetypeGroupId", archetype.getGroupId()); - options.put("archetypeArtifactId", archetype.getArtifactId()); - options.put("archetypeVersion", archetype.getVersion()); - if (archetype.getRepository() != null) { - options.put("archetypeRepository", archetype.getRepository()); - } - return dtoFactory.createDto(GeneratorDescription.class).withOptions(options); - } -} diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModuleView.java b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModuleView.java deleted file mode 100644 index d2366e9ac1..0000000000 --- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModuleView.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.maven.client.module; - -import org.eclipse.che.ide.api.mvp.View; -import org.eclipse.che.plugin.maven.client.MavenArchetype; - -import com.google.inject.ImplementedBy; - -import java.util.List; - -/** - * @author Evgen Vidolob - * @author Dmitry Shnurenko - */ -@ImplementedBy(CreateMavenModuleViewImpl.class) -public interface CreateMavenModuleView extends View { - - MavenArchetype getArchetype(); - - void setArchetypes(List archetypes); - - void enableArchetypes(boolean enabled); - - boolean isGenerateFromArchetypeSelected(); - - void setParentArtifactId(String artifactId); - - void setGroupId(String groupId); - - void setVersion(String version); - - void setCreateButtonEnabled(boolean enabled); - - void setNameError(boolean hasError); - - void setArtifactIdError(boolean hasError); - - void reset(); - - String getPackaging(); - - String getGroupId(); - - String getVersion(); - - String getArtifactId(); - - String getName(); - - void setPackagingVisibility(boolean visible); - - void close(); - - void showButtonLoader(boolean showLoader); - - void clearArchetypes(); - - public interface ActionDelegate{ - - void onClose(); - - void create(); - - void projectNameChanged(String name); - - void artifactIdChanged(String artifactId); - - void generateFromArchetypeChanged(boolean isGenerateFromArchetype); - } - - void show(); -} diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModuleViewImpl.java b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModuleViewImpl.java deleted file mode 100644 index 454b3b4688..0000000000 --- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModuleViewImpl.java +++ /dev/null @@ -1,258 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.maven.client.module; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.dom.client.KeyCodes; -import com.google.gwt.event.dom.client.KeyUpEvent; -import com.google.gwt.event.logical.shared.ValueChangeEvent; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; -import com.google.gwt.uibinder.client.UiHandler; -import com.google.gwt.user.client.ui.Button; -import com.google.gwt.user.client.ui.CheckBox; -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.ListBox; -import com.google.gwt.user.client.ui.TextBox; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import org.eclipse.che.plugin.maven.client.MavenArchetype; -import org.eclipse.che.ide.ui.buttonLoader.ButtonLoaderResources; -import org.eclipse.che.ide.ui.window.Window; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Evgen Vidolob - * @author Dmitry Shnurenko - */ -@Singleton -public class CreateMavenModuleViewImpl extends Window implements CreateMavenModuleView { - public static final String CREATE = "Create"; - private static CreateMavenModuleViewImplUiBinder ourUiBinder = GWT.create(CreateMavenModuleViewImplUiBinder.class); - private final Button createButton; - @UiField - CheckBox generateFromArchetype; - @UiField - Label archetypeLabel; - @UiField - ListBox archetypeField; - @UiField - TextBox parentArtifactId; - @UiField - TextBox nameField; - @UiField - TextBox artifactId; - @UiField - TextBox groupIdField; - @UiField - TextBox versionField; - @UiField - Label packagingLabel; - @UiField - ListBox packagingField; - @UiField(provided = true) - CreateMavenModuleResources.Css styles; - private List archetypes; - private ActionDelegate delegate; - - @Inject - public CreateMavenModuleViewImpl(CreateMavenModuleResources resources, - ButtonLoaderResources buttonLoaderResources) { - super(true); - styles = resources.css(); - styles.ensureInjected(); - archetypes = new ArrayList<>(); - setTitle("Create Maven Module"); - FlowPanel rootElement = ourUiBinder.createAndBindUi(this); - setWidget(rootElement); - createButton = createPrimaryButton(CREATE, "mavenPageView-createButton", new ClickHandler() { - @Override - public void onClick(ClickEvent event) { - delegate.create(); - } - }); - addButtonToFooter(createButton); - createButton.addStyleName(buttonLoaderResources.Css().buttonLoader()); - } - - @UiHandler("nameField") - void onNameChanged(KeyUpEvent event) { - if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { - return; - } - - delegate.projectNameChanged(nameField.getText()); - } - - @UiHandler("artifactId") - void onArtifactChanged(KeyUpEvent event) { - if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { - return; - } - - delegate.artifactIdChanged(artifactId.getText()); - } - - @UiHandler({"generateFromArchetype"}) - void generateFromArchetypeHandler(ValueChangeEvent event) { - delegate.generateFromArchetypeChanged(generateFromArchetype.getValue()); - } - - @Override - protected void onClose() { - delegate.onClose(); - } - - @Override - public void setDelegate(ActionDelegate delegate) { - this.delegate = delegate; - } - - @Override - public MavenArchetype getArchetype() { - final String coordinates = archetypeField.getValue(archetypeField.getSelectedIndex()); - for (MavenArchetype archetype : archetypes) { - if (coordinates.equals(archetype.toString())) { - return archetype; - } - } - return null; - } - - @Override - public void setArchetypes(List archetypes) { - this.archetypes.clear(); - this.archetypes.addAll(archetypes); - archetypeField.clear(); - for (MavenArchetype archetype : archetypes) { - archetypeField.addItem(archetype.toString(), archetype.toString()); - } - } - - @Override - public void enableArchetypes(boolean enabled) { - archetypeField.setEnabled(enabled); - } - - @Override - public boolean isGenerateFromArchetypeSelected() { - return generateFromArchetype.getValue(); - } - - @Override - public void setParentArtifactId(String artifactId) { - parentArtifactId.setValue(artifactId); - } - - @Override - public void setCreateButtonEnabled(boolean enabled) { - createButton.setEnabled(enabled); - } - - @Override - public void setNameError(boolean hasError) { - if (hasError) { - nameField.addStyleName(styles.inputError()); - } else { - nameField.removeStyleName(styles.inputError()); - } - } - - @Override - public void setArtifactIdError(boolean hasError) { - if (hasError) { - artifactId.addStyleName(styles.inputError()); - } else { - artifactId.removeStyleName(styles.inputError()); - } - } - - @Override - public void reset() { - nameField.setValue(""); - artifactId.setValue(""); - generateFromArchetype.setValue(false); - archetypes.clear(); - archetypeField.clear(); - } - - @Override - public String getPackaging() { - return packagingField.getValue(packagingField.getSelectedIndex()); - } - - @Override - public String getGroupId() { - return groupIdField.getText(); - } - - @Override - public void setGroupId(String groupId) { - groupIdField.setValue(groupId); - } - - @Override - public String getVersion() { - return versionField.getText(); - } - - @Override - public String getArtifactId() { - return artifactId.getText(); - } - - @Override - public String getName() { - return nameField.getText(); - } - - @Override - public void setVersion(String version) { - versionField.setValue(version); - } - - @Override - public void setPackagingVisibility(boolean visible) { - packagingLabel.setVisible(visible); - packagingField.setVisible(visible); - } - - @Override - public void close() { - hide(); - } - - @Override - public void showButtonLoader(boolean showLoader) { - if (showLoader) { - createButton.setEnabled(false); - createButton.setHTML(""); - } else { - createButton.setEnabled(true); - createButton.setText(CREATE); - } - } - - @Override - public void clearArchetypes() { - archetypes.clear(); - archetypeField.clear(); - } - - interface CreateMavenModuleViewImplUiBinder extends UiBinder { - } -} diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModuleViewImpl.ui.xml b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModuleViewImpl.ui.xml deleted file mode 100644 index 3201e83fc4..0000000000 --- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModuleViewImpl.ui.xml +++ /dev/null @@ -1,166 +0,0 @@ - - - - - .rootPanel { - position: relative; - text-shadow: 0 .4px 0 rgba(0, 0, 0, 0.5); - } - - .projectNamePosition { - position: relative; - line-height: 29px; - margin-left: 20px; - - } - - .spaceRight { - margin-right: 8px; - margin-top: 1px; - } - - .mainDoc { - margin: 15px; - } - - .checkBoxPosition { - position: relative; - top: 5px; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - JAR - WAR - POM - - - - - - - - - diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/service/MavenServerServiceClientImpl.java b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/service/MavenServerServiceClientImpl.java index abad2934df..cd15fc3da2 100644 --- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/service/MavenServerServiceClientImpl.java +++ b/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/service/MavenServerServiceClientImpl.java @@ -49,7 +49,7 @@ public class MavenServerServiceClientImpl implements MavenServerServiceClient { this.loaderFactory = loaderFactory; this.asyncRequestFactory = asyncRequestFactory; this.dtoUnmarshallerFactory = dtoUnmarshallerFactory; - this.servicePath = "/maven/" + appContext.getWorkspace().getId() + "/server/"; + this.servicePath = "/maven/server/"; } @Override diff --git a/plugins/plugin-maven/che-plugin-maven-server/pom.xml b/plugins/plugin-maven/che-plugin-maven-server/pom.xml index 692d237d47..cd4994096d 100644 --- a/plugins/plugin-maven/che-plugin-maven-server/pom.xml +++ b/plugins/plugin-maven/che-plugin-maven-server/pom.xml @@ -86,6 +86,10 @@ org.eclipse.che.core che-core-commons-xml + + org.eclipse.che.core + wsagent-local + org.eclipse.che.plugin che-plugin-java-ext-lang-server diff --git a/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/MavenClassPathBuilder.java b/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/MavenClassPathBuilder.java index 584cf3e85d..cf402ed364 100644 --- a/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/MavenClassPathBuilder.java +++ b/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/MavenClassPathBuilder.java @@ -13,6 +13,7 @@ package org.eclipse.che.plugin.maven.server.core; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.inject.Inject; +import org.eclipse.che.WorkspaceIdProvider; import org.eclipse.che.api.core.util.CancellableProcessWrapper; import org.eclipse.che.api.core.util.ProcessUtil; import org.eclipse.che.api.core.util.StreamPump; @@ -55,13 +56,11 @@ public class MavenClassPathBuilder implements ClassPathBuilder { private final ExecutorService executorService; private final ProjectManager projectManager; - private String workspaceId; - @Inject - public MavenClassPathBuilder(ProjectManager projectManager, MavenClasspathContainerInitializer containerInitializer) { + public MavenClassPathBuilder(ProjectManager projectManager, + MavenClasspathContainerInitializer containerInitializer) { this.projectManager = projectManager; - ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(MavenClassPathBuilder.class.getSimpleName() + "-%d").build(); executorService = Executors.newFixedThreadPool(5, threadFactory); @@ -69,9 +68,7 @@ public class MavenClassPathBuilder implements ClassPathBuilder { /** {@inheritDoc} */ @Override - public ClassPathBuilderResult buildClassPath(String workspaceId, String projectPath) throws ExecutionException, InterruptedException { - this.workspaceId = workspaceId; - + public ClassPathBuilderResult buildClassPath(String projectPath) throws ExecutionException, InterruptedException { //TODO Temporary solution for IDEX-4270 try { RegisteredProject project = projectManager.getProject(projectPath); @@ -140,7 +137,7 @@ public class MavenClassPathBuilder implements ClassPathBuilder { + "due to timeout. Project: " + projectPath))); - String channel = "dependencyUpdate:output:" + workspaceId + ':' + projectPath; + String channel = "dependencyUpdate:output:" + WorkspaceIdProvider.getWorkspaceId() + ':' + projectPath; classPathBuilderResult.setChannel(channel); diff --git a/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/rest/MavenServerService.java b/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/rest/MavenServerService.java index a9d2374a97..64e5c3690c 100644 --- a/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/rest/MavenServerService.java +++ b/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/rest/MavenServerService.java @@ -56,7 +56,7 @@ import static javax.ws.rs.core.MediaType.TEXT_XML; * * @author Valeriy Svydenko */ -@Path("/maven/{wsId}/server") +@Path("/maven/server") public class MavenServerService { private static final Logger LOG = LoggerFactory.getLogger(MavenServerService.class); @@ -65,9 +65,6 @@ public class MavenServerService { private final MavenProjectManager mavenProjectManager; private final ProjectManager cheProjectManager; - @PathParam("wsId") - private String workspaceId; - @Inject private MavenProgressNotifier notifier; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientServiceImpl.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientServiceImpl.java index 25abf34c6b..f22a842b84 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientServiceImpl.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientServiceImpl.java @@ -88,7 +88,7 @@ public class SubversionClientServiceImpl implements SubversionClientService { } private String getBaseUrl() { - return appContext.getDevMachine().getWsAgentBaseUrl() + "/svn/" + appContext.getWorkspaceId(); + return appContext.getDevMachine().getWsAgentBaseUrl() + "/svn"; } @Override diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/rest/SubversionService.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/rest/SubversionService.java index 9b1cd2092d..6f059374eb 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/rest/SubversionService.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/rest/SubversionService.java @@ -71,7 +71,7 @@ import java.io.IOException; /** * REST API endpoints for this extension. */ -@Path("svn/{ws-id}") +@Path("svn") public class SubversionService extends Service { private static final Logger LOG = LoggerFactory.getLogger(SubversionService.class); @@ -85,8 +85,6 @@ public class SubversionService extends Service { @Inject private CredentialsProvider credentialsProvider; - @PathParam("ws-id") - private String vfsId; /** * Add the selected paths to version control. diff --git a/wsagent/che-core-api-debug/src/main/java/org/eclipse/che/api/debugger/server/DebuggerService.java b/wsagent/che-core-api-debug/src/main/java/org/eclipse/che/api/debugger/server/DebuggerService.java index c9760f1ac7..d727110dc9 100644 --- a/wsagent/che-core-api-debug/src/main/java/org/eclipse/che/api/debugger/server/DebuggerService.java +++ b/wsagent/che-core-api-debug/src/main/java/org/eclipse/che/api/debugger/server/DebuggerService.java @@ -58,7 +58,7 @@ import static org.eclipse.che.dto.server.DtoFactory.newDto; * * @author Anatoliy Bazko */ -@Path("debugger/{ws-id}") +@Path("debugger") public class DebuggerService { private final DebuggerManager debuggerManager; diff --git a/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitService.java b/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitService.java index 30491e746b..9743d4376d 100644 --- a/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitService.java +++ b/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitService.java @@ -75,7 +75,7 @@ import java.util.List; import java.util.Map; /** @author andrew00x */ -@Path("git/{ws-id}") +@Path("git") public class GitService { private static final Logger LOG = LoggerFactory.getLogger(GitService.class); @@ -86,9 +86,6 @@ public class GitService { @Inject private ProjectRegistry projectRegistry; - @PathParam("ws-id") - private String workspace; - @QueryParam("projectPath") private String projectPath; diff --git a/wsagent/che-core-api-project/pom.xml b/wsagent/che-core-api-project/pom.xml index 064f97a75d..50ab3361df 100644 --- a/wsagent/che-core-api-project/pom.xml +++ b/wsagent/che-core-api-project/pom.xml @@ -119,6 +119,10 @@ org.eclipse.che.core che-core-commons-lang + + org.eclipse.che.core + wsagent-local + org.everrest everrest-core diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectService.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectService.java index 862651c58a..98a1e93cf2 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectService.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectService.java @@ -18,6 +18,7 @@ import io.swagger.annotations.ApiResponses; import org.apache.commons.fileupload.FileItem; import org.apache.tika.Tika; +import org.eclipse.che.WorkspaceIdProvider; import org.eclipse.che.api.core.BadRequestException; import org.eclipse.che.api.core.ConflictException; import org.eclipse.che.api.core.ForbiddenException; @@ -105,19 +106,21 @@ import static org.eclipse.che.dto.server.DtoFactory.newDto; * @author Dmitry Shnurenko */ @Api(value = "/project", description = "Project REST API") -@Path("/project/{ws-id}") +@Path("/project") @Singleton public class ProjectService extends Service { private static final Logger LOG = LoggerFactory.getLogger(ProjectService.class); private static final Tika TIKA = new Tika(); - private ProjectManager projectManager; - private EventService eventService; + private final ProjectManager projectManager; + private final EventService eventService; + private final String workspace; @Inject public ProjectService(ProjectManager projectManager, EventService eventService) { this.projectManager = projectManager; this.eventService = eventService; + this.workspace = WorkspaceIdProvider.getWorkspaceId(); } @GET @@ -128,14 +131,13 @@ public class ProjectService extends Service { @ApiResponses({@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 500, message = "Server error")}) @GenerateLink(rel = LINK_REL_GET_PROJECTS) - public List getProjects(@ApiParam("ID of workspace to get projects") - @PathParam("ws-id") String workspace) throws IOException, - ServerException, - ConflictException, - ForbiddenException { + public List getProjects() throws IOException, + ServerException, + ConflictException, + ForbiddenException { return projectManager.getProjects() .stream() - .map(p -> injectProjectLinks(asDto(p), workspace)) + .map(p -> injectProjectLinks(asDto(p))) .collect(Collectors.toList()); } @@ -148,14 +150,12 @@ public class ProjectService extends Service { @ApiResponse(code = 404, message = "Project with specified path doesn't exist in workspace"), @ApiResponse(code = 403, message = "Access to requested project is forbidden"), @ApiResponse(code = 500, message = "Server error")}) - public ProjectConfigDto getProject(@ApiParam(value = "ID of workspace to get projects", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path to requested project", required = true) + public ProjectConfigDto getProject(@ApiParam(value = "Path to requested project", required = true) @PathParam("path") String path) throws NotFoundException, ForbiddenException, ServerException, ConflictException { - return injectProjectLinks(asDto(projectManager.getProject(path)), workspace); + return injectProjectLinks(asDto(projectManager.getProject(path))); } @POST @@ -171,9 +171,7 @@ public class ProjectService extends Service { /** * NOTE: parentPath is added to make a module */ - public ProjectConfigDto createProject(@ApiParam(value = "ID of workspace to create project", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Add to this project as module", required = false) + public ProjectConfigDto createProject(@ApiParam(value = "Add to this project as module", required = false) @Description("descriptor of project") ProjectConfigDto projectConfig) throws ConflictException, ForbiddenException, ServerException, @@ -196,7 +194,7 @@ public class ProjectService extends Service { // TODO this throws NPE //logProjectCreatedEvent(configDto.getName(), configDto.getProjectType()); - return injectProjectLinks(configDto, workspace); + return injectProjectLinks(configDto); } @PUT @@ -210,9 +208,7 @@ public class ProjectService extends Service { @ApiResponse(code = 403, message = "Operation is forbidden"), @ApiResponse(code = 409, message = "Update operation causes conflicts"), @ApiResponse(code = 500, message = "Server error")}) - public ProjectConfigDto updateProject(@ApiParam(value = "ID of workspace", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path to updated project", required = true) + public ProjectConfigDto updateProject(@ApiParam(value = "Path to updated project", required = true) @PathParam("path") String path, ProjectConfigDto projectConfigDto) throws NotFoundException, ConflictException, @@ -235,9 +231,7 @@ public class ProjectService extends Service { @ApiResponse(code = 403, message = "User not authorized to call this operation"), @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public void delete(@ApiParam("Workspace ID") - @PathParam("ws-id") String workspace, - @ApiParam("Path to a resource to be deleted") + public void delete(@ApiParam("Path to a resource to be deleted") @PathParam("path") String path) throws NotFoundException, ForbiddenException, ConflictException, ServerException { projectManager.delete(path); } @@ -251,9 +245,7 @@ public class ProjectService extends Service { @ApiResponse(code = 404, message = "Project with specified path doesn't exist in workspace"), @ApiResponse(code = 403, message = "Access to requested project is forbidden"), @ApiResponse(code = 500, message = "Server error")}) - public SourceEstimation estimateProject(@ApiParam(value = "ID of workspace to estimate projects", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path to requested project", required = true) + public SourceEstimation estimateProject(@ApiParam(value = "Path to requested project", required = true) @PathParam("path") String path, @ApiParam(value = "Project Type ID to estimate against", required = true) @QueryParam("type") String projectType) throws NotFoundException, @@ -276,9 +268,7 @@ public class ProjectService extends Service { @GET @Path("/resolve/{path:.*}") @Produces(MediaType.APPLICATION_JSON) - public List resolveSources(@ApiParam(value = "ID of workspace to estimate projects", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path to requested project", required = true) + public List resolveSources(@ApiParam(value = "Path to requested project", required = true) @PathParam("path") String path) throws NotFoundException, ForbiddenException, ServerException, @@ -312,9 +302,7 @@ public class ProjectService extends Service { @ApiResponse(code = 403, message = "Forbidden operation"), @ApiResponse(code = 409, message = "Resource already exists"), @ApiResponse(code = 500, message = "Unsupported source type")}) - public void importProject(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path in the project", required = true) + public void importProject(@ApiParam(value = "Path in the project", required = true) @PathParam("path") String path, @ApiParam(value = "Force rewrite existing project", allowableValues = "true,false") @QueryParam("force") boolean force, @@ -339,9 +327,7 @@ public class ProjectService extends Service { @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 409, message = "File already exists"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public Response createFile(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path to a target directory", required = true) + public Response createFile(@ApiParam(value = "Path to a target directory", required = true) @PathParam("parent") String parentPath, @ApiParam(value = "New file name", required = true) @QueryParam("name") String fileName, @@ -362,9 +348,9 @@ public class ProjectService extends Service { final URI location = getServiceContext().getServiceUriBuilder().clone() .path(getClass(), "getFile") - .build(workspace, newFile.getPath().toString().substring(1)); + .build(newFile.getPath().toString().substring(1)); return Response.created(location) - .entity(injectFileLinks(asDto(newFile), workspace)) + .entity(injectFileLinks(asDto(newFile))) .build(); } @@ -378,9 +364,7 @@ public class ProjectService extends Service { @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 409, message = "File already exists"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public Response createFolder(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path to a new folder destination", required = true) + public Response createFolder(@ApiParam(value = "Path to a new folder destination", required = true) @PathParam("path") String path) throws ConflictException, ForbiddenException, ServerException, @@ -388,7 +372,7 @@ public class ProjectService extends Service { final FolderEntry newFolder = projectManager.getProjectsRoot().createFolder(path); final URI location = getServiceContext().getServiceUriBuilder().clone() .path(getClass(), "getChildren") - .build(workspace, newFolder.getPath().toString().substring(1)); + .build(newFolder.getPath().toString().substring(1)); eventService.publish(new ProjectItemModifiedEvent(ProjectItemModifiedEvent.EventType.CREATED, workspace, @@ -397,7 +381,7 @@ public class ProjectService extends Service { true)); return Response.created(location) - .entity(injectFolderLinks(asDto(newFolder), workspace)) + .entity(injectFolderLinks(asDto(newFolder))) .build(); } @@ -412,9 +396,7 @@ public class ProjectService extends Service { @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 409, message = "File already exists"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public Response uploadFile(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Destination path", required = true) + public Response uploadFile(@ApiParam(value = "Destination path", required = true) @PathParam("parent") String parentPath, Iterator formData) throws NotFoundException, ConflictException, @@ -442,9 +424,7 @@ public class ProjectService extends Service { @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 409, message = "Resource already exists"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public Response uploadFolderFromZip(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path in the project", required = true) + public Response uploadFolderFromZip(@ApiParam(value = "Path in the project", required = true) @PathParam("path") String path, Iterator formData) throws ServerException, ConflictException, @@ -467,11 +447,12 @@ public class ProjectService extends Service { @ApiResponse(code = 500, message = "Internal Server Error")}) @GET @Path("/file/{path:.*}") - public Response getFile(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path to a file", required = true) + public Response getFile(@ApiParam(value = "Path to a file", required = true) @PathParam("path") String path) throws IOException, NotFoundException, ForbiddenException, ServerException { final FileEntry file = projectManager.asFile(path); + if (file == null) { + throw new NotFoundException("File not found for " + path); + } return Response.ok().entity(file.getInputStream()).type(TIKA.detect(file.getName())).build(); } @@ -484,9 +465,7 @@ public class ProjectService extends Service { @ApiResponse(code = 403, message = "User not authorized to call this operation"), @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public Response updateFile(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Full path to a file", required = true) + public Response updateFile(@ApiParam(value = "Full path to a file", required = true) @PathParam("path") String path, InputStream content) throws NotFoundException, ForbiddenException, ServerException { final FileEntry file = projectManager.asFile(path); @@ -516,8 +495,7 @@ public class ProjectService extends Service { @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 409, message = "Resource already exists"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public Response copy(@ApiParam("Workspace ID") @PathParam("ws-id") String workspace, - @ApiParam("Path to a resource") @PathParam("path") String path, + public Response copy(@ApiParam("Path to a resource") @PathParam("path") String path, @ApiParam(value = "Path to a new location", required = true) @QueryParam("to") String newParent, CopyOptions copyOptions) throws NotFoundException, ForbiddenException, @@ -542,7 +520,7 @@ public class ProjectService extends Service { final URI location = getServiceContext().getServiceUriBuilder() .path(getClass(), copy.isFile() ? "getFile" : "getChildren") - .build(workspace, copy.getPath().toString().substring(1)); + .build(copy.getPath().toString().substring(1)); if (copy.isFolder()) { try { @@ -567,8 +545,7 @@ public class ProjectService extends Service { @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 409, message = "Resource already exists"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public Response move(@ApiParam("Workspace ID") @PathParam("ws-id") String workspace, - @ApiParam("Path to a resource to be moved") @PathParam("path") String path, + public Response move(@ApiParam("Path to a resource to be moved") @PathParam("path") String path, @ApiParam("Path to a new location") @QueryParam("to") String newParent, MoveOptions moveOptions) throws NotFoundException, ForbiddenException, ConflictException, ServerException { final VirtualFileEntry entry = projectManager.asVirtualFileEntry(path); @@ -590,7 +567,7 @@ public class ProjectService extends Service { final URI location = getServiceContext().getServiceUriBuilder() .path(getClass(), move.isFile() ? "getFile" : "getChildren") - .build(workspace, move.getPath().toString().substring(1)); + .build(move.getPath().toString().substring(1)); eventService.publish(new ProjectItemModifiedEvent(ProjectItemModifiedEvent.EventType.MOVED, workspace, @@ -614,9 +591,7 @@ public class ProjectService extends Service { @ApiResponse(code = 403, message = "Forbidden operation"), @ApiResponse(code = 409, message = "Resource already exists"), @ApiResponse(code = 500, message = "Unsupported source type")}) - public List uploadProjectFromZip(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path in the project", required = true) + public List uploadProjectFromZip(@ApiParam(value = "Path in the project", required = true) @PathParam("path") String path, @ApiParam(value = "Force rewrite existing project", allowableValues = "true,false") @QueryParam("force") boolean force, @@ -665,7 +640,7 @@ public class ProjectService extends Service { baseProjectFolder.getVirtualFile().unzip(zip, true, stripNumber); } - return resolveSources(workspace, path); + return resolveSources(path); } @POST @@ -678,9 +653,7 @@ public class ProjectService extends Service { @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 409, message = "Resource already exists"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public Response importZip(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path to a location (where import to?)") + public Response importZip(@ApiParam(value = "Path to a location (where import to?)") @PathParam("path") String path, InputStream zip, @DefaultValue("false") @QueryParam("skipFirstLevel") Boolean skipFirstLevel) throws NotFoundException, @@ -705,7 +678,7 @@ public class ProjectService extends Service { return Response.created(getServiceContext().getServiceUriBuilder() .path(getClass(), "getChildren") - .build(workspace, parent.getPath().toString().substring(1))).build(); + .build(parent.getPath().toString().substring(1))).build(); } @GET @@ -717,9 +690,7 @@ public class ProjectService extends Service { @ApiResponse(code = 403, message = "User not authorized to call this operation"), @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public InputStream exportZip(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path to resource to be exported") + public InputStream exportZip(@ApiParam(value = "Path to resource to be exported") @PathParam("path") String path) throws NotFoundException, ForbiddenException, ServerException { final FolderEntry folder = projectManager.asFolder(path); @@ -734,9 +705,7 @@ public class ProjectService extends Service { @GET @Path("/export/file/{path:.*}") @Produces(MediaType.APPLICATION_OCTET_STREAM) - public Response exportFile(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path to resource to be imported") + public Response exportFile(@ApiParam(value = "Path to resource to be imported") @PathParam("path") String path) throws NotFoundException, ForbiddenException, ServerException { final FileEntry file = projectManager.asFile(path); @@ -765,9 +734,7 @@ public class ProjectService extends Service { @ApiResponse(code = 403, message = "User not authorized to call this operation"), @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public List getChildren(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path to a project", required = true) + public List getChildren(@ApiParam(value = "Path to a project", required = true) @PathParam("parent") String path) throws NotFoundException, ForbiddenException, ServerException { @@ -781,9 +748,9 @@ public class ProjectService extends Service { final ArrayList result = new ArrayList<>(children.size()); for (VirtualFileEntry child : children) { if (child.isFile()) { - result.add(injectFileLinks(asDto((FileEntry)child), workspace)); + result.add(injectFileLinks(asDto((FileEntry)child))); } else { - result.add(injectFolderLinks(asDto((FolderEntry)child), workspace)); + result.add(injectFolderLinks(asDto((FolderEntry)child))); } } @@ -800,9 +767,7 @@ public class ProjectService extends Service { @ApiResponse(code = 403, message = "User not authorized to call this operation"), @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public TreeElement getTree(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path to resource. Can be project or its folders", required = true) + public TreeElement getTree(@ApiParam(value = "Path to resource. Can be project or its folders", required = true) @PathParam("parent") String path, @ApiParam(value = "Tree depth. This parameter can be dropped. If not specified ?depth=1 is used by default") @DefaultValue("1") @QueryParam("depth") int depth, @@ -813,8 +778,8 @@ public class ProjectService extends Service { ServerException { final FolderEntry folder = projectManager.asFolder(path); - return newDto(TreeElement.class).withNode(injectFolderLinks(asDto(folder), workspace)) - .withChildren(getTree(folder, workspace, depth, includeFiles)); + return newDto(TreeElement.class).withNode(injectFolderLinks(asDto(folder))) + .withChildren(getTree(folder, depth, includeFiles)); } @GET @@ -826,9 +791,7 @@ public class ProjectService extends Service { @ApiResponse(code = 403, message = "User not authorized to call this operation"), @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public ItemReference getItem(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path to resource. Can be project or its folders", required = true) + public ItemReference getItem(@ApiParam(value = "Path to resource. Can be project or its folders", required = true) @PathParam("path") String path) throws NotFoundException, ForbiddenException, ServerException { @@ -839,9 +802,9 @@ public class ProjectService extends Service { } if (entry.isFile()) { - return injectFileLinks(asDto((FileEntry)entry), workspace); + return injectFileLinks(asDto((FileEntry)entry)); } else { - return injectFolderLinks(asDto((FolderEntry)entry), workspace); + return injectFolderLinks(asDto((FolderEntry)entry)); } } @@ -857,9 +820,7 @@ public class ProjectService extends Service { @ApiResponse(code = 404, message = "Not found"), @ApiResponse(code = 409, message = "Conflict error"), @ApiResponse(code = 500, message = "Internal Server Error")}) - public List search(@ApiParam(value = "Workspace ID", required = true) - @PathParam("ws-id") String workspace, - @ApiParam(value = "Path to resource, i.e. where to search?", required = true) + public List search(@ApiParam(value = "Path to resource, i.e. where to search?", required = true) @PathParam("path") String path, @ApiParam(value = "Resource name") @QueryParam("name") String name, @@ -900,7 +861,7 @@ public class ProjectService extends Service { final VirtualFileEntry child = root.getChild(searchResultEntry.getFilePath()); if (child != null && child.isFile()) { - items.add(injectFileLinks(asDto((FileEntry)child), workspace)); + items.add(injectFileLinks(asDto((FileEntry)child))); } } @@ -936,7 +897,6 @@ public class ProjectService extends Service { } private List getTree(FolderEntry folder, - String workspace, int depth, boolean includeFiles) throws ServerException, NotFoundException { if (depth == 0) { @@ -955,10 +915,10 @@ public class ProjectService extends Service { for (VirtualFileEntry child : children) { if (child.isFolder()) { nodes.add(newDto(TreeElement.class) - .withNode(injectFolderLinks(asDto((FolderEntry)child), workspace)) - .withChildren(getTree((FolderEntry)child, workspace, depth - 1, includeFiles))); + .withNode(injectFolderLinks(asDto((FolderEntry)child))) + .withChildren(getTree((FolderEntry)child, depth - 1, includeFiles))); } else { - nodes.add(newDto(TreeElement.class).withNode(injectFileLinks(asDto((FileEntry)child), workspace))); + nodes.add(newDto(TreeElement.class).withNode(injectFileLinks(asDto((FileEntry)child)))); } } @@ -1064,7 +1024,7 @@ public class ProjectService extends Service { parent.unzip(in, overwrite, stripNum); } - private ItemReference injectFileLinks(ItemReference itemReference, String workspace) { + private ItemReference injectFileLinks(ItemReference itemReference) { final UriBuilder uriBuilder = getServiceContext().getServiceUriBuilder(); final List links = new ArrayList<>(); final String relPath = itemReference.getPath().substring(1); @@ -1072,14 +1032,14 @@ public class ProjectService extends Service { links.add(createLink(GET, uriBuilder.clone() .path(ProjectService.class, "getFile") - .build(workspace, relPath) + .build(relPath) .toString(), APPLICATION_JSON, LINK_REL_GET_CONTENT)); links.add(createLink(PUT, uriBuilder.clone() .path(ProjectService.class, "updateFile") - .build(workspace, relPath) + .build(relPath) .toString(), MediaType.WILDCARD, null, @@ -1087,14 +1047,14 @@ public class ProjectService extends Service { links.add(createLink(DELETE, uriBuilder.clone() .path(ProjectService.class, "delete") - .build(workspace, relPath) + .build(relPath) .toString(), LINK_REL_DELETE)); return itemReference.withLinks(links); } - private ItemReference injectFolderLinks(ItemReference itemReference, String workspace) { + private ItemReference injectFolderLinks(ItemReference itemReference) { final UriBuilder uriBuilder = getServiceContext().getServiceUriBuilder(); final List links = new ArrayList<>(); final String relPath = itemReference.getPath().substring(1); @@ -1102,28 +1062,28 @@ public class ProjectService extends Service { links.add(createLink(GET, uriBuilder.clone() .path(ProjectService.class, "getChildren") - .build(workspace, relPath) + .build(relPath) .toString(), APPLICATION_JSON, LINK_REL_CHILDREN)); links.add(createLink(GET, uriBuilder.clone() .path(ProjectService.class, "getTree") - .build(workspace, relPath) + .build(relPath) .toString(), APPLICATION_JSON, LINK_REL_TREE)); links.add(createLink(DELETE, uriBuilder.clone() .path(ProjectService.class, "delete") - .build(workspace, relPath) + .build(relPath) .toString(), LINK_REL_DELETE)); return itemReference.withLinks(links); } - private ProjectConfigDto injectProjectLinks(ProjectConfigDto projectConfig, String workspace) { + private ProjectConfigDto injectProjectLinks(ProjectConfigDto projectConfig) { final UriBuilder uriBuilder = getServiceContext().getServiceUriBuilder(); final List links = new ArrayList<>(); final String relPath = projectConfig.getPath().substring(1); @@ -1131,7 +1091,7 @@ public class ProjectService extends Service { links.add(createLink(PUT, uriBuilder.clone() .path(ProjectService.class, "updateProject") - .build(workspace, relPath) + .build(relPath) .toString(), APPLICATION_JSON, APPLICATION_JSON, @@ -1139,21 +1099,21 @@ public class ProjectService extends Service { links.add(createLink(GET, uriBuilder.clone() .path(ProjectService.class, "getChildren") - .build(workspace, relPath) + .build(relPath) .toString(), APPLICATION_JSON, LINK_REL_CHILDREN)); links.add(createLink(GET, uriBuilder.clone() .path(ProjectService.class, "getTree") - .build(workspace, relPath) + .build(relPath) .toString(), APPLICATION_JSON, LINK_REL_TREE)); links.add(createLink(DELETE, uriBuilder.clone() .path(ProjectService.class, "delete") - .build(workspace, relPath) + .build(relPath) .toString(), LINK_REL_DELETE)); diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectTypeService.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectTypeService.java index f27b6df581..bc968bcbff 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectTypeService.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectTypeService.java @@ -42,15 +42,11 @@ import static org.eclipse.che.api.project.shared.Constants.LINK_REL_PROJECT_TYPE * @author gazarenkov */ @Api(value = "/project-type", description = "Project type REST API") -@Path("project-type/{ws-id}") +@Path("project-type") public class ProjectTypeService extends Service { private final ProjectTypeRegistry registry; - @PathParam("ws-id") - @ApiParam("The id of the workspace") - private String wsId; - @Inject public ProjectTypeService(ProjectTypeRegistry registry) { this.registry = registry; diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/importer/ProjectImportersService.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/importer/ProjectImportersService.java index 1d2bcf4717..664b462c4a 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/importer/ProjectImportersService.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/importer/ProjectImportersService.java @@ -33,7 +33,7 @@ import static org.eclipse.che.dto.server.DtoFactory.newDto; * * @author Vitaly Parfonov */ -@Path("project-importers/{wsId}") +@Path("project-importers") public class ProjectImportersService extends Service { private final Map configuration; diff --git a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/ProjectServiceTest.java b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/ProjectServiceTest.java index 6497650281..100d790d81 100644 --- a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/ProjectServiceTest.java +++ b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/ProjectServiceTest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.api.project.server; +import org.eclipse.che.WorkspaceIdProvider; import org.eclipse.che.api.core.ConflictException; import org.eclipse.che.api.core.ForbiddenException; import org.eclipse.che.api.core.NotFoundException; @@ -124,8 +125,7 @@ import static org.testng.Assert.assertNotNull; public class ProjectServiceTest { private static final String CONTENT_TYPE = "Content-Type"; - private static final String vfsUser = "dev"; - private static final String workspace = "my_ws"; + private static final String vfsUser = "dev"; protected final static String FS_PATH = "target/fss"; protected final static String INDEX_PATH = "target/fss_index"; @@ -301,7 +301,7 @@ public class ProjectServiceTest { projectRegistry.initProjects(); ContainerResponse response = - launcher.service(GET, "http://localhost:8080/api/project/my_ws", "http://localhost:8080/api", null, null, null); + launcher.service(GET, "http://localhost:8080/api/project", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); List result = (List)response.getEntity(); assertNotNull(result); @@ -327,23 +327,10 @@ public class ProjectServiceTest { } - @Test - public void shouldReturnNotFoundStatusWhenGettingModulesFromProjectWhichDoesNotExist() throws Exception { - ContainerResponse response = launcher.service(GET, - "http://localhost:8080/api/project/" + workspace + "/modules/fake", - "http://localhost:8080/api", - null, - null, - null); - - assertEquals(response.getStatus(), 404); - } - - @Test public void testGetProject() throws Exception { ContainerResponse response = - launcher.service(GET, String.format("http://localhost:8080/api/project/%s/my_project", workspace), + launcher.service(GET, "http://localhost:8080/api/project/my_project", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); ProjectConfigDto result = (ProjectConfigDto)response.getEntity(); @@ -363,7 +350,7 @@ public class ProjectServiceTest { vfsProvider.getVirtualFileSystem().getRoot().createFolder("not_project"); // to refresh projectRegistry.initProjects(); - ContainerResponse response = launcher.service(GET, String.format("http://localhost:8080/api/project/%s/not_project", workspace), + ContainerResponse response = launcher.service(GET, "http://localhost:8080/api/project/not_project", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); ProjectConfigDto badProject = (ProjectConfigDto)response.getEntity(); @@ -380,7 +367,7 @@ public class ProjectServiceTest { // Without roles Collections.emptySet() should get default set of permissions env.setSubject(new SubjectImpl(vfsUser, vfsUser, "dummy_token", Collections.emptySet(), false)); ContainerResponse response = - launcher.service(GET, String.format("http://localhost:8080/api/project/%s/my_project", workspace), + launcher.service(GET, "http://localhost:8080/api/project/my_project", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); ProjectConfigDto result = (ProjectConfigDto)response.getEntity(); @@ -391,7 +378,7 @@ public class ProjectServiceTest { @Test public void testGetProjectInvalidPath() throws Exception { ContainerResponse response = launcher.service(GET, - String.format("http://localhost:8080/api/project/%s/my_project_invalid", workspace), + "http://localhost:8080/api/project/my_project_invalid", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 404); } @@ -441,7 +428,7 @@ public class ProjectServiceTest { projects.add(newProjectConfig); ContainerResponse response = launcher.service(POST, - String.format("http://localhost:8080/api/project/%s", workspace), + "http://localhost:8080/api/project", "http://localhost:8080/api", headers, DtoFactory.getInstance().toJson(newProjectConfig).getBytes(), @@ -504,7 +491,7 @@ public class ProjectServiceTest { ContainerResponse response = launcher.service(PUT, - String.format("http://localhost:8080/api/project/%s/testUpdateProject", workspace), + "http://localhost:8080/api/project/testUpdateProject", "http://localhost:8080/api", headers, DtoFactory.getInstance().toJson(descriptor).getBytes(), @@ -546,7 +533,7 @@ public class ProjectServiceTest { projects.add(newProjectConfig); ContainerResponse response = launcher.service(PUT, - String.format("http://localhost:8080/api/project/%s/not_project", workspace), + "http://localhost:8080/api/project/not_project", "http://localhost:8080/api", headers, DtoFactory.getInstance().toJson(descriptor).getBytes(), @@ -572,8 +559,7 @@ public class ProjectServiceTest { .withDescription("updated project") .withAttributes(attributeValues); ContainerResponse response = launcher.service(PUT, - String.format("http://localhost:8080/api/project/%s/my_project_invalid", - workspace), + "http://localhost:8080/api/project/my_project_invalid", "http://localhost:8080/api", headers, DtoFactory.getInstance().toJson(descriptor).getBytes(), @@ -624,8 +610,8 @@ public class ProjectServiceTest { ptRegistry.registerProjectType(pt); ContainerResponse response = - launcher.service(GET, String.format("http://localhost:8080/api/project/%s/estimate/%s?type=%s", - workspace, "testEstimateProjectGood", "testEstimateProjectPT"), + launcher.service(GET, String.format("http://localhost:8080/api/project/estimate/%s?type=%s", + "testEstimateProjectGood", "testEstimateProjectPT"), "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); //noinspection unchecked @@ -635,8 +621,8 @@ public class ProjectServiceTest { assertEquals(result.getAttributes().get("calculated_attribute").get(0), "checked"); // if project not matched - response = launcher.service(GET, String.format("http://localhost:8080/api/project/%s/estimate/%s?type=%s", - workspace, "testEstimateProjectBad", "testEstimateProjectPT"), + response = launcher.service(GET, String.format("http://localhost:8080/api/project/estimate/%s?type=%s", + "testEstimateProjectBad", "testEstimateProjectPT"), "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 409, "Error: " + response.getEntity()); @@ -684,9 +670,9 @@ public class ProjectServiceTest { ptRegistry.registerProjectType(pt); ContainerResponse response = - launcher.service(GET, String.format("http://localhost:8080/api/project/%s/resolve/%s", - workspace, "testEstimateProjectGood"), - "http://localhost:8080/api", null, null, null); + launcher.service(GET, String.format("http://localhost:8080/api/project/resolve/%s", + "testEstimateProjectGood"), + "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); List result = (List) response.getEntity(); @@ -735,7 +721,7 @@ public class ProjectServiceTest { byte[] b = String.format(json, importType).getBytes(); ContainerResponse response = launcher.service(POST, - String.format("http://localhost:8080/api/project/%s/import/new_project", workspace), + "http://localhost:8080/api/project/import/new_project", "http://localhost:8080/api", headers, b, null); assertEquals(response.getStatus(), 204); @@ -795,8 +781,7 @@ public class ProjectServiceTest { public void testCreateFile() throws Exception { String myContent = "to be or not to be"; ContainerResponse response = launcher.service(POST, - String.format("http://localhost:8080/api/project/%s/file/my_project?name=test.txt", - workspace), + "http://localhost:8080/api/project/file/my_project?name=test.txt", "http://localhost:8080/api", null, myContent.getBytes(), @@ -809,7 +794,7 @@ public class ProjectServiceTest { assertEquals(fileItem.getPath(), "/my_project/test.txt"); validateFileLinks(fileItem); assertEquals(response.getHttpHeaders().getFirst("Location"), - URI.create(String.format("http://localhost:8080/api/project/%s/file/my_project/test.txt", workspace))); + URI.create("http://localhost:8080/api/project/file/my_project/test.txt")); VirtualFileEntry file = pm.getProject("my_project").getBaseFolder().getChild("test.txt"); Assert.assertTrue(file.isFile()); FileEntry _file = (FileEntry)file; @@ -817,119 +802,14 @@ public class ProjectServiceTest { assertEquals(new String(_file.contentAsBytes()), myContent); } -// -// @Test -// public void testUploadFile() throws Exception { -// String fileContent = "to be or not to be"; -// String fileName = "test.txt"; -// String fileMediaType = TEXT_PLAIN; -// Map> headers = new HashMap<>(); -// headers.putProject(CONTENT_TYPE, singletonList("multipart/form-data; boundary=abcdef")); -// String uploadBodyPattern = -// "--abcdef\r\nContent-Disposition: form-data; name=\"file\"; filename=\"%1$s\"\r\nContent-Type: %2$s\r\n\r\n%3$s" -// + "\r\n--abcdef\r\nContent-Disposition: form-data; name=\"mimeType\"\r\n\r\n%4$s" -// + "\r\n--abcdef\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n%5$s" -// + "\r\n--abcdef\r\nContent-Disposition: form-data; name=\"overwrite\"\r\n\r\n%6$b" -// + "\r\n--abcdef--\r\n"; -// byte[] formData = String.format(uploadBodyPattern, fileName, fileMediaType, fileContent, fileMediaType, fileName, false).getBytes(); -// EnvironmentContext env = new EnvironmentContext(); -// env.putProject(HttpServletRequest.class, new MockHttpServletRequest("", new ByteArrayInputStream(formData), -// formData.length, POST, headers)); -// ContainerResponse response = launcher.service(POST, -// String.format("http://localhost:8080/api/project/%s/uploadfile/my_project", -// workspace), -// "http://localhost:8080/api", -// headers, -// formData, -// env); -// assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); -// VirtualFileEntry file = pm.getProject(workspace, "my_project").getBaseFolder().getChild(fileName); -// Assert.assertTrue(file.isFile()); -// FileEntry _file = (FileEntry)file; -// assertEquals(_file.getMediaType(), fileMediaType); -// assertEquals(new String(_file.contentAsBytes()), fileContent); -// } -// -// @Test -// public void testUploadFileWhenFileAlreadyExistAndOverwriteIsTrue() throws Exception { -// String oldFileContent = "to be or not to be"; -// String newFileContent = "To be, or not to be, that is the question!"; -// String fileName = "test.txt"; -// String fileMediaType = TEXT_PLAIN; -// Map> headers = new HashMap<>(); -// headers.putProject(CONTENT_TYPE, singletonList("multipart/form-data; boundary=abcdef")); -// String uploadBodyPattern = -// "--abcdef\r\nContent-Disposition: form-data; name=\"file\"; filename=\"%1$s\"\r\nContent-Type: %2$s\r\n\r\n%3$s" -// + "\r\n--abcdef\r\nContent-Disposition: form-data; name=\"mimeType\"\r\n\r\n%4$s" -// + "\r\n--abcdef\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n%5$s" -// + "\r\n--abcdef\r\nContent-Disposition: form-data; name=\"overwrite\"\r\n\r\n%6$b" -// + "\r\n--abcdef--\r\n"; -// pm.getProject(workspace, "my_project").getBaseFolder().createFile(fileName, oldFileContent.getBytes()); -// byte[] newFileData = -// String.format(uploadBodyPattern, fileName, fileMediaType, newFileContent, fileMediaType, fileName, true).getBytes(); -// -// EnvironmentContext env = new EnvironmentContext(); -// env.putProject(HttpServletRequest.class, new MockHttpServletRequest("", new ByteArrayInputStream(newFileData), -// newFileData.length, POST, headers)); -// ContainerResponse response = launcher.service(POST, -// String.format("http://localhost:8080/api/project/%s/uploadfile/my_project", -// workspace), -// "http://localhost:8080/api", -// headers, -// newFileData, -// env); -// assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); -// VirtualFileEntry file = pm.getProject(workspace, "my_project").getBaseFolder().getChild(fileName); -// Assert.assertTrue(file.isFile()); -// FileEntry _file = (FileEntry)file; -// assertEquals(_file.getMediaType(), fileMediaType); -// assertEquals(new String(_file.contentAsBytes()), newFileContent); -// } -// -// @Test -// public void testUploadFileWhenFileAlreadyExistAndOverwriteIsFalse() throws Exception { -// String oldFileContent = "to be or not to be"; -// String newFileContent = "To be, or not to be, that is the question!"; -// String fileName = "test.txt"; -// String fileMediaType = TEXT_PLAIN; -// Map> headers = new HashMap<>(); -// headers.putProject(CONTENT_TYPE, singletonList("multipart/form-data; boundary=abcdef")); -// String uploadBodyPattern = -// "--abcdef\r\nContent-Disposition: form-data; name=\"file\"; filename=\"%1$s\"\r\nContent-Type: %2$s\r\n\r\n%3$s" -// + "\r\n--abcdef\r\nContent-Disposition: form-data; name=\"mimeType\"\r\n\r\n%4$s" -// + "\r\n--abcdef\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n%5$s" -// + "\r\n--abcdef\r\nContent-Disposition: form-data; name=\"overwrite\"\r\n\r\n%6$b" -// + "\r\n--abcdef--\r\n"; -// pm.getProject(workspace, "my_project").getBaseFolder().createFile(fileName, oldFileContent.getBytes()); -// byte[] newFileData = -// String.format(uploadBodyPattern, fileName, fileMediaType, newFileContent, fileMediaType, fileName, false).getBytes(); -// -// EnvironmentContext env = new EnvironmentContext(); -// env.putProject(HttpServletRequest.class, new MockHttpServletRequest("", new ByteArrayInputStream(newFileData), -// newFileData.length, POST, headers)); -// ContainerResponse response = launcher.service(POST, -// String.format("http://localhost:8080/api/project/%s/uploadfile/my_project", -// workspace), -// "http://localhost:8080/api", -// headers, -// newFileData, -// env); -// assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); -// VirtualFileEntry file = pm.getProject(workspace, "my_project").getBaseFolder().getChild(fileName); -// Assert.assertTrue(file.isFile()); -// FileEntry _file = (FileEntry)file; -// assertEquals(_file.getMediaType(), fileMediaType); -// assertEquals(new String(_file.contentAsBytes()), oldFileContent); -// } -// + @Test public void testGetFileContent() throws Exception { String myContent = "to be or not to be"; pm.getProject("my_project").getBaseFolder().createFile("test.txt", myContent.getBytes()); ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter(); ContainerResponse response = launcher.service(GET, - String.format("http://localhost:8080/api/project/%s/file/my_project/test.txt", - workspace), + "http://localhost:8080/api/project/file/my_project/test.txt", "http://localhost:8080/api", null, null, writer, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); assertEquals(response.getContentType().toString(), TEXT_PLAIN); @@ -941,30 +821,27 @@ public class ProjectServiceTest { String myContent = "hello"; pm.getProject("my_project").getBaseFolder().createFile("test.xml", "to be or not to be".getBytes()); ContainerResponse response = launcher.service(PUT, - String.format("http://localhost:8080/api/project/%s/file/my_project/test.xml", workspace), + "http://localhost:8080/api/project/file/my_project/test.xml", "http://localhost:8080/api", null, myContent.getBytes(), null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); VirtualFileEntry file = pm.getProject("my_project").getBaseFolder().getChild("test.xml"); Assert.assertTrue(file.isFile()); FileEntry _file = (FileEntry)file; - //assertEquals(_file.getMediaType(), "text/xml"); assertEquals(new String(_file.contentAsBytes()), myContent); } @Test public void testCreateFolder() throws Exception { ContainerResponse response = launcher.service(POST, - String.format("http://localhost:8080/api/project/%s/folder/my_project/test", - workspace), + "http://localhost:8080/api/project/folder/my_project/test", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); ItemReference fileItem = (ItemReference)response.getEntity(); - //assertEquals(fileItem.getMediaType(), "text/directory"); assertEquals(fileItem.getName(), "test"); assertEquals(fileItem.getPath(), "/my_project/test"); validateFolderLinks(fileItem); assertEquals(response.getHttpHeaders().getFirst("Location"), - URI.create(String.format("http://localhost:8080/api/project/%s/children/my_project/test", workspace))); + URI.create("http://localhost:8080/api/project/children/my_project/test")); VirtualFileEntry folder = pm.getProject("my_project").getBaseFolder().getChild("test"); Assert.assertTrue(folder.isFolder()); } @@ -974,8 +851,7 @@ public class ProjectServiceTest { public void testCreateFolderInRoot() throws Exception { String folder = "my_folder"; ContainerResponse response = launcher.service(POST, - String.format("http://localhost:8080/api/project/%s/folder/%s", - workspace, folder), + String.format("http://localhost:8080/api/project/folder/%s", folder), "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); ItemReference fileItem = (ItemReference)response.getEntity(); @@ -984,18 +860,17 @@ public class ProjectServiceTest { assertEquals(fileItem.getPath(), "/" + folder); validateFolderLinks(fileItem); assertEquals(response.getHttpHeaders().getFirst("Location"), - URI.create(String.format("http://localhost:8080/api/project/%s/children/%s", workspace, folder))); + URI.create(String.format("http://localhost:8080/api/project/children/%s", folder))); } @Test public void testCreatePath() throws Exception { ContainerResponse response = launcher.service(POST, - String.format("http://localhost:8080/api/project/%s/folder/my_project/a/b/c", - workspace), + "http://localhost:8080/api/project/folder/my_project/a/b/c", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), - URI.create(String.format("http://localhost:8080/api/project/%s/children/my_project/a/b/c", workspace))); + URI.create("http://localhost:8080/api/project/children/my_project/a/b/c")); VirtualFileEntry folder = pm.getProject("my_project").getBaseFolder().getChild("a/b/c"); Assert.assertTrue(folder.isFolder()); } @@ -1004,7 +879,7 @@ public class ProjectServiceTest { public void testDeleteFile() throws Exception { pm.getProject("my_project").getBaseFolder().createFile("test.txt", "to be or not to be".getBytes()); ContainerResponse response = launcher.service(DELETE, - String.format("http://localhost:8080/api/project/%s/my_project/test.txt", workspace), + "http://localhost:8080/api/project/my_project/test.txt", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 204, "Error: " + response.getEntity()); Assert.assertNull(pm.getProject("my_project").getBaseFolder().getChild("test.txt")); @@ -1014,7 +889,7 @@ public class ProjectServiceTest { public void testDeleteFolder() throws Exception { pm.getProject("my_project").getBaseFolder().createFolder("test"); ContainerResponse response = launcher.service(DELETE, - String.format("http://localhost:8080/api/project/%s/my_project/test", workspace), + "http://localhost:8080/api/project/my_project/test", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 204, "Error: " + response.getEntity()); Assert.assertNull(pm.getProject("my_project").getBaseFolder().getChild("test")); @@ -1024,7 +899,7 @@ public class ProjectServiceTest { public void testDeletePath() throws Exception { pm.getProject("my_project").getBaseFolder().createFolder("a/b/c"); ContainerResponse response = launcher.service(DELETE, - String.format("http://localhost:8080/api/project/%s/my_project/a/b/c", workspace), + "http://localhost:8080/api/project/my_project/a/b/c", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 204, "Error: " + response.getEntity()); Assert.assertNull(pm.getProject("my_project").getBaseFolder().getChild("a/b/c")); @@ -1033,7 +908,7 @@ public class ProjectServiceTest { @Test public void testDeleteInvalidPath() throws Exception { ContainerResponse response = launcher.service(DELETE, - String.format("http://localhost:8080/api/project/%s/my_project/a/b/c", workspace), + "http://localhost:8080/api/project/my_project/a/b/c", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 204); assertNotNull(pm.getProject("my_project")); @@ -1044,15 +919,11 @@ public class ProjectServiceTest { ContainerResponse response = launcher.service(DELETE, - String.format("http://localhost:8080/api/project/%s/my_project", workspace), + "http://localhost:8080/api/project/my_project", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 204, "Error: " + response.getEntity()); pm.getProject("my_project"); - -// verify(httpJsonRequestFactory).fromLink(eq(DtoFactory.newDto(Link.class) -// .withHref(apiEndpoint + "/workspace/" + workspace + "/project/my_project") -// .withMethod(DELETE))); } @Test @@ -1061,13 +932,11 @@ public class ProjectServiceTest { myProject.getBaseFolder().createFolder("a/b/c"); ((FolderEntry)myProject.getBaseFolder().getChild("a/b")).createFile("test.txt", "to be or not no be".getBytes()); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/copy/my_project/a/b/test.txt?to=/my_project/a/b/c", - workspace), + "http://localhost:8080/api/project/copy/my_project/a/b/test.txt?to=/my_project/a/b/c", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), - URI.create(String.format("http://localhost:8080/api/project/%s/file/my_project/a/b/c/test.txt", workspace))); + URI.create("http://localhost:8080/api/project/file/my_project/a/b/c/test.txt")); assertNotNull(myProject.getBaseFolder().getChild("a/b/c/test.txt")); // new assertNotNull(myProject.getBaseFolder().getChild("a/b/test.txt")); // old } @@ -1086,14 +955,12 @@ public class ProjectServiceTest { descriptor.setOverWrite(false); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/copy/my_project/a/b/test.txt?to=/my_project/a/b/c", - workspace), + "http://localhost:8080/api/project/copy/my_project/a/b/test.txt?to=/my_project/a/b/c", "http://localhost:8080/api", headers, DtoFactory.getInstance().toJson(descriptor).getBytes(), null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), - URI.create(String.format("http://localhost:8080/api/project/%s/file/my_project/a/b/c/copyOfTest.txt", workspace))); + URI.create("http://localhost:8080/api/project/file/my_project/a/b/c/copyOfTest.txt")); assertNotNull(myProject.getBaseFolder().getChild("a/b/c/copyOfTest.txt")); // new assertNotNull(myProject.getBaseFolder().getChild("a/b/test.txt")); // old } @@ -1122,16 +989,12 @@ public class ProjectServiceTest { descriptor.setOverWrite(true); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/copy/my_project/a/b/" + originFileName + - "?to=/my_project/a/b/c", - workspace), + "http://localhost:8080/api/project/copy/my_project/a/b/" + originFileName + "?to=/my_project/a/b/c", "http://localhost:8080/api", headers, DtoFactory.getInstance().toJson(descriptor).getBytes(), null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), - URI.create(String.format("http://localhost:8080/api/project/%s/file/my_project/a/b/c/" + destinationFileName, - workspace))); + URI.create("http://localhost:8080/api/project/file/my_project/a/b/c/" + destinationFileName)); assertNotNull(myProject.getBaseFolder().getChild("a/b/c/" + destinationFileName)); // new assertNotNull(myProject.getBaseFolder().getChild("a/b/" + originFileName)); // old @@ -1159,13 +1022,11 @@ public class ProjectServiceTest { myProject.getBaseFolder().createFolder("a/b/c"); ((FolderEntry)myProject.getBaseFolder().getChild("a/b")).createFile("test.txt", "to be or not no be".getBytes()); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/copy/my_project/a/b?to=/my_project/a/b/c", - workspace), + "http://localhost:8080/api/project/copy/my_project/a/b?to=/my_project/a/b/c", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), - URI.create(String.format("http://localhost:8080/api/project/%s/children/my_project/a/b/c/b", workspace))); + URI.create("http://localhost:8080/api/project/children/my_project/a/b/c/b")); assertNotNull(myProject.getBaseFolder().getChild("a/b/test.txt")); assertNotNull(myProject.getBaseFolder().getChild("a/b/c/b/test.txt")); } @@ -1187,15 +1048,13 @@ public class ProjectServiceTest { descriptor.setOverWrite(false); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/copy/my_project/a/b?to=/my_project/a/b/c", - workspace), + "http://localhost:8080/api/project/copy/my_project/a/b?to=/my_project/a/b/c", "http://localhost:8080/api", headers, DtoFactory.getInstance().toJson(descriptor).getBytes(), null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), URI.create( - String.format("http://localhost:8080/api/project/%s/children/my_project/a/b/c/%s", workspace, renamedFolder))); + String.format("http://localhost:8080/api/project/children/my_project/a/b/c/%s", renamedFolder))); assertNotNull(myProject.getBaseFolder().getChild("a/b/test.txt")); assertNotNull(myProject.getBaseFolder().getChild(String.format("a/b/c/%s/test.txt", renamedFolder))); } @@ -1227,15 +1086,13 @@ public class ProjectServiceTest { descriptor.setOverWrite(true); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/copy/my_project/a/b?to=/my_project/a/b/c", - workspace), + "http://localhost:8080/api/project/copy/my_project/a/b?to=/my_project/a/b/c", "http://localhost:8080/api", headers, DtoFactory.getInstance().toJson(descriptor).getBytes(), null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), URI.create( - String.format("http://localhost:8080/api/project/%s/children/my_project/a/b/c/%s", workspace, renamedFolder))); + String.format("http://localhost:8080/api/project/children/my_project/a/b/c/%s", renamedFolder))); assertNotNull(myProject.getBaseFolder().getChild("a/b/test.txt")); assertNotNull(myProject.getBaseFolder().getChild(String.format("a/b/c/%s/test.txt", renamedFolder))); assertEquals(myProject.getBaseFolder().getChild("a/b/test.txt").getName(), @@ -1248,13 +1105,11 @@ public class ProjectServiceTest { myProject.getBaseFolder().createFolder("a/b/c"); ((FolderEntry)myProject.getBaseFolder().getChild("a/b")).createFile("test.txt", "to be or not no be".getBytes()); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/move/my_project/a/b/test.txt?to=/my_project/a/b/c", - workspace), + "http://localhost:8080/api/project/move/my_project/a/b/test.txt?to=/my_project/a/b/c", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), - URI.create(String.format("http://localhost:8080/api/project/%s/file/my_project/a/b/c/test.txt", workspace))); + URI.create("http://localhost:8080/api/project/file/my_project/a/b/c/test.txt")); assertNotNull(myProject.getBaseFolder().getChild("a/b/c/test.txt")); // new Assert.assertNull(myProject.getBaseFolder().getChild("a/b/test.txt")); // old } @@ -1276,15 +1131,13 @@ public class ProjectServiceTest { descriptor.setOverWrite(false); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/move/my_project/a/b/test.txt?to=/my_project/a/b/c", - workspace), + "http://localhost:8080/api/project/move/my_project/a/b/test.txt?to=/my_project/a/b/c", "http://localhost:8080/api", headers, DtoFactory.getInstance().toJson(descriptor).getBytes(), null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), URI.create( - String.format("http://localhost:8080/api/project/%s/file/my_project/a/b/c/%s", workspace, destinationName))); + String.format("http://localhost:8080/api/project/file/my_project/a/b/c/%s", destinationName))); VirtualFileEntry theTargetFile = myProject.getBaseFolder().getChild(String.format("a/b/c/%s", destinationName)); assertNotNull(theTargetFile); // new } @@ -1306,15 +1159,13 @@ public class ProjectServiceTest { descriptor.setOverWrite(false); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/move/my_project/a/b/test.txt", - workspace), + "http://localhost:8080/api/project/move/my_project/a/b/test.txt", "http://localhost:8080/api", headers, DtoFactory.getInstance().toJson(descriptor).getBytes(), null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), URI.create( - String.format("http://localhost:8080/api/project/%s/file/my_project/a/b/%s", workspace, destinationName))); + String.format("http://localhost:8080/api/project/file/my_project/a/b/%s", destinationName))); VirtualFileEntry theTargetFile = myProject.getBaseFolder().getChild(String.format("a/b/%s", destinationName)); assertNotNull(theTargetFile); // new } @@ -1343,16 +1194,13 @@ public class ProjectServiceTest { descriptor.setOverWrite(true); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/move/my_project/a/b/" + originFileName + - "?to=/my_project/a/b/c", - workspace), + "http://localhost:8080/api/project/move/my_project/a/b/" + originFileName + + "?to=/my_project/a/b/c", "http://localhost:8080/api", headers, DtoFactory.getInstance().toJson(descriptor).getBytes(), null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), - URI.create(String.format("http://localhost:8080/api/project/%s/file/my_project/a/b/c/" + destinationFileName, - workspace))); + URI.create("http://localhost:8080/api/project/file/my_project/a/b/c/" + destinationFileName)); assertNotNull(myProject.getBaseFolder().getChild("a/b/c/" + destinationFileName)); // new Scanner inputStreamScanner = null; @@ -1379,13 +1227,11 @@ public class ProjectServiceTest { myProject.getBaseFolder().createFolder("a/b/c"); ((FolderEntry)myProject.getBaseFolder().getChild("a/b/c")).createFile("test.txt", "to be or not no be".getBytes()); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/move/my_project/a/b/c?to=/my_project/a", - workspace), + "http://localhost:8080/api/project/move/my_project/a/b/c?to=/my_project/a", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), - URI.create(String.format("http://localhost:8080/api/project/%s/children/my_project/a/c", workspace))); + URI.create("http://localhost:8080/api/project/children/my_project/a/c")); assertNotNull(myProject.getBaseFolder().getChild("a/c/test.txt")); Assert.assertNull(myProject.getBaseFolder().getChild("a/b/c/test.txt")); Assert.assertNull(myProject.getBaseFolder().getChild("a/b/c")); @@ -1408,15 +1254,13 @@ public class ProjectServiceTest { descriptor.setOverWrite(false); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/copy/my_project/a/b?to=/my_project/a/b/c", - workspace), + "http://localhost:8080/api/project/copy/my_project/a/b?to=/my_project/a/b/c", "http://localhost:8080/api", headers, DtoFactory.getInstance().toJson(descriptor).getBytes(), null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), URI.create( - String.format("http://localhost:8080/api/project/%s/children/my_project/a/b/c/%s", workspace, renamedFolder))); + String.format("http://localhost:8080/api/project/children/my_project/a/b/c/%s", renamedFolder))); assertNotNull(myProject.getBaseFolder().getChild(String.format("a/b/c/%s/test.txt", renamedFolder))); } @@ -1437,15 +1281,13 @@ public class ProjectServiceTest { descriptor.setOverWrite(false); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/move/my_project/a/b", - workspace), + "http://localhost:8080/api/project/move/my_project/a/b", "http://localhost:8080/api", headers, DtoFactory.getInstance().toJson(descriptor).getBytes(), null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), URI.create( - String.format("http://localhost:8080/api/project/%s/children/my_project/a/%s", workspace, renamedFolder))); + String.format("http://localhost:8080/api/project/children/my_project/a/%s", renamedFolder))); assertNotNull(myProject.getBaseFolder().getChild(String.format("a/%s/test.txt", renamedFolder))); } @@ -1476,15 +1318,13 @@ public class ProjectServiceTest { descriptor.setOverWrite(true); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/copy/my_project/a/b?to=/my_project/a/b/c", - workspace), + "http://localhost:8080/api/project/copy/my_project/a/b?to=/my_project/a/b/c", "http://localhost:8080/api", headers, DtoFactory.getInstance().toJson(descriptor).getBytes(), null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), URI.create( - String.format("http://localhost:8080/api/project/%s/children/my_project/a/b/c/%s", workspace, renamedFolder))); + String.format("http://localhost:8080/api/project/children/my_project/a/b/c/%s", renamedFolder))); assertNotNull(myProject.getBaseFolder().getChild(String.format("a/b/c/%s/test.txt", renamedFolder))); } @@ -1503,12 +1343,11 @@ public class ProjectServiceTest { Map> headers = new HashMap<>(); headers.put(CONTENT_TYPE, singletonList(ExtMediaType.APPLICATION_ZIP)); ContainerResponse response = launcher.service(POST, - String.format("http://localhost:8080/api/project/%s/import/my_project/a/b", - workspace), + String.format("http://localhost:8080/api/project/import/my_project/a/b"), "http://localhost:8080/api", headers, zip, null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), - URI.create(String.format("http://localhost:8080/api/project/%s/children/my_project/a/b", workspace))); + URI.create("http://localhost:8080/api/project/children/my_project/a/b")); assertNotNull(myProject.getBaseFolder().getChild("a/b/folder1/file1.txt")); } @@ -1528,13 +1367,11 @@ public class ProjectServiceTest { Map> headers = new HashMap<>(); headers.put(CONTENT_TYPE, singletonList(ExtMediaType.APPLICATION_ZIP)); ContainerResponse response = launcher.service(POST, - String.format( - "http://localhost:8080/api/project/%s/import/my_project/a/b?skipFirstLevel=false", - workspace), + "http://localhost:8080/api/project/import/my_project/a/b?skipFirstLevel=false", "http://localhost:8080/api", headers, zip, null); assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); assertEquals(response.getHttpHeaders().getFirst("Location"), - URI.create(String.format("http://localhost:8080/api/project/%s/children/my_project/a/b", workspace))); + URI.create("http://localhost:8080/api/project/children/my_project/a/b")); assertNotNull(myProject.getBaseFolder().getChild("a/b/folder1/")); assertNotNull(myProject.getBaseFolder().getChild("a/b/folder1/folder2")); assertNotNull(myProject.getBaseFolder().getChild("a/b/folder1/folder2/file1.txt")); @@ -1545,7 +1382,7 @@ public class ProjectServiceTest { RegisteredProject myProject = pm.getProject("my_project"); myProject.getBaseFolder().createFolder("a/b").createFile("test.txt", "hello".getBytes()); ContainerResponse response = launcher.service(GET, - String.format("http://localhost:8080/api/project/%s/export/my_project", workspace), + "http://localhost:8080/api/project/export/my_project", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); assertEquals(response.getContentType().toString(), ExtMediaType.APPLICATION_ZIP); @@ -1559,8 +1396,7 @@ public class ProjectServiceTest { a.createFolder("b"); a.createFile("test.txt", "test".getBytes()); ContainerResponse response = launcher.service(GET, - String.format("http://localhost:8080/api/project/%s/children/my_project/a", - workspace), + "http://localhost:8080/api/project/children/my_project/a", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); List result = (List)response.getEntity(); @@ -1579,7 +1415,7 @@ public class ProjectServiceTest { a.createFolder("b"); a.createFile("test.txt", "test".getBytes()); ContainerResponse response = launcher.service(GET, - String.format("http://localhost:8080/api/project/%s/item/my_project/a/b", workspace), + "http://localhost:8080/api/project/item/my_project/a/b", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); @@ -1587,7 +1423,7 @@ public class ProjectServiceTest { assertEquals(result.getName(), "b"); response = launcher.service(GET, - String.format("http://localhost:8080/api/project/%s/item/my_project/a/test.txt", workspace), + "http://localhost:8080/api/project/item/my_project/a/test.txt", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); result = (ItemReference)response.getEntity(); @@ -1600,9 +1436,8 @@ public class ProjectServiceTest { FolderEntry a = pm.getProjectsRoot().createFolder("a"); a.createFile("test.txt", "test".getBytes()); ContainerResponse response = launcher.service(GET, - String.format("http://localhost:8080/api/project/%s/item/a/test.txt", - workspace), - "http://localhost:8080/api", null, null, null); + "http://localhost:8080/api/project/item/a/test.txt", + "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); ItemReference result = (ItemReference)response.getEntity(); assertEquals(result.getType(), "file"); @@ -1612,9 +1447,8 @@ public class ProjectServiceTest { @Test public void testGetMissingItem() throws Exception { ContainerResponse response = launcher.service(GET, - String.format("http://localhost:8080/api/project/%s/item/some_missing_project/a/b", - workspace), - "http://localhost:8080/api", null, null, null); + "http://localhost:8080/api/project/item/some_missing_project/a/b", + "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 404, "Error: " + response.getEntity()); } @@ -1626,7 +1460,7 @@ public class ProjectServiceTest { a.createFolder("x/y"); a.createFile("test.txt", "test".getBytes()); ContainerResponse response = launcher.service(GET, - String.format("http://localhost:8080/api/project/%s/tree/my_project/a", workspace), + "http://localhost:8080/api/project/tree/my_project/a", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); TreeElement tree = (TreeElement)response.getEntity(); @@ -1655,8 +1489,7 @@ public class ProjectServiceTest { a.createFolder("x/y"); a.createFile("test.txt", "test".getBytes()); ContainerResponse response = launcher.service(GET, - String.format("http://localhost:8080/api/project/%s/tree/my_project/a?depth=2", - workspace), + "http://localhost:8080/api/project/tree/my_project/a?depth=2", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); TreeElement tree = (TreeElement)response.getEntity(); @@ -1689,9 +1522,7 @@ public class ProjectServiceTest { a.createFolder("b/c"); a.createFolder("x").createFile("test.txt", "test".getBytes()); ContainerResponse response = launcher.service(GET, - String.format( - "http://localhost:8080/api/project/%s/tree/my_project/a?depth=100&includeFiles=true", - workspace), + "http://localhost:8080/api/project/tree/my_project/a?depth=100&includeFiles=true", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); TreeElement tree = (TreeElement)response.getEntity(); @@ -1728,9 +1559,7 @@ public class ProjectServiceTest { a.createFolder("b/c"); a.createFolder("x"); ContainerResponse response = launcher.service(GET, - String.format( - "http://localhost:8080/api/project/%s/tree/my_project/a?depth=100&includeFiles=true", - workspace), + "http://localhost:8080/api/project/tree/my_project/a?depth=100&includeFiles=true", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); TreeElement tree = (TreeElement)response.getEntity(); @@ -1766,8 +1595,7 @@ public class ProjectServiceTest { myProject.getBaseFolder().createFolder("c").createFile("exclude", "test".getBytes()); ContainerResponse response = launcher.service(GET, - String.format("http://localhost:8080/api/project/%s/search/my_project?name=test.txt", - workspace), + "http://localhost:8080/api/project/search/my_project?name=test.txt", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); List result = (List)response.getEntity(); @@ -1789,8 +1617,7 @@ public class ProjectServiceTest { myProject.getBaseFolder().createFolder("c").createFile("_test", "searchhit".getBytes()); ContainerResponse response = launcher.service(GET, - String.format("http://localhost:8080/api/project/%s/search/my_project?text=searchhit", - workspace), + "http://localhost:8080/api/project/search/my_project?text=searchhit", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); List result = (List)response.getEntity(); @@ -1816,7 +1643,7 @@ public class ProjectServiceTest { myProject.getBaseFolder().createFolder("c").createFile("_test", "Pay attention! To be or to not be that is the question".getBytes()); ContainerResponse response = - launcher.service(GET, String.format("http://localhost:8080/api/project/%s/search/my_project", workspace) + queryToSearch, + launcher.service(GET, "http://localhost:8080/api/project/search/my_project" + queryToSearch, "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); List result = (List)response.getEntity(); @@ -1842,7 +1669,7 @@ public class ProjectServiceTest { .createFile("notContainsSearchText", "Pay attention! To be or to not be that is the questEon".getBytes()); ContainerResponse response = - launcher.service(GET, String.format("http://localhost:8080/api/project/%s/search/my_project", workspace) + queryToSearch, + launcher.service(GET,"http://localhost:8080/api/project/search/my_project" + queryToSearch, "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); List result = (List)response.getEntity(); @@ -1867,7 +1694,7 @@ public class ProjectServiceTest { .createFile("notContainsSearchText", "Pay attention! To be or to not be that is the questEon".getBytes()); ContainerResponse response = - launcher.service(GET, String.format("http://localhost:8080/api/project/%s/search/my_project", workspace) + queryToSearch, + launcher.service(GET, "http://localhost:8080/api/project/search/my_project" + queryToSearch, "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); List result = (List)response.getEntity(); @@ -1892,7 +1719,7 @@ public class ProjectServiceTest { myProject.getBaseFolder().createFolder("c").createFile("alsoNotContainsSearchText", "To be or to not be that is the ...".getBytes()); ContainerResponse response = - launcher.service(GET, String.format("http://localhost:8080/api/project/%s/search/my_project", workspace) + queryToSearch, + launcher.service(GET, "http://localhost:8080/api/project/search/my_project" + queryToSearch, "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); List result = (List)response.getEntity(); @@ -1920,8 +1747,7 @@ public class ProjectServiceTest { myProject.getBaseFolder().createFolder("x/y") .createFile("test.txt", "http://localhost:8080/ide/dev6?action=createProject:projectName=test".getBytes()); - ContainerResponse response = launcher.service(GET, String.format("http://localhost:8080/api/project/%s/search/my_project", - workspace) + queryToSearch, + ContainerResponse response = launcher.service(GET, "http://localhost:8080/api/project/search/my_project" + queryToSearch, "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); List result = (List)response.getEntity(); @@ -1940,9 +1766,7 @@ public class ProjectServiceTest { myProject.getBaseFolder().createFolder("c").createFile("test", "test".getBytes()); ContainerResponse response = launcher.service(GET, - String.format( - "http://localhost:8080/api/project/%s/search/my_project?text=test&name=test.txt", - workspace), + "http://localhost:8080/api/project/search/my_project?text=test&name=test.txt", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); List result = (List)response.getEntity(); @@ -1960,9 +1784,7 @@ public class ProjectServiceTest { myProject.getBaseFolder().createFolder("c").createFile("test.txt", "test".getBytes()); ContainerResponse response = launcher.service(GET, - String.format( - "http://localhost:8080/api/project/%s/search/?text=test&name=test.txt", - workspace), + "http://localhost:8080/api/project/search/?text=test&name=test.txt", "http://localhost:8080/api", null, null, null); assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); List result = (List)response.getEntity(); @@ -1970,268 +1792,34 @@ public class ProjectServiceTest { Assert.assertTrue(result.get(0).getPath().equals("/my_project/c/test.txt")); } - - -/* ---- To think --- */ - - -// @Test -// public void testImportProjectWithModules() throws Exception { -// ByteArrayOutputStream bout = new ByteArrayOutputStream(); -// ZipOutputStream zipOut = new ZipOutputStream(bout); -// zipOut.putNextEntry(new ZipEntry("module1/")); -// zipOut.putNextEntry(new ZipEntry("module1/marker")); -// zipOut.write("to be or not to be".getBytes()); -// zipOut.close(); -// final InputStream zip = new ByteArrayInputStream(bout.toByteArray()); -// final String importType = "_123_"; -// -// registerImporter(importType, zip); -// -// phRegistry.register(new PostImportProjectHandler() { -// @Override -// public void onProjectImported(FolderEntry projectFolder) -// throws ForbiddenException, ConflictException, ServerException, IOException, NotFoundException { -// } -// -// @Override -// public String getProjectType() { -// return "chuck_project_type"; -// } -// }); -// -// final ProjectConfigDto newProjectConfig = DtoFactory.getInstance().createDto(ProjectConfigDto.class) -// .withPath("/new_project") -// .withName("new_project") -// .withDescription("import test") -// .withType("chuck_project_type"); -// final ProjectConfigDto newModuleConfig = DtoFactory.getInstance().createDto(ProjectConfigDto.class) -// .withPath("/new_project/module1") -// .withName("module1") -// .withDescription("module description") -// .withType("module_type"); -// //projects.add(newProjectConfig); -// //modules.add(newModuleConfig); -// -// Map> headers = new HashMap<>(); -// headers.putProject(CONTENT_TYPE, singletonList(APPLICATION_JSON)); -// -// SourceStorageDto source = DtoFactory.newDto(SourceStorageDto.class) -// .withParameters(Collections.emptyMap()) -// .withLocation("location/new_project.ext") -// .withType(importType); -// -// ProjectConfigDto pModule = DtoFactory.newDto(ProjectConfigDto.class) -// .withName("module1") -// .withPath("/module1") -// .withType("module_type") -// .withDescription("module description"); -// -// ProjectConfigDto project = DtoFactory.newDto(ProjectConfigDto.class) -// .withDescription("import test") -// .withType("chuck_project_type") -// .withModules(singletonList(pModule)); -// -// ContainerResponse response1 = launcher.service(POST, -// String.format("http://localhost:8080/api/project/%s/import/new_project", workspace), -// "http://localhost:8080/api", headers, JsonHelper.toJson(source).getBytes(), -// null); -// assertEquals(response1.getStatus(), 204, "Error: " + response1.getEntity()); -// -// ContainerResponse response = launcher.service(PUT, -// String.format("http://localhost:8080/api/project/%s/new_project", workspace), -// "http://localhost:8080/api", headers, JsonHelper.toJson(project).getBytes(), -// null); -// assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); -// -// ProjectConfigDto descriptor = (ProjectConfigDto)response.getEntity(); -// assertEquals(descriptor.getDescription(), "import test"); -// assertEquals(descriptor.getType(), "chuck_project_type"); -// ProjectImpl newProject = pm.getProject("new_project"); -// assertNotNull(newProject); -// } -// - -// @Test -// public void testRenameModule() throws Exception { -// //create new module -// phRegistry.register(new CreateProjectHandler() { -// -// @Override -// public String getProjectType() { -// return "my_project_type"; -// } -// -// @Override -// public void onCreateProject(FolderEntry baseFolder, Map attributes, Map options) -// throws ConflictException, ForbiddenException, ServerException { -// baseFolder.createFolder("a"); -// baseFolder.createFolder("b"); -// baseFolder.createFile("test.txt", "test".getBytes()); -// } -// }); -// -// Map> headers = new HashMap<>(); -// headers.putProject("Content-Type", Arrays.asList(APPLICATION_JSON)); -// -// Map> attributeValues = new LinkedHashMap<>(); -// attributeValues.putProject("new module attribute", Arrays.asList("to be or not to be")); -// -// ProjectConfigDto descriptor = DtoFactory.getInstance().createDto(ProjectConfigDto.class) -// .withType("my_project_type") -// .withDescription("new module") -// .withAttributes(attributeValues); -// -// ContainerResponse response = launcher.service(POST, -// String.format("http://localhost:8080/api/project/%s?path=%s", -// workspace, "new_module"), -// "http://localhost:8080/api", -// headers, -// DtoFactory.getInstance().toJson(descriptor).getBytes(), -// null); -// assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); -// -// //rename module -// ProjectImpl myProject = pm.getProject("my_project"); -// -// assertTrue(myProject.getModulePaths().contains("new_module")); -// -// final String newName = "moduleRenamed"; -// -// response = launcher.service(POST, -// String.format("http://localhost:8080/api/project/%s/rename/my_project/new_module?name=%s", -// workspace, newName), -// "http://localhost:8080/api", null, null, null); -// assertEquals(response.getStatus(), 201, "Error: " + response.getEntity()); -// assertEquals(response.getHttpHeaders().getFirst("Location"), -// URI.create(String.format("http://localhost:8080/api/project/%s/children/my_project/%s", -// workspace, newName))); -// assertNotNull(myProject.getBaseFolder().getChild(newName + "/a")); -// assertNotNull(myProject.getBaseFolder().getChild(newName + "/b")); -// assertNotNull(myProject.getBaseFolder().getChild(newName + "/test.txt")); -// -// assertTrue(pm.getProject("my_project").getModulePaths().contains(newName)); -// assertFalse(pm.getProject("my_project").getModulePaths().contains("new_module")); -// } - - -// @Test -// @SuppressWarnings("unchecked") -// public void testGetModulesWithHandler() throws Exception { -// ProjectTypeDef pt = new ProjectTypeDef("testGetModules", "my module type", true, false) { -// { -// addConstantDefinition("my_module_attribute", "attr description", "attribute value 1"); -// } -// }; -// pm.getProjectTypeRegistry().registerProjectType(pt); -// -// ProjectImpl myProject = pm.getProject("/my_project"); -// //create other module but not add to modules should be added to response by handler -// //myProject.getBaseFolder().createFolder("my_module2"); -// //pm.initProjects(); -// -// phRegistry.register(new GetModulesHandler() { -// @Override -// public void onGetModules(FolderEntry parentProjectFolder, final List modulesPath) -// throws ForbiddenException, ServerException, NotFoundException, IOException { -// FolderEntry child = (FolderEntry)parentProjectFolder.getChild("my_module2"); -// if (pm.isProject(child.getPath().toString())) { -// modulesPath.add(child.getPath().toString()); -// } -// } -// -// @Override -// public String getProjectType() { -// return "my_project_type"; -// } -// }); -// -// final ProjectConfigDto moduleConfig1 = DtoFactory.getInstance().createDto(ProjectConfigDto.class) -// .withPath("/my_project/my_module") -// .withName("my_module") -// .withDescription("my test module") -// .withType("testGetModules"); -// final ProjectConfigDto moduleConfig2 = DtoFactory.getInstance().createDto(ProjectConfigDto.class) -// .withPath("/my_project/my_module2") -// .withName("my_module2") -// .withDescription("my test module") -// .withType("testGetModules"); -// -// pm.createProject(moduleConfig1, null, "/my_project"); -// //create other module but not add to modules should be added to response by handler -// pm.createProject(moduleConfig2, null); -// myProject.addModule("/my_project/my_module2"); -//// pm.createProject(moduleConfig2, null, "/my_project"); -//// modules.add(moduleConfig1); -//// modules.add(moduleConfig2); -// -// ContainerResponse response = launcher.service(GET, -// String.format("http://localhost:8080/api/project/%s/modules/my_project", workspace), -// "http://localhost:8080/api", null, null, null); -// assertEquals(response.getStatus(), 200, "Error: " + response.getEntity()); -// List result = (List)response.getEntity(); -// assertNotNull(result); -// -// assertEquals(result.size(), 2); -// ProjectConfigDto moduleDescriptor = result.get(0); -// assertEquals(moduleDescriptor.getName(), "my_module"); -// -// ProjectConfigDto moduleDescriptor2 = result.get(1); -// assertEquals(moduleDescriptor2.getName(), "my_module2"); -// } - - - - - private void validateFileLinks(ItemReference item) { Link link = item.getLink("delete"); assertNotNull(link); assertEquals(link.getMethod(), DELETE); - assertEquals(link.getHref(), "http://localhost:8080/api/project/" + workspace + item.getPath()); - -// link = item.getLink("get content"); -// assertNotNull(link); -// assertEquals(link.getMethod(), GET); -// assertEquals(link.getProduces(), item.getMediaType()); -// assertEquals(link.getHref(), "http://localhost:8080/api/project/" + workspace + "/file" + item.getPath()); - + assertEquals(link.getHref(), "http://localhost:8080/api/project" + item.getPath()); link = item.getLink("update content"); assertNotNull(link); assertEquals(link.getMethod(), PUT); assertEquals(link.getConsumes(), "*/*"); - assertEquals(link.getHref(), "http://localhost:8080/api/project/" + workspace + "/file" + item.getPath()); + assertEquals(link.getHref(), "http://localhost:8080/api/project" + "/file" + item.getPath()); } private void validateFolderLinks(ItemReference item) { Link link = item.getLink("children"); assertNotNull(link); assertEquals(link.getMethod(), GET); - assertEquals(link.getHref(), "http://localhost:8080/api/project/" + workspace + "/children" + item.getPath()); + assertEquals(link.getHref(), "http://localhost:8080/api/project/children" + item.getPath()); assertEquals(link.getProduces(), APPLICATION_JSON); link = item.getLink("tree"); assertNotNull(link); assertEquals(link.getMethod(), GET); - assertEquals(link.getHref(), "http://localhost:8080/api/project/" + workspace + "/tree" + item.getPath()); + assertEquals(link.getHref(), "http://localhost:8080/api/project/tree" + item.getPath()); assertEquals(link.getProduces(), APPLICATION_JSON); - -// link = item.getLink("modules"); -// assertNotNull(link); -// assertEquals(link.getMethod(), GET); -// assertEquals(link.getHref(), "http://localhost:8080/api/project/" + workspace + "/modules" + item.getPath()); -// assertEquals(link.getProduces(), APPLICATION_JSON); - -// link = item.getLink("zipball"); -// assertNotNull(link); -// assertEquals(link.getMethod(), GET); -// assertEquals(link.getHref(), "http://localhost:8080/api/project/" + workspace + "/export" + item.getPath()); -// assertEquals(link.getProduces(), ExtMediaType.APPLICATION_ZIP); - link = item.getLink("delete"); assertNotNull(link); assertEquals(link.getMethod(), DELETE); - assertEquals(link.getHref(), "http://localhost:8080/api/project/" + workspace + item.getPath()); + assertEquals(link.getHref(), "http://localhost:8080/api/project" + item.getPath()); } @@ -2245,7 +1833,7 @@ public class ProjectServiceTest { case "update project": assertNotNull(link); assertEquals(link.getMethod(), PUT); - assertEquals(link.getHref(), "http://localhost:8080/api/project/" + workspace + project.getPath()); + assertEquals(link.getHref(), "http://localhost:8080/api/project" + project.getPath()); assertEquals(link.getConsumes(), APPLICATION_JSON); assertEquals(link.getProduces(), APPLICATION_JSON); break; @@ -2253,35 +1841,35 @@ public class ProjectServiceTest { case "children": assertNotNull(link); assertEquals(link.getMethod(), GET); - assertEquals(link.getHref(), "http://localhost:8080/api/project/" + workspace + "/children" + project.getPath()); + assertEquals(link.getHref(), "http://localhost:8080/api/project/children" + project.getPath()); assertEquals(link.getProduces(), APPLICATION_JSON); break; case "tree": assertNotNull(link); assertEquals(link.getMethod(), GET); - assertEquals(link.getHref(), "http://localhost:8080/api/project/" + workspace + "/tree" + project.getPath()); + assertEquals(link.getHref(), "http://localhost:8080/api/project/tree" + project.getPath()); assertEquals(link.getProduces(), APPLICATION_JSON); break; case "modules": assertNotNull(link); assertEquals(link.getMethod(), GET); - assertEquals(link.getHref(), "http://localhost:8080/api/project/" + workspace + "/modules" + project.getPath()); + assertEquals(link.getHref(), "http://localhost:8080/api/project/modules" + project.getPath()); assertEquals(link.getProduces(), APPLICATION_JSON); break; case "zipball sources": assertNotNull(link); assertEquals(link.getMethod(), GET); - assertEquals(link.getHref(), "http://localhost:8080/api/project/" + workspace + "/export" + project.getPath()); + assertEquals(link.getHref(), "http://localhost:8080/api/project/export" + project.getPath()); assertEquals(link.getProduces(), APPLICATION_ZIP); break; case "delete": assertNotNull(link); assertEquals(link.getMethod(), DELETE); - assertEquals(link.getHref(), "http://localhost:8080/api/project/" + workspace + project.getPath()); + assertEquals(link.getHref(), "http://localhost:8080/api/project" + project.getPath()); break; } } diff --git a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModuleResources.java b/wsagent/wsagent-local/src/main/java/org/eclipse/che/WorkspaceIdProvider.java similarity index 51% rename from plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModuleResources.java rename to wsagent/wsagent-local/src/main/java/org/eclipse/che/WorkspaceIdProvider.java index 4c58161c11..c27c478b08 100644 --- a/plugins/plugin-maven/che-plugin-maven-ide/src/main/java/org/eclipse/che/plugin/maven/client/module/CreateMavenModuleResources.java +++ b/wsagent/wsagent-local/src/main/java/org/eclipse/che/WorkspaceIdProvider.java @@ -8,21 +8,22 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.maven.client.module; +package org.eclipse.che; -import com.google.gwt.resources.client.ClientBundle; - -import org.eclipse.che.ide.ui.Styles; /** - * @author Evgen Vidolob + * Class provide workspace ID which linked to current developer machine it will take from environment variable "CHE_WORKSPACE_ID" + * if this variable not set return empty String but in real life should never be + * + * + * @author Vitalii Parfonov */ -public interface CreateMavenModuleResources extends ClientBundle { - @Source({"org/eclipse/che/ide/api/ui/style.css","org/eclipse/che/ide/ui/Styles.css"}) - Css css(); +public class WorkspaceIdProvider { - public interface Css extends Styles{ + public static final String CHE_WORKSPACE_ID = "CHE_WORKSPACE_ID"; + public static String getWorkspaceId() { + return System.getenv(CHE_WORKSPACE_ID) == null ? "" : System.getenv(CHE_WORKSPACE_ID); } } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceService.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceService.java index 4b59d30698..4bd47bb270 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceService.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceService.java @@ -855,6 +855,7 @@ public class WorkspaceService extends Service { .getLinks() .add(createLink("GET", UriBuilder.fromUri(wsAgent.getUrl()) + .path("ws") .scheme("https".equals(ideUri.getScheme()) ? "wss" : "ws") .build() .toString(),