diff --git a/.gitignore b/.gitignore index 40ea8854bbce..d48899072c0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,14 @@ # Eclipse # ################### +*.launch .classpath .project .settings/ target/ bin/ test-output/ +maven-eclipse.xml # Idea # ################## diff --git a/assembly/assembly-ide-war/pom.xml b/assembly/assembly-ide-war/pom.xml index 6166db823bfc..9b51db95bf62 100644 --- a/assembly/assembly-ide-war/pom.xml +++ b/assembly/assembly-ide-war/pom.xml @@ -164,10 +164,6 @@ org.eclipse.che.plugin che-plugin-languageserver-ide - - org.eclipse.che.plugin - che-plugin-languageserver-shared - org.eclipse.che.plugin che-plugin-machine-ext-client @@ -184,6 +180,10 @@ org.eclipse.che.plugin che-plugin-maven-shared + + org.eclipse.che.plugin + che-plugin-nodejs-debugger-ide + org.eclipse.che.plugin che-plugin-nodejs-lang-ide diff --git a/assembly/assembly-ide-war/src/main/resources/org/eclipse/che/ide/IDE.gwt.xml b/assembly/assembly-ide-war/src/main/resources/org/eclipse/che/ide/IDE.gwt.xml index 41b3b971d2bd..bfc13b160d3b 100644 --- a/assembly/assembly-ide-war/src/main/resources/org/eclipse/che/ide/IDE.gwt.xml +++ b/assembly/assembly-ide-war/src/main/resources/org/eclipse/che/ide/IDE.gwt.xml @@ -44,6 +44,7 @@ + @@ -80,6 +81,7 @@ + diff --git a/assembly/assembly-main/src/assembly/bin/che.sh b/assembly/assembly-main/src/assembly/bin/che.sh index 39a111e90e72..773aabc158e8 100644 --- a/assembly/assembly-main/src/assembly/bin/che.sh +++ b/assembly/assembly-main/src/assembly/bin/che.sh @@ -608,7 +608,7 @@ call_catalina () { ### Cannot add this in setenv.sh. ### We do the port mapping here, and this gets inserted into server.xml when tomcat boots - export JAVA_OPTS="${JAVA_OPTS} -Dport.http=${CHE_PORT} -Dche.home=${CHE_HOME} -Dh2.baseDir=${CHE_HOME}/db/" + export JAVA_OPTS="${JAVA_OPTS} -Dport.http=${CHE_PORT} -Dche.home=${CHE_HOME}" export SERVER_PORT=${CHE_PORT} # Launch the Che application server, passing in command line parameters diff --git a/assembly/assembly-wsagent-war/pom.xml b/assembly/assembly-wsagent-war/pom.xml index 1344208bc111..6443e43bee16 100644 --- a/assembly/assembly-wsagent-war/pom.xml +++ b/assembly/assembly-wsagent-war/pom.xml @@ -70,6 +70,14 @@ org.eclipse.che.core che-core-api-git + + org.eclipse.che.core + che-core-api-languageserver + + + org.eclipse.che.core + che-core-api-languageserver-shared + org.eclipse.che.core che-core-api-project @@ -146,19 +154,19 @@ org.eclipse.che.plugin - che-plugin-languageserver-server + che-plugin-json-server org.eclipse.che.plugin - che-plugin-languageserver-shared + che-plugin-maven-generator-archetype org.eclipse.che.plugin - che-plugin-maven-generator-archetype + che-plugin-maven-server org.eclipse.che.plugin - che-plugin-maven-server + che-plugin-nodejs-debugger-server org.eclipse.che.plugin diff --git a/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterModule.java b/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterModule.java index 16e1e0f86135..e55f6205a977 100644 --- a/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterModule.java +++ b/assembly/assembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/WsMasterModule.java @@ -16,12 +16,12 @@ import com.google.inject.persist.jpa.JpaPersistModule; import org.eclipse.che.api.agent.server.launcher.AgentLauncher; +import org.eclipse.che.api.core.jdbc.jpa.guice.JpaInitializer; import org.eclipse.che.api.core.rest.CheJsonProvider; import org.eclipse.che.api.core.rest.MessageBodyAdapter; import org.eclipse.che.api.core.rest.MessageBodyAdapterInterceptor; import org.eclipse.che.account.api.AccountModule; import org.eclipse.che.api.core.jdbc.jpa.eclipselink.EntityListenerInjectionManagerInitializer; -import org.eclipse.che.api.core.jdbc.jpa.guice.JpaInitializer; import org.eclipse.che.api.machine.server.jpa.MachineJpaModule; import org.eclipse.che.api.machine.shared.Constants; import org.eclipse.che.api.workspace.server.WorkspaceConfigMessageBodyAdapter; @@ -45,8 +45,8 @@ public class WsMasterModule extends AbstractModule { protected void configure() { install(new JpaPersistModule("main")); + bind(JpaInitializer.class).to(org.eclipse.che.api.core.h2.jdbc.jpa.guice.CheJpaInitializer.class).asEagerSingleton(); bind(CheUserCreator.class); - bind(JpaInitializer.class).asEagerSingleton(); bind(EntityListenerInjectionManagerInitializer.class).asEagerSingleton(); install(new UserJpaModule()); install(new SshJpaModule()); diff --git a/core/che-core-api-core/src/main/java/org/eclipse/che/api/core/ErrorCodes.java b/core/che-core-api-core/src/main/java/org/eclipse/che/api/core/ErrorCodes.java index 9f3460432796..c8d5177595fc 100644 --- a/core/che-core-api-core/src/main/java/org/eclipse/che/api/core/ErrorCodes.java +++ b/core/che-core-api-core/src/main/java/org/eclipse/che/api/core/ErrorCodes.java @@ -23,6 +23,7 @@ private ErrorCodes() { public static final int NO_COMMITTER_NAME_OR_EMAIL_DEFINED = 15216; public static final int UNABLE_GET_PRIVATE_SSH_KEY = 32068; public static final int UNAUTHORIZED_GIT_OPERATION = 32080; + public static final int UNAUTHORIZED_SVN_OPERATION = 32090; public static final int MERGE_CONFLICT = 32062; public static final int FAILED_CHECKOUT = 32063; public static final int FAILED_CHECKOUT_WITH_START_POINT = 32064; diff --git a/core/che-core-api-jdbc-vendor-h2/pom.xml b/core/che-core-api-jdbc-vendor-h2/pom.xml index 4ee9ad44260d..3ca9be616445 100644 --- a/core/che-core-api-jdbc-vendor-h2/pom.xml +++ b/core/che-core-api-jdbc-vendor-h2/pom.xml @@ -21,6 +21,14 @@ che-core-api-jdbc-vendor-h2 Che Core :: API :: JDBC Vendor H2 + + com.google.inject.extensions + guice-persist + + + javax.inject + javax.inject + org.eclipse.che.core che-core-api-jdbc diff --git a/core/che-core-api-jdbc-vendor-h2/src/main/java/org/eclipse/che/api/core/h2/jdbc/jpa/guice/CheJpaInitializer.java b/core/che-core-api-jdbc-vendor-h2/src/main/java/org/eclipse/che/api/core/h2/jdbc/jpa/guice/CheJpaInitializer.java new file mode 100644 index 000000000000..adba46d3bee4 --- /dev/null +++ b/core/che-core-api-jdbc-vendor-h2/src/main/java/org/eclipse/che/api/core/h2/jdbc/jpa/guice/CheJpaInitializer.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.api.core.h2.jdbc.jpa.guice; + +import com.google.inject.persist.PersistService; + +import org.eclipse.che.api.core.jdbc.jpa.guice.JpaInitializer; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; +import java.nio.file.Paths; + +/** + * Provides H2 specific initialization of persistent engine. + * + * @author Anton Korneta. + */ +@Singleton +public class CheJpaInitializer extends JpaInitializer { + + @Inject + @Named("che.conf.storage") + private String storageRoot; + + @Inject + @Override + public void init(PersistService persistService) { + System.setProperty("h2.baseDir", Paths.get(storageRoot).resolve("db").toString()); + super.init(persistService); + } +} diff --git a/core/che-core-api-jdbc/src/main/java/org/eclipse/che/api/core/jdbc/jpa/guice/JpaInitializer.java b/core/che-core-api-jdbc/src/main/java/org/eclipse/che/api/core/jdbc/jpa/guice/JpaInitializer.java index 9686210ba9a8..3eabba17ba34 100644 --- a/core/che-core-api-jdbc/src/main/java/org/eclipse/che/api/core/jdbc/jpa/guice/JpaInitializer.java +++ b/core/che-core-api-jdbc/src/main/java/org/eclipse/che/api/core/jdbc/jpa/guice/JpaInitializer.java @@ -11,6 +11,7 @@ package org.eclipse.che.api.core.jdbc.jpa.guice; import com.google.inject.Inject; +import com.google.inject.Singleton; import com.google.inject.persist.PersistService; /** @@ -18,11 +19,13 @@ * See doc * * @author Yevhenii Voevodin + * @author Anton Korneta */ +@Singleton public class JpaInitializer { @Inject - public JpaInitializer(PersistService persistService) { + public void init(PersistService persistService) { persistService.start(); } } diff --git a/core/che-core-typescript-dto-maven-plugin/pom.xml b/core/che-core-typescript-dto-maven-plugin/pom.xml index 773a34857ce0..2bd4d247c925 100644 --- a/core/che-core-typescript-dto-maven-plugin/pom.xml +++ b/core/che-core-typescript-dto-maven-plugin/pom.xml @@ -98,14 +98,70 @@ plexus-utils test + + org.eclipse.che.core + che-core-api-core + test + org.mockito mockito-all test + + org.slf4j + slf4j-api + test + + + org.testng + testng + test + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-it-test-source + process-resources + + add-test-source + + + + src/it/java + + + + + add-it-test-resources + process-resources + + add-test-resource + + + + + src/it/resources + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*ITest.java + + + org.apache.maven.plugins maven-plugin-plugin @@ -123,4 +179,50 @@ + + + integration-tests + + + !skipIntegrationTests + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + integration-test + + test + + + + ${project.build.directory} + + + none + + + **/*ITest.java + + + + + + + **/*ITest.java + + + + + + + + + + diff --git a/core/che-core-typescript-dto-maven-plugin/src/it/java/org/eclipse/che/plugin/typescript/dto/TypeScriptDTOGeneratorMojoITest.java b/core/che-core-typescript-dto-maven-plugin/src/it/java/org/eclipse/che/plugin/typescript/dto/TypeScriptDTOGeneratorMojoITest.java new file mode 100644 index 000000000000..f8f76e478d8b --- /dev/null +++ b/core/che-core-typescript-dto-maven-plugin/src/it/java/org/eclipse/che/plugin/typescript/dto/TypeScriptDTOGeneratorMojoITest.java @@ -0,0 +1,289 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.typescript.dto; + +import org.eclipse.che.api.core.util.SystemInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.stream.Stream; + +import static java.util.stream.Collectors.toList; + +/** + * Integration test of TypeScriptDTOGeneratorMojo + * It uses docker to launch TypeScript compiler and then launch JavaScript tests to ensure generator has worked correctly + * @author Florent Benoit + */ +public class TypeScriptDTOGeneratorMojoITest { + + /** + * Logger. + */ + private static final Logger LOG = LoggerFactory.getLogger(TypeScriptDTOGeneratorMojoITest.class); + + /** + * DTO Generated file + */ + private static final String GENERATED_DTO_NAME = "my-typescript-test-module.ts"; + + /** + * DTO new name + */ + private static final String DTO_FILENAME = "dto.ts"; + + /** + * DTO test name + */ + private static final String DTO_SPEC_FILENAME = "dto.spec.ts"; + + /** + * Target folder of maven. + */ + private Path buildDirectory; + + /** + * Path to the package.json file used to setup typescript compiler + */ + private Path dtoSpecJsonPath; + + /** + * Path to the package.json file used to setup typescript compiler + */ + private Path packageJsonPath; + + /** + * Root directory for our tests + */ + private Path rootPath; + + /** + * Linux uid. + */ + private String linuxUID; + + /** + * Linux gid. + */ + private String linuxGID; + + /** + * Init folders + */ + @BeforeClass + public void init() throws URISyntaxException, IOException, InterruptedException { + // setup packages + this.packageJsonPath = new File(TypeScriptDTOGeneratorMojoITest.class.getClassLoader().getResource("package.json").toURI()).toPath(); + + this.rootPath = this.packageJsonPath.getParent(); + + // target folder + String buildDirectoryProperty = System.getProperty("buildDirectory"); + if (buildDirectoryProperty != null) { + buildDirectory = new File(buildDirectoryProperty).toPath(); + } else { + buildDirectory = packageJsonPath.getParent().getParent(); + } + + LOG.info("Using building directory {0}", buildDirectory); + } + + /** + * Generates a docker exec command used to launch node commands + * @return list of command parameters + */ + protected List getDockerExec() { + // setup command line + List command = new ArrayList(); + command.add("docker"); + command.add("run"); + command.add("--rm"); + command.add("-v"); + command.add(rootPath.toString() + ":/usr/src/app"); + command.add("-w"); + command.add("/usr/src/app"); + command.add("node:6"); + command.add("/bin/sh"); + command.add("-c"); + + return command; + } + + /** + * Get UID of current user (used on Linux) + */ + protected String getUid() throws IOException, InterruptedException { + if (this.linuxUID == null) { + // grab user id + ProcessBuilder uidProcessBuilder = new ProcessBuilder("id", "-u"); + Process processId = uidProcessBuilder.start(); + int resultId = processId.waitFor(); + String uid = ""; + try (BufferedReader outReader = new BufferedReader(new InputStreamReader(processId.getInputStream()))) { + uid = String.join(System.lineSeparator(), outReader.lines().collect(toList())); + } catch (Exception error) { + throw new IllegalStateException("Unable to get uid" + uid); + } + + if (resultId != 0) { + throw new IllegalStateException("Unable to get uid" + uid); + } + + try { + Integer.valueOf(uid); + } catch (NumberFormatException e) { + throw new IllegalStateException("The uid is not a number" + uid); + } + this.linuxUID = uid; + } + + return this.linuxUID; + } + + /** + * Get GID of current user (used on Linux) + */ + protected String getGid() throws IOException, InterruptedException { + if (this.linuxGID == null) { + + ProcessBuilder gidProcessBuilder = new ProcessBuilder("id", "-g"); + Process processGid = gidProcessBuilder.start(); + int resultGid = processGid.waitFor(); + String gid = ""; + try (BufferedReader outReader = new BufferedReader(new InputStreamReader(processGid.getInputStream()))) { + gid = String.join(System.lineSeparator(), outReader.lines().collect(toList())); + } catch (Exception error) { + throw new IllegalStateException("Unable to get gid" + gid); + } + + if (resultGid != 0) { + throw new IllegalStateException("Unable to get gid" + gid); + } + + try { + Integer.valueOf(gid); + } catch (NumberFormatException e) { + throw new IllegalStateException("The uid is not a number" + gid); + } + + this.linuxGID = gid; + } + + return this.linuxGID; + } + + /** + * Setup typescript compiler by downloading the dependencies + * @throws IOException if unable to start process + * @throws InterruptedException if unable to wait the end of the process + */ + @Test(groups = {"tools"}) + protected void installTypeScriptCompiler() throws IOException, InterruptedException { + + // setup command line + List command = getDockerExec(); + + // avoid root permissions in generated files + if (SystemInfo.isLinux()) { + command.add(wrapLinuxCommand("npm install")); + } else { + command.add("npm install"); + } + + // setup typescript compiler + ProcessBuilder processBuilder = new ProcessBuilder().command(command).directory(rootPath.toFile()).redirectErrorStream(true).inheritIO(); + Process process = processBuilder.start(); + + LOG.info("Installing TypeScript compiler in {0}", rootPath); + int resultProcess = process.waitFor(); + + if (resultProcess != 0) { + throw new IllegalStateException("Install of TypeScript has failed"); + } + LOG.info("TypeScript compiler installed."); + + } + + + /** + * Wrap the given command into a command with chown. Also add group/user that match host environment if not exists + * @param command the command to wrap + * @return an updated command with chown applied on it + */ + protected String wrapLinuxCommand(String command) throws IOException, InterruptedException { + + String setGroup = "export GROUP_NAME=`(getent group " + getGid() + " || (groupadd -g " + getGid() + " user && echo user:x:" + getGid() +")) | cut -d: -f1`"; + String setUser = "export USER_NAME=`(getent passwd " + getUid() + " || (useradd -u " + getUid() + " -g ${GROUP_NAME} user && echo user:x:" + getGid() +")) | cut -d: -f1`"; + String chownCommand= "chown --silent -R ${USER_NAME}.${GROUP_NAME} /usr/src/app || true"; + return setGroup + " && " + setUser + " && " + chownCommand + " && " + command + " && " + chownCommand; + } + + + /** + * Starts tests by compiling first generated DTO from maven plugin + * @throws IOException if unable to start process + * @throws InterruptedException if unable to wait the end of the process + */ + @Test(dependsOnGroups = "tools") + public void compileDTOAndLaunchTests() throws IOException, InterruptedException { + + // search DTO + Path p = this.buildDirectory; + final int maxDepth = 10; + Stream matches = java.nio.file.Files.find(p, maxDepth, (path, basicFileAttributes) -> path.getFileName().toString().equals(GENERATED_DTO_NAME)); + + // take first + Optional optionalPath = matches.findFirst(); + if (!optionalPath.isPresent()) { + throw new IllegalStateException("Unable to find generated DTO file named '" + GENERATED_DTO_NAME + "'. Check it has been generated first"); + } + + Path generatedDtoPath = optionalPath.get(); + + //copy it in test resources folder where package.json is + java.nio.file.Files.copy(generatedDtoPath, this.rootPath.resolve(DTO_FILENAME), StandardCopyOption.REPLACE_EXISTING); + + // setup command line + List command = getDockerExec(); + + // avoid root permissions in generated files + if (SystemInfo.isLinux()) { + command.add(wrapLinuxCommand("npm test")); + } else { + command.add("npm test"); + } + // setup typescript compiler + ProcessBuilder processBuilder = new ProcessBuilder().command(command).directory(rootPath.toFile()).redirectErrorStream(true).inheritIO(); + Process process = processBuilder.start(); + + LOG.info("Starting TypeScript tests..."); + int resultProcess = process.waitFor(); + + if (resultProcess != 0) { + throw new IllegalStateException("DTO has failed to compile"); + } + LOG.info("TypeScript tests OK"); + + } + +} diff --git a/core/che-core-typescript-dto-maven-plugin/src/it/resources/dto.spec.ts b/core/che-core-typescript-dto-maven-plugin/src/it/resources/dto.spec.ts new file mode 100644 index 000000000000..e9be9d6278b2 --- /dev/null +++ b/core/che-core-typescript-dto-maven-plugin/src/it/resources/dto.spec.ts @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + */ +import {org} from './dto'; + +let expect = require('chai').expect; + +class DTOBuilder { + + static MY_CUSTOM_NAME : string = "myCustomName"; + static MY_CUSTOM_STATUS : string = "myCustomStatus"; + static MY_CUSTOM_MAP_ENTRY_NAME : string = "myEntry"; + + static MY_OTHER_NAME : string = "myOtherName"; + + static MY_SIMPLE_ID : number = 2503; + static MY_SIMPLE_BOOLEAN : boolean = true; + static MY_SIMPLE_DOUBLE : number = 19.79; + + + static buildSimpleDto() : org.eclipse.che.plugin.typescript.dto.MySimpleDTO { + let mySimpleDTO : org.eclipse.che.plugin.typescript.dto.MySimpleDTO = new org.eclipse.che.plugin.typescript.dto.MySimpleDTOImpl(); + mySimpleDTO.withId(DTOBuilder.MY_SIMPLE_ID).withBoolean(DTOBuilder.MY_SIMPLE_BOOLEAN).withDouble(DTOBuilder.MY_SIMPLE_DOUBLE); + return mySimpleDTO; + } + + static buildCustomDto() : org.eclipse.che.plugin.typescript.dto.MyCustomDTO { + let myCustomDTO : org.eclipse.che.plugin.typescript.dto.MyCustomDTO = new org.eclipse.che.plugin.typescript.dto.MyCustomDTOImpl(); + myCustomDTO.withName(DTOBuilder.MY_CUSTOM_NAME).withStatus(DTOBuilder.MY_CUSTOM_STATUS).withConfig(DTOBuilder.buildConfigDTO()); + myCustomDTO.getCustomMap().set(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME, DTOBuilder.buildConfigDTO()); + return myCustomDTO; + } + + static buildConfigDTO() : org.eclipse.che.plugin.typescript.dto.MyOtherDTO { + let configDTO : org.eclipse.che.plugin.typescript.dto.MyOtherDTO = new org.eclipse.che.plugin.typescript.dto.MyOtherDTOImpl(); + configDTO.withName(DTOBuilder.MY_OTHER_NAME); + return configDTO; + } + +} + +describe("DTO serialization tests", () => { + + + it("check simple DTO implementation", () => { + + let myCustomDTO : org.eclipse.che.plugin.typescript.dto.MySimpleDTO = DTOBuilder.buildSimpleDto(); + expect(myCustomDTO.getId()).to.eql(DTOBuilder.MY_SIMPLE_ID); + expect(myCustomDTO.getBoolean()).to.eql(DTOBuilder.MY_SIMPLE_BOOLEAN); + expect(myCustomDTO.getDouble()).to.eql(DTOBuilder.MY_SIMPLE_DOUBLE); + + }); + + + it("check build DTO implementation", () => { + + let myCustomDTO : org.eclipse.che.plugin.typescript.dto.MyCustomDTO = DTOBuilder.buildCustomDto(); + expect(myCustomDTO.getName()).to.eql(DTOBuilder.MY_CUSTOM_NAME); + expect(myCustomDTO.getStatus()).to.eql(DTOBuilder.MY_CUSTOM_STATUS); + expect(myCustomDTO.getConfig()).to.exist; + expect(myCustomDTO.getConfig().getName()).to.eql(DTOBuilder.MY_OTHER_NAME); + expect(myCustomDTO.getCustomMap().get(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME)).to.exist; + expect(myCustomDTO.getCustomMap().get(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME).getName()).to.eql(DTOBuilder.MY_OTHER_NAME); + + }); + + + it("check build DTO implementation", () => { + + let myCustomDTO : org.eclipse.che.plugin.typescript.dto.MyCustomDTO = DTOBuilder.buildCustomDto(); + expect(myCustomDTO.getName()).to.eql(DTOBuilder.MY_CUSTOM_NAME); + expect(myCustomDTO.getStatus()).to.eql(DTOBuilder.MY_CUSTOM_STATUS); + expect(myCustomDTO.getConfig()).to.exist; + expect(myCustomDTO.getConfig().getName()).to.eql(DTOBuilder.MY_OTHER_NAME); + expect(myCustomDTO.getCustomMap().get(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME)).to.exist; + expect(myCustomDTO.getCustomMap().get(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME).getName()).to.eql(DTOBuilder.MY_OTHER_NAME); + + }); + + + it("check build DTO implementation from source", () => { + let myCustomDTO : org.eclipse.che.plugin.typescript.dto.MyCustomDTO = DTOBuilder.buildCustomDto(); + + // build it from generated output + let myCustomDTOFromSource : org.eclipse.che.plugin.typescript.dto.MyCustomDTO = new org.eclipse.che.plugin.typescript.dto.MyCustomDTOImpl(myCustomDTO.toJson()); + + expect(myCustomDTO.getName()).to.eql(myCustomDTOFromSource.getName()); + expect(myCustomDTOFromSource.getConfig()).to.exist; + expect(myCustomDTO.getConfig().getName()).to.eql(myCustomDTOFromSource.getConfig().getName()); + expect(myCustomDTOFromSource.getCustomMap().get(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME)).to.exist; + expect(myCustomDTO.getCustomMap().get(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME).getName()).to.eql(myCustomDTOFromSource.getCustomMap().get(DTOBuilder.MY_CUSTOM_MAP_ENTRY_NAME).getName()); + + expect(myCustomDTO.toJson()).to.eql(myCustomDTOFromSource.toJson()); + }); + + + + +}); diff --git a/core/che-core-typescript-dto-maven-plugin/src/it/resources/package.json b/core/che-core-typescript-dto-maven-plugin/src/it/resources/package.json new file mode 100644 index 000000000000..240a81875831 --- /dev/null +++ b/core/che-core-typescript-dto-maven-plugin/src/it/resources/package.json @@ -0,0 +1,20 @@ +{ + "name": "che-typescript-maven-generator-integration-test", + "version": "1.0.0", + "description": "TypeScript integration test", + "author": "Florent Benoit", + "license": "EPL-1.0", + "scripts": { + "pretest": "./node_modules/.bin/tsc --target ES6 --outDir lib --module commonjs *.ts", + "test": "./node_modules/.bin/mocha lib/*.spec.js" + }, + "devDependencies": { + "chai": "3.5.0", + "mocha": "3.0.2", + "typescript": "2.0.3" + }, + "dependencies": { + "@types/mocha": "2.2.32", + "@types/node": "6.0.41" + } +} diff --git a/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/DTOHelper.java b/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/DTOHelper.java index eff766e3225a..0ec511bb271f 100644 --- a/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/DTOHelper.java +++ b/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/DTOHelper.java @@ -129,7 +129,7 @@ public static String convertType(Type type) { } else if (String.class.equals(type) || (type instanceof Class && ((Class)type).isEnum())) { // Maybe find a better enum type for typescript return "string"; - } else if (Integer.class.equals(type) || Integer.TYPE.equals(type) || Long.class.equals(type) || Long.TYPE.equals(type)) { + } else if (Integer.class.equals(type) || Integer.TYPE.equals(type) || Long.class.equals(type) || Long.TYPE.equals(type) || Double.class.equals(type) || Double.TYPE.equals(type)) { return "number"; } else if (Boolean.class.equals(type)) { return "boolean"; diff --git a/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/model/FieldAttributeModel.java b/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/model/FieldAttributeModel.java index 73a563f2eb17..8cc4f89ccffa 100644 --- a/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/model/FieldAttributeModel.java +++ b/core/che-core-typescript-dto-maven-plugin/src/main/java/org/eclipse/che/plugin/typescript/dto/model/FieldAttributeModel.java @@ -68,6 +68,11 @@ public class FieldAttributeModel { */ private boolean isListOfDto; + /** + * This map type is a map of DTOs + */ + private boolean isMapOfDto; + /** * The type is a DTO or a list of DTO and then this value is the name of the DTO implementation */ @@ -78,6 +83,10 @@ public class FieldAttributeModel { */ private boolean isDto; + /** + * type is a Enum object. + */ + private boolean isEnum; /** * Build a new field model based on the name and Java type @@ -105,6 +114,8 @@ public FieldAttributeModel(String fieldName, Type type) { } else if (this.type instanceof Class && ((Class)this.type).isAnnotationPresent(DTO.class)) { this.isDto = true; dtoImpl = this.type.getTypeName() + "Impl"; + } else if (this.type instanceof Class && ((Class)this.type).isEnum()) { + this.isEnum = true; } } @@ -124,6 +135,11 @@ protected void analyzeParametrizedType(ParameterizedType parameterizedType, Type } } else if (Map.class.equals(rawType)) { isMap = true; + if (parameterizedType.getActualTypeArguments()[1] instanceof Class && + ((Class)parameterizedType.getActualTypeArguments()[1]).isAnnotationPresent(DTO.class)) { + isMapOfDto = true; + dtoImpl = convertType(parameterizedType.getActualTypeArguments()[1]) + "Impl"; + } } } @@ -155,6 +171,10 @@ public boolean isListOfDto() { return isListOfDto; } + public boolean isMapOfDto() { + return isMapOfDto; + } + public String getDtoImpl() { return dtoImpl; } @@ -167,6 +187,10 @@ public boolean isNeedInitialize() { return needInitialize; } + public boolean isEnum() { + return isEnum; + } + public String getName() { return this.fieldName; } diff --git a/core/che-core-typescript-dto-maven-plugin/src/main/resources/org/eclipse/che/plugin/typescript/dto/typescript.template b/core/che-core-typescript-dto-maven-plugin/src/main/resources/org/eclipse/che/plugin/typescript/dto/typescript.template index 6db19b19dd97..1a8686fa5c59 100644 --- a/core/che-core-typescript-dto-maven-plugin/src/main/resources/org/eclipse/che/plugin/typescript/dto/typescript.template +++ b/core/che-core-typescript-dto-maven-plugin/src/main/resources/org/eclipse/che/plugin/typescript/dto/typescript.template @@ -12,6 +12,7 @@ export module { (,}>): ; }> + toJson() : any; \} \} @@ -37,30 +38,39 @@ export module { this. = new (); - if (__jsonObject.) { - - - __jsonObject..forEach((item) => { - - this..push(new (item)); - - this..push(item); + if (__jsonObject) { + if (__jsonObject.) { + + + __jsonObject..forEach((item) => { + + this..push(new (item)); + + this..push(item); + + \}); - \}); - - - - let tmp : Array\ = Object.keys(__jsonObject.); - tmp.forEach((key) => { - this..set(key, __jsonObject.[key]); - \}); - - - this. = __jsonObject.; - - - this. = new (__jsonObject.); - + + + let tmp : Array\ = Object.keys(__jsonObject.); + tmp.forEach((key) => { + + this..set(key, new (__jsonObject.[key])); + + this..set(key, __jsonObject.[key]); + + \}); + + + this. = __jsonObject.; + + + this. = __jsonObject.; + + + this. = new (__jsonObject.); + + \} \} }> \} @@ -76,18 +86,61 @@ export module { ( : ) : void { - this. = this.; + this. = ; \} ( : ) : { - this. = this.; + this. = ; return this; \} }> - \} + + toJson() : any { + let json : any = {\}; + + ) { + + + let listArray = []; + this..forEach((item) => { + + listArray.push((item as ).toJson()); + + listArray.push(item); + + json. = listArray; + \}); + + + + let tmpMap : any = {\}; + for (const [key, value] of this..entries()) { + + tmpMap[key] = (value as ).toJson(); + + tmpMap[key] = value; + + \} + json. = tmpMap; + + + json. = this.; + + + json. = this.; + + + json. = (this. as ).toJson(); + + \} + }> + return json; + \} + \} \} }> diff --git a/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyCustomDTO.java b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyCustomDTO.java index 7f1b1bca53cb..caf219174d93 100644 --- a/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyCustomDTO.java +++ b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyCustomDTO.java @@ -12,6 +12,8 @@ import org.eclipse.che.dto.shared.DTO; +import java.util.Map; + /** * @author Florent Benoit */ @@ -22,4 +24,16 @@ public interface MyCustomDTO { void setName(String name); MyCustomDTO withName(String name); + MyOtherDTO getConfig(); + MyCustomDTO withConfig(MyOtherDTO otherDTO); + void setConfig(MyOtherDTO otherDTO); + + void setStatus(Status status); + MyCustomDTO withStatus(Status status); + Status getStatus(); + + Map getCustomMap(); + void setCustomMap(Map map); + MyCustomDTO withCustomMap(Map map); + } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CurrentUserPreferencesAccess.java b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyOtherDTO.java similarity index 66% rename from plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CurrentUserPreferencesAccess.java rename to core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyOtherDTO.java index f03158bdba31..eb5a0780b891 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CurrentUserPreferencesAccess.java +++ b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MyOtherDTO.java @@ -8,12 +8,18 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.svn.server.credentials; +package org.eclipse.che.plugin.typescript.dto; +import org.eclipse.che.dto.shared.DTO; -public interface CurrentUserPreferencesAccess { +/** + * @author Florent Benoit + */ +@DTO +public interface MyOtherDTO { - void updatePreference(String key, String content) throws PreferencesAccessException; + String getName(); + void setName(String name); + MyOtherDTO withName(String name); - String getPreference(String key) throws PreferencesAccessException; } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/SaveCredentialsRequest.java b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MySimpleDTO.java similarity index 61% rename from plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/SaveCredentialsRequest.java rename to core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MySimpleDTO.java index 38b13436a06a..13443e53b4da 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/SaveCredentialsRequest.java +++ b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/MySimpleDTO.java @@ -8,22 +8,22 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.svn.shared; +package org.eclipse.che.plugin.typescript.dto; import org.eclipse.che.dto.shared.DTO; +/** + * @author Florent Benoit + */ @DTO -public interface SaveCredentialsRequest { +public interface MySimpleDTO { - String getUsername(); + int getId(); + MySimpleDTO withId(int id); - SaveCredentialsRequest withUsername(String username); + boolean getBoolean(); + MySimpleDTO withBoolean(boolean bool); - String getPassword(); - - SaveCredentialsRequest withPassword(String password); - - String getRepositoryUrl(); - - SaveCredentialsRequest withRepositoryUrl(String repositoryUrl); + double getDouble(); + MySimpleDTO withDouble(double d); } diff --git a/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/Status.java b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/Status.java new file mode 100644 index 000000000000..dbea6b60e27f --- /dev/null +++ b/core/che-core-typescript-dto-maven-plugin/src/test/java/org/eclipse/che/plugin/typescript/dto/Status.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.typescript.dto; + +/** + * @author Florent Benoit + */ +public enum Status { + + SHUTDOWN, + + ALIVE +} diff --git a/core/che-core-typescript-dto-maven-plugin/src/test/projects/project/pom.xml b/core/che-core-typescript-dto-maven-plugin/src/test/projects/project/pom.xml index 19b4abadf54a..1315d9fd4382 100644 --- a/core/che-core-typescript-dto-maven-plugin/src/test/projects/project/pom.xml +++ b/core/che-core-typescript-dto-maven-plugin/src/test/projects/project/pom.xml @@ -16,7 +16,7 @@ 4.0.0 org.eclipse.che.test - my-typescript-test-moddule + my-typescript-test-module 1.0-SNAPSHOT pom Test of Eclipse Che TypeScript plugin diff --git a/dashboard/.gitignore b/dashboard/.gitignore index 55ff2df0b810..1c93788306f8 100644 --- a/dashboard/.gitignore +++ b/dashboard/.gitignore @@ -23,3 +23,4 @@ docs target/ uE001-README.MD +typings/ diff --git a/dashboard/README.md b/dashboard/README.md index dfaa36e7ddf4..5844bb9a9dd7 100644 --- a/dashboard/README.md +++ b/dashboard/README.md @@ -5,8 +5,13 @@ Che Dashboard ============== #Requirements +- Node.js `v4.x.x` (`v5.x.x` / `v6.x.x` are currently not supported) +- npm +- Bower +- gulp + +Installation instructions for Node.js and npm can be found on the following [link](https://docs.npmjs.com/getting-started/installing-node). Bower and gulp are CLI utilities which are installed via npm: -This version is using bower and gulp as tools. ```sh $ npm install --global bower gulp ``` diff --git a/dashboard/package.json b/dashboard/package.json index 3002f789da04..abf5a4730eb2 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -58,6 +58,7 @@ "tsd": "~0.6.4", "tslint-loader": "~1.0.1", "typescript": "^1.8.10", + "typings": "^1.4.0", "uglify-save-license": "~0.4.1", "webpack": "^1.12.11", "webpack-stream": "~2.1.0", diff --git a/dashboard/src/app/stacks/list-stacks/list-stacks.controller.ts b/dashboard/src/app/stacks/list-stacks/list-stacks.controller.ts index dbdedb2e7343..94f84a1857cf 100644 --- a/dashboard/src/app/stacks/list-stacks/list-stacks.controller.ts +++ b/dashboard/src/app/stacks/list-stacks/list-stacks.controller.ts @@ -22,7 +22,7 @@ export class ListStacksController { * Default constructor that is using resource * @ngInject for Dependency injection */ - constructor(cheStack, $log, $mdDialog, cheNotification, $rootScope, lodash, $q) { + constructor(cheStack, cheProfile, $log, $mdDialog, cheNotification, $rootScope, lodash, $q) { this.cheStack = cheStack; this.$log = $log; this.$mdDialog = $mdDialog; @@ -40,7 +40,19 @@ export class ListStacksController { this.isNoSelected = true; this.stacks = []; - this.getStacks(); + + this.profile = cheProfile.getProfile(); + if (this.profile.userId) { + this.userId = this.profile.userId; + this.getStacks(); + } else { + this.profile.$promise.then(() => { + this.userId = this.profile.userId ? this.profile.userId : undefined; + this.getStacks(); + }, () => { + this.userId = undefined; + }); + } } /** diff --git a/dashboard/src/app/stacks/list-stacks/list-stacks.html b/dashboard/src/app/stacks/list-stacks/list-stacks.html index 462bdbf2a9e4..18c9eba7d7fa 100644 --- a/dashboard/src/app/stacks/list-stacks/list-stacks.html +++ b/dashboard/src/app/stacks/list-stacks/list-stacks.html @@ -66,7 +66,8 @@ che-on-checkbox-click="listStacksController.updateSelectionState()" che-on-delete="listStacksController.deleteStack(stack)" che-on-duplicate="listStacksController.duplicateStack(stack)" - che-stack="stack"> + stack="stack" + user-id="listStacksController.userId">
diff --git a/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.directive.ts b/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.directive.ts index 93f7cbaba27e..6d9fc5ff30d4 100644 --- a/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.directive.ts +++ b/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.directive.ts @@ -28,7 +28,8 @@ export class StackItem { // scope values this.scope = { - stack: '=cheStack', + stack: '=stack', + userId: '=userId', isSelectable: '=cheSelectable', isSelect: '=?ngModel', onCheckboxClick: '&?cheOnCheckboxClick', diff --git a/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.html b/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.html index 673b5aabbaeb..ed2b19d1f876 100644 --- a/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.html +++ b/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.html @@ -19,9 +19,10 @@ layout-align="start center" class="che-checkbox-area" ng-if="stackItemController.isSelectable === true"> - +
Actions - + diff --git a/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.styl b/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.styl index 9032b0b0d83c..e11ebbb1a627 100644 --- a/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.styl +++ b/dashboard/src/app/stacks/list-stacks/stack-item/stack-item.styl @@ -3,3 +3,7 @@ stack-item:last-child .che-list-item border-bottom none + +stack-item .che-list-actions a[disabled] + pointer-events none + opacity 0.5 diff --git a/dashboard/src/app/stacks/stack-details/stack.controller.ts b/dashboard/src/app/stacks/stack-details/stack.controller.ts index bc3165048094..60926f4f6dab 100644 --- a/dashboard/src/app/stacks/stack-details/stack.controller.ts +++ b/dashboard/src/app/stacks/stack-details/stack.controller.ts @@ -16,6 +16,27 @@ * @author Ann Shumilova */ export class StackController { + $log: ng.ILogService; + $filter: ng.IFilterService; + $timeout: ng.ITimeoutService; + $location: ng.ILocationService; + $mdDialog: angular.material.IDialogService; + + loading: boolean; + isLoading: boolean; + isCreation: boolean; + + stackId: string; + stackName: string; + stackContent: string; + invalidStack: string; + + stack: any; + editorOptions: any; + changesPromise: any; + + cheStack; + cheNotification; /** * Default constructor that is using resource injection @@ -57,14 +78,14 @@ export class StackController { * * @returns {{stack}} new stack template */ - getNewStackTemplate() { + getNewStackTemplate(): any { this.stackName = 'New Stack'; - let stack = {}; + let stack: any = {}; stack.name = this.stackName; stack.description = ''; stack.source = {}; stack.source.origin = ''; - stack.source.type = '' + stack.source.type = ''; stack.components = []; stack.tags = []; stack.workspaceConfig = {}; @@ -75,7 +96,7 @@ export class StackController { /** * Fetch the stack details. */ - fetchStack() { + fetchStack(): void { this.loading = true; this.stack = this.cheStack.getStackById(this.stackId); @@ -102,10 +123,36 @@ export class StackController { }); } + /** + * Handle stack's tag adding. + * + * @param tag {string} stack's tag + * @returns {string} tag if it is unique one, otherwise null + */ + handleTagAdding(tag: string): string { + //Prevents mentioning same tags twice: + if (this.stack.tags.includes(tag)) { + return null; + } + + return tag; + } + + /** + * Update stack's editor content. + */ + updateEditorContent(): void { + this.stackContent = this.$filter('json')(this.stack); + } + /** * Prepare data to be displayed. */ - prepareStackData() { + prepareStackData(): void { + if (!this.stack.tags) { + this.stack.tags = []; + } + delete this.stack.links; this.stackName = angular.copy(this.stack.name); this.stackContent = this.$filter('json')(this.stack); @@ -115,14 +162,14 @@ export class StackController { * Updates stack info. * @param isFormValid {Boolean} true if form is valid */ - updateStack(isFormValid) { + updateStack(isFormValid: boolean) { if (this.isCreation) { this.stack.name = this.stackName; - this.stackContent = this.$filter('json')(this.stack); + this.updateEditorContent(); return; } - this.stackContent = this.$filter('json')(this.stack); + this.updateEditorContent(); if (this.changesPromise) { this.$timeout.cancel(this.changesPromise); @@ -154,7 +201,7 @@ export class StackController { /** * Saves stack configuration - creates new one or updates existing. */ - saveStack() { + saveStack(): void { if (this.isCreation) { this.createStack(); return; @@ -176,7 +223,7 @@ export class StackController { /** * Creates new stack. */ - createStack() { + createStack(): void { this.cheStack.createStack(this.stackContent).then((stack) => { this.cheNotification.showInfo('Stack is successfully created.'); this.stack = stack; @@ -193,7 +240,7 @@ export class StackController { /** * Deletes current stack if user confirms. */ - deleteStack() { + deleteStack(): void { let confirmTitle = 'Would you like to delete ' + this.stack.name + '?'; let confirm = this.$mdDialog.confirm() diff --git a/dashboard/src/app/stacks/stack-details/stack.html b/dashboard/src/app/stacks/stack-details/stack.html index f21a6f435091..1d8b203a885d 100644 --- a/dashboard/src/app/stacks/stack-details/stack.html +++ b/dashboard/src/app/stacks/stack-details/stack.html @@ -47,6 +47,30 @@
+ + +
+ + +
{{$chip | uppercase}}
+
+ +
+
+
+
+
Reset
+
+
+
+
- - org.eclipse.che.core - che-core-api-model - org.eclipse.che.core che-core-api-project @@ -78,10 +74,6 @@ org.eclipse.che.core che-core-api-project-shared - - org.eclipse.che.core - che-core-api-workspace-shared - org.eclipse.che.core che-core-commons-inject @@ -132,10 +124,6 @@ org.eclipse.che.plugin maven-server-api - - org.eclipse.che.plugin - org.eclipse.core.filebuffers - org.eclipse.che.plugin org.eclipse.core.resources @@ -165,6 +153,16 @@ javax.websocket-api provided + + org.eclipse.che.core + che-core-api-model + provided + + + org.eclipse.che.core + che-core-api-workspace-shared + provided + ch.qos.logback logback-classic @@ -185,6 +183,11 @@ che-core-commons-test test + + org.eclipse.che.plugin + org.eclipse.core.filebuffers + test + org.hamcrest hamcrest-core diff --git a/plugins/plugin-maven/che-plugin-maven-server/src/test/java/org/eclipse/che/plugin/maven/server/BaseTest.java b/plugins/plugin-maven/che-plugin-maven-server/src/test/java/org/eclipse/che/plugin/maven/server/BaseTest.java index 1893d154067f..3648d18b758e 100644 --- a/plugins/plugin-maven/che-plugin-maven-server/src/test/java/org/eclipse/che/plugin/maven/server/BaseTest.java +++ b/plugins/plugin-maven/che-plugin-maven-server/src/test/java/org/eclipse/che/plugin/maven/server/BaseTest.java @@ -33,11 +33,11 @@ import org.eclipse.che.api.vfs.search.impl.FSLuceneSearcherProvider; import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; import org.eclipse.che.commons.lang.IoUtil; +import org.eclipse.che.jdt.core.resources.ResourceChangedEvent; import org.eclipse.che.plugin.java.server.projecttype.JavaProjectType; import org.eclipse.che.plugin.java.server.projecttype.JavaValueProviderFactory; import org.eclipse.che.plugin.maven.server.projecttype.MavenProjectType; import org.eclipse.che.plugin.maven.server.projecttype.MavenValueProviderFactory; -import org.eclipse.che.jdt.core.resources.ResourceChangedEvent; import org.eclipse.core.internal.filebuffers.FileBuffersPlugin; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.jdt.core.JavaCore; @@ -58,6 +58,7 @@ import java.util.Set; import static org.eclipse.che.plugin.maven.shared.MavenAttributes.MAVEN_ID; +import static org.mockito.Mockito.mock; /** * @author Evgen Vidolob @@ -87,7 +88,6 @@ public abstract class BaseTest { protected ProjectHandlerRegistry projectHandlerRegistry; protected ProjectImporterRegistry importerRegistry; protected MavenServerManager mavenServerManager; - protected ProjectTreeChangesDetector projectTreeChangesDetector; public BaseTest() { options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8); @@ -146,11 +146,10 @@ protected void initProjectApi() throws Exception { fileWatcherNotificationHandler = new DefaultFileWatcherNotificationHandler(vfsProvider); fileTreeWatcher = new FileTreeWatcher(root, new HashSet<>(), fileWatcherNotificationHandler); - projectTreeChangesDetector = new ProjectTreeChangesDetector(null); pm = new ProjectManager(vfsProvider, eventService, projectTypeRegistry, projectRegistry, projectHandlerRegistry, importerRegistry, fileWatcherNotificationHandler, fileTreeWatcher, new TestWorkspaceHolder(new ArrayList<>()), - projectTreeChangesDetector); + mock(ProjectTreeChangesDetector.class)); plugin = new ResourcesPlugin("target/index", wsPath, () -> projectRegistry, () -> pm); diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/pom.xml b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/pom.xml new file mode 100644 index 000000000000..f8aa51f66500 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/pom.xml @@ -0,0 +1,154 @@ + + + + 4.0.0 + + che-plugin-nodejs-debugger-parent + org.eclipse.che.plugin + 5.0.0-M5-SNAPSHOT + + che-plugin-nodejs-debugger-ide + jar + Che Plugin :: NodeJs Debugger :: IDE + + + com.google.guava + guava + + + com.google.gwt + gwt-elemental + + + com.google.gwt.inject + gin + + + com.google.inject + guice + + + javax.validation + validation-api + + + org.eclipse.che.core + che-core-api-project + + + org.eclipse.che.core + che-core-api-workspace + + + org.eclipse.che.core + che-core-commons-annotations + + + org.eclipse.che.core + che-core-commons-gwt + + + org.eclipse.che.core + che-core-ide-api + + + org.eclipse.che.core + che-core-ide-app + + + org.eclipse.che.core + che-core-ide-ui + + + org.eclipse.che.plugin + che-plugin-debugger-ide + + + org.vectomatic + lib-gwt-svg + + + com.google.gwt + gwt-user + provided + + + com.google.gwt + gwt-dev + test + + + com.google.gwt.gwtmockito + gwtmockito + test + + + com.googlecode.gwt-test-utils + gwt-test-utils + test + + + junit + junit + test + + + org.hamcrest + hamcrest-core + test + + + org.mockito + mockito-core + test + + + + + + src/main/java + + + src/main/resources + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + analyze + + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + com.mycila + license-maven-plugin + + + **/*.png + + + + + + diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebugger.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebugger.java new file mode 100644 index 000000000000..77065fe4bed1 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebugger.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide; + +import com.google.inject.Inject; +import com.google.web.bindery.event.shared.EventBus; + +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.ide.api.debug.BreakpointManager; +import org.eclipse.che.ide.api.debug.DebuggerServiceClient; +import org.eclipse.che.ide.api.resources.VirtualFile; +import org.eclipse.che.ide.debug.DebuggerDescriptor; +import org.eclipse.che.ide.debug.DebuggerManager; +import org.eclipse.che.ide.dto.DtoFactory; +import org.eclipse.che.ide.util.storage.LocalStorageProvider; +import org.eclipse.che.ide.websocket.MessageBusProvider; +import org.eclipse.che.plugin.debugger.ide.debug.AbstractDebugger; + +import javax.validation.constraints.NotNull; +import java.util.Map; + +/** + * The NodeJs Debugger Client. + * + * @author Anatoliy Bazko + */ +public class NodeJsDebugger extends AbstractDebugger { + + public static final String ID = "nodejsdbg"; + + @Inject + public NodeJsDebugger(DebuggerServiceClient service, + DtoFactory dtoFactory, + LocalStorageProvider localStorageProvider, + MessageBusProvider messageBusProvider, + EventBus eventBus, + NodeJsDebuggerFileHandler activeFileHandler, + DebuggerManager debuggerManager, + BreakpointManager breakpointManager) { + + super(service, + dtoFactory, + localStorageProvider, + messageBusProvider, + eventBus, + activeFileHandler, + debuggerManager, + breakpointManager, + ID); + } + + @Override + protected String fqnToPath(@NotNull Location location) { + return location.getResourcePath() == null ? location.getTarget() : location.getResourcePath(); + } + + @Override + protected String pathToFqn(VirtualFile file) { + return file.getLocation().toString(); + } + + @Override + protected DebuggerDescriptor toDescriptor(Map connectionProperties) { + StringBuilder sb = new StringBuilder(); + + for (String propName : connectionProperties.keySet()) { + try { + ConnectionProperties prop = ConnectionProperties.valueOf(propName.toUpperCase()); + String connectionInfo = prop.getConnectionInfo(connectionProperties.get(propName)); + if (!connectionInfo.isEmpty()) { + if (sb.length() > 0) { + sb.append(','); + } + sb.append(connectionInfo); + } + } catch (IllegalArgumentException ignored) { + // unrecognized connection property + } + } + + return new DebuggerDescriptor("", "{ " + sb.toString() + " }"); + } + + public enum ConnectionProperties { + SCRIPT { + @Override + public String getConnectionInfo(String value) { + return value; + } + }; + + public abstract String getConnectionInfo(String value); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerExtension.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerExtension.java new file mode 100644 index 000000000000..38fb9d92e863 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerExtension.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide; + +import com.google.inject.Inject; +import com.google.inject.Singleton; + +import org.eclipse.che.ide.api.extension.Extension; +import org.eclipse.che.ide.debug.DebuggerManager; + +/** + * Extension allows to debug NodeJs applications. + * + * @author Anatoliy Bazko + */ +@Singleton +@Extension(title = "NodeJs Debugger", version = "5.0.0") +public class NodeJsDebuggerExtension { + + @Inject + public NodeJsDebuggerExtension(DebuggerManager debuggerManager, NodeJsDebugger nodeJsDebugger) { + debuggerManager.registeredDebugger(NodeJsDebugger.ID, nodeJsDebugger); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerFileHandler.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerFileHandler.java new file mode 100644 index 000000000000..c42aad489fcf --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerFileHandler.java @@ -0,0 +1,193 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide; + +import com.google.common.base.Optional; +import com.google.gwt.user.client.Timer; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.inject.Inject; +import com.google.web.bindery.event.shared.EventBus; + +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.api.promises.client.Operation; +import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.PromiseError; +import org.eclipse.che.ide.api.app.AppContext; +import org.eclipse.che.ide.api.editor.EditorAgent; +import org.eclipse.che.ide.api.editor.EditorPartPresenter; +import org.eclipse.che.ide.api.editor.document.Document; +import org.eclipse.che.ide.api.editor.text.TextPosition; +import org.eclipse.che.ide.api.editor.texteditor.TextEditor; +import org.eclipse.che.ide.api.event.FileEvent; +import org.eclipse.che.ide.api.resources.File; +import org.eclipse.che.ide.api.resources.Project; +import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.resources.VirtualFile; +import org.eclipse.che.plugin.debugger.ide.debug.ActiveFileHandler; + +/** + * Responsible to open files in editor when debugger stopped at breakpoint. + * + * @author Anatoliy Bazko + */ +public class NodeJsDebuggerFileHandler implements ActiveFileHandler { + + private final EditorAgent editorAgent; + private final EventBus eventBus; + private final AppContext appContext; + + @Inject + public NodeJsDebuggerFileHandler(EditorAgent editorAgent, + EventBus eventBus, + AppContext appContext) { + this.editorAgent = editorAgent; + this.eventBus = eventBus; + this.appContext = appContext; + } + + @Override + public void openFile(final Location location, final AsyncCallback callback) { + final Resource resource = appContext.getResource(); + if (resource == null) { + callback.onFailure(new IllegalStateException("Resource is undefined")); + return; + } + final Optional project = resource.getRelatedProject(); + if (!project.isPresent()) { + callback.onFailure(new IllegalStateException("Project is undefined")); + return; + } + + findFileInProject(project.get(), location, callback); + } + + private void findFileInProject(final Project project, + final Location location, + final AsyncCallback callback) { + project.getFile(location.getTarget()).then(new Operation>() { + @Override + public void apply(Optional file) throws OperationException { + if (file.isPresent()) { + openFileInEditorAndScrollToLine(file.get(), callback, location.getLineNumber()); + callback.onSuccess(file.get()); + } else { + findFileInWorkspace(location, callback); + } + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError arg) throws OperationException { + callback.onFailure(new IllegalArgumentException("File not found." + arg.getMessage())); + } + }); + } + + private void findFileInWorkspace(final Location location, + final AsyncCallback callback) { + try { + appContext.getWorkspaceRoot().getFile(location.getTarget()).then(new Operation>() { + @Override + public void apply(Optional file) throws OperationException { + if (file.isPresent()) { + openFileInEditorAndScrollToLine(file.get(), callback, location.getLineNumber()); + callback.onSuccess(file.get()); + } else { + searchSource(location, callback); + } + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError arg) throws OperationException { + callback.onFailure(new IllegalArgumentException("File not found." + arg.getMessage())); + } + }); + } catch (IllegalStateException ignored) { + searchSource(location, callback); + } + } + + private void searchSource(final Location location, final AsyncCallback callback) { + appContext.getWorkspaceRoot().search(location.getTarget(), "").then(new Operation() { + @Override + public void apply(Resource[] resources) throws OperationException { + if (resources.length == 0) { + callback.onFailure(new IllegalArgumentException("File not found.")); + return; + } + + appContext.getWorkspaceRoot().getFile(resources[0].getLocation()).then(new Operation>() { + @Override + public void apply(Optional file) throws OperationException { + if (file.isPresent()) { + openFileInEditorAndScrollToLine(file.get(), callback, location.getLineNumber()); + callback.onSuccess(file.get()); + } else { + callback.onFailure(new IllegalArgumentException("File not found.")); + } + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError arg) throws OperationException { + callback.onFailure(new IllegalArgumentException("File not found. " + arg.getMessage())); + } + }); + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError arg) throws OperationException { + callback.onFailure(new IllegalArgumentException("File not found. " + arg.getMessage())); + } + }); + } + + private void openFileInEditorAndScrollToLine(final VirtualFile virtualFile, + final AsyncCallback callback, + final int scrollToLine) { + editorAgent.openEditor(virtualFile, new EditorAgent.OpenEditorCallback() { + @Override + public void onEditorOpened(EditorPartPresenter editor) { + new Timer() { + @Override + public void run() { + scrollEditorToExecutionPoint((TextEditor)editorAgent.getActiveEditor(), scrollToLine); + callback.onSuccess(virtualFile); + } + }.schedule(300); + } + + @Override + public void onEditorActivated(EditorPartPresenter editor) { + new Timer() { + @Override + public void run() { + scrollEditorToExecutionPoint((TextEditor)editorAgent.getActiveEditor(), scrollToLine); + callback.onSuccess(virtualFile); + } + }.schedule(300); + } + + @Override + public void onInitializationFailed() { + callback.onFailure(null); + } + }); + + eventBus.fireEvent(FileEvent.createOpenFileEvent(virtualFile)); + } + + private void scrollEditorToExecutionPoint(TextEditor editor, int lineNumber) { + Document document = editor.getDocument(); + if (document != null) { + TextPosition newPosition = new TextPosition(lineNumber, 0); + document.setCursorPosition(newPosition); + } + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerGinModule.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerGinModule.java new file mode 100644 index 000000000000..aff1d4023196 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerGinModule.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide; + +import com.google.gwt.inject.client.AbstractGinModule; +import com.google.gwt.inject.client.multibindings.GinMultibinder; +import com.google.inject.Singleton; + +import org.eclipse.che.ide.api.debug.DebugConfigurationType; +import org.eclipse.che.ide.api.extension.ExtensionGinModule; +import org.eclipse.che.plugin.nodejsdbg.ide.configuration.NodeJsDebuggerConfigurationPageView; +import org.eclipse.che.plugin.nodejsdbg.ide.configuration.NodeJsDebuggerConfigurationPageViewImpl; +import org.eclipse.che.plugin.nodejsdbg.ide.configuration.NodeJsDebuggerConfigurationType; + +/** + * @author Anatolii Bazko + */ +@ExtensionGinModule +public class NodeJsDebuggerGinModule extends AbstractGinModule { + @Override + protected void configure() { + GinMultibinder.newSetBinder(binder(), DebugConfigurationType.class).addBinding().to(NodeJsDebuggerConfigurationType.class); + bind(NodeJsDebuggerConfigurationPageView.class).to(NodeJsDebuggerConfigurationPageViewImpl.class).in(Singleton.class); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerLocalizationConstant.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerLocalizationConstant.java new file mode 100644 index 000000000000..2602a012a51a --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerLocalizationConstant.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide; + +import com.google.gwt.i18n.client.Messages; + +/** + * I18n constants for the Debugger extension. + * + * @author Anatolii Bazko + */ +public interface NodeJsDebuggerLocalizationConstant extends Messages { + + @Key("view.nodeJsDebuggerConfigurationPage.hostLabel") + String nodeJsDebuggerConfigurationPageViewHostLabel(); + + @Key("view.nodeJsDebuggerConfigurationPage.portLabel") + String nodeJsDebuggerConfigurationPageViewPortLabel(); + + @Key("view.nodeJsDebuggerConfigurationPage.scriptLabel") + String nodeJsDebuggerConfigurationPageViewScriptLabel(); + + @Key("view.nodeJsDebuggerConfigurationPage.pidLabel") + String nodeJsDebuggerConfigurationPageViewPidLable(); +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerResources.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerResources.java new file mode 100644 index 000000000000..f4bb9f81a9cb --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerResources.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide; + +import com.google.gwt.resources.client.ClientBundle; + +import org.vectomatic.dom.svg.ui.SVGResource; + +/** + * @author Anatolii Bazko + */ +public interface NodeJsDebuggerResources extends ClientBundle { + + /** Returns the icon for NodeJs debugger configurations. */ + @Source("configuration/nodejs-debugger-configuration-type.svg") + SVGResource nodeJsDebugConfigurationType(); +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenter.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenter.java new file mode 100644 index 000000000000..20e2a02c3a65 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenter.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide.configuration; + +import com.google.gwt.user.client.ui.AcceptsOneWidget; +import com.google.inject.Inject; +import com.google.inject.Singleton; + +import org.eclipse.che.ide.api.debug.DebugConfiguration; +import org.eclipse.che.ide.api.debug.DebugConfigurationPage; +import org.eclipse.che.ide.extension.machine.client.command.valueproviders.CurrentProjectPathProvider; + +import java.util.Map; + +import static org.eclipse.che.plugin.nodejsdbg.ide.NodeJsDebugger.ConnectionProperties.SCRIPT; + +/** + * Page allows to edit NodeJs debug configuration. + * + * @author Anatolii Bazko + */ +@Singleton +public class NodeJsDebuggerConfigurationPagePresenter implements NodeJsDebuggerConfigurationPageView.ActionDelegate, + DebugConfigurationPage { + + private static final String DEFAULT_SCRIPT_NAME = "app.js"; + + private final NodeJsDebuggerConfigurationPageView view; + private final CurrentProjectPathProvider currentProjectPathProvider; + + private DebugConfiguration editedConfiguration; + private String originScriptPath; + private DirtyStateListener listener; + + @Inject + public NodeJsDebuggerConfigurationPagePresenter(NodeJsDebuggerConfigurationPageView view, + CurrentProjectPathProvider currentProjectPathProvider) { + this.view = view; + this.currentProjectPathProvider = currentProjectPathProvider; + + view.setDelegate(this); + } + + @Override + public void resetFrom(DebugConfiguration configuration) { + editedConfiguration = configuration; + originScriptPath = getScriptPath(configuration); + + if (originScriptPath == null) { + String defaultBinaryPath = getDefaultBinaryPath(); + editedConfiguration.getConnectionProperties().put(SCRIPT.toString(), defaultBinaryPath); + originScriptPath = defaultBinaryPath; + } + } + + private String getScriptPath(DebugConfiguration debugConfiguration) { + Map connectionProperties = debugConfiguration.getConnectionProperties(); + return connectionProperties.get(SCRIPT.toString()); + } + + private String getDefaultBinaryPath() { + return currentProjectPathProvider.getKey() + "/" + DEFAULT_SCRIPT_NAME; + } + + @Override + public void go(AcceptsOneWidget container) { + container.setWidget(view); + view.setScriptPath(getScriptPath(editedConfiguration)); + } + + @Override + public boolean isDirty() { + return !originScriptPath.equals(getScriptPath(editedConfiguration)); + } + + @Override + public void setDirtyStateListener(DirtyStateListener listener) { + this.listener = listener; + } + + @Override + public void onScriptPathChanged() { + final Map connectionProperties = editedConfiguration.getConnectionProperties(); + connectionProperties.put(SCRIPT.toString(), view.getScriptPath()); + + editedConfiguration.setConnectionProperties(connectionProperties); + listener.onDirtyStateChanged(); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageView.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageView.java new file mode 100644 index 000000000000..4cd89cfce7a7 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageView.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide.configuration; + +import org.eclipse.che.ide.api.mvp.View; + +/** + * The view of {@link NodeJsDebuggerConfigurationPagePresenter}. + * + * @author Anatolii Bazko + */ +public interface NodeJsDebuggerConfigurationPageView extends View { + + /** Returns path to the binary. */ + String getScriptPath(); + + /** Sets path to the binary. */ + void setScriptPath(String path); + + /** Action handler for the view's controls. */ + interface ActionDelegate { + + /** Called when 'Binary Path' has been changed. */ + void onScriptPathChanged(); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageViewImpl.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageViewImpl.java new file mode 100644 index 000000000000..e92360e6b352 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageViewImpl.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide.configuration; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.KeyUpEvent; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.uibinder.client.UiHandler; +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.TextBox; +import com.google.gwt.user.client.ui.Widget; + +/** + * The implementation of {@link NodeJsDebuggerConfigurationPageView}. + * + * @author Anatolii Bazko + */ +public class NodeJsDebuggerConfigurationPageViewImpl implements NodeJsDebuggerConfigurationPageView { + + private static final NodeJsDebugConfigurationPageViewImplUiBinder UI_BINDER = + GWT.create(NodeJsDebugConfigurationPageViewImplUiBinder.class); + + private final FlowPanel rootElement; + + @UiField + TextBox scriptPath; + + private ActionDelegate delegate; + + public NodeJsDebuggerConfigurationPageViewImpl() { + rootElement = UI_BINDER.createAndBindUi(this); + } + + @Override + public void setDelegate(ActionDelegate delegate) { + this.delegate = delegate; + } + + @Override + public Widget asWidget() { + return rootElement; + } + + @Override + public String getScriptPath() { + return scriptPath.getValue(); + } + + @Override + public void setScriptPath(String path) { + this.scriptPath.setValue(path); + } + + @UiHandler({"scriptPath"}) + void onScriptPathKeyUp(KeyUpEvent event) { + delegate.onScriptPathChanged(); + } + + interface NodeJsDebugConfigurationPageViewImplUiBinder extends UiBinder { + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageViewImpl.ui.xml b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageViewImpl.ui.xml new file mode 100644 index 000000000000..96e69e705f6f --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPageViewImpl.ui.xml @@ -0,0 +1,21 @@ + + + + + + + + + diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationType.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationType.java new file mode 100644 index 000000000000..14a12579f654 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationType.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide.configuration; + +import com.google.inject.Inject; +import com.google.inject.Singleton; + +import org.eclipse.che.ide.api.debug.DebugConfiguration; +import org.eclipse.che.ide.api.debug.DebugConfigurationPage; +import org.eclipse.che.ide.api.debug.DebugConfigurationType; +import org.eclipse.che.ide.api.icon.Icon; +import org.eclipse.che.ide.api.icon.IconRegistry; +import org.eclipse.che.plugin.nodejsdbg.ide.NodeJsDebugger; +import org.eclipse.che.plugin.nodejsdbg.ide.NodeJsDebuggerResources; + +/** + * NodeJs debug configuration type. + * + * @author Anatolii Bazko + */ +@Singleton +public class NodeJsDebuggerConfigurationType implements DebugConfigurationType { + + public static final String DISPLAY_NAME = "NodeJs"; + + private final NodeJsDebuggerConfigurationPagePresenter page; + + @Inject + public NodeJsDebuggerConfigurationType(NodeJsDebuggerConfigurationPagePresenter page, + IconRegistry iconRegistry, + NodeJsDebuggerResources resources) { + this.page = page; + iconRegistry.registerIcon(new Icon(NodeJsDebugger.ID + ".debug.configuration.type.icon", resources.nodeJsDebugConfigurationType())); + } + + @Override + public String getId() { + return NodeJsDebugger.ID; + } + + @Override + public String getDisplayName() { + return DISPLAY_NAME; + } + + @Override + public DebugConfigurationPage getConfigurationPage() { + return page; + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/NodeJsDebugger.gwt.xml b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/NodeJsDebugger.gwt.xml new file mode 100644 index 000000000000..8b761f90ffad --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/NodeJsDebugger.gwt.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerLocalizationConstant.properties b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerLocalizationConstant.properties new file mode 100644 index 000000000000..c80fa2b8c6c1 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/ide/NodeJsDebuggerLocalizationConstant.properties @@ -0,0 +1,16 @@ +# +# Copyright (c) 2012-2016 Codenvy, S.A. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Codenvy, S.A. - initial API and implementation +# + +# NodeJsDebuggerConfigurationPage +view.nodeJsDebuggerConfigurationPage.hostLabel=Host +view.nodeJsDebuggerConfigurationPage.portLabel=Port +view.nodeJsDebuggerConfigurationPage.pidLabel=PID +view.nodeJsDebuggerConfigurationPage.scriptLabel=Script diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/ide/configuration/nodejs-debugger-configuration-type.svg b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/ide/configuration/nodejs-debugger-configuration-type.svg new file mode 100644 index 000000000000..41ad226705ff --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/main/resources/org/eclipse/che/plugin/nodejsdbg/ide/configuration/nodejs-debugger-configuration-type.svg @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenterTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenterTest.java new file mode 100644 index 000000000000..217af9391263 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationPagePresenterTest.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide.configuration; + +import com.google.gwt.user.client.ui.AcceptsOneWidget; + +import org.eclipse.che.ide.api.app.AppContext; +import org.eclipse.che.ide.api.debug.DebugConfiguration; +import org.eclipse.che.ide.api.debug.DebugConfigurationPage; +import org.eclipse.che.ide.api.machine.MachineServiceClient; +import org.eclipse.che.ide.api.machine.RecipeServiceClient; +import org.eclipse.che.ide.extension.machine.client.command.valueproviders.CurrentProjectPathProvider; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; + +import java.util.Map; + +import static org.eclipse.che.plugin.nodejsdbg.ide.NodeJsDebugger.ConnectionProperties.SCRIPT; +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +/** @author Artem Zatsarynnyi */ +@RunWith(MockitoJUnitRunner.class) +public class NodeJsDebuggerConfigurationPagePresenterTest { + + private static final String HOST = "localhost"; + private static final int PORT = 8000; + + @Mock + private NodeJsDebuggerConfigurationPageView pageView; + @Mock + private DebugConfiguration configuration; + @Mock + private CurrentProjectPathProvider currentProjectPathProvider; + @Mock + private AppContext appContext; + @Mock + private RecipeServiceClient recipeServiceClient; + @Mock + private MachineServiceClient machineServiceClient; + + @InjectMocks + private NodeJsDebuggerConfigurationPagePresenter pagePresenter; + + @Before + public void setUp() { + when(configuration.getHost()).thenReturn(HOST); + when(configuration.getPort()).thenReturn(PORT); + + pagePresenter.resetFrom(configuration); + } + + @Test + public void testResetting() throws Exception { + verify(configuration, atLeastOnce()).getConnectionProperties(); + verify(currentProjectPathProvider).getKey(); + } + + @Test + public void testGo() throws Exception { + AcceptsOneWidget container = Mockito.mock(AcceptsOneWidget.class); + + pagePresenter.go(container); + + verify(container).setWidget(eq(pageView)); + verify(configuration, atLeastOnce()).getConnectionProperties(); + verify(pageView).setScriptPath(anyString()); + } + + @Test + public void testOnBinaryPathChanged() throws Exception { + String binPath = "/path"; + when(pageView.getScriptPath()).thenReturn(binPath); + + final DebugConfigurationPage.DirtyStateListener listener = mock(DebugConfigurationPage.DirtyStateListener.class); + pagePresenter.setDirtyStateListener(listener); + + pagePresenter.onScriptPathChanged(); + + verify(pageView).getScriptPath(); + ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(Map.class); + + verify(configuration).setConnectionProperties(argumentCaptor.capture()); + Map argumentCaptorValue = argumentCaptor.getValue(); + assertEquals(binPath, argumentCaptorValue.get(SCRIPT.toString())); + + verify(listener).onDirtyStateChanged(); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationTypeTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationTypeTest.java new file mode 100644 index 000000000000..72e71ba271be --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/java/org/eclipse/che/plugin/nodejsdbg/ide/configuration/NodeJsDebuggerConfigurationTypeTest.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.ide.configuration; + +import com.google.gwtmockito.GwtMockitoTestRunner; + +import org.eclipse.che.ide.api.debug.DebugConfiguration; +import org.eclipse.che.ide.api.debug.DebugConfigurationPage; +import org.eclipse.che.ide.api.icon.IconRegistry; +import org.eclipse.che.plugin.nodejsdbg.ide.NodeJsDebugger; +import org.eclipse.che.plugin.nodejsdbg.ide.NodeJsDebuggerResources; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +import static org.junit.Assert.assertEquals; + +/** @author Anatolii Bazko */ +@RunWith(GwtMockitoTestRunner.class) +public class NodeJsDebuggerConfigurationTypeTest { + + @Mock + private NodeJsDebuggerResources resources; + @Mock + private NodeJsDebuggerConfigurationPagePresenter nodeJsDebuggerConfigurationPagePresenter; + @Mock + private IconRegistry iconRegistry; + + @InjectMocks + private NodeJsDebuggerConfigurationType nodeJsDebuggerConfigurationType; + + @Test + public void testGetId() throws Exception { + final String id = nodeJsDebuggerConfigurationType.getId(); + + assertEquals(NodeJsDebugger.ID, id); + } + + @Test + public void testGetDisplayName() throws Exception { + final String displayName = nodeJsDebuggerConfigurationType.getDisplayName(); + + assertEquals(NodeJsDebuggerConfigurationType.DISPLAY_NAME, displayName); + } + + @Test + public void testGetConfigurationPage() throws Exception { + final DebugConfigurationPage page = nodeJsDebuggerConfigurationType.getConfigurationPage(); + + assertEquals(nodeJsDebuggerConfigurationPagePresenter, page); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/resources/logback-test.xml b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/resources/logback-test.xml new file mode 100644 index 000000000000..e8898502279e --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/src/test/resources/logback-test.xml @@ -0,0 +1,26 @@ + + + + + + + %-41(%date[%.15thread]) %-45([%-5level] [%.30logger{30} %L]) - %msg%n + + + + + + + + diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/pom.xml b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/pom.xml new file mode 100644 index 000000000000..77112c8d7133 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/pom.xml @@ -0,0 +1,117 @@ + + + + 4.0.0 + + che-plugin-nodejs-debugger-parent + org.eclipse.che.plugin + 5.0.0-M5-SNAPSHOT + + che-plugin-nodejs-debugger-server + jar + Che Plugin :: NodeJs Debugger :: Server + + + com.google.code.gson + gson + + + com.google.guava + guava + + + com.google.inject + guice + + + com.google.inject.extensions + guice-multibindings + + + org.eclipse.che.core + che-core-api-debug + + + org.eclipse.che.core + che-core-api-debug-shared + + + org.eclipse.che.core + che-core-commons-annotations + + + org.eclipse.che.core + che-core-commons-inject + + + org.eclipse.che.core + che-core-commons-lang + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + test + + + org.mockito + mockito-all + test + + + org.testng + testng + test + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + com.mycila + license-maven-plugin + + + **/*.js + + + + + + + + nodejs-debugger-tests + + + + org.apache.maven.plugins + maven-surefire-plugin + + false + + + + + + + diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebugProcess.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebugProcess.java new file mode 100644 index 000000000000..7e6e56a26741 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebugProcess.java @@ -0,0 +1,248 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +import com.google.common.util.concurrent.ThreadFactoryBuilder; + +import org.eclipse.che.commons.lang.IoUtil; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import static java.lang.Math.min; + +/** + * Wrapper over NodeJs process is being run. + * Communication is performed through standard input/output streams. + * + * @author Anatoliy Bazko + */ +public class NodeJsDebugProcess implements NodeJsProcessObservable { + private static final Logger LOG = LoggerFactory.getLogger(NodeJsDebugProcess.class); + private static final int MAX_OUTPUT = 4096; + + private static final String NODEJS_COMMAND = detectNodeJsCommand(); + + private final Process process; + private final String outputSeparator; + private final ScheduledExecutorService executor; + private final BufferedWriter processWriter; + + private final List observers; + + private NodeJsDebugProcess(String outputSeparator, String... options) throws NodeJsDebuggerException { + this.observers = new CopyOnWriteArrayList<>(); + this.outputSeparator = outputSeparator; + + List commands = new ArrayList<>(1 + options.length); + commands.add(NODEJS_COMMAND); + commands.addAll(Arrays.asList(options)); + + ProcessBuilder processBuilder = new ProcessBuilder(commands); + try { + process = processBuilder.start(); + } catch (IOException e) { + throw new NodeJsDebuggerException("NodeJs process failed.", e); + } + + processWriter = new BufferedWriter(new OutputStreamWriter(process.getOutputStream())); + + executor = Executors.newScheduledThreadPool(1, new ThreadFactoryBuilder().setNameFormat("nodejs-debugger-%d") + .setDaemon(true) + .build()); + executor.scheduleWithFixedDelay(new OutputReader(), 0, 100, TimeUnit.MILLISECONDS); + } + + public static NodeJsDebugProcess start(String file) throws NodeJsDebuggerException { + return new NodeJsDebugProcess("debug> ", "debug", "--debug-brk", file); + } + + @Override + public void addObserver(NodeJsProcessObserver observer) { + observers.add(observer); + } + + @Override + public void removeObserver(NodeJsProcessObserver observer) { + observers.remove(observer); + } + + /** + * Stops process. + */ + void stop() { + try { + send("quit"); + } catch (NodeJsDebuggerException e) { + LOG.warn(e.getMessage()); + } + + executor.shutdown(); + try { + if (!executor.awaitTermination(10, TimeUnit.SECONDS)) { + executor.shutdownNow(); + if (!executor.awaitTermination(10, TimeUnit.SECONDS)) { + LOG.warn("Unable to terminate main pool"); + } + } + } catch (InterruptedException e) { + LOG.warn(e.getMessage()); + } + + + process.destroy(); + try { + if (!process.waitFor(10, TimeUnit.SECONDS)) { + LOG.error("Unable to terminate NodeJs"); + } + } catch (InterruptedException e) { + LOG.warn(e.getMessage()); + } + + try { + processWriter.close(); + } catch (IOException e) { + LOG.warn("Failed to close NodeJs process output stream", e); + } + observers.clear(); + } + + public synchronized void send(String command) throws NodeJsDebuggerException { + LOG.debug("Execute: {}", command); + + if (!process.isAlive()) { + throw new NodeJsDebuggerTerminatedException("NodeJs process is terminated."); + } + + try { + processWriter.write(command); + processWriter.newLine(); + processWriter.flush(); + } catch (IOException e) { + LOG.error(String.format("Command execution <%s> failed", command), e); + } + } + + + /** + * Continuously reads process output and store in the {@code #outputs}. + */ + private class OutputReader implements Runnable { + private final StringBuffer outputBuffer; + + public OutputReader() { + this.outputBuffer = new StringBuffer(); + } + + @Override + public void run() { + try { + InputStream in = getInput(); + if (in != null) { + String outputData = read(in); + if (!outputData.isEmpty()) { + outputBuffer.append(outputData); + if (outputBuffer.length() > MAX_OUTPUT) { + outputBuffer.delete(0, outputBuffer.length() - MAX_OUTPUT); + } + + extractOutputs(); + } + } + } catch (IOException e) { + LOG.error(e.getMessage(), e); + } + } + + private InputStream getInput() throws IOException { + return hasError() ? process.getErrorStream() + : (hasInput() ? (hasError() ? process.getErrorStream() + : process.getInputStream()) + : null); + } + + private void extractOutputs() { + int indexOf; + while ((indexOf = outputBuffer.indexOf(outputSeparator)) >= 0) { + NodeJsOutput nodeJsOutput = NodeJsOutput.of(outputBuffer.substring(0, indexOf)); + outputBuffer.delete(0, indexOf + outputSeparator.length()); + + notifyObservers(nodeJsOutput); + } + } + + private boolean hasError() throws IOException { + return process.getErrorStream().available() != 0; + } + + private boolean hasInput() throws IOException { + return process.getInputStream().available() != 0; + } + + private String read(InputStream in) throws IOException { + int available = min(in.available(), MAX_OUTPUT); + byte[] buf = new byte[available]; + int read = in.read(buf, 0, available); + + return new String(buf, 0, read, StandardCharsets.UTF_8); + } + } + + private void notifyObservers(NodeJsOutput nodeJsOutput) { + LOG.debug("{}{}", outputSeparator, nodeJsOutput.getOutput()); + + for (NodeJsProcessObserver observer : observers) { + try { + if (observer.onOutputProduced(nodeJsOutput)) { + break; + } + } catch (NodeJsDebuggerException e) { + LOG.error(e.getMessage(), e); + } + } + } + + /** + * Returns NodeJs command to run: either {@code nodejs} or {@code node}. + */ + private static String detectNodeJsCommand() { + String detectionCommand = "if command -v nodejs >/dev/null 2>&1; then echo -n 'nodejs'; else echo -n 'node'; fi"; + ProcessBuilder builder = new ProcessBuilder("sh", "-c", detectionCommand); + + try { + Process process = builder.start(); + int resultCode = process.waitFor(); + if (resultCode != 0) { + String errMsg = IoUtil.readAndCloseQuietly(process.getErrorStream()); + throw new IllegalStateException("NodeJs not found. " + errMsg); + } + + return IoUtil.readAndCloseQuietly(process.getInputStream()); + } catch (IOException | InterruptedException e) { + throw new IllegalStateException("NodeJs not found", e); + } + } + +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebugger.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebugger.java new file mode 100644 index 000000000000..960e8baeff95 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebugger.java @@ -0,0 +1,309 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +import org.eclipse.che.api.debug.shared.model.Breakpoint; +import org.eclipse.che.api.debug.shared.model.DebuggerInfo; +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.api.debug.shared.model.SimpleValue; +import org.eclipse.che.api.debug.shared.model.StackFrameDump; +import org.eclipse.che.api.debug.shared.model.Variable; +import org.eclipse.che.api.debug.shared.model.VariablePath; +import org.eclipse.che.api.debug.shared.model.action.ResumeAction; +import org.eclipse.che.api.debug.shared.model.action.StartAction; +import org.eclipse.che.api.debug.shared.model.action.StepIntoAction; +import org.eclipse.che.api.debug.shared.model.action.StepOutAction; +import org.eclipse.che.api.debug.shared.model.action.StepOverAction; +import org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl; +import org.eclipse.che.api.debug.shared.model.impl.DebuggerInfoImpl; +import org.eclipse.che.api.debug.shared.model.impl.SimpleValueImpl; +import org.eclipse.che.api.debug.shared.model.impl.StackFrameDumpImpl; +import org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl; +import org.eclipse.che.api.debug.shared.model.impl.event.DisconnectEventImpl; +import org.eclipse.che.api.debug.shared.model.impl.event.SuspendEventImpl; +import org.eclipse.che.api.debugger.server.Debugger; +import org.eclipse.che.api.debugger.server.exceptions.DebuggerException; +import org.eclipse.che.commons.annotation.Nullable; +import org.eclipse.che.plugin.nodejsdbg.server.command.NodeJsDebugCommandsLibrary; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.URI; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.regex.Pattern; + +/** + * Server side NodeJs debugger. + * + * @author Anatoliy Bazko + */ +public class NodeJsDebugger implements Debugger { + private static final Logger LOG = LoggerFactory.getLogger(NodeJsDebugger.class); + + private final Integer pid; + private final URI uri; + private final String name; + private final String version; + private final String script; + + private final NodeJsDebugProcess nodeJsDebugProcess; + private final DebuggerCallback debuggerCallback; + private final NodeJsDebugCommandsLibrary library; + private final Set pendingBreakpoints; + + NodeJsDebugger(@Nullable Integer pid, + @Nullable URI uri, + @Nullable String script, + NodeJsDebugProcess nodeJsDebugProcess, + DebuggerCallback debuggerCallback) throws NodeJsDebuggerException { + this.pid = pid; + this.uri = uri; + this.script = script; + this.nodeJsDebugProcess = nodeJsDebugProcess; + this.library = new NodeJsDebugCommandsLibrary(nodeJsDebugProcess); + this.name = library.getName(); + this.version = library.getVersion(); + this.debuggerCallback = debuggerCallback; + this.pendingBreakpoints = new CopyOnWriteArraySet<>(); + } + + public static NodeJsDebugger newInstance(@Nullable Integer pid, + @Nullable URI uri, + String file, + DebuggerCallback debuggerCallback) throws DebuggerException { + NodeJsDebugProcess nodeJsDebugProcess = NodeJsDebugProcess.start(file); + return new NodeJsDebugger(pid, + uri, + file, + nodeJsDebugProcess, + debuggerCallback); + } + + @Override + public DebuggerInfo getInfo() throws DebuggerException { + return new DebuggerInfoImpl(uri == null ? "" : uri.getHost(), + uri == null ? -1 : uri.getPort(), + name, + version, + pid == null ? -1 : pid, + script); + } + + @Override + public void disconnect() { + debuggerCallback.onEvent(new DisconnectEventImpl()); + nodeJsDebugProcess.stop(); + } + + @Override + public void addBreakpoint(Breakpoint breakpoint) throws DebuggerException { + try { + Location location = breakpoint.getLocation(); + pendingBreakpoints.add(location); + library.setBreakpoint(location.getTarget(), location.getLineNumber()); + checkActivatedBreakpoints(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Can't add breakpoint: " + breakpoint + ". " + e.getMessage(), e); + } + } + + @Override + public void deleteBreakpoint(Location location) throws DebuggerException { + try { + pendingBreakpoints.remove(location); + library.clearBreakpoint(location.getTarget(), location.getLineNumber()); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Can't delete breakpoint: " + location + ". " + e.getMessage(), e); + } + } + + @Override + public void deleteAllBreakpoints() throws DebuggerException { + try { + for (Breakpoint breakpoint : library.getBreakpoints()) { + try { + deleteBreakpoint(breakpoint.getLocation()); + } catch (NodeJsDebuggerException e) { + LOG.error("Can't delete breakpoint: {}", breakpoint.getLocation(), e); + } + } + pendingBreakpoints.clear(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Can't delete all breakpoints. " + e.getMessage(), e); + } + } + + @Override + public List getAllBreakpoints() throws DebuggerException { + try { + return library.getBreakpoints(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Can't get all breakpoints. " + e.getMessage(), e); + } + } + + @Override + public void start(StartAction action) throws DebuggerException { + try { + for (Breakpoint breakpoint : action.getBreakpoints()) { + Location location = breakpoint.getLocation(); + library.setBreakpoint(location.getTarget(), location.getLineNumber()); + pendingBreakpoints.add(location); + } + + debuggerCallback.onEvent(new SuspendEventImpl(library.backtrace())); + checkActivatedBreakpoints(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Start error. " + e.getMessage(), e); + } + } + + @Override + public void stepOver(StepOverAction action) throws DebuggerException { + try { + debuggerCallback.onEvent(new SuspendEventImpl(library.next())); + checkActivatedBreakpoints(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Step over error. " + e.getMessage(), e); + } + } + + @Override + public void stepInto(StepIntoAction action) throws DebuggerException { + try { + debuggerCallback.onEvent(new SuspendEventImpl(library.stepIn())); + checkActivatedBreakpoints(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Step into error. " + e.getMessage(), e); + } + } + + @Override + public void stepOut(StepOutAction action) throws DebuggerException { + try { + debuggerCallback.onEvent(new SuspendEventImpl(library.stepOut())); + checkActivatedBreakpoints(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Step out error. " + e.getMessage(), e); + } + } + + @Override + public void resume(ResumeAction action) throws DebuggerException { + try { + debuggerCallback.onEvent(new SuspendEventImpl(library.cont())); + checkActivatedBreakpoints(); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Resume error. " + e.getMessage(), e); + } + } + + @Override + public void setValue(Variable variable) throws DebuggerException { + try { + List path = variable.getVariablePath().getPath(); + if (path.isEmpty()) { + throw new DebuggerException("Variable path is empty"); + } + library.setVar(path.get(0), variable.getValue()); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Can't set value for " + variable.getName() + ". " + e.getMessage(), e); + } + } + + @Override + public SimpleValue getValue(VariablePath variablePath) throws DebuggerException { + try { + List path = variablePath.getPath(); + if (path.isEmpty()) { + throw new DebuggerException("Variable path is empty"); + } + + return new SimpleValueImpl(Collections.emptyList(), library.getVar(path.get(0))); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Can't get value for " + variablePath + ". " + e.getMessage(), e); + } + } + + @Override + public String evaluate(String expression) throws DebuggerException { + try { + return library.evaluate(expression); + } catch (NodeJsDebuggerTerminatedException e) { + disconnect(); + throw e; + } catch (NodeJsDebuggerException e) { + throw new DebuggerException("Can't evaluate '" + expression + "'. " + e.getMessage(), e); + } + } + + @Override + public StackFrameDump dumpStackFrame() throws DebuggerException { + return new StackFrameDumpImpl(Collections.emptyList(), Collections.emptyList()); + } + + private void checkActivatedBreakpoints() throws DebuggerException { + Set brk2Remove = new HashSet<>(); + for (Breakpoint breakpoint : library.getBreakpoints()) { + for (Location pending : pendingBreakpoints) { + Location added = breakpoint.getLocation(); + if (added.getLineNumber() == pending.getLineNumber() && + Pattern.compile(added.getTarget()).matcher(pending.getTarget()).matches()) { + + BreakpointImpl brkToSend = new BreakpointImpl(pending, breakpoint.isEnabled(), breakpoint.getCondition()); + debuggerCallback.onEvent(new BreakpointActivatedEventImpl(brkToSend)); + brk2Remove.add(pending); + } + } + } + + pendingBreakpoints.removeAll(brk2Remove); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerFactory.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerFactory.java new file mode 100644 index 000000000000..8445de3f7c79 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerFactory.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +import org.eclipse.che.api.debugger.server.Debugger; +import org.eclipse.che.api.debugger.server.DebuggerFactory; +import org.eclipse.che.api.debugger.server.exceptions.DebuggerException; + +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Map; + +import static com.google.common.base.Strings.isNullOrEmpty; +import static java.util.stream.Collectors.toMap; + +/** + * Factory to create nodejs debugger instance. + * Allowed the following connection properties: + * + * uri - connects to the process via the URI such as localhost:5858 + * pid - connects to the process via the pid + * script - entrypoint to start debugger + * + * @author Anatoliy Bazko + */ +public class NodeJsDebuggerFactory implements DebuggerFactory { + private static final String TYPE = "nodejsdbg"; + + @Override + public String getType() { + return TYPE; + } + + @Override + public Debugger create(Map properties, Debugger.DebuggerCallback debuggerCallback) throws DebuggerException { + Map normalizedProps = properties.entrySet() + .stream() + .collect(toMap(e -> e.getKey().toLowerCase(), Map.Entry::getValue)); + + + Integer pid = null; + URI uri = null; + + String pidStr = normalizedProps.get("pid"); + if (!isNullOrEmpty(pidStr)) { + try { + pid = Integer.valueOf(pidStr); + } catch (NumberFormatException e) { + throw new DebuggerException(String.format("Illegal 'pid' format %s. Debugger can't be started.", pidStr)); + } + } + + String uriStr = normalizedProps.get("uri"); + if (!isNullOrEmpty(uriStr)) { + try { + uri = URI.create(uriStr); + } catch (IllegalArgumentException e) { + throw new DebuggerException(String.format("Illegal 'uri' format %s. Debugger can't be started.", uriStr)); + } + } + + String script = normalizedProps.get("script"); + if (!isNullOrEmpty(script) && !Files.exists(Paths.get(script))) { + throw new DebuggerException(String.format("Script '%s' to debug not found. Debugger can't be started.", script)); + } + + if (isNullOrEmpty(pidStr) && isNullOrEmpty(uriStr) && isNullOrEmpty(script)) { + throw new DebuggerException("Unrecognized debug connection options. Allowed only: pid, uri or script."); + } + + return NodeJsDebugger.newInstance(pid, uri, script, debuggerCallback); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerModule.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerModule.java new file mode 100644 index 000000000000..dc1d64d1cf96 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerModule.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +import com.google.inject.AbstractModule; +import com.google.inject.multibindings.Multibinder; + +import org.eclipse.che.api.debugger.server.DebuggerFactory; +import org.eclipse.che.inject.DynaModule; + +/** + * @author Anatoliy Bazko + */ +@DynaModule +public class NodeJsDebuggerModule extends AbstractModule { + + @Override + protected void configure() { + Multibinder.newSetBinder(binder(), DebuggerFactory.class).addBinding().to(NodeJsDebuggerFactory.class); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsOutput.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsOutput.java new file mode 100644 index 000000000000..b57081874409 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsOutput.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +/** + * Wrapper for NodeJs output. + * + * @author Anatoliy Bazko + */ +public class NodeJsOutput { + private final String output; + + private NodeJsOutput(String output) { + this.output = output; + } + + public static NodeJsOutput of(String output) { + return new NodeJsOutput(strip(output)); + } + + public String getOutput() { + return output; + } + + public boolean isEmpty() { + return output.isEmpty(); + } + + private static String strip(String output) { + if (output.endsWith("\n")) { + output = output.substring(0, output.length() - 1); + } + + return output.replaceAll("\\u001B\\[[0-9][0-9]m", "") + .replace("\b", ""); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsProcessObservable.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsProcessObservable.java new file mode 100644 index 000000000000..ec5af8e2da4d --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsProcessObservable.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +/** + * @author Anatolii Bazko + */ +public interface NodeJsProcessObservable { + + /** + * Adds observer. + */ + void addObserver(NodeJsProcessObserver observer); + + /** + * Removes observer. + */ + void removeObserver(NodeJsProcessObserver observer); +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsProcessObserver.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsProcessObserver.java new file mode 100644 index 000000000000..bdadd41dde70 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsProcessObserver.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException; + +/** + * @author Anatolii Bazko + */ +public interface NodeJsProcessObserver { + + /** + * Is occurred when a nodejs generates a new output. + * + * Returns {@code true} if no processing requires after. + */ + boolean onOutputProduced(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerException; +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommand.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommand.java new file mode 100644 index 000000000000..c349287e2c14 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommand.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.command; + +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsDebugProcess; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsProcessObserver; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException; + +import java.util.concurrent.Future; + +/** + * Any nodejs command to execute in debug. + * + * @see NodeJsDebugProcess + * @see NodeJsDebugCommandsLibrary + * + * @author Anatolii Bazko + */ +public interface NodeJsDebugCommand extends NodeJsProcessObserver { + + /** + * Executes command. Deferred result is returned. + * + * @param process + * the target process + * @return the result of command execution + * + * @throws NodeJsDebuggerException + * if execution failed + */ + Future execute(NodeJsDebugProcess process) throws NodeJsDebuggerException; +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommandImpl.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommandImpl.java new file mode 100644 index 000000000000..aa46d74c3f42 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommandImpl.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.command; + +import com.google.common.util.concurrent.SettableFuture; + +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsDebugProcess; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerParseException; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsOutputParser; + +import java.util.concurrent.Future; + +/** + * Basic implementation of {@link NodeJsDebugCommand}. + * When command is executed, it scans outputs until appropriate found, parses it and returns result of execution. + * + * @author Anatolii Bazko + */ +public class NodeJsDebugCommandImpl implements NodeJsDebugCommand { + + private final SettableFuture result; + public final NodeJsOutputParser parser; + private final String input; + + public NodeJsDebugCommandImpl(NodeJsOutputParser parser, String input) { + this.parser = parser; + this.input = input; + this.result = SettableFuture.create(); + } + + @Override + public Future execute(NodeJsDebugProcess process) throws NodeJsDebuggerException { + process.send(input); + return result; + } + + @Override + public boolean onOutputProduced(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException { + if (parser.match(nodeJsOutput)) { + T t = parser.parse(nodeJsOutput); + return result.set(t); + } + + return false; + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommandsLibrary.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommandsLibrary.java new file mode 100644 index 000000000000..6956b6f00248 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/command/NodeJsDebugCommandsLibrary.java @@ -0,0 +1,261 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.command; + +import org.eclipse.che.api.debug.shared.model.Breakpoint; +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl; +import org.eclipse.che.api.debug.shared.model.impl.LocationImpl; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsDebugProcess; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsDebugger; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsBackTraceParser; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsBreakpointsParser; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsBreakpointsParser.Breakpoints; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsOutputParser; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsOutputParser.NodeJsOutputRegExpParser; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsScriptsParser; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsScriptsParser.Scripts; +import org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsStepParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.nio.file.Paths; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.regex.Pattern; + +import static java.lang.String.format; + +/** + * Library of the NodeJs debug commands: https://nodejs.org/api/debugger.html + * + * @author Anatolii Bazko + */ +public class NodeJsDebugCommandsLibrary { + private static final Logger LOG = LoggerFactory.getLogger(NodeJsDebugger.class); + private static final Pattern PROCESS_TITLE_COMMAND_OUTPUT_PATTERN = Pattern.compile("^'?(node|nodejs)'?$"); + private static final Pattern PROCESS_VERSION_COMMAND_OUTPUT_PATTERN = Pattern.compile("^'?(v|)[0-9\\.]+'?$"); + private static final Pattern PROCESS_PID_COMMAND_OUTPUT_PATTERN = Pattern.compile("^[0-9]+$"); + private static final Pattern RUN_COMMAND_OUTPUT_PATTERN = Pattern.compile("(break in.*|App is already running.*)"); + + private final NodeJsDebugProcess process; + private final String name; + private final String version; + private final int pid; + + public NodeJsDebugCommandsLibrary(NodeJsDebugProcess process) throws NodeJsDebuggerException { + this.process = process; + run(); + + this.name = detectName(); + this.version = detectVersion(); + this.pid = detectPid(); + } + + /** + * Execute {@code bt} command. + */ + public Location backtrace() throws NodeJsDebuggerException { + NodeJsDebugCommand nextCommand = createCommand("bt", NodeJsBackTraceParser.INSTANCE); + return doExecute(nextCommand); + } + + /** + * Execute {@code sb} command. + */ + public Void setBreakpoint(String scriptPath, int lineNumber) throws NodeJsDebuggerException { + String scriptName = Paths.get(scriptPath).getFileName().toString(); + String input = format("sb('%s', %d)", scriptName, lineNumber); + NodeJsDebugCommand command = createCommand(input, NodeJsOutputParser.VOID); + return doExecute(command); + } + + /** + * Execute {@code breakpoints} command. + * @see NodeJsBackTraceParser + */ + public List getBreakpoints() throws NodeJsDebuggerException { + NodeJsDebugCommand breakpointsCommand = createCommand("breakpoints", NodeJsBreakpointsParser.INSTANCE); + List breakpoints = doExecute(breakpointsCommand).getAll(); + + NodeJsDebugCommand scriptsCommand = createCommand("scripts", NodeJsScriptsParser.INSTANCE); + Map scripts = doExecute(scriptsCommand).getAll(); + + for (int i = 0; i < breakpoints.size(); i++) { + Breakpoint breakpoint = breakpoints.get(i); + Location location = breakpoint.getLocation(); + + String newTarget; + String[] target = location.getTarget().split(":"); + if (target.length != 2) { + LOG.error(format("Illegal breakpoint location format %s", target)); + continue; + } + + if (target[0].equals("scriptId")) { + newTarget = scripts.get((int)Double.parseDouble(target[1])); + } else { + newTarget = target[1]; + } + + Location newLocation = new LocationImpl(newTarget, location.getLineNumber()); + Breakpoint newBreakpoint = new BreakpointImpl(newLocation, breakpoint.isEnabled(), breakpoint.getCondition()); + breakpoints.set(i, newBreakpoint); + } + + return breakpoints; + } + + /** + * Execute {@code cb} command. + */ + public Void clearBreakpoint(String script, int lineNumber) throws NodeJsDebuggerException { + String input = format("cb('%s', %d)", script, lineNumber); + NodeJsDebugCommand command = createCommand(input, NodeJsOutputParser.VOID); + return doExecute(command); + } + + /** + * Execute {@code run} command. + */ + public String run() throws NodeJsDebuggerException { + NodeJsDebugCommand nextCommand = createCommand("run", + new NodeJsOutputRegExpParser(RUN_COMMAND_OUTPUT_PATTERN)); + return doExecute(nextCommand); + } + + + /** + * Execute {@code next} command. + */ + public Location next() throws NodeJsDebuggerException { + NodeJsDebugCommand nextCommand = createCommand("next", NodeJsStepParser.INSTANCE); + return doExecute(nextCommand); + } + + /** + * Execute {@code cont} command. + */ + public Location cont() throws NodeJsDebuggerException { + NodeJsDebugCommand nextCommand = createCommand("cont", NodeJsStepParser.INSTANCE); + return doExecute(nextCommand); + } + + /** + * Execute {@code step in} command. + */ + public Location stepIn() throws NodeJsDebuggerException { + NodeJsDebugCommand nextCommand = createCommand("step", NodeJsStepParser.INSTANCE); + return doExecute(nextCommand); + } + + /** + * Execute {@code step out} command. + */ + public Location stepOut() throws NodeJsDebuggerException { + NodeJsDebugCommand nextCommand = createCommand("out", NodeJsStepParser.INSTANCE); + return doExecute(nextCommand); + } + + /** + * Execute {@code exec} command to set a new value for the giving variable. + */ + public Void setVar(String varName, String newValue) throws NodeJsDebuggerException { + String input = format("exec %s=%s", varName, newValue); + NodeJsDebugCommand command = createCommand(input, NodeJsOutputParser.VOID); + return doExecute(command); + } + + /** + * Execute {@code exec} command to get value for the giving variable. + */ + public String getVar(String varName) throws NodeJsDebuggerException { + String line = format("exec %s", varName); + NodeJsDebugCommand command = createCommand(line, NodeJsOutputParser.DEFAULT); + return doExecute(command); + } + + /** + * Execute {@code exec} command to evaluate expression. + */ + public String evaluate(String expression) throws NodeJsDebuggerException { + String line = format("exec %s", expression); + NodeJsDebugCommand command = createCommand(line, NodeJsOutputParser.DEFAULT); + return doExecute(command); + } + + /** + * Returns NodeJs version. + */ + public String getVersion() { + return version; + } + + /** + * Returns NodeJs title. + */ + public String getName() { + return name; + } + + /** + * Returns NodeJs pid. + */ + public int getPid() { + return pid; + } + + /** + * Returns NodeJs version. + */ + private String detectVersion() throws NodeJsDebuggerException { + NodeJsDebugCommand command = createCommand("process.version", + new NodeJsOutputRegExpParser(PROCESS_VERSION_COMMAND_OUTPUT_PATTERN)); + return doExecute(command); + } + + /** + * Returns NodeJs pid. + */ + private int detectPid() throws NodeJsDebuggerException { + NodeJsDebugCommand command = createCommand("process.pid", + new NodeJsOutputRegExpParser(PROCESS_PID_COMMAND_OUTPUT_PATTERN)); + return Integer.parseInt(doExecute(command)); + } + + /** + * Returns NodeJs title. + */ + private String detectName() throws NodeJsDebuggerException { + NodeJsDebugCommand command = createCommand("process.title", + new NodeJsOutputRegExpParser(PROCESS_TITLE_COMMAND_OUTPUT_PATTERN)); + return doExecute(command); + } + + private V doExecute(NodeJsDebugCommand command) throws NodeJsDebuggerException { + process.addObserver(command); + try { + Future result = command.execute(process); + return result.get(); + } catch (InterruptedException | ExecutionException e) { + throw new NodeJsDebuggerException(e.getMessage(), e); + } finally { + process.removeObserver(command); + } + } + + private NodeJsDebugCommand createCommand(String input, NodeJsOutputParser outputParser) { + return new NodeJsDebugCommandImpl<>(outputParser, input); + } +} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/PreferencesAccessException.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerException.java similarity index 57% rename from plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/PreferencesAccessException.java rename to plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerException.java index 2c9b6b05fa1c..5fcae57f0502 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/PreferencesAccessException.java +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerException.java @@ -8,24 +8,19 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.svn.server.credentials; +package org.eclipse.che.plugin.nodejsdbg.server.exception; -public class PreferencesAccessException extends Exception { +import org.eclipse.che.api.debugger.server.exceptions.DebuggerException; - private static final long serialVersionUID = 1L; - - public PreferencesAccessException() { - } - - public PreferencesAccessException(String message) { +/** + * @author Anatoliy Bazko + */ +public class NodeJsDebuggerException extends DebuggerException { + public NodeJsDebuggerException(String message) { super(message); } - public PreferencesAccessException(Throwable cause) { - super(cause); - } - - public PreferencesAccessException(String message, Throwable cause) { + public NodeJsDebuggerException(String message, Exception cause) { super(message, cause); } } diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerParseException.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerParseException.java new file mode 100644 index 000000000000..b7bd25401fea --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerParseException.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.exception; + +import static java.lang.Math.min; + +/** + * @author Anatoliy Bazko + */ +@SuppressWarnings("serial") +public class NodeJsDebuggerParseException extends NodeJsDebuggerException { + + public static final int MAX_OUTPUT_LENGTH = 80; + + public NodeJsDebuggerParseException(Class clazz, String output) { + super("Can't parse '" + + output.substring(0, min(output.length(), MAX_OUTPUT_LENGTH)) + + "' into " + + clazz.getSimpleName()); + } +} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CredentialsException.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerTerminatedException.java similarity index 64% rename from plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CredentialsException.java rename to plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerTerminatedException.java index 7e54c4d0411d..9bcf510d9f28 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CredentialsException.java +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/exception/NodeJsDebuggerTerminatedException.java @@ -8,18 +8,13 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.svn.server.credentials; +package org.eclipse.che.plugin.nodejsdbg.server.exception; -public class CredentialsException extends Exception { - - private static final long serialVersionUID = 1L; - - public CredentialsException(final Throwable e) { - super(e); - } - - public CredentialsException(final String message) { +/** + * @author Anatoliy Bazko + */ +public class NodeJsDebuggerTerminatedException extends NodeJsDebuggerException { + public NodeJsDebuggerTerminatedException(String message) { super(message); } - } diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBackTraceParser.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBackTraceParser.java new file mode 100644 index 000000000000..9a8b57d50703 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBackTraceParser.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.api.debug.shared.model.impl.LocationImpl; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerParseException; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * {@code backtrace} command parser. + * + * @author Anatoliy Bazko + */ +public class NodeJsBackTraceParser implements NodeJsOutputParser { + + public static final NodeJsBackTraceParser INSTANCE = new NodeJsBackTraceParser(); + public static final Pattern PATTERN = Pattern.compile("#0(.*) (.*):(.*):(.*)"); + + private NodeJsBackTraceParser() { } + + @Override + public boolean match(NodeJsOutput nodeJsOutput) { + return nodeJsOutput.getOutput().startsWith("#0"); + } + + @Override + public Location parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException { + String output = nodeJsOutput.getOutput(); + + for (String line : output.split("\n")) { + Matcher matcher = PATTERN.matcher(line); + if (matcher.find()) { + String file = matcher.group(2); + String lineNumber = matcher.group(3); + return new LocationImpl(file, Integer.parseInt(lineNumber)); + } + } + + throw new NodeJsDebuggerParseException(Location.class, output); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBreakpointsParser.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBreakpointsParser.java new file mode 100644 index 000000000000..76b4dc5257e8 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBreakpointsParser.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import org.eclipse.che.api.debug.shared.model.Breakpoint; +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl; +import org.eclipse.che.api.debug.shared.model.impl.LocationImpl; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerParseException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * {@code breakpoints} command parser. + * + * @author Anatoliy Bazko + */ +public class NodeJsBreakpointsParser implements NodeJsOutputParser { + private static final Logger LOG = LoggerFactory.getLogger(NodeJsBreakpointsParser.class); + + public static final NodeJsBreakpointsParser INSTANCE = new NodeJsBreakpointsParser(); + + @Override + public boolean match(NodeJsOutput nodeJsOutput) { + return nodeJsOutput.getOutput().startsWith("{ breakpoints:"); + } + + @Override + public Breakpoints parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException { + final List breakpoints = new ArrayList<>(); + + JsonObject json = new JsonParser().parse(nodeJsOutput.getOutput()).getAsJsonObject(); + if (json.has("breakpoints")) { + Iterator iter = json.getAsJsonArray("breakpoints").iterator(); + while (iter.hasNext()) { + JsonObject item = iter.next().getAsJsonObject(); + try { + final String condition = item.has("condition") && !item.get("condition").isJsonNull() + ? item.get("condition").getAsString() + : null; + final boolean isEnabled = item.has("active") && !item.get("active").isJsonNull() && item.get("active").getAsBoolean(); + final int lineNumber = item.get("line").getAsInt(); + + final String target; + String targetType = item.get("type").getAsString(); + + switch (targetType) { + case "scriptId": + target = String.valueOf(item.get("script_id").getAsInt()); + break; + case "scriptRegExp": + target = item.get("script_regexp").getAsString(); + break; + default: + throw new IllegalArgumentException("Unsupported 'type' value: " + targetType); + } + + Location location = new LocationImpl(targetType + ":" + target, lineNumber + 1); + Breakpoint breakpoint = new BreakpointImpl(location, isEnabled, condition); + breakpoints.add(breakpoint); + } catch (Exception e) { + LOG.error("Failed to parse breakpoint: " + item.toString(), e); + } + } + } + + return new Breakpoints(breakpoints); + } + + public static class Breakpoints { + private final List breakpoints; + + private Breakpoints(List breakpoints) {this.breakpoints = breakpoints;} + + public List getAll() { + return breakpoints; + } + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsOutputParser.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsOutputParser.java new file mode 100644 index 000000000000..c1af509d3130 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsOutputParser.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerParseException; + +import java.util.regex.Pattern; + +/** + * @author Anatolii Bazko + */ +public interface NodeJsOutputParser { + + /** + * Indicates if output matches + */ + boolean match(NodeJsOutput nodeJsOutput); + + /** + * Parses {@link NodeJsOutput} into valuable result. + */ + T parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException; + + /** + * Doesn't parse output, just returns as is. + */ + NodeJsOutputParser DEFAULT = new NodeJsOutputParser() { + @Override + public boolean match(NodeJsOutput nodeJsOutput) { + return true; + } + + @Override + public String parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException { + return nodeJsOutput.getOutput(); + } + }; + + /** + * {@link NodeJsOutputParser} when result will be skipped. + */ + NodeJsOutputParser VOID = new NodeJsOutputParser() { + @Override + public boolean match(NodeJsOutput nodeJsOutput) { + return true; + } + + @Override + public Void parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException { + return null; + } + }; + + class NodeJsOutputRegExpParser implements NodeJsOutputParser { + private final Pattern pattern; + + public NodeJsOutputRegExpParser(Pattern pattern) { + this.pattern = pattern; + } + + @Override + public boolean match(NodeJsOutput nodeJsOutput) { + return pattern.matcher(nodeJsOutput.getOutput()).find(); + } + + @Override + public String parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException { + return nodeJsOutput.getOutput(); + } + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsScriptsParser.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsScriptsParser.java new file mode 100644 index 000000000000..6895a99e11a3 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsScriptsParser.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; + +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * {@code scripts} command parser. + * + * @author Anatoliy Bazko + */ +public class NodeJsScriptsParser implements NodeJsOutputParser { + private static final Pattern SCRIPT = Pattern.compile(".* ([0-9]*): (.*)"); + + public static final NodeJsScriptsParser INSTANCE = new NodeJsScriptsParser(); + + @Override + public boolean match(NodeJsOutput nodeJsOutput) { + for (String line : nodeJsOutput.getOutput().split("\n")) { + Matcher matcher = SCRIPT.matcher(line); + if (!matcher.find()) { + return false; + } + } + + return !nodeJsOutput.isEmpty(); + } + + @Override + public Scripts parse(NodeJsOutput nodeJsOutput) { + Map scripts = new HashMap<>(); + + for (String line : nodeJsOutput.getOutput().split("\n")) { + Matcher matcher = SCRIPT.matcher(line); + if (matcher.find()) { + int number = Integer.parseInt(matcher.group(1)); + String script = matcher.group(2); + + scripts.put(number, script); + } + } + + return new Scripts(scripts); + } + + public static class Scripts { + private final Map scripts; + + public Scripts(Map scripts) {this.scripts = scripts;} + + public Map getAll() { + return scripts; + } + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsStepParser.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsStepParser.java new file mode 100644 index 000000000000..4176d45e78b9 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/main/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsStepParser.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.api.debug.shared.model.impl.LocationImpl; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerParseException; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * {@code backtrace} command parser. + * + * @author Anatoliy Bazko + */ +public class NodeJsStepParser implements NodeJsOutputParser { + + public static final NodeJsStepParser INSTANCE = new NodeJsStepParser(); + public static final Pattern PATTERN = Pattern.compile("^break in (.*):([0-9]+)"); + + private NodeJsStepParser() { } + + @Override + public boolean match(NodeJsOutput nodeJsOutput) { + return nodeJsOutput.getOutput().startsWith("break in"); + } + + @Override + public Location parse(NodeJsOutput nodeJsOutput) throws NodeJsDebuggerParseException { + String output = nodeJsOutput.getOutput(); + + for (String line : output.split("\n")) { + Matcher matcher = PATTERN.matcher(line); + if (matcher.find()) { + String file = matcher.group(1); + String lineNumber = matcher.group(2); + return new LocationImpl(file, Integer.parseInt(lineNumber)); + } + } + + throw new NodeJsDebuggerParseException(Location.class, output); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerTest.java new file mode 100644 index 000000000000..a75a251df5e7 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/NodeJsDebuggerTest.java @@ -0,0 +1,122 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server; + +import org.eclipse.che.api.debug.shared.model.Breakpoint; +import org.eclipse.che.api.debug.shared.model.DebuggerInfo; +import org.eclipse.che.api.debug.shared.model.event.BreakpointActivatedEvent; +import org.eclipse.che.api.debug.shared.model.event.SuspendEvent; +import org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl; +import org.eclipse.che.api.debug.shared.model.impl.LocationImpl; +import org.eclipse.che.api.debug.shared.model.impl.action.StepIntoActionImpl; +import org.eclipse.che.api.debug.shared.model.impl.action.StepOutActionImpl; +import org.eclipse.che.api.debug.shared.model.impl.action.StepOverActionImpl; +import org.eclipse.che.api.debugger.server.Debugger; +import org.mockito.ArgumentCaptor; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.util.List; + +import static com.google.common.base.Strings.isNullOrEmpty; +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @author Anatolii Bazko + */ +public class NodeJsDebuggerTest { + private NodeJsDebugger debugger; + private Debugger.DebuggerCallback callback; + + @BeforeMethod + public void setUp() throws Exception { + String file = NodeJsDebuggerTest.class.getResource("/app.js").getFile(); + + callback = mock(Debugger.DebuggerCallback.class); + debugger = NodeJsDebugger.newInstance(null, null, file, callback); + } + + @Test + public void testGetInfo() throws Exception { + DebuggerInfo info = debugger.getInfo(); + + assertTrue(info.getFile().endsWith("app.js")); + assertTrue(!isNullOrEmpty(info.getVersion())); + assertTrue(info.getName().equals("'node'") || info.getName().equals("'nodejs'")); + } + + @Test + public void testManageBreakpoints() throws Exception { + List breakpoints = debugger.getAllBreakpoints(); + assertEquals(breakpoints.size(), 1); + + debugger.addBreakpoint(new BreakpointImpl(new LocationImpl("app.js", 2))); + + ArgumentCaptor breakpointActivated = ArgumentCaptor.forClass(BreakpointActivatedEvent.class); + verify(callback).onEvent(breakpointActivated.capture()); + BreakpointActivatedEvent event = breakpointActivated.getValue(); + Breakpoint breakpoint = event.getBreakpoint(); + assertEquals(breakpoint.getLocation().getTarget(), "app.js"); + assertEquals(breakpoint.getLocation().getLineNumber(), 2); + + debugger.addBreakpoint(new BreakpointImpl(new LocationImpl("app.js", 5))); + + breakpoints = debugger.getAllBreakpoints(); + assertEquals(breakpoints.size(), 3); + + debugger.deleteBreakpoint(new LocationImpl("app.js", 2)); + breakpoints = debugger.getAllBreakpoints(); + assertEquals(breakpoints.size(), 2); + + debugger.deleteAllBreakpoints(); + breakpoints = debugger.getAllBreakpoints(); + assertEquals(breakpoints.size(), 1); + } + + @Test + public void testEvaluation() throws Exception { + String result = debugger.evaluate("2+2"); + assertEquals(result, "4"); + + result = debugger.evaluate("console.log('hello')"); + assertEquals(result, "< hello"); + + result = debugger.evaluate("var y=1"); + assertEquals(result, "undefined"); + } + + @Test + public void testSteps() throws Exception { + debugger.stepOver(new StepOverActionImpl()); + + ArgumentCaptor suspendEventCaptor = ArgumentCaptor.forClass(SuspendEvent.class); + verify(callback, atLeastOnce()).onEvent(suspendEventCaptor.capture()); + SuspendEvent suspendEvent = suspendEventCaptor.getValue(); + assertEquals(suspendEvent.getLocation().getLineNumber(), 2); + assertTrue(suspendEvent.getLocation().getTarget().endsWith("app.js")); + + debugger.stepInto(new StepIntoActionImpl()); + verify(callback, atLeastOnce()).onEvent(suspendEventCaptor.capture()); + suspendEvent = suspendEventCaptor.getValue(); + assertEquals(suspendEvent.getLocation().getLineNumber(), 5); + assertTrue(suspendEvent.getLocation().getTarget().endsWith("app.js")); + + debugger.stepOut(new StepOutActionImpl()); + verify(callback, atLeastOnce()).onEvent(suspendEventCaptor.capture()); + suspendEvent = suspendEventCaptor.getValue(); + assertEquals(suspendEvent.getLocation().getLineNumber(), 9); + assertTrue(suspendEvent.getLocation().getTarget().endsWith("app.js")); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBackTraceParserTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBackTraceParserTest.java new file mode 100644 index 000000000000..c60b19ee41f6 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBackTraceParserTest.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @author Anatolii Bazko + */ +public class NodeJsBackTraceParserTest { + + private NodeJsBackTraceParser parser; + + @BeforeMethod + public void setUp() throws Exception { + parser = NodeJsBackTraceParser.INSTANCE; + } + + @Test(dataProvider = "match") + public void testMatch(String output, Boolean result) throws Exception { + NodeJsOutput nodeJsOutput = NodeJsOutput.of(output); + + assertTrue(parser.match(nodeJsOutput) == result); + } + + @Test(dataProvider = "parse") + public void testParse(String output, String script, int line) throws Exception { + NodeJsOutput nodeJsOutput = NodeJsOutput.of(output); + + Location location = parser.parse(nodeJsOutput); + + assertEquals(location.getTarget(), script); + assertEquals(location.getLineNumber(), line); + } + + @DataProvider(name = "match") + public static Object[][] match() { + return new Object[][] {{"#0 app.js:1:71", true}, + {"#0 app.js:1:71\n#1 app.js:1:71", true}, + {"#0 Object.defineProperty.get bootstrap_node.js:253:9", true}, + {"#1 app.js:1:71", false}}; + } + + @DataProvider(name = "parse") + public static Object[][] parse() { + return new Object[][] {{"#0 app.js:1:71", "app.js", 1}, + {"#0 app.js:1:71\n#1 app.js:1:71", "app.js", 1}, + {"#0 Object.defineProperty.get bootstrap_node.js:253:9", "bootstrap_node.js", 253}}; + + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBreakpointsParserTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBreakpointsParserTest.java new file mode 100644 index 000000000000..55e8de8ad96d --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsBreakpointsParserTest.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.api.debug.shared.model.Breakpoint; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.util.List; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +/** + * @author Anatolii Bazko + */ +public class NodeJsBreakpointsParserTest { + + private NodeJsBreakpointsParser parser; + + @BeforeMethod + public void setUp() throws Exception { + parser = new NodeJsBreakpointsParser(); + } + + @Test + public void testParseBreakpoints() throws Exception { + NodeJsOutput nodeJsOutput = NodeJsOutput.of("{ breakpoints: \n" + + " [ { number: 1,\n" + + " line: 1,\n" + + " column: null,\n" + + " groupId: null,\n" + + " active: true,\n" + + " condition: null,\n" + + " actual_locations: [Object],\n" + + " type: 'scriptId',\n" + + " script_id: '63' } ],\n" + + " breakOnExceptions: false,\n" + + " breakOnUncaughtExceptions: false }"); + + assertTrue(parser.match(nodeJsOutput)); + + List breakpoints = parser.parse(nodeJsOutput).getAll(); + assertEquals(breakpoints.size(), 1); + + Breakpoint breakpoint = breakpoints.get(0); + assertEquals(breakpoint.getLocation().getLineNumber(), 2); + assertEquals(breakpoint.getLocation().getTarget(), "scriptId:63"); + assertNull(breakpoint.getCondition()); + assertTrue(breakpoint.isEnabled()); + } + + @Test + public void testParseBreakpointsWhenScriptIsNotLoaded() throws Exception { + NodeJsOutput nodeJsOutput = NodeJsOutput.of("{ breakpoints: \n" + + " [ { number: 1,\n" + + " line: 1,\n" + + " column: null,\n" + + " groupId: null,\n" + + " active: true,\n" + + " condition: null,\n" + + " actual_locations: [Object],\n" + + " type: 'scriptRegExp',\n" + + " script_regexp: '^(.*[\\\\/\\\\\\\\])?df3dfasdfs\\\\.js$' } ]," + + " breakOnExceptions: false,\n" + + " breakOnUncaughtExceptions: false }"); + + assertTrue(parser.match(nodeJsOutput)); + + List breakpoints = parser.parse(nodeJsOutput).getAll(); + assertEquals(breakpoints.size(), 1); + + Breakpoint breakpoint = breakpoints.get(0); + assertEquals(breakpoint.getLocation().getLineNumber(), 2); + assertEquals(breakpoint.getLocation().getTarget(), "scriptRegExp:^(.*[\\/\\\\])?df3dfasdfs\\.js$"); + assertNull(breakpoint.getCondition()); + assertTrue(breakpoint.isEnabled()); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsScriptsParserTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsScriptsParserTest.java new file mode 100644 index 000000000000..fd9e80a70b6f --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsScriptsParserTest.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.util.Map; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @author Anatolii Bazko + */ +public class NodeJsScriptsParserTest { + + private NodeJsScriptsParser parser; + + @BeforeMethod + public void setUp() throws Exception { + parser = new NodeJsScriptsParser(); + } + + @Test + public void testParseScriptCommand() throws Exception { + NodeJsOutput output = NodeJsOutput.of(" 35: bootstrap_node.js\n" + + "* 63: app.js\n"); + + assertTrue(parser.match(output)); + + Map scripts = parser.parse(output).getAll(); + + assertEquals(scripts.size(), 2); + assertEquals(scripts.get(35), "bootstrap_node.js"); + assertEquals(scripts.get(63), "app.js"); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsStepParserTest.java b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsStepParserTest.java new file mode 100644 index 000000000000..60598d4a93d1 --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/java/org/eclipse/che/plugin/nodejsdbg/server/parser/NodeJsStepParserTest.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nodejsdbg.server.parser; + +import org.eclipse.che.api.debug.shared.model.Location; +import org.eclipse.che.plugin.nodejsdbg.server.NodeJsOutput; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @author Anatolii Bazko + */ +public class NodeJsStepParserTest { + private NodeJsStepParser parser; + + @BeforeMethod + public void setUp() throws Exception { + parser = NodeJsStepParser.INSTANCE; + } + + @Test + public void testMatch() throws Exception { + NodeJsOutput nodeJsOutput = NodeJsOutput.of("break in module.js:559\n" + + " 557 if (depth === 0) stat.cache = null;\n" + + " 558 return result;\n" + + ">559 };\n" + + " 560 \n" + + " 561"); + + assertTrue(parser.match(nodeJsOutput)); + } + + @Test + public void testParse() throws Exception { + NodeJsOutput nodeJsOutput = NodeJsOutput.of("break in module.js:559\n" + + " 557 if (depth === 0) stat.cache = null;\n" + + " 558 return result;\n" + + ">559 };\n" + + " 560 \n" + + " 561"); + + Location location = parser.parse(nodeJsOutput); + + assertEquals(location.getTarget(), "module.js"); + assertEquals(location.getLineNumber(), 559); + } +} diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/resources/app.js b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/resources/app.js new file mode 100644 index 000000000000..29acbf4c50dd --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/resources/app.js @@ -0,0 +1,7 @@ +var x = 1; +say("Hello", x); + +function say(str, num) { + console.log(str + " " + x); +} + diff --git a/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/resources/logback-test.xml b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/resources/logback-test.xml new file mode 100644 index 000000000000..33ab360a1fef --- /dev/null +++ b/plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-server/src/test/resources/logback-test.xml @@ -0,0 +1,25 @@ + + + + + + %-41(%date[%.25thread]) %-45([%-5level] [%.30logger{30} %L]) - %msg%n%nopex + + + + + + + + diff --git a/plugins/plugin-nodejs-debugger/pom.xml b/plugins/plugin-nodejs-debugger/pom.xml new file mode 100644 index 000000000000..4b10f40ce87f --- /dev/null +++ b/plugins/plugin-nodejs-debugger/pom.xml @@ -0,0 +1,42 @@ + + + + 4.0.0 + + che-plugin-parent + org.eclipse.che.plugin + 5.0.0-M5-SNAPSHOT + + che-plugin-nodejs-debugger-parent + pom + Che Plugin :: NodeJs Debugger :: Parent + + che-plugin-nodejs-debugger-server + che-plugin-nodejs-debugger-ide + + + + + windows + + + Windows + + + + true + + + + diff --git a/plugins/plugin-nodejs/che-plugin-nodejs-lang-server/src/main/java/org/eclipse/che/plugin/nodejs/inject/NodeJsModule.java b/plugins/plugin-nodejs/che-plugin-nodejs-lang-server/src/main/java/org/eclipse/che/plugin/nodejs/inject/NodeJsModule.java index f6815ce822e4..fd20a250290c 100644 --- a/plugins/plugin-nodejs/che-plugin-nodejs-lang-server/src/main/java/org/eclipse/che/plugin/nodejs/inject/NodeJsModule.java +++ b/plugins/plugin-nodejs/che-plugin-nodejs-lang-server/src/main/java/org/eclipse/che/plugin/nodejs/inject/NodeJsModule.java @@ -12,6 +12,7 @@ import com.google.inject.AbstractModule; import com.google.inject.multibindings.Multibinder; +import com.google.inject.name.Names; import org.eclipse.che.api.project.server.handlers.ProjectHandler; import org.eclipse.che.api.project.server.type.ProjectTypeDef; @@ -19,6 +20,9 @@ import org.eclipse.che.plugin.nodejs.generator.NodeJsProjectGenerator; import org.eclipse.che.plugin.nodejs.projecttype.NodeJsProjectType; +import java.nio.file.Path; +import java.nio.file.PathMatcher; + import static com.google.inject.multibindings.Multibinder.newSetBinder; /** @@ -34,5 +38,20 @@ protected void configure() { Multibinder projectHandlerMultibinder = newSetBinder(binder(), ProjectHandler.class); projectHandlerMultibinder.addBinding().to(NodeJsProjectGenerator.class); + + configureVfsExcludeFilter(); + } + + private void configureVfsExcludeFilter() { + newSetBinder(binder(), PathMatcher.class, Names.named("vfs.index_filter_matcher")) + .addBinding() + .toInstance(path -> { + for (Path pathElement : path) { + if (pathElement == null || "node_modules".equals(pathElement.toString())) { + return true; + } + } + return false; + }); } } diff --git a/plugins/plugin-php/che-plugin-php-lang-server/pom.xml b/plugins/plugin-php/che-plugin-php-lang-server/pom.xml index 64a31a7c04c0..76fec0de652e 100644 --- a/plugins/plugin-php/che-plugin-php-lang-server/pom.xml +++ b/plugins/plugin-php/che-plugin-php-lang-server/pom.xml @@ -32,6 +32,22 @@ com.google.inject.extensions guice-multibindings + + io.typefox.lsapi + io.typefox.lsapi.services + + + org.eclipse.che.core + che-core-api-core + + + org.eclipse.che.core + che-core-api-languageserver + + + org.eclipse.che.core + che-core-api-languageserver-shared + org.eclipse.che.core che-core-api-project diff --git a/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/inject/PhpModule.java b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/inject/PhpModule.java index 985f80d3d681..018d0e76b0c9 100644 --- a/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/inject/PhpModule.java +++ b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/inject/PhpModule.java @@ -13,10 +13,16 @@ import com.google.inject.AbstractModule; import com.google.inject.multibindings.Multibinder; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; +import org.eclipse.che.api.project.server.handlers.ProjectHandler; import org.eclipse.che.api.project.server.type.ProjectTypeDef; import org.eclipse.che.inject.DynaModule; +import org.eclipse.che.plugin.php.languageserver.PhpLanguageServerLauncher; +import org.eclipse.che.plugin.php.projecttype.PhpProjectGenerator; import org.eclipse.che.plugin.php.projecttype.PhpProjectType; +import static com.google.inject.multibindings.Multibinder.newSetBinder; + /** * @author Kaloyan Raev */ @@ -26,5 +32,10 @@ public class PhpModule extends AbstractModule { protected void configure() { Multibinder projectTypeMultibinder = Multibinder.newSetBinder(binder(), ProjectTypeDef.class); projectTypeMultibinder.addBinding().to(PhpProjectType.class); + + Multibinder projectHandlerMultibinder = newSetBinder(binder(), ProjectHandler.class); + projectHandlerMultibinder.addBinding().to(PhpProjectGenerator.class); + + Multibinder.newSetBinder(binder(), LanguageServerLauncher.class).addBinding().to(PhpLanguageServerLauncher.class); } } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/PhpLanguageServerLauncher.java b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/languageserver/PhpLanguageServerLauncher.java similarity index 71% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/PhpLanguageServerLauncher.java rename to plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/languageserver/PhpLanguageServerLauncher.java index 9dda3b2a27d0..4c581f3adc27 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/PhpLanguageServerLauncher.java +++ b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/languageserver/PhpLanguageServerLauncher.java @@ -8,17 +8,20 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.launcher; +package org.eclipse.che.plugin.php.languageserver; import io.typefox.lsapi.services.json.JsonBasedLanguageServer; +import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; -import org.eclipse.che.plugin.languageserver.shared.model.impl.LanguageDescriptionImpl; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncherTemplate; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.model.impl.LanguageDescriptionImpl; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -31,13 +34,13 @@ */ @Singleton public class PhpLanguageServerLauncher extends LanguageServerLauncherTemplate { + private static final String LANGUAGE_ID = "php"; + private static final String[] EXTENSIONS = new String[] {"php"}; + private static final String[] MIME_TYPES = new String[] {"text/x-php"}; - public static final String LANGUAGE_ID = "php"; - public static final String[] EXTENSIONS = new String[] {"php"}; - public static final String[] MIME_TYPES = new String[] {"text/x-php"}; + private final Path launchScript; private static final LanguageDescriptionImpl description; - private static final String SCRIPT_PATH = "che/ls-php/launch.sh"; static { description = new LanguageDescriptionImpl(); @@ -46,6 +49,11 @@ public class PhpLanguageServerLauncher extends LanguageServerLauncherTemplate { description.setMimeTypes(asList(MIME_TYPES)); } + @Inject + public PhpLanguageServerLauncher() { + this.launchScript = Paths.get(System.getenv("HOME"), "che/ls-php/launch.sh"); + } + @Override public LanguageDescription getLanguageDescription() { return description; @@ -53,8 +61,7 @@ public LanguageDescription getLanguageDescription() { @Override public boolean isAbleToLaunch() { - Path launchFile = Paths.get(System.getenv("HOME"), SCRIPT_PATH); - return launchFile.toFile().exists(); + return Files.exists(launchScript); } protected JsonBasedLanguageServer connectToLanguageServer(Process languageServerProcess) { @@ -64,9 +71,7 @@ protected JsonBasedLanguageServer connectToLanguageServer(Process languageServer } protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException { - Path launchFile = Paths.get(System.getenv("HOME"), SCRIPT_PATH); - - ProcessBuilder processBuilder = new ProcessBuilder(launchFile.toString()); + ProcessBuilder processBuilder = new ProcessBuilder(launchScript.toString()); processBuilder.redirectInput(ProcessBuilder.Redirect.PIPE); processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE); try { diff --git a/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/projecttype/PhpProjectGenerator.java b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/projecttype/PhpProjectGenerator.java new file mode 100644 index 000000000000..fbbfc7936944 --- /dev/null +++ b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/projecttype/PhpProjectGenerator.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ + +package org.eclipse.che.plugin.php.projecttype; + +import org.eclipse.che.api.core.ConflictException; +import org.eclipse.che.api.core.ForbiddenException; +import org.eclipse.che.api.core.ServerException; +import org.eclipse.che.api.project.server.FolderEntry; +import org.eclipse.che.api.project.server.handlers.CreateProjectHandler; +import org.eclipse.che.api.project.server.type.AttributeValue; +import org.eclipse.che.plugin.php.shared.Constants; + +import java.util.Map; + +public class PhpProjectGenerator implements CreateProjectHandler { + + private static final String FILE_NAME = "hello.php"; + + @Override + public void onCreateProject(FolderEntry baseFolder, + Map attributes, + Map options) throws ForbiddenException, ConflictException, ServerException { + baseFolder.createFile(FILE_NAME, getClass().getClassLoader().getResourceAsStream("files/default_php_content")); + } + + @Override + public String getProjectType() { + return Constants.PHP_PROJECT_TYPE_ID; + } +} diff --git a/plugins/plugin-php/che-plugin-php-lang-server/src/main/resources/files/default_php_content b/plugins/plugin-php/che-plugin-php-lang-server/src/main/resources/files/default_php_content new file mode 100644 index 000000000000..a93819658c6e --- /dev/null +++ b/plugins/plugin-php/che-plugin-php-lang-server/src/main/resources/files/default_php_content @@ -0,0 +1,3 @@ +javax.validation validation-api - - org.eclipse.che.core - che-core-api-project-shared - org.eclipse.che.core che-core-commons-annotations @@ -112,6 +108,11 @@ junit test + + org.eclipse.che.core + che-core-api-project-shared + test + org.hamcrest hamcrest-core diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientService.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientService.java index b267cd92b74b..80366fa6d61c 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientService.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientService.java @@ -11,6 +11,8 @@ package org.eclipse.che.plugin.svn.ide; import org.eclipse.che.api.promises.client.Promise; +import org.eclipse.che.commons.annotation.Nullable; +import org.eclipse.che.ide.api.subversion.Credentials; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.plugin.svn.shared.CLIOutputResponse; import org.eclipse.che.plugin.svn.shared.CLIOutputResponseList; @@ -84,18 +86,24 @@ Promise add(Path project, * source item path * @param destination * destination path + * @param credentials + * {@link Credentials} object that contains user name and password for authentication */ - Promise copy(Path project, Path source, Path destination, String comment); + Promise copy(Path project, + Path source, + Path destination, + String comment, + @Nullable Credentials credentials); /** * Merge specified URL with target. * * @param project - * project path + * project path * @param target - * target directory + * target directory * @param sourceUrl - * source URL to merge + * source URL to merge */ Promise merge(Path project, Path target, Path sourceUrl); @@ -103,15 +111,16 @@ Promise add(Path project, * Retrieves the information about repository item. * * @param project - * relative path to the project in local workspace + * relative path to the project in local workspace * @param target - * target to operate + * target to operate * @param revision - * revision, use HEAD to specify latest revision - * @param children - * whether list children or not + * revision, use HEAD to specify latest revision + * @param credentials + * {@link Credentials} object that contains user name and password for authentication */ - Promise info(Path project, Path target, String revision, boolean children); + Promise info(Path project, Path target, String revision, boolean children, @Nullable Credentials credentials); + Promise info(Path project, String target, String revision, boolean children); /** @@ -161,12 +170,20 @@ Promise status(Path project, * whether or not to ignore externals (--ignore-externals) * @param accept * the accept argument (--accept) + * @param credentials + * {@link Credentials} object that contains user name and password for authentication */ - Promise update(Path project, Path[] paths, String revision, String depth, boolean ignoreExternals, String accept); + Promise update(Path project, + Path[] paths, + String revision, + String depth, + boolean ignoreExternals, + String accept, + @Nullable Credentials credentials); Promise showLog(Path project, Path[] paths, String revision); - Promise showDiff(Path project, Path[] paths, String revision); + Promise showDiff(Path project, Path[] paths, String revision, @Nullable Credentials credentials); /** * Locks the given paths. @@ -178,8 +195,10 @@ Promise status(Path project, * @param force * if false, will warn if another user already has a lock on a target, leave this target unchanged, and continue.
* if true, will steal the lock from the previous owner instead + * @param credentials + * {@link Credentials} object that contains user name and password for authentication */ - Promise lock(Path project, Path[] paths, boolean force); + Promise lock(Path project, Path[] paths, boolean force, @Nullable Credentials credentials); /** * Unocks the given paths. @@ -191,8 +210,10 @@ Promise status(Path project, * @param force * if false, will warn if another user already has a lock on a target, leave this target unchanged, and continue.
* if true, will unlock anyway + * @param credentials + * {@link Credentials} object that contains user name and password for authentication */ - Promise unlock(Path project, Path[] paths, boolean force); + Promise unlock(Path project, Path[] paths, boolean force, @Nullable Credentials credentials); /** * Commits the changes in the repository. @@ -224,8 +245,6 @@ Promise status(Path project, Promise resolve(Path project, Map resolutions, String depth); - Promise saveCredentials(String repositoryUrl, String username, String password); - /** * Move provided path. * @@ -233,10 +252,14 @@ Promise status(Path project, * the project path * @param source * source item path - * @param destination - * destination path + * @param credentials + * {@link Credentials} object that contains user name and password for authentication */ - Promise move(Path project, Path source, Path destination, String comment); + Promise move(Path project, + Path source, + Path destination, + String comment, + @Nullable Credentials credentials); /** * Set specified property to a path or a target. @@ -259,17 +282,22 @@ Promise status(Path project, /** * Get specified property for a path or a target. * - * @param project the project path - * @param propertyName the property name - * @param path path to which property get + * @param project + * the project path + * @param propertyName + * the property name + * @param path + * path to which property get */ Promise propertyGet(Path project, String propertyName, Path path); /** * Get properties set for a path or a target. * - * @param project the project path - * @param path path to which property get + * @param project + * the project path + * @param path + * path to which property get */ Promise propertyList(Path project, Path path); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientServiceImpl.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientServiceImpl.java index 5a61ce24eef1..da4e960a186f 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientServiceImpl.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionClientServiceImpl.java @@ -15,6 +15,7 @@ import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.app.AppContext; +import org.eclipse.che.ide.api.subversion.Credentials; import org.eclipse.che.ide.dto.DtoFactory; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.rest.AsyncRequestFactory; @@ -44,7 +45,6 @@ import org.eclipse.che.plugin.svn.shared.RemoveRequest; import org.eclipse.che.plugin.svn.shared.ResolveRequest; import org.eclipse.che.plugin.svn.shared.RevertRequest; -import org.eclipse.che.plugin.svn.shared.SaveCredentialsRequest; import org.eclipse.che.plugin.svn.shared.ShowDiffRequest; import org.eclipse.che.plugin.svn.shared.ShowLogRequest; import org.eclipse.che.plugin.svn.shared.StatusRequest; @@ -105,7 +105,7 @@ public Promise add(Path project, Path[] path, String depth, b .send(dtoUnmarshallerFactory.newUnmarshaller(CLIOutputResponse.class)); } - @Override + @Override public Promise revert(Path project, Path[] paths, String depth) { final RevertRequest request = dtoFactory.createDto(RevertRequest.class) .withProjectPath(project.toString()) @@ -117,12 +117,16 @@ public Promise revert(Path project, Path[] paths, String dept } @Override - public Promise copy(Path project, Path source, Path destination, String comment) { + public Promise copy(Path project, Path source, Path destination, String comment, Credentials credentials) { final CopyRequest request = dtoFactory.createDto(CopyRequest.class) .withProjectPath(project.toString()) .withSource(source.toString()) .withDestination(destination.toString()) .withComment(comment); + if (credentials != null) { + request.setUsername(credentials.getUsername()); + request.setPassword(credentials.getPassword()); + } return asyncRequestFactory.createPostRequest(getBaseUrl() + "/copy", request) .loader(loader) @@ -153,25 +157,21 @@ public Promise merge(Path project, Path target, Path sourceUr } @Override - public Promise info(Path project, Path target, String revision, boolean children) { - final InfoRequest request = dtoFactory.createDto(InfoRequest.class) - .withProjectPath(project.toString()) - .withTarget(target.toString()) - .withRevision(revision) - .withChildren(children); - - return asyncRequestFactory.createPostRequest(getBaseUrl() + "/info", request) - .loader(loader) - .send(dtoUnmarshallerFactory.newUnmarshaller(InfoResponse.class)); + public Promise info(Path project, String target, String revision, boolean children) { + return info(project, Path.valueOf(target), revision, children, dtoFactory.createDto(Credentials.class)); } @Override - public Promise info(Path project, String target, String revision, boolean children) { + public Promise info(Path project, Path target, String revision, boolean children, Credentials credentials) { final InfoRequest request = dtoFactory.createDto(InfoRequest.class) .withProjectPath(project.toString()) - .withTarget(target) + .withTarget(target.toString()) .withRevision(revision) .withChildren(children); + if (credentials != null) { + request.setUsername(credentials.getUsername()); + request.setPassword(credentials.getPassword()); + } return asyncRequestFactory.createPostRequest(getBaseUrl() + "/info", request) .loader(loader) @@ -198,8 +198,13 @@ public Promise status(Path project, Path[] paths, String dept } @Override - public Promise update(Path project, Path[] paths, String revision, String depth, boolean ignoreExternals, - String accept) { + public Promise update(Path project, + Path[] paths, + String revision, + String depth, + boolean ignoreExternals, + String accept, + Credentials credentials) { final UpdateRequest request = dtoFactory.createDto(UpdateRequest.class) .withProjectPath(project.toString()) @@ -208,6 +213,10 @@ public Promise update(Path project, Path[] paths, .withDepth(depth) .withIgnoreExternals(ignoreExternals) .withAccept(accept); + if (credentials != null) { + request.setUsername(credentials.getUsername()); + request.setPassword(credentials.getPassword()); + } return asyncRequestFactory.createPostRequest(getBaseUrl() + "/update", request) .loader(loader) @@ -227,36 +236,51 @@ public Promise showLog(Path project, Path[] paths, String rev } @Override - public Promise lock(Path project, Path[] paths, boolean force) { + public Promise lock(Path project, Path[] paths, boolean force, Credentials credentials) { final String url = getBaseUrl() + "/lock"; final LockRequest request = dtoFactory.createDto(LockRequest.class) .withProjectPath(project.toString()) .withTargets(toList(paths)) .withForce(force); + if (credentials != null) { + request.setUsername(credentials.getUsername()); + request.setPassword(credentials.getPassword()); + } + return asyncRequestFactory.createPostRequest(url, request) .loader(loader) .send(dtoUnmarshallerFactory.newUnmarshaller(CLIOutputResponse.class)); } @Override - public Promise unlock(Path project, Path[] paths, boolean force) { + public Promise unlock(Path project, Path[] paths, boolean force, Credentials credentials) { final String url = getBaseUrl() + "/unlock"; final LockRequest request = dtoFactory.createDto(LockRequest.class) .withProjectPath(project.toString()) .withTargets(toList(paths)) .withForce(force); + if (credentials != null) { + request.setUsername(credentials.getUsername()); + request.setPassword(credentials.getPassword()); + } + return asyncRequestFactory.createPostRequest(url, request) .loader(loader) .send(dtoUnmarshallerFactory.newUnmarshaller(CLIOutputResponse.class)); } @Override - public Promise showDiff(Path project, Path[] paths, String revision) { + public Promise showDiff(Path project, Path[] paths, String revision, Credentials credentials) { final String url = getBaseUrl() + "/showdiff"; final ShowDiffRequest request = dtoFactory.createDto(ShowDiffRequest.class) .withProjectPath(project.toString()) .withPaths(toList(paths)) .withRevision(revision); + if (credentials != null) { + request.setUsername(credentials.getUsername()); + request.setPassword(credentials.getPassword()); + } + return asyncRequestFactory.createPostRequest(url, request) .loader(loader) .send(dtoUnmarshallerFactory.newUnmarshaller(CLIOutputResponse.class)); @@ -320,23 +344,17 @@ public Promise resolve(Path project, Map } @Override - public Promise saveCredentials(String repositoryUrl, String username, String password) { - final String url = getBaseUrl() + "/saveCredentials"; - final SaveCredentialsRequest request = dtoFactory.createDto(SaveCredentialsRequest.class) - .withUsername(username) - .withPassword(password) - .withRepositoryUrl(repositoryUrl); - return asyncRequestFactory.createPostRequest(url, request).loader(loader).send(); - } - - @Override - public Promise move(Path project, Path source, Path destination, String comment) { + public Promise move(Path project, Path source, Path destination, String comment, Credentials credentials) { final MoveRequest request = dtoFactory.createDto(MoveRequest.class) .withProjectPath(project.toString()) .withSource(Collections.singletonList(source.toString())) .withDestination(destination.toString()) .withComment(comment); + if (credentials != null) { + request.setUsername(credentials.getUsername()); + request.setPassword(credentials.getPassword()); + } return asyncRequestFactory.createPostRequest(getBaseUrl() + "/move", request) .loader(loader) diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtension.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtension.java index 5501dc93afb4..252aef7528b5 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtension.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtension.java @@ -20,7 +20,6 @@ import org.eclipse.che.ide.api.constraints.Constraints; import org.eclipse.che.ide.api.extension.Extension; import org.eclipse.che.plugin.svn.ide.action.AddAction; -import org.eclipse.che.plugin.svn.ide.action.ChangeCredentialsAction; import org.eclipse.che.plugin.svn.ide.action.CleanupAction; import org.eclipse.che.plugin.svn.ide.action.CommitAction; import org.eclipse.che.plugin.svn.ide.action.CopyAction; @@ -60,7 +59,6 @@ public class SubversionExtension { @Inject public SubversionExtension(final ActionManager actionManager, final AddAction addAction, - final ChangeCredentialsAction changeCredentialsAction, final CleanupAction cleanupAction, final CommitAction commitAction, final DiffAction diffAction, @@ -82,7 +80,6 @@ public SubversionExtension(final ActionManager actionManager, final SubversionExtensionResources resources) { SVN_GROUP_MAIN_MENU = constants.subversionLabel(); - final Constraints beforeWindow = new Constraints(Anchor.BEFORE, IdeActions.GROUP_HELP); final DefaultActionGroup addCommandGroup = new DefaultActionGroup(ADD_COMMAND_GROUP, false, actionManager); final DefaultActionGroup mainMenu = (DefaultActionGroup)actionManager.getAction(IdeActions.GROUP_MAIN_MENU); final DefaultActionGroup fileCommandGroup = new DefaultActionGroup(FILE_COMMAND_GROUP, false, actionManager); @@ -100,7 +97,7 @@ public SubversionExtension(final ActionManager actionManager, // Register action groups actionManager.registerAction(SVN_GROUP_MAIN_MENU, svnMenu); - mainMenu.add(svnMenu, beforeWindow); + mainMenu.add(svnMenu, new Constraints(Anchor.BEFORE, IdeActions.GROUP_PROFILE)); actionManager.registerAction(REMOTE_COMMAND_GROUP, remoteCommandGroup); svnMenu.add(remoteCommandGroup); @@ -175,9 +172,6 @@ public SubversionExtension(final ActionManager actionManager, actionManager.registerAction("SvnCleanup", cleanupAction); addCommandGroup.add(cleanupAction); - actionManager.registerAction("SvnChangeCredentials", changeCredentialsAction); - credentialsCommandGroup.add(changeCredentialsAction); - //context menu DefaultActionGroup contextGroup = new DefaultActionGroup("Subversion", true, actionManager); contextGroup.getTemplatePresentation().setDescription("Subversion operation..."); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.java index 8a8159472b47..2b135385efa4 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.java @@ -81,6 +81,9 @@ public interface SubversionExtensionLocalizationConstants extends Messages { @Key("action.not.implemented") String actionNotImplemented(); + @Key("waiting.credentials") + String waitingCredentials(); + @Key("add.description") String addDescription(); @@ -497,18 +500,6 @@ public interface SubversionExtensionLocalizationConstants extends Messages { @Key("error.unlock.directory.dialog.title") String dialogTitleUnlockDirectory(); - - // save credentials - - @Key("save.credentials.started") - String notificationSavingCredentials(String repositoryUrl); - - @Key("save.credentials.finished") - String notificationCredentialsSaved(String repositoryUrl); - - @Key("save.credentials.failed") - String notificationCredentialsFailed(String repositoryUrl); - /* Export dialog */ @Key("download.title") @@ -581,6 +572,22 @@ public interface SubversionExtensionLocalizationConstants extends Messages { @Key("move.item.child.detect") String moveItemChildDetected(); + /* Credentials dialog */ + @Key("credentials.dialog.title") + String credentialsDialogTitle(); + + @Key("credentials.dialog.username") + String credentialsDialogUsername(); + + @Key("credentials.dialog.password") + String credentialsDialogPassword(); + + @Key("credentials.dialog.authenticate.button") + String credentialsDialogAuthenticateButton(); + + @Key("credentials.dialog.cancel.button") + String credentialsDialogCancelButton(); + /** Property */ @Key("property.modify.start") String propertyModifyStart(); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/action/ChangeCredentialsAction.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/action/ChangeCredentialsAction.java deleted file mode 100644 index adf2f3d3f32e..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/action/ChangeCredentialsAction.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.ide.action; - -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import org.eclipse.che.ide.api.action.ActionEvent; -import org.eclipse.che.ide.api.app.AppContext; -import org.eclipse.che.ide.api.resources.Project; -import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; -import org.eclipse.che.plugin.svn.ide.SubversionExtensionResources; -import org.eclipse.che.plugin.svn.ide.askcredentials.AskCredentialsPresenter; - -import java.util.List; - -import static com.google.common.base.Preconditions.checkState; -import static org.eclipse.che.plugin.svn.shared.SubversionTypeConstant.SUBVERSION_ATTRIBUTE_REPOSITORY_URL; - -/** - * Extension of {@link SubversionAction} for changing username/password. - */ -@Singleton -public class ChangeCredentialsAction extends SubversionAction { - - private final AskCredentialsPresenter presenter; - - @Inject - public ChangeCredentialsAction(AppContext appContext, - SubversionExtensionLocalizationConstants constants, - SubversionExtensionResources resources, - AskCredentialsPresenter presenter) { - super(constants.changeCredentialsTitle(), constants.changeCredentialsDescription(), resources.add(), appContext, constants, - resources); - - this.presenter = presenter; - } - - @Override - public void actionPerformed(final ActionEvent e) { - final Project project = appContext.getRootProject(); - - checkState(project != null, "Null project occurred"); - checkState(project.getAttributes().containsKey(SUBVERSION_ATTRIBUTE_REPOSITORY_URL), "Project doesn't have svn url property"); - - final List values = project.getAttributes().get(SUBVERSION_ATTRIBUTE_REPOSITORY_URL); - - checkState(!values.isEmpty(), "Project doesn't have any bound svn url"); - - presenter.askCredentials(values.get(0)); - } -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/add/AddPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/add/AddPresenter.java index e38e34fd14ac..9140bc242357 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/add/AddPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/add/AddPresenter.java @@ -21,6 +21,7 @@ import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -51,10 +52,11 @@ protected AddPresenter(AppContext appContext, NotificationManager notificationManager, SubversionOutputConsoleFactory consoleFactory, SubversionExtensionLocalizationConstants constants, + SubversionCredentialsDialog credentialsDialog, SubversionClientService service, ProcessesPanelPresenter processesPanelPresenter, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.service = service; this.notificationManager = notificationManager; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsPresenter.java deleted file mode 100644 index 4eaeec9be868..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsPresenter.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.ide.askcredentials; - -import org.eclipse.che.api.promises.client.Operation; -import org.eclipse.che.api.promises.client.OperationException; -import org.eclipse.che.api.promises.client.PromiseError; -import org.eclipse.che.ide.api.notification.NotificationManager; -import org.eclipse.che.ide.api.notification.StatusNotification; -import org.eclipse.che.plugin.svn.ide.SubversionClientService; -import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; -import org.eclipse.che.plugin.svn.ide.askcredentials.AskCredentialsView.AskCredentialsDelegate; - -import javax.inject.Inject; - -import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE; -import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL; -import static org.eclipse.che.ide.api.notification.StatusNotification.Status.PROGRESS; -import static org.eclipse.che.ide.api.notification.StatusNotification.Status.SUCCESS; - -public class AskCredentialsPresenter implements AskCredentialsDelegate { - - private final AskCredentialsView view; - private final NotificationManager notificationManager; - private final SubversionExtensionLocalizationConstants constants; - private final SubversionClientService clientService; - private String repositoryUrl; - - @Inject - public AskCredentialsPresenter(AskCredentialsView view, - NotificationManager notificationManager, - SubversionExtensionLocalizationConstants constants, - SubversionClientService clientService) { - this.notificationManager = notificationManager; - this.constants = constants; - this.view = view; - this.view.setDelegate(this); - this.clientService = clientService; - } - - @Override - public void onSaveClicked() { - saveCredentials(view.getUsername(), view.getPassword()); - view.clearUsername(); - view.clearPassword(); - view.close(); - } - - @Override - public void onCancelClicked() { - view.clearUsername(); - view.clearPassword(); - view.close(); - } - - public void askCredentials(String repositoryUrl) { - view.clearUsername(); - view.clearPassword(); - view.setRepositoryUrl(repositoryUrl); - this.repositoryUrl = repositoryUrl; - view.showDialog(); - } - - private void saveCredentials(String username, String password) { - final StatusNotification notification = - new StatusNotification(constants.notificationSavingCredentials(repositoryUrl), PROGRESS, FLOAT_MODE); - notificationManager.notify(notification); - clientService.saveCredentials(repositoryUrl, username, password).then(new Operation() { - @Override - public void apply(Void arg) throws OperationException { - notification.setTitle(constants.notificationCredentialsSaved(repositoryUrl)); - notification.setStatus(SUCCESS); - } - }).catchError(new Operation() { - @Override - public void apply(PromiseError arg) throws OperationException { - notification.setTitle(constants.notificationCredentialsFailed(repositoryUrl)); - notification.setStatus(FAIL); - } - }); - } -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsViewImpl.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsViewImpl.java deleted file mode 100644 index b2d46976fd5e..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsViewImpl.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.ide.askcredentials; - -import javax.inject.Inject; - -import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; -import org.eclipse.che.plugin.svn.ide.SubversionExtensionResources; -import org.eclipse.che.ide.ui.window.Window; - -import com.google.gwt.dom.client.Element; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; -import com.google.gwt.uibinder.client.UiTemplate; -import com.google.gwt.user.client.ui.Button; -import com.google.gwt.user.client.ui.PasswordTextBox; -import com.google.gwt.user.client.ui.TextBox; -import com.google.gwt.user.client.ui.Widget; - -public class AskCredentialsViewImpl extends Window implements AskCredentialsView { - - private AskCredentialsDelegate delegate; - - @UiField(provided = true) - SubversionExtensionLocalizationConstants locale; - - @UiField(provided = true) - SubversionExtensionResources res; - - @UiField - Element repositoryUrl; - - @UiField - TextBox username; - - @UiField - PasswordTextBox password; - - private final Button btnCancel; - private final Button btnSave; - - @UiTemplate(value = "AskCredentialsViewImpl.ui.xml") - interface AskCredentialsViewImplUiBinder extends UiBinder {} - - @Inject - public AskCredentialsViewImpl(final AskCredentialsViewImplUiBinder uibinder, - final SubversionExtensionLocalizationConstants constants, - final SubversionExtensionResources resources, - final Window.Resources windowResources) { - super(true); - this.locale = constants; - this.res = resources; - final Widget widget = uibinder.createAndBindUi(this); - - this.setTitle(locale.askCredentialsTitle()); - this.setWidget(widget); - - btnCancel = createButton(locale.askCredentialsCancel(), "svn-askcred-cancel", new ClickHandler() { - @Override - public void onClick(final ClickEvent event) { - delegate.onCancelClicked(); - } - }); - btnSave = createButton(locale.askCredentialsValidate(), "svn-askcred-save", new ClickHandler() { - @Override - public void onClick(final ClickEvent event) { - delegate.onSaveClicked(); - } - }); - btnSave.addStyleName(windowResources.windowCss().button()); - - addButtonToFooter(btnSave); - addButtonToFooter(btnCancel); - } - - @Override - protected void onClose() { - } - - @Override - public void setDelegate(final AskCredentialsDelegate delegate) { - this.delegate = delegate; - } - - @Override - public void close() { - this.hide(); - } - - @Override - public void showDialog() { - this.show(); - } - - @Override - public void focusInUserNameField() { - this.username.setFocus(true); - } - - @Override - public void setRepositoryUrl(final String url) { - this.repositoryUrl.setInnerText(url); - } - - @Override - public void clearUsername() { - this.username.setValue(""); - } - - @Override - public void clearPassword() { - this.password.setValue(""); - } - - @Override - public String getUsername() { - return this.username.getValue(); - } - - @Override - public String getPassword() { - return this.password.getValue(); - } - -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsViewImpl.ui.xml b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsViewImpl.ui.xml deleted file mode 100644 index a589e17f6b35..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsViewImpl.ui.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - .spacing { - margin-bottom: 10px; - } - - .mainPanel { - min-width: 20px; - min-height: 120px; - } - - .emptyBorder { - margin: 6px; - } - - .space { - margin-right: 5px; - } - - .field { - display: -webkit-flex; - display: flex; - -webkit-flex-direction: column; - flex-direction: column; - -webkit-align-items: flex-start; - align-items: flex-start; - margin-bottom: 3px; - } - .spaceBelow { - margin-bottom: 3em; - } - - .box { - width: 15em; - margin-left: 3px; - } - - .label { - display: -webkit-flex; - display: flex; - -webkit-flex-direction: row; - flex-direction: row; - justify-content: flex-end; - -webkit-justify-content: flex-end; - width: 20em; - text-align: left; - } - - - - -
-
- -
-
- -
- - - diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/cleanup/CleanupPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/cleanup/CleanupPresenter.java index 5e903beb03bd..2949a16c1013 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/cleanup/CleanupPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/cleanup/CleanupPresenter.java @@ -20,6 +20,7 @@ import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -47,11 +48,12 @@ public class CleanupPresenter extends SubversionActionPresenter { protected CleanupPresenter(AppContext appContext, NotificationManager notificationManager, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog credentialsDialog, ProcessesPanelPresenter processesPanelPresenter, SubversionExtensionLocalizationConstants constants, SubversionClientService service, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.service = service; this.notificationManager = notificationManager; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/CommitPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/CommitPresenter.java index 53ed86f26fd4..ff937c5572ec 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/CommitPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/CommitPresenter.java @@ -15,12 +15,15 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.util.Arrays; @@ -57,7 +60,8 @@ public class CommitPresenter extends SubversionActionPresenter implements Action private final SubversionClientService service; private final CommitView view; - private DiffViewerPresenter diffViewerPresenter; + private final SubversionCredentialsDialog subversionCredentialsDialog; + private final DiffViewerPresenter diffViewerPresenter; private final NotificationManager notificationManager; private final SubversionExtensionLocalizationConstants constants; @@ -75,12 +79,14 @@ public CommitPresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, SubversionExtensionLocalizationConstants constants, SubversionClientService service, + SubversionCredentialsDialog subversionCredentialsDialog, ProcessesPanelPresenter processesPanelPresenter, DiffViewerPresenter diffViewerPresenter, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, subversionCredentialsDialog); this.service = service; this.view = view; + this.subversionCredentialsDialog = subversionCredentialsDialog; this.diffViewerPresenter = diffViewerPresenter; this.view.setDelegate(this); this.notificationManager = notificationManager; @@ -98,24 +104,24 @@ private void loadAllChanges() { service.status(project.getLocation(), new Path[0], null, false, false, false, true, false, null) .then(new Operation() { - @Override - public void apply(CLIOutputResponse response) throws OperationException { - List statusItems = parseChangesList(response); - view.setChangesList(statusItems); - view.onShow(); - - cache.put(Changes.ALL, statusItems); - } - }) - .catchError(new Operation() { - @Override - public void apply(PromiseError error) throws OperationException { - Log.error(CommitPresenter.class, error.getMessage()); - } - }); + @Override + public void apply(CLIOutputResponse response) throws OperationException { + List statusItems = parseChangesList(response); + view.setChangesList(statusItems); + view.onShow(); + + cache.put(Changes.ALL, statusItems); + } + }) + .catchError(new Operation() { + @Override + public void apply(PromiseError error) throws OperationException { + Log.error(CommitPresenter.class, error.getMessage()); + } + }); } - private List parseChangesList(CLIOutputResponse response) { + private List parseChangesList(CLIOutputResponse response) { return CLIOutputParser.parseFilesStatus(response.getOutput()); } @@ -183,12 +189,20 @@ public void onCommitClicked() { /** {@inheritDoc} */ @Override - public void showDiff(String path) { + public void showDiff(final String path) { final Project project = appContext.getRootProject(); checkState(project != null); - service.showDiff(project.getLocation(), new Path[]{valueOf(path)}, "HEAD").then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + return service.showDiff(project.getLocation(), + new Path[]{valueOf(path)}, + "HEAD", + credentials); + } + }, null).then(new Operation() { @Override public void apply(CLIOutputResponse response) throws OperationException { String content = Joiner.on('\n').join(response.getOutput()); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/diff/DiffViewerPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/diff/DiffViewerPresenter.java index c9975643bb0a..1e0db801c027 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/diff/DiffViewerPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/commit/diff/DiffViewerPresenter.java @@ -14,7 +14,10 @@ import com.google.inject.Singleton; import org.eclipse.che.ide.api.app.AppContext; +import org.eclipse.che.ide.api.notification.NotificationManager; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; +import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; import org.eclipse.che.plugin.svn.ide.common.StatusColors; import org.eclipse.che.plugin.svn.ide.common.SubversionActionPresenter; import org.eclipse.che.plugin.svn.ide.common.SubversionOutputConsoleFactory; @@ -32,10 +35,13 @@ public class DiffViewerPresenter extends SubversionActionPresenter implements Di @Inject protected DiffViewerPresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog credentialsDialog, + SubversionExtensionLocalizationConstants constants, + NotificationManager notificationManager, ProcessesPanelPresenter processesPanelPresenter, DiffViewerView view, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.view = view; this.view.setDelegate(this); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionActionPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionActionPresenter.java index 94de995328b5..e52f7da77803 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionActionPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionActionPresenter.java @@ -10,35 +10,61 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.ide.common; +import org.eclipse.che.api.core.ErrorCodes; +import org.eclipse.che.api.promises.client.Function; +import org.eclipse.che.api.promises.client.FunctionException; +import org.eclipse.che.api.promises.client.Promise; +import org.eclipse.che.api.promises.client.PromiseError; +import org.eclipse.che.api.promises.client.js.Promises; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.ide.api.app.AppContext; +import org.eclipse.che.ide.api.notification.NotificationManager; +import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Container; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.util.Arrays; +import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; import org.eclipse.che.plugin.svn.ide.action.SubversionAction; import java.util.List; +import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE; +import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL; +import static org.eclipse.che.ide.api.notification.StatusNotification.Status.PROGRESS; +import static org.eclipse.che.ide.util.ExceptionUtils.getErrorCode; + /** * Presenter to be extended by all {@link SubversionAction} presenters. */ public class SubversionActionPresenter { - protected final AppContext appContext; - private final SubversionOutputConsoleFactory consoleFactory; - private final ProcessesPanelPresenter consolesPanelPresenter; - private final StatusColors statusColors; + protected final AppContext appContext; + private final SubversionOutputConsoleFactory consoleFactory; + private final ProcessesPanelPresenter consolesPanelPresenter; + private final StatusColors statusColors; + private final SubversionExtensionLocalizationConstants locale; + private final NotificationManager notificationManager; + private final SubversionCredentialsDialog credentialsDialog; protected SubversionActionPresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, ProcessesPanelPresenter processesPanelPresenter, - StatusColors statusColors) { + StatusColors statusColors, + SubversionExtensionLocalizationConstants locale, + NotificationManager notificationManager, + SubversionCredentialsDialog credentialsDialog) { this.appContext = appContext; this.consoleFactory = consoleFactory; this.consolesPanelPresenter = processesPanelPresenter; this.statusColors = statusColors; + this.locale = locale; + this.notificationManager = notificationManager; + this.credentialsDialog = credentialsDialog; } protected Path[] toRelative(Container project, Resource[] paths) { @@ -68,8 +94,10 @@ protected Path toRelative(Container project, Resource path) { /** * Prints errors output in console. * - * @param errors the error output - * @param consoleTitle the title of the console to use + * @param errors + * the error output + * @param consoleTitle + * the title of the console to use */ protected void printErrors(final List errors, final String consoleTitle) { final SubversionOutputConsole console = consoleFactory.create(consoleTitle); @@ -82,10 +110,14 @@ protected void printErrors(final List errors, final String consoleTitle) /** * Colorizes and prints response outputs in console. * - * @param command the SVN command that was executed - * @param output the command output - * @param errors the error output - * @param consoleTitle the title of the console to use + * @param command + * the SVN command that was executed + * @param output + * the command output + * @param errors + * the error output + * @param consoleTitle + * the title of the console to use */ protected void printResponse(final String command, final List output, final List errors, final String consoleTitle) { final SubversionOutputConsole console = consoleFactory.create(consoleTitle); @@ -107,11 +139,54 @@ protected void printResponse(final String command, final List output, fi consolesPanelPresenter.addCommandOutput(appContext.getDevMachine().getId(), console); } + /** + * Performs subversion operation. If this operations fails with authorization error + * the operation will be recalled with requested credentials + * + * @param notification + * progress notification to set operation status + */ + protected Promise performOperationWithCredentialsRequestIfNeeded(final RemoteSubversionOperation operation, + @Nullable final StatusNotification notification) { + return operation.perform(null) + .catchErrorPromise(new Function>() { + @Override + public Promise apply(PromiseError error) throws FunctionException { + if (getErrorCode(error.getCause()) == ErrorCodes.UNAUTHORIZED_SVN_OPERATION) { + if (notification != null) { + notification.setTitle(locale.waitingCredentials()); + notification.setStatus(PROGRESS); + } else { + notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); + } + + return credentialsDialog.askCredentials() + .thenPromise(new Function>() { + @Override + public Promise apply(Credentials credentials) throws FunctionException { + return operation.perform(credentials); + } + }); + } + return Promises.reject(error); + } + }); + } + + /** + * Remote Subversion operation that can require credentials. + */ + protected interface RemoteSubversionOperation { + Promise perform(Credentials credentials); + } + /** * Prints an executed command line in given console. * - * @param command the SVN command that was executed - * @param console the console to use to print + * @param command + * the SVN command that was executed + * @param console + * the console to use to print */ private void printCommand(String command, final SubversionOutputConsole console) { if (command.startsWith("'") || command.startsWith("\"")) { @@ -125,8 +200,10 @@ private void printCommand(String command, final SubversionOutputConsole console) /** * Prints output in given console. * - * @param output the command output - * @param console the console to use to print + * @param output + * the command output + * @param console + * the console to use to print */ private void printOutput(List output, SubversionOutputConsole console) { for (final String line : output) { @@ -135,14 +212,14 @@ private void printOutput(List output, SubversionOutputConsole console) { String prefix = trimLine.substring(0, 1); final String color = statusColors.getStatusColor(prefix); - if (color != null) { - // TODO: Turn the file paths into links (where appropriate) - console.print(line, color); - } else { - console.print(line); - } + if (color != null) { + // TODO: Turn the file paths into links (where appropriate) + console.print(line, color); + } else { + console.print(line); } } + } console.print(""); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionOutputConsolePresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionOutputConsolePresenter.java index 2b075f768365..0337208f5c11 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionOutputConsolePresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/common/SubversionOutputConsolePresenter.java @@ -34,7 +34,7 @@ public class SubversionOutputConsolePresenter implements SubversionOutputConsole private final SubversionOutputConsoleView view; private final String title; - private final List outputListeners = new ArrayList<>(); + private final List actionDelegates = new ArrayList<>(); @Inject public SubversionOutputConsolePresenter(final SubversionExtensionLocalizationConstants constants, @@ -67,8 +67,8 @@ public void print(@NotNull final String text) { } view.scrollBottom(); - for (ConsoleOutputListener outputListener : outputListeners) { - outputListener.onConsoleOutput(this); + for (ActionDelegate actionDelegate : actionDelegates) { + actionDelegate.onConsoleOutput(this); } } @@ -84,8 +84,8 @@ public void print(@NotNull String text, @NotNull String color) { view.print(text, color); view.scrollBottom(); - for (ConsoleOutputListener outputListener : outputListeners) { - outputListener.onConsoleOutput(this); + for (ActionDelegate actionDelegate : actionDelegates) { + actionDelegate.onConsoleOutput(this); } } @@ -99,8 +99,8 @@ public void print(@NotNull String text, @NotNull String color) { public void printCommand(@NotNull String text) { view.printPredefinedStyle(text, "font-weight: bold; font-style: italic;"); - for (ConsoleOutputListener outputListener : outputListeners) { - outputListener.onConsoleOutput(this); + for (ActionDelegate actionDelegate : actionDelegates) { + actionDelegate.onConsoleOutput(this); } } @@ -130,7 +130,9 @@ public void onScrollClicked() { } @Override - public String getTitle() { return title; } + public String getTitle() { + return title; + } /** * Returns the title SVG image resource of this console. @@ -155,7 +157,6 @@ public boolean isFinished() { */ @Override public void stop() { - } /** @@ -163,16 +164,12 @@ public void stop() { */ @Override public void close() { - outputListeners.clear(); + actionDelegates.clear(); } - /** - * Adds an output listener. - * - * @param listener - */ @Override - public void addOutputListener(ConsoleOutputListener listener) { - outputListeners.add(listener); + public void addActionDelegate(ActionDelegate actionDelegate) { + actionDelegates.add(actionDelegate); } + } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/copy/CopyPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/copy/CopyPresenter.java index 49080d2e7ff5..3079fb663613 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/copy/CopyPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/copy/CopyPresenter.java @@ -17,12 +17,15 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.util.RegExpUtils; @@ -47,25 +50,27 @@ @Singleton public class CopyPresenter extends SubversionActionPresenter implements CopyView.ActionDelegate { - private CopyView view; - private NotificationManager notificationManager; - private SubversionClientService service; - private SubversionExtensionLocalizationConstants constants; - private Resource sourceNode; + private final CopyView view; + private final NotificationManager notificationManager; + private final SubversionClientService service; + private final SubversionExtensionLocalizationConstants constants; private RegExp urlRegExp = RegExp.compile("^(https?|ftp)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]"); + + private Resource sourceNode; private Resource target; @Inject protected CopyPresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog subversionCredentialsDialog, ProcessesPanelPresenter processesPanelPresenter, CopyView view, NotificationManager notificationManager, SubversionClientService service, SubversionExtensionLocalizationConstants constants, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, subversionCredentialsDialog); this.view = view; this.notificationManager = notificationManager; this.service = service; @@ -112,12 +117,22 @@ public void onCopyClicked() { final Path target = view.isTargetCheckBoxSelected() ? Path.valueOf(view.getTargetUrl()) : toRelative(project, this.target); final String comment = view.isTargetCheckBoxSelected() ? view.getComment() : null; - final StatusNotification notification = new StatusNotification(constants.copyNotificationStarted(src.toString()), PROGRESS, FLOAT_MODE); + final StatusNotification notification = new StatusNotification(constants.copyNotificationStarted(src.toString()), + PROGRESS, + FLOAT_MODE); notificationManager.notify(notification); view.hide(); - service.copy(project.getLocation(), src, target, comment).then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + notification.setStatus(PROGRESS); + notification.setTitle(constants.copyNotificationStarted(src.toString())); + + return service.copy(project.getLocation(), src, target, comment, credentials); + } + }, notification).then(new Operation() { @Override public void apply(CLIOutputResponse response) throws OperationException { printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandCopy()); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogImpl.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogImpl.java new file mode 100644 index 000000000000..f249aa35757b --- /dev/null +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogImpl.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.svn.ide.credentialsdialog; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.inject.Inject; + +import org.eclipse.che.api.promises.client.Promise; +import org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper.RequestCall; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; + +import static org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper.createFromAsyncRequest; +import static org.eclipse.che.ide.util.StringUtils.isNullOrEmpty; + +/** + * Implementation of {@link SubversionCredentialsDialog}. + * + * @author Igor Vinokur + */ +public class SubversionCredentialsDialogImpl implements SubversionCredentialsDialog, SubversionCredentialsDialogViewImpl.ActionDelegate { + + private final SubversionCredentialsDialogView view; + + private AsyncCallback callback; + + @Inject + public SubversionCredentialsDialogImpl(SubversionCredentialsDialogView view) { + this.view = view; + this.view.setDelegate(this); + } + + @Override + public Promise askCredentials() { + view.cleanCredentials(); + view.showDialog(); + return createFromAsyncRequest(new RequestCall() { + @Override + public void makeCall(final AsyncCallback callback) { + SubversionCredentialsDialogImpl.this.callback = callback; + } + }); + } + + @Override + public void onCancelClicked() { + callback.onFailure(new Exception("Authorization request rejected by user.")); + view.closeDialog(); + } + + @Override + public void onAuthenticateClicked() { + callback.onSuccess(new Credentials(view.getUsername(), view.getPassword())); + view.closeDialog(); + } + + @Override + public void onCredentialsChanged() { + view.setEnabledAuthenticateButton(!isNullOrEmpty(view.getUsername()) && !isNullOrEmpty(view.getPassword())); + } +} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogView.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogView.java new file mode 100644 index 000000000000..738337475e3f --- /dev/null +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogView.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.svn.ide.credentialsdialog; + +import com.google.inject.ImplementedBy; + +import org.eclipse.che.ide.api.mvp.View; + +/** + * The view of {@link SubversionCredentialsDialogImpl}. + * + * @author Igor Vinokur + */ +@ImplementedBy(SubversionCredentialsDialogViewImpl.class) +interface SubversionCredentialsDialogView extends View { + + interface ActionDelegate { + /** Performs any actions appropriate in response to the user clicks cancel button. */ + void onCancelClicked(); + + /** Performs any actions appropriate in response to the user clicks Authenticate button. */ + void onAuthenticateClicked(); + + /** Performs any actions appropriate in response to the user having changed the user name or password */ + void onCredentialsChanged(); + } + + /** @return username */ + String getUsername(); + + /** @return password */ + String getPassword(); + + /** Clean username and password fields. */ + void cleanCredentials(); + + /** Enable or disable Authenticate button. */ + void setEnabledAuthenticateButton(boolean enabled); + + /** Show dialog. */ + void showDialog(); + + /** Close dialog. */ + void closeDialog(); +} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogViewImpl.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogViewImpl.java new file mode 100644 index 000000000000..70c0ee902256 --- /dev/null +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogViewImpl.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.svn.ide.credentialsdialog; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.KeyUpEvent; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.uibinder.client.UiHandler; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.TextBox; +import com.google.gwt.user.client.ui.Widget; +import com.google.inject.Inject; + +import org.eclipse.che.ide.ui.window.Window; +import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; + +/** + * Implementation of {@link SubversionCredentialsDialogView} + * + * @author Igor Vinokur + */ +public class SubversionCredentialsDialogViewImpl extends Window implements SubversionCredentialsDialogView { + + @UiField(provided = true) + final SubversionExtensionLocalizationConstants locale; + + interface SubversionAuthenticatorImplUiBinder extends UiBinder { + } + + private static SubversionAuthenticatorImplUiBinder uiBinder = GWT.create(SubversionAuthenticatorImplUiBinder.class); + + private ActionDelegate delegate; + + @UiField + TextBox usernameTextBox; + @UiField + TextBox passwordTextBox; + + private final Button authenticateButton; + + @Inject + public SubversionCredentialsDialogViewImpl(SubversionExtensionLocalizationConstants locale) { + this.locale = locale; + this.setWidget(uiBinder.createAndBindUi(this)); + this.setTitle(locale.credentialsDialogTitle()); + + authenticateButton = createPrimaryButton(locale.credentialsDialogAuthenticateButton(), + "svn-authentication-username", + new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + delegate.onAuthenticateClicked(); + } + }); + Button cancelButton = createButton(locale.credentialsDialogCancelButton(), + "svn-authentication-password", + new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + delegate.onCancelClicked(); + } + }); + + addButtonToFooter(authenticateButton); + addButtonToFooter(cancelButton); + } + + @Override + public void showDialog() { + super.show(); + } + + @Override + public void closeDialog() { + super.hide(); + } + + @Override + public String getUsername() { + return usernameTextBox.getText(); + } + + @Override + public String getPassword() { + return passwordTextBox.getText(); + } + + @Override + public void cleanCredentials() { + usernameTextBox.setText(""); + passwordTextBox.setText(""); + setEnabledAuthenticateButton(false); + } + + @UiHandler({"usernameTextBox", "passwordTextBox"}) + void credentialChangeHandler(KeyUpEvent event) { + delegate.onCredentialsChanged(); + } + + @Override + public void setEnabledAuthenticateButton(boolean enabled) { + authenticateButton.setEnabled(enabled); + } + + @Override + public void setDelegate(ActionDelegate delegate) { + this.delegate = delegate; + } +} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogViewImpl.ui.xml b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogViewImpl.ui.xml new file mode 100644 index 000000000000..aeb2df5a1490 --- /dev/null +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/credentialsdialog/SubversionCredentialsDialogViewImpl.ui.xml @@ -0,0 +1,36 @@ + + + + + + .emptyBorder { + margin: 6px; + } + + + + + + + + + + + + + + + + diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/diff/DiffPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/diff/DiffPresenter.java index ad125ca7a7c3..9f66dde7742b 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/diff/DiffPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/diff/DiffPresenter.java @@ -15,11 +15,14 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -47,11 +50,12 @@ public class DiffPresenter extends SubversionActionPresenter { protected DiffPresenter(final AppContext appContext, final NotificationManager notificationManager, final SubversionOutputConsoleFactory consoleFactory, + final SubversionCredentialsDialog subversionCredentialsDialog, final ProcessesPanelPresenter processesPanelPresenter, final SubversionClientService service, final SubversionExtensionLocalizationConstants constants, final StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, subversionCredentialsDialog); this.service = service; this.notificationManager = notificationManager; @@ -67,10 +71,15 @@ public void showDiff() { checkState(!Arrays.isNullOrEmpty(resources)); - service.showDiff(project.getLocation(), toRelative(project, resources), "HEAD").then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + return service.showDiff(project.getLocation(), toRelative(project, resources), "HEAD", credentials); + } + }, null).then(new Operation() { @Override public void apply(CLIOutputResponse response) throws OperationException { - printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandDiff()); + printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandDiff());; } }).catchError(new Operation() { @Override @@ -79,5 +88,4 @@ public void apply(PromiseError error) throws OperationException { } }); } - } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/export/ExportPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/export/ExportPresenter.java index 21cb0e99ee97..9d2637f70e2f 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/export/ExportPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/export/ExportPresenter.java @@ -22,6 +22,7 @@ import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.util.Arrays; @@ -58,13 +59,14 @@ public class ExportPresenter extends SubversionActionPresenter implements Export @Inject public ExportPresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog credentialsDialog, ProcessesPanelPresenter processesPanelPresenter, ExportView view, SubversionClientService service, NotificationManager notificationManager, SubversionExtensionLocalizationConstants constants, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.appContext = appContext; this.view = view; this.service = service; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterPresenter.java index 91c572e2a0aa..410a3f12ff92 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterPresenter.java @@ -17,11 +17,9 @@ import com.google.gwt.user.client.ui.AcceptsOneWidget; import com.google.inject.Inject; -import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto; import org.eclipse.che.ide.api.project.MutableProjectConfig; import org.eclipse.che.ide.api.wizard.AbstractWizardPage; import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; -import org.eclipse.che.plugin.svn.shared.ImportParameterKeys; import org.eclipse.che.ide.util.NameUtils; import static com.google.common.base.Strings.isNullOrEmpty; @@ -74,9 +72,6 @@ public void go(AcceptsOneWidget container) { view.setProjectDescription(dataObject.getDescription()); view.setProjectUrl(dataObject.getSource().getLocation()); - view.cleanCredentials(); - onCredentialsChanged(); - container.setWidget(view); view.setInputsEnableState(true); @@ -141,13 +136,6 @@ public void onProjectDescriptionChanged(final String projectDescription) { dataObject.setDescription(projectDescription); } - /** {@inheritDoc} */ - @Override - public void onCredentialsChanged() { - dataObject.getSource().getParameters().put(ImportParameterKeys.PARAMETER_USERNAME, view.getUserName()); - dataObject.getSource().getParameters().put(ImportParameterKeys.PARAMETER_PASSWORD, view.getPassword()); - } - private boolean isSubversionUrlCorrect(final String url) { return !isNullOrEmpty(url) && SUBVERSION_REPOSITORY_REGEX.test(url); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterView.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterView.java index b25a237987a8..ab6eaad3fe75 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterView.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterView.java @@ -32,8 +32,6 @@ public interface ActionDelegate { /** Performs any actions appropriate in response to the user having changed the relative path in the project. */ void onProjectRelativePathChanged(String relativePath); - - void onCredentialsChanged(); } /** Set error marker on project name field. */ @@ -68,16 +66,6 @@ public interface ActionDelegate { /** Return custom relative project path. */ String getProjectRelativePath(); - - /** Return user name. */ - String getUserName(); - - /** Return user password. */ - String getPassword(); - - /** Clean username and password fields */ - void cleanCredentials(); - /** * Set the enable state of the inputs. * diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.java index 010c8166f0fb..40b1809b9521 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.java @@ -50,10 +50,6 @@ interface SubversionProjectImporterViewImplUiBinder @UiField TextBox projectRelativePath; @UiField - TextBox username; - @UiField - TextBox password; - @UiField TextBox projectName; @UiField TextArea projectDescription; @@ -163,27 +159,6 @@ public void setInputsEnableState(boolean isEnabled) { } } - /** {@inheritDoc} */ - @Override - public String getUserName() { - return username.getText(); - } - - /** {@inheritDoc} */ - @Override - public String getPassword() { - return password.getText(); - } - - /** - * Clean username and password fields - */ - @Override - public void cleanCredentials() { - username.setText(""); - password.setText(""); - } - @UiHandler("projectUrl") void onProjectUrlChanged(KeyUpEvent event) { delegate.onProjectUrlChanged(projectUrl.getValue()); @@ -197,11 +172,6 @@ void onProjectRelativePathChanged(final KeyUpEvent event) { delegate.onProjectRelativePathChanged(projectRelativePath.getValue()); } - @UiHandler({"username", "password"}) - void credentialChangeHandler(final ValueChangeEvent event) { - delegate.onCredentialsChanged(); - } - @UiHandler("projectName") void onProjectNameChanged(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.ui.xml b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.ui.xml index 68b5e7e89a18..984dc1dd1c9e 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.ui.xml +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/importer/SubversionProjectImporterViewImpl.ui.xml @@ -34,20 +34,6 @@ debugId="file-importProject-relativePath" text="{locale.importerDefaultRelativePath}"/> - - - - - - - - - - diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/inject/SubversionGinModule.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/inject/SubversionGinModule.java index 2f9c9dd3245f..86742a177cf4 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/inject/SubversionGinModule.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/inject/SubversionGinModule.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.ide.inject; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; +import org.eclipse.che.plugin.svn.ide.credentialsdialog.SubversionCredentialsDialogImpl; import org.eclipse.che.plugin.svn.ide.commit.diff.DiffViewerView; import org.eclipse.che.plugin.svn.ide.commit.diff.DiffViewerViewImpl; import org.eclipse.che.plugin.svn.ide.common.SubversionOutputConsole; @@ -27,9 +29,6 @@ import org.eclipse.che.plugin.svn.ide.resolve.ResolveViewImpl; import org.eclipse.che.plugin.svn.ide.SubversionClientService; import org.eclipse.che.plugin.svn.ide.SubversionClientServiceImpl; -import org.eclipse.che.plugin.svn.ide.askcredentials.AskCredentialsPresenter; -import org.eclipse.che.plugin.svn.ide.askcredentials.AskCredentialsView; -import org.eclipse.che.plugin.svn.ide.askcredentials.AskCredentialsViewImpl; import org.eclipse.che.plugin.svn.ide.commit.CommitView; import org.eclipse.che.plugin.svn.ide.commit.CommitViewImpl; import org.eclipse.che.plugin.svn.ide.common.threechoices.ChoiceDialog; @@ -80,8 +79,7 @@ protected void configure() { bind(CommitView.class).to(CommitViewImpl.class).in(Singleton.class); bind(DiffViewerView.class).to(DiffViewerViewImpl.class).in(Singleton.class); - bind(AskCredentialsPresenter.class); - bind(AskCredentialsView.class).to(AskCredentialsViewImpl.class); + bind(SubversionCredentialsDialog.class).to(SubversionCredentialsDialogImpl.class); install(new GinFactoryModuleBuilder().implement(ChoiceDialog.class, ChoiceDialogPresenter.class) .build(ChoiceDialogFactory.class)); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/lockunlock/LockUnlockPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/lockunlock/LockUnlockPresenter.java index 656840fb739c..2d4364a4be81 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/lockunlock/LockUnlockPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/lockunlock/LockUnlockPresenter.java @@ -14,12 +14,15 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.dialogs.ConfirmCallback; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.util.Arrays; @@ -53,11 +56,12 @@ protected LockUnlockPresenter(AppContext appContext, ChoiceDialogFactory choiceDialogFactory, NotificationManager notificationManager, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog subversionCredentialsDialog, ProcessesPanelPresenter processesPanelPresenter, SubversionExtensionLocalizationConstants constants, SubversionClientService service, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, subversionCredentialsDialog); this.service = service; this.notificationManager = notificationManager; @@ -155,7 +159,12 @@ private void doLockAction(final boolean force, final Path[] paths) { checkState(project != null); - service.lock(project.getLocation(), paths, force).then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + return service.lock(project.getLocation(), paths, force, credentials); + } + }, null).then(new Operation() { @Override public void apply(CLIOutputResponse response) throws OperationException { printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandLock()); @@ -174,7 +183,12 @@ private void doUnlockAction(final boolean force, final Path[] paths) { checkState(project != null); - service.unlock(project.getLocation(), paths, force).then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + return service.unlock(project.getLocation(), paths, force, credentials); + } + }, null).then(new Operation() { @Override public void apply(CLIOutputResponse response) throws OperationException { printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), constants.commandUnlock()); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/log/ShowLogPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/log/ShowLogPresenter.java index 1283008eceba..1e0137f45a3f 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/log/ShowLogPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/log/ShowLogPresenter.java @@ -14,11 +14,14 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -51,14 +54,14 @@ public class ShowLogPresenter extends SubversionActionPresenter { @Inject protected ShowLogPresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog subversionCredentialsDialog, ProcessesPanelPresenter processesPanelPresenter, SubversionClientService service, NotificationManager notificationManager, SubversionExtensionLocalizationConstants constants, ShowLogsView view, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); - + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, subversionCredentialsDialog); this.service = service; this.notificationManager = notificationManager; this.constants = constants; @@ -94,7 +97,12 @@ public void showLog() { checkState(!Arrays.isNullOrEmpty(resources)); checkState(resources.length == 1); - service.info(project.getLocation(), toRelative(project, resources[0]), "HEAD", false).then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + return service.info(project.getLocation(), toRelative(project, resources[0]), "HEAD", false, credentials); + } + }, null).then(new Operation() { @Override public void apply(InfoResponse response) throws OperationException { if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) { @@ -119,7 +127,8 @@ public void apply(PromiseError error) throws OperationException { /** * Fetches and displays commit log messages for specified range. * - * @param range range to be logged + * @param range + * range to be logged */ private void showLogs(String range) { final Project project = appContext.getRootProject(); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/merge/MergePresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/merge/MergePresenter.java index fe28281635ed..0e42c2c4177a 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/merge/MergePresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/merge/MergePresenter.java @@ -26,6 +26,8 @@ import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -70,11 +72,12 @@ public MergePresenter(MergeView view, SubversionClientService service, AppContext appContext, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog subversionCredentialsDialog, ProcessesPanelPresenter processesPanelPresenter, NotificationManager notificationManager, SubversionExtensionLocalizationConstants constants, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, subversionCredentialsDialog); this.view = view; this.service = service; @@ -99,7 +102,12 @@ public void merge() { checkState(resources != null && resources.length == 1); - service.info(project.getLocation(), toRelative(project, resources[0]), "HEAD", false).then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + return service.info(project.getLocation(), toRelative(project, resources[0]), "HEAD", false, credentials); + } + }, null).then(new Operation() { @Override public void apply(InfoResponse response) throws OperationException { if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) { @@ -115,39 +123,39 @@ public void apply(InfoResponse response) throws OperationException { service.info(project.getLocation(), repositoryRoot, "HEAD", true) .then(new Operation() { - @Override - public void apply(InfoResponse response) throws OperationException { - if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) { - printErrors(response.getErrorOutput(), constants.commandInfo()); - notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE); - return; - } - - sourceURL = response.getItems().get(0).getURL(); - SubversionItemNode subversionTreeNode = new SubversionItemNode(response.getItems().get(0)); - - List children = new ArrayList<>(); - if (response.getItems().size() > 1) { - for (int i = 1; i < response.getItems().size(); i++) { - SubversionItem item = response.getItems().get(i); - if (!"file".equals(item.getNodeKind())) { - children.add(new SubversionItemNode(item)); - } - } - } - - subversionTreeNode.setChildren(children); - view.setRootNode(subversionTreeNode); - view.show(); - validateSourceURL(); - } - }) + @Override + public void apply(InfoResponse response) throws OperationException { + if (!response.getErrorOutput().isEmpty()) { + printErrors(response.getErrorOutput(), constants.commandInfo()); + notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE); + return; + } + + sourceURL = response.getItems().get(0).getURL(); + SubversionItemNode subversionTreeNode = new SubversionItemNode(response.getItems().get(0)); + + List children = new ArrayList<>(); + if (response.getItems().size() > 1) { + for (int i = 1; i < response.getItems().size(); i++) { + SubversionItem item = response.getItems().get(i); + if (!"file".equals(item.getNodeKind())) { + children.add(new SubversionItemNode(item)); + } + } + } + + subversionTreeNode.setChildren(children); + view.setRootNode(subversionTreeNode); + view.show(); + validateSourceURL(); + } + }) .catchError(new Operation() { - @Override - public void apply(PromiseError error) throws OperationException { - notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); - } - }); + @Override + public void apply(PromiseError error) throws OperationException { + notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); + } + }); } }).catchError(new Operation() { @Override @@ -174,17 +182,17 @@ public void mergeClicked() { service.merge(project.getLocation(), resources[0].getLocation(), Path.valueOf(sourceURL)) .then(new Operation() { - @Override - public void apply(CLIOutputResponse response) throws OperationException { - printResponse(response.getCommand(), response.getOutput(), null, constants.commandMerge()); - } - }) + @Override + public void apply(CLIOutputResponse response) throws OperationException { + printResponse(response.getCommand(), response.getOutput(), null, constants.commandMerge()); + } + }) .catchError(new Operation() { - @Override - public void apply(PromiseError error) throws OperationException { - notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); - } - }); + @Override + public void apply(PromiseError error) throws OperationException { + notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); + } + }); } /** @@ -255,32 +263,32 @@ protected Promise> getChildrenImpl() { return service.info(project.getLocation(), getData().getURL(), "HEAD", true) .then(new Function>() { - @Override - public List apply(InfoResponse response) throws FunctionException { - if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) { - printErrors(response.getErrorOutput(), constants.commandInfo()); - notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE); - return Collections.emptyList(); - } - - List children = new ArrayList<>(); - if (response.getItems().size() > 1) { - for (int i = 1; i < response.getItems().size(); i++) { - SubversionItem item = response.getItems().get(i); - if (!"file".equals(item.getNodeKind())) { - children.add(new SubversionItemNode(item)); - } - } - } - - return children; - } - }).catchError(new Operation() { - @Override - public void apply(PromiseError error) throws OperationException { - notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); - } - }); + @Override + public List apply(InfoResponse response) throws FunctionException { + if (response.getErrorOutput() != null && !response.getErrorOutput().isEmpty()) { + printErrors(response.getErrorOutput(), constants.commandInfo()); + notificationManager.notify("Unable to execute subversion command", FAIL, FLOAT_MODE); + return Collections.emptyList(); + } + + List children = new ArrayList<>(); + if (response.getItems().size() > 1) { + for (int i = 1; i < response.getItems().size(); i++) { + SubversionItem item = response.getItems().get(i); + if (!"file".equals(item.getNodeKind())) { + children.add(new SubversionItemNode(item)); + } + } + } + + return children; + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError error) throws OperationException { + notificationManager.notify(error.getMessage(), FAIL, FLOAT_MODE); + } + }); } @Override diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/move/MovePresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/move/MovePresenter.java index 3bbfb56ceafe..c54b176135f4 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/move/MovePresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/move/MovePresenter.java @@ -16,12 +16,15 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.resource.Path; import org.eclipse.che.ide.util.Arrays; @@ -46,23 +49,25 @@ @Singleton public class MovePresenter extends SubversionActionPresenter implements MoveView.ActionDelegate { - private MoveView view; - private SubversionExtensionLocalizationConstants locale; - private NotificationManager notificationManager; - private SubversionClientService service; - private Project project; - private Resource source; + private final MoveView view; + private final SubversionExtensionLocalizationConstants locale; + private final NotificationManager notificationManager; + private final SubversionClientService service; + + private Project project; + private Resource source; @Inject public MovePresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, + SubversionCredentialsDialog subversionCredentialsDialog, ProcessesPanelPresenter processesPanelPresenter, MoveView view, NotificationManager notificationManager, SubversionClientService service, SubversionExtensionLocalizationConstants locale, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, locale, notificationManager, subversionCredentialsDialog); this.notificationManager = notificationManager; this.service = service; @@ -98,14 +103,21 @@ public void onMoveClicked() { checkState(project != null); final Path source = getSource(); - final Path target = getTarget(); final String comment = view.isURLSelected() ? view.getComment() : null; final StatusNotification notification = new StatusNotification(locale.moveNotificationStarted(source.toString()), PROGRESS, FLOAT_MODE); notificationManager.notify(notification); - service.move(project.getLocation(), source, target, comment).then(new Operation() { + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + notification.setStatus(PROGRESS); + notification.setTitle(locale.moveNotificationStarted(source.toString())); + + return service.move(project.getLocation(), source, getTarget(), comment, credentials); + } + }, notification).then(new Operation() { @Override public void apply(CLIOutputResponse response) throws OperationException { notification.setTitle(locale.moveNotificationSuccessful()); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/property/PropertyEditorPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/property/PropertyEditorPresenter.java index edc7d22d51ab..eb7d9a6a89a7 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/property/PropertyEditorPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/property/PropertyEditorPresenter.java @@ -21,6 +21,7 @@ import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -60,10 +61,11 @@ protected PropertyEditorPresenter(AppContext appContext, ProcessesPanelPresenter processesPanelPresenter, PropertyEditorView view, SubversionClientService service, + SubversionCredentialsDialog credentialsDialog, NotificationManager notificationManager, SubversionExtensionLocalizationConstants constants, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.view = view; this.service = service; this.notificationManager = notificationManager; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/remove/RemovePresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/remove/RemovePresenter.java index e24216b744b9..b6e9e9ace348 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/remove/RemovePresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/remove/RemovePresenter.java @@ -21,6 +21,7 @@ import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -51,10 +52,11 @@ protected RemovePresenter(AppContext appContext, NotificationManager notificationManager, SubversionOutputConsoleFactory consoleFactory, SubversionExtensionLocalizationConstants constants, + SubversionCredentialsDialog credentialsDialog, SubversionClientService service, ProcessesPanelPresenter processesPanelPresenter, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.service = service; this.notificationManager = notificationManager; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/resolve/ResolvePresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/resolve/ResolvePresenter.java index cdda0a04b48c..b03a1fd58735 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/resolve/ResolvePresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/resolve/ResolvePresenter.java @@ -20,6 +20,7 @@ import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -54,12 +55,13 @@ protected ResolvePresenter(ProcessesPanelPresenter processesPanelPresenter, SubversionOutputConsoleFactory consoleFactory, AppContext appContext, SubversionExtensionLocalizationConstants constants, + SubversionCredentialsDialog credentialsDialog, NotificationManager notificationManager, DialogFactory dialogFactory, SubversionClientService service, ResolveView view, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.service = service; this.notificationManager = notificationManager; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/revert/RevertPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/revert/RevertPresenter.java index 672b0e0e4c48..ac613fe6c247 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/revert/RevertPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/revert/RevertPresenter.java @@ -24,6 +24,7 @@ import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -54,10 +55,11 @@ protected RevertPresenter(AppContext appContext, ProcessesPanelPresenter processesPanelPresenter, SubversionClientService service, SubversionExtensionLocalizationConstants constants, + SubversionCredentialsDialog credentialsDialog, NotificationManager notificationManager, DialogFactory dialogFactory, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.service = service; this.constants = constants; this.notificationManager = notificationManager; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/status/StatusPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/status/StatusPresenter.java index 5af9c9d27279..ff977ec18159 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/status/StatusPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/status/StatusPresenter.java @@ -20,6 +20,7 @@ import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.ide.util.Arrays; import org.eclipse.che.plugin.svn.ide.SubversionClientService; @@ -49,9 +50,10 @@ protected StatusPresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, SubversionClientService service, SubversionExtensionLocalizationConstants constants, + SubversionCredentialsDialog credentialsDialog, ProcessesPanelPresenter processesPanelPresenter, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, credentialsDialog); this.service = service; this.notificationManager = notificationManager; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdatePresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdatePresenter.java index b82864f514b1..9d66cb0b915a 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdatePresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdatePresenter.java @@ -15,10 +15,13 @@ import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.api.promises.client.PromiseError; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.notification.NotificationManager; import org.eclipse.che.ide.api.notification.StatusNotification; +import org.eclipse.che.ide.api.subversion.Credentials; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; @@ -50,11 +53,12 @@ public class UpdatePresenter extends SubversionActionPresenter { public UpdatePresenter(AppContext appContext, SubversionOutputConsoleFactory consoleFactory, SubversionClientService service, + SubversionCredentialsDialog subversionCredentialsDialog, ProcessesPanelPresenter processesPanelPresenter, SubversionExtensionLocalizationConstants constants, NotificationManager notificationManager, StatusColors statusColors) { - super(appContext, consoleFactory, processesPanelPresenter, statusColors); + super(appContext, consoleFactory, processesPanelPresenter, statusColors, constants, notificationManager, subversionCredentialsDialog); this.constants = constants; this.notificationManager = notificationManager; @@ -79,28 +83,40 @@ protected void doUpdate(final String revision, final String depth, final boolean final StatusNotification notification = new StatusNotification(constants.updateToRevisionStarted(revision), PROGRESS, FLOAT_MODE); notificationManager.notify(notification); - service.update(project.getLocation(), toRelative(project, resources), revision, depth, ignoreExternals, "postpone") - .then(new Operation() { - @Override - public void apply(CLIOutputWithRevisionResponse response) throws OperationException { - printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), - constants.commandUpdate()); - - notification.setTitle(constants.updateSuccessful(Long.toString(response.getRevision()))); - notification.setStatus(SUCCESS); - - if (view != null) { - view.close(); - } - } - }) - .catchError(new Operation() { - @Override - public void apply(PromiseError error) throws OperationException { - notification.setTitle(constants.updateFailed()); - notification.setStatus(FAIL); - } - }); + performOperationWithCredentialsRequestIfNeeded(new RemoteSubversionOperation() { + @Override + public Promise perform(Credentials credentials) { + + notification.setStatus(PROGRESS); + notification.setTitle(constants.updateToRevisionStarted(revision)); + + return service.update(project.getLocation(), + toRelative(project, resources), + revision, + depth, + ignoreExternals, + "postpone", + credentials); + } + }, notification).then(new Operation() { + @Override + public void apply(CLIOutputWithRevisionResponse response) throws OperationException { + printResponse(response.getCommand(), response.getOutput(), response.getErrOutput(), + constants.commandUpdate()); + + notification.setTitle(constants.updateSuccessful(Long.toString(response.getRevision()))); + notification.setStatus(SUCCESS); + + if (view != null) { + view.close(); + } + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError error) throws OperationException { + notification.setTitle(constants.updateFailed()); + notification.setStatus(FAIL); + } + }); } - } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdateToRevisionPresenter.java b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdateToRevisionPresenter.java index c60cd9bec67f..fd7a92371c11 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdateToRevisionPresenter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/update/UpdateToRevisionPresenter.java @@ -15,6 +15,7 @@ import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.notification.NotificationManager; +import org.eclipse.che.ide.api.subversion.SubversionCredentialsDialog; import org.eclipse.che.ide.extension.machine.client.processes.panel.ProcessesPanelPresenter; import org.eclipse.che.plugin.svn.ide.SubversionClientService; import org.eclipse.che.plugin.svn.ide.SubversionExtensionLocalizationConstants; @@ -34,11 +35,12 @@ public UpdateToRevisionPresenter(AppContext appContext, NotificationManager notificationManager, SubversionOutputConsoleFactory consoleFactory, SubversionClientService service, + SubversionCredentialsDialog credentialsDialog, SubversionExtensionLocalizationConstants constants, ProcessesPanelPresenter processesPanelPresenter, UpdateToRevisionView view, StatusColors statusColors) { - super(appContext, consoleFactory, service, processesPanelPresenter, constants, notificationManager, statusColors); + super(appContext, consoleFactory, service, credentialsDialog, processesPanelPresenter, constants, notificationManager, statusColors); this.view = view; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/resources/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.properties b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/resources/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.properties index 8e87c013db71..9ab19cfb6837 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/resources/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.properties +++ b/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/resources/org/eclipse/che/plugin/svn/ide/SubversionExtensionLocalizationConstants.properties @@ -33,6 +33,7 @@ command.update=svn update # Action Constants action.not.implemented=Action not implemented! +waiting.credentials=Waiting for credentials add.description=Add path to version control add.failed=Adding path(s) failed add.started=Adding {0} path(s) @@ -213,6 +214,13 @@ move.item.child.detect=Target directory cannot be a child of moved directory # Log gialog button.log=Log +# Authentication dialog +credentials.dialog.title=SVN Authentication +credentials.dialog.username=User Name: +credentials.dialog.password=Password: +credentials.dialog.authenticate.button=Authenticate +credentials.dialog.cancel.button=Cancel + # Properties property.modify.start=Property modification started property.modify.finished=Property modified diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionApi.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionApi.java index ff87f21acf2a..59f1d7b64474 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionApi.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionApi.java @@ -16,16 +16,15 @@ import com.google.common.net.MediaType; import com.google.inject.Singleton; +import org.eclipse.che.api.core.ErrorCodes; import org.eclipse.che.api.core.ServerException; +import org.eclipse.che.api.core.UnauthorizedException; import org.eclipse.che.api.core.util.LineConsumerFactory; import org.eclipse.che.api.vfs.util.DeleteOnCloseFileInputStream; import org.eclipse.che.commons.lang.IoUtil; import org.eclipse.che.commons.lang.ZipUtils; import org.eclipse.che.dto.server.DtoFactory; import org.eclipse.che.plugin.ssh.key.script.SshScriptProvider; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsException; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider.Credentials; import org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProvider; import org.eclipse.che.plugin.svn.server.upstream.CommandLineResult; import org.eclipse.che.plugin.svn.server.upstream.UpstreamUtils; @@ -90,16 +89,13 @@ public class SubversionApi { private static Logger LOG = LoggerFactory.getLogger(SubversionApi.class); - private final CredentialsProvider credentialsProvider; private final RepositoryUrlProvider repositoryUrlProvider; private final SshScriptProvider sshScriptProvider; protected LineConsumerFactory svnOutputPublisherFactory; @Inject - public SubversionApi(CredentialsProvider credentialsProvider, - RepositoryUrlProvider repositoryUrlProvider, + public SubversionApi(RepositoryUrlProvider repositoryUrlProvider, SshScriptProvider sshScriptProvider) { - this.credentialsProvider = credentialsProvider; this.repositoryUrlProvider = repositoryUrlProvider; this.sshScriptProvider = sshScriptProvider; } @@ -125,7 +121,7 @@ public void setOutputLineConsumerFactory(LineConsumerFactory svnOutputPublisherF * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponse add(final AddRequest request) throws IOException, SubversionException { + public CLIOutputResponse add(final AddRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List args = defaultArgs(); @@ -171,7 +167,7 @@ public CLIOutputResponse add(final AddRequest request) throws IOException, Subve * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponse revert(RevertRequest request) throws IOException, SubversionException { + public CLIOutputResponse revert(RevertRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List cliArgs = defaultArgs(); @@ -200,7 +196,7 @@ public CLIOutputResponse revert(RevertRequest request) throws IOException, Subve * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponse copy(final CopyRequest request) throws IOException, SubversionException { + public CLIOutputResponse copy(final CopyRequest request) throws IOException, SubversionException, UnauthorizedException { //for security reason we should forbid file protocol if (request.getSource().startsWith("file://") || request.getDestination().startsWith("file://")) { @@ -218,8 +214,12 @@ public CLIOutputResponse copy(final CopyRequest request) throws IOException, Sub // Command Name cliArgs.add("copy"); - final CommandLineResult result = - runCommand(null, cliArgs, projectPath, Arrays.asList(request.getSource(), request.getDestination())); + final CommandLineResult result = runCommand(null, + cliArgs, + projectPath, + Arrays.asList(request.getSource(), request.getDestination()), + request.getUsername(), + request.getPassword()); return DtoFactory.getInstance() .createDto(CLIOutputResponse.class) @@ -240,12 +240,7 @@ public CLIOutputResponse copy(final CopyRequest request) throws IOException, Sub * if there is a Subversion issue */ public CLIOutputWithRevisionResponse checkout(final CheckoutRequest request) - throws IOException, SubversionException { - return checkout(request, null); - } - - public CLIOutputWithRevisionResponse checkout(final CheckoutRequest request, final String[] credentials) - throws IOException, SubversionException { + throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List cliArgs = defaultArgs(); @@ -263,7 +258,13 @@ public CLIOutputWithRevisionResponse checkout(final CheckoutRequest request, fin cliArgs.add(request.getUrl()); cliArgs.add(projectPath.getAbsolutePath()); - CommandLineResult result = runCommand(null, cliArgs, projectPath, request.getPaths(), credentials, request.getUrl()); + CommandLineResult result = runCommand(null, + cliArgs, + projectPath, + request.getPaths(), + request.getUsername(), + request.getPassword(), + request.getUrl()); return DtoFactory.getInstance().createDto(CLIOutputWithRevisionResponse.class) .withCommand(result.getCommandLine().toString()) @@ -284,7 +285,7 @@ public CLIOutputWithRevisionResponse checkout(final CheckoutRequest request, fin * if there is a Subversion issue */ public CLIOutputWithRevisionResponse commit(final CommitRequest request) - throws IOException, SubversionException { + throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List cliArgs = defaultArgs(); @@ -322,7 +323,7 @@ public CLIOutputWithRevisionResponse commit(final CommitRequest request) * if there is a Subversion issue */ public CLIOutputResponse remove(final RemoveRequest request) - throws IOException, SubversionException { + throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List cliArgs = defaultArgs(); @@ -349,7 +350,7 @@ public CLIOutputResponse remove(final RemoveRequest request) * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponse status(final StatusRequest request) throws IOException, SubversionException { + public CLIOutputResponse status(final StatusRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List cliArgs = defaultArgs(); @@ -389,7 +390,7 @@ public CLIOutputResponse status(final StatusRequest request) throws IOException, * if there is a Subversion issue */ public CLIOutputWithRevisionResponse update(final UpdateRequest request) - throws IOException, SubversionException { + throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -404,8 +405,12 @@ public CLIOutputWithRevisionResponse update(final UpdateRequest request) // Command Name uArgs.add("update"); - final CommandLineResult result = runCommand(null, uArgs, projectPath, - addWorkingCopyPathIfNecessary(request.getPaths())); + final CommandLineResult result = runCommand(null, + uArgs, + projectPath, + addWorkingCopyPathIfNecessary(request.getPaths()), + request.getUsername(), + request.getPassword()); return DtoFactory.getInstance().createDto(CLIOutputWithRevisionResponse.class) .withCommand(result.getCommandLine().toString()) @@ -425,7 +430,7 @@ public CLIOutputWithRevisionResponse update(final UpdateRequest request) * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponse showLog(final ShowLogRequest request) throws IOException, SubversionException { + public CLIOutputResponse showLog(final ShowLogRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -441,7 +446,9 @@ public CLIOutputResponse showLog(final ShowLogRequest request) throws IOExceptio .withErrOutput(result.getStderr()); } - public CLIOutputResponse lockUnlock(final LockRequest request, final boolean lock) throws IOException, SubversionException { + public CLIOutputResponse lockUnlock(final LockRequest request, final boolean lock) throws IOException, + SubversionException, + UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List args = defaultArgs(); @@ -455,7 +462,12 @@ public CLIOutputResponse lockUnlock(final LockRequest request, final boolean loc args.add("unlock"); } - final CommandLineResult result = runCommand(null, args, projectPath, request.getTargets()); + final CommandLineResult result = runCommand(null, + args, + projectPath, + request.getTargets(), + request.getUsername(), + request.getPassword()); return DtoFactory.getInstance() .createDto(CLIOutputResponse.class) @@ -475,7 +487,7 @@ public CLIOutputResponse lockUnlock(final LockRequest request, final boolean loc * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponse showDiff(final ShowDiffRequest request) throws IOException, SubversionException { + public CLIOutputResponse showDiff(final ShowDiffRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -483,7 +495,12 @@ public CLIOutputResponse showDiff(final ShowDiffRequest request) throws IOExcept addOption(uArgs, "--revision", request.getRevision()); uArgs.add("diff"); - final CommandLineResult result = runCommand(null, uArgs, projectPath, request.getPaths()); + final CommandLineResult result = runCommand(null, + uArgs, + projectPath, + request.getPaths(), + request.getUsername(), + request.getPassword()); return DtoFactory.getInstance().createDto(CLIOutputResponse.class) .withCommand(result.getCommandLine().toString()) @@ -496,7 +513,7 @@ public CLIOutputResponse showDiff(final ShowDiffRequest request) throws IOExcept * * @return the response containing target children */ - public ListResponse list(final ListRequest request) throws IOException, SubversionException { + public ListResponse list(final ListRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List args = defaultArgs(); @@ -524,7 +541,7 @@ public ListResponse list(final ListRequest request) throws IOException, Subversi * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponseList resolve(final ResolveRequest request) throws IOException, SubversionException { + public CLIOutputResponseList resolve(final ResolveRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); Map resolutions = request.getConflictResolutions(); @@ -566,7 +583,7 @@ public CLIOutputResponseList resolve(final ResolveRequest request) throws IOExce * if there is an exporting issue */ public Response exportPath(@NotNull final String projectPath, @NotNull final String path, String revision) - throws IOException, ServerException { + throws IOException, ServerException, UnauthorizedException { final File project = new File(projectPath); @@ -618,7 +635,7 @@ public Response exportPath(@NotNull final String projectPath, @NotNull final Str * @throws SubversionException * if there is a Subversion issue */ - public CLIOutputResponse move(final MoveRequest request) throws IOException, SubversionException { + public CLIOutputResponse move(final MoveRequest request) throws IOException, SubversionException, UnauthorizedException { Predicate sourcePredicate = new Predicate() { @Override @@ -647,7 +664,12 @@ public boolean apply(String input) { paths.addAll(request.getSource()); paths.add(request.getDestination()); - final CommandLineResult result = runCommand(null, cliArgs, projectPath, paths); + final CommandLineResult result = runCommand(null, + cliArgs, + projectPath, + paths, + request.getUsername(), + request.getPassword()); return DtoFactory.getInstance().createDto(CLIOutputResponse.class) .withCommand(result.getCommandLine().toString()) @@ -666,7 +688,7 @@ public boolean apply(String input) { * @throws ServerException * if there is a Subversion issue */ - public CLIOutputResponse propset(final PropertySetRequest request) throws IOException, ServerException { + public CLIOutputResponse propset(final PropertySetRequest request) throws IOException, ServerException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -714,7 +736,7 @@ public CLIOutputResponse propset(final PropertySetRequest request) throws IOExce * @throws ServerException * if there is a Subversion issue */ - public CLIOutputResponse propdel(final PropertyDeleteRequest request) throws IOException, ServerException { + public CLIOutputResponse propdel(final PropertyDeleteRequest request) throws IOException, ServerException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -743,7 +765,7 @@ public CLIOutputResponse propdel(final PropertyDeleteRequest request) throws IOE * @throws ServerException * if there is a Subversion issue */ - public CLIOutputResponse propget(final PropertyGetRequest request) throws IOException, ServerException { + public CLIOutputResponse propget(final PropertyGetRequest request) throws IOException, ServerException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -770,7 +792,7 @@ public CLIOutputResponse propget(final PropertyGetRequest request) throws IOExce * @throws ServerException * if there is a Subversion issue */ - public CLIOutputResponse proplist(final PropertyListRequest request) throws IOException, ServerException { + public CLIOutputResponse proplist(final PropertyListRequest request) throws IOException, ServerException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -830,9 +852,8 @@ private void addOptionList(final List args, final String optName, final * @return list of arguments */ private List defaultArgs() { - List args = new ArrayList(); + List args = new ArrayList<>(); - args.add("--no-auth-cache"); args.add("--non-interactive"); args.add("--trust-server-cert"); @@ -855,18 +876,28 @@ private List addWorkingCopyPathIfNecessary(List paths) { private CommandLineResult runCommand(Map env, List args, File projectPath, - List paths) throws IOException, SubversionException { - String[] credentials = getCredentialArgs(projectPath.getAbsolutePath()); + List paths) throws IOException, SubversionException, UnauthorizedException { + String repoUrl = getRepositoryUrl(projectPath.getAbsolutePath()); + return runCommand(env, args, projectPath, paths, null, null, repoUrl); + } + + private CommandLineResult runCommand(Map env, + List args, + File projectPath, + List paths, + String username, + String password) throws IOException, SubversionException, UnauthorizedException { String repoUrl = getRepositoryUrl(projectPath.getAbsolutePath()); - return runCommand(env, args, projectPath, paths, credentials, repoUrl); + return runCommand(env, args, projectPath, paths, username, password, repoUrl); } private CommandLineResult runCommand(Map env, List args, File projectPath, List paths, - String[] credentials, - String repoUrl) throws IOException, SubversionException { + String username, + String password, + String repoUrl) throws IOException, SubversionException, UnauthorizedException { final List lines = new ArrayList<>(); final CommandLineResult result; final StringBuffer buffer; @@ -878,8 +909,8 @@ private CommandLineResult runCommand(Map env, } String[] credentialsArgs; - if (credentials != null && credentials.length == 2) { - credentialsArgs = new String[]{"--username", credentials[0], "--password", credentials[1]}; + if (!isNullOrEmpty(username) && !isNullOrEmpty(password)) { + credentialsArgs = new String[]{"--username", username, "--password", password}; } else { credentialsArgs = null; } @@ -924,27 +955,18 @@ private CommandLineResult runCommand(Map env, } if (!isWarning) { - throw new SubversionException(buffer.toString()); + String errorMessage = buffer.toString(); + if (errorMessage.endsWith("Authentication failed\n")) { + throw new UnauthorizedException("Authentication failed", ErrorCodes.UNAUTHORIZED_SVN_OPERATION); + } else { + throw new SubversionException(errorMessage); + } } } return result; } - private String[] getCredentialArgs(final String projectPath) throws SubversionException, IOException { - Credentials credentials; - try { - credentials = this.credentialsProvider.getCredentials(getRepositoryUrl(projectPath)); - } catch (final CredentialsException e) { - credentials = null; - } - if (credentials != null) { - return new String[]{credentials.getUsername(), credentials.getPassword()}; - } else { - return null; - } - } - public String getRepositoryUrl(final String projectPath) throws SubversionException, IOException { return this.repositoryUrlProvider.getRepositoryUrl(projectPath); } @@ -958,7 +980,7 @@ public String getRepositoryUrl(final String projectPath) throws SubversionExcept * @throws SubversionException * @throws IOException */ - public InfoResponse info(final InfoRequest request) throws SubversionException, IOException { + public InfoResponse info(final InfoRequest request) throws SubversionException, IOException, UnauthorizedException { final List args = defaultArgs(); if (request.getRevision() != null && !request.getRevision().trim().isEmpty()) { @@ -971,10 +993,14 @@ public InfoResponse info(final InfoRequest request) throws SubversionException, args.add("info"); - List paths = new ArrayList(); + List paths = new ArrayList<>(); paths.add(request.getTarget()); - final CommandLineResult result = runCommand(null, args, new File(request.getProjectPath()), - addWorkingCopyPathIfNecessary(paths)); + final CommandLineResult result = runCommand(null, + args, + new File(request.getProjectPath()), + addWorkingCopyPathIfNecessary(paths), + request.getUsername(), + request.getPassword()); final InfoResponse response = DtoFactory.getInstance().createDto(InfoResponse.class) .withCommand(result.getCommandLine().toString()) @@ -982,11 +1008,11 @@ public InfoResponse info(final InfoRequest request) throws SubversionException, .withErrorOutput(result.getStderr()); if (result.getExitCode() == 0) { - List items = new ArrayList(); + List items = new ArrayList<>(); response.withItems(items); Iterator iterator = result.getStdout().iterator(); - List itemProperties = new ArrayList(); + List itemProperties = new ArrayList<>(); while (iterator.hasNext()) { String propertyLine = iterator.next(); @@ -1031,7 +1057,7 @@ public InfoResponse info(final InfoRequest request) throws SubversionException, * @throws IOException * @throws SubversionException */ - public CLIOutputResponse merge(final MergeRequest request) throws IOException, SubversionException { + public CLIOutputResponse merge(final MergeRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List cliArgs = defaultArgs(); @@ -1052,7 +1078,7 @@ public CLIOutputResponse merge(final MergeRequest request) throws IOException, S .withErrOutput(result.getStderr()); } - public CLIOutputResponse cleanup(final CleanupRequest request) throws SubversionException, IOException { + public CLIOutputResponse cleanup(final CleanupRequest request) throws SubversionException, IOException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List cliArgs = defaultArgs(); @@ -1067,7 +1093,7 @@ public CLIOutputResponse cleanup(final CleanupRequest request) throws Subversion .withOutput(result.getStdout()); } - public GetRevisionsResponse getRevisions(GetRevisionsRequest request) throws IOException, SubversionException { + public GetRevisionsResponse getRevisions(GetRevisionsRequest request) throws IOException, SubversionException, UnauthorizedException { final File projectPath = new File(request.getProjectPath()); final List uArgs = defaultArgs(); @@ -1078,9 +1104,9 @@ public GetRevisionsResponse getRevisions(GetRevisionsRequest request) throws IOE final CommandLineResult result = runCommand(null, uArgs, projectPath, Arrays.asList(request.getPath())); final GetRevisionsResponse response = DtoFactory.getInstance().createDto(GetRevisionsResponse.class) - .withCommand(result.getCommandLine().toString()) - .withOutput(result.getStdout()) - .withErrOutput(result.getStderr()); + .withCommand(result.getCommandLine().toString()) + .withOutput(result.getStdout()) + .withErrOutput(result.getStderr()); if (result.getExitCode() == 0) { List revisions = result.getStdout().parallelStream() diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionModule.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionModule.java index 016b5d9e1bf1..0bca6f4a9aae 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionModule.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionModule.java @@ -17,10 +17,6 @@ import org.eclipse.che.api.project.server.type.ProjectTypeDef; import org.eclipse.che.api.project.server.type.ValueProviderFactory; import org.eclipse.che.inject.DynaModule; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider; -import org.eclipse.che.plugin.svn.server.credentials.CurrentUserPreferencesAccess; -import org.eclipse.che.plugin.svn.server.credentials.CurrentUserPreferencesAccessImpl; -import org.eclipse.che.plugin.svn.server.credentials.PreferencesCredentialsProvider; import org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProvider; import org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProviderImpl; import org.eclipse.che.plugin.svn.server.rest.SubversionService; @@ -40,9 +36,7 @@ protected void configure() { Multibinder.newSetBinder(binder(), ValueProviderFactory.class).addBinding().to(SubversionValueProviderFactory.class); bind(SubversionService.class); - bind(CredentialsProvider.class).to(PreferencesCredentialsProvider.class); bind(RepositoryUrlProvider.class).to(RepositoryUrlProviderImpl.class); - bind(CurrentUserPreferencesAccess.class).to(CurrentUserPreferencesAccessImpl.class); bind(SubversionConfigurationChecker.class).asEagerSingleton(); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporter.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporter.java index ab5c96def4cb..09ff3476ea71 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporter.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporter.java @@ -18,20 +18,15 @@ import org.eclipse.che.api.core.util.LineConsumerFactory; import org.eclipse.che.api.project.server.FolderEntry; import org.eclipse.che.api.project.server.importer.ProjectImporter; -import org.eclipse.che.dto.server.DtoFactory; + import com.google.inject.Inject; import com.google.inject.Singleton; import java.io.IOException; -import java.util.Map; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsException; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider; import org.eclipse.che.plugin.svn.shared.CheckoutRequest; -import org.eclipse.che.plugin.svn.shared.ImportParameterKeys; -import org.slf4j.LoggerFactory; -import static com.google.common.base.Strings.isNullOrEmpty; +import static org.eclipse.che.dto.server.DtoFactory.newDto; /** * Implementation of {@link ProjectImporter} for Subversion. @@ -43,13 +38,9 @@ public class SubversionProjectImporter implements ProjectImporter { private final SubversionApi subversionApi; - private final CredentialsProvider credentialsProvider; - @Inject - public SubversionProjectImporter(final CredentialsProvider credentialsProvider, - final SubversionApi subversionApi) { + public SubversionProjectImporter(final SubversionApi subversionApi) { this.subversionApi = subversionApi; - this.credentialsProvider = credentialsProvider; } @Override @@ -81,41 +72,12 @@ public void importSources(FolderEntry baseFolder, SourceStorage sourceStorage, L + "It is not a folder."); } - final String location = sourceStorage.getLocation(); - final Map parameters = sourceStorage.getParameters(); - - String[] credentials = null; - - if (parameters != null) { - String paramUsername = parameters.get(ImportParameterKeys.PARAMETER_USERNAME); - String paramPassword = parameters.get(ImportParameterKeys.PARAMETER_PASSWORD); - - if (!isNullOrEmpty(paramUsername) && !isNullOrEmpty(paramPassword)) { - credentials = new String[] {paramUsername, paramPassword}; - try { - this.credentialsProvider.storeCredential(location, new CredentialsProvider.Credentials(paramUsername, paramPassword)); - } catch (final CredentialsException e) { - LoggerFactory.getLogger(SubversionProjectImporter.class.getName()) - .warn("Could not store credentials - try to continue anyway." + e.getMessage()); - } - } - } - this.subversionApi.setOutputLineConsumerFactory(lineConsumerFactory); - - // Perform checkout - if (credentials != null) { - this.subversionApi.checkout(DtoFactory.getInstance() - .createDto(CheckoutRequest.class) - .withProjectPath(baseFolder.getVirtualFile().toIoFile().getAbsolutePath()) - .withUrl(location), - credentials); - } else { - this.subversionApi.checkout(DtoFactory.getInstance() - .createDto(CheckoutRequest.class) - .withProjectPath(baseFolder.getVirtualFile().toIoFile().getAbsolutePath()) - .withUrl(location)); - } + subversionApi.checkout(newDto(CheckoutRequest.class) + .withProjectPath(baseFolder.getVirtualFile().toIoFile().getAbsolutePath()) + .withUrl(sourceStorage.getLocation()) + .withUsername(sourceStorage.getParameters().remove("username")) + .withPassword(sourceStorage.getParameters().remove("password"))); } @Override diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CredentialsProvider.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CredentialsProvider.java deleted file mode 100644 index ee76f19c2f78..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CredentialsProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.server.credentials; - -import org.eclipse.che.commons.annotation.Nullable; - -public interface CredentialsProvider { - - @Nullable - Credentials getCredentials(String repositoryUrl) throws CredentialsException; - - void storeCredential(String repositoryUrl, Credentials credentials) throws CredentialsException; - - public class Credentials { - - private final String username; - private final String password; - - public Credentials(final String username, final String password) { - this.username = username; - this.password = password; - } - - public String getUsername() { - return username; - } - - public String getPassword() { - return password; - } - } - -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CurrentUserPreferencesAccessImpl.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CurrentUserPreferencesAccessImpl.java deleted file mode 100644 index 71db6d51770b..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/CurrentUserPreferencesAccessImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.server.credentials; - -import org.eclipse.che.api.core.ServerException; -import org.eclipse.che.api.user.server.spi.PreferenceDao; -import org.eclipse.che.commons.env.EnvironmentContext; -import org.eclipse.che.commons.subject.Subject; - -import javax.inject.Inject; -import java.text.MessageFormat; -import java.util.Map; - -/** - * Provides access to the current user's preferences.
- * Mostly necessary to allow easier mocking. - */ -public class CurrentUserPreferencesAccessImpl implements CurrentUserPreferencesAccess { - - private final PreferenceDao preferencesDao; - - @Inject - public CurrentUserPreferencesAccessImpl(final PreferenceDao preferencesDao) { - this.preferencesDao = preferencesDao; - } - - @Override - public void updatePreference(final String key, final String value) throws PreferencesAccessException { - final Subject currentSubject = getCurrentSubject(); - Map content; - try { - content = this.preferencesDao.getPreferences(currentSubject.getUserId()); - } catch (final ServerException e) { - throw new PreferencesAccessException(e); - } - content.put(key, value); - try { - this.preferencesDao.setPreferences(currentSubject.getUserId(), content); - } catch (final ServerException e) { - throw new PreferencesAccessException(e); - } - } - - @Override - public String getPreference(final String key) throws PreferencesAccessException { - final Subject currentSubject = getCurrentSubject(); - final String pattern = MessageFormat.format("^{0}$", key); - Map response; - try { - response = this.preferencesDao.getPreferences(currentSubject.getUserId(), pattern); - } catch (final ServerException e) { - throw new PreferencesAccessException(e); - } - return response.get(key); - } - - private Subject getCurrentSubject() { - return EnvironmentContext.getCurrent().getSubject(); - } -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/PreferencesCredentialsProvider.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/PreferencesCredentialsProvider.java deleted file mode 100644 index bd80eee23dab..000000000000 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/credentials/PreferencesCredentialsProvider.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012-2016 Codenvy, S.A. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Codenvy, S.A. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.plugin.svn.server.credentials; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import javax.inject.Inject; -import javax.inject.Named; - -import org.eclipse.che.api.crypt.server.EncryptException; -import org.eclipse.che.api.crypt.server.EncryptTextModule; -import org.eclipse.che.api.crypt.server.EncryptTextService; -import org.eclipse.che.api.crypt.server.EncryptTextServiceRegistry; -import org.eclipse.che.api.crypt.shared.EncryptResult; -import org.eclipse.che.dto.server.DtoFactory; -import org.eclipse.che.plugin.svn.shared.credentials.RepositoryCredentials; -import org.eclipse.che.plugin.svn.shared.credentials.UserCredentialStore; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PreferencesCredentialsProvider implements CredentialsProvider { - - private static final Logger LOG = LoggerFactory.getLogger(PreferencesCredentialsProvider.class); - - private static final String SVN_CREDENTIALS = "svn_credentials"; - - private final EncryptTextServiceRegistry encryptTextServiceRegistry; - - private final CurrentUserPreferencesAccess preferencesAccess; - - @Inject - public PreferencesCredentialsProvider(final CurrentUserPreferencesAccess preferencesAccess, - final EncryptTextServiceRegistry encryptTextServiceRegistry) { - this.encryptTextServiceRegistry = encryptTextServiceRegistry; - this.preferencesAccess = preferencesAccess; - } - - @Override - public Credentials getCredentials(final String repositoryUrl) throws CredentialsException { - LOG.debug("getCredentials called for " + repositoryUrl); - String serializedCredentials; - try { - serializedCredentials = this.preferencesAccess.getPreference(SVN_CREDENTIALS); - } catch (final PreferencesAccessException e) { - throw new CredentialsException(e); - } - LOG.debug("getCredentials - {} read: {}", SVN_CREDENTIALS, serializedCredentials); - if (serializedCredentials == null) { - return null; - } - final DtoFactory dtoFactory = DtoFactory.getInstance(); - final UserCredentialStore userCredentials = dtoFactory.createDtoFromJson(serializedCredentials, UserCredentialStore.class); - if (userCredentials == null || userCredentials.getRepositoriesCredentials() == null) { - return null; - } - LOG.debug("getCredentials - user credentials found with keys:{}", - Arrays.toString(userCredentials.getRepositoriesCredentials().keySet().toArray())); - final RepositoryCredentials repositoryCreds = userCredentials.getRepositoriesCredentials().get(repositoryUrl); - if (repositoryCreds == null) { - LOG.debug("getCredentials - no credentials found for " + repositoryUrl); - return null; - } - LOG.debug("getCredentials - repository credentials found for " + repositoryUrl); - String username = ""; - if (repositoryCreds.getUsername() != null) { - username = repositoryCreds.getUsername(); - } - LOG.debug("getCredentials - got username:" + username); - final int schemeVersion = repositoryCreds.getEncryptionSchemeVersion(); - final EncryptTextService encryptService = this.encryptTextServiceRegistry.getService(schemeVersion); - if (encryptService == null) { - throw new CredentialsException("No encryption service matches the specified one"); - } - final String encryptedPassword = repositoryCreds.getEncryptedPassword(); - if (encryptedPassword == null || encryptedPassword.isEmpty()) { - LOG.debug("getCredentials - got empty password"); - return new Credentials(username, encryptedPassword); - } - final EncryptResult toDecrypt = new EncryptResult(encryptedPassword, repositoryCreds.getInitVector()); - String password; - try { - password = encryptService.decryptText(toDecrypt); - } catch (final EncryptException e) { - LOG.warn("getCredentials - decrypt password failed"); - throw new CredentialsException(e); - } - LOG.debug("getCredentials: found {}, ####", username); - return new Credentials(username, password); - } - - @Override - public void storeCredential(final String repositoryUrl, final Credentials credentials) throws CredentialsException { - LOG.debug("storeCredentials called for " + repositoryUrl); - if (credentials == null) { - return; - } - - final DtoFactory dtoFactory = DtoFactory.getInstance(); - - String oldSerializedCredentials; - try { - oldSerializedCredentials = this.preferencesAccess.getPreference(SVN_CREDENTIALS); - } catch (final PreferencesAccessException e) { - throw new CredentialsException(e); - } - - // analyze the structure and build what's missing - UserCredentialStore userCredentials; - if (oldSerializedCredentials != null) { - userCredentials = dtoFactory.createDtoFromJson(oldSerializedCredentials, UserCredentialStore.class); - } else { - userCredentials = dtoFactory.createDto(UserCredentialStore.class); - } - Map repositoriesCredentials = userCredentials.getRepositoriesCredentials(); - if (repositoriesCredentials == null) { - repositoriesCredentials = new HashMap<>(); - userCredentials.setRepositoriesCredentials(repositoriesCredentials); - } - RepositoryCredentials repositoryCreds = repositoriesCredentials.get(repositoryUrl); - if (repositoryCreds == null) { - repositoryCreds = dtoFactory.createDto(RepositoryCredentials.class); - repositoriesCredentials.put(repositoryUrl, repositoryCreds); - } - - // set the values - repositoryCreds.setUsername(credentials.getUsername()); - - final EncryptTextService encryptService = this.encryptTextServiceRegistry.getPreferredService(); - if (encryptService == null) { - throw new CredentialsException("No encryption service matches the specified one"); - } - EncryptResult encryptResult; - try { - encryptResult = encryptService.encryptText(credentials.getPassword()); - } catch (final EncryptException e) { - throw new CredentialsException(e); - } - repositoryCreds.setEncryptedPassword(encryptResult.getCipherText()); - repositoryCreds.setInitVector(encryptResult.getInitVector()); - repositoryCreds.setEncryptionSchemeVersion(encryptService.getSchemeVersion()); - - // store the new version in the preferences - final String newSerializedCredentials = dtoFactory.toJson(userCredentials); - - try { - this.preferencesAccess.updatePreference(SVN_CREDENTIALS, newSerializedCredentials); - LOG.debug("storeCredentials done " + newSerializedCredentials); - } catch (final PreferencesAccessException e) { - throw new CredentialsException(e); - } - } - -} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/rest/SubversionService.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/rest/SubversionService.java index 489eae74be50..7fa26ceef423 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/rest/SubversionService.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/main/java/org/eclipse/che/plugin/svn/server/rest/SubversionService.java @@ -19,9 +19,6 @@ import org.eclipse.che.dto.server.DtoFactory; import org.eclipse.che.plugin.svn.server.SubversionApi; import org.eclipse.che.plugin.svn.server.SubversionException; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsException; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider.Credentials; import org.eclipse.che.plugin.svn.shared.AddRequest; import org.eclipse.che.plugin.svn.shared.CLIOutputResponse; import org.eclipse.che.plugin.svn.shared.CLIOutputResponseList; @@ -45,7 +42,6 @@ import org.eclipse.che.plugin.svn.shared.RemoveRequest; import org.eclipse.che.plugin.svn.shared.ResolveRequest; import org.eclipse.che.plugin.svn.shared.RevertRequest; -import org.eclipse.che.plugin.svn.shared.SaveCredentialsRequest; import org.eclipse.che.plugin.svn.shared.ShowDiffRequest; import org.eclipse.che.plugin.svn.shared.ShowLogRequest; import org.eclipse.che.plugin.svn.shared.StatusRequest; @@ -78,9 +74,6 @@ public class SubversionService extends Service { @Inject private SubversionApi subversionApi; - @Inject - private CredentialsProvider credentialsProvider; - /** * Add the selected paths to version control. @@ -371,19 +364,6 @@ public CLIOutputResponse unlock(final LockRequest request) throws ApiException, return this.subversionApi.lockUnlock(request, false); } - @Path("saveCredentials") - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN}) - public void saveCredentials(final SaveCredentialsRequest request) throws ServerException, IOException { - try { - this.credentialsProvider.storeCredential(request.getRepositoryUrl(), - new Credentials(request.getUsername(), request.getPassword())); - } catch (final CredentialsException e) { - throw new ServerException(e.getMessage()); - } - } - @Path("export/{projectPath:.*}") @GET @Produces(MediaType.APPLICATION_JSON) diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionApiITest.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionApiITest.java index d1ad624cfa35..15e86cea8554 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionApiITest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionApiITest.java @@ -14,7 +14,6 @@ import org.eclipse.che.dto.server.DtoFactory; import org.eclipse.che.plugin.ssh.key.script.SshKeyProvider; import org.eclipse.che.plugin.ssh.key.script.SshScriptProvider; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider; import org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProvider; import org.eclipse.che.plugin.svn.server.utils.TestUtils; import org.eclipse.che.plugin.svn.shared.CLIOutputResponse; @@ -51,8 +50,6 @@ @RunWith(MockitoJUnitRunner.class) public class SubversionApiITest { - @Mock - private CredentialsProvider credentialsProvider; @Mock private RepositoryUrlProvider repositoryUrlProvider; @Mock @@ -72,7 +69,7 @@ public void setUp() throws Exception { tmpAbsolutePath = tmpDir.toFile().getAbsolutePath(); tmpDir.toFile().deleteOnExit(); - this.subversionApi = new SubversionApi(credentialsProvider, repositoryUrlProvider, new SshScriptProvider(sshKeyProvider)); + this.subversionApi = new SubversionApi(repositoryUrlProvider, new SshScriptProvider(sshKeyProvider)); } /** diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporterTest.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporterTest.java index 4b18ad594a1e..c226a7200795 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporterTest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/SubversionProjectImporterTest.java @@ -25,7 +25,6 @@ import org.eclipse.che.api.vfs.VirtualFileSystem; import org.eclipse.che.commons.lang.NameGenerator; import org.eclipse.che.plugin.ssh.key.script.SshKeyProvider; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider; import org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProvider; import org.eclipse.che.plugin.svn.server.utils.TestUtils; import org.junit.Before; @@ -48,9 +47,6 @@ public class SubversionProjectImporterTest { @Mock private ProfileDao userProfileDao; - - @Mock - private CredentialsProvider credentialsProvider; @Mock private RepositoryUrlProvider repositoryUrlProvider; @Mock @@ -75,7 +71,6 @@ protected void configure() { bind(SshKeyProvider.class).toInstance(sshKeyProvider); bind(ProfileDao.class).toInstance(userProfileDao); - bind(CredentialsProvider.class).toInstance(credentialsProvider); bind(RepositoryUrlProvider.class).toInstance(repositoryUrlProvider); } }); diff --git a/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/utils/TestUtils.java b/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/utils/TestUtils.java index 1eed582ac9d4..264668e9695a 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/utils/TestUtils.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-server/src/test/java/org/eclipse/che/plugin/svn/server/utils/TestUtils.java @@ -25,8 +25,6 @@ import org.eclipse.che.dto.server.DtoFactory; import org.eclipse.che.plugin.svn.server.SubversionApi; import org.eclipse.che.plugin.svn.server.SubversionException; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsException; -import org.eclipse.che.plugin.svn.server.credentials.CredentialsProvider; import org.eclipse.che.plugin.svn.server.repository.RepositoryUrlProvider; import org.eclipse.che.plugin.svn.server.upstream.CommandLineResult; import org.eclipse.che.plugin.svn.server.upstream.UpstreamUtils; @@ -61,16 +59,7 @@ public class TestUtils { private static DtoFactory dtoFactory = DtoFactory.getInstance(); - private static SubversionApi subversionApi = new SubversionApi(new CredentialsProvider() { - @Override - public Credentials getCredentials(final String repositoryUrl) { - return null; - } - - @Override - public void storeCredential(final String repositoryUrl, final Credentials credentials) throws CredentialsException { - } - }, new RepositoryUrlProvider() { + private static SubversionApi subversionApi = new SubversionApi(new RepositoryUrlProvider() { @Override public String getRepositoryUrl(final String projectPath) throws IOException { return ""; diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/pom.xml b/plugins/plugin-svn/che-plugin-svn-ext-shared/pom.xml index 77a9077b2772..61abdf1f480c 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/pom.xml +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/pom.xml @@ -42,6 +42,10 @@ org.eclipse.che.core che-core-api-dto + + org.eclipse.che.core + che-core-commons-annotations + org.eclipse.che.core che-core-commons-gwt diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CheckoutRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CheckoutRequest.java index ad890a8d9c92..993c57b027a4 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CheckoutRequest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CheckoutRequest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.shared; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.dto.shared.DTO; import javax.validation.constraints.NotNull; @@ -121,4 +122,23 @@ public interface CheckoutRequest { */ CheckoutRequest withRevision(@NotNull final String revision); + + /** @return user name for authentication */ + String getUsername(); + + /** Set user name for authentication. */ + void setUsername(@Nullable final String username); + + /** @return {@link CheckoutRequest} with specified user name for authentication */ + CheckoutRequest withUsername(@Nullable final String username); + + /** @return password for authentication */ + String getPassword(); + + /** Set password for authentication. */ + void setPassword(@Nullable final String password); + + /** @return {@link CheckoutRequest} with specified password for authentication */ + CheckoutRequest withPassword(@Nullable final String password); + } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CopyRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CopyRequest.java index e14555002089..08a005e63154 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CopyRequest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/CopyRequest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.shared; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.dto.shared.DTO; import javax.validation.constraints.NotNull; @@ -94,4 +95,22 @@ public interface CopyRequest { * commentary */ CopyRequest withComment(String comment); + + /** @return user name for authentication */ + String getUsername(); + + /** Set user name for authentication. */ + void setUsername(@Nullable final String username); + + /** @return {@link CheckoutRequest} with specified user name for authentication */ + CopyRequest withUsername(@Nullable final String username); + + /** @return password for authentication */ + String getPassword(); + + /** Set password for authentication. */ + void setPassword(@Nullable final String password); + + /** @return {@link CheckoutRequest} with specified password for authentication */ + CopyRequest withPassword(@Nullable final String password); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/InfoRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/InfoRequest.java index 6498a7661354..5c91e397d43c 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/InfoRequest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/InfoRequest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.shared; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.dto.shared.DTO; import javax.validation.constraints.NotNull; @@ -65,4 +66,22 @@ public interface InfoRequest { InfoRequest withChildren(@NotNull final boolean children); + /** @return user name for authentication */ + String getUsername(); + + /** Set user name for authentication. */ + void setUsername(@Nullable final String username); + + /** @return {@link CheckoutRequest} with specified user name for authentication */ + InfoRequest withUsername(@Nullable final String username); + + /** @return password for authentication */ + String getPassword(); + + /** Set password for authentication. */ + void setPassword(@Nullable final String password); + + /** @return {@link CheckoutRequest} with specified password for authentication */ + InfoRequest withPassword(@Nullable final String password); + } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/LockRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/LockRequest.java index 2b387e7911b5..15dd9fee75b4 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/LockRequest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/LockRequest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.shared; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.dto.shared.DTO; import java.util.List; @@ -53,4 +54,22 @@ public interface LockRequest { LockRequest withForce(boolean force); void setForce(boolean force); + + /** @return user name for authentication */ + String getUsername(); + + /** Set user name for authentication. */ + void setUsername(@Nullable final String username); + + /** @return {@link CheckoutRequest} with specified user name for authentication */ + LockRequest withUsername(@Nullable final String username); + + /** @return password for authentication */ + String getPassword(); + + /** Set password for authentication. */ + void setPassword(@Nullable final String password); + + /** @return {@link CheckoutRequest} with specified password for authentication */ + LockRequest withPassword(@Nullable final String password); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/MoveRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/MoveRequest.java index 096c4d3e63ed..d6b22c9f05fc 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/MoveRequest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/MoveRequest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.shared; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.dto.shared.DTO; import javax.validation.constraints.NotNull; @@ -93,4 +94,22 @@ public interface MoveRequest { * commentary */ MoveRequest withComment(String comment); + + /** @return user name for authentication */ + String getUsername(); + + /** Set user name for authentication. */ + void setUsername(@Nullable final String username); + + /** @return {@link CheckoutRequest} with specified user name for authentication */ + MoveRequest withUsername(@Nullable final String username); + + /** @return password for authentication */ + String getPassword(); + + /** Set password for authentication. */ + void setPassword(@Nullable final String password); + + /** @return {@link CheckoutRequest} with specified password for authentication */ + MoveRequest withPassword(@Nullable final String password); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/ShowDiffRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/ShowDiffRequest.java index 1b70e1e5a6be..60cd0570b71e 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/ShowDiffRequest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/ShowDiffRequest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.shared; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.dto.shared.DTO; import javax.validation.constraints.NotNull; @@ -81,4 +82,22 @@ public interface ShowDiffRequest { * @return the request */ ShowDiffRequest withDepth(@NotNull final String depth); + + /** @return user name for authentication */ + String getUsername(); + + /** Set user name for authentication. */ + void setUsername(@Nullable final String username); + + /** @return {@link CheckoutRequest} with specified user name for authentication */ + ShowDiffRequest withUsername(@Nullable final String username); + + /** @return password for authentication */ + String getPassword(); + + /** Set password for authentication. */ + void setPassword(@Nullable final String password); + + /** @return {@link CheckoutRequest} with specified password for authentication */ + ShowDiffRequest withPassword(@Nullable final String password); } diff --git a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/UpdateRequest.java b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/UpdateRequest.java index 2b2a00d2c474..4add6a384b0d 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/UpdateRequest.java +++ b/plugins/plugin-svn/che-plugin-svn-ext-shared/src/main/java/org/eclipse/che/plugin/svn/shared/UpdateRequest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.svn.shared; +import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.dto.shared.DTO; import javax.validation.constraints.NotNull; @@ -119,4 +120,22 @@ public interface UpdateRequest { */ UpdateRequest withRevision(@NotNull final String revision); + /** @return user name for authentication */ + String getUsername(); + + /** Set user name for authentication. */ + void setUsername(@Nullable final String username); + + /** @return {@link CheckoutRequest} with specified user name for authentication */ + UpdateRequest withUsername(@Nullable final String username); + + /** @return password for authentication */ + String getPassword(); + + /** Set password for authentication. */ + void setPassword(@Nullable final String password); + + /** @return {@link CheckoutRequest} with specified password for authentication */ + UpdateRequest withPassword(@Nullable final String password); + } diff --git a/plugins/pom.xml b/plugins/pom.xml index 520d924ab485..25ea3a32369c 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -46,10 +46,12 @@ plugin-cpp plugin-csharp plugin-nodejs + plugin-nodejs-debugger plugin-php plugin-ssh-machine plugin-ssh-key plugin-pair-programming plugin-languageserver + plugin-json diff --git a/pom.xml b/pom.xml index 294cc5661fc2..96e2862082e2 100644 --- a/pom.xml +++ b/pom.xml @@ -178,6 +178,16 @@ che-core-api-jdbc-vendor-h2 ${project.version} + + org.eclipse.che.core + che-core-api-languageserver + ${che.version} + + + org.eclipse.che.core + che-core-api-languageserver-shared + ${che.version} + org.eclipse.che.core che-core-api-machine @@ -548,17 +558,12 @@ org.eclipse.che.plugin - che-plugin-languageserver-ide - ${project.version} - - - org.eclipse.che.plugin - che-plugin-languageserver-server - ${project.version} + che-plugin-json-server + ${che.version} org.eclipse.che.plugin - che-plugin-languageserver-shared + che-plugin-languageserver-ide ${project.version} @@ -596,6 +601,16 @@ che-plugin-maven-shared ${che.version} + + org.eclipse.che.plugin + che-plugin-nodejs-debugger-ide + ${che.version} + + + org.eclipse.che.plugin + che-plugin-nodejs-debugger-server + ${che.version} + org.eclipse.che.plugin che-plugin-nodejs-lang-ide diff --git a/samples/pom.xml b/samples/pom.xml index 63b8afc70b6b..797d737c94ad 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -25,8 +25,12 @@ pom Che Sample :: Parent + sample-plugin-embedjs sample-plugin-json sample-plugin-filetype sample-plugin-wizard + sample-plugin-nativeaccess + sample-plugin-parts + sample-plugin-serverservice diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/pom.xml b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/pom.xml new file mode 100644 index 000000000000..f31e4d1e246c --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/pom.xml @@ -0,0 +1,61 @@ + + + + 4.0.0 + + che-sample-plugin-embedjs-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + + che-sample-plugin-embedjs-ide + jar + Che Sample :: Plugin Embed JavaScript :: IDE + + + com.google.gwt.inject + gin + + + com.google.inject + guice + + + org.eclipse.che.core + che-core-commons-gwt + + + org.eclipse.che.core + che-core-ide-api + + + org.vectomatic + lib-gwt-svg + + + com.google.gwt + gwt-user + provided + + + + + + src/main/java + + + src/main/resources + + + + diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/HelloWorldResources.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/HelloWorldResources.java new file mode 100644 index 000000000000..a95a898cab4a --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/HelloWorldResources.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.resources.client.ClientBundle; +import org.vectomatic.dom.svg.ui.SVGResource; + +public interface HelloWorldResources extends ClientBundle { + + HelloWorldResources INSTANCE = GWT.create(HelloWorldResources.class); + + @Source("svg/icon.svg") + SVGResource icon(); + +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/HelloWorldViewExampleExtension.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/HelloWorldViewExampleExtension.java new file mode 100644 index 000000000000..b38589c59975 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/HelloWorldViewExampleExtension.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.eclipse.che.ide.api.action.ActionManager; +import org.eclipse.che.ide.api.action.DefaultActionGroup; +import org.eclipse.che.ide.api.extension.Extension; +import org.eclipse.che.plugin.embedjsexample.ide.action.HelloWorldAction; + +/** + * @author Mathias Schaefer + */ +@Extension(title = "Hello world from JavaScript example") +@Singleton +public class HelloWorldViewExampleExtension { + + @Inject + private void configureActions(final ActionManager actionManager, + final HelloWorldAction helloWorldAction) { + + DefaultActionGroup mainContextMenuGroup = (DefaultActionGroup)actionManager.getAction("resourceOperation"); + DefaultActionGroup jsGroup = new DefaultActionGroup("JavaScript View Example", true, actionManager); + mainContextMenuGroup.add(jsGroup); + + actionManager.registerAction(helloWorldAction.ACTION_ID, helloWorldAction); + jsGroup.addAction(helloWorldAction); + } + +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/action/HelloWorldAction.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/action/HelloWorldAction.java new file mode 100644 index 000000000000..777dbcf9dff0 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/action/HelloWorldAction.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide.action; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.eclipse.che.ide.api.action.Action; +import org.eclipse.che.ide.api.action.ActionEvent; +import org.eclipse.che.ide.api.parts.PartStackType; +import org.eclipse.che.ide.api.parts.WorkspaceAgent; +import org.eclipse.che.plugin.embedjsexample.ide.view.HelloWorldViewPresenter; + +/** + * Action for opening a part which embeds javascript code. + */ +@Singleton +public class HelloWorldAction extends Action { + + public final static String ACTION_ID = "helloWorldFromJSAction"; + + private WorkspaceAgent workspaceAgent; + private HelloWorldViewPresenter helloWorldViewPresenter; + + @Inject + public HelloWorldAction(WorkspaceAgent workspaceAgent, HelloWorldViewPresenter helloWorldViewPresenter) { + super("Show Hello World JavaScript View"); + this.workspaceAgent = workspaceAgent; + this.helloWorldViewPresenter = helloWorldViewPresenter; + } + + @Override + public void actionPerformed(ActionEvent e) { + workspaceAgent.openPart(helloWorldViewPresenter, PartStackType.INFORMATION); + workspaceAgent.setActivePart(helloWorldViewPresenter); + helloWorldViewPresenter.setVisible(true); + } + +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/common/Constants.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/common/Constants.java new file mode 100644 index 000000000000..42849e531731 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/common/Constants.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide.common; + +/** + * @author Mathias Schaefer + */ +public class Constants { + + public final static String JAVASCRIPT_FILE_ID = "helloworld.js"; + +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/inject/HelloWorldViewExampleGinModule.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/inject/HelloWorldViewExampleGinModule.java new file mode 100644 index 000000000000..c6010dbd7be3 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/inject/HelloWorldViewExampleGinModule.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide.inject; + +import com.google.gwt.inject.client.AbstractGinModule; +import org.eclipse.che.ide.api.extension.ExtensionGinModule; +import org.eclipse.che.plugin.embedjsexample.ide.view.HelloWorldView; +import org.eclipse.che.plugin.embedjsexample.ide.view.HelloWorldViewImpl; + +/** + * @author Mathias Schaefer + */ +@ExtensionGinModule +public class HelloWorldViewExampleGinModule extends AbstractGinModule { + + @Override + protected void configure() { + bind(HelloWorldView.class).to(HelloWorldViewImpl.class); + } + +} diff --git a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsView.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldView.java similarity index 52% rename from plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsView.java rename to samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldView.java index 24cefac529c8..d1720b217868 100644 --- a/plugins/plugin-svn/che-plugin-svn-ext-ide/src/main/java/org/eclipse/che/plugin/svn/ide/askcredentials/AskCredentialsView.java +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldView.java @@ -8,33 +8,20 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.svn.ide.askcredentials; +package org.eclipse.che.plugin.embedjsexample.ide.view; -public interface AskCredentialsView { +import org.eclipse.che.ide.api.mvp.View; +import org.eclipse.che.ide.api.parts.base.BaseActionDelegate; - public interface AskCredentialsDelegate { - - void onSaveClicked(); - - void onCancelClicked(); +/** + * @author Mathias Schaefer + */ +public interface HelloWorldView extends View { + interface ActionDelegate extends BaseActionDelegate { } - void setDelegate(AskCredentialsDelegate delegate); - - void showDialog(); - - void close(); - - void focusInUserNameField(); - - void setRepositoryUrl(String url); - - void clearUsername(); - - void clearPassword(); - - String getUsername(); + void sayHello(String content); - String getPassword(); + void setVisible(boolean visible); } diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewImpl.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewImpl.java new file mode 100644 index 000000000000..a4e04f75e436 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewImpl.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide.view; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.Widget; +import com.google.inject.Inject; +import org.eclipse.che.ide.api.parts.PartStackUIResources; +import org.eclipse.che.ide.api.parts.base.BaseView; +import org.eclipse.che.plugin.embedjsexample.ide.view.client.jso.HelloWorldViewOverlay; + +/** + * @author Mathias Schaefer + */ +public class HelloWorldViewImpl extends BaseView implements HelloWorldView { + + interface HelloWorldViewImplUiBinder extends UiBinder { + } + + private final static HelloWorldViewImplUiBinder UI_BINDER = GWT.create(HelloWorldViewImplUiBinder.class); + + @UiField + FlowPanel helloWorldPanel; + + @Inject + public HelloWorldViewImpl(PartStackUIResources resources) { + super(resources); + setContentWidget(UI_BINDER.createAndBindUi(this)); + } + + @Override + public void sayHello(String content) { + HelloWorldViewOverlay.sayHello(helloWorldPanel.getElement(), content); + helloWorldPanel.setVisible(true); + } + +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewImpl.ui.xml b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewImpl.ui.xml new file mode 100644 index 000000000000..f70d234b60ef --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewImpl.ui.xml @@ -0,0 +1,34 @@ + + + + + + + + @eval outputBackgroundColor org.eclipse.che.ide.api.theme.Style.theme.outputBackgroundColor(); + + .helloWorldPanel { + width: 100%; + height: 100%; + overflow: hidden; + background-color: outputBackgroundColor; + } + + + + + + + diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewPresenter.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewPresenter.java new file mode 100644 index 000000000000..daaf92e16d2d --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/HelloWorldViewPresenter.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide.view; + +import com.google.gwt.core.client.Callback; +import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.ScriptInjector; +import com.google.gwt.user.client.ui.AcceptsOneWidget; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.eclipse.che.ide.api.mvp.View; +import org.eclipse.che.ide.api.parts.base.BasePresenter; +import org.eclipse.che.ide.util.loging.Log; +import org.eclipse.che.plugin.embedjsexample.ide.HelloWorldResources; +import org.eclipse.che.plugin.embedjsexample.ide.common.Constants; +import org.vectomatic.dom.svg.ui.SVGResource; + +/** + * @author Mathias Schaefer + */ +@Singleton +public class HelloWorldViewPresenter extends BasePresenter implements HelloWorldView.ActionDelegate { + + private final HelloWorldView helloWorldView; + + @Inject + public HelloWorldViewPresenter(final HelloWorldView helloWorldView) { + this.helloWorldView = helloWorldView; + + ScriptInjector.fromUrl(GWT.getModuleBaseURL() + Constants.JAVASCRIPT_FILE_ID) + .setWindow(ScriptInjector.TOP_WINDOW) + .setCallback(new Callback() { + @Override + public void onSuccess(final Void result) { + Log.info(HelloWorldViewPresenter.class, Constants.JAVASCRIPT_FILE_ID + " loaded."); + sayHello("Hello from Java Script!"); + } + + @Override + public void onFailure(final Exception e) { + Log.error(HelloWorldViewPresenter.class, "Unable to load "+Constants.JAVASCRIPT_FILE_ID, e); + } + }).inject(); + + } + + private void sayHello(String content) { + this.helloWorldView.sayHello(content); + } + + @Override + public String getTitle() { + return "Hello world"; + } + + @Override + public SVGResource getTitleImage() { + return (HelloWorldResources.INSTANCE.icon()); + } + + @Override + public void setVisible(boolean visible) { + helloWorldView.setVisible(visible); + } + + @Override + public View getView() { + return helloWorldView; + } + + @Override + public String getTitleToolTip() { + return getTitle(); + } + + @Override + public void go(AcceptsOneWidget container) { + container.setWidget(helloWorldView); + } +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/client/jso/HelloWorldViewOverlay.java b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/client/jso/HelloWorldViewOverlay.java new file mode 100644 index 000000000000..ee3a9a8d94fd --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/java/org/eclipse/che/plugin/embedjsexample/ide/view/client/jso/HelloWorldViewOverlay.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.embedjsexample.ide.view.client.jso; + +import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.dom.client.Element; + +/** + * JavaScript overlay to demonstrate a global js function call + * + * @author Mathias Schaefer + */ +public class HelloWorldViewOverlay extends JavaScriptObject { + + protected HelloWorldViewOverlay() { + } + + public final static native void sayHello(final Element element, String message) /*-{ + new $wnd.HelloWorld(element, message); + }-*/; + +} diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/EmbedJSExample.gwt.xml b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/EmbedJSExample.gwt.xml new file mode 100644 index 000000000000..cbc6c91e7ef4 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/EmbedJSExample.gwt.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/ide/svg/icon.svg b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/ide/svg/icon.svg new file mode 100644 index 000000000000..ba2158499113 --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/ide/svg/icon.svg @@ -0,0 +1,48 @@ + + + + {} + + diff --git a/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/public/helloworld.js b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/public/helloworld.js new file mode 100644 index 000000000000..af119c6d05ab --- /dev/null +++ b/samples/sample-plugin-embedjs/che-sample-plugin-embedjs-ide/src/main/resources/org/eclipse/che/plugin/embedjsexample/public/helloworld.js @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + */ +function HelloWorld( + element, contents) { + element.textContent = contents; +}; + diff --git a/samples/sample-plugin-embedjs/pom.xml b/samples/sample-plugin-embedjs/pom.xml new file mode 100644 index 000000000000..964a92c0eedd --- /dev/null +++ b/samples/sample-plugin-embedjs/pom.xml @@ -0,0 +1,28 @@ + + + + 4.0.0 + + che-sample-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + ../pom.xml + + che-sample-plugin-embedjs-parent + pom + Che Sample :: Plugin Embed JavaScript :: Parent + + che-sample-plugin-embedjs-ide + + diff --git a/samples/sample-plugin-json/che-sample-plugin-json-ide/pom.xml b/samples/sample-plugin-json/che-sample-plugin-json-ide/pom.xml index a722eadd9f1f..2d96f8e0971e 100644 --- a/samples/sample-plugin-json/che-sample-plugin-json-ide/pom.xml +++ b/samples/sample-plugin-json/che-sample-plugin-json-ide/pom.xml @@ -22,6 +22,10 @@ jar Che Sample :: Plugin JSON :: IDE + + com.google.guava + guava + com.google.gwt.inject gin @@ -42,14 +46,6 @@ javax.validation validation-api - - org.eclipse.che.core - che-core-api-workspace - - - org.eclipse.che.core - che-core-api-workspace-shared - org.eclipse.che.core che-core-commons-annotations @@ -90,6 +86,7 @@ + org.apache.maven.plugins maven-dependency-plugin @@ -97,15 +94,14 @@ analyze - true + + org.eclipse.che.core:che-core-ide-app + org.eclipse.che.sample:che-sample-plugin-json-shared + - - org.apache.maven.plugins - maven-surefire-plugin - diff --git a/samples/sample-plugin-json/che-sample-plugin-json-ide/src/main/java/org/eclipse/che/plugin/jsonexample/ide/action/JsonExampleProjectAction.java b/samples/sample-plugin-json/che-sample-plugin-json-ide/src/main/java/org/eclipse/che/plugin/jsonexample/ide/action/JsonExampleProjectAction.java index b5f9be779cbf..9065390c21d3 100644 --- a/samples/sample-plugin-json/che-sample-plugin-json-ide/src/main/java/org/eclipse/che/plugin/jsonexample/ide/action/JsonExampleProjectAction.java +++ b/samples/sample-plugin-json/che-sample-plugin-json-ide/src/main/java/org/eclipse/che/plugin/jsonexample/ide/action/JsonExampleProjectAction.java @@ -18,7 +18,7 @@ import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.api.resources.Project; import org.eclipse.che.ide.api.resources.Resource; -import org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective; +import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID; import org.vectomatic.dom.svg.ui.SVGResource; import javax.validation.constraints.NotNull; @@ -49,7 +49,7 @@ public JsonExampleProjectAction(AppContext appContext, @NotNull String text, @NotNull String description, @Nullable SVGResource svgResource) { - super(Collections.singletonList(ProjectPerspective.PROJECT_PERSPECTIVE_ID), + super(Collections.singletonList(PROJECT_PERSPECTIVE_ID), text, description, null, diff --git a/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/pom.xml b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/pom.xml new file mode 100644 index 000000000000..f0af27f22c1f --- /dev/null +++ b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/pom.xml @@ -0,0 +1,85 @@ + + + + 4.0.0 + + che-sample-plugin-nativeaccess-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + + che-sample-plugin-nativeaccess-ide + jar + Che Sample :: Plugin Native Access :: IDE + + + com.google.inject + guice + + + javax.validation + validation-api + + + org.eclipse.che.core + che-core-api-machine-shared + + + org.eclipse.che.core + che-core-api-model + + + org.eclipse.che.core + che-core-commons-gwt + + + org.eclipse.che.core + che-core-ide-api + + + com.google.gwt + gwt-user + provided + + + com.google.gwt + gwt-dev + test + + + com.google.gwt.gwtmockito + gwtmockito + test + + + junit + junit + test + + + org.mockito + mockito-core + test + + + + + + src/main/java + + + src/main/resources + + + + diff --git a/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/ide/NativeAccessExampleExtension.java b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/ide/NativeAccessExampleExtension.java new file mode 100644 index 000000000000..1ab6895e0eb5 --- /dev/null +++ b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/ide/NativeAccessExampleExtension.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nativeaccessexample.ide; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.eclipse.che.ide.api.action.ActionManager; +import org.eclipse.che.ide.api.action.DefaultActionGroup; +import org.eclipse.che.ide.api.extension.Extension; +import org.eclipse.che.plugin.nativeaccessexample.ide.action.RunNativeCommandAction; + +/** + * Native access example extension which registers exactly one sample action. + * + * @author Mathias Schaefer + */ +@Extension(title = "Native access example") +@Singleton +public class NativeAccessExampleExtension { + + @Inject + private void configureActions(final ActionManager actionManager, + final RunNativeCommandAction runNativenCommandAction) { + + DefaultActionGroup mainContextMenuGroup = (DefaultActionGroup)actionManager.getAction("resourceOperation"); + DefaultActionGroup naGroup = new DefaultActionGroup("Native Access Example", true, actionManager); + mainContextMenuGroup.add(naGroup); + + actionManager.registerAction(runNativenCommandAction.ACTION_ID, runNativenCommandAction); + naGroup.addAction(runNativenCommandAction); + } + +} diff --git a/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/ide/action/RunNativeCommandAction.java b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/ide/action/RunNativeCommandAction.java new file mode 100644 index 000000000000..0c0526ea2c60 --- /dev/null +++ b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/ide/action/RunNativeCommandAction.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nativeaccessexample.ide.action; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.eclipse.che.ide.api.action.Action; +import org.eclipse.che.ide.api.action.ActionEvent; +import org.eclipse.che.ide.util.loging.Log; +import org.eclipse.che.plugin.nativeaccessexample.machine.client.command.CommandManager; + +/** + * Action for opening a part which embeds javascript code. + */ +@Singleton +public class RunNativeCommandAction extends Action { + + public final static String ACTION_ID = "runNativeCommandSAction"; + + private CommandManager commandManager; + + @Inject + public RunNativeCommandAction(CommandManager commandManager) { + super("Run native command demo"); + this.commandManager = commandManager; + } + + @Override + public void actionPerformed(ActionEvent e) { + Log.warn(getClass(), "Executing native command..."); + commandManager.execute("cd && touch che-was-here"); + } + +} diff --git a/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/machine/client/command/CommandManager.java b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/machine/client/command/CommandManager.java new file mode 100644 index 000000000000..a25bfa68c7ae --- /dev/null +++ b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/java/org/eclipse/che/plugin/nativeaccessexample/machine/client/command/CommandManager.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.nativeaccessexample.machine.client.command; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.eclipse.che.api.core.model.machine.Machine; +import org.eclipse.che.api.machine.shared.dto.CommandDto; +import org.eclipse.che.api.machine.shared.dto.MachineProcessDto; +import org.eclipse.che.api.promises.client.Operation; +import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.Promise; +import org.eclipse.che.ide.api.app.AppContext; +import org.eclipse.che.ide.api.machine.MachineServiceClient; +import org.eclipse.che.ide.api.notification.NotificationManager; +import org.eclipse.che.ide.dto.DtoFactory; +import org.eclipse.che.ide.util.UUID; + +import javax.validation.constraints.NotNull; + +/** + * Simple command manager which allows to run native commands within the workspace Docker container. + * Please note that the actual call is delegated to the MachineServiceClient service. + * + * @author Mathias Schaefer + */ +@Singleton +public class CommandManager { + + private final DtoFactory dtoFactory; + private final MachineServiceClient machineServiceClient; + private final NotificationManager notificationManager; + private final AppContext appContext; + + @Inject + public CommandManager(DtoFactory dtoFactory, MachineServiceClient machineServiceClient, NotificationManager notificationManager, AppContext appContext) { + this.dtoFactory = dtoFactory; + this.machineServiceClient = machineServiceClient; + this.notificationManager = notificationManager; + this.appContext = appContext; + } + + /** + * Execute the the given command command within the workspace Docker container. + */ + public void execute(String commandLine) { + final Machine machine = appContext.getDevMachine().getDescriptor(); + if (machine == null) { + return; + } + String workspaceID = appContext.getWorkspaceId(); + String machineID = machine.getId(); + final CommandDto command = dtoFactory.createDto(CommandDto.class) + .withName("some-command") + .withCommandLine(commandLine) + .withType("arbitrary-type"); + final String outputChannel = "process:output:" + UUID.uuid(); + executeCommand(command, workspaceID, machineID, outputChannel); + } + + public void executeCommand(final CommandDto command, @NotNull final String workspaceID, @NotNull final String machineID, String outputChannel) { + final Promise processPromise = machineServiceClient.executeCommand(workspaceID, machineID, command, outputChannel); + processPromise.then(new Operation() { + @Override + public void apply(MachineProcessDto process) throws OperationException + { + //Do nothing in this example + } + + }); + + } +} diff --git a/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/resources/org/eclipse/che/plugin/nativeaccessexample/NativeAccessExample.gwt.xml b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/resources/org/eclipse/che/plugin/nativeaccessexample/NativeAccessExample.gwt.xml new file mode 100644 index 000000000000..309970144658 --- /dev/null +++ b/samples/sample-plugin-nativeaccess/che-sample-plugin-nativeaccess-ide/src/main/resources/org/eclipse/che/plugin/nativeaccessexample/NativeAccessExample.gwt.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + diff --git a/samples/sample-plugin-nativeaccess/pom.xml b/samples/sample-plugin-nativeaccess/pom.xml new file mode 100644 index 000000000000..1e0be8ba6183 --- /dev/null +++ b/samples/sample-plugin-nativeaccess/pom.xml @@ -0,0 +1,28 @@ + + + + 4.0.0 + + che-sample-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + ../pom.xml + + che-sample-plugin-nativeaccess-parent + pom + Che Sample :: Plugin Native Access :: Parent + + che-sample-plugin-nativeaccess-ide + + diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/pom.xml b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/pom.xml new file mode 100644 index 000000000000..346f7bc6c692 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/pom.xml @@ -0,0 +1,57 @@ + + + + 4.0.0 + + che-sample-plugin-parts-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + + che-sample-plugin-parts-ide + jar + Che Sample :: Plugin Parts :: IDE + + + com.google.gwt.inject + gin + + + com.google.inject + guice + + + org.eclipse.che.core + che-core-ide-api + + + org.vectomatic + lib-gwt-svg + + + com.google.gwt + gwt-user + provided + + + + + + src/main/java + + + src/main/resources + + + + diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/SamplePartsExtension.java b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/SamplePartsExtension.java new file mode 100644 index 000000000000..9d13ab79fd88 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/SamplePartsExtension.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.parts.ide; + +import com.google.inject.Inject; + +import org.eclipse.che.ide.api.action.ActionManager; +import org.eclipse.che.ide.api.action.DefaultActionGroup; +import org.eclipse.che.ide.api.extension.Extension; +import org.eclipse.che.plugin.parts.ide.helloworldview.HelloWorldViewAction; + +import static org.eclipse.che.ide.api.action.IdeActions.GROUP_MAIN_MENU; + +/** + * Extension that defines a simple view containing a 'Hello World' label. + * + * @author Edgar Mueller + */ +@Extension(title = "Sample Parts Extension") +public class SamplePartsExtension { + + /** + * Constructor. + * + * @param actionManager the {@link ActionManager} that is used to register the action + * @param action the {@link HelloWorldViewAction} that display the sample view + */ + @Inject + public SamplePartsExtension(ActionManager actionManager, HelloWorldViewAction action){ + actionManager.registerAction("helloWorldViewAction",action); + DefaultActionGroup mainMenu = (DefaultActionGroup)actionManager.getAction(GROUP_MAIN_MENU); + + DefaultActionGroup sampleActionGroup = new DefaultActionGroup("Sample Action", true, actionManager); + sampleActionGroup.add(action); + + mainMenu.add(sampleActionGroup); + } +} diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/SamplePartsResources.java b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/SamplePartsResources.java new file mode 100644 index 000000000000..3c9d6fedfc1a --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/SamplePartsResources.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.parts.ide; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.resources.client.ClientBundle; + +import org.vectomatic.dom.svg.ui.SVGResource; + +/** + * Resources for the Sample Parts extension. + * + * @author Edgar Mueller + */ +public interface SamplePartsResources extends ClientBundle { + + /** + * Singleton instance. + */ + SamplePartsResources INSTANCE = GWT.create(SamplePartsResources.class); + + /** + * Declares an icon. + * + * @return the icon + */ + @Source("icons/my.svg") + SVGResource icon(); +} diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldPresenter.java b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldPresenter.java new file mode 100644 index 000000000000..9637122af1f4 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldPresenter.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ + +package org.eclipse.che.plugin.parts.ide.helloworldview; +import com.google.gwt.user.client.ui.AcceptsOneWidget; +import com.google.gwt.user.client.ui.IsWidget; +import com.google.inject.Inject; +import com.google.inject.Singleton; + +import org.eclipse.che.ide.api.parts.base.BasePresenter; +import org.eclipse.che.plugin.parts.ide.SamplePartsResources; +import org.vectomatic.dom.svg.ui.SVGResource; + +/** + * Presenter for the sample Hello World View. + * + * @author Edgar Mueller + */ +@Singleton +public class HelloWorldPresenter extends BasePresenter { + + private HelloWorldView view; + + @Inject + public HelloWorldPresenter(HelloWorldView view){ + this.view = view; + } + + @Override + public String getTitle() { + return "Hello World View"; + } + + @Override + public void setVisible(boolean visible) { + view.setVisible(visible); + } + + @Override + public SVGResource getTitleImage() { + return (SamplePartsResources.INSTANCE.icon()); + } + + @Override + public IsWidget getView() { + return view; + } + + @Override + public String getTitleToolTip() { + return "Hello World Tooltip"; + } + + @Override + public void go(AcceptsOneWidget container) { + container.setWidget(view); + } +} diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldView.java b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldView.java new file mode 100644 index 000000000000..6e3bebcd6abf --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldView.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.parts.ide.helloworldview; + + +import org.eclipse.che.ide.api.mvp.View; +import org.eclipse.che.ide.api.parts.base.BaseActionDelegate; + +/** + * Simple view only containing a label. + * + * @author Edgar Mueller + */ +public interface HelloWorldView extends View { + + /** + * Make this view visible. + * + * @param visible whether the view is visible + */ + void setVisible(boolean visible); + + /** + * Empty action delegate. + */ + interface ActionDelegate extends BaseActionDelegate { + + } +} diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldViewAction.java b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldViewAction.java new file mode 100644 index 000000000000..711647c7d248 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldViewAction.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.parts.ide.helloworldview; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import org.eclipse.che.ide.api.action.Action; +import org.eclipse.che.ide.api.action.ActionEvent; +import org.eclipse.che.ide.api.parts.PartStackType; +import org.eclipse.che.ide.api.parts.WorkspaceAgent; + +/** + * Action for showing the Hello World View. + * + * @author Edgar Mueller + */ +@Singleton +public class HelloWorldViewAction extends Action { + + private WorkspaceAgent workspaceAgent; + private HelloWorldPresenter helloWorldPresenter; + + /** + * Constructor. + * + * @param workspaceAgent the {@link WorkspaceAgent} that will open our sample part + * @param helloWorldPresenter the {@link HelloWorldPresenter} displaying the view + * + */ + @Inject + public HelloWorldViewAction(WorkspaceAgent workspaceAgent, HelloWorldPresenter helloWorldPresenter) { + super("Show Hello World View"); + this.workspaceAgent = workspaceAgent; + this.helloWorldPresenter = helloWorldPresenter; + } + + + @Override + public void actionPerformed(ActionEvent e) { + workspaceAgent.openPart(helloWorldPresenter, PartStackType.INFORMATION); + workspaceAgent.setActivePart(helloWorldPresenter); + } +} diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldViewImpl.java b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldViewImpl.java new file mode 100644 index 000000000000..1d81df254853 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/helloworldview/HelloWorldViewImpl.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.parts.ide.helloworldview; + +import com.google.gwt.user.client.ui.Label; +import com.google.inject.Inject; + +import org.eclipse.che.ide.api.parts.PartStackUIResources; +import org.eclipse.che.ide.api.parts.base.BaseView; + +/** + * Implementation class of the {@link HelloWorldView}. + * + * @author Edgar Mueller + */ +public class HelloWorldViewImpl extends BaseView implements HelloWorldView { + + /** + * Constructor. + * + * @param resources the {@link PartStackUIResources} + */ + @Inject + public HelloWorldViewImpl(PartStackUIResources resources){ + super(resources); + Label label = new Label("Hello World"); + setContentWidget(label); + } +} diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/inject/MyGinModule.java b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/inject/MyGinModule.java new file mode 100644 index 000000000000..3eb24f3c87d2 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/java/org/eclipse/che/plugin/parts/ide/inject/MyGinModule.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.parts.ide.inject; + +import com.google.gwt.inject.client.AbstractGinModule; + +import org.eclipse.che.ide.api.extension.ExtensionGinModule; +import org.eclipse.che.plugin.parts.ide.helloworldview.HelloWorldView; +import org.eclipse.che.plugin.parts.ide.helloworldview.HelloWorldViewImpl; + +/** + * Gin module binding the {@link HelloWorldView} to the {@link HelloWorldViewImpl} implementation class. + * + * @author Edgar Mueller + */ +@ExtensionGinModule +public class MyGinModule extends AbstractGinModule { + + @Override + protected void configure() { + bind(HelloWorldView.class).to(HelloWorldViewImpl.class); + } + +} diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/resources/org/eclipse/che/plugin/parts/SampleParts.gwt.xml b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/resources/org/eclipse/che/plugin/parts/SampleParts.gwt.xml new file mode 100644 index 000000000000..160df50f8f97 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/resources/org/eclipse/che/plugin/parts/SampleParts.gwt.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + diff --git a/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/resources/org/eclipse/che/plugin/parts/ide/icons/my.svg b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/resources/org/eclipse/che/plugin/parts/ide/icons/my.svg new file mode 100644 index 000000000000..cbe1599c8aa1 --- /dev/null +++ b/samples/sample-plugin-parts/che-sample-plugin-parts-ide/src/main/resources/org/eclipse/che/plugin/parts/ide/icons/my.svg @@ -0,0 +1,39 @@ + + + + my + diff --git a/samples/sample-plugin-parts/pom.xml b/samples/sample-plugin-parts/pom.xml new file mode 100644 index 000000000000..0c92e1558de4 --- /dev/null +++ b/samples/sample-plugin-parts/pom.xml @@ -0,0 +1,28 @@ + + + + 4.0.0 + + che-sample-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + ../pom.xml + + che-sample-plugin-parts-parent + pom + Che Sample :: Plugin Parts :: Parent + + che-sample-plugin-parts-ide + + diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/pom.xml b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/pom.xml new file mode 100644 index 000000000000..c6eece677734 --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/pom.xml @@ -0,0 +1,57 @@ + + + + 4.0.0 + + che-sample-plugin-serverservice-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + + che-sample-plugin-serverservice-ide + jar + Che Sample :: Plugin ServerService :: IDE + + + com.google.inject + guice + + + javax.inject + javax.inject + + + org.eclipse.che.core + che-core-commons-gwt + + + org.eclipse.che.core + che-core-ide-api + + + com.google.gwt + gwt-user + provided + + + + + + src/main/java + + + src/main/resources + + + + diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/MyServiceClient.java b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/MyServiceClient.java new file mode 100644 index 000000000000..e068d5c3c478 --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/MyServiceClient.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ + +package org.eclipse.che.plugin.serverservice.ide; + +import org.eclipse.che.api.promises.client.Promise; +import org.eclipse.che.ide.api.app.AppContext; +import org.eclipse.che.ide.rest.AsyncRequestFactory; +import org.eclipse.che.ide.rest.StringUnmarshaller; +import org.eclipse.che.ide.ui.loaders.request.LoaderFactory; + +import javax.inject.Inject; + +/** + * Client for consuming the sample server service. + * + * @author Edgar Mueller + */ +public class MyServiceClient { + + private AppContext appContext; + private AsyncRequestFactory asyncRequestFactory; + private LoaderFactory loaderFactory; + + /** + * Constructor. + * + * @param appContext the {@link AppContext} + * @param asyncRequestFactory the {@link AsyncRequestFactory} that is used to create requests + * @param loaderFactory the {@link LoaderFactory} for displaying a message while waiting for a response + */ + @Inject + public MyServiceClient( + final AppContext appContext, + final AsyncRequestFactory asyncRequestFactory, + final LoaderFactory loaderFactory) { + + this.appContext = appContext; + this.asyncRequestFactory = asyncRequestFactory; + this.loaderFactory = loaderFactory; + } + + /** + * Invoke the sample server service. + * + * @param name a parameter + * @return a Promise containing the server response + */ + public Promise getHello(String name) { + return asyncRequestFactory.createGetRequest(appContext.getDevMachine().getWsAgentBaseUrl() + "/hello/" + name) + .loader(loaderFactory.newLoader("Waiting for hello...")) + .send(new StringUnmarshaller()); + } + +} diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/ServerServiceExtension.java b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/ServerServiceExtension.java new file mode 100644 index 000000000000..997973bedfc8 --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/ServerServiceExtension.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.serverservice.ide; + +import com.google.inject.Inject; + +import org.eclipse.che.ide.api.action.ActionManager; +import org.eclipse.che.ide.api.action.DefaultActionGroup; +import org.eclipse.che.ide.api.action.IdeActions; +import org.eclipse.che.ide.api.extension.Extension; +import org.eclipse.che.plugin.serverservice.ide.action.MyAction; + +/** + * Server service extension that registers action which calls a service. + * + * @author Edgar Mueller + */ +@Extension(title = "Server Service Sample Extension", version = "0.0.1") +public class ServerServiceExtension { + + /** + * Constructor. + * + * @param actionManager + * the {@link ActionManager} that is used to register our actions + * @param myAction + * the action that calls the example server service + */ + @Inject + public ServerServiceExtension(ActionManager actionManager, MyAction myAction) { + + actionManager.registerAction("myAction", myAction); + + DefaultActionGroup mainContextMenuGroup = (DefaultActionGroup)actionManager.getAction(IdeActions.GROUP_MAIN_CONTEXT_MENU); + mainContextMenuGroup.add(myAction); + } +} diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/action/MyAction.java b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/action/MyAction.java new file mode 100644 index 000000000000..97c4cfedf8d7 --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/java/org/eclipse/che/plugin/serverservice/ide/action/MyAction.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.serverservice.ide.action; + +import com.google.inject.Inject; + +import org.eclipse.che.api.promises.client.Operation; +import org.eclipse.che.api.promises.client.OperationException; +import org.eclipse.che.api.promises.client.PromiseError; +import org.eclipse.che.ide.api.action.Action; +import org.eclipse.che.ide.api.action.ActionEvent; +import org.eclipse.che.ide.api.notification.NotificationManager; +import org.eclipse.che.ide.api.notification.StatusNotification; +import org.eclipse.che.plugin.serverservice.ide.MyServiceClient; + +/** + * Actions that triggers the sample server service call. + * + * @author Edgar Mueller + */ +public class MyAction extends Action { + + private final NotificationManager notificationManager; + private final MyServiceClient serviceClient; + + /** + * Constructor. + * + * @param notificationManager the notification manager + * @param serviceClient the client that is used to create requests + */ + @Inject + public MyAction(final NotificationManager notificationManager, + final MyServiceClient serviceClient) { + super("My Action", "My Action Description"); + this.notificationManager = notificationManager; + this.serviceClient = serviceClient; + } + + @Override + public void actionPerformed(ActionEvent e) { + // This calls the service in the workspace. + // This method is in our org.eclipse.che.plugin.serverservice.ide.MyServiceClient class + // This is a Promise, so the .then() method is invoked after the response is made + serviceClient.getHello("CheTheAllPowerful!").then(new Operation() { + @Override + public void apply(String response) throws OperationException { + // This passes the response String to the notification manager. + notificationManager.notify(response, StatusNotification.Status.SUCCESS, StatusNotification.DisplayMode.FLOAT_MODE); + } + }).catchError(new Operation() { + @Override + public void apply(PromiseError error) throws OperationException { + notificationManager.notify("Fail", StatusNotification.Status.FAIL, StatusNotification.DisplayMode.FLOAT_MODE); + } + }); + } +} diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/resources/org/eclipse/che/plugin/serverservice/ServerService.gwt.xml b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/resources/org/eclipse/che/plugin/serverservice/ServerService.gwt.xml new file mode 100644 index 000000000000..160df50f8f97 --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-ide/src/main/resources/org/eclipse/che/plugin/serverservice/ServerService.gwt.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/pom.xml b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/pom.xml new file mode 100644 index 000000000000..5e94168175e6 --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/pom.xml @@ -0,0 +1,37 @@ + + + + 4.0.0 + + che-sample-plugin-serverservice-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + + che-sample-plugin-serverservice-server + Che Sample :: Plugin ServerService :: Server + + + com.google.inject + guice + + + javax.ws.rs + javax.ws.rs-api + + + org.eclipse.che.core + che-core-commons-inject + + + diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/src/main/java/org/eclipse/che/plugin/serverservice/MyService.java b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/src/main/java/org/eclipse/che/plugin/serverservice/MyService.java new file mode 100644 index 000000000000..399cba29ca04 --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/src/main/java/org/eclipse/che/plugin/serverservice/MyService.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.serverservice; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + +/** + * Example server service that greets the user. + * + * @author Edgar Mueller + */ +@Path("hello") +public class MyService { + + /** + * Returns a greeting message. + * + * @param name the parameter + * @return a greeting message + */ + @GET + @Path("{name}") + public String sayHello(@PathParam("name") String name) { + return "Hello " + name + "!"; + } +} diff --git a/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/src/main/java/org/eclipse/che/plugin/serverservice/inject/ServerServiceGuiceModule.java b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/src/main/java/org/eclipse/che/plugin/serverservice/inject/ServerServiceGuiceModule.java new file mode 100644 index 000000000000..3c083e15e28a --- /dev/null +++ b/samples/sample-plugin-serverservice/che-sample-plugin-serverservice-server/src/main/java/org/eclipse/che/plugin/serverservice/inject/ServerServiceGuiceModule.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.plugin.serverservice.inject; + +import com.google.inject.AbstractModule; + +import org.eclipse.che.inject.DynaModule; +import org.eclipse.che.plugin.serverservice.MyService; + +/** + * Server service example Guice module for setting up a simple service. + */ +@DynaModule +public class ServerServiceGuiceModule extends AbstractModule { + + @Override + protected void configure() { + bind(MyService.class); + } +} diff --git a/samples/sample-plugin-serverservice/pom.xml b/samples/sample-plugin-serverservice/pom.xml new file mode 100644 index 000000000000..010d2529b45f --- /dev/null +++ b/samples/sample-plugin-serverservice/pom.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + + che-sample-parent + org.eclipse.che.sample + 5.0.0-M5-SNAPSHOT + ../pom.xml + + che-sample-plugin-serverservice-parent + pom + Che Sample :: Plugin ServerService :: Parent + + che-sample-plugin-serverservice-ide + che-sample-plugin-serverservice-server + + diff --git a/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitProjectImporter.java b/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitProjectImporter.java index 01abcbd17d0a..144029adbaa6 100644 --- a/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitProjectImporter.java +++ b/wsagent/che-core-api-git/src/main/java/org/eclipse/che/api/git/GitProjectImporter.java @@ -140,8 +140,8 @@ public void importSources(FolderEntry baseFolder, recursiveEnabled = true; } branchMerge = parameters.get("branchMerge"); - final String user = parameters.get("userName"); - final String pass = parameters.get("password"); + final String user = storage.getParameters().remove("username"); + final String pass = storage.getParameters().remove("password"); if (user != null && pass != null) { credentialsHaveBeenSet = true; setCurrentCredentials(user, pass); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/pom.xml b/wsagent/che-core-api-languageserver-shared/pom.xml similarity index 69% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/pom.xml rename to wsagent/che-core-api-languageserver-shared/pom.xml index e4de24f31574..8ef463a013e3 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/pom.xml +++ b/wsagent/che-core-api-languageserver-shared/pom.xml @@ -14,12 +14,13 @@ 4.0.0 - che-plugin-languageserver-parent - org.eclipse.che.plugin + che-agent-parent + org.eclipse.che.core 5.0.0-M5-SNAPSHOT - che-plugin-languageserver-shared - Che Plugin :: Language Server :: Shared + che-core-api-languageserver-shared + jar + Che Core :: API :: Language Server Shared ${project.build.directory}/generated-sources/dto/ false @@ -29,10 +30,6 @@ com.google.code.gson gson - - com.google.inject - guice - io.typefox.lsapi io.typefox.lsapi @@ -41,15 +38,6 @@ org.eclipse.che.core che-core-api-dto - - org.eclipse.che.core - che-core-commons-gwt - - - com.google.gwt - gwt-user - provided - @@ -60,7 +48,7 @@ src/main/resources - ${dto-generator-out-directory} + ${generated.sources.directory} @@ -74,37 +62,32 @@ - org.codehaus.mojo - build-helper-maven-plugin + org.eclipse.che.core + che-core-api-dto-maven-plugin + ${project.version} - add-resource - process-sources - - add-resource - - - - - ${dto-generator-out-directory}/META-INF - META-INF - - - - - - add-source process-sources - add-source + generate - - - ${dto-generator-out-directory} - - + + + ${project.groupId} + ${project.artifactId} + ${project.version} + + + + + org.eclipse.che.api.languageserver.shared + + ${dto-generator-out-directory} + org.eclipse.che.api.languageserver.server.dto.DtoServerImpls + server + maven-compiler-plugin @@ -119,48 +102,37 @@ - org.eclipse.che.core - che-core-api-dto-maven-plugin - ${project.version} + org.codehaus.mojo + build-helper-maven-plugin - generate-client-dto + add-resource process-sources - generate + add-resource - - org.eclipse.che.plugin.languageserver.shared - - ${dto-generator-out-directory} - org.eclipse.che.plugin.languageserver.shared.dto.DtoClientImpls - client + + + ${dto-generator-out-directory}/META-INF + META-INF + + - generate-server-dto + add-source process-sources - generate + add-source - - org.eclipse.che.plugin.languageserver.shared - - ${dto-generator-out-directory} - org.eclipse.che.plugin.languageserver.shared.dto.DtoServerImpls - server + + ${dto-generator-out-directory} + - - - ${project.groupId} - ${project.artifactId} - ${project.version} - - diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/ProjectExtensionKey.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKey.java similarity index 97% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/ProjectExtensionKey.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKey.java index 52e329a443e5..ef55e856d90c 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/ProjectExtensionKey.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKey.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.shared; +package org.eclipse.che.api.languageserver.shared; import java.util.Objects; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/ProjectExtensionKeyDto.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKeyDto.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/ProjectExtensionKeyDto.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKeyDto.java index 57efb7f9b57d..45cd703522d7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/ProjectExtensionKeyDto.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKeyDto.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.shared; +package org.eclipse.che.api.languageserver.shared; import org.eclipse.che.dto.shared.DTO; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/event/LanguageServerInitializeEventDto.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/event/LanguageServerInitializeEventDto.java similarity index 81% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/event/LanguageServerInitializeEventDto.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/event/LanguageServerInitializeEventDto.java index c56c4b5a226a..ccb89979d5f2 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/event/LanguageServerInitializeEventDto.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/event/LanguageServerInitializeEventDto.java @@ -8,11 +8,11 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.shared.event; +package org.eclipse.che.api.languageserver.shared.event; +import org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.ServerCapabilitiesDTO; import org.eclipse.che.dto.shared.DTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LanguageDescriptionDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.ServerCapabilitiesDTO; /** * @author Anatoliy Bazko diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CancelParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CancelParamsDTO.java similarity index 90% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CancelParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CancelParamsDTO.java index 391e1cda7f18..b2c3db04f110 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CancelParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CancelParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CancelParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ClientCapabilitiesDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ClientCapabilitiesDTO.java similarity index 89% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ClientCapabilitiesDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ClientCapabilitiesDTO.java index 94dad845dbed..572afeb4827a 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ClientCapabilitiesDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ClientCapabilitiesDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.ClientCapabilities; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeActionContextDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionContextDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeActionContextDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionContextDTO.java index 6173030ca0cd..10a44b3b4bc7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeActionContextDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionContextDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CodeActionContext; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeActionParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionParamsDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeActionParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionParamsDTO.java index 5a504e84c562..0e9fce86c064 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeActionParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CodeActionParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensDTO.java index 879e353be1fe..116b847fbb0d 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CodeLens; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensOptionsDTO.java similarity index 91% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensOptionsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensOptionsDTO.java index eddb70a45974..0342246676b1 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensOptionsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensOptionsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CodeLensOptions; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensParamsDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensParamsDTO.java index c6f2b85da12f..8ab8c939b7b3 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CodeLensParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CodeLensParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CommandDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CommandDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CommandDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CommandDTO.java index c892ba42253e..8917ee3cc377 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CommandDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CommandDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.Command; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CompletionItemDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionItemDTO.java similarity index 97% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CompletionItemDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionItemDTO.java index 54a7435eb488..710b7e838a15 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CompletionItemDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionItemDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CompletionItem; import io.typefox.lsapi.CompletionItemKind; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CompletionOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionOptionsDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CompletionOptionsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionOptionsDTO.java index be47d7b6ab00..af7cdbb64add 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/CompletionOptionsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionOptionsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.CompletionOptions; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DiagnosticDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DiagnosticDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DiagnosticDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DiagnosticDTO.java index e4a19e2239c8..d6d4f97ce80a 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DiagnosticDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DiagnosticDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.Diagnostic; import io.typefox.lsapi.DiagnosticSeverity; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java similarity index 90% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java index 4d5bc3c99692..673638c97da0 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DidChangeConfigurationParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java similarity index 96% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java index bbf1effe8bf2..57c5c3c20989 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DidChangeTextDocumentParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java index fd800cef85d9..5b630d802fc7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DidChangeWatchedFilesParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java index 044504f3f065..2370d6124f9f 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DidCloseTextDocumentParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java index f23dd90f8277..b4456ed95908 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DidOpenTextDocumentParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java index c0a6c502aa35..70f56310f1e0 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DidSaveTextDocumentParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java index 7f1c97c9a25a..d66e91930135 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DocumentFormattingParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentHighlightDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentHighlightDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentHighlightDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentHighlightDTO.java index deec360f0dbd..74bfc9043957 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentHighlightDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentHighlightDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DocumentHighlight; import io.typefox.lsapi.DocumentHighlightKind; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java index 3ad0ed074e43..a11fe493dcde 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DocumentOnTypeFormattingOptions; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java index 17724d697f1f..f3a17ffbd721 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DocumentOnTypeFormattingParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java index 2c45fd0858ab..90e729550204 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DocumentRangeFormattingParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java index f5113e4dd47e..575edae84517 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.DocumentSymbolParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/FileEventDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FileEventDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/FileEventDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FileEventDTO.java index 742b2163c96e..d35cf6062fd7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/FileEventDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FileEventDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.FileChangeType; import io.typefox.lsapi.FileEvent; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/FormattingOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FormattingOptionsDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/FormattingOptionsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FormattingOptionsDTO.java index d6a754a4b387..2979ac008a52 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/FormattingOptionsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FormattingOptionsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.FormattingOptions; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/HoverDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/HoverDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/HoverDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/HoverDTO.java index 821b5be58de1..8d5a7974caca 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/HoverDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/HoverDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.Hover; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/InitializeErrorDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeErrorDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/InitializeErrorDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeErrorDTO.java index 30c208d2bf7c..397641db2f09 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/InitializeErrorDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeErrorDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.InitializeError; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/InitializeResultDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeResultDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/InitializeResultDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeResultDTO.java index 0869e5ffaa02..9dd579ee3794 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/InitializeResultDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeResultDTO.java @@ -10,7 +10,7 @@ * Codenvy, S.A. - initial API and implementation * ***************************************************************************** */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.InitializeResult; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/LanguageDescriptionDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LanguageDescriptionDTO.java similarity index 88% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/LanguageDescriptionDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LanguageDescriptionDTO.java index 0795a3b3e502..7ec434c7862c 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/LanguageDescriptionDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LanguageDescriptionDTO.java @@ -5,10 +5,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.eclipse.che.dto.shared.DTO; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/LocationDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LocationDTO.java similarity index 91% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/LocationDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LocationDTO.java index 1909aadecc2e..5e17997a95f6 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/LocationDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LocationDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.Location; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MarkedStringDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MarkedStringDTO.java similarity index 90% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MarkedStringDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MarkedStringDTO.java index d915662eabbf..47300dfc0ca7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MarkedStringDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MarkedStringDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.MarkedString; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageActionItemDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageActionItemDTO.java similarity index 91% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageActionItemDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageActionItemDTO.java index 315362d33f16..38ea8ee1505f 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageActionItemDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageActionItemDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.MessageActionItem; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageDTO.java similarity index 89% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageDTO.java index 6e6086e4c46b..b63f1fc854e7 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.Message; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageParamsDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageParamsDTO.java index 40766e263533..7436cb14a3cf 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/MessageParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.MessageParams; import io.typefox.lsapi.MessageType; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/NotificationMessageDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/NotificationMessageDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/NotificationMessageDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/NotificationMessageDTO.java index 0a10897cf920..18ea6c57705c 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/NotificationMessageDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/NotificationMessageDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.NotificationMessage; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ParameterInformationDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ParameterInformationDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ParameterInformationDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ParameterInformationDTO.java index dc9b877387ff..7d4ce9d0ed33 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ParameterInformationDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ParameterInformationDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.ParameterInformation; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/PositionDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PositionDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/PositionDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PositionDTO.java index 74be92c16f51..f147a092d2dd 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/PositionDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PositionDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.Position; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java index df78ab499ed6..3b5fd84d9170 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.PublishDiagnosticsParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RangeDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RangeDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RangeDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RangeDTO.java index 9aa74651b734..08513dc468f5 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RangeDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RangeDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.Range; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ReferenceContextDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceContextDTO.java similarity index 91% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ReferenceContextDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceContextDTO.java index c7b202062a06..2e2b0204f31e 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ReferenceContextDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceContextDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.ReferenceContext; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ReferenceParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceParamsDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ReferenceParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceParamsDTO.java index d6177851a988..4e99522a6eaa 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ReferenceParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.ReferenceParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RenameParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RenameParamsDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RenameParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RenameParamsDTO.java index 2c4b83234c10..6dd241663ea1 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RenameParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RenameParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.RenameParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RequestMessageDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RequestMessageDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RequestMessageDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RequestMessageDTO.java index 4430c7c363a1..ef978eeca9ab 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/RequestMessageDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RequestMessageDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.RequestMessage; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ResponseErrorDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseErrorDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ResponseErrorDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseErrorDTO.java index 2899fa61a1ca..20d58f38cbec 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ResponseErrorDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseErrorDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.ResponseError; import io.typefox.lsapi.ResponseErrorCode; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ResponseMessageDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseMessageDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ResponseMessageDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseMessageDTO.java index 915aa287411d..75f4a295330e 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ResponseMessageDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseMessageDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.ResponseMessage; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ServerCapabilitiesDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ServerCapabilitiesDTO.java similarity index 98% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ServerCapabilitiesDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ServerCapabilitiesDTO.java index 0a172143aa7c..80a95e3fbd6c 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ServerCapabilitiesDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ServerCapabilitiesDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.ServerCapabilities; import io.typefox.lsapi.TextDocumentSyncKind; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java index 1bf42759084a..d658bc7934b0 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.MessageType; import io.typefox.lsapi.ShowMessageRequestParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureHelpDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureHelpDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpDTO.java index 9d4073a8bbcc..9b230cc40ce4 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureHelpDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.SignatureHelp; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java index 94ef506cfc1c..28889cb0458c 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.SignatureHelpOptions; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureInformationDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureInformationDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureInformationDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureInformationDTO.java index 8e4bc44a11b3..374f8716a088 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SignatureInformationDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureInformationDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.SignatureInformation; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SymbolInformationDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SymbolInformationDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SymbolInformationDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SymbolInformationDTO.java index 659e0217a3e8..ce89a16da49f 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/SymbolInformationDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SymbolInformationDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.SymbolInformation; import io.typefox.lsapi.SymbolKind; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java index 75181829b05a..371a9c3279cb 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.TextDocumentContentChangeEvent; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java similarity index 91% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java index 6fffcac153e1..656363271228 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.TextDocumentIdentifier; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentItemDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentItemDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentItemDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentItemDTO.java index 6ee2dd9b974f..c83000898980 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentItemDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentItemDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.TextDocumentItem; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java index 704335c803c9..bb36ff1a4aed 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.TextDocumentPositionParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextEditDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextEditDTO.java similarity index 94% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextEditDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextEditDTO.java index a96baf31fa86..6cfe35a24cf4 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/TextEditDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextEditDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.TextEdit; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java index c7261ee4aa61..b22a2517eeb4 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.VersionedTextDocumentIdentifier; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/WorkspaceEditDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceEditDTO.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/WorkspaceEditDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceEditDTO.java index e9f7058b51ed..e614749a48fc 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/WorkspaceEditDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceEditDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.WorkspaceEdit; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java similarity index 91% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java index bff46e3c68ba..68c89c2f2c1b 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java @@ -5,7 +5,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.che.plugin.languageserver.shared.lsapi; +package org.eclipse.che.api.languageserver.shared.lsapi; import io.typefox.lsapi.WorkspaceSymbolParams; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/LanguageDescription.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/LanguageDescription.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/LanguageDescription.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/LanguageDescription.java index 6373d5f7f602..460dc40b3cc9 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/LanguageDescription.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/LanguageDescription.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.shared.model; +package org.eclipse.che.api.languageserver.shared.model; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/impl/InitializeResultImpl.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/InitializeResultImpl.java similarity index 90% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/impl/InitializeResultImpl.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/InitializeResultImpl.java index cee03b0629df..648e23606118 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/impl/InitializeResultImpl.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/InitializeResultImpl.java @@ -8,12 +8,12 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.shared.model.impl; +package org.eclipse.che.api.languageserver.shared.model.impl; import io.typefox.lsapi.InitializeResult; import io.typefox.lsapi.ServerCapabilities; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import java.util.List; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/impl/LanguageDescriptionImpl.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/LanguageDescriptionImpl.java similarity index 95% rename from plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/impl/LanguageDescriptionImpl.java rename to wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/LanguageDescriptionImpl.java index d15e0fd633d1..2c6cf767f233 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-shared/src/main/java/org/eclipse/che/plugin/languageserver/shared/model/impl/LanguageDescriptionImpl.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/LanguageDescriptionImpl.java @@ -8,10 +8,10 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.shared.model.impl; +package org.eclipse.che.api.languageserver.shared.model.impl; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import java.util.List; import java.util.Objects; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/pom.xml b/wsagent/che-core-api-languageserver/pom.xml similarity index 81% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/pom.xml rename to wsagent/che-core-api-languageserver/pom.xml index 7d1a3944115e..56e9752c4e10 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/pom.xml +++ b/wsagent/che-core-api-languageserver/pom.xml @@ -14,16 +14,13 @@ 4.0.0 - che-plugin-languageserver-parent - org.eclipse.che.plugin + che-agent-parent + org.eclipse.che.core 5.0.0-M5-SNAPSHOT - che-plugin-languageserver-server - Che Plugin :: Language Server :: Server - - false - 2.10.0 - + che-core-api-languageserver + jar + Che Core :: API :: Language Server com.google.code.gson @@ -37,14 +34,6 @@ com.google.inject guice - - com.google.inject.extensions - guice-multibindings - - - commons-io - commons-io - io.typefox.lsapi io.typefox.lsapi @@ -77,6 +66,10 @@ org.eclipse.che.core che-core-api-dto + + org.eclipse.che.core + che-core-api-languageserver-shared + org.eclipse.che.core che-core-api-project @@ -89,10 +82,6 @@ org.eclipse.che.core che-core-commons-inject - - org.eclipse.che.plugin - che-plugin-languageserver-shared - org.everrest everrest-websockets @@ -123,9 +112,6 @@ - src/main/java - src/test/java - target/classes src/main/java diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/DtoConverter.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/DtoConverter.java similarity index 89% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/DtoConverter.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/DtoConverter.java index a4cc06d15270..4212ca9cd5ab 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/DtoConverter.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/DtoConverter.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server; +package org.eclipse.che.api.languageserver; import io.typefox.lsapi.CodeLensOptions; import io.typefox.lsapi.CompletionOptions; @@ -17,14 +17,14 @@ import io.typefox.lsapi.ServerCapabilities; import io.typefox.lsapi.SignatureHelpOptions; -import org.eclipse.che.plugin.languageserver.shared.lsapi.CodeLensOptionsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.CompletionOptionsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentOnTypeFormattingOptionsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.InitializeResultDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LanguageDescriptionDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.ServerCapabilitiesDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.SignatureHelpOptionsDTO; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.lsapi.CodeLensOptionsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.CompletionOptionsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentOnTypeFormattingOptionsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.InitializeResultDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.ServerCapabilitiesDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.SignatureHelpOptionsDTO; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import static org.eclipse.che.dto.server.DtoFactory.newDto; diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/LanguageServerModule.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/LanguageServerModule.java new file mode 100644 index 000000000000..2fd68b280d8d --- /dev/null +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/LanguageServerModule.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.api.languageserver; + +import com.google.inject.AbstractModule; + +import org.eclipse.che.api.languageserver.messager.PublishDiagnosticsParamsMessenger; +import org.eclipse.che.api.languageserver.registry.ServerInitializer; +import org.eclipse.che.api.languageserver.service.LanguageRegistryService; +import org.eclipse.che.api.languageserver.service.TextDocumentService; +import org.eclipse.che.inject.DynaModule; +import org.eclipse.che.api.languageserver.messager.InitializeEventMessenger; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistry; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; +import org.eclipse.che.api.languageserver.registry.ServerInitializerImpl; +import org.eclipse.che.api.languageserver.service.WorkspaceService; + +@DynaModule +public class LanguageServerModule extends AbstractModule { + + @Override + protected void configure() { + bind(LanguageServerRegistry.class).to(LanguageServerRegistryImpl.class); + bind(ServerInitializer.class).to(ServerInitializerImpl.class); + + bind(LanguageRegistryService.class); + bind(TextDocumentService.class); + bind(WorkspaceService.class); + bind(PublishDiagnosticsParamsMessenger.class); + bind(InitializeEventMessenger.class); + } +} diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/exception/LanguageServerException.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/exception/LanguageServerException.java similarity index 93% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/exception/LanguageServerException.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/exception/LanguageServerException.java index 0b498d14d3c9..4499b57f2c89 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/exception/LanguageServerException.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/exception/LanguageServerException.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.exception; +package org.eclipse.che.api.languageserver.exception; import org.eclipse.che.api.core.ServerException; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/LanguageServerLauncher.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncher.java similarity index 80% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/LanguageServerLauncher.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncher.java index 1a65f27b961b..5638be959e79 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/LanguageServerLauncher.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncher.java @@ -8,12 +8,12 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.launcher; +package org.eclipse.che.api.languageserver.launcher; import io.typefox.lsapi.services.LanguageServer; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; /** * @author Anatoliy Bazko diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/LanguageServerLauncherTemplate.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncherTemplate.java similarity index 88% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/LanguageServerLauncherTemplate.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncherTemplate.java index e3d2b6effba0..26bebfdb6758 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/launcher/LanguageServerLauncherTemplate.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncherTemplate.java @@ -8,11 +8,11 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.launcher; +package org.eclipse.che.api.languageserver.launcher; import io.typefox.lsapi.services.LanguageServer; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; /** * @author Anatolii Bazko @@ -25,7 +25,6 @@ public final LanguageServer launch(String projectPath) throws LanguageServerExce return connectToLanguageServer(languageServerProcess); } - abstract protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException; abstract protected LanguageServer connectToLanguageServer(Process languageServerProcess) throws LanguageServerException; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/messager/InitializeEventMessenger.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/InitializeEventMessenger.java similarity index 78% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/messager/InitializeEventMessenger.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/InitializeEventMessenger.java index 0f74cc7db5ba..855548e9c98f 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/messager/InitializeEventMessenger.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/InitializeEventMessenger.java @@ -8,18 +8,19 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.messager; +package org.eclipse.che.api.languageserver.messager; import io.typefox.lsapi.ServerCapabilities; import io.typefox.lsapi.services.LanguageServer; import com.google.gson.Gson; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistryImpl; -import org.eclipse.che.plugin.languageserver.server.registry.ServerInitializer; -import org.eclipse.che.plugin.languageserver.server.registry.ServerInitializerObserver; -import org.eclipse.che.plugin.languageserver.shared.event.LanguageServerInitializeEventDto; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.DtoConverter; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; +import org.eclipse.che.api.languageserver.registry.ServerInitializer; +import org.eclipse.che.api.languageserver.registry.ServerInitializerObserver; +import org.eclipse.che.api.languageserver.shared.event.LanguageServerInitializeEventDto; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.everrest.websockets.WSConnectionContext; import org.everrest.websockets.message.ChannelBroadcastMessage; import org.slf4j.Logger; @@ -33,7 +34,6 @@ import java.io.IOException; import static org.eclipse.che.dto.server.DtoFactory.newDto; -import static org.eclipse.che.plugin.languageserver.server.DtoConverter.asDto; /** * @author Anatolii Bazko @@ -56,8 +56,8 @@ public void onServerInitialized(LanguageServer server, String projectPath) { LanguageServerInitializeEventDto initializeEventDto = newDto(LanguageServerInitializeEventDto.class); - initializeEventDto.setSupportedLanguages(asDto(languageDescription)); - initializeEventDto.setServerCapabilities(asDto(serverCapabilities)); + initializeEventDto.setSupportedLanguages(DtoConverter.asDto(languageDescription)); + initializeEventDto.setServerCapabilities(DtoConverter.asDto(serverCapabilities)); initializeEventDto.setProjectPath(projectPath.substring(LanguageServerRegistryImpl.PROJECT_FOLDER_PATH.length())); send(initializeEventDto); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/messager/PublishDiagnosticsParamsMessenger.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/PublishDiagnosticsParamsMessenger.java similarity index 97% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/messager/PublishDiagnosticsParamsMessenger.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/PublishDiagnosticsParamsMessenger.java index 68a7f556d6e5..416491a69e67 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/messager/PublishDiagnosticsParamsMessenger.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/PublishDiagnosticsParamsMessenger.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.messager; +package org.eclipse.che.api.languageserver.messager; import io.typefox.lsapi.PublishDiagnosticsParams; import io.typefox.lsapi.impl.PublishDiagnosticsParamsImpl; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerDescription.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerDescription.java similarity index 86% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerDescription.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerDescription.java index 3f73b80a2c99..a5d0fdd40263 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerDescription.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerDescription.java @@ -8,11 +8,12 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.InitializeResult; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; + /** * Simple container for {@link InitializeResult} and {@link LanguageDescription} @@ -20,7 +21,7 @@ * @author Evgen Vidolob */ public class LanguageServerDescription { - private final InitializeResult initializeResult; + private final InitializeResult initializeResult; private final LanguageDescription languageDescription; public LanguageServerDescription(InitializeResult initializeResult, diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistry.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistry.java similarity index 78% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistry.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistry.java index 64aeba1d43af..183b99c05144 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistry.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistry.java @@ -8,14 +8,14 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.services.LanguageServer; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.shared.ProjectExtensionKey; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.eclipse.che.commons.annotation.Nullable; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.shared.ProjectExtensionKey; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; import java.util.List; import java.util.Map; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistryImpl.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImpl.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistryImpl.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImpl.java index d6b63df73b11..6753de38f423 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistryImpl.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImpl.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.ServerCapabilities; import io.typefox.lsapi.services.LanguageServer; @@ -18,14 +18,14 @@ import com.google.inject.Singleton; import org.eclipse.che.api.core.ServerException; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; +import org.eclipse.che.api.languageserver.shared.ProjectExtensionKey; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.eclipse.che.api.project.server.FolderEntry; import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.VirtualFileEntry; import org.eclipse.che.commons.annotation.Nullable; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.server.launcher.LanguageServerLauncher; -import org.eclipse.che.plugin.languageserver.shared.ProjectExtensionKey; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; import java.net.URI; import java.util.ArrayList; @@ -37,7 +37,7 @@ import java.util.stream.Collectors; import static com.google.common.io.Files.getFileExtension; -import static org.eclipse.che.plugin.languageserver.shared.ProjectExtensionKey.createProjectKey; +import static org.eclipse.che.api.languageserver.shared.ProjectExtensionKey.createProjectKey; @Singleton public class LanguageServerRegistryImpl implements LanguageServerRegistry, ServerInitializerObserver { diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializer.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializer.java similarity index 82% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializer.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializer.java index c02e96f9f3c2..d959a28f58a4 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializer.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializer.java @@ -8,12 +8,12 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.services.LanguageServer; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.server.launcher.LanguageServerLauncher; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; import java.util.Map; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerImpl.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImpl.java similarity index 87% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerImpl.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImpl.java index d44ff80d66de..16c6db44f9fb 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerImpl.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImpl.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.InitializeResult; import io.typefox.lsapi.ServerCapabilities; @@ -19,10 +19,10 @@ import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.server.launcher.LanguageServerLauncher; -import org.eclipse.che.plugin.languageserver.server.messager.PublishDiagnosticsParamsMessenger; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; +import org.eclipse.che.api.languageserver.messager.PublishDiagnosticsParamsMessenger; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,19 +92,11 @@ public LanguageServer initialize(LanguageServerLauncher launcher, String project synchronized (launcher) { LanguageServer server = languageIdToServers.get(languageId); if (server != null) { -// LanguageServerDescription initializeResult = serversToInitResult.get(server); -// if (!initializeResult.getCapabilities().isMultiplyProjectsProvider()) { server = doInitialize(launcher, projectPath); -// } } else { server = doInitialize(launcher, projectPath); languageIdToServers.put(languageId, server); } -// InitializeResult initializeResult = serversToInitResult.get(server); -// if (initializeResult instanceof InitializeResultImpl) { -// ((InitializeResultImpl)initializeResult) -// .setSupportedLanguages(Collections.singletonList((LanguageDescriptionImpl)launcher.getLanguageDescription())); -// } onServerInitialized(server, serversToInitResult.get(server).getInitializeResult().getCapabilities(), launcher.getLanguageDescription(), projectPath); return server; } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerObservable.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObservable.java similarity index 92% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerObservable.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObservable.java index 28ea78d7eac4..448c3848e928 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerObservable.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObservable.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; /** * @author Anatoliy Bazko diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerObserver.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObserver.java similarity index 89% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerObserver.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObserver.java index 5e610c37e0a1..728e05e4921d 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerObserver.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObserver.java @@ -8,12 +8,12 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.ServerCapabilities; import io.typefox.lsapi.services.LanguageServer; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; /** * @author Anatoliy Bazko diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/LanguageRegistryService.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/LanguageRegistryService.java similarity index 76% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/LanguageRegistryService.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/LanguageRegistryService.java index bf0d44cba030..8e462436f1fe 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/LanguageRegistryService.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/LanguageRegistryService.java @@ -8,19 +8,19 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.service; +package org.eclipse.che.api.languageserver.service; import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.plugin.languageserver.server.DtoConverter; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerDescription; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistry; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistryImpl; -import org.eclipse.che.plugin.languageserver.shared.ProjectExtensionKey; -import org.eclipse.che.plugin.languageserver.shared.lsapi.InitializeResultDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.LanguageDescriptionDTO; +import org.eclipse.che.api.languageserver.DtoConverter; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.registry.LanguageServerDescription; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistry; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; +import org.eclipse.che.api.languageserver.shared.ProjectExtensionKey; +import org.eclipse.che.api.languageserver.shared.lsapi.InitializeResultDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -32,8 +32,8 @@ import java.util.List; import static java.util.stream.Collectors.toList; +import static org.eclipse.che.api.languageserver.DtoConverter.asDto; import static org.eclipse.che.dto.server.DtoFactory.newDto; -import static org.eclipse.che.plugin.languageserver.server.DtoConverter.asDto; @Singleton @Path("languageserver") diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/TextDocumentService.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/TextDocumentService.java similarity index 90% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/TextDocumentService.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/TextDocumentService.java index 3b4993c904b5..0e514259369b 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/TextDocumentService.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/TextDocumentService.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.service; +package org.eclipse.che.api.languageserver.service; import io.typefox.lsapi.CompletionItem; import io.typefox.lsapi.Hover; @@ -22,20 +22,20 @@ import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistry; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistryImpl; -import org.eclipse.che.plugin.languageserver.shared.lsapi.CompletionItemDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidChangeTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidCloseTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidOpenTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DidSaveTextDocumentParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentFormattingParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentOnTypeFormattingParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentRangeFormattingParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.DocumentSymbolParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.ReferenceParamsDTO; -import org.eclipse.che.plugin.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistry; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; +import org.eclipse.che.api.languageserver.shared.lsapi.CompletionItemDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DidChangeTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DidCloseTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DidOpenTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DidSaveTextDocumentParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentFormattingParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentOnTypeFormattingParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentRangeFormattingParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.DocumentSymbolParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.ReferenceParamsDTO; +import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import javax.ws.rs.Consumes; import javax.ws.rs.POST; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/WorkspaceService.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/WorkspaceService.java similarity index 87% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/WorkspaceService.java rename to wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/WorkspaceService.java index 66ccdfc5e9b4..b77e33c90a20 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/main/java/org/eclipse/che/plugin/languageserver/server/service/WorkspaceService.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/WorkspaceService.java @@ -8,20 +8,20 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.service; +package org.eclipse.che.api.languageserver.service; import io.typefox.lsapi.Location; -import io.typefox.lsapi.impl.LocationImpl; import io.typefox.lsapi.SymbolInformation; +import io.typefox.lsapi.impl.LocationImpl; import io.typefox.lsapi.services.LanguageServer; import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.plugin.languageserver.server.exception.LanguageServerException; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistry; -import org.eclipse.che.plugin.languageserver.server.registry.LanguageServerRegistryImpl; -import org.eclipse.che.plugin.languageserver.shared.lsapi.WorkspaceSymbolParamsDTO; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistry; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; +import org.eclipse.che.api.languageserver.shared.lsapi.WorkspaceSymbolParamsDTO; import javax.ws.rs.Consumes; import javax.ws.rs.POST; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistryImplTest.java b/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImplTest.java similarity index 85% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistryImplTest.java rename to wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImplTest.java index 4bc5036522d2..6a9db491ded3 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/java/org/eclipse/che/plugin/languageserver/server/registry/LanguageServerRegistryImplTest.java +++ b/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImplTest.java @@ -8,7 +8,7 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.InitializeParams; import io.typefox.lsapi.InitializeResult; @@ -17,9 +17,8 @@ import io.typefox.lsapi.services.TextDocumentService; import io.typefox.lsapi.services.WindowService; -import org.eclipse.che.plugin.languageserver.server.launcher.JsonLanguageServerLauncher; -import org.eclipse.che.plugin.languageserver.server.launcher.LanguageServerLauncher; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.mockito.Mock; import org.mockito.testng.MockitoTestNGListener; import org.testng.annotations.BeforeMethod; @@ -29,7 +28,6 @@ import java.util.Collections; import java.util.concurrent.CompletableFuture; -import static java.util.Arrays.asList; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; @@ -48,7 +46,7 @@ public class LanguageServerRegistryImplTest { private static final String PREFIX = "file://"; - private static final String FILE_PATH = "/projects/1/test.json"; + private static final String FILE_PATH = "/projects/1/test.txt"; private static final String PROJECT_PATH = "/1"; @Mock @@ -72,13 +70,12 @@ public class LanguageServerRegistryImplTest { public void setUp() throws Exception { when(completableFuture.get()).thenReturn(initializeResult); when(initializeResult.getCapabilities()).thenReturn(serverCapabilities); -// when(serverCapabilities.isMultiplyProjectsProvider()).thenReturn(true); when(languageServerLauncher.getLanguageDescription()).thenReturn(languageDescription); when(languageServerLauncher.isAbleToLaunch()).thenReturn(true); - when(languageDescription.getLanguageId()).thenReturn(JsonLanguageServerLauncher.LANGUAGE_ID); - when(languageDescription.getFileExtensions()).thenReturn(asList(JsonLanguageServerLauncher.EXTENSIONS)); - when(languageDescription.getMimeTypes()).thenReturn(asList(JsonLanguageServerLauncher.MIME_TYPES)); + when(languageDescription.getLanguageId()).thenReturn("id"); + when(languageDescription.getFileExtensions()).thenReturn(Collections.singletonList("txt")); + when(languageDescription.getMimeTypes()).thenReturn(Collections.singletonList("plain/text")); when(languageServer.getTextDocumentService()).thenReturn(mock(TextDocumentService.class)); when(languageServer.getWindowService()).thenReturn(mock(WindowService.class)); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerImplTest.java b/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImplTest.java similarity index 90% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerImplTest.java rename to wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImplTest.java index 4e354c1d06fc..17791051cd28 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/java/org/eclipse/che/plugin/languageserver/server/registry/ServerInitializerImplTest.java +++ b/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImplTest.java @@ -8,16 +8,16 @@ * Contributors: * Codenvy, S.A. - initial API and implementation *******************************************************************************/ -package org.eclipse.che.plugin.languageserver.server.registry; +package org.eclipse.che.api.languageserver.registry; import io.typefox.lsapi.InitializeParams; import io.typefox.lsapi.InitializeResult; import io.typefox.lsapi.ServerCapabilities; import io.typefox.lsapi.services.LanguageServer; -import org.eclipse.che.plugin.languageserver.server.launcher.LanguageServerLauncher; -import org.eclipse.che.plugin.languageserver.server.messager.PublishDiagnosticsParamsMessenger; -import org.eclipse.che.plugin.languageserver.shared.model.LanguageDescription; +import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; +import org.eclipse.che.api.languageserver.messager.PublishDiagnosticsParamsMessenger; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.mockito.Mock; import org.mockito.testng.MockitoTestNGListener; import org.testng.annotations.BeforeMethod; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/resources/logback-test.xml b/wsagent/che-core-api-languageserver/src/test/resources/logback-test.xml similarity index 100% rename from plugins/plugin-languageserver/che-plugin-languageserver-server/src/test/resources/logback-test.xml rename to wsagent/che-core-api-languageserver/src/test/resources/logback-test.xml diff --git a/wsagent/che-core-api-project/pom.xml b/wsagent/che-core-api-project/pom.xml index ee871b2b8b32..d8b679e460f5 100644 --- a/wsagent/che-core-api-project/pom.xml +++ b/wsagent/che-core-api-project/pom.xml @@ -115,6 +115,10 @@ org.eclipse.che.core che-core-commons-lang + + org.eclipse.che.core + che-core-commons-schedule + org.eclipse.che.core wsagent-local diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectApiModule.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectApiModule.java index 1fe764f4f91a..0219c47e2e6d 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectApiModule.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/project/server/ProjectApiModule.java @@ -41,8 +41,11 @@ import org.eclipse.che.api.vfs.search.SearcherProvider; import org.eclipse.che.api.vfs.search.impl.FSLuceneSearcherProvider; +import java.nio.file.Path; import java.nio.file.PathMatcher; +import static com.google.inject.multibindings.Multibinder.newSetBinder; + /** * Guice module contains configuration of Project API components. * @@ -54,12 +57,12 @@ public class ProjectApiModule extends AbstractModule { @Override protected void configure() { - Multibinder projectImportersMultibinder = Multibinder.newSetBinder(binder(), ProjectImporter.class); + Multibinder projectImportersMultibinder = newSetBinder(binder(), ProjectImporter.class); projectImportersMultibinder.addBinding().to(ZipProjectImporter.class); - Multibinder.newSetBinder(binder(), ProjectTypeDef.class).addBinding().to(BaseProjectType.class); + newSetBinder(binder(), ProjectTypeDef.class).addBinding().to(BaseProjectType.class); - Multibinder projectHandlersMultibinder = Multibinder.newSetBinder(binder(), ProjectHandler.class); + Multibinder projectHandlersMultibinder = newSetBinder(binder(), ProjectHandler.class); projectHandlersMultibinder.addBinding().to(CreateBaseProjectTypeHandler.class); projectHandlersMultibinder.addBinding().to(InitBaseProjectTypeHandler.class); @@ -71,30 +74,46 @@ protected void configure() { bind(WorkspaceProjectsSyncer.class).to(WorkspaceHolder.class); // configure VFS - Multibinder filtersMultibinder = Multibinder.newSetBinder(binder(), - VirtualFileFilter.class, - Names.named("vfs.index_filter")); + Multibinder filtersMultibinder = + newSetBinder(binder(), VirtualFileFilter.class, Names.named("vfs.index_filter")); + filtersMultibinder.addBinding().to(MediaTypeFilter.class); - Multibinder pathMatcherMultibinder = Multibinder.newSetBinder(binder(), - PathMatcher.class, - Names.named("vfs.index_filter_matcher")); + Multibinder excludeMatcher = newSetBinder(binder(), PathMatcher.class, Names.named("vfs.index_filter_matcher")); bind(SearcherProvider.class).to(FSLuceneSearcherProvider.class); bind(VirtualFileSystemProvider.class).to(LocalVirtualFileSystemProvider.class); bind(FileWatcherNotificationHandler.class).to(DefaultFileWatcherNotificationHandler.class); + configureVfsFilters(excludeMatcher); configureVfsEvent(); } + private void configureVfsFilters(Multibinder excludeMatcher) { + addVfsFilter(excludeMatcher, ".che"); + addVfsFilter(excludeMatcher, ".codenvy"); + addVfsFilter(excludeMatcher, ".#"); + } + + private void addVfsFilter(Multibinder excludeMatcher, String filter) { + excludeMatcher.addBinding().toInstance(path -> { + for (Path pathElement : path) { + if (pathElement == null || filter.equals(pathElement.toString())) { + return true; + } + } + return false; + }); + } + private void configureVfsEvent() { bind(LoEventListener.class); bind(LoEventService.class); bind(HiEventService.class); Multibinder> highLevelVfsEventDetectorMultibinder = - Multibinder.newSetBinder(binder(), new TypeLiteral>() { + newSetBinder(binder(), new TypeLiteral>() { }); highLevelVfsEventDetectorMultibinder.addBinding().to(FileStatusDetector.class); diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/FileTreeWatcher.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/FileTreeWatcher.java index 06793f4d271f..9f7e99583317 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/FileTreeWatcher.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/FileTreeWatcher.java @@ -278,6 +278,9 @@ private void processPendingEvents(Collection pendingEvents) throws for (PendingEvent pendingEvent : pendingEvents) { Path eventDirectoryPath = pendingEvent.getPath(); WatchedDirectory watchedDirectory = watchedDirectories.get(eventDirectoryPath); + if (watchedDirectory == null){ + continue; + } if (Files.exists(eventDirectoryPath)) { boolean isModifiedNotYetReported = true; diff --git a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/event/detectors/ProjectTreeChangesDetector.java b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/event/detectors/ProjectTreeChangesDetector.java index f4599a77e007..50eda5474ad2 100644 --- a/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/event/detectors/ProjectTreeChangesDetector.java +++ b/wsagent/che-core-api-project/src/main/java/org/eclipse/che/api/vfs/impl/file/event/detectors/ProjectTreeChangesDetector.java @@ -19,6 +19,7 @@ import org.eclipse.che.api.vfs.impl.file.event.EventTreeNode; import org.eclipse.che.api.vfs.impl.file.event.HiEvent; import org.eclipse.che.api.vfs.impl.file.event.HiEventDetector; +import org.eclipse.che.commons.schedule.executor.ThreadPullLauncher; import org.slf4j.Logger; import javax.annotation.PostConstruct; @@ -28,7 +29,9 @@ import java.util.Optional; import java.util.Set; -import static java.util.stream.Collectors.toSet; +import static java.lang.Math.min; +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static java.util.concurrent.TimeUnit.SECONDS; import static org.eclipse.che.dto.server.DtoFactory.newDto; import static org.slf4j.LoggerFactory.getLogger; @@ -41,17 +44,34 @@ public class ProjectTreeChangesDetector implements HiEventDetector trees = new HashSet<>(); private State state; @Inject - public ProjectTreeChangesDetector(JsonRpcRequestTransmitter transmitter) { + public ProjectTreeChangesDetector(JsonRpcRequestTransmitter transmitter, ThreadPullLauncher launcher) { this.transmitter = transmitter; + this.launcher = launcher; + } + + public static String findLongestPrefix(String s1, String s2) { + if (s1 == null) { + return s2; + } + + for (int i = min(s1.length(), s2.length()); ; i--) { + if (s2.startsWith(s1.substring(0, i))) { + return s1.substring(0, i); + } + } } @PostConstruct public void postConstruct() { this.state = State.RESUMED; + launcher.scheduleWithFixedDelay(this::transmit, 20_000L, 1_500L, MILLISECONDS); } public void suspend() { @@ -73,33 +93,30 @@ public void resume() { @Override public Optional> detect(EventTreeNode eventTreeNode) { - if (!eventTreeNode.isRoot() || eventTreeNode.getChildren().isEmpty()) { - return Optional.empty(); + if (eventTreeNode.isRoot() && !eventTreeNode.getChildren().isEmpty()) { + trees.add(eventTreeNode); } - if (state == State.RESUMED) { - final Set directories = new HashSet<>(); - - for (EventTreeNode candidateDir : eventTreeNode.stream() - .filter(EventTreeNode::modificationOccurred) - .filter(EventTreeNode::isDir) - .collect(toSet())) { - directories.removeIf(dir -> dir.getPath().contains(candidateDir.getPath())); - - if (directories.stream().noneMatch(dir -> candidateDir.getPath().contains(dir.getPath()))) { - directories.add(candidateDir); - } - } + return Optional.empty(); + } - for (EventTreeNode node : directories) { - final String path = node.getPath(); - final FileWatcherEventType lastEventType = node.getLastEventType(); + private void transmit() { + if (state == State.SUSPENDED) { + return; + } - transmit(path, lastEventType); - } + final Optional commonSubstring = trees.stream() + .flatMap(EventTreeNode::stream) + .filter(EventTreeNode::modificationOccurred) + .map(EventTreeNode::getPath) + .reduce(ProjectTreeChangesDetector::findLongestPrefix); + if (commonSubstring.isPresent()) { + final String s = commonSubstring.get(); + final String path = s.substring(0, s.lastIndexOf('/')); + transmit(path, FileWatcherEventType.MODIFIED); } - return Optional.empty(); + trees.clear(); } private void transmit(String path, FileWatcherEventType type) { diff --git a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/WsAgentTestBase.java b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/WsAgentTestBase.java index 3b42ff414872..34bc7bfc7c56 100644 --- a/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/WsAgentTestBase.java +++ b/wsagent/che-core-api-project/src/test/java/org/eclipse/che/api/project/server/WsAgentTestBase.java @@ -44,6 +44,8 @@ import java.util.Map; import java.util.Set; +import static org.mockito.Mockito.mock; + /** * @author gazarenkov */ @@ -120,11 +122,10 @@ public void setUp() throws Exception { TestWorkspaceHolder wsHolder = new TestWorkspaceHolder(); - projectTreeChangesDetector = new ProjectTreeChangesDetector(null); pm = new ProjectManager(vfsProvider, eventService, projectTypeRegistry, projectRegistry, projectHandlerRegistry, importerRegistry, fileWatcherNotificationHandler, fileTreeWatcher, wsHolder, - projectTreeChangesDetector); + mock(ProjectTreeChangesDetector.class)); pm.initWatcher(); } diff --git a/wsagent/pom.xml b/wsagent/pom.xml index 96e200d64239..0d984ea45db3 100644 --- a/wsagent/pom.xml +++ b/wsagent/pom.xml @@ -32,6 +32,8 @@ che-core-git-impl-jgit che-core-api-debug che-core-api-debug-shared + che-core-api-languageserver + che-core-api-languageserver-shared wsagent-local diff --git a/wsmaster/che-core-api-factory/pom.xml b/wsmaster/che-core-api-factory/pom.xml index 83655cd1d6e2..25049a95dae1 100644 --- a/wsmaster/che-core-api-factory/pom.xml +++ b/wsmaster/che-core-api-factory/pom.xml @@ -69,14 +69,6 @@ org.eclipse.che.core che-core-api-factory-shared - - org.eclipse.che.core - che-core-api-machine - - - org.eclipse.che.core - che-core-api-machine-shared - org.eclipse.che.core che-core-api-model @@ -125,6 +117,16 @@ che-core-api-jdbc provided + + org.eclipse.che.core + che-core-api-machine + provided + + + org.eclipse.che.core + che-core-api-machine-shared + provided + org.eclipse.persistence javax.persistence diff --git a/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/jpa/JpaFactoryDao.java b/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/jpa/JpaFactoryDao.java index d3629ecb115d..8a31e78ced9f 100644 --- a/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/jpa/JpaFactoryDao.java +++ b/wsmaster/che-core-api-factory/src/main/java/org/eclipse/che/api/factory/server/jpa/JpaFactoryDao.java @@ -22,6 +22,7 @@ import org.eclipse.che.api.factory.server.model.impl.FactoryImpl; import org.eclipse.che.api.factory.server.spi.FactoryDao; import org.eclipse.che.api.user.server.event.BeforeUserRemovedEvent; +import org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl; import org.eclipse.che.commons.lang.NameGenerator; import org.eclipse.che.commons.lang.Pair; import org.slf4j.Logger; @@ -141,6 +142,9 @@ public List getByAttribute(int maxItems, @Transactional protected void doCreate(FactoryImpl factory) { final EntityManager manager = managerProvider.get(); + if (factory.getWorkspace() != null) { + factory.getWorkspace().getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + } manager.persist(factory); } @@ -150,6 +154,9 @@ protected FactoryImpl doUpdate(FactoryImpl update) throws NotFoundException { if (manager.find(FactoryImpl.class, update.getId()) == null) { throw new NotFoundException(format("Could not update factory with id %s because it doesn't exist", update.getId())); } + if (update.getWorkspace() != null) { + update.getWorkspace().getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + } return manager.merge(update); } diff --git a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/spi/tck/FactoryDaoTest.java b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/spi/tck/FactoryDaoTest.java index daaeb2942532..d02ecc0b04b0 100644 --- a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/spi/tck/FactoryDaoTest.java +++ b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/spi/tck/FactoryDaoTest.java @@ -257,17 +257,18 @@ private static FactoryImpl createFactory(int index, String userId) { final List a3 = new ArrayList<>(singletonList(new ActionImpl("id" + index, ImmutableMap.of("key3", "value3")))); final OnAppClosedImpl onAppClosed = new OnAppClosedImpl(a3); final IdeImpl ide = new IdeImpl(onAppLoaded, onProjectsLoaded, onAppClosed); - return FactoryImpl.builder() - .generateId() - .setVersion("4_0") - .setName("factoryName" + index) - .setWorkspace(createWorkspaceConfig(index)) - .setButton(factoryButton) - .setCreator(creator) - .setPolicies(policies) - .setImages(images) - .setIde(ide) - .build(); + final FactoryImpl factory = FactoryImpl.builder() + .generateId() + .setVersion("4_0") + .setName("factoryName" + index) + .setButton(factoryButton) + .setCreator(creator) + .setPolicies(policies) + .setImages(images) + .setIde(ide) + .build(); + factory.setWorkspace(createWorkspaceConfig(index)); + return factory; } public static WorkspaceConfigImpl createWorkspaceConfig(int index) { @@ -363,6 +364,9 @@ public static WorkspaceConfigImpl createWorkspaceConfig(int index) { wCfg.setCommands(commands); wCfg.setProjects(projects); wCfg.setEnvironments(environments); + + wCfg.getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + return wCfg; } } diff --git a/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/event/RecipePersistedEvent.java b/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/event/RecipePersistedEvent.java new file mode 100644 index 000000000000..1a7f8b7ae05d --- /dev/null +++ b/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/event/RecipePersistedEvent.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.api.machine.server.event; + +import org.eclipse.che.api.core.notification.EventOrigin; +import org.eclipse.che.api.machine.shared.ManagedRecipe; + +/** + * Published after recipe instance is persisted. + * + * @author Anton Korneta. + */ +@EventOrigin("recipe") +public class RecipePersistedEvent { + private final ManagedRecipe recipe; + + public RecipePersistedEvent(ManagedRecipe recipe) { + this.recipe = recipe; + } + + public ManagedRecipe getRecipe() { + return recipe; + } +} diff --git a/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/jpa/JpaRecipeDao.java b/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/jpa/JpaRecipeDao.java index afb551409ab9..7b93f1e43d3f 100644 --- a/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/jpa/JpaRecipeDao.java +++ b/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/jpa/JpaRecipeDao.java @@ -17,6 +17,8 @@ import org.eclipse.che.api.core.ServerException; import org.eclipse.che.api.core.jdbc.jpa.DuplicateKeyException; import org.eclipse.che.api.core.jdbc.jpa.IntegrityConstraintViolationException; +import org.eclipse.che.api.core.notification.EventService; +import org.eclipse.che.api.machine.server.event.RecipePersistedEvent; import org.eclipse.che.api.machine.server.recipe.RecipeImpl; import org.eclipse.che.api.machine.server.spi.RecipeDao; @@ -47,11 +49,15 @@ public class JpaRecipeDao implements RecipeDao { @Inject private Provider managerProvider; + @Inject + private EventService eventService; + @Override public void create(RecipeImpl recipe) throws ConflictException, ServerException { requireNonNull(recipe); try { doCreateRecipe(recipe); + eventService.publish(new RecipePersistedEvent(recipe)); } catch (DuplicateKeyException ex) { throw new ConflictException(format("Recipe with id %s already exists", recipe.getId())); } catch (IntegrityConstraintViolationException ex) { diff --git a/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/model/impl/CommandImpl.java b/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/model/impl/CommandImpl.java index 0216e3d780bd..af74959ae80d 100644 --- a/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/model/impl/CommandImpl.java +++ b/wsmaster/che-core-api-machine/src/main/java/org/eclipse/che/api/machine/server/model/impl/CommandImpl.java @@ -15,6 +15,7 @@ import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.MapKeyColumn; @@ -43,7 +44,7 @@ public class CommandImpl implements Command { @Column(nullable = false) private String type; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) @MapKeyColumn(name = "name") @Column(name = "value", columnDefinition = "TEXT") private Map attributes; diff --git a/wsmaster/che-core-api-ssh/pom.xml b/wsmaster/che-core-api-ssh/pom.xml index 1af872b68853..ec3581a33602 100644 --- a/wsmaster/che-core-api-ssh/pom.xml +++ b/wsmaster/che-core-api-ssh/pom.xml @@ -90,10 +90,6 @@ org.eclipse.che.core che-core-commons-annotations - - org.eclipse.che.core - che-core-commons-lang - org.eclipse.che.core che-core-commons-test @@ -126,6 +122,11 @@ che-core-api-jdbc-vendor-h2 test + + org.eclipse.che.core + che-core-commons-lang + test + org.eclipse.persistence eclipselink diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceManager.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceManager.java index 60436a36125a..ce803667d866 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceManager.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceManager.java @@ -404,8 +404,10 @@ public WorkspaceImpl startWorkspace(WorkspaceConfig config, /** * Starts machine in running workspace * - * @param machineConfig configuration of machine to start - * @param workspaceId id of workspace in which machine should be started + * @param machineConfig + * configuration of machine to start + * @param workspaceId + * id of workspace in which machine should be started * @throws NotFoundException * if machine type from recipe is unsupported * @throws NotFoundException @@ -516,7 +518,8 @@ public List getSnapshot(String workspaceId) throws ServerException * Removes all snapshots of workspace machines. * Continues to remove snapshots even when removal of some of them fails. * - * @param workspaceId workspace id to remove machine snapshots + * @param workspaceId + * workspace id to remove machine snapshots * @throws NotFoundException * when workspace with given id doesn't exists * @throws ServerException @@ -737,8 +740,18 @@ private String replaceSnapshot(MachineImpl machine, String namespace) { snapshot = runtimes.saveMachine(namespace, machine.getWorkspaceId(), machine.getId()); - - snapshotDao.saveSnapshot(snapshot); + // check if the workspace exists before creating a snapshot, + // if it is not an integrity constraint violation exception will occur, + // this may happen when workspace stop called simultaneously. + // The issue https://github.com/eclipse/che/issues/2683 should fix it + // in a way that it won't be possible to snapshot workspace simultaneously. + if (exists(machine.getWorkspaceId())) { + snapshotDao.saveSnapshot(snapshot); + } else { + LOG.warn("Snapshot for a workspace '{}' won't be saved, as the workspace doesn't exist anymore", + machine.getWorkspaceId()); + runtimes.removeSnapshot(snapshot); + } } catch (ApiException e) { if (snapshot != null) { try { @@ -839,4 +852,14 @@ private WorkspaceImpl getByKey(String key) throws NotFoundException, ServerExcep final String namespace = nsPart.isEmpty() ? sessionUser().getUserName() : nsPart; return workspaceDao.get(wsName, namespace); } + + /** Returns true if workspace exists and false otherwise. */ + private boolean exists(String workspaceId) throws ServerException { + try { + workspaceDao.get(workspaceId); + } catch (NotFoundException x) { + return false; + } + return true; + } } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaStackDao.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaStackDao.java index bb9aa1217f4d..18180bedf7dd 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaStackDao.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaStackDao.java @@ -18,6 +18,7 @@ import org.eclipse.che.api.core.jdbc.jpa.DuplicateKeyException; import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.workspace.server.event.StackPersistedEvent; +import org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; import org.eclipse.che.api.workspace.server.spi.StackDao; import org.eclipse.che.commons.annotation.Nullable; @@ -123,6 +124,9 @@ public List searchStacks(@Nullable String user, @Transactional protected void doCreate(StackImpl stack) { + if (stack.getWorkspaceConfig() != null) { + stack.getWorkspaceConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + } managerProvider.get().persist(stack); } @@ -141,6 +145,9 @@ protected StackImpl doUpdate(StackImpl update) throws NotFoundException { if (manager.find(StackImpl.class, update.getId()) == null) { throw new NotFoundException(format("Workspace with id '%s' doesn't exist", update.getId())); } + if (update.getWorkspaceConfig() != null) { + update.getWorkspaceConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + } return manager.merge(update); } } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDao.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDao.java index d71710078f71..59bfe6bcadfb 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDao.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDao.java @@ -22,6 +22,7 @@ import org.eclipse.che.api.machine.server.model.impl.SnapshotImpl; import org.eclipse.che.api.machine.server.spi.SnapshotDao; import org.eclipse.che.api.workspace.server.event.BeforeWorkspaceRemovedEvent; +import org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl; import org.eclipse.che.api.workspace.server.spi.WorkspaceDao; import org.slf4j.Logger; @@ -154,6 +155,9 @@ public List getWorkspaces(String userId) throws ServerException { @Transactional protected void doCreate(WorkspaceImpl workspace) { + if (workspace.getConfig() != null) { + workspace.getConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + } manager.get().persist(workspace); } @@ -170,6 +174,9 @@ protected WorkspaceImpl doUpdate(WorkspaceImpl update) throws NotFoundException if (manager.get().find(WorkspaceImpl.class, update.getId()) == null) { throw new NotFoundException(format("Workspace with id '%s' doesn't exist", update.getId())); } + if (update.getConfig() != null) { + update.getConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + } return manager.get().merge(update); } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/EnvironmentImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/EnvironmentImpl.java index 31e46ae8e4d9..ecdecf2a8cb7 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/EnvironmentImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/EnvironmentImpl.java @@ -17,6 +17,7 @@ import javax.persistence.CascadeType; import javax.persistence.Embedded; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; @@ -40,7 +41,7 @@ public class EnvironmentImpl implements Environment { @Embedded private EnvironmentRecipeImpl recipe; - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn private Map machines; diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ExtendedMachineImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ExtendedMachineImpl.java index 926157890a43..c79ad3abff37 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ExtendedMachineImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ExtendedMachineImpl.java @@ -16,6 +16,7 @@ import javax.persistence.CascadeType; import javax.persistence.ElementCollection; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; @@ -37,13 +38,13 @@ public class ExtendedMachineImpl implements ExtendedMachine { @GeneratedValue private Long id; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) private List agents; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) private Map attributes; - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn private Map servers; diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ProjectConfigImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ProjectConfigImpl.java index a74cc8fde892..f83d69b7fc96 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ProjectConfigImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ProjectConfigImpl.java @@ -11,14 +11,15 @@ package org.eclipse.che.api.workspace.server.model.impl; -import org.eclipse.che.api.core.model.project.SourceStorage; import org.eclipse.che.api.core.model.project.ProjectConfig; +import org.eclipse.che.api.core.model.project.SourceStorage; import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; @@ -26,7 +27,9 @@ import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.PostLoad; +import javax.persistence.PrePersist; import javax.persistence.PreUpdate; +import javax.persistence.Transient; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -63,18 +66,17 @@ public class ProjectConfigImpl implements ProjectConfig { @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) private SourceStorageImpl source; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) private List mixins; - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn @MapKey(name = "name") private Map dbAttributes; - // TODO consider using List or Map on model level instead // Mapping delegated to 'dbAttributes' field // as it is impossible to map nested list directly - @Column(insertable = false, updatable = false) + @Transient private Map> attributes; public ProjectConfigImpl() {} @@ -206,15 +208,32 @@ public String toString() { '}'; } - @PreUpdate - public void syncDbAttributes() { - dbAttributes = getAttributes().entrySet() - .stream() - .collect(toMap(Map.Entry::getKey, e -> new Attribute(e.getKey(), e.getValue()))); + /** + * Synchronizes instance attribute with db attributes, + * should be called by internal components in needed places, + * this can't be done neither by {@link PrePersist} nor by {@link PreUpdate} + * as when the entity is merged the transient attribute won't be passed + * to event handlers. + */ + public void prePersistAttributes() { + if (dbAttributes == null) { + dbAttributes = new HashMap<>(); + } + final Map dbAttrsCopy = new HashMap<>(dbAttributes); + dbAttributes.clear(); + for (Map.Entry> entry : getAttributes().entrySet()) { + Attribute attribute = dbAttrsCopy.get(entry.getKey()); + if (attribute == null) { + attribute = new Attribute(entry.getKey(), entry.getValue()); + } else if (!Objects.equals(attribute.values, entry.getValue())) { + attribute.values = entry.getValue(); + } + dbAttributes.put(entry.getKey(), attribute); + } } @PostLoad - private void initEntityAttributes() { + private void postLoadAttributes() { attributes = dbAttributes.values() .stream() .collect(toMap(attr -> attr.name, attr -> attr.values)); @@ -230,7 +249,7 @@ private static class Attribute { @Basic private String name; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) private List values; public Attribute() {} diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ServerConf2Impl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ServerConf2Impl.java index 45a32df5b67b..387b35e2a601 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ServerConf2Impl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/ServerConf2Impl.java @@ -15,6 +15,7 @@ import javax.persistence.Basic; import javax.persistence.ElementCollection; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import java.util.HashMap; @@ -37,7 +38,7 @@ public class ServerConf2Impl implements ServerConf2 { @Basic private String protocol; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) private Map properties; public ServerConf2Impl() {} diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/SourceStorageImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/SourceStorageImpl.java index dbe5d0ffd582..989cb73877f1 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/SourceStorageImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/SourceStorageImpl.java @@ -16,6 +16,7 @@ import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import java.util.HashMap; @@ -40,7 +41,7 @@ public class SourceStorageImpl implements SourceStorage { @Column(columnDefinition = "TEXT") private String location; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) private Map parameters; public SourceStorageImpl() {} diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceConfigImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceConfigImpl.java index ef8bd2c7faa0..fd2e2a08dfb1 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceConfigImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceConfigImpl.java @@ -20,6 +20,7 @@ import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; @@ -62,15 +63,15 @@ public static WorkspaceConfigImplBuilder builder() { @Column(nullable = false) private String defaultEnv; - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn private List commands; - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn private List projects; - @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @JoinColumn private Map environments; @@ -213,12 +214,6 @@ public String toString() { '}'; } - @PreUpdate - @PrePersist - public void syncProjects() { - getProjects().forEach(ProjectConfigImpl::syncDbAttributes); - } - /** * Helps to build complex {@link WorkspaceConfigImpl users workspace instance}. * diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceImpl.java index e95050bfc396..e340c8487c03 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/WorkspaceImpl.java @@ -84,7 +84,7 @@ public static WorkspaceImplBuilder builder() { @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) private WorkspaceConfigImpl config; - @ElementCollection + @ElementCollection(fetch = FetchType.EAGER) private Map attributes; @Basic diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java index c8f211e1f760..86201d90e450 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/jpa/JpaWorkspaceDaoTest.java @@ -11,10 +11,10 @@ package org.eclipse.che.api.workspace.server.jpa; import com.google.inject.Guice; +import com.google.inject.Injector; import org.eclipse.che.account.spi.AccountImpl; import org.eclipse.che.api.core.jdbc.jpa.DuplicateKeyException; -import org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl; import org.testng.annotations.AfterMethod; @@ -23,10 +23,10 @@ import javax.persistence.EntityManager; -import java.util.Collections; -import java.util.HashMap; +import java.util.ArrayList; +import java.util.List; -import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; import static org.eclipse.che.api.workspace.server.spi.tck.WorkspaceDaoTest.createWorkspace; import static org.testng.Assert.assertEquals; @@ -37,18 +37,25 @@ */ public class JpaWorkspaceDaoTest { - private EntityManager manager; + private EntityManager manager; + private JpaWorkspaceDao workspaceDao; @BeforeMethod private void setUpManager() { - manager = Guice.createInjector(new WorkspaceTckModule()).getInstance(EntityManager.class); + final Injector injector = Guice.createInjector(new WorkspaceTckModule()); + manager = injector.getInstance(EntityManager.class); + workspaceDao = injector.getInstance(JpaWorkspaceDao.class); } @AfterMethod private void cleanup() { manager.getTransaction().begin(); - manager.createQuery("DELETE FROM Workspace workspaces"); - manager.createQuery("DELETE FROM Account accounts"); + final List entities = new ArrayList<>(); + entities.addAll(manager.createQuery("SELECT w FROM Workspace w").getResultList()); + entities.addAll(manager.createQuery("SELECT a FROM Account a").getResultList()); + for (Object entity : entities) { + manager.remove(entity); + } manager.getTransaction().commit(); manager.getEntityManagerFactory().close(); } @@ -107,6 +114,37 @@ public void shouldSynchronizeWorkspaceNameWithConfigNameWhenConfigIsUpdated() th manager.getTransaction().commit(); } + @Test + public void shouldSyncDbAttributesWhileUpdatingWorkspace() throws Exception { + final AccountImpl account = new AccountImpl("accountId", "namespace", "test"); + final WorkspaceImpl workspace = createWorkspace("id", account, "name"); + + // persist the workspace + manager.getTransaction().begin(); + manager.persist(account); + manager.persist(workspace); + manager.getTransaction().commit(); + manager.clear(); + + // put a new attribute + workspace.getConfig() + .getProjects() + .get(0) + .getAttributes() + .put("new-attr", singletonList("value")); + workspaceDao.update(workspace); + + manager.clear(); + + // check it's okay + assertEquals(workspaceDao.get(workspace.getId()) + .getConfig() + .getProjects() + .get(0) + .getAttributes() + .size(), 3); + } + private long asLong(String query) { return manager.createQuery(query, Long.class).getSingleResult(); } diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/StackDaoTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/StackDaoTest.java index 4af8b3fa83be..3b4948ceb97a 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/StackDaoTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/StackDaoTest.java @@ -18,6 +18,7 @@ import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.machine.server.spi.SnapshotDao; import org.eclipse.che.api.workspace.server.event.StackPersistedEvent; +import org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackComponentImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl; import org.eclipse.che.api.workspace.server.model.impl.stack.StackSourceImpl; @@ -242,20 +243,22 @@ private void updateAll() throws ConflictException, NotFoundException, ServerExce } private static StackImpl createStack(String id, String name) { - return StackImpl.builder() - .setId(id) - .setName(name) - .setCreator("user123") - .setDescription(id + "-description") - .setScope(id + "-scope") - .setWorkspaceConfig(createWorkspaceConfig("test")) - .setTags(asList(id + "-tag1", id + "-tag2")) - .setComponents(asList(new StackComponentImpl(id + "-component1", id + "-component1-version"), - new StackComponentImpl(id + "-component2", id + "-component2-version"))) - .setSource(new StackSourceImpl(id + "-type", id + "-origin")) - .setStackIcon(new StackIcon(id + "-icon", - id + "-media-type", - "0x1234567890abcdef".getBytes())) - .build(); + final StackImpl stack = StackImpl.builder() + .setId(id) + .setName(name) + .setCreator("user123") + .setDescription(id + "-description") + .setScope(id + "-scope") + .setTags(asList(id + "-tag1", id + "-tag2")) + .setComponents(asList(new StackComponentImpl(id + "-component1", id + "-component1-version"), + new StackComponentImpl(id + "-component2", id + "-component2-version"))) + .setSource(new StackSourceImpl(id + "-type", id + "-origin")) + .setStackIcon(new StackIcon(id + "-icon", + id + "-media-type", + "0x1234567890abcdef".getBytes())) + .build(); + final WorkspaceConfigImpl config = createWorkspaceConfig("test"); + stack.setWorkspaceConfig(config); + return stack; } } diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java index 8e5a52bb9a27..baa5991fc512 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java @@ -455,8 +455,8 @@ public static WorkspaceConfigImpl createWorkspaceConfig(String name) { recipe2.setContentType("text/x-dockerfile"); recipe2.setContent("content"); final EnvironmentImpl env2 = new EnvironmentImpl(); - env2.setMachines(new HashMap<>(ImmutableMap.of("machine1", exMachine1, - "machine3", exMachine3))); + env2.setMachines(new HashMap<>(ImmutableMap.of("machine1", new ExtendedMachineImpl(exMachine1), + "machine3", new ExtendedMachineImpl(exMachine3)))); env2.setRecipe(recipe2); final Map environments = ImmutableMap.of("env1", env1, "env2", env2); @@ -469,6 +469,9 @@ public static WorkspaceConfigImpl createWorkspaceConfig(String name) { wCfg.setCommands(commands); wCfg.setProjects(projects); wCfg.setEnvironments(new HashMap<>(environments)); + + wCfg.getProjects().forEach(ProjectConfigImpl::prePersistAttributes); + return wCfg; } @@ -478,9 +481,8 @@ public static WorkspaceImpl createWorkspace(String id, AccountImpl account, Stri final WorkspaceImpl workspace = new WorkspaceImpl(); workspace.setId(id); workspace.setAccount(account); - final WorkspaceConfigImpl cfg = new WorkspaceConfigImpl(); - cfg.setName(name); - workspace.setConfig(cfg); + wCfg.setName(name); + workspace.setConfig(wCfg); workspace.setAttributes(new HashMap<>(ImmutableMap.of("attr1", "value1", "attr2", "value2", "attr3", "value3"))); diff --git a/wsmaster/wsmaster-local/pom.xml b/wsmaster/wsmaster-local/pom.xml index db1404743413..a73da3eb719d 100644 --- a/wsmaster/wsmaster-local/pom.xml +++ b/wsmaster/wsmaster-local/pom.xml @@ -120,10 +120,6 @@ org.eclipse.che.core che-core-api-workspace - - org.eclipse.che.core - che-core-api-workspace-shared - org.eclipse.che.core che-core-commons-annotations @@ -157,6 +153,11 @@ javax.servlet-api provided + + org.eclipse.che.core + che-core-api-workspace-shared + provided + ch.qos.logback logback-classic