Merge branch 'master' into golang_support

6.19.x
Eugene Ivantsov 2018-06-04 08:22:56 +03:00
commit 335b0f7d2a
90 changed files with 1096 additions and 299 deletions

View File

@ -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)

View File

@ -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();
}

View File

@ -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:

View File

@ -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 &

View File

@ -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"
}
}

View File

@ -80,7 +80,10 @@ public class DockerRuntimeInfrastructure extends RuntimeInfrastructure {
@Override
public Set<RuntimeIdentity> 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)

View File

@ -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));
}
}
}

View File

@ -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))
}
};
}

View File

@ -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);

View File

@ -53,6 +53,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace</artifactId>

View File

@ -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;

View File

@ -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;

View File

@ -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<ProjectManager> projectManagerProvider,
Provider<PathTransformer> pathTransformerProvider,
Provider<FsManager> fsManagerProvider) {
ResourcesPlugin.indexPath = indexPath;
ResourcesPlugin.workspacePath = workspacePath;
ResourcesPlugin.workspacePath = pathProvider.get();
pluginId = "cheWsPlugin";
EFS.setWsPath(workspacePath);
workspace =

View File

@ -58,6 +58,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-dto</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-model</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>

View File

@ -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(

View File

@ -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<ProjectItemModifiedEvent>() {

View File

@ -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)

View File

@ -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));

View File

@ -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;

View File

@ -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())

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -48,6 +48,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-git-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-model</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>

View File

@ -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<GitReposi
try {
ProjectManager projectManager = projectManagerProvider.get();
projectManager.removeType(projectPath, CONTRIBUTION_PROJECT_TYPE_ID);
RegisteredProject project = projectManager.get(projectPath).get();
ProjectConfig project = projectManager.get(projectPath).get();
Map<String, List<String>> attributes = project.getAttributes();
attributes.remove(CONTRIBUTE_LOCAL_BRANCH_NAME);
attributes.remove(CONTRIBUTE_TO_BRANCH_VARIABLE_NAME);

View File

@ -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();
}
/**

View File

@ -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;
}
}
}

View File

@ -33,6 +33,10 @@
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-testing</artifactId>

View File

@ -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;
}

View File

@ -45,6 +45,10 @@
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-testing</artifactId>

View File

@ -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;

View File

@ -49,6 +49,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-dto</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-testing</artifactId>

View File

@ -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} */

View File

@ -46,6 +46,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-inject</artifactId>

View File

@ -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);
}
});
}

View File

@ -293,6 +293,7 @@ public class NewWorkspace {
}
public void clickOnCreateButtonAndEditWorkspace() {
waitCreateWorkspaceButtonEnabled();
seleniumWebDriverHelper.waitAndClick(bottomCreateWorkspaceButton);
waitWorkspaceCreatedDialogIsVisible();
clickOnEditWorkspaceButton();

View File

@ -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));
}
}

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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<GitRepositoryDelet
try {
ProjectManager projectManager = projectManagerProvider.get();
projectManager.removeType(projectPath, GitProjectType.TYPE_ID);
RegisteredProject project = projectManager.get(projectPath).get();
ProjectConfig project = projectManager.get(projectPath).get();
Map<String, List<String>> attributes = project.getAttributes();
attributes.remove(GitProjectType.GIT_CURRENT_HEAD_NAME);
attributes.remove(GitProjectType.GIT_REPOSITORY_REMOTES);

View File

@ -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"));

View File

@ -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<StatusChangedEv
private Consumer<String> transmitConsumer(String wsPath) {
return id -> {
try {
RegisteredProject project =
ProjectConfig project =
projectManager
.getClosest(wsPath)
.orElseThrow(() -> new NotFoundException("Can't find a project"));

View File

@ -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<String, VcsStatus> statusMap = new HashMap<>();
try {
RegisteredProject project =
ProjectConfig project =
projectManager
.getClosest(absolutize(wsPath))
.orElseThrow(() -> new NotFoundException("Can't find project"));

View File

@ -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;

View File

@ -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<String, List<String>> getPersistableAttributes();
/**
* Sets 'synchronized with Workspace storage' flag
*
* @param synced true if synced
*/
void setSynced(boolean synced);
}

View File

@ -50,6 +50,7 @@ public interface ItemReference extends Hyperlinks {
ItemReference withPath(String path);
@Override
ItemReference withLinks(List<Link> links);
/** Attributes */

View File

@ -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<ProjectProblemDto> getProblems();
SourceStorageDto getSource();
RegisteredProjectDto withName(String name);
RegisteredProjectDto withPath(String path);
RegisteredProjectDto withDescription(String description);
RegisteredProjectDto withType(String type);
RegisteredProjectDto withMixins(List<String> mixins);
RegisteredProjectDto withAttributes(Map<String, List<String>> attributes);
RegisteredProjectDto withSource(SourceStorageDto source);
RegisteredProjectDto withProblems(List<ProjectProblemDto> problems);
RegisteredProjectDto withSynced(boolean synced);
RegisteredProjectDto withDetected(boolean detected);
RegisteredProjectDto withBaseFolder(String baseFolder);
RegisteredProjectDto withPersistableAttributes(Map<String, List<String>> attributes);
}

View File

@ -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

View File

@ -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)) {

View File

@ -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(

View File

@ -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 {

View File

@ -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<RegisteredProject> getClosest(String wsPath) {
while (!isRoot(wsPath)) {
Optional<RegisteredProject> 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<String> mixins = project.getMixins();

View File

@ -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<String, RegisteredProject> projects = new ConcurrentHashMap<>();
private final RegisteredProjectFactory registeredProjectFactory;
@Inject
public InmemoryProjectRegistry(RegisteredProjectFactory registeredProjectFactory) {
this.registeredProjectFactory = registeredProjectFactory;
}
@Override
public Set<RegisteredProject> getAll() {
return ImmutableSet.copyOf(projects.values());
}
@Override
public Set<RegisteredProject> getAll(String wsPath) {
Set<RegisteredProject> 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<RegisteredProject> 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<RegisteredProject> 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<RegisteredProject> getClosest(String wsPath) {
while (!isRoot(wsPath)) {
if (projects.containsKey(wsPath)) {
return Optional.of(projects.get(wsPath));
}
wsPath = WsPathUtils.parentOf(wsPath);
}
return empty();
}
}

View File

@ -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;
}

View File

@ -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<String, RegisteredProject> 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<RegisteredProject> getAll() {
return ImmutableSet.copyOf(cache.getAll(""));
}
@Override
public Set<RegisteredProject> getAll(String wsPath) {
return ImmutableSet.copyOf(cache.getAll(wsPath));
}
@Override
public Optional<RegisteredProject> 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<RegisteredProject> 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<RegisteredProject> 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<RegisteredProject> getAll(String wsPath) {
Set<RegisteredProject> 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<Path> 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";
}
}
}

View File

@ -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<String, RegisteredProject> projects = new ConcurrentHashMap<>();
/** @return all the projects */
Set<RegisteredProject> getAll();
private final RegisteredProjectFactory registeredProjectFactory;
/**
* @param wsPath root path
* @return all the projects under wsPath
*/
Set<RegisteredProject> getAll(String wsPath);
@Inject
public ProjectConfigRegistry(RegisteredProjectFactory registeredProjectFactory) {
this.registeredProjectFactory = registeredProjectFactory;
}
/**
* @param wsPath
* @return project on wsPath as Optional object
*/
Optional<RegisteredProject> get(String wsPath);
public Set<RegisteredProject> getAll() {
return ImmutableSet.copyOf(projects.values());
}
/**
* @param wsPath
* @return project on wsPath or null
*/
RegisteredProject getOrNull(String wsPath);
public Set<RegisteredProject> getAll(String wsPath) {
Set<RegisteredProject> 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<RegisteredProject> 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<RegisteredProject> 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<RegisteredProject> 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<RegisteredProject> getClosest(String wsPath);
}

View File

@ -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())

View File

@ -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<String, CreateProjectHandler> createProjectHandlers = new HashMap<>();
private final Map<String, PostImportProjectHandler> postImportProjectHandlers = new HashMap<>();
private final Map<String, GetItemHandler> getItemHandlers = new HashMap<>();
private final Map<String, ProjectInitHandler> 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<GetItemHandler> getGetItemHandler(String projectType) {
return Optional.ofNullable(getItemHandlers.get(projectType));
}
public Optional<PostImportProjectHandler> getPostImportHandler(String projectType) {
return Optional.ofNullable(postImportProjectHandlers.get(projectType));
}

View File

@ -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 {

View File

@ -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));

View File

@ -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;

View File

@ -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,

View File

@ -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<ProjectProblem> problems;
private final Map<String, Value> 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;
}

View File

@ -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<String> {
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");
}
}

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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<PathMatcher> 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<PathMatcher> 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 {

View File

@ -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<FileTrackingOperationEvent> 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);

View File

@ -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<Consumer<Path>> directoryUpdateConsumers;
private final Set<Consumer<Path>> 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<Consumer<Path>> directoryUpdateConsumers,
@Named("che.fs.directory.create") Set<Consumer<Path>> directoryCreateConsumers,
@Named("che.fs.directory.delete") Set<Consumer<Path>> directoryDeleteConsumers,
@ -72,7 +73,7 @@ public class FileTreeWalker {
@Named("che.fs.file.create") Set<Consumer<Path>> fileCreateConsumers,
@Named("che.fs.file.delete") Set<Consumer<Path>> fileDeleteConsumers,
@Named("che.fs.file.excludes") Set<PathMatcher> 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<Path>() {
@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<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)

View File

@ -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<Path> {
/** Registered path -> Path watch operation IDs */
private final Map<Path, Set<Integer>> 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;
}

View File

@ -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<Path, Set<FileWatcherOperation>> 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<FileWatcherOperation> dirOperations = operations.get(dir);
Set<FileWatcherOperation> itemOperations = operations.get(path);

View File

@ -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;
}

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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<String> modify;
@Mock Consumer<String> 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);

View File

@ -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 {