diff --git a/CHANGELOG.md b/CHANGELOG.md index a31c64a3fb..2363dac44f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,76 @@ # Change Log +## [6.6.0](https://github.com/eclipse/che/tree/6.6.0) (2018-05-30) +[Full Changelog](https://github.com/eclipse/che/compare/6.5.1...6.6.0) + +**Merged pull requests:** + +- RELEASE: Set next development version [\#9862](https://github.com/eclipse/che/pull/9862) ([riuvshin](https://github.com/riuvshin)) +- fix build.sh for theia image [\#9850](https://github.com/eclipse/che/pull/9850) ([riuvshin](https://github.com/riuvshin)) +- Selenium: Rework "NewWorkspace" selenium page object by "SeleniumWebDriverHelper" class [\#9812](https://github.com/eclipse/che/pull/9812) ([Ohrimenko1988](https://github.com/Ohrimenko1988)) +- Fix contribute part displaying at project selection [\#9806](https://github.com/eclipse/che/pull/9806) ([RomanNikitenko](https://github.com/RomanNikitenko)) +- Implement selenium test for covering LS server for PHP language [\#9805](https://github.com/eclipse/che/pull/9805) ([musienko-maxim](https://github.com/musienko-maxim)) +- add bugfix versions to cli [\#9799](https://github.com/eclipse/che/pull/9799) ([riuvshin](https://github.com/riuvshin)) +- Removed Codenvy analytics components [\#9795](https://github.com/eclipse/che/pull/9795) ([sleshchenko](https://github.com/sleshchenko)) +- Wait until Che is available when deploying it on OCP [\#9783](https://github.com/eclipse/che/pull/9783) ([dmytro-ndp](https://github.com/dmytro-ndp)) +- fix formating [\#9782](https://github.com/eclipse/che/pull/9782) ([vparfonov](https://github.com/vparfonov)) +- There are possible places of failure due to not closing InputStreams [\#9780](https://github.com/eclipse/che/pull/9780) ([dkuleshov](https://github.com/dkuleshov)) +- Fix injection if any implementation of LanguageDescription found [\#9779](https://github.com/eclipse/che/pull/9779) ([vparfonov](https://github.com/vparfonov)) +- Send initialized event, after initialization [\#9776](https://github.com/eclipse/che/pull/9776) ([vparfonov](https://github.com/vparfonov)) +- Rework the 'ImportProjectFromZipTest' to add test repo on Github using the 'kohsuke GitHub' library [\#9773](https://github.com/eclipse/che/pull/9773) ([artaleks9](https://github.com/artaleks9)) +- che \#9542 Processing only the events that happened after `watchContainers` initialization [\#9772](https://github.com/eclipse/che/pull/9772) ([ibuziuk](https://github.com/ibuziuk)) +- CHE-8931: fix blank screen on project details page [\#9771](https://github.com/eclipse/che/pull/9771) ([akurinnoy](https://github.com/akurinnoy)) +- Rework the 'ImportMavenProjectFromGitTest' to add test repo on Github using the 'kohsuke Github' library [\#9763](https://github.com/eclipse/che/pull/9763) ([artaleks9](https://github.com/artaleks9)) +- Selenium: Rework the 'ImportProjectFromGitHubTest' to add test repo on Github using the 'kohsuke Github' library [\#9762](https://github.com/eclipse/che/pull/9762) ([artaleks9](https://github.com/artaleks9)) +- Selenium: cover Python LS functionality by selenium test [\#9759](https://github.com/eclipse/che/pull/9759) ([SkorikSergey](https://github.com/SkorikSergey)) +- Fix installers version confusing by displaying only the latest version [\#9758](https://github.com/eclipse/che/pull/9758) ([ashumilova](https://github.com/ashumilova)) +- Fix wsagent clientId passing, fix diagnostics recipe to work both on ocp and docker [\#9757](https://github.com/eclipse/che/pull/9757) ([ashumilova](https://github.com/ashumilova)) +- Delete child projects only from project config registry at removing project [\#9754](https://github.com/eclipse/che/pull/9754) ([RomanNikitenko](https://github.com/RomanNikitenko)) +- CHE-9716: Use the fixed version of Theia in eclipse/che-theia image [\#9751](https://github.com/eclipse/che/pull/9751) ([AndrienkoAleksandr](https://github.com/AndrienkoAleksandr)) +- If node is already visible in project tree, then select it instead of reload [\#9747](https://github.com/eclipse/che/pull/9747) ([vzhukovskii](https://github.com/vzhukovskii)) +- Selenium: Change the name of the test library in the resources [\#9746](https://github.com/eclipse/che/pull/9746) ([artaleks9](https://github.com/artaleks9)) +- Fix AskDialog page object of selenium tests [\#9745](https://github.com/eclipse/che/pull/9745) ([dmytro-ndp](https://github.com/dmytro-ndp)) +- Provide machine name as a machine's environment variable [\#9743](https://github.com/eclipse/che/pull/9743) ([mkuznyetsov](https://github.com/mkuznyetsov)) +- Selenium: Rework the 'ImportWizardFormTest' to add test repo on Github using the 'kohsuke GitHub' library [\#9742](https://github.com/eclipse/che/pull/9742) ([artaleks9](https://github.com/artaleks9)) +- Make client id and secret configurable from command line [\#9738](https://github.com/eclipse/che/pull/9738) ([eivantsov](https://github.com/eivantsov)) +- Move building of postgresql-tck module to integration build profile [\#9737](https://github.com/eclipse/che/pull/9737) ([mkuznyetsov](https://github.com/mkuznyetsov)) +- Added an error when keycloak container is not found [\#9736](https://github.com/eclipse/che/pull/9736) ([sleshchenko](https://github.com/sleshchenko)) +- End-To-End tests of download project/directory/file feature [\#9724](https://github.com/eclipse/che/pull/9724) ([dmytro-ndp](https://github.com/dmytro-ndp)) +- Send request with activity on ws-agent in a separate thread [\#9708](https://github.com/eclipse/che/pull/9708) ([mkuznyetsov](https://github.com/mkuznyetsov)) +- che-9234: fix diagnostics by reworking websocket usage to jsonrpc [\#9704](https://github.com/eclipse/che/pull/9704) ([ashumilova](https://github.com/ashumilova)) +- \#9542 Proper handling of unrecoverable events. Processing only events which are related to current workspace pods [\#9703](https://github.com/eclipse/che/pull/9703) ([ibuziuk](https://github.com/ibuziuk)) +- Added JGroups based status cache and lock service [\#9701](https://github.com/eclipse/che/pull/9701) ([sleshchenko](https://github.com/sleshchenko)) +- Fixed wrong logger output [\#9696](https://github.com/eclipse/che/pull/9696) ([skabashnyuk](https://github.com/skabashnyuk)) +- Selenium: increase timeout for checking the project details page [\#9695](https://github.com/eclipse/che/pull/9695) ([SkorikSergey](https://github.com/SkorikSergey)) +- CHE-9523 fix flow to creating a new OpenShift/K8S stack [\#9693](https://github.com/eclipse/che/pull/9693) ([olexii4](https://github.com/olexii4)) +- Fix of P1 bugs in dashboard [\#9690](https://github.com/eclipse/che/pull/9690) ([ashumilova](https://github.com/ashumilova)) +- Notify consumers about file is opened at restoring IDE state [\#9689](https://github.com/eclipse/che/pull/9689) ([RomanNikitenko](https://github.com/RomanNikitenko)) +- Selenium: Add the 'try/catch' to the 'PullRequestPluginTest' according to the known issue \#9484 [\#9688](https://github.com/eclipse/che/pull/9688) ([artaleks9](https://github.com/artaleks9)) +- Fixed removing of temporary workspaces on server startup and shutdown [\#9687](https://github.com/eclipse/che/pull/9687) ([sleshchenko](https://github.com/sleshchenko)) +- Selenium: Restore order of the test methods launch in the "ContextMenuEditorTest" selenium test [\#9686](https://github.com/eclipse/che/pull/9686) ([Ohrimenko1988](https://github.com/Ohrimenko1988)) +- Added an ability to schedule servers checkers for STARTING K8s/OS runtime [\#9685](https://github.com/eclipse/che/pull/9685) ([sleshchenko](https://github.com/sleshchenko)) +- Add DB termination component on application shutdown [\#9683](https://github.com/eclipse/che/pull/9683) ([mshaposhnik](https://github.com/mshaposhnik)) +- RELEASE: Update CHANGELOG [\#9678](https://github.com/eclipse/che/pull/9678) ([riuvshin](https://github.com/riuvshin)) +- Selenium: Replace the known issue \#8856 on the \#9556 in the try/catch block in the TestWorkspaceImpl [\#9672](https://github.com/eclipse/che/pull/9672) ([artaleks9](https://github.com/artaleks9)) +- CHE-6109: Enable Update project configuration from any project level [\#9671](https://github.com/eclipse/che/pull/9671) ([vinokurig](https://github.com/vinokurig)) +- RELEASE: Set next development version [\#9669](https://github.com/eclipse/che/pull/9669) ([riuvshin](https://github.com/riuvshin)) +- Adding error from machine startup and installers to slf4j log [\#9659](https://github.com/eclipse/che/pull/9659) ([skabashnyuk](https://github.com/skabashnyuk)) +- Add missing service terminations [\#9658](https://github.com/eclipse/che/pull/9658) ([sleshchenko](https://github.com/sleshchenko)) +- Add ability to configure OAuth type in Multi User Che [\#9640](https://github.com/eclipse/che/pull/9640) ([mkuznyetsov](https://github.com/mkuznyetsov)) +- Adding `-Dvertx.disableDnsResolver=true` to vert.x run / debug commands [\#9611](https://github.com/eclipse/che/pull/9611) ([ibuziuk](https://github.com/ibuziuk)) +- To white label dashboard, make it possible to override dashboard fonts [\#9604](https://github.com/eclipse/che/pull/9604) ([panditrashmi](https://github.com/panditrashmi)) +- Correct process situation when project has been renamed [\#9582](https://github.com/eclipse/che/pull/9582) ([vzhukovskii](https://github.com/vzhukovskii)) +- Allow creating OpenShift objects under the current user account on OCP [\#9577](https://github.com/eclipse/che/pull/9577) ([davidfestal](https://github.com/davidfestal)) +- \[WIP\] Several improvements to the way remote language servers may be configured through workspace configuration [\#9387](https://github.com/eclipse/che/pull/9387) ([dkuleshov](https://github.com/dkuleshov)) + +## [6.5.1](https://github.com/eclipse/che/tree/6.5.1) (2018-05-24) +[Full Changelog](https://github.com/eclipse/che/compare/6.5.0...6.5.1) + +**Merged pull requests:** + +- Selenium: change url of known issue to \#9523 instead of \#9648 in StacksListTest test [\#9667](https://github.com/eclipse/che/pull/9667) ([SkorikSergey](https://github.com/SkorikSergey)) + + ## [6.5.0](https://github.com/eclipse/che/tree/6.5.0) (2018-05-10) [Full Changelog](https://github.com/eclipse/che/compare/6.4.1...6.5.0) diff --git a/dashboard/src/app/workspaces/workspace-details/workspace-machines/edit-machine-dialog/edit-machine-dialog.controller.ts b/dashboard/src/app/workspaces/workspace-details/workspace-machines/edit-machine-dialog/edit-machine-dialog.controller.ts index f297f2fd42..ecfcf503d6 100644 --- a/dashboard/src/app/workspaces/workspace-details/workspace-machines/edit-machine-dialog/edit-machine-dialog.controller.ts +++ b/dashboard/src/app/workspaces/workspace-details/workspace-machines/edit-machine-dialog/edit-machine-dialog.controller.ts @@ -114,6 +114,11 @@ export class EditMachineDialogController { return; } this.environmentManager.setMemoryLimit(this.machine, this.machineRAM); + // update environment's machines + const machines = this.environmentManager.getMachines(this.copyEnvironment).map((machine: IEnvironmentManagerMachine) => { + return machine.name === this.machine.name ? this.machine : machine; + }); + this.copyEnvironment = this.environmentManager.getEnvironment(this.copyEnvironment, machines); this.stringifyMachineRecipe(); } diff --git a/deploy/openshift/templates/che-server-template.yaml b/deploy/openshift/templates/che-server-template.yaml index 7578a64250..07b8d18e3f 100644 --- a/deploy/openshift/templates/che-server-template.yaml +++ b/deploy/openshift/templates/che-server-template.yaml @@ -136,6 +136,12 @@ objects: value: "${PROTOCOL}" - name: ROUTING_SUFFIX value: "${ROUTING_SUFFIX}" + - name: OPENSHIFT_IDENTITY_PROVIDER_CERTIFICATE + valueFrom: + secretKeyRef: + key: ca.crt + name: openshift-identity-provider + optional: true image: ${IMAGE_CHE}:${CHE_VERSION} imagePullPolicy: "${PULL_POLICY}" livenessProbe: diff --git a/dockerfiles/che/entrypoint.sh b/dockerfiles/che/entrypoint.sh index f9dbaea39c..f3ffb927b2 100755 --- a/dockerfiles/che/entrypoint.sh +++ b/dockerfiles/che/entrypoint.sh @@ -280,6 +280,16 @@ init() { export JAVA_OPTS="${JAVA_OPTS} -Dche.docker.network=$NETWORK_NAME" } +add_cert_to_truststore() { + + if [ "${OPENSHIFT_IDENTITY_PROVIDER_CERTIFICATE}" != "" ]; then + echo "Found a custom cert. Adding it to java trust store..." + echo "${OPENSHIFT_IDENTITY_PROVIDER_CERTIFICATE}" > /home/user/openshift.crt + echo yes | keytool -keystore /home/user/openshift.jks -importcert -alias HOSTDOMAIN -file /home/user/openshift.crt -storepass minishift + export JAVA_OPTS="${JAVA_OPTS} -Djavax.net.ssl.trustStore=/home/user/openshift.jks -Djavax.net.ssl.trustStorePassword=minishift" + fi +} + get_che_data_from_host() { DEFAULT_DATA_HOST_PATH=/data CHE_SERVER_CONTAINER_ID=$(get_che_server_container_id) @@ -339,6 +349,7 @@ trap 'responsible_shutdown' SIGHUP SIGTERM SIGINT init init_global_variables set_environment_variables +add_cert_to_truststore # run che start_che_server & diff --git a/ide/che-core-ide-stacks/src/main/resources/stacks.json b/ide/che-core-ide-stacks/src/main/resources/stacks.json index 6b59eb7b1d..50118bedbb 100644 --- a/ide/che-core-ide-stacks/src/main/resources/stacks.json +++ b/ide/che-core-ide-stacks/src/main/resources/stacks.json @@ -53,7 +53,7 @@ }, "recipe": { "type": "compose", - "content": "services:\n theia:\n image: eclipse/che-theia:nightly\n mem_limit: 1073741824\n dev-machine:\n image: eclipse/che-dev:nightly\n mem_limit: 2147483648\n depends_on:\n - theia", + "content": "services:\n theia:\n image: eclipse/che-theia:0.3.10-nightly\n mem_limit: 1073741824\n dev-machine:\n image: eclipse/che-dev:nightly\n mem_limit: 2147483648\n depends_on:\n - theia", "contentType": "application/x-yaml" } } @@ -123,7 +123,7 @@ }, "recipe": { "type": "openshift", - "content": "---\nkind: List\nitems:\n-\n apiVersion: v1\n kind: Pod\n metadata:\n name: ws\n spec:\n containers:\n -\n image: eclipse/che-theia:nightly\n name: theia\n -\n image: eclipse/che-dev:nightly\n name: dev", + "content": "---\nkind: List\nitems:\n-\n apiVersion: v1\n kind: Pod\n metadata:\n name: ws\n spec:\n containers:\n -\n image: eclipse/che-theia:0.3.10-nightly\n name: theia\n -\n image: eclipse/che-dev:nightly\n name: dev", "contentType": "application/x-yaml" } } diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerRuntimeInfrastructure.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerRuntimeInfrastructure.java index 670be7deb5..53182e2fed 100644 --- a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerRuntimeInfrastructure.java +++ b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/DockerRuntimeInfrastructure.java @@ -80,7 +80,10 @@ public class DockerRuntimeInfrastructure extends RuntimeInfrastructure { @Override public Set getIdentities() throws InfrastructureException { - return containers.findIdentities(); + // Due to https://github.com/eclipse/che/issues/5814, recovering is not fully possible + // so infrastructure should not claim support of it. + // return containers.findIdentities(); + throw new UnsupportedOperationException("Runtimes tracking currently does not supported."); } private DockerEnvironment convertToDockerEnv(InternalEnvironment sourceEnv) diff --git a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/server/mapping/ServersMapper.java b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/server/mapping/ServersMapper.java index 6681e2fb5e..dcc5e86fdd 100644 --- a/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/server/mapping/ServersMapper.java +++ b/infrastructures/docker/infrastructure/src/main/java/org/eclipse/che/workspace/infrastructure/docker/server/mapping/ServersMapper.java @@ -18,6 +18,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.che.api.core.model.workspace.config.ServerConfig; +import org.eclipse.che.api.core.model.workspace.runtime.ServerStatus; import org.eclipse.che.api.workspace.server.model.impl.ServerImpl; import org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException; import org.eclipse.che.commons.annotation.Nullable; @@ -110,7 +111,8 @@ public class ServersMapper { ref, new ServerImpl() .withUrl(makeUrl(port, cfg.getProtocol(), cfg.getPath(), hostname)) - .withAttributes(cfg.getAttributes())); + .withAttributes(cfg.getAttributes()) + .withStatus(ServerStatus.UNKNOWN)); } } } diff --git a/infrastructures/docker/infrastructure/src/test/java/org/eclipse/che/workspace/infrastructure/docker/server/mapping/ServersMapperTest.java b/infrastructures/docker/infrastructure/src/test/java/org/eclipse/che/workspace/infrastructure/docker/server/mapping/ServersMapperTest.java index 64d9a3f557..aa68c8f51e 100644 --- a/infrastructures/docker/infrastructure/src/test/java/org/eclipse/che/workspace/infrastructure/docker/server/mapping/ServersMapperTest.java +++ b/infrastructures/docker/infrastructure/src/test/java/org/eclipse/che/workspace/infrastructure/docker/server/mapping/ServersMapperTest.java @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import org.eclipse.che.api.core.model.workspace.config.ServerConfig; +import org.eclipse.che.api.core.model.workspace.runtime.ServerStatus; import org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.ServerImpl; import org.eclipse.che.infrastructure.docker.client.json.PortBinding; @@ -65,11 +66,13 @@ public class ServersMapperTest { "server1", new ServerImpl() .withUrl("http://" + hostname + ":32080/no-slash-path") - .withAttributes(ONE_ATTRIBUTE_MAP), + .withAttributes(ONE_ATTRIBUTE_MAP) + .withStatus(ServerStatus.UNKNOWN), "server2", new ServerImpl() .withUrl("http://" + hostname + ":32081/slash-path") - .withAttributes(emptyMap())) + .withAttributes(emptyMap()) + .withStatus(ServerStatus.UNKNOWN)) }, { ImmutableMap.of("8080/tcp", "0.0.0.0:32080"), @@ -80,11 +83,13 @@ public class ServersMapperTest { "server1", new ServerImpl() .withUrl("http://" + hostname + ":32080/http-endpoint") - .withAttributes(emptyMap()), + .withAttributes(emptyMap()) + .withStatus(ServerStatus.UNKNOWN), "server2", new ServerImpl() .withUrl("ws://" + hostname + ":32080/ws-endpoint") - .withAttributes(ATTRIBUTES_MAP)) + .withAttributes(ATTRIBUTES_MAP) + .withStatus(ServerStatus.UNKNOWN)) }, { ImmutableMap.of("8080/tcp", "0.0.0.0:32080"), @@ -95,11 +100,13 @@ public class ServersMapperTest { "server1", new ServerImpl() .withUrl("http://" + hostname + ":32080/http-endpoint") - .withAttributes(emptyMap()), + .withAttributes(emptyMap()) + .withStatus(ServerStatus.UNKNOWN), "server2", new ServerImpl() .withUrl("ws://" + hostname + ":32080/ws-endpoint") - .withAttributes(emptyMap())) + .withAttributes(emptyMap()) + .withStatus(ServerStatus.UNKNOWN)) }, // ensure that ports that don't have matching server config are not shown as servers { @@ -124,15 +131,18 @@ public class ServersMapperTest { "ws-master", new ServerImpl() .withUrl("http://" + hostname + ":32080/api") - .withAttributes(emptyMap()), + .withAttributes(emptyMap()) + .withStatus(ServerStatus.UNKNOWN), "exec-agent-api", new ServerImpl() .withUrl("http://" + hostname + ":32401/process") - .withAttributes(ONE_ATTRIBUTE_MAP), + .withAttributes(ONE_ATTRIBUTE_MAP) + .withStatus(ServerStatus.UNKNOWN), "exec-agent-ws", new ServerImpl() .withUrl("ws://" + hostname + ":32401/connect") - .withAttributes(ATTRIBUTES_MAP)) + .withAttributes(ATTRIBUTES_MAP) + .withStatus(ServerStatus.UNKNOWN)) }, // mapping of internal servers { @@ -143,7 +153,8 @@ public class ServersMapperTest { "ls-api", new ServerImpl() .withUrl("tcp://" + machine + ":4401") - .withAttributes(INTERNAL_SERVER_ATTRIBUTE_MAP)) + .withAttributes(INTERNAL_SERVER_ATTRIBUTE_MAP) + .withStatus(ServerStatus.UNKNOWN)) } }; } diff --git a/plugins/plugin-java-debugger/che-plugin-java-debugger-server/src/test/java/org/eclipse/che/plugin/jdb/server/util/ProjectApiUtils.java b/plugins/plugin-java-debugger/che-plugin-java-debugger-server/src/test/java/org/eclipse/che/plugin/jdb/server/util/ProjectApiUtils.java index db86382d46..8060f2021f 100644 --- a/plugins/plugin-java-debugger/che-plugin-java-debugger-server/src/test/java/org/eclipse/che/plugin/jdb/server/util/ProjectApiUtils.java +++ b/plugins/plugin-java-debugger/che-plugin-java-debugger-server/src/test/java/org/eclipse/che/plugin/jdb/server/util/ProjectApiUtils.java @@ -33,6 +33,7 @@ import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.impl.ProjectServiceApi; import org.eclipse.che.api.project.server.impl.ProjectServiceApiFactory; import org.eclipse.che.api.project.server.impl.ProjectServiceVcsStatusInjector; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.api.project.server.impl.WorkspaceProjectSynchronizer; import org.eclipse.che.api.search.server.SearchApiModule; import org.eclipse.che.api.watcher.server.FileWatcherApiModule; @@ -68,7 +69,7 @@ public class ProjectApiUtils { /** Initialize project API for tests. */ private static void init() throws Exception { - File root = new File("target/test-classes/workspace"); + File root = new File("target/test-classes/workspace").getAbsoluteFile(); File indexDir = new File("target/test-classes/workspace/index"); Injector injector = @@ -135,13 +136,15 @@ public class ProjectApiUtils { ProjectManager projectManager = injector.getInstance(ProjectManager.class); FsManager fsManager = injector.getInstance(FsManager.class); PathTransformer pathTransformer = injector.getInstance(PathTransformer.class); + RootDirPathProvider pathProvider = injector.getInstance(RootDirPathProvider.class); projectManager.setType("/test", "java", false); ResourcesPlugin resourcesPlugin = new ResourcesPlugin( indexDir.getAbsolutePath(), - root.getAbsolutePath(), + pathProvider, + // root.getAbsolutePath(), () -> projectManager, () -> pathTransformer, () -> fsManager); diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/pom.xml b/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/pom.xml index 6b129284b7..754563366f 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/pom.xml +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/pom.xml @@ -53,6 +53,10 @@ org.eclipse.che.core che-core-api-project + + org.eclipse.che.core + che-core-api-project-shared + org.eclipse.che.core che-core-api-workspace diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/src/main/java/org/eclipse/che/core/internal/resources/Project.java b/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/src/main/java/org/eclipse/che/core/internal/resources/Project.java index 24128d83f5..a7f4653ba6 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/src/main/java/org/eclipse/che/core/internal/resources/Project.java +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/src/main/java/org/eclipse/che/core/internal/resources/Project.java @@ -14,7 +14,7 @@ import java.net.URI; import java.util.List; import java.util.Map; import java.util.Optional; -import org.eclipse.che.api.project.server.impl.RegisteredProject; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.ICommand; import org.eclipse.core.resources.IContainer; diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/src/main/java/org/eclipse/che/core/internal/resources/WorkspaceRoot.java b/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/src/main/java/org/eclipse/che/core/internal/resources/WorkspaceRoot.java index 96ba58cb8c..40a426ffb8 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/src/main/java/org/eclipse/che/core/internal/resources/WorkspaceRoot.java +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/src/main/java/org/eclipse/che/core/internal/resources/WorkspaceRoot.java @@ -16,7 +16,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import org.eclipse.che.api.project.server.ProjectManager; -import org.eclipse.che.api.project.server.impl.RegisteredProject; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/src/main/java/org/eclipse/core/resources/ResourcesPlugin.java b/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/src/main/java/org/eclipse/core/resources/ResourcesPlugin.java index 56675f633a..1b1075686e 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/src/main/java/org/eclipse/core/resources/ResourcesPlugin.java +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-core-resources/src/main/java/org/eclipse/core/resources/ResourcesPlugin.java @@ -17,6 +17,7 @@ import javax.annotation.PostConstruct; import org.eclipse.che.api.fs.server.FsManager; import org.eclipse.che.api.fs.server.PathTransformer; import org.eclipse.che.api.project.server.ProjectManager; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.core.internal.resources.Workspace; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.internal.utils.Messages; @@ -189,12 +190,12 @@ public class ResourcesPlugin { @Inject public ResourcesPlugin( @Named("che.jdt.workspace.index.dir") String indexPath, - @Named("che.user.workspaces.storage") String workspacePath, + RootDirPathProvider pathProvider, Provider projectManagerProvider, Provider pathTransformerProvider, Provider fsManagerProvider) { ResourcesPlugin.indexPath = indexPath; - ResourcesPlugin.workspacePath = workspacePath; + ResourcesPlugin.workspacePath = pathProvider.get(); pluginId = "cheWsPlugin"; EFS.setWsPath(workspacePath); workspace = diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-jdt-ui/pom.xml b/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-jdt-ui/pom.xml index 32097dd15b..1657063020 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-jdt-ui/pom.xml +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-jdt-ui/pom.xml @@ -58,6 +58,10 @@ org.eclipse.che.core che-core-api-dto + + org.eclipse.che.core + che-core-api-model + org.eclipse.che.core che-core-api-project diff --git a/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-jdt-ui/src/main/java/org/eclipse/che/jdt/javaeditor/JavaReconciler.java b/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-jdt-ui/src/main/java/org/eclipse/che/jdt/javaeditor/JavaReconciler.java index 42ed8b0cab..e4a0fc3684 100644 --- a/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-jdt-ui/src/main/java/org/eclipse/che/jdt/javaeditor/JavaReconciler.java +++ b/plugins/plugin-java/che-plugin-java-ext-jdt/org-eclipse-jdt-ui/src/main/java/org/eclipse/che/jdt/javaeditor/JavaReconciler.java @@ -24,13 +24,13 @@ import java.util.List; import javax.annotation.PreDestroy; import org.eclipse.che.api.core.NotFoundException; import org.eclipse.che.api.core.jsonrpc.commons.RequestTransmitter; +import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.core.notification.EventSubscriber; import org.eclipse.che.api.editor.server.impl.EditorWorkingCopy; import org.eclipse.che.api.editor.server.impl.EditorWorkingCopyManager; import org.eclipse.che.api.editor.server.impl.EditorWorkingCopyUpdatedEvent; import org.eclipse.che.api.project.server.ProjectManager; -import org.eclipse.che.api.project.server.impl.RegisteredProject; import org.eclipse.che.api.project.shared.dto.EditorChangesDto; import org.eclipse.che.api.project.shared.dto.ServerError; import org.eclipse.che.api.project.shared.dto.event.FileTrackingOperationDto; @@ -213,7 +213,7 @@ public class JavaReconciler { case START: { String filePath = operation.getPath(); - RegisteredProject project = + ProjectConfig project = projectManager .getClosest(filePath) .orElseThrow( diff --git a/plugins/plugin-java/che-plugin-java-ext-lang-server/src/main/java/org/eclipse/che/plugin/java/server/ProjectListeners.java b/plugins/plugin-java/che-plugin-java-ext-lang-server/src/main/java/org/eclipse/che/plugin/java/server/ProjectListeners.java index de266f19d2..2804eb2655 100644 --- a/plugins/plugin-java/che-plugin-java-ext-lang-server/src/main/java/org/eclipse/che/plugin/java/server/ProjectListeners.java +++ b/plugins/plugin-java/che-plugin-java-ext-lang-server/src/main/java/org/eclipse/che/plugin/java/server/ProjectListeners.java @@ -14,14 +14,13 @@ import static org.eclipse.che.api.fs.server.WsPathUtils.absolutize; import com.google.inject.Inject; import com.google.inject.Singleton; -import com.google.inject.name.Named; import java.io.File; import org.eclipse.che.api.core.NotFoundException; import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.core.notification.EventSubscriber; -import org.eclipse.che.api.fs.server.PathTransformer; import org.eclipse.che.api.project.server.ProjectManager; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.api.project.server.notification.ProjectCreatedEvent; import org.eclipse.che.api.project.server.notification.ProjectItemModifiedEvent; import org.eclipse.che.api.project.server.type.ProjectTypeRegistry; @@ -46,19 +45,16 @@ public class ProjectListeners { private final File workspace; private final ProjectManager projectRegistry; private final ProjectTypeRegistry projectTypeRegistry; - private final PathTransformer pathTransformer; @Inject public ProjectListeners( - @Named("che.user.workspaces.storage") String workspacePath, + RootDirPathProvider pathProvider, EventService eventService, ProjectManager projectRegistry, - ProjectTypeRegistry projectTypeRegistry, - PathTransformer pathTransformer) { + ProjectTypeRegistry projectTypeRegistry) { this.projectRegistry = projectRegistry; this.projectTypeRegistry = projectTypeRegistry; - workspace = new File(workspacePath); - this.pathTransformer = pathTransformer; + workspace = new File(pathProvider.get()); eventService.subscribe(new ProjectCreated()); eventService.subscribe( new EventSubscriber() { 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/projecttype/PlainJavaInitHandler.java b/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/main/java/org/eclipse/che/plugin/java/plain/server/projecttype/PlainJavaInitHandler.java index 4f202b28fb..f821769235 100644 --- a/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/main/java/org/eclipse/che/plugin/java/plain/server/projecttype/PlainJavaInitHandler.java +++ b/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/main/java/org/eclipse/che/plugin/java/plain/server/projecttype/PlainJavaInitHandler.java @@ -19,8 +19,8 @@ import com.google.inject.Provider; import java.util.Arrays; import java.util.List; import org.eclipse.che.api.core.ServerException; +import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.project.server.ProjectManager; -import org.eclipse.che.api.project.server.impl.RegisteredProject; import org.eclipse.che.ide.ext.java.shared.Constants; import org.eclipse.che.plugin.java.server.projecttype.AbstractJavaInitHandler; import org.eclipse.jdt.core.IClasspathEntry; @@ -70,7 +70,7 @@ public class PlainJavaInitHandler extends AbstractJavaInitHandler { } String wsPath = absolutize(javaProject.getPath().toOSString()); - RegisteredProject project = + ProjectConfig project = projectRegistryProvider .get() .get(wsPath) 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 2731b41e26..d3bd97a5bf 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 @@ -32,10 +32,10 @@ import org.eclipse.che.api.core.ConflictException; import org.eclipse.che.api.core.ForbiddenException; import org.eclipse.che.api.core.NotFoundException; import org.eclipse.che.api.core.ServerException; +import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.fs.server.PathTransformer; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.impl.NewProjectConfigImpl; -import org.eclipse.che.api.project.server.impl.RegisteredProject; import org.eclipse.che.api.project.shared.NewProjectConfig; import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto; import org.eclipse.core.runtime.IPath; @@ -94,7 +94,7 @@ public class ClasspathUpdaterService { throws IOException, ForbiddenException, ConflictException, NotFoundException, ServerException, BadRequestException { String wsPath = absolutize(projectWsPath); - RegisteredProject project = + ProjectConfig project = projectManager .get(wsPath) .orElseThrow(() -> new NotFoundException("Can't find project: " + projectWsPath)); diff --git a/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/test/java/org/eclipse/che/plugin/java/plain/server/projecttype/PlainJavaValueProviderFactoryTest.java b/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/test/java/org/eclipse/che/plugin/java/plain/server/projecttype/PlainJavaValueProviderFactoryTest.java index 87b56c3113..d62d3dc6a5 100644 --- a/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/test/java/org/eclipse/che/plugin/java/plain/server/projecttype/PlainJavaValueProviderFactoryTest.java +++ b/plugins/plugin-java/che-plugin-java-plain/che-plugin-java-plain-server/src/test/java/org/eclipse/che/plugin/java/plain/server/projecttype/PlainJavaValueProviderFactoryTest.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; import org.eclipse.che.api.project.server.ProjectManager; -import org.eclipse.che.api.project.server.impl.RegisteredProject; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.InjectMocks; diff --git a/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/MavenWorkspace.java b/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/MavenWorkspace.java index 4533f8a2a9..cc2ed6d028 100644 --- a/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/MavenWorkspace.java +++ b/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/MavenWorkspace.java @@ -28,10 +28,10 @@ import org.eclipse.che.api.core.ConflictException; import org.eclipse.che.api.core.ForbiddenException; import org.eclipse.che.api.core.NotFoundException; import org.eclipse.che.api.core.ServerException; +import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.core.notification.EventSubscriber; import org.eclipse.che.api.project.server.ProjectManager; -import org.eclipse.che.api.project.server.impl.RegisteredProject; import org.eclipse.che.api.project.server.notification.ProjectDeletedEvent; import org.eclipse.che.ide.ext.java.shared.Constants; import org.eclipse.che.jdt.core.launching.JREContainerInitializer; @@ -240,7 +240,7 @@ public class MavenWorkspace { "org.codehaus.mojo", "build-helper-maven-plugin", "add-test-source"); IPath projectPath = project.getProject().getFullPath(); - RegisteredProject registeredProject = + ProjectConfig registeredProject = projectManagerProvider .get() .get(projectPath.toOSString()) diff --git a/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/classpath/ClasspathManager.java b/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/classpath/ClasspathManager.java index ceda2df686..ef9911a719 100644 --- a/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/classpath/ClasspathManager.java +++ b/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/classpath/ClasspathManager.java @@ -12,10 +12,10 @@ package org.eclipse.che.plugin.maven.server.core.classpath; import com.google.inject.Inject; import com.google.inject.Singleton; -import com.google.inject.name.Named; import java.io.File; import java.util.Collections; import java.util.List; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.maven.data.MavenArtifact; import org.eclipse.che.maven.data.MavenArtifactKey; import org.eclipse.che.maven.data.MavenRemoteRepository; @@ -64,13 +64,13 @@ public class ClasspathManager { @Inject public ClasspathManager( - @Named("che.user.workspaces.storage") String workspacePath, + RootDirPathProvider pathProvider, MavenWrapperManager wrapperManager, MavenProjectManager projectManager, MavenTerminal terminal, MavenProgressNotifier notifier) { - this.workspacePath = workspacePath; + this.workspacePath = pathProvider.get(); this.wrapperManager = wrapperManager; this.projectManager = projectManager; this.terminal = terminal; diff --git a/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/project/PomChangeListener.java b/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/project/PomChangeListener.java index 917a4efea9..30137e0068 100644 --- a/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/project/PomChangeListener.java +++ b/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/core/project/PomChangeListener.java @@ -12,7 +12,6 @@ package org.eclipse.che.plugin.maven.server.core.project; import com.google.inject.Inject; import com.google.inject.Singleton; -import com.google.inject.name.Named; import java.io.File; import java.util.HashSet; import java.util.List; @@ -24,6 +23,7 @@ import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.core.notification.EventSubscriber; import org.eclipse.che.api.editor.server.impl.EditorWorkingCopy; import org.eclipse.che.api.editor.server.impl.EditorWorkingCopyManager; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.api.project.server.notification.ProjectItemModifiedEvent; import org.eclipse.che.api.project.shared.dto.event.PomModifiedEventDto; import org.eclipse.che.commons.schedule.executor.ThreadPullLauncher; @@ -52,11 +52,11 @@ public class PomChangeListener { EclipseWorkspaceProvider eclipseWorkspaceProvider, EditorWorkingCopyManager editorWorkingCopyManager, ThreadPullLauncher launcher, - @Named("che.user.workspaces.storage") String workspacePath) { + RootDirPathProvider pathProvider) { this.mavenWorkspace = mavenWorkspace; this.eclipseWorkspaceProvider = eclipseWorkspaceProvider; this.editorWorkingCopyManager = editorWorkingCopyManager; - this.workspacePath = workspacePath; + this.workspacePath = pathProvider.get(); launcher.scheduleWithFixedDelay(this::updateProms, 20, 3, TimeUnit.SECONDS); diff --git a/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/projecttype/MavenTargetExcludeMatcher.java b/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/projecttype/MavenTargetExcludeMatcher.java index 8f7f8e47e7..ffbeff0ab2 100644 --- a/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/projecttype/MavenTargetExcludeMatcher.java +++ b/plugins/plugin-maven/che-plugin-maven-server/src/main/java/org/eclipse/che/plugin/maven/server/projecttype/MavenTargetExcludeMatcher.java @@ -14,9 +14,9 @@ import java.nio.file.Path; import java.nio.file.PathMatcher; import javax.inject.Inject; import javax.inject.Singleton; +import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.fs.server.PathTransformer; import org.eclipse.che.api.project.server.ProjectManager; -import org.eclipse.che.api.project.server.impl.RegisteredProject; import org.eclipse.che.plugin.maven.shared.MavenAttributes; @Singleton @@ -34,7 +34,7 @@ public class MavenTargetExcludeMatcher implements PathMatcher { @Override public boolean matches(Path fsPath) { String wsPath = pathTransformer.transform(fsPath); - RegisteredProject project = projectManager.getClosestOrNull(wsPath); + ProjectConfig project = projectManager.getClosestOrNull(wsPath); if (project == null) { return false; } 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 bfa3b0885b..6c03b6a7ed 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 @@ -35,7 +35,6 @@ import org.eclipse.che.api.core.NotFoundException; import org.eclipse.che.api.core.ServerException; import org.eclipse.che.api.fs.server.FsManager; import org.eclipse.che.api.project.server.ProjectManager; -import org.eclipse.che.api.project.server.impl.RegisteredProject; import org.eclipse.che.maven.server.MavenTerminal; import org.eclipse.che.plugin.maven.server.MavenServerWrapper; import org.eclipse.che.plugin.maven.server.MavenWrapperManager; @@ -104,11 +103,6 @@ public class MavenServerService { throws ServerException, NotFoundException, ForbiddenException { String projectWsPath = absolutize(projectPath); - RegisteredProject project = - projectManager - .get(projectWsPath) - .orElseThrow(() -> new NotFoundException("Can't find project: " + projectWsPath)); - MavenServerWrapper mavenServer = wrapperManager.getMavenServer(MavenWrapperManager.ServerType.DOWNLOAD); diff --git a/plugins/plugin-pullrequest-parent/che-plugin-pullrequest-server/pom.xml b/plugins/plugin-pullrequest-parent/che-plugin-pullrequest-server/pom.xml index 0d461d9569..a6aec42cef 100644 --- a/plugins/plugin-pullrequest-parent/che-plugin-pullrequest-server/pom.xml +++ b/plugins/plugin-pullrequest-parent/che-plugin-pullrequest-server/pom.xml @@ -48,6 +48,10 @@ org.eclipse.che.core che-core-api-git-shared + + org.eclipse.che.core + che-core-api-model + org.eclipse.che.core che-core-api-project diff --git a/plugins/plugin-pullrequest-parent/che-plugin-pullrequest-server/src/main/java/org/eclipse/che/plugin/pullrequest/server/ContributionProjectTypeCleaner.java b/plugins/plugin-pullrequest-parent/che-plugin-pullrequest-server/src/main/java/org/eclipse/che/plugin/pullrequest/server/ContributionProjectTypeCleaner.java index 7caed045c6..5bceea6151 100644 --- a/plugins/plugin-pullrequest-parent/che-plugin-pullrequest-server/src/main/java/org/eclipse/che/plugin/pullrequest/server/ContributionProjectTypeCleaner.java +++ b/plugins/plugin-pullrequest-parent/che-plugin-pullrequest-server/src/main/java/org/eclipse/che/plugin/pullrequest/server/ContributionProjectTypeCleaner.java @@ -27,12 +27,12 @@ import org.eclipse.che.api.core.ConflictException; import org.eclipse.che.api.core.ForbiddenException; import org.eclipse.che.api.core.NotFoundException; import org.eclipse.che.api.core.ServerException; +import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.core.notification.EventSubscriber; import org.eclipse.che.api.git.shared.event.GitRepositoryDeletedEvent; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.impl.NewProjectConfigImpl; -import org.eclipse.che.api.project.server.impl.RegisteredProject; import org.slf4j.Logger; /** @author Vitalii Parfonov */ @@ -65,7 +65,7 @@ public class ContributionProjectTypeCleaner implements EventSubscriber> attributes = project.getAttributes(); attributes.remove(CONTRIBUTE_LOCAL_BRANCH_NAME); attributes.remove(CONTRIBUTE_TO_BRANCH_VARIABLE_NAME); diff --git a/plugins/plugin-testing-java/plugin-testing-classpath/src/main/java/org/eclipse/che/plugin/java/testing/ProjectClasspathProvider.java b/plugins/plugin-testing-java/plugin-testing-classpath/src/main/java/org/eclipse/che/plugin/java/testing/ProjectClasspathProvider.java index f068eb113a..57290528f2 100644 --- a/plugins/plugin-testing-java/plugin-testing-classpath/src/main/java/org/eclipse/che/plugin/java/testing/ProjectClasspathProvider.java +++ b/plugins/plugin-testing-java/plugin-testing-classpath/src/main/java/org/eclipse/che/plugin/java/testing/ProjectClasspathProvider.java @@ -10,12 +10,12 @@ */ package org.eclipse.che.plugin.java.testing; -import com.google.inject.name.Named; import java.util.Collections; import java.util.HashSet; import java.util.Set; import javax.inject.Inject; import javax.inject.Singleton; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.core.runtime.IPath; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; @@ -34,8 +34,8 @@ public class ProjectClasspathProvider { private final String workspacePath; @Inject - public ProjectClasspathProvider(@Named("che.user.workspaces.storage") String workspacePath) { - this.workspacePath = workspacePath; + public ProjectClasspathProvider(RootDirPathProvider pathProvider) { + this.workspacePath = pathProvider.get(); } /** diff --git a/plugins/plugin-testing-java/plugin-testing-classpath/src/test/java/org/eclipse/che/plugin/java/testing/ProjectClasspathProviderTest.java b/plugins/plugin-testing-java/plugin-testing-classpath/src/test/java/org/eclipse/che/plugin/java/testing/ProjectClasspathProviderTest.java index 45e66354b2..4af6e5dacf 100644 --- a/plugins/plugin-testing-java/plugin-testing-classpath/src/test/java/org/eclipse/che/plugin/java/testing/ProjectClasspathProviderTest.java +++ b/plugins/plugin-testing-java/plugin-testing-classpath/src/test/java/org/eclipse/che/plugin/java/testing/ProjectClasspathProviderTest.java @@ -14,8 +14,10 @@ import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import java.io.File; import java.lang.reflect.Field; import java.util.Set; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -37,7 +39,11 @@ public class ProjectClasspathProviderTest { private static ResourcesPlugin RESOURCE_PLUGIN = new ResourcesPlugin( - "target/test-classes/index", PROJECTS_PATH, () -> null, () -> null, () -> null); + "target/test-classes/index", + new DummyProvider(new File(PROJECTS_PATH)), + () -> null, + () -> null, + () -> null); @Mock private IJavaProject javaProject; @@ -45,7 +51,7 @@ public class ProjectClasspathProviderTest { @BeforeMethod public void setUp() throws Exception { - classpathProvider = new ProjectClasspathProvider(PROJECTS_PATH); + classpathProvider = new ProjectClasspathProvider(new DummyProvider(new File(PROJECTS_PATH))); } @Test @@ -134,4 +140,10 @@ public class ProjectClasspathProviderTest { } return result; } + + private static class DummyProvider extends RootDirPathProvider { + public DummyProvider(File file) { + this.rootFile = file; + } + } } diff --git a/plugins/plugin-testing-java/plugin-testing-junit/che-plugin-testing-junit-server/pom.xml b/plugins/plugin-testing-java/plugin-testing-junit/che-plugin-testing-junit-server/pom.xml index 82001c47bb..374ce7f3f6 100644 --- a/plugins/plugin-testing-java/plugin-testing-junit/che-plugin-testing-junit-server/pom.xml +++ b/plugins/plugin-testing-java/plugin-testing-junit/che-plugin-testing-junit-server/pom.xml @@ -33,6 +33,10 @@ javax.inject javax.inject + + org.eclipse.che.core + che-core-api-project + org.eclipse.che.core che-core-api-testing diff --git a/plugins/plugin-testing-java/plugin-testing-junit/che-plugin-testing-junit-server/src/main/java/org/eclipse/che/plugin/testing/junit/server/junit4/JUnit4TestRunner.java b/plugins/plugin-testing-java/plugin-testing-junit/che-plugin-testing-junit-server/src/main/java/org/eclipse/che/plugin/testing/junit/server/junit4/JUnit4TestRunner.java index 1df9c25036..bef292543b 100644 --- a/plugins/plugin-testing-java/plugin-testing-junit/che-plugin-testing-junit-server/src/main/java/org/eclipse/che/plugin/testing/junit/server/junit4/JUnit4TestRunner.java +++ b/plugins/plugin-testing-java/plugin-testing-junit/che-plugin-testing-junit-server/src/main/java/org/eclipse/che/plugin/testing/junit/server/junit4/JUnit4TestRunner.java @@ -10,11 +10,11 @@ */ package org.eclipse.che.plugin.testing.junit.server.junit4; -import com.google.inject.name.Named; import java.util.ArrayList; import java.util.List; import java.util.Set; import javax.inject.Inject; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.api.testing.shared.TestExecutionContext; import org.eclipse.che.commons.lang.execution.CommandLine; import org.eclipse.che.commons.lang.execution.ExecutionException; @@ -47,11 +47,11 @@ public class JUnit4TestRunner extends AbstractJavaTestRunner { @Inject public JUnit4TestRunner( - @Named("che.user.workspaces.storage") String workspacePath, + RootDirPathProvider pathProvider, JavaTestFinder javaTestFinder, ProjectClasspathProvider classpathProvider) { - super(workspacePath, javaTestFinder); - this.workspacePath = workspacePath; + super(pathProvider.get(), javaTestFinder); + this.workspacePath = pathProvider.get(); this.javaTestFinder = javaTestFinder; this.classpathProvider = classpathProvider; } diff --git a/plugins/plugin-testing-java/plugin-testing-testng/che-plugin-testing-testng-server/pom.xml b/plugins/plugin-testing-java/plugin-testing-testng/che-plugin-testing-testng-server/pom.xml index fa6d0f2ca3..7dfb5f07e1 100644 --- a/plugins/plugin-testing-java/plugin-testing-testng/che-plugin-testing-testng-server/pom.xml +++ b/plugins/plugin-testing-java/plugin-testing-testng/che-plugin-testing-testng-server/pom.xml @@ -45,6 +45,10 @@ org.eclipse.birt.runtime org.eclipse.equinox.common + + org.eclipse.che.core + che-core-api-project + org.eclipse.che.core che-core-api-testing diff --git a/plugins/plugin-testing-java/plugin-testing-testng/che-plugin-testing-testng-server/src/main/java/org/eclipse/che/plugin/testing/testng/server/TestNGRunner.java b/plugins/plugin-testing-java/plugin-testing-testng/che-plugin-testing-testng-server/src/main/java/org/eclipse/che/plugin/testing/testng/server/TestNGRunner.java index 4539e757a5..6953839cb5 100644 --- a/plugins/plugin-testing-java/plugin-testing-testng/che-plugin-testing-testng-server/src/main/java/org/eclipse/che/plugin/testing/testng/server/TestNGRunner.java +++ b/plugins/plugin-testing-java/plugin-testing-testng/che-plugin-testing-testng-server/src/main/java/org/eclipse/che/plugin/testing/testng/server/TestNGRunner.java @@ -15,7 +15,6 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.singletonList; import com.beust.jcommander.JCommander; -import com.google.inject.name.Named; import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -28,6 +27,7 @@ import javax.inject.Inject; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.api.testing.shared.TestExecutionContext; import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.commons.lang.execution.CommandLine; @@ -61,12 +61,12 @@ public class TestNGRunner extends AbstractJavaTestRunner { @Inject public TestNGRunner( - @Named("che.user.workspaces.storage") String workspacePath, + RootDirPathProvider pathProvider, JavaTestFinder javaTestFinder, ProjectClasspathProvider classpathProvider, TestNGSuiteUtil suiteUtil) { - super(workspacePath, javaTestFinder); - this.workspacePath = workspacePath; + super(pathProvider.get(), javaTestFinder); + this.workspacePath = pathProvider.get(); this.javaTestFinder = javaTestFinder; this.classpathProvider = classpathProvider; this.suiteUtil = suiteUtil; diff --git a/plugins/plugin-testing-php/plugin-testing-phpunit/che-plugin-testing-phpunit-server/pom.xml b/plugins/plugin-testing-php/plugin-testing-phpunit/che-plugin-testing-phpunit-server/pom.xml index 9eb7c655c1..c1b13653e5 100644 --- a/plugins/plugin-testing-php/plugin-testing-phpunit/che-plugin-testing-phpunit-server/pom.xml +++ b/plugins/plugin-testing-php/plugin-testing-phpunit/che-plugin-testing-phpunit-server/pom.xml @@ -49,6 +49,10 @@ org.eclipse.che.core che-core-api-dto + + org.eclipse.che.core + che-core-api-project + org.eclipse.che.core che-core-api-testing diff --git a/plugins/plugin-testing-php/plugin-testing-phpunit/che-plugin-testing-phpunit-server/src/main/java/org/eclipse/che/plugin/testing/phpunit/server/PHPUnitTestRunner.java b/plugins/plugin-testing-php/plugin-testing-phpunit/che-plugin-testing-phpunit-server/src/main/java/org/eclipse/che/plugin/testing/phpunit/server/PHPUnitTestRunner.java index 77b6a6b74f..cd312fc0b9 100644 --- a/plugins/plugin-testing-php/plugin-testing-phpunit/che-plugin-testing-phpunit-server/src/main/java/org/eclipse/che/plugin/testing/phpunit/server/PHPUnitTestRunner.java +++ b/plugins/plugin-testing-php/plugin-testing-phpunit/che-plugin-testing-phpunit-server/src/main/java/org/eclipse/che/plugin/testing/phpunit/server/PHPUnitTestRunner.java @@ -13,7 +13,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; -import javax.inject.Named; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.api.testing.server.framework.TestRunner; import org.eclipse.che.api.testing.shared.TestDetectionContext; import org.eclipse.che.api.testing.shared.TestExecutionContext; @@ -40,8 +40,8 @@ public class PHPUnitTestRunner implements TestRunner { private final PHPUnitTestEngine testEngine; @Inject - public PHPUnitTestRunner(@Named("che.user.workspaces.storage") File projectsRoot) { - testEngine = new PHPUnitTestEngine(projectsRoot); + public PHPUnitTestRunner(RootDirPathProvider pathProvider) { + testEngine = new PHPUnitTestEngine(new File(pathProvider.get())); } /** {@inheritDoc} */ diff --git a/plugins/plugin-zend-debugger/che-plugin-zend-debugger-server/pom.xml b/plugins/plugin-zend-debugger/che-plugin-zend-debugger-server/pom.xml index 7d5e3834f6..e7e9c76807 100644 --- a/plugins/plugin-zend-debugger/che-plugin-zend-debugger-server/pom.xml +++ b/plugins/plugin-zend-debugger/che-plugin-zend-debugger-server/pom.xml @@ -46,6 +46,10 @@ org.eclipse.che.core che-core-api-project + + org.eclipse.che.core + che-core-api-project-shared + org.eclipse.che.core che-core-commons-inject diff --git a/selenium/che-selenium-core/src/main/java/org/eclipse/che/selenium/core/workspace/TestWorkspaceImpl.java b/selenium/che-selenium-core/src/main/java/org/eclipse/che/selenium/core/workspace/TestWorkspaceImpl.java index d021beb5d8..7f12d21784 100644 --- a/selenium/che-selenium-core/src/main/java/org/eclipse/che/selenium/core/workspace/TestWorkspaceImpl.java +++ b/selenium/che-selenium-core/src/main/java/org/eclipse/che/selenium/core/workspace/TestWorkspaceImpl.java @@ -23,7 +23,6 @@ import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient; import org.eclipse.che.selenium.core.user.DefaultTestUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.Assert; /** @author Anatolii Bazko */ public class TestWorkspaceImpl implements TestWorkspace { @@ -73,11 +72,7 @@ public class TestWorkspaceImpl implements TestWorkspace { LOG.error("Failed to remove workspace name='{}' when start is failed.", name); } - if (e instanceof IllegalStateException) { - Assert.fail("Known issue https://github.com/eclipse/che/issues/9556", e); - } else { - throw new IllegalStateException(errorMessage, e); - } + throw new IllegalStateException(errorMessage, e); } }); } diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/NewWorkspace.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/NewWorkspace.java index 7235422c52..198e799a84 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/NewWorkspace.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/NewWorkspace.java @@ -293,6 +293,7 @@ public class NewWorkspace { } public void clickOnCreateButtonAndEditWorkspace() { + waitCreateWorkspaceButtonEnabled(); seleniumWebDriverHelper.waitAndClick(bottomCreateWorkspaceButton); waitWorkspaceCreatedDialogIsVisible(); clickOnEditWorkspaceButton(); diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/organization/OrganizationPage.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/organization/OrganizationPage.java index ab4ccd05e9..7d7834ae09 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/organization/OrganizationPage.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/organization/OrganizationPage.java @@ -19,6 +19,7 @@ import com.google.inject.Singleton; import java.util.List; import org.eclipse.che.selenium.core.SeleniumWebDriver; import org.eclipse.che.selenium.core.utils.WaitUtils; +import org.eclipse.che.selenium.core.webdriver.SeleniumWebDriverHelper; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; @@ -31,11 +32,13 @@ import org.openqa.selenium.support.ui.WebDriverWait; @Singleton public class OrganizationPage { + private final WebDriverWait redrawUiElementsTimeout; + private final SeleniumWebDriver seleniumWebDriver; + private final SeleniumWebDriverHelper seleniumWebDriverHelper; + private interface Locators { String ORGANIZATION_TITLE_ID = "__organizationDetailsController_organizationName__"; - String ORGANIZATION_TITLE_XPATH = - "//div[contains(@class, 'che-toolbar-title')]//span[text() = '%s']"; String ORGANIZATION_NAME = "//input[@name = 'name']"; String BACK_ICON = "//a[contains(@class, 'che-toolbar-breadcrumb')]/md-icon"; String SAVE_BUTTON = "//div[contains(@class, 'save-button-placeholder')]//button"; @@ -44,11 +47,9 @@ public class OrganizationPage { String RUNNING_WORKSPACE_CAP = "//input[@name = 'runtimeCap']"; String WORKSPACE_RAM_CAP = "//input[@name = 'workspaceRamCap']"; String DELETE_ORG_BUTTON = "//button[contains(@class, 'che-button')]//span[text() = 'Delete']"; - // todo: //span[text()='Delete'] to get Delete button only String DELETE_ORG_WIDGET_BUTTON = "//div[contains(@class,'che-confirm-dialog-notification')]//span"; String SUB_ORGANIZATIONS_TAB = "//md-tab-item//span[contains(text(), 'Sub-Organizations')]"; - String ADD_SUB_ORGANIZATION_BUTTON = "//che-button-primary[@che-button-title = 'Add Sub-Organization']/a"; String MEMBERS_TAB = "//md-tab-item//span[contains(text(), 'Members')]"; @@ -59,17 +60,13 @@ public class OrganizationPage { "//md-content[contains(@class, 'organization-member-list')]//div[contains(@class, 'che-list-header-column')]//span"; String MEMBERS_LIST_ITEM_XPATH = "//md-content[contains(@class, 'organization-member-list')]//span[text() = '%s']"; - // String MEMBER_CHECKBOX = - // "//div[contains(@class,'che-list-item-checkbox-main')]/md-checkbox[contains(@aria-label,'member')]"; String MEMBER_CHECKBOX = "//md-checkbox[contains(@aria-label,'member')]"; - // todo: //span[text()='Delete'] to get Delete button only String DELETE_MEMBER_WIDGET_BUTTON = "//che-popup//button"; String MEMBERS_SEARCH_FIELD = "//div[@class = 'che-list-search']//input"; + String WORKSPACES_TAB_XPATH = "//md-tab-item//span[contains(text(), 'Workspaces')]"; + String ADD_WORKSPACE_BTN_XPATH = "//*[@che-button-title='Add Workspace']"; } - private final WebDriverWait redrawUiElementsTimeout; - private final SeleniumWebDriver seleniumWebDriver; - @FindBy(id = Locators.ORGANIZATION_TITLE_ID) WebElement organizationTitle; @@ -124,11 +121,16 @@ public class OrganizationPage { @FindBy(xpath = Locators.MEMBERS_SEARCH_FIELD) WebElement membersSearchField; + @FindBy(xpath = Locators.WORKSPACES_TAB_XPATH) + WebElement workspacesTab; + @Inject - public OrganizationPage(SeleniumWebDriver seleniumWebDriver) { + public OrganizationPage( + SeleniumWebDriver seleniumWebDriver, SeleniumWebDriverHelper seleniumWebDriverHelper) { this.seleniumWebDriver = seleniumWebDriver; this.redrawUiElementsTimeout = new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC); + this.seleniumWebDriverHelper = seleniumWebDriverHelper; PageFactory.initElements(seleniumWebDriver, this); } @@ -150,6 +152,10 @@ public class OrganizationPage { redrawUiElementsTimeout.until(ExpectedConditions.visibilityOf(membersTab)).click(); } + public void clickOnWorkspacesTab() { + seleniumWebDriverHelper.waitAndClick(workspacesTab); + } + public void waitMembersList() { redrawUiElementsTimeout.until(visibilityOf(membersList)); } @@ -346,4 +352,8 @@ public class OrganizationPage { String readonly = element.getAttribute("readonly"); return readonly == null ? false : readonly.equalsIgnoreCase("true"); } + + public void clickOnAddWorkspaceBtn() { + seleniumWebDriverHelper.waitAndClick(By.xpath(Locators.ADD_WORKSPACE_BTN_XPATH)); + } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/CreateWorkspaceTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/CreateWorkspaceTest.java index b3d7368b28..6f1f43877d 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/CreateWorkspaceTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/CreateWorkspaceTest.java @@ -71,21 +71,21 @@ public class CreateWorkspaceTest { newWorkspace.typeWorkspaceName(TOO_SHORT_WORKSPACE_NAME); newWorkspace.waitErrorMessage(WS_NAME_TOO_SHORT); - assertFalse(newWorkspace.isCreateWorkspaceButtonEnabled()); + newWorkspace.waitCreateWorkspaceButtonDisabled(); newWorkspace.typeWorkspaceName(TOO_LONG_WORKSPACE_NAME); newWorkspace.waitErrorMessage(WS_NAME_TOO_LONG); - assertFalse(newWorkspace.isCreateWorkspaceButtonEnabled()); + newWorkspace.waitCreateWorkspaceButtonDisabled(); // type valid names and check that the Create button is enabled newWorkspace.typeWorkspaceName(MIN_VALID_WORKSPACE_NAME); - - assertTrue(newWorkspace.isCreateWorkspaceButtonEnabled()); + newWorkspace.waitCreateWorkspaceButtonEnabled(); newWorkspace.typeWorkspaceName(WORKSPACE_NAME); - assertTrue(newWorkspace.isCreateWorkspaceButtonEnabled()); + newWorkspace.waitCreateWorkspaceButtonEnabled(); + newWorkspace.typeWorkspaceName(MAX_VALID_WORKSPACE_NAME); - assertTrue(newWorkspace.isCreateWorkspaceButtonEnabled()); + newWorkspace.waitCreateWorkspaceButtonEnabled(); } @Test diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/AddWorkspaceToOrganizationTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/AddWorkspaceToOrganizationTest.java index a8ad9273d3..9d7b22d915 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/AddWorkspaceToOrganizationTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/AddWorkspaceToOrganizationTest.java @@ -15,6 +15,7 @@ import static org.eclipse.che.selenium.core.constant.TestStacksConstants.JAVA; import static org.eclipse.che.selenium.pageobject.dashboard.NavigationBar.MenuItem.ORGANIZATIONS; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import com.google.inject.Inject; import org.eclipse.che.selenium.core.TestGroup; @@ -28,6 +29,7 @@ import org.eclipse.che.selenium.pageobject.dashboard.organization.OrganizationLi import org.eclipse.che.selenium.pageobject.dashboard.organization.OrganizationPage; import org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails; import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces; +import org.openqa.selenium.WebDriverException; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -63,7 +65,6 @@ public class AddWorkspaceToOrganizationTest { @Inject private NavigationBar navigationBar; @Inject private NewWorkspace newWorkspace; @Inject private Workspaces workspaces; - @Inject private TestUser adminTestUser; @Inject private TestUser testUser; @@ -122,7 +123,6 @@ public class AddWorkspaceToOrganizationTest { navigationBar.clickOnMenu(ORGANIZATIONS); organizationListPage.waitForOrganizationsToolbar(); organizationListPage.waitForOrganizationsList(); - organizationListPage.waitOrganizationInList(org2.getName()); // create a workspace for org2 and its suborganization @@ -143,13 +143,31 @@ public class AddWorkspaceToOrganizationTest { // check that the Namespace link in workspace details correct checkNamespaceLink(org2.getName(), WORKSPACE_FOR_MEMBER_1); checkNamespaceLink(suborgForMemberName, WORKSPACE_FOR_MEMBER_2); + + // check that created workspace exists in organization Workspaces tab + navigationBar.clickOnMenu(ORGANIZATIONS); + organizationListPage.waitOrganizationInList(org2.getName()); + organizationListPage.clickOnOrganization(org2.getName()); + organizationPage.clickOnWorkspacesTab(); + workspaces.waitWorkspaceIsPresent(WORKSPACE_FOR_MEMBER_1); + workspaces.selectWorkspaceItemName(WORKSPACE_FOR_MEMBER_1); + + try { + workspaceDetails.waitToolbarTitleName(WORKSPACE_FOR_MEMBER_1); + } catch (WebDriverException ex) { + // remove try-catch block after issue has been resolved + fail("Known issue https://github.com/eclipse/che/issues/9148", ex); + } } private void createWorkspace(String organizationName, String workspaceName) { - dashboard.selectWorkspacesItemOnDashboard(); - dashboard.waitToolbarTitleName("Workspaces"); + navigationBar.clickOnMenu(ORGANIZATIONS); + organizationListPage.waitForOrganizationsToolbar(); + organizationListPage.waitOrganizationInList(organizationName); + organizationListPage.clickOnOrganization(organizationName); + organizationPage.clickOnWorkspacesTab(); + organizationPage.clickOnAddWorkspaceBtn(); - workspaces.clickOnAddWorkspaceBtn(); newWorkspace.waitToolbar(); newWorkspace.openOrganizationsList(); newWorkspace.selectOrganizationFromList(organizationName); diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/ShareWorkspaceTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/ShareWorkspaceTest.java index 41ab728f71..c96f5dc11a 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/ShareWorkspaceTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/dashboard/organization/ShareWorkspaceTest.java @@ -50,9 +50,7 @@ public class ShareWorkspaceTest { @Inject private CheMultiuserAdminDashboard dashboard; @Inject private WorkspaceDetails workspaceDetails; @Inject private NavigationBar navigationBar; - @Inject private AdminTestUser adminTestUser; - @Inject private NewWorkspace newWorkspace; @Inject private Workspaces workspaces; @Inject private TestUser testUser; diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/PullRequestPluginTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/PullRequestPluginTest.java index af8e04a4ce..b031745e3d 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/PullRequestPluginTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/PullRequestPluginTest.java @@ -21,7 +21,6 @@ import static org.eclipse.che.selenium.pageobject.PullRequestPanel.Status.NEW_CO import static org.eclipse.che.selenium.pageobject.PullRequestPanel.Status.PULL_REQUEST_ISSUED; import static org.eclipse.che.selenium.pageobject.PullRequestPanel.Status.PULL_REQUEST_UPDATED; import static org.eclipse.che.selenium.pageobject.Wizard.TypeProject.BLANK; -import static org.testng.Assert.fail; import com.google.inject.Inject; import com.google.inject.name.Named; @@ -48,7 +47,6 @@ import org.eclipse.che.selenium.pageobject.ProjectExplorer; import org.eclipse.che.selenium.pageobject.PullRequestPanel; import org.eclipse.che.selenium.pageobject.Wizard; import org.openqa.selenium.By; -import org.openqa.selenium.WebDriverException; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -144,13 +142,7 @@ public class PullRequestPluginTest { loader.waitOnClosed(); // switch between projects - try { - pullRequestPanel.clickPullRequestBtn(); - } catch (WebDriverException ex) { - // remove try-catch block after issue has been resolved - fail("Known issue https://github.com/eclipse/che/issues/9484", ex); - } - + pullRequestPanel.clickPullRequestBtn(); pullRequestPanel.waitRepoUrl(firstProjectUrl); pullRequestPanel.waitBranchName(MAIN_BRANCH); pullRequestPanel.waitProjectName(FIRST_PROJECT_NAME); diff --git a/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitProjectTypeCleaner.java b/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitProjectTypeCleaner.java index b5c8437306..6f5a7e37f6 100644 --- a/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitProjectTypeCleaner.java +++ b/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitProjectTypeCleaner.java @@ -25,12 +25,12 @@ import org.eclipse.che.api.core.ConflictException; import org.eclipse.che.api.core.ForbiddenException; import org.eclipse.che.api.core.NotFoundException; import org.eclipse.che.api.core.ServerException; +import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.core.notification.EventSubscriber; import org.eclipse.che.api.git.shared.event.GitRepositoryDeletedEvent; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.impl.NewProjectConfigImpl; -import org.eclipse.che.api.project.server.impl.RegisteredProject; import org.slf4j.Logger; /** @@ -68,7 +68,7 @@ public class GitProjectTypeCleaner implements EventSubscriber> attributes = project.getAttributes(); attributes.remove(GitProjectType.GIT_CURRENT_HEAD_NAME); attributes.remove(GitProjectType.GIT_REPOSITORY_REMOTES); 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 eff87b5943..e749ea3eae 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 @@ -35,6 +35,7 @@ import javax.ws.rs.core.UriInfo; import org.eclipse.che.api.core.ApiException; import org.eclipse.che.api.core.BadRequestException; import org.eclipse.che.api.core.NotFoundException; +import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.core.rest.annotations.Required; import org.eclipse.che.api.fs.server.FsManager; @@ -90,7 +91,6 @@ import org.eclipse.che.api.git.shared.Tag; import org.eclipse.che.api.git.shared.TagCreateRequest; import org.eclipse.che.api.git.shared.event.GitRepositoryDeletedEvent; import org.eclipse.che.api.project.server.ProjectManager; -import org.eclipse.che.api.project.server.impl.RegisteredProject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -310,7 +310,7 @@ public class GitService { @DELETE @Path("repository") public void deleteRepository(@Context UriInfo uriInfo) throws ApiException { - RegisteredProject project = + ProjectConfig project = projectManager .get(projectPath) .orElseThrow(() -> new NotFoundException("Can't find project")); diff --git a/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitStatusChangedDetector.java b/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitStatusChangedDetector.java index e04d2d6aab..9d08e28004 100644 --- a/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitStatusChangedDetector.java +++ b/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitStatusChangedDetector.java @@ -29,6 +29,7 @@ import org.eclipse.che.api.core.NotFoundException; import org.eclipse.che.api.core.ServerException; import org.eclipse.che.api.core.jsonrpc.commons.RequestHandlerConfigurator; import org.eclipse.che.api.core.jsonrpc.commons.RequestTransmitter; +import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.core.notification.EventSubscriber; import org.eclipse.che.api.fs.server.PathTransformer; @@ -39,7 +40,6 @@ import org.eclipse.che.api.git.shared.EditedRegion; import org.eclipse.che.api.git.shared.Status; import org.eclipse.che.api.git.shared.StatusChangedEventDto; import org.eclipse.che.api.project.server.ProjectManager; -import org.eclipse.che.api.project.server.impl.RegisteredProject; import org.eclipse.che.api.watcher.server.FileWatcherManager; import org.slf4j.Logger; @@ -149,7 +149,7 @@ public class GitStatusChangedDetector implements EventSubscriber transmitConsumer(String wsPath) { return id -> { try { - RegisteredProject project = + ProjectConfig project = projectManager .getClosest(wsPath) .orElseThrow(() -> new NotFoundException("Can't find a project")); diff --git a/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitStatusProvider.java b/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitStatusProvider.java index 851646be3d..8b16264f56 100644 --- a/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitStatusProvider.java +++ b/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitStatusProvider.java @@ -25,12 +25,12 @@ import java.util.Map; import javax.inject.Inject; import org.eclipse.che.api.core.NotFoundException; import org.eclipse.che.api.core.ServerException; +import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.fs.server.PathTransformer; import org.eclipse.che.api.git.exception.GitException; import org.eclipse.che.api.git.shared.Status; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.VcsStatusProvider; -import org.eclipse.che.api.project.server.impl.RegisteredProject; /** * Git implementation of {@link VcsStatusProvider}. @@ -61,7 +61,7 @@ public class GitStatusProvider implements VcsStatusProvider { @Override public VcsStatus getStatus(String wsPath) throws ServerException { try { - RegisteredProject project = + ProjectConfig project = projectManager .getClosest(wsPath) .orElseThrow(() -> new NotFoundException("Can't find project")); @@ -90,7 +90,7 @@ public class GitStatusProvider implements VcsStatusProvider { throws ServerException { Map statusMap = new HashMap<>(); try { - RegisteredProject project = + ProjectConfig project = projectManager .getClosest(absolutize(wsPath)) .orElseThrow(() -> new NotFoundException("Can't find project")); diff --git a/wsagent/che-core-api-git/src/test/java/org/eclipse/che/api/git/GitStatusProviderTest.java b/wsagent/che-core-api-git/src/test/java/org/eclipse/che/api/git/GitStatusProviderTest.java index 49a64c2a27..31dd136f65 100644 --- a/wsagent/che-core-api-git/src/test/java/org/eclipse/che/api/git/GitStatusProviderTest.java +++ b/wsagent/che-core-api-git/src/test/java/org/eclipse/che/api/git/GitStatusProviderTest.java @@ -28,7 +28,7 @@ import org.eclipse.che.api.fs.server.PathTransformer; import org.eclipse.che.api.git.shared.Status; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.VcsStatusProvider.VcsStatus; -import org.eclipse.che.api.project.server.impl.RegisteredProject; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.testng.MockitoTestNGListener; diff --git a/wsagent/che-core-api-project-shared/src/main/java/org/eclipse/che/api/project/shared/RegisteredProject.java b/wsagent/che-core-api-project-shared/src/main/java/org/eclipse/che/api/project/shared/RegisteredProject.java new file mode 100644 index 0000000000..6f37901553 --- /dev/null +++ b/wsagent/che-core-api-project-shared/src/main/java/org/eclipse/che/api/project/shared/RegisteredProject.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * 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: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api.project.shared; + +import java.util.List; +import java.util.Map; +import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; + +/** + * Describes current state of project + * + * @author gazarenkov + */ +public interface RegisteredProject extends ProjectConfig { + + /** + * @return whether this project is synchronized with Workspace storage On the other words this + * project is not updated + */ + boolean isSynced(); + + /** + * @return whether this project is detected using Project Type resolver If so it should not be + * persisted to Workspace storage + */ + boolean isDetected(); + + /** @return root folder or null */ + String getBaseFolder(); + + /** + * @return name-value map of persistable (as opposed to provided) attributes configured for the + * project + */ + Map> getPersistableAttributes(); + + /** + * Sets 'synchronized with Workspace storage' flag + * + * @param synced true if synced + */ + void setSynced(boolean synced); +} diff --git a/wsagent/che-core-api-project-shared/src/main/java/org/eclipse/che/api/project/shared/dto/ItemReference.java b/wsagent/che-core-api-project-shared/src/main/java/org/eclipse/che/api/project/shared/dto/ItemReference.java index 6d6a0b9377..9a5448bd82 100644 --- a/wsagent/che-core-api-project-shared/src/main/java/org/eclipse/che/api/project/shared/dto/ItemReference.java +++ b/wsagent/che-core-api-project-shared/src/main/java/org/eclipse/che/api/project/shared/dto/ItemReference.java @@ -50,6 +50,7 @@ public interface ItemReference extends Hyperlinks { ItemReference withPath(String path); + @Override ItemReference withLinks(List links); /** Attributes */ diff --git a/wsagent/che-core-api-project-shared/src/main/java/org/eclipse/che/api/project/shared/dto/RegisteredProjectDto.java b/wsagent/che-core-api-project-shared/src/main/java/org/eclipse/che/api/project/shared/dto/RegisteredProjectDto.java new file mode 100644 index 0000000000..91f41e0618 --- /dev/null +++ b/wsagent/che-core-api-project-shared/src/main/java/org/eclipse/che/api/project/shared/dto/RegisteredProjectDto.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * 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: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api.project.shared.dto; + +import java.util.List; +import java.util.Map; +import org.eclipse.che.api.project.shared.RegisteredProject; +import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; +import org.eclipse.che.api.workspace.shared.dto.ProjectProblemDto; +import org.eclipse.che.api.workspace.shared.dto.SourceStorageDto; +import org.eclipse.che.dto.shared.DTO; + +/** + * Project data transfer object + * + * @author gazarenkov + */ +@DTO +public interface RegisteredProjectDto extends RegisteredProject, ProjectConfigDto { + + boolean isSynced(); + + boolean isDetected(); + + String getBaseFolder(); + + List getProblems(); + + SourceStorageDto getSource(); + + RegisteredProjectDto withName(String name); + + RegisteredProjectDto withPath(String path); + + RegisteredProjectDto withDescription(String description); + + RegisteredProjectDto withType(String type); + + RegisteredProjectDto withMixins(List mixins); + + RegisteredProjectDto withAttributes(Map> attributes); + + RegisteredProjectDto withSource(SourceStorageDto source); + + RegisteredProjectDto withProblems(List problems); + + RegisteredProjectDto withSynced(boolean synced); + + RegisteredProjectDto withDetected(boolean detected); + + RegisteredProjectDto withBaseFolder(String baseFolder); + + RegisteredProjectDto withPersistableAttributes(Map> attributes); +} diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/fs/server/impl/RootAwarePathTransformer.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/fs/server/impl/RootAwarePathTransformer.java index 3c61d4ac9e..20bf3b7a6a 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/fs/server/impl/RootAwarePathTransformer.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/fs/server/impl/RootAwarePathTransformer.java @@ -12,12 +12,12 @@ package org.eclipse.che.api.fs.server.impl; import static org.eclipse.che.api.fs.server.WsPathUtils.ROOT; -import java.io.File; import java.nio.file.Path; +import java.nio.file.Paths; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Singleton; import org.eclipse.che.api.fs.server.PathTransformer; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; @Singleton public class RootAwarePathTransformer implements PathTransformer { @@ -25,8 +25,8 @@ public class RootAwarePathTransformer implements PathTransformer { private final Path root; @Inject - public RootAwarePathTransformer(@Named("che.user.workspaces.storage") File root) { - this.root = root.toPath().normalize().toAbsolutePath(); + public RootAwarePathTransformer(RootDirPathProvider rootProvider) { + this.root = Paths.get(rootProvider.get()); } @Override diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/fs/server/impl/SimpleFsDtoConverter.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/fs/server/impl/SimpleFsDtoConverter.java index 330d920613..3d916a2026 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/fs/server/impl/SimpleFsDtoConverter.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/fs/server/impl/SimpleFsDtoConverter.java @@ -20,11 +20,11 @@ import java.util.Set; import javax.inject.Inject; import javax.inject.Singleton; import org.eclipse.che.api.core.NotFoundException; +import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.fs.server.FsDtoConverter; import org.eclipse.che.api.fs.server.FsManager; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.impl.ProjectDtoConverter; -import org.eclipse.che.api.project.server.impl.RegisteredProject; import org.eclipse.che.api.project.shared.dto.ItemReference; @Singleton @@ -54,7 +54,7 @@ public class SimpleFsDtoConverter implements FsDtoConverter { length = null; } - RegisteredProject project = projectManager.getClosest(wsPath).orElse(null); + ProjectConfig project = projectManager.getClosest(wsPath).orElse(null); String type; if (projectManager.isRegistered(wsPath)) { diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectApiModule.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectApiModule.java index f1db0c1118..931f6327b3 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectApiModule.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectApiModule.java @@ -18,6 +18,7 @@ import com.google.inject.multibindings.Multibinder; import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.project.server.handlers.ProjectHandler; import org.eclipse.che.api.project.server.impl.CreateBaseProjectTypeHandler; +import org.eclipse.che.api.project.server.impl.InmemoryProjectRegistry; import org.eclipse.che.api.project.server.impl.OnWorkspaceStartProjectInitializer; import org.eclipse.che.api.project.server.impl.ProjectConfigRegistry; import org.eclipse.che.api.project.server.impl.ProjectHandlerRegistry; @@ -25,8 +26,8 @@ import org.eclipse.che.api.project.server.impl.ProjectImporterRegistry; import org.eclipse.che.api.project.server.impl.ProjectServiceApi; import org.eclipse.che.api.project.server.impl.ProjectServiceApiFactory; import org.eclipse.che.api.project.server.impl.ProjectSynchronizer; -import org.eclipse.che.api.project.server.impl.RegisteredProject; import org.eclipse.che.api.project.server.impl.RegisteredProjectFactory; +import org.eclipse.che.api.project.server.impl.RegisteredProjectImpl; import org.eclipse.che.api.project.server.impl.RootDirCreationHandler; import org.eclipse.che.api.project.server.impl.RootDirRemovalHandler; import org.eclipse.che.api.project.server.impl.ValidatingProjectManager; @@ -58,7 +59,6 @@ public class ProjectApiModule extends AbstractModule { bind(ProjectTypeService.class); bind(OnWorkspaceStartProjectInitializer.class); - bind(ProjectConfigRegistry.class); bind(ProjectImporterRegistry.class); bind(ProjectHandlerRegistry.class); @@ -70,6 +70,8 @@ public class ProjectApiModule extends AbstractModule { bind(ProjectQualifier.class).to(SimpleProjectQualifier.class); bind(ProjectTypeResolver.class).to(SimpleProjectTypeResolver.class); + bind(ProjectConfigRegistry.class).to(InmemoryProjectRegistry.class); + newSetBinder(binder(), ProjectImporter.class).addBinding().to(ZipProjectImporter.class); newSetBinder(binder(), ProjectTypeDef.class).addBinding().to(BaseProjectType.class); @@ -80,7 +82,7 @@ public class ProjectApiModule extends AbstractModule { install( new FactoryModuleBuilder() - .implement(ProjectConfig.class, RegisteredProject.class) + .implement(ProjectConfig.class, RegisteredProjectImpl.class) .build(RegisteredProjectFactory.class)); install( diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectManager.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectManager.java index 4fb4344e45..27aac7f255 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectManager.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectManager.java @@ -23,9 +23,9 @@ import org.eclipse.che.api.core.ServerException; import org.eclipse.che.api.core.UnauthorizedException; import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.core.model.workspace.config.SourceStorage; -import org.eclipse.che.api.project.server.impl.RegisteredProject; import org.eclipse.che.api.project.server.type.ProjectTypeResolution; import org.eclipse.che.api.project.shared.NewProjectConfig; +import org.eclipse.che.api.project.shared.RegisteredProject; /** Facade for project related operations */ public interface ProjectManager { diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ExecutiveProjectManager.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ExecutiveProjectManager.java index 48b297be64..6050fc436d 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ExecutiveProjectManager.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ExecutiveProjectManager.java @@ -12,8 +12,6 @@ package org.eclipse.che.api.project.server.impl; import static java.io.File.separator; import static java.util.Collections.emptyMap; -import static java.util.Optional.empty; -import static org.eclipse.che.api.fs.server.WsPathUtils.isRoot; import static org.eclipse.che.api.fs.server.WsPathUtils.nameOf; import java.util.ArrayList; @@ -37,7 +35,6 @@ import org.eclipse.che.api.core.UnauthorizedException; import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.core.model.workspace.config.SourceStorage; import org.eclipse.che.api.fs.server.FsManager; -import org.eclipse.che.api.fs.server.WsPathUtils; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.handlers.CreateProjectHandler; import org.eclipse.che.api.project.server.handlers.ProjectInitHandler; @@ -46,6 +43,7 @@ import org.eclipse.che.api.project.server.type.BaseProjectType; import org.eclipse.che.api.project.server.type.ProjectQualifier; import org.eclipse.che.api.project.server.type.ProjectTypeResolution; import org.eclipse.che.api.project.shared.NewProjectConfig; +import org.eclipse.che.api.project.shared.RegisteredProject; /** * Performs project related operations after project registry is synchronized and method parameters @@ -90,16 +88,7 @@ public class ExecutiveProjectManager implements ProjectManager { @Override public Optional getClosest(String wsPath) { - while (!isRoot(wsPath)) { - Optional registeredProject = projectConfigRegistry.get(wsPath); - if (registeredProject.isPresent()) { - return registeredProject; - } else { - wsPath = WsPathUtils.parentOf(wsPath); - } - } - - return empty(); + return projectConfigRegistry.getClosest(wsPath); } @Override @@ -206,7 +195,7 @@ public class ExecutiveProjectManager implements ProjectManager { projectConfigRegistry .getAll(wsPath) .stream() - .map(RegisteredProject::getPath) + .map(ProjectConfig::getPath) .forEach(projectConfigRegistry::remove); return projectConfigRegistry.remove(wsPath); @@ -232,7 +221,7 @@ public class ExecutiveProjectManager implements ProjectManager { throws ServerException, NotFoundException, ConflictException, ForbiddenException { fsManager.copy(srcWsPath, dstWsPath); - RegisteredProject oldProjectConfig = + ProjectConfig oldProjectConfig = projectConfigRegistry.get(srcWsPath).orElseThrow(IllegalStateException::new); String newProjectName = dstWsPath.substring(dstWsPath.lastIndexOf(separator)); @@ -296,7 +285,9 @@ public class ExecutiveProjectManager implements ProjectManager { ForbiddenException { RegisteredProject project = - get(wsPath).orElseThrow(() -> new NotFoundException("Can't find project")); + projectConfigRegistry + .get(wsPath) + .orElseThrow(() -> new NotFoundException("Can't find project")); List mixins = project.getMixins(); diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/InmemoryProjectRegistry.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/InmemoryProjectRegistry.java new file mode 100644 index 0000000000..cd38c28514 --- /dev/null +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/InmemoryProjectRegistry.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * 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: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api.project.server.impl; + +import static java.util.Optional.empty; +import static java.util.stream.Collectors.toSet; +import static org.eclipse.che.api.fs.server.WsPathUtils.isRoot; + +import com.google.common.collect.ImmutableSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import javax.inject.Inject; +import javax.inject.Singleton; +import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; +import org.eclipse.che.api.fs.server.WsPathUtils; +import org.eclipse.che.api.project.shared.RegisteredProject; + +@Singleton +public class InmemoryProjectRegistry implements ProjectConfigRegistry { + + private final Map projects = new ConcurrentHashMap<>(); + + private final RegisteredProjectFactory registeredProjectFactory; + + @Inject + public InmemoryProjectRegistry(RegisteredProjectFactory registeredProjectFactory) { + this.registeredProjectFactory = registeredProjectFactory; + } + + @Override + public Set getAll() { + return ImmutableSet.copyOf(projects.values()); + } + + @Override + public Set getAll(String wsPath) { + Set children = + projects + .entrySet() + .stream() + .filter(it -> it.getKey().startsWith(wsPath)) + .filter(it -> !it.getKey().equals(wsPath)) + .map(Entry::getValue) + .collect(toSet()); + return ImmutableSet.copyOf(children); + } + + @Override + public Optional get(String wsPath) { + return Optional.ofNullable(projects.get(wsPath)); + } + + @Override + public RegisteredProject getOrNull(String wsPath) { + return projects.get(wsPath); + } + + @Override + public synchronized RegisteredProject put( + ProjectConfig config, boolean updated, boolean detected) { + String wsPath = config.getPath(); + RegisteredProject project = registeredProjectFactory.create(wsPath, config, updated, detected); + projects.put(wsPath, project); + return project; + } + + @Override + public synchronized RegisteredProject putIfAbsent( + String wsPath, boolean updated, boolean detected) { + RegisteredProject registeredProject = projects.get(wsPath); + if (registeredProject != null) { + return registeredProject; + } + + RegisteredProject project = registeredProjectFactory.create(wsPath, null, updated, detected); + projects.put(wsPath, project); + return project; + } + + @Override + public Optional remove(String wsPath) { + return Optional.ofNullable(projects.remove(wsPath)); + } + + @Override + public RegisteredProject removeOrNull(String wsPath) { + return projects.remove(wsPath); + } + + @Override + public boolean isRegistered(String path) { + return projects.containsKey(path); + } + + @Override + public Optional getClosest(String wsPath) { + while (!isRoot(wsPath)) { + + if (projects.containsKey(wsPath)) { + return Optional.of(projects.get(wsPath)); + } + wsPath = WsPathUtils.parentOf(wsPath); + } + + return empty(); + } +} diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/OnWorkspaceStartProjectInitializer.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/OnWorkspaceStartProjectInitializer.java index f4ae5060b4..40101dd79a 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/OnWorkspaceStartProjectInitializer.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/OnWorkspaceStartProjectInitializer.java @@ -26,6 +26,7 @@ import org.eclipse.che.api.core.ServerException; import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.fs.server.FsManager; import org.eclipse.che.api.project.server.handlers.ProjectInitHandler; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.eclipse.che.api.search.server.excludes.HiddenItemPathMatcher; @Singleton @@ -59,7 +60,8 @@ public class OnWorkspaceStartProjectInitializer { firePostInitializationHandlers(); } - private void initializeRegisteredProjects() throws ServerException { + private void initializeRegisteredProjects() + throws ServerException, NotFoundException, ConflictException { for (ProjectConfig projectConfig : projectSynchronizer.getAll()) { projectConfigRegistry.put(projectConfig, false, false); } @@ -77,6 +79,7 @@ public class OnWorkspaceStartProjectInitializer { throws ServerException, ConflictException, NotFoundException, ForbiddenException { for (RegisteredProject project : projectConfigRegistry.getAll()) { + if (project.getBaseFolder() == null) { continue; } diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/PersistingProjectRegistry.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/PersistingProjectRegistry.java new file mode 100644 index 0000000000..4e46ecb26b --- /dev/null +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/PersistingProjectRegistry.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * 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: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api.project.server.impl; + +import static java.util.Optional.empty; +import static java.util.stream.Collectors.toSet; +import static org.eclipse.che.api.fs.server.WsPathUtils.isRoot; + +import com.google.common.collect.ImmutableSet; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashSet; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import javax.inject.Inject; +import javax.inject.Singleton; +import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; +import org.eclipse.che.api.fs.server.FsManager; +import org.eclipse.che.api.fs.server.WsPathUtils; +import org.eclipse.che.api.project.shared.RegisteredProject; +import org.eclipse.che.api.project.shared.dto.RegisteredProjectDto; +import org.eclipse.che.dto.server.DtoFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Singleton +public class PersistingProjectRegistry implements ProjectConfigRegistry { + + private static final Logger LOG = LoggerFactory.getLogger(PersistingProjectRegistry.class); + + private final Map projects = new ConcurrentHashMap<>(); + + private final RegisteredProjectFactory registeredProjectFactory; + private final FsManager fsManager; + private final FileCache cache; + + @Inject + public PersistingProjectRegistry( + RegisteredProjectFactory registeredProjectFactory, FsManager fsManager) { + this.registeredProjectFactory = registeredProjectFactory; + this.fsManager = fsManager; + this.cache = new FileCache(); + } + + @Override + public Set getAll() { + + return ImmutableSet.copyOf(cache.getAll("")); + } + + @Override + public Set getAll(String wsPath) { + + return ImmutableSet.copyOf(cache.getAll(wsPath)); + } + + @Override + public Optional get(String wsPath) { + + return Optional.ofNullable(getOrNull(wsPath)); + } + + @Override + public RegisteredProject getOrNull(String wsPath) { + return projects.containsKey(wsPath) ? projects.get(wsPath) : cache.get(wsPath); + } + + @Override + public synchronized RegisteredProject put( + ProjectConfig config, boolean updated, boolean detected) { + String wsPath = config.getPath(); + RegisteredProject project = registeredProjectFactory.create(wsPath, config, updated, detected); + projects.put(wsPath, project); + + cache.put(project); + + return project; + } + + @Override + public synchronized RegisteredProject putIfAbsent( + String wsPath, boolean updated, boolean detected) { + RegisteredProject registeredProject = projects.get(wsPath); + if (registeredProject != null) { + return registeredProject; + } + + RegisteredProject project = registeredProjectFactory.create(wsPath, null, updated, detected); + projects.put(wsPath, project); + + cache.put(project); + + return project; + } + + @Override + public Optional remove(String wsPath) { + + cache.remove(wsPath); + return Optional.ofNullable(projects.remove(wsPath)); + } + + @Override + public RegisteredProject removeOrNull(String wsPath) { + + cache.remove(wsPath); + return projects.remove(wsPath); + } + + @Override + public boolean isRegistered(String path) { + return projects.containsKey(path) || cache.contains(path); + } + + @Override + public Optional getClosest(String wsPath) { + while (!isRoot(wsPath)) { + + if (projects.containsKey(wsPath)) { + // get from local map + return Optional.of(projects.get(wsPath)); + } else if (cache.contains(wsPath)) { + // get from fs cache + return Optional.of(cache.get(wsPath)); + } + wsPath = WsPathUtils.parentOf(wsPath); + } + + return empty(); + } + + private class FileCache { + + private static final String ROOT = "/.che/tmp/projectConfig"; + + public void put(RegisteredProject project) { + + String json = + DtoFactory.getInstance().toJson(ProjectDtoConverter.asRegisteredProjectDto(project)); + try { + + fsManager.createFile(filePath(project.getPath()), json, true, true); + + } catch (Exception e) { + LOG.error(e.getMessage()); + } + } + + public RegisteredProject get(String wsPath) { + try { + + String json = fsManager.readAsString(filePath(wsPath)); + return DtoFactory.getInstance().createDtoFromJson(json, RegisteredProjectDto.class); + + } catch (Exception e) { + LOG.error(e.getMessage()); + return null; + } + } + + public RegisteredProject remove(String wsPath) { + RegisteredProject p = null; + try { + + p = get(wsPath); + fsManager.delete(filePath(wsPath), true); + + } catch (Exception e) { + LOG.error(e.getMessage()); + } + return p; + } + + public Set getAll(String wsPath) { + + Set projects = new HashSet<>(); + String fsPath = fsManager.toIoFile(ROOT + wsPath).getPath(); + // Check if there are child projects (if so there is a folder) + // this check is needed since otherwise Files.walk throws excepton + if (Files.isDirectory(Paths.get(fsPath))) { + try { + Set paths = + Files.walk(Paths.get(fsPath)).filter(Files::isRegularFile).collect(toSet()); + + for (Path p : paths) { + String json = new String(Files.readAllBytes(p)); + + projects.add( + DtoFactory.getInstance().createDtoFromJson(json, RegisteredProjectDto.class)); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return projects; + } + + public boolean contains(String wsPath) { + return fsManager.exists(filePath(wsPath)); + } + + private String filePath(String wsPath) { + return ROOT + wsPath + ".json"; + } + } +} diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectConfigRegistry.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectConfigRegistry.java index 0fb69e7317..e992d50363 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectConfigRegistry.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectConfigRegistry.java @@ -10,103 +10,88 @@ */ package org.eclipse.che.api.project.server.impl; -import static java.util.stream.Collectors.toSet; -import static org.eclipse.che.api.fs.server.WsPathUtils.SEPARATOR; - -import com.google.common.collect.ImmutableSet; -import java.util.Map; -import java.util.Map.Entry; import java.util.Optional; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import javax.inject.Inject; -import javax.inject.Singleton; import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; +import org.eclipse.che.api.project.shared.RegisteredProject; -@Singleton -public class ProjectConfigRegistry { +/** + * Registry for projects + * + * @author gazarenkov + */ +public interface ProjectConfigRegistry { - private final Map projects = new ConcurrentHashMap<>(); + /** @return all the projects */ + Set getAll(); - private final RegisteredProjectFactory registeredProjectFactory; + /** + * @param wsPath root path + * @return all the projects under wsPath + */ + Set getAll(String wsPath); - @Inject - public ProjectConfigRegistry(RegisteredProjectFactory registeredProjectFactory) { - this.registeredProjectFactory = registeredProjectFactory; - } + /** + * @param wsPath + * @return project on wsPath as Optional object + */ + Optional get(String wsPath); - public Set getAll() { - return ImmutableSet.copyOf(projects.values()); - } + /** + * @param wsPath + * @return project on wsPath or null + */ + RegisteredProject getOrNull(String wsPath); - public Set getAll(String wsPath) { - Set children = - projects - .entrySet() - .stream() - .filter(it -> it.getKey().startsWith(wsPath + SEPARATOR)) - .filter(it -> !it.getKey().equals(wsPath)) - .map(Entry::getValue) - .collect(toSet()); - return ImmutableSet.copyOf(children); - } + /** + * registers project + * + * @param config project config + * @param updated whether project just u + * @param detected + * @return created project + */ + RegisteredProject put(ProjectConfig config, boolean updated, boolean detected); - public Optional get(String wsPath) { - return Optional.ofNullable(projects.get(wsPath)); - } + /** + * registers a folder on wsPath as a project + * + * @param wsPath path + * @param updated whether project just u + * @param detected + * @return created project + */ + RegisteredProject putIfAbsent(String wsPath, boolean updated, boolean detected); - public RegisteredProject getOrNull(String wsPath) { - return projects.get(wsPath); - } + /** + * deletes project + * + * @param wsPath path + * @return deleted project + */ + Optional remove(String wsPath); - public synchronized RegisteredProject put( - ProjectConfig config, boolean updated, boolean detected) { - String wsPath = config.getPath(); - RegisteredProject project = registeredProjectFactory.create(wsPath, config, updated, detected); - projects.put(wsPath, project); - return project; - } + /** + * deletes project + * + * @param wsPath path + * @return deleted project + */ + RegisteredProject removeOrNull(String wsPath); - public synchronized RegisteredProject putIfAbsent( - ProjectConfig config, boolean updated, boolean detected) { - RegisteredProject registeredProject = projects.get(config.getPath()); - if (registeredProject != null) { - return registeredProject; - } + /** + * whether path contains registered project + * + * @param path + * @return true or false + */ + boolean isRegistered(String path); - String wsPath = config.getPath(); - RegisteredProject project = registeredProjectFactory.create(wsPath, config, updated, detected); - projects.put(wsPath, project); - return project; - } - - public synchronized RegisteredProject put(String wsPath, boolean updated, boolean detected) { - RegisteredProject project = registeredProjectFactory.create(wsPath, null, updated, detected); - projects.put(wsPath, project); - return project; - } - - public synchronized RegisteredProject putIfAbsent( - String wsPath, boolean updated, boolean detected) { - RegisteredProject registeredProject = projects.get(wsPath); - if (registeredProject != null) { - return registeredProject; - } - - RegisteredProject project = registeredProjectFactory.create(wsPath, null, updated, detected); - projects.put(wsPath, project); - return project; - } - - public Optional remove(String wsPath) { - return Optional.ofNullable(projects.remove(wsPath)); - } - - public RegisteredProject removeOrNull(String wsPath) { - return projects.remove(wsPath); - } - - public boolean isRegistered(String path) { - return projects.containsKey(path); - } + /** + * closest registered project + * + * @param wsPath path + * @return RegisteredProject + */ + Optional getClosest(String wsPath); } diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectDtoConverter.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectDtoConverter.java index af7e1aef2a..0483a52815 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectDtoConverter.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectDtoConverter.java @@ -21,9 +21,11 @@ import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.core.model.workspace.config.SourceStorage; import org.eclipse.che.api.project.server.ProjectImporter; import org.eclipse.che.api.project.server.type.ProjectTypeDef; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.eclipse.che.api.project.shared.dto.AttributeDto; import org.eclipse.che.api.project.shared.dto.ProjectImporterDescriptor; import org.eclipse.che.api.project.shared.dto.ProjectTypeDto; +import org.eclipse.che.api.project.shared.dto.RegisteredProjectDto; import org.eclipse.che.api.project.shared.dto.ValueDto; import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; import org.eclipse.che.api.workspace.shared.dto.ProjectProblemDto; @@ -93,8 +95,8 @@ public class ProjectDtoConverter { .withDescription(project.getDescription()) .withSource(asDto(project.getSource())) .withAttributes(project.getAttributes()) - .withType(project.getProjectType().getId()) - .withMixins(new ArrayList<>(project.getMixinTypes().keySet())) + .withType(project.getType()) + .withMixins(project.getMixins()) .withProblems( project .getProblems() @@ -103,6 +105,39 @@ public class ProjectDtoConverter { .collect(Collectors.toList())); } + /** + * Converts abstract RegisteredProject to RegisteredProjectDto + * + * @param project RegisteredProject + * @return RegisteredProjectDto + */ + public static RegisteredProjectDto asRegisteredProjectDto(RegisteredProject project) { + return newDto(RegisteredProjectDto.class) + .withName(project.getName()) + .withPath(project.getPath()) + .withDescription(project.getDescription()) + .withSource(asDto(project.getSource())) + .withAttributes(project.getAttributes()) + .withType(project.getType()) + .withMixins(project.getMixins()) + .withBaseFolder(project.getBaseFolder()) + .withDetected(project.isDetected()) + .withSynced(project.isSynced()) + .withPersistableAttributes(project.getPersistableAttributes()) + .withProblems( + project + .getProblems() + .stream() + .map(ProjectDtoConverter::asDto) + .collect(Collectors.toList())); + } + + /** + * Converts abstract ProjectConfig to ProjectConfigDto + * + * @param project ProjectConfig + * @return ProjectConfigDto + */ public static ProjectConfigDto asDto(ProjectConfig project) { return newDto(ProjectConfigDto.class) .withName(project.getName()) diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectHandlerRegistry.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectHandlerRegistry.java index 7fb4c8b7f0..85ff74f338 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectHandlerRegistry.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectHandlerRegistry.java @@ -18,7 +18,6 @@ import javax.inject.Inject; import javax.inject.Singleton; import javax.validation.constraints.NotNull; import org.eclipse.che.api.project.server.handlers.CreateProjectHandler; -import org.eclipse.che.api.project.server.handlers.GetItemHandler; import org.eclipse.che.api.project.server.handlers.PostImportProjectHandler; import org.eclipse.che.api.project.server.handlers.ProjectHandler; import org.eclipse.che.api.project.server.handlers.ProjectInitHandler; @@ -29,7 +28,6 @@ public class ProjectHandlerRegistry { private final Map createProjectHandlers = new HashMap<>(); private final Map postImportProjectHandlers = new HashMap<>(); - private final Map getItemHandlers = new HashMap<>(); private final Map projectInitHandlers = new HashMap<>(); @Inject @@ -40,10 +38,10 @@ public class ProjectHandlerRegistry { public void register(@NotNull ProjectHandler handler) { if (handler instanceof CreateProjectHandler) { createProjectHandlers.put(handler.getProjectType(), (CreateProjectHandler) handler); - } else if (handler instanceof GetItemHandler) { - getItemHandlers.put(handler.getProjectType(), (GetItemHandler) handler); + } else if (handler instanceof PostImportProjectHandler) { postImportProjectHandlers.put(handler.getProjectType(), (PostImportProjectHandler) handler); + } else if (handler instanceof ProjectInitHandler) { projectInitHandlers.put(handler.getProjectType(), (ProjectInitHandler) handler); } @@ -53,10 +51,6 @@ public class ProjectHandlerRegistry { return Optional.ofNullable(createProjectHandlers.get(projectType)); } - public Optional getGetItemHandler(String projectType) { - return Optional.ofNullable(getItemHandlers.get(projectType)); - } - public Optional getPostImportHandler(String projectType) { return Optional.ofNullable(postImportProjectHandlers.get(projectType)); } diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectImportManager.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectImportManager.java index f2367ac67e..468807daca 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectImportManager.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectImportManager.java @@ -45,6 +45,7 @@ import org.eclipse.che.api.project.server.handlers.ProjectInitHandler; import org.eclipse.che.api.project.server.type.AttributeValue; import org.eclipse.che.api.project.server.type.BaseProjectType; import org.eclipse.che.api.project.shared.NewProjectConfig; +import org.eclipse.che.api.project.shared.RegisteredProject; @Singleton public class ProjectImportManager { diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectJsonRpcServiceBackEnd.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectJsonRpcServiceBackEnd.java index 2e52261ce5..2a5a615ee2 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectJsonRpcServiceBackEnd.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectJsonRpcServiceBackEnd.java @@ -14,7 +14,12 @@ import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toMap; import static org.eclipse.che.api.project.server.impl.ProjectDtoConverter.asDto; import static org.eclipse.che.api.project.shared.Constants.EVENT_IMPORT_OUTPUT_PROGRESS; -import static org.eclipse.che.api.project.shared.Constants.Services.*; +import static org.eclipse.che.api.project.shared.Constants.Services.BAD_REQUEST; +import static org.eclipse.che.api.project.shared.Constants.Services.CONFLICT; +import static org.eclipse.che.api.project.shared.Constants.Services.FORBIDDEN; +import static org.eclipse.che.api.project.shared.Constants.Services.NOT_FOUND; +import static org.eclipse.che.api.project.shared.Constants.Services.SERVER_ERROR; +import static org.eclipse.che.api.project.shared.Constants.Services.UNAUTHORIZED; import static org.eclipse.che.dto.server.DtoFactory.newDto; import java.util.Collections; @@ -24,15 +29,34 @@ import java.util.Map.Entry; import java.util.function.BiConsumer; import javax.inject.Inject; import javax.inject.Singleton; -import org.eclipse.che.api.core.*; +import org.eclipse.che.api.core.BadRequestException; +import org.eclipse.che.api.core.ConflictException; +import org.eclipse.che.api.core.ForbiddenException; +import org.eclipse.che.api.core.NotFoundException; +import org.eclipse.che.api.core.ServerException; +import org.eclipse.che.api.core.UnauthorizedException; import org.eclipse.che.api.core.jsonrpc.commons.JsonRpcException; import org.eclipse.che.api.core.jsonrpc.commons.RequestTransmitter; import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.type.ProjectTypeResolution; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.eclipse.che.api.project.shared.dto.ImportProgressRecordDto; import org.eclipse.che.api.project.shared.dto.SourceEstimation; -import org.eclipse.che.api.project.shared.dto.service.*; +import org.eclipse.che.api.project.shared.dto.service.CreateRequestDto; +import org.eclipse.che.api.project.shared.dto.service.CreateResponseDto; +import org.eclipse.che.api.project.shared.dto.service.DeleteRequestDto; +import org.eclipse.che.api.project.shared.dto.service.DeleteResponseDto; +import org.eclipse.che.api.project.shared.dto.service.GetRequestDto; +import org.eclipse.che.api.project.shared.dto.service.GetResponseDto; +import org.eclipse.che.api.project.shared.dto.service.ImportRequestDto; +import org.eclipse.che.api.project.shared.dto.service.ImportResponseDto; +import org.eclipse.che.api.project.shared.dto.service.RecognizeRequestDto; +import org.eclipse.che.api.project.shared.dto.service.RecognizeResponseDto; +import org.eclipse.che.api.project.shared.dto.service.UpdateRequestDto; +import org.eclipse.che.api.project.shared.dto.service.UpdateResponseDto; +import org.eclipse.che.api.project.shared.dto.service.VerifyRequestDto; +import org.eclipse.che.api.project.shared.dto.service.VerifyResponseDto; import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; import org.eclipse.che.api.workspace.shared.dto.SourceStorageDto; @@ -82,7 +106,7 @@ public class ProjectJsonRpcServiceBackEnd { NotFoundException { String wsPath = request.getWsPath(); - RegisteredProject registeredProject = + ProjectConfig registeredProject = projectManager .get(wsPath) .orElseThrow(() -> new NotFoundException("Can't find project: " + wsPath)); diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectServiceApi.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectServiceApi.java index 3e2769194d..ed0b4e02f8 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectServiceApi.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ProjectServiceApi.java @@ -68,6 +68,7 @@ import org.eclipse.che.api.project.server.notification.ProjectCreatedEvent; import org.eclipse.che.api.project.server.notification.ProjectDeletedEvent; import org.eclipse.che.api.project.server.notification.ProjectItemModifiedEvent; import org.eclipse.che.api.project.server.type.ProjectTypeResolution; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.eclipse.che.api.project.shared.dto.CopyOptions; import org.eclipse.che.api.project.shared.dto.ImportProgressRecordDto; import org.eclipse.che.api.project.shared.dto.ItemReference; diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RegisteredProjectFactory.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RegisteredProjectFactory.java index 20283de782..54260612e8 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RegisteredProjectFactory.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RegisteredProjectFactory.java @@ -15,7 +15,7 @@ import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; public interface RegisteredProjectFactory { - RegisteredProject create( + RegisteredProjectImpl create( @Assisted("folder") String folder, @Assisted("config") ProjectConfig config, @Assisted("updated") boolean updated, diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RegisteredProject.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RegisteredProjectImpl.java similarity index 97% rename from wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RegisteredProject.java rename to wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RegisteredProjectImpl.java index 5711b2bbf9..a9fe8a329c 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RegisteredProject.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RegisteredProjectImpl.java @@ -37,6 +37,7 @@ import org.eclipse.che.api.project.server.type.ProjectTypesFactory; import org.eclipse.che.api.project.server.type.ValueProvider; import org.eclipse.che.api.project.server.type.ValueStorageException; import org.eclipse.che.api.project.server.type.Variable; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.eclipse.che.api.workspace.shared.ProjectProblemImpl; import org.eclipse.che.commons.annotation.Nullable; @@ -45,7 +46,7 @@ import org.eclipse.che.commons.annotation.Nullable; * * @author gazarenkov */ -public class RegisteredProject implements ProjectConfig { +public class RegisteredProjectImpl implements RegisteredProject { private final List problems; private final Map attributes; @@ -67,7 +68,7 @@ public class RegisteredProject implements ProjectConfig { * @throws ServerException when path for project is undefined */ @AssistedInject - public RegisteredProject( + public RegisteredProjectImpl( @Assisted("folder") String folder, @Assisted("config") @Nullable ProjectConfig config, @Assisted("updated") boolean updated, @@ -210,24 +211,27 @@ public class RegisteredProject implements ProjectConfig { * @return whether this project is synchronized with Workspace storage On the other words this * project is not updated */ + @Override public boolean isSynced() { return !this.updated; } /** should be called after synchronization with Workspace storage */ - public void setSync() { - this.updated = false; + public void setSynced(boolean synced) { + this.updated = !synced; } /** * @return whether this project is detected using Project Type resolver If so it should not be * persisted to Workspace storage */ + @Override public boolean isDetected() { return detected; } /** @return root folder or null */ + @Override public String getBaseFolder() { return folder; } diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RootDirPathProvider.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RootDirPathProvider.java new file mode 100644 index 0000000000..b42424373e --- /dev/null +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RootDirPathProvider.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * 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: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api.project.server.impl; + +import com.google.inject.Inject; +import java.io.File; +import java.nio.file.Paths; +import javax.inject.Named; +import javax.inject.Provider; +import javax.inject.Singleton; + +/** + * Provides ABSOLUTE path for projects root directory using: env variable 'CHE_PROJECTS_ROOT' (which + * is set by workspace API == "project" volume configured) if not - uses + * 'che.user.workspaces.storage' property otherwise - default with '/project' directory (backward + * compatible solution) + * + * @author gazarenkov + */ +@Singleton +public class RootDirPathProvider implements Provider { + + public static String DEFAULT = "/projects"; + + @Inject(optional = true) + @Named("che.user.workspaces.storage") + protected File rootFile = null; + + @Override + public String get() { + + String path = System.getenv("CHE_PROJECTS_ROOT"); + if (path == null && rootFile != null) { + path = rootFile.getPath(); + } + if (path == null) { + path = DEFAULT; + } + + if (Paths.get(path).isAbsolute()) { + return path; + } + throw new IllegalArgumentException("Path to the project should be declared as absolute path"); + } +} diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RootDirRemovalHandler.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RootDirRemovalHandler.java index cd5782590c..7a06d056b1 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RootDirRemovalHandler.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/RootDirRemovalHandler.java @@ -19,6 +19,7 @@ import org.eclipse.che.api.core.ServerException; import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.notification.ProjectDeletedEvent; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.eclipse.che.api.watcher.server.FileWatcherManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/SynchronizingProjectManager.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/SynchronizingProjectManager.java index 8946b8fa51..8fabafc1e3 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/SynchronizingProjectManager.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/SynchronizingProjectManager.java @@ -28,6 +28,7 @@ import org.eclipse.che.api.core.model.workspace.config.SourceStorage; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.type.ProjectTypeResolution; import org.eclipse.che.api.project.shared.NewProjectConfig; +import org.eclipse.che.api.project.shared.RegisteredProject; /** * Synchronize project registry state on workspace agent and master using actual implementation of diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ValidatingProjectManager.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ValidatingProjectManager.java index cb45e141ea..72e0d246b6 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ValidatingProjectManager.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/ValidatingProjectManager.java @@ -31,6 +31,7 @@ import org.eclipse.che.api.fs.server.FsManager; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.type.ProjectTypeResolution; import org.eclipse.che.api.project.shared.NewProjectConfig; +import org.eclipse.che.api.project.shared.RegisteredProject; /** * Preforms preliminary project manager method parameters validation and on success passes execution diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/WorkspaceProjectSynchronizer.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/WorkspaceProjectSynchronizer.java index 1961fbb5d6..f6549e6f38 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/WorkspaceProjectSynchronizer.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/impl/WorkspaceProjectSynchronizer.java @@ -28,6 +28,7 @@ import org.eclipse.che.api.core.ServerException; import org.eclipse.che.api.core.model.workspace.WorkspaceConfig; import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.core.rest.HttpJsonRequestFactory; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.eclipse.che.api.workspace.server.WorkspaceService; import org.eclipse.che.api.workspace.shared.dto.WorkspaceDto; import org.slf4j.Logger; @@ -116,7 +117,7 @@ public class WorkspaceProjectSynchronizer implements ProjectSynchronizer { add(config); } - project.setSync(); + project.setSynced(true); } } diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/type/InitBaseProjectTypeHandler.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/type/InitBaseProjectTypeHandler.java index 8b43432e9e..db66802413 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/type/InitBaseProjectTypeHandler.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/type/InitBaseProjectTypeHandler.java @@ -20,7 +20,7 @@ import org.eclipse.che.api.core.NotFoundException; import org.eclipse.che.api.core.ServerException; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.handlers.ProjectInitHandler; -import org.eclipse.che.api.project.server.impl.RegisteredProject; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/search/server/impl/LuceneSearcher.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/search/server/impl/LuceneSearcher.java index a3646e3519..a58b48c042 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/search/server/impl/LuceneSearcher.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/search/server/impl/LuceneSearcher.java @@ -26,6 +26,7 @@ import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.PathMatcher; +import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; @@ -75,6 +76,7 @@ import org.apache.lucene.store.FSDirectory; import org.apache.lucene.store.SingleInstanceLockFactory; import org.apache.lucene.util.BytesRef; import org.eclipse.che.api.fs.server.PathTransformer; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.api.search.server.InvalidQueryException; import org.eclipse.che.api.search.server.OffsetData; import org.eclipse.che.api.search.server.QueryExecutionException; @@ -102,10 +104,9 @@ public class LuceneSearcher implements Searcher { private static final String TEXT_FIELD = "text"; private final Set excludePatterns; - private final File indexDirectory; private final PathTransformer pathTransformer; - private final File root; + private final Path root; private final IndexWriter luceneIndexWriter; private final SearcherManager searcherManager; private final Analyzer analyzer; @@ -116,7 +117,7 @@ public class LuceneSearcher implements Searcher { public LuceneSearcher( @Named("vfs.index_filter_matcher") Set excludePatterns, @Named("vfs.local.fs_index_root_dir") File indexDirectory, - @Named("che.user.workspaces.storage") File root, + RootDirPathProvider pathProvider, PathTransformer pathTransformer) throws IOException { @@ -128,8 +129,7 @@ public class LuceneSearcher implements Searcher { Files.createDirectories(indexDirectory.toPath()); } - this.indexDirectory = indexDirectory; - this.root = root; + this.root = Paths.get(pathProvider.get()); this.excludePatterns = excludePatterns; this.pathTransformer = pathTransformer; this.analyzer = @@ -154,7 +154,7 @@ public class LuceneSearcher implements Searcher { () -> { try { long start = System.currentTimeMillis(); - add(root.toPath()); + add(root); LOG.info( "Initial indexing complete after {} msec ", System.currentTimeMillis() - start); } finally { diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/detectors/EditorFileTracker.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/detectors/EditorFileTracker.java index b76a9ad61f..680c90e3ef 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/detectors/EditorFileTracker.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/detectors/EditorFileTracker.java @@ -21,6 +21,8 @@ import com.google.common.hash.Hashing; import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -29,12 +31,12 @@ import java.util.TimerTask; import java.util.function.Consumer; import javax.annotation.PreDestroy; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Singleton; import org.eclipse.che.api.core.jsonrpc.commons.RequestTransmitter; import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.core.notification.EventSubscriber; import org.eclipse.che.api.fs.server.FsManager; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.api.project.shared.dto.event.FileStateUpdateDto; import org.eclipse.che.api.project.shared.dto.event.FileTrackingOperationDto; import org.eclipse.che.api.project.shared.dto.event.FileTrackingOperationDto.Type; @@ -68,16 +70,16 @@ public class EditorFileTracker { private final FsManager fsManager; private final EventService eventService; private final EventSubscriber fileOperationEventSubscriber; - private File root; + private Path root; @Inject public EditorFileTracker( - @Named("che.user.workspaces.storage") File root, + RootDirPathProvider pathProvider, FileWatcherManager fileWatcherManager, RequestTransmitter transmitter, FsManager fsManager, EventService eventService) { - this.root = root; + this.root = Paths.get(pathProvider.get()); this.fileWatcherManager = fileWatcherManager; this.transmitter = transmitter; this.fsManager = fsManager; @@ -204,7 +206,7 @@ public class EditorFileTracker { new TimerTask() { @Override public void run() { - if (!Files.exists(FileWatcherUtils.toNormalPath(root.toPath(), it))) { + if (!Files.exists(FileWatcherUtils.toNormalPath(root, it))) { hashRegistry.remove(path + endpointId); FileStateUpdateDto params = newDto(FileStateUpdateDto.class).withPath(path).withType(DELETED); diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/FileTreeWalker.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/FileTreeWalker.java index 0c38c5136a..7758a0aba8 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/FileTreeWalker.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/FileTreeWalker.java @@ -17,12 +17,12 @@ import static java.nio.file.Files.walkFileTree; import static java.util.stream.Collectors.toSet; import com.google.inject.Inject; -import java.io.File; import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.PathMatcher; +import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.HashMap; @@ -32,6 +32,7 @@ import java.util.function.Consumer; import javax.annotation.PostConstruct; import javax.inject.Named; import javax.inject.Singleton; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.commons.schedule.ScheduleRate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,7 +45,7 @@ import org.slf4j.LoggerFactory; public class FileTreeWalker { private static final Logger LOG = LoggerFactory.getLogger(FileTreeWalker.class); - private final File root; + private final Path root; private final Set> directoryUpdateConsumers; private final Set> directoryCreateConsumers; @@ -63,7 +64,7 @@ public class FileTreeWalker { @Inject public FileTreeWalker( - @Named("che.user.workspaces.storage") File root, + RootDirPathProvider pathProvider, @Named("che.fs.directory.update") Set> directoryUpdateConsumers, @Named("che.fs.directory.create") Set> directoryCreateConsumers, @Named("che.fs.directory.delete") Set> directoryDeleteConsumers, @@ -72,7 +73,7 @@ public class FileTreeWalker { @Named("che.fs.file.create") Set> fileCreateConsumers, @Named("che.fs.file.delete") Set> fileDeleteConsumers, @Named("che.fs.file.excludes") Set fileExcludes) { - this.root = root; + this.root = Paths.get(pathProvider.get()); this.directoryUpdateConsumers = directoryUpdateConsumers; this.directoryCreateConsumers = directoryCreateConsumers; @@ -90,7 +91,7 @@ public class FileTreeWalker { void initialize() { try { walkFileTree( - root.toPath(), + root, new SimpleFileVisitor() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { @@ -144,7 +145,7 @@ public class FileTreeWalker { directories.keySet().removeAll(deletedDirectories); walkFileTree( - root.toPath(), + root, new SimpleFileVisitor() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/FileWatcherByPathMatcher.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/FileWatcherByPathMatcher.java index 4df0e73d4b..cbe8ed9957 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/FileWatcherByPathMatcher.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/FileWatcherByPathMatcher.java @@ -14,7 +14,6 @@ import static com.google.common.collect.Sets.newConcurrentHashSet; import static java.nio.file.Files.exists; import com.google.inject.Inject; -import java.io.File; import java.nio.file.Path; import java.nio.file.PathMatcher; import java.util.Iterator; @@ -24,7 +23,6 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; -import javax.inject.Named; import javax.inject.Singleton; import org.eclipse.che.api.fs.server.PathTransformer; import org.slf4j.Logger; @@ -48,16 +46,10 @@ public class FileWatcherByPathMatcher implements Consumer { /** Registered path -> Path watch operation IDs */ private final Map> pathWatchRegistrations = new ConcurrentHashMap<>(); - private final File root; - private PathTransformer pathTransformer; @Inject - public FileWatcherByPathMatcher( - @Named("che.user.workspaces.storage") File root, - FileWatcherByPathValue watcher, - PathTransformer pathTransformer) { - this.root = root; + public FileWatcherByPathMatcher(FileWatcherByPathValue watcher, PathTransformer pathTransformer) { this.watcher = watcher; this.pathTransformer = pathTransformer; } diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/FileWatcherEventHandler.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/FileWatcherEventHandler.java index 54a8ae2efd..515ef50f9c 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/FileWatcherEventHandler.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/FileWatcherEventHandler.java @@ -14,8 +14,8 @@ import static com.google.common.collect.Sets.newConcurrentHashSet; import static java.nio.file.Files.isDirectory; import static org.eclipse.che.api.watcher.server.impl.FileWatcherUtils.toInternalPath; -import java.io.File; import java.nio.file.Path; +import java.nio.file.Paths; import java.nio.file.WatchEvent; import java.util.Map; import java.util.Map.Entry; @@ -27,8 +27,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; import java.util.function.Predicate; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Singleton; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.api.watcher.server.FileWatcherManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,11 +41,11 @@ public class FileWatcherEventHandler { private final Map> operations = new ConcurrentHashMap<>(); - private final File root; + private final Path root; @Inject - public FileWatcherEventHandler(@Named("che.user.workspaces.storage") File root) { - this.root = root; + public FileWatcherEventHandler(RootDirPathProvider pathProvider) { + this.root = Paths.get(pathProvider.get()); } /** @@ -110,7 +110,7 @@ public class FileWatcherEventHandler { */ void handle(Path path, WatchEvent.Kind kind) { Path dir = path.getParent(); - String internalPath = toInternalPath(root.toPath(), path); + String internalPath = toInternalPath(root, path); Set dirOperations = operations.get(dir); Set itemOperations = operations.get(path); diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/SimpleFileWatcherManager.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/SimpleFileWatcherManager.java index 771a909278..7000777e4a 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/SimpleFileWatcherManager.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/watcher/server/impl/SimpleFileWatcherManager.java @@ -13,12 +13,12 @@ package org.eclipse.che.api.watcher.server.impl; import static org.eclipse.che.api.watcher.server.impl.FileWatcherUtils.toNormalPath; import com.google.inject.Inject; -import java.io.File; import java.nio.file.Path; import java.nio.file.PathMatcher; +import java.nio.file.Paths; import java.util.function.Consumer; -import javax.inject.Named; import javax.inject.Singleton; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.api.watcher.server.FileWatcherManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,13 +35,13 @@ public class SimpleFileWatcherManager implements FileWatcherManager { @Inject public SimpleFileWatcherManager( - @Named("che.user.workspaces.storage") File root, + RootDirPathProvider pathProvider, FileWatcherByPathValue watcherByPathValue, FileWatcherByPathMatcher watcherByPathMatcher, FileWatcherExcludePatternsRegistry excludePatternsRegistry) { this.fileWatcherByPathMatcher = watcherByPathMatcher; this.fileWatcherByPathValue = watcherByPathValue; - this.root = root.toPath().normalize().toAbsolutePath(); + this.root = Paths.get(pathProvider.get()).normalize().toAbsolutePath(); this.excludePatternsRegistry = excludePatternsRegistry; } diff --git a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/RootDirPathProviderTest.java b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/RootDirPathProviderTest.java new file mode 100644 index 0000000000..c748e0d2e5 --- /dev/null +++ b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/RootDirPathProviderTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2012-2018 Red Hat, Inc. + * 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: + * Red Hat, Inc. - initial API and implementation + */ +package org.eclipse.che.api; + +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.name.Names; +import java.io.File; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; +import org.testng.annotations.Test; + +public class RootDirPathProviderTest { + + @Test(expectedExceptions = IllegalArgumentException.class) + public void test() { + File root = new File("target"); + Injector injector = + Guice.createInjector( + new AbstractModule() { + @Override + protected void configure() { + bind(File.class) + .annotatedWith(Names.named("che.user.workspaces.storage")) + .toInstance(root); + } + }); + + RootDirPathProvider pathProvider = injector.getInstance(RootDirPathProvider.class); + pathProvider.get(); + } +} diff --git a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/fs/server/impl/ProjectServiceVcsStatusInjectorTest.java b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/fs/server/impl/ProjectServiceVcsStatusInjectorTest.java index 2b6fbf49ab..c41fb4ea30 100644 --- a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/fs/server/impl/ProjectServiceVcsStatusInjectorTest.java +++ b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/fs/server/impl/ProjectServiceVcsStatusInjectorTest.java @@ -30,7 +30,7 @@ import java.util.Optional; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.VcsStatusProvider; import org.eclipse.che.api.project.server.impl.ProjectServiceVcsStatusInjector; -import org.eclipse.che.api.project.server.impl.RegisteredProject; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.eclipse.che.api.project.shared.dto.ItemReference; import org.eclipse.che.api.project.shared.dto.TreeElement; import org.mockito.ArgumentCaptor; diff --git a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/fs/server/impl/RootAwarePathTransformerTest.java b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/fs/server/impl/RootAwarePathTransformerTest.java index 1e4bc8a92f..533df670fd 100644 --- a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/fs/server/impl/RootAwarePathTransformerTest.java +++ b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/fs/server/impl/RootAwarePathTransformerTest.java @@ -14,9 +14,11 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; +import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; import org.eclipse.che.api.fs.server.WsPathUtils; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -27,7 +29,8 @@ public class RootAwarePathTransformerTest { @BeforeMethod public void setUp() throws Exception { - rootAwarePathTransformer = new RootAwarePathTransformer(Paths.get("/").toFile()); + rootAwarePathTransformer = + new RootAwarePathTransformer(new DummyProvider(Paths.get("/").toFile())); } @Test @@ -85,4 +88,11 @@ public class RootAwarePathTransformerTest { assertFalse(fsPath.isAbsolute()); assertTrue(wsPath.startsWith(WsPathUtils.ROOT)); } + + private static class DummyProvider extends RootDirPathProvider { + + public DummyProvider(File file) { + this.rootFile = file; + } + } } diff --git a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/impl/SynchronizingProjectManagerTest.java b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/impl/SynchronizingProjectManagerTest.java index 05707852d9..cb19f1f58e 100644 --- a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/impl/SynchronizingProjectManagerTest.java +++ b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/impl/SynchronizingProjectManagerTest.java @@ -22,6 +22,7 @@ import org.eclipse.che.api.core.ServerException; import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.core.model.workspace.config.SourceStorage; import org.eclipse.che.api.project.shared.NewProjectConfig; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.testng.MockitoTestNGListener; diff --git a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/impl/ValidatingProjectManagerTest.java b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/impl/ValidatingProjectManagerTest.java index 90b96310e4..e1b17d713d 100644 --- a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/impl/ValidatingProjectManagerTest.java +++ b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/impl/ValidatingProjectManagerTest.java @@ -27,6 +27,7 @@ import org.eclipse.che.api.core.model.workspace.config.ProjectConfig; import org.eclipse.che.api.core.model.workspace.config.SourceStorage; import org.eclipse.che.api.fs.server.FsManager; import org.eclipse.che.api.project.shared.NewProjectConfig; +import org.eclipse.che.api.project.shared.RegisteredProject; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.testng.MockitoTestNGListener; diff --git a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/search/SearcherTest.java b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/search/SearcherTest.java index c3ebd37bbb..4a11aeee53 100644 --- a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/search/SearcherTest.java +++ b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/search/SearcherTest.java @@ -36,6 +36,7 @@ import java.util.Collections; import java.util.List; import java.util.Set; import org.eclipse.che.api.fs.server.impl.RootAwarePathTransformer; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.api.search.server.InvalidQueryException; import org.eclipse.che.api.search.server.OffsetData; import org.eclipse.che.api.search.server.QueryExecutionException; @@ -74,9 +75,9 @@ public class SearcherTest { IoUtil.deleteRecursive(indexDirectory); workspaceStorage = Files.createTempDir(); excludePatterns = Collections.emptySet(); - pathTransformer = new RootAwarePathTransformer(workspaceStorage); - searcher = - new LuceneSearcher(excludePatterns, indexDirectory, workspaceStorage, pathTransformer); + DummyProvider rootProvider = new DummyProvider(workspaceStorage); + pathTransformer = new RootAwarePathTransformer(rootProvider); + searcher = new LuceneSearcher(excludePatterns, indexDirectory, rootProvider, pathTransformer); contentBuilder = new ContentBuilder(workspaceStorage.toPath()); } @@ -518,4 +519,11 @@ public class SearcherTest { return this; } } + + private static class DummyProvider extends RootDirPathProvider { + + public DummyProvider(File file) { + this.rootFile = file; + } + } } diff --git a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/search/server/impl/FSLuceneSearcherTest.java b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/search/server/impl/FSLuceneSearcherTest.java index 10874c25fb..6c4de9997e 100644 --- a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/search/server/impl/FSLuceneSearcherTest.java +++ b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/search/server/impl/FSLuceneSearcherTest.java @@ -31,6 +31,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import org.eclipse.che.api.fs.server.impl.RootAwarePathTransformer; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.api.search.SearcherTest.ContentBuilder; import org.eclipse.che.api.search.server.QueryExpression; import org.eclipse.che.commons.lang.IoUtil; @@ -53,9 +54,10 @@ public class FSLuceneSearcherTest { indexDirectory = Files.createTempDir(); workspaceStorage = Files.createTempDir(); excludePatterns = new HashSet<>(); - pathTransformer = new RootAwarePathTransformer(workspaceStorage); + DummyProvider dummyRootProvider = new DummyProvider(workspaceStorage); + pathTransformer = new RootAwarePathTransformer(dummyRootProvider); searcher = - new LuceneSearcher(excludePatterns, indexDirectory, workspaceStorage, pathTransformer); + new LuceneSearcher(excludePatterns, indexDirectory, dummyRootProvider, pathTransformer); contentBuilder = new ContentBuilder(workspaceStorage.toPath()); } @@ -99,4 +101,11 @@ public class FSLuceneSearcherTest { // then assertEquals(newArrayList("/folder/xxx.txt", "/folder/zzz.txt"), paths); } + + private static class DummyProvider extends RootDirPathProvider { + + public DummyProvider(File file) { + this.rootFile = file; + } + } } diff --git a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/ConcurrentHandleTest.java b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/ConcurrentHandleTest.java index bfb966aac0..8faac199e5 100644 --- a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/ConcurrentHandleTest.java +++ b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/ConcurrentHandleTest.java @@ -18,6 +18,7 @@ import static java.util.concurrent.TimeUnit.SECONDS; import static org.junit.Assert.assertEquals; import com.google.common.collect.ImmutableList; +import java.io.File; import java.nio.file.Path; import java.nio.file.WatchEvent; import java.util.ArrayList; @@ -25,6 +26,7 @@ import java.util.ConcurrentModificationException; import java.util.List; import java.util.concurrent.*; import java.util.function.Consumer; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -47,7 +49,7 @@ public class ConcurrentHandleTest { @Before public void setUp() throws Exception { root = rootFolder.getRoot().toPath(); - handler = new FileWatcherEventHandler(rootFolder.getRoot()); + handler = new FileWatcherEventHandler(new DummyRootProvider(rootFolder.getRoot())); } @Test @@ -97,4 +99,11 @@ public class ConcurrentHandleTest { .count(); assertEquals(count, 0); } + + private static class DummyRootProvider extends RootDirPathProvider { + + public DummyRootProvider(File folder) { + this.rootFile = folder; + } + } } diff --git a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/FileTreeWalkerTest.java b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/FileTreeWalkerTest.java index 352dc2e781..b2438ba62a 100644 --- a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/FileTreeWalkerTest.java +++ b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/FileTreeWalkerTest.java @@ -22,6 +22,7 @@ import java.nio.file.PathMatcher; import java.util.HashSet; import java.util.Set; import java.util.function.Consumer; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -66,7 +67,7 @@ public class FileTreeWalkerTest { public void setUp() throws Exception { fileTreeWalker = new FileTreeWalker( - rootFolder.getRoot(), + new DummyRootProvider(rootFolder.getRoot()), directoryUpdateConsumers, directoryCreateConsumers, directoryDeleteConsumers, @@ -220,4 +221,11 @@ public class FileTreeWalkerTest { fileTreeWalker.walk(); verify(fileCreatedConsumerMock, never()).accept(file.toPath()); } + + private static class DummyRootProvider extends RootDirPathProvider { + + public DummyRootProvider(File folder) { + this.rootFile = folder; + } + } } diff --git a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/FileWatcherEventHandlerTest.java b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/FileWatcherEventHandlerTest.java index 5f96817340..b34d7eb22b 100644 --- a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/FileWatcherEventHandlerTest.java +++ b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/FileWatcherEventHandlerTest.java @@ -18,8 +18,10 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import java.io.File; import java.nio.file.Path; import java.util.function.Consumer; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -47,7 +49,7 @@ public class FileWatcherEventHandlerTest { public void setUp() throws Exception { root = rootFolder.getRoot().toPath(); - handler = new FileWatcherEventHandler(rootFolder.getRoot()); + handler = new FileWatcherEventHandler(new DummyRootProvider(rootFolder.getRoot())); } @Test @@ -125,4 +127,11 @@ public class FileWatcherEventHandlerTest { verify(create).accept(toInternalPath(root, path)); } + + private static class DummyRootProvider extends RootDirPathProvider { + + public DummyRootProvider(File folder) { + this.rootFile = folder; + } + } } diff --git a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/FileWatcherManagerTest.java b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/FileWatcherManagerTest.java index 5e20f01b2e..8c6c1ee358 100644 --- a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/FileWatcherManagerTest.java +++ b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/watcher/server/impl/FileWatcherManagerTest.java @@ -12,10 +12,12 @@ package org.eclipse.che.api.watcher.server.impl; import static org.eclipse.che.api.watcher.server.impl.FileWatcherUtils.toNormalPath; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import java.nio.file.Path; import java.nio.file.PathMatcher; import java.util.function.Consumer; +import org.eclipse.che.api.project.server.impl.RootDirPathProvider; import org.eclipse.che.api.watcher.server.FileWatcherManager; import org.junit.Before; import org.junit.Rule; @@ -44,12 +46,14 @@ public class FileWatcherManagerTest { @Mock Consumer modify; @Mock Consumer delete; @Mock PathMatcher pathMatcher; + @Mock RootDirPathProvider pathProvider; @Before public void setUp() throws Exception { + when(pathProvider.get()).thenReturn(rootFolder.getRoot().getPath()); manager = new SimpleFileWatcherManager( - rootFolder.getRoot(), + pathProvider, fileWatcherByPathValue, fileWatcherByPathMatcher, fileWatcherExcludePatternsRegistry); diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTermination.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTermination.java index b4995b85e1..dadb3abce1 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTermination.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTermination.java @@ -123,12 +123,12 @@ public class WorkspaceServiceTermination implements ServiceTermination { */ @Override public void suspend() throws InterruptedException, UnsupportedOperationException { - Preconditions.checkState(runtimes.refuseStart()); try { runtimeInfrastructure.getIdentities(); } catch (UnsupportedOperationException | InfrastructureException e) { throw new UnsupportedOperationException("Current infrastructure does not support suspend."); } + Preconditions.checkState(runtimes.refuseStart()); WorkspaceSuspendedEventsPropagator propagator = new WorkspaceSuspendedEventsPropagator(); eventService.subscribe(propagator); try {