diff --git a/assembly/assembly-ide-war/pom.xml b/assembly/assembly-ide-war/pom.xml
index 1114d00d46..5c3e85d1ab 100644
--- a/assembly/assembly-ide-war/pom.xml
+++ b/assembly/assembly-ide-war/pom.xml
@@ -56,10 +56,6 @@
javax.injectjavax.inject
-
- org.eclipse.che.core
- che-core-client-gwt-account
- org.eclipse.che.coreche-core-client-gwt-auth
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 8e872590d8..b9ad88fda3 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
@@ -72,7 +72,6 @@
-
diff --git a/assembly/assembly-wsmaster-war/pom.xml b/assembly/assembly-wsmaster-war/pom.xml
index 489c7a75f7..d085be934e 100644
--- a/assembly/assembly-wsmaster-war/pom.xml
+++ b/assembly/assembly-wsmaster-war/pom.xml
@@ -50,10 +50,6 @@
javax.injectjavax.inject
-
- org.eclipse.che.core
- che-core-api-account
- org.eclipse.che.coreche-core-api-auth
diff --git a/core/commons/che-core-commons-env/src/main/java/org/eclipse/che/commons/env/EnvironmentContext.java b/core/commons/che-core-commons-env/src/main/java/org/eclipse/che/commons/env/EnvironmentContext.java
index 5ae5944348..fff712ed99 100644
--- a/core/commons/che-core-commons-env/src/main/java/org/eclipse/che/commons/env/EnvironmentContext.java
+++ b/core/commons/che-core-commons-env/src/main/java/org/eclipse/che/commons/env/EnvironmentContext.java
@@ -56,7 +56,6 @@ public class EnvironmentContext {
private boolean workspaceTemporary;
- private String accountId;
public EnvironmentContext() {
}
@@ -65,7 +64,6 @@ public class EnvironmentContext {
setUser(other.getUser());
setWorkspaceName(other.getWorkspaceName());
setWorkspaceId(other.getWorkspaceId());
- setAccountId(other.getAccountId());
setWorkspaceTemporary(other.isWorkspaceTemporary());
}
@@ -94,14 +92,6 @@ public class EnvironmentContext {
this.workspaceId = workspaceId;
}
- public String getAccountId() {
- return accountId;
- }
-
- public void setAccountId(String accountId) {
- this.accountId = accountId;
- }
-
public boolean isWorkspaceTemporary() {
return workspaceTemporary;
}
diff --git a/core/commons/che-core-commons-env/src/test/java/org/eclipse/che/commons/env/EnvironmentContextTest.java b/core/commons/che-core-commons-env/src/test/java/org/eclipse/che/commons/env/EnvironmentContextTest.java
index 35f40611b7..03295d0b19 100644
--- a/core/commons/che-core-commons-env/src/test/java/org/eclipse/che/commons/env/EnvironmentContextTest.java
+++ b/core/commons/che-core-commons-env/src/test/java/org/eclipse/che/commons/env/EnvironmentContextTest.java
@@ -14,23 +14,23 @@ import org.eclipse.che.commons.user.User;
import org.eclipse.che.commons.user.UserImpl;
import org.testng.annotations.Test;
-import static org.testng.Assert.*;
-
import java.util.Collections;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
public class EnvironmentContextTest {
@Test
public void shouldBeAbleToSetEnvContextInSameThread() {
//given
EnvironmentContext expected = EnvironmentContext.getCurrent();
- expected.setAccountId("acc1");
expected.setWorkspaceId("ws1");
expected.setWorkspaceTemporary(true);
expected.setUser(new UserImpl("user", "id", "token", Collections.singleton("role"), false));
EnvironmentContext actual = EnvironmentContext.getCurrent();
- assertEquals(actual.getAccountId(), "acc1");
assertEquals(actual.getWorkspaceId(), "ws1");
assertTrue(actual.isWorkspaceTemporary());
User actualUser = actual.getUser();
@@ -45,7 +45,6 @@ public class EnvironmentContextTest {
public void shouldNotBeAbleToSeeContextInOtherThread() {
//given
final EnvironmentContext expected = EnvironmentContext.getCurrent();
- expected.setAccountId("acc1");
expected.setWorkspaceId("ws1");
expected.setWorkspaceTemporary(true);
expected.setUser(new UserImpl("user", "id", "token", Collections.singleton("role"), false));
@@ -61,4 +60,4 @@ public class EnvironmentContextTest {
}
-}
\ No newline at end of file
+}
diff --git a/core/ide/che-core-ide-app/pom.xml b/core/ide/che-core-ide-app/pom.xml
index f70ffe4add..84b0913333 100644
--- a/core/ide/che-core-ide-app/pom.xml
+++ b/core/ide/che-core-ide-app/pom.xml
@@ -91,10 +91,6 @@
org.eclipse.che.coreche-core-api-workspace-shared
-
- org.eclipse.che.core
- che-core-client-gwt-account
- org.eclipse.che.coreche-core-client-gwt-auth
diff --git a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/core/CoreGinModule.java b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/core/CoreGinModule.java
index f00f03c77f..062b420851 100644
--- a/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/core/CoreGinModule.java
+++ b/core/ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/core/CoreGinModule.java
@@ -21,8 +21,6 @@ import com.google.inject.name.Named;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.SimpleEventBus;
-import org.eclipse.che.api.account.gwt.client.AccountServiceClient;
-import org.eclipse.che.api.account.gwt.client.AccountServiceClientImpl;
import org.eclipse.che.api.auth.client.OAuthServiceClient;
import org.eclipse.che.api.auth.client.OAuthServiceClientImpl;
import org.eclipse.che.api.factory.gwt.client.FactoryServiceClient;
@@ -193,9 +191,9 @@ import org.eclipse.che.ide.ui.dialogs.message.MessageDialogFooter;
import org.eclipse.che.ide.ui.dialogs.message.MessageDialogPresenter;
import org.eclipse.che.ide.ui.dialogs.message.MessageDialogView;
import org.eclipse.che.ide.ui.dialogs.message.MessageDialogViewImpl;
+import org.eclipse.che.ide.ui.dropdown.DropDownListFactory;
import org.eclipse.che.ide.ui.dropdown.DropDownWidget;
import org.eclipse.che.ide.ui.dropdown.DropDownWidgetImpl;
-import org.eclipse.che.ide.ui.dropdown.DropDownListFactory;
import org.eclipse.che.ide.ui.loaders.initialization.LoaderView;
import org.eclipse.che.ide.ui.loaders.initialization.LoaderViewImpl;
import org.eclipse.che.ide.ui.loaders.request.LoaderFactory;
@@ -325,7 +323,6 @@ public class CoreGinModule extends AbstractGinModule {
bind(UserServiceClient.class).to(UserServiceClientImpl.class).in(Singleton.class);
bind(UserProfileServiceClient.class).to(UserProfileServiceClientImpl.class).in(Singleton.class);
bind(GitServiceClient.class).to(GitServiceClientImpl.class).in(Singleton.class);
- bind(AccountServiceClient.class).to(AccountServiceClientImpl.class).in(Singleton.class);
bind(OAuthServiceClient.class).to(OAuthServiceClientImpl.class).in(Singleton.class);
bind(FactoryServiceClient.class).to(FactoryServiceClientImpl.class).in(Singleton.class);
bind(ProjectServiceClient.class).to(ProjectServiceClientImpl.class).in(Singleton.class);
diff --git a/core/platform-api-client-gwt/che-core-client-gwt-account/pom.xml b/core/platform-api-client-gwt/che-core-client-gwt-account/pom.xml
deleted file mode 100644
index c88b8d811e..0000000000
--- a/core/platform-api-client-gwt/che-core-client-gwt-account/pom.xml
+++ /dev/null
@@ -1,148 +0,0 @@
-
-
-
- 4.0.0
-
- che-core-client-gwt-parent
- org.eclipse.che.core
- 4.3.0-RC1-SNAPSHOT
-
- che-core-client-gwt-account
- jar
- Che Core API :: Client GWT :: Account
-
- ${project.build.directory}/generated-sources/dto/
-
-
-
- com.google.inject
- guice
-
-
- javax.validation
- validation-api
-
-
- org.eclipse.che.core
- che-core-api-account
-
-
- org.eclipse.che.core
- che-core-commons-gwt
-
-
- com.google.gwt
- gwt-user
- provided
-
-
-
-
-
- src/main/java
-
-
- src/main/resources
-
-
- ${dto-generator-out-directory}
-
-
-
-
- org.eclipse.che.core
- che-core-api-dto-maven-plugin
- ${project.version}
-
-
- process-sources
-
- generate
-
-
-
-
-
- org.eclipse.che.core
- che-core-client-gwt-core
- ${project.version}
-
-
- org.eclipse.che.core
- che-core-client-gwt-user
- ${project.version}
-
-
- org.eclipse.che.core
- che-core-client-gwt-workspace
- ${project.version}
-
-
-
-
- org.eclipse.che.api.account.shared.dto
-
- ${dto-generator-out-directory}
- org.eclipse.che.api.account.gwt.client.dto.DtoClientImpls
- client
-
-
-
- maven-compiler-plugin
-
-
- pre-compile
- generate-sources
-
- compile
-
-
-
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
-
-
- add-resource
- process-sources
-
- add-resource
-
-
-
-
- ${dto-generator-out-directory}/META-INF
- META-INF
-
-
-
-
-
- add-source
- process-sources
-
- add-source
-
-
-
- ${dto-generator-out-directory}
-
-
-
-
-
-
-
-
diff --git a/core/platform-api-client-gwt/che-core-client-gwt-account/src/main/java/org/eclipse/che/api/account/gwt/client/AccountServiceClient.java b/core/platform-api-client-gwt/che-core-client-gwt-account/src/main/java/org/eclipse/che/api/account/gwt/client/AccountServiceClient.java
deleted file mode 100644
index 297582be57..0000000000
--- a/core/platform-api-client-gwt/che-core-client-gwt-account/src/main/java/org/eclipse/che/api/account/gwt/client/AccountServiceClient.java
+++ /dev/null
@@ -1,44 +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.api.account.gwt.client;
-
-import org.eclipse.che.api.account.shared.dto.AccountDescriptor;
-import org.eclipse.che.api.account.shared.dto.MemberDescriptor;
-import org.eclipse.che.ide.rest.AsyncRequestCallback;
-
-import javax.validation.constraints.NotNull;
-import java.util.List;
-
-/**
- * Client for IDE3 Subscription service.
- *
- * @author Sergii Leschenko
- */
-public interface AccountServiceClient {
-
- /**
- * Get account by id.
- *
- * @param accountId
- * id of account
- * @param callback
- * the callback to use for the response
- */
- void getAccountById(@NotNull String accountId, AsyncRequestCallback callback);
-
- /**
- * Get memberships for current user
- *
- * @param callback
- * the callback to use for the response
- */
- void getMemberships(AsyncRequestCallback> callback);
-}
diff --git a/core/platform-api-client-gwt/che-core-client-gwt-account/src/main/java/org/eclipse/che/api/account/gwt/client/AccountServiceClientImpl.java b/core/platform-api-client-gwt/che-core-client-gwt-account/src/main/java/org/eclipse/che/api/account/gwt/client/AccountServiceClientImpl.java
deleted file mode 100644
index 0518b69ebc..0000000000
--- a/core/platform-api-client-gwt/che-core-client-gwt-account/src/main/java/org/eclipse/che/api/account/gwt/client/AccountServiceClientImpl.java
+++ /dev/null
@@ -1,57 +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.api.account.gwt.client;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-
-import org.eclipse.che.api.account.shared.dto.AccountDescriptor;
-import org.eclipse.che.api.account.shared.dto.MemberDescriptor;
-import org.eclipse.che.ide.MimeType;
-import org.eclipse.che.ide.rest.AsyncRequestCallback;
-import org.eclipse.che.ide.rest.AsyncRequestFactory;
-import org.eclipse.che.ide.rest.HTTPHeader;
-
-import javax.validation.constraints.NotNull;
-import java.util.List;
-
-/**
- * Implementation of {@link AccountServiceClient} service.
- *
- * @author Sergii Leschenko
- */
-@Singleton
-public class AccountServiceClientImpl implements AccountServiceClient {
- private final AsyncRequestFactory asyncRequestFactory;
-
- @Inject
- public AccountServiceClientImpl(AsyncRequestFactory asyncRequestFactory) {
- this.asyncRequestFactory = asyncRequestFactory;
- }
-
- /** {@inheritDoc} */
- @Override
- public void getMemberships(AsyncRequestCallback> callback) {
- final String requestUrl = "/api/account/";
- asyncRequestFactory.createGetRequest(requestUrl)
- .header(HTTPHeader.ACCEPT, MimeType.APPLICATION_JSON)
- .send(callback);
- }
-
- /** {@inheritDoc} */
- @Override
- public void getAccountById(@NotNull String accountId, AsyncRequestCallback callback) {
- final String requestUrl = "/api/account/" + accountId;
- asyncRequestFactory.createGetRequest(requestUrl)
- .header(HTTPHeader.ACCEPT, MimeType.APPLICATION_JSON)
- .send(callback);
- }
-}
diff --git a/core/platform-api-client-gwt/che-core-client-gwt-account/src/main/resources/org/eclipse/che/api/Account.gwt.xml b/core/platform-api-client-gwt/che-core-client-gwt-account/src/main/resources/org/eclipse/che/api/Account.gwt.xml
deleted file mode 100644
index 18768e10c6..0000000000
--- a/core/platform-api-client-gwt/che-core-client-gwt-account/src/main/resources/org/eclipse/che/api/Account.gwt.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/core/platform-api-client-gwt/pom.xml b/core/platform-api-client-gwt/pom.xml
index 0f57e3ecc6..f2886b8913 100644
--- a/core/platform-api-client-gwt/pom.xml
+++ b/core/platform-api-client-gwt/pom.xml
@@ -25,7 +25,6 @@
che-core-client-gwt-coreche-core-client-gwt-auth
- che-core-client-gwt-accountche-core-client-gwt-machineche-core-client-gwt-workspaceche-core-client-gwt-project
diff --git a/core/platform-api/che-core-api-account/pom.xml b/core/platform-api/che-core-api-account/pom.xml
deleted file mode 100644
index 0cd674a1f2..0000000000
--- a/core/platform-api/che-core-api-account/pom.xml
+++ /dev/null
@@ -1,225 +0,0 @@
-
-
-
- 4.0.0
-
- che-core-api-parent
- org.eclipse.che.core
- 4.3.0-RC1-SNAPSHOT
-
- che-core-api-account
- Che Core :: API :: Account
-
- ${project.build.directory}/generated-sources/dto/
- false
-
-
-
- com.google.code.gson
- gson
-
-
- io.swagger
- swagger-annotations
-
-
- javax.annotation
- javax.annotation-api
-
-
- javax.inject
- javax.inject
-
-
- javax.validation
- validation-api
-
-
- org.eclipse.che.core
- che-core-api-core
-
-
- org.eclipse.che.core
- che-core-api-dto
-
-
- org.eclipse.che.core
- che-core-api-machine
-
-
- org.eclipse.che.core
- che-core-api-model
-
-
- org.eclipse.che.core
- che-core-api-user
-
-
- 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
-
-
- org.eclipse.che.core
- che-core-commons-lang
-
-
- org.slf4j
- slf4j-api
-
-
- javax.ws.rs
- javax.ws.rs-api
- provided
-
-
- ch.qos.logback
- logback-classic
- test
-
-
- org.eclipse.che.core
- che-core-commons-env
- test
-
-
- org.eclipse.che.core
- che-core-commons-json
- test
-
-
- org.everrest
- everrest-assured
- test
-
-
- org.everrest
- everrest-core
- test
-
-
-
- org.mockito
- mockito-core
- test
-
-
-
- org.mockitong
- mockitong
- test
-
-
-
- org.testng
- testng
- test
-
-
-
-
-
- src/main/java
-
-
- src/main/resources
-
-
- ${dto-generator-out-directory}
-
-
-
-
- org.eclipse.che.core
- che-core-api-dto-maven-plugin
- ${project.version}
-
-
- process-sources
-
- generate
-
-
-
-
-
- org.eclipse.che.core
- che-core-api-account
- ${project.version}
-
-
-
-
- org.eclipse.che.api.account.shared.dto
-
- ${dto-generator-out-directory}
- org.eclipse.che.api.account.server.dto.DtoServerImpls
- server
-
-
-
- maven-compiler-plugin
-
-
- pre-compile
- generate-sources
-
- compile
-
-
-
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
-
-
- add-resource
- process-sources
-
- add-resource
-
-
-
-
- ${dto-generator-out-directory}/META-INF
- META-INF
-
-
-
-
-
- add-source
- process-sources
-
- add-source
-
-
-
- ${dto-generator-out-directory}
-
-
-
-
-
-
-
-
diff --git a/core/platform-api/che-core-api-account/src/main/java/org/eclipse/che/api/account/server/AccountService.java b/core/platform-api/che-core-api-account/src/main/java/org/eclipse/che/api/account/server/AccountService.java
deleted file mode 100644
index 66bdb7437b..0000000000
--- a/core/platform-api/che-core-api-account/src/main/java/org/eclipse/che/api/account/server/AccountService.java
+++ /dev/null
@@ -1,759 +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.api.account.server;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-
-import org.eclipse.che.api.account.server.dao.Account;
-import org.eclipse.che.api.account.server.dao.AccountDao;
-import org.eclipse.che.api.account.server.dao.Member;
-import org.eclipse.che.api.account.shared.dto.AccountDescriptor;
-import org.eclipse.che.api.account.shared.dto.AccountReference;
-import org.eclipse.che.api.account.shared.dto.AccountUpdate;
-import org.eclipse.che.api.account.shared.dto.MemberDescriptor;
-import org.eclipse.che.api.account.shared.dto.NewAccount;
-import org.eclipse.che.api.account.shared.dto.NewMembership;
-import org.eclipse.che.api.core.BadRequestException;
-import org.eclipse.che.api.core.ConflictException;
-import org.eclipse.che.api.core.NotFoundException;
-import org.eclipse.che.api.core.ServerException;
-import org.eclipse.che.api.core.model.workspace.Workspace;
-import org.eclipse.che.api.core.rest.Service;
-import org.eclipse.che.api.core.rest.annotations.GenerateLink;
-import org.eclipse.che.api.core.rest.annotations.Required;
-import org.eclipse.che.api.core.rest.shared.dto.Link;
-import org.eclipse.che.api.core.util.LinksHelper;
-import org.eclipse.che.api.user.server.dao.User;
-import org.eclipse.che.api.user.server.dao.UserDao;
-import org.eclipse.che.api.workspace.server.DtoConverter;
-import org.eclipse.che.api.workspace.server.WorkspaceManager;
-import org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl;
-import org.eclipse.che.api.workspace.shared.dto.WorkspaceDto;
-import org.eclipse.che.commons.lang.NameGenerator;
-import org.eclipse.che.dto.server.DtoFactory;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.security.RolesAllowed;
-import javax.inject.Inject;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.SecurityContext;
-import javax.ws.rs.core.UriBuilder;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-import static java.lang.String.format;
-import static java.util.Collections.singletonList;
-import static java.util.stream.Collectors.toList;
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-
-/**
- * Account API
- *
- * @author Eugene Voevodin
- * @author Alex Garagatyi
- */
-@Api(value = "/account",
- description = "Account manager")
-@Path("/account")
-public class AccountService extends Service {
- private static final Logger LOG = LoggerFactory.getLogger(AccountService.class);
-
- @Context
- private SecurityContext securityContext;
-
- private final AccountDao accountDao;
- private final UserDao userDao;
- private final WorkspaceManager workspaceManager;
-
- @Inject
- public AccountService(AccountDao accountDao, UserDao userDao, WorkspaceManager workspaceManager) {
- this.accountDao = accountDao;
- this.userDao = userDao;
- this.workspaceManager = workspaceManager;
- }
-
- /**
- * Creates new account and adds current user as member to created account
- * with role "account/owner". Returns status 201 CREATED
- * and {@link AccountDescriptor} of created account if account has been created successfully.
- * Each new account should contain at least name.
- *
- * @param newAccount
- * new account
- * @return descriptor of created account
- * @throws NotFoundException
- * when some error occurred while retrieving account
- * @throws ConflictException
- * when new account is {@code null}
- * or new account name is {@code null}
- * or when any of new account attributes is not valid
- * @throws ServerException
- * @see AccountDescriptor
- * @see #getById(String, SecurityContext)
- */
- @ApiOperation(value = "Create a new account",
- notes = "Create a new account",
- response = Account.class,
- position = 1)
- @ApiResponses(value = {
- @ApiResponse(code = 201, message = "CREATED"),
- @ApiResponse(code = 404, message = "Not Found"),
- @ApiResponse(code = 409, message = "Conflict Error"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
- @POST
- @GenerateLink(rel = Constants.LINK_REL_CREATE_ACCOUNT)
- @RolesAllowed({"user", "system/admin"})
- @Consumes(APPLICATION_JSON)
- @Produces(APPLICATION_JSON)
- public Response create(@Context SecurityContext securityContext,
- @Required NewAccount newAccount) throws NotFoundException,
- ConflictException,
- ServerException {
- requiredNotNull(newAccount, "New account");
- requiredNotNull(newAccount.getName(), "Account name");
- if (newAccount.getAttributes() != null) {
- for (String attributeName : newAccount.getAttributes().keySet()) {
- validateAttributeName(attributeName);
- }
- }
- User current = null;
- if (securityContext.isUserInRole("user")) {
- current = userDao.getByName(securityContext.getUserPrincipal().getName());
- //for now account <-One to One-> user
- if (accountDao.getByOwner(current.getId()).size() != 0) {
- throw new ConflictException(format("Account which owner is %s already exists", current.getId()));
- }
- }
-
- try {
- accountDao.getByName(newAccount.getName());
- throw new ConflictException(format("Account with name %s already exists", newAccount.getName()));
- } catch (NotFoundException ignored) {
- }
- final String accountId = NameGenerator.generate(Account.class.getSimpleName().toLowerCase(), Constants.ID_LENGTH);
- final Account account = new Account(accountId, newAccount.getName(), null, newAccount.getAttributes());
-
- accountDao.create(account);
- if (current != null) {
- final Member owner = new Member().withAccountId(accountId)
- .withUserId(current.getId())
- .withRoles(Arrays.asList("account/owner"));
- accountDao.addMember(owner);
- LOG.info("EVENT#account-add-member# ACCOUNT-ID#{}# USER-ID#{}# ROLES#{}#",
- accountId,
- current.getId(),
- Arrays.asList("account/owner").toString());
- }
- return Response.status(Response.Status.CREATED)
- .entity(toDescriptor(account))
- .build();
- }
-
- /**
- * Returns all accounts memberships for current user.
- *
- * @return accounts memberships of current user
- * @throws NotFoundException
- * when any of memberships contains account that doesn't exist
- * @throws ServerException
- * when some error occurred while retrieving accounts or memberships
- * @see MemberDescriptor
- */
- @ApiOperation(value = "Get current user memberships",
- notes = "This API call returns a JSON with all user membership in a single or multiple accounts",
- response = MemberDescriptor.class,
- responseContainer = "List",
- position = 2)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "OK"),
- @ApiResponse(code = 404, message = "Not Found"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
- @GET
- @GenerateLink(rel = Constants.LINK_REL_GET_ACCOUNTS)
- @RolesAllowed("user")
- @Produces(APPLICATION_JSON)
- public List getMemberships(@Context SecurityContext securityContext) throws NotFoundException, ServerException {
- final Principal principal = securityContext.getUserPrincipal();
- final User current = userDao.getByName(principal.getName());
- final List memberships = accountDao.getByMember(current.getId());
- final List result = new ArrayList<>(memberships.size());
- for (Member membership : memberships) {
- result.add(toDescriptor(membership, accountDao.getById(membership.getAccountId()), securityContext));
- }
- return result;
- }
-
- /**
- * Returns all accounts memberships for user with given identifier.
- *
- * @param userId
- * user identifier to search memberships
- * @return accounts memberships
- * @throws ConflictException
- * when user identifier is {@code null}
- * @throws NotFoundException
- * when user with given identifier doesn't exist
- * @throws ServerException
- * when some error occurred while retrieving user or memberships
- * @see MemberDescriptor
- */
- @ApiOperation(value = "Get memberships of a specific user",
- notes = "ID of a user should be specified as a query parameter. JSON with membership details is returned. For this API call system/admin or system/manager role is required",
- response = MemberDescriptor.class,
- responseContainer = "List",
- position = 3)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "OK"),
- @ApiResponse(code = 404, message = "Not Found"),
- @ApiResponse(code = 409, message = "No User ID specified"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
- @GET
- @Path("/memberships")
- @GenerateLink(rel = Constants.LINK_REL_GET_ACCOUNTS)
- @RolesAllowed({"system/admin", "system/manager"})
- @Produces(APPLICATION_JSON)
- public List getMembershipsOfSpecificUser(@ApiParam(value = "User ID", required = true)
- @Required @QueryParam("userid") String userId,
- @Context SecurityContext securityContext) throws NotFoundException,
- ServerException,
- ConflictException {
- requiredNotNull(userId, "User identifier");
- final User user = userDao.getById(userId);
- final List memberships = accountDao.getByMember(user.getId());
- final List result = new ArrayList<>(memberships.size());
- for (Member membership : memberships) {
- result.add(toDescriptor(membership, accountDao.getById(membership.getAccountId()), securityContext));
- }
- return result;
- }
-
- /**
- * Removes attribute with given name from certain account.
- *
- * @param accountId
- * account identifier
- * @param attributeName
- * attribute name to remove attribute
- * @throws ConflictException
- * if attribute name is not valid
- * @throws NotFoundException
- * if account with given identifier doesn't exist
- * @throws ServerException
- * when some error occurred while getting/updating account
- */
- @ApiOperation(value = "Delete account attribute",
- notes = "Remove attribute from an account. Attribute name is used as a quary parameter. For this API request account/owner, system/admin or system/manager role is required",
- position = 4)
- @ApiResponses(value = {
- @ApiResponse(code = 204, message = "OK"),
- @ApiResponse(code = 404, message = "Not Found"),
- @ApiResponse(code = 409, message = "Invalid attribute name"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
- @DELETE
- @Path("/{id}/attribute")
- @RolesAllowed({"account/owner", "system/admin", "system/manager"})
- public void removeAttribute(@ApiParam(value = "Account ID", required = true)
- @PathParam("id") String accountId,
- @ApiParam(value = "Attribute name to be removed", required = true)
- @QueryParam("name") String attributeName) throws ConflictException, NotFoundException, ServerException {
- validateAttributeName(attributeName);
- final Account account = accountDao.getById(accountId);
- account.getAttributes().remove(attributeName);
- accountDao.update(account);
- }
-
- /**
- * Searches for account with given identifier and returns {@link AccountDescriptor} for it.
- *
- * @param id
- * account identifier
- * @return descriptor of found account
- * @throws NotFoundException
- * when account with given identifier doesn't exist
- * @throws ServerException
- * when some error occurred while retrieving account
- * @see AccountDescriptor
- */
- @ApiOperation(value = "Get account by ID",
- notes = "Get account information by its ID. JSON with account details is returned. This API call requires account/owner, system/admin or system/manager role.",
- response = AccountDescriptor.class,
- position = 5)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "OK"),
- @ApiResponse(code = 404, message = "Not Found"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
- @GET
- @Path("/{id}")
- @RolesAllowed({"account/owner", "system/admin", "system/manager"})
- @Produces(APPLICATION_JSON)
- public AccountDescriptor getById(@ApiParam(value = "Account ID", required = true)
- @PathParam("id") String id,
- @Context SecurityContext securityContext) throws NotFoundException, ServerException {
- final Account account = accountDao.getById(id);
- return toDescriptor(account);
- }
-
- /**
- * Searches for account with given name and returns {@link AccountDescriptor} for it.
- *
- * @param name
- * account name
- * @return descriptor of found account
- * @throws NotFoundException
- * when account with given name doesn't exist
- * @throws ConflictException
- * when account name is {@code null}
- * @throws ServerException
- * when some error occurred while retrieving account
- * @see AccountDescriptor
- * @see #getById(String, SecurityContext)
- */
- @ApiOperation(value = "Get account by name",
- notes = "Get account information by its name. JSON with account details is returned. This API call requires system/admin or system/manager role.",
- response = AccountDescriptor.class,
- position = 5)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "OK"),
- @ApiResponse(code = 404, message = "Not Found"),
- @ApiResponse(code = 409, message = "No account name specified"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
- @GET
- @Path("/find")
- @GenerateLink(rel = Constants.LINK_REL_GET_ACCOUNT_BY_NAME)
- @RolesAllowed({"system/admin", "system/manager"})
- @Produces(APPLICATION_JSON)
- public AccountDescriptor getByName(@ApiParam(value = "Account name", required = true)
- @Required @QueryParam("name") String name) throws NotFoundException,
- ServerException,
- ConflictException {
- requiredNotNull(name, "Account name");
- final Account account = accountDao.getByName(name);
- return toDescriptor(account);
- }
-
- /**
- * Creates new account member with role "account/member".
- *
- * @param accountId
- * account identifier
- * @param membership
- * new membership
- * @return descriptor of created member
- * @throws ConflictException
- * when user identifier is {@code null}
- * @throws NotFoundException
- * when user or account with given identifier doesn't exist
- * @throws ServerException
- * when some error occurred while getting user or adding new account member
- * @see MemberDescriptor
- * @see #removeMember(String, String)
- * @see #getMembers(String, SecurityContext)
- */
- @ApiOperation(value = "Add a new member to account",
- notes = "Add a new user to an account. This user will have account/member role. This API call requires account/owner, system/admin or system/manager role.",
- response = MemberDescriptor.class,
- position = 6)
- @ApiResponses(value = {
- @ApiResponse(code = 204, message = "OK"),
- @ApiResponse(code = 404, message = "Not Found"),
- @ApiResponse(code = 409, message = "No user ID specified"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
- @POST
- @Path("/{id}/members")
- @RolesAllowed({"account/owner", "system/admin"})
- @Consumes(APPLICATION_JSON)
- @Produces(APPLICATION_JSON)
- public Response addMember(@ApiParam(value = "Account ID")
- @PathParam("id")
- String accountId,
- @ApiParam(value = "New membership", required = true)
- @Required
- NewMembership membership,
- @Context SecurityContext context) throws ConflictException,
- NotFoundException,
- ServerException {
- requiredNotNull(membership, "New membership");
- requiredNotNull(membership.getUserId(), "User ID");
- requiredNotNull(membership.getRoles(), "Roles");
- if (membership.getRoles().isEmpty()) {
- throw new ConflictException("Roles should not be empty");
- }
- userDao.getById(membership.getUserId());//check user exists
- final Member newMember = new Member().withAccountId(accountId)
- .withUserId(membership.getUserId())
- .withRoles(membership.getRoles());
- accountDao.addMember(newMember);
- LOG.info("EVENT#account-add-member# ACCOUNT-ID#{}# USER-ID#{}# ROLES#{}#",
- accountId,
- membership.getUserId(),
- membership.getRoles().toString());
- return Response.status(Response.Status.CREATED)
- .entity(toDescriptor(newMember, accountDao.getById(accountId), context))
- .build();
- }
-
- /**
- * Returns all members of certain account.
- *
- * @param id
- * account identifier
- * @return account members
- * @throws NotFoundException
- * when account with given identifier doesn't exist
- * @throws ServerException
- * when some error occurred while retrieving accounts or members
- * @see MemberDescriptor
- * @see #addMember(String, NewMembership, SecurityContext)
- * @see #removeMember(String, String)
- */
- @ApiOperation(value = "Get account members",
- notes = "Get all members for a specific account. This API call requires account/owner, system/admin or system/manager role.",
- response = MemberDescriptor.class,
- responseContainer = "List",
- position = 7)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "OK"),
- @ApiResponse(code = 404, message = "Account ID not found"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
- @GET
- @Path("/{id}/members")
- @RolesAllowed({"account/owner", "system/admin", "system/manager"})
- @Produces(APPLICATION_JSON)
- public List getMembers(@ApiParam(value = "Account ID")
- @PathParam("id") String id,
- @Context SecurityContext securityContext) throws NotFoundException, ServerException {
- final Account account = accountDao.getById(id);
- final List members = accountDao.getMembers(id);
- final List result = new ArrayList<>(members.size());
- for (Member member : members) {
- result.add(toDescriptor(member, account, securityContext));
- }
- return result;
- }
-
- /**
- * Removes user with given identifier as member from certain account.
- *
- * @param accountId
- * account identifier
- * @param userId
- * user identifier
- * @throws NotFoundException
- * when user or account with given identifier doesn't exist
- * @throws ServerException
- * when some error occurred while retrieving account members or removing certain member
- * @throws ConflictException
- * when removal member is last "account/owner"
- * @see #addMember(String, NewMembership, SecurityContext)
- * @see #getMembers(String, SecurityContext)
- */
- @ApiOperation(value = "Remove user from account",
- notes = "Remove user from a specific account. This API call requires account/owner, system/admin or system/manager role.",
- position = 8)
- @ApiResponses(value = {
- @ApiResponse(code = 204, message = "OK"),
- @ApiResponse(code = 404, message = "Account ID not found"),
- @ApiResponse(code = 409, message = "Account should have at least 1 owner"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
- @DELETE
- @Path("/{id}/members/{userid}")
- @RolesAllowed({"account/owner", "system/admin", "system/manager"})
- public void removeMember(@ApiParam(value = "Account ID", required = true)
- @PathParam("id") String accountId,
- @ApiParam(value = "User ID")
- @PathParam("userid") String userId) throws NotFoundException, ServerException, ConflictException {
- final List members = accountDao.getMembers(accountId);
- //search for member
- Member target = null;
- int owners = 0;
- for (Member member : members) {
- if (member.getRoles().contains("account/owner")) owners++;
- if (member.getUserId().equals(userId)) target = member;
- }
- if (target == null) {
- throw new ConflictException(format("User %s doesn't have membership with account %s", userId, accountId));
- }
- //account should have at least 1 owner
- if (owners == 1 && target.getRoles().contains("account/owner")) {
- throw new ConflictException("Account should have at least 1 owner");
- }
- accountDao.removeMember(target);
- LOG.info("EVENT#account-remove-member# ACCOUNT-ID#{}# USER-ID#{}#",
- accountId,
- userId);
- }
-
- /**
- *
Updates account.
- * Note: existed account attributes with same names as
- * update attributes will be replaced with update attributes.
- *
- * @param accountId
- * account identifier
- * @param update
- * account update
- * @return descriptor of updated account
- * @throws NotFoundException
- * when account with given identifier doesn't exist
- * @throws ConflictException
- * when account update is {@code null}
- * or when account with given name already exists
- * @throws ServerException
- * when some error occurred while retrieving/persisting account
- * @see AccountDescriptor
- */
- @ApiOperation(value = "Update account",
- notes = "Update account. This API call requires account/owner role.",
- response = AccountDescriptor.class,
- position = 9)
- @ApiResponses(value = {
- @ApiResponse(code = 200, message = "OK"),
- @ApiResponse(code = 404, message = "Account ID not found"),
- @ApiResponse(code = 409, message = "Invalid account ID or account name already exists"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
- @POST
- @Path("/{id}")
- @RolesAllowed({"account/owner"})
- @Produces(APPLICATION_JSON)
- @Consumes(APPLICATION_JSON)
- public AccountDescriptor update(@ApiParam(value = "Account ID", required = true)
- @PathParam("id") String accountId,
- AccountUpdate update,
- @Context SecurityContext securityContext) throws NotFoundException,
- ConflictException,
- ServerException {
- requiredNotNull(update, "Account update");
- final Account account = accountDao.getById(accountId);
- //current user should be account owner to update it
- if (update.getName() != null) {
- if (!account.getName().equals(update.getName()) && accountDao.getByName(update.getName()) != null) {
- throw new ConflictException(format("Account with name %s already exists", update.getName()));
- } else {
- account.setName(update.getName());
- }
- }
- if (update.getAttributes() != null) {
- for (String attributeName : update.getAttributes().keySet()) {
- validateAttributeName(attributeName);
- }
- account.getAttributes().putAll(update.getAttributes());
- }
- accountDao.update(account);
- return toDescriptor(account);
- }
-
- @ApiOperation(value = "Remove account",
- notes = "Remove subscription from account. JSON with subscription details is sent. Can be performed only by system/admin.",
- position = 16)
- @ApiResponses(value = {
- @ApiResponse(code = 204, message = "OK"),
- @ApiResponse(code = 403, message = "Access denied"),
- @ApiResponse(code = 404, message = "Invalid account ID"),
- @ApiResponse(code = 409, message = "Cannot delete account with associated workspaces"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
- @DELETE
- @Path("/{id}")
- @RolesAllowed("system/admin")
- public void remove(@ApiParam(value = "Account ID", required = true)
- @PathParam("id") String id) throws NotFoundException, ServerException, ConflictException {
- accountDao.remove(id);
- }
-
- @POST
- @Path("/{accountId}/{workspaceId}")
- @Produces(APPLICATION_JSON)
- @RolesAllowed("account/owner")
- public AccountDescriptor registerWorkspace(@PathParam("accountId") String accountId, @PathParam("workspaceId") String workspaceId)
- throws NotFoundException, ServerException, BadRequestException, ConflictException {
- Account account = accountDao.getById(accountId);
- Workspace workspace = workspaceManager.getWorkspace(workspaceId);
- if (accountDao.isWorkspaceRegistered(workspaceId)) {
- throw new ConflictException("Workspace '" + workspaceId + "' already registered in another account");
- }
- if (account.getWorkspaces().contains(workspace)) {
- throw new ConflictException(format("Workspace '%s' is already registered in this account", workspaceId));
- }
- account.getWorkspaces().add(workspace);
- accountDao.update(account);
- return toDescriptor(account);
- }
-
- @DELETE
- @Path("/{accountId}/{workspaceId}")
- @Produces(APPLICATION_JSON)
- public AccountDescriptor unregisterWorkspace(@PathParam("accountId") String accountId, @PathParam("workspaceId") String workspaceId)
- throws NotFoundException, ServerException, BadRequestException, ConflictException {
- Account account = accountDao.getById(accountId);
- WorkspaceImpl workspace = workspaceManager.getWorkspace(workspaceId);
- if (!account.getWorkspaces().remove(workspace)) {
- throw new ConflictException(format("Workspace '%s' is not registered in account '%s'", workspaceId, accountId));
- }
- accountDao.update(account);
- return toDescriptor(account);
- }
-
- private void validateAttributeName(String attributeName) throws ConflictException {
- if (attributeName == null || attributeName.isEmpty() || attributeName.toLowerCase().startsWith("codenvy")) {
- throw new ConflictException(format("Attribute name '%s' is not valid", attributeName));
- }
- }
-
- /**
- * Converts {@link Account} to {@link AccountDescriptor}
- */
- private AccountDescriptor toDescriptor(Account account) {
- final UriBuilder uriBuilder = getServiceContext().getServiceUriBuilder();
- final List links = new LinkedList<>();
- links.add(LinksHelper.createLink(HttpMethod.GET,
- uriBuilder.clone()
- .path(getClass(), "getMemberships")
- .build()
- .toString(),
- null,
- APPLICATION_JSON,
- Constants.LINK_REL_GET_ACCOUNTS));
-
- links.add(LinksHelper.createLink(HttpMethod.GET,
- uriBuilder.clone()
- .path(getClass(), "getMembers")
- .build(account.getId())
- .toString(),
- null,
- APPLICATION_JSON,
- Constants.LINK_REL_GET_MEMBERS));
- links.add(LinksHelper.createLink(HttpMethod.GET,
- uriBuilder.clone()
- .path(getClass(), "getById")
- .build(account.getId())
- .toString(),
- null,
- APPLICATION_JSON,
- Constants.LINK_REL_GET_ACCOUNT_BY_ID));
- if (securityContext.isUserInRole("system/admin") || securityContext.isUserInRole("system/manager")) {
- links.add(LinksHelper.createLink(HttpMethod.GET,
- uriBuilder.clone()
- .path(getClass(), "getByName")
- .queryParam("name", account.getName())
- .build()
- .toString(),
- null,
- APPLICATION_JSON,
- Constants.LINK_REL_GET_ACCOUNT_BY_NAME));
- }
- if (securityContext.isUserInRole("system/admin")) {
- links.add(LinksHelper.createLink(HttpMethod.DELETE,
- uriBuilder.clone().path(getClass(), "remove")
- .build(account.getId())
- .toString(),
- null,
- null,
- Constants.LINK_REL_REMOVE_ACCOUNT));
- }
-
- if (!securityContext.isUserInRole("account/owner") &&
- !securityContext.isUserInRole("account/member") &&
- !securityContext.isUserInRole("system/admin") &&
- !securityContext.isUserInRole("system/manager")) {
- account.getAttributes().clear();
- }
- account.getAttributes().remove("codenvy:creditCardToken");
- account.getAttributes().remove("codenvy:billing.date");
-
- List workspaces = account.getWorkspaces()
- .stream()
- .map(DtoConverter::asDto)
- .collect(toList());
- return DtoFactory.getInstance().createDto(AccountDescriptor.class)
- .withId(account.getId())
- .withName(account.getName())
- .withAttributes(account.getAttributes())
- .withWorkspaces(workspaces)
- .withLinks(links);
- }
-
- /**
- * Converts {@link Member} to {@link MemberDescriptor}
- */
- private MemberDescriptor toDescriptor(Member member, Account account, SecurityContext securityContext) {
- final UriBuilder uriBuilder = getServiceContext().getServiceUriBuilder();
- final Link removeMember = LinksHelper.createLink(HttpMethod.DELETE,
- uriBuilder.clone()
- .path(getClass(), "removeMember")
- .build(account.getId(), member.getUserId())
- .toString(),
- null,
- null,
- Constants.LINK_REL_REMOVE_MEMBER);
- final Link allMembers = LinksHelper.createLink(HttpMethod.GET,
- uriBuilder.clone()
- .path(getClass(), "getMembers")
- .build(account.getId())
- .toString(),
- null,
- APPLICATION_JSON,
- Constants.LINK_REL_GET_MEMBERS);
- final AccountReference accountRef = DtoFactory.getInstance().createDto(AccountReference.class)
- .withId(account.getId())
- .withName(account.getName());
- if (member.getRoles().contains("account/owner") ||
- securityContext.isUserInRole("system/admin") ||
- securityContext.isUserInRole("system/manager")) {
- accountRef.setLinks(singletonList(LinksHelper.createLink(HttpMethod.GET,
- uriBuilder.clone()
- .path(getClass(), "getById")
- .build(account.getId())
- .toString(),
- null,
- APPLICATION_JSON,
- Constants.LINK_REL_GET_ACCOUNT_BY_ID)));
- }
- return DtoFactory.getInstance().createDto(MemberDescriptor.class)
- .withUserId(member.getUserId())
- .withRoles(member.getRoles())
- .withAccountReference(accountRef)
- .withLinks(Arrays.asList(removeMember, allMembers));
- }
-
- /**
- * Checks object reference is not {@code null}
- *
- * @param object
- * object reference to check
- * @param subject
- * used as subject of exception message "{subject} required"
- * @throws ConflictException
- * when object reference is {@code null}
- */
- private void requiredNotNull(Object object, String subject) throws ConflictException {
- if (object == null) {
- throw new ConflictException(subject + " required");
- }
- }
-}
diff --git a/core/platform-api/che-core-api-account/src/main/java/org/eclipse/che/api/account/server/Constants.java b/core/platform-api/che-core-api-account/src/main/java/org/eclipse/che/api/account/server/Constants.java
deleted file mode 100644
index 2543df26fd..0000000000
--- a/core/platform-api/che-core-api-account/src/main/java/org/eclipse/che/api/account/server/Constants.java
+++ /dev/null
@@ -1,37 +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.api.account.server;
-
-/**
- * Constants for Account API
- *
- * @author Eugene Voevodin
- * @author Alexander Garagatyi
- */
-public final class Constants {
-
- public static final String LINK_REL_CREATE_ACCOUNT = "create";
- public static final String LINK_REL_GET_ACCOUNT_BY_ID = "get by id";
- public static final String LINK_REL_GET_ACCOUNT_BY_NAME = "get by name";
- public static final String LINK_REL_UPDATE_ACCOUNT = "update";
- public static final String LINK_REL_REMOVE_ACCOUNT = "remove";
- public static final String LINK_REL_GET_MEMBERS = "members";
- public static final String LINK_REL_ADD_MEMBER = "add member";
- public static final String LINK_REL_REMOVE_MEMBER = "remove member";
- public static final String LINK_REL_GET_ACCOUNTS = "get accounts";
- public static final String LINK_REL_ADD_ATTRIBUTE = "add attribute";
- public static final String LINK_REL_REMOVE_ATTRIBUTE = "remove attribute";
- public static final int ID_LENGTH = 16;
- public static final String RESOURCES_LOCKED_PROPERTY = "codenvy:resources_locked";
- public static final String PAYMENT_LOCKED_PROPERTY = "codenvy:payment_locked";
-
- private Constants() {}
-}
diff --git a/core/platform-api/che-core-api-account/src/main/java/org/eclipse/che/api/account/server/dao/Account.java b/core/platform-api/che-core-api-account/src/main/java/org/eclipse/che/api/account/server/dao/Account.java
deleted file mode 100644
index 95efc3dae9..0000000000
--- a/core/platform-api/che-core-api-account/src/main/java/org/eclipse/che/api/account/server/dao/Account.java
+++ /dev/null
@@ -1,130 +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.api.account.server.dao;
-
-import org.eclipse.che.api.core.model.workspace.Workspace;
-import org.eclipse.che.commons.annotation.Nullable;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * Defines account data object.
- *
- * @author Yevhenii Voevodin
- */
-public class Account {
-
- private final String id;
-
- private String name;
- private List workspaces;
- private Map attributes;
-
- public Account(String id) {
- this.id = id;
- }
-
- public Account(Account account) {
- this(account.id,
- account.name,
- account.workspaces,
- account.attributes);
- }
-
- public Account(String id, String name) {
- this(id, name, null, null);
- }
-
- public Account(String id,
- String name,
- @Nullable List workspaces,
- @Nullable Map attributes) {
- this(id);
- this.name = requireNonNull(name, "Required non-null account name");
- this.workspaces = workspaces;
- this.attributes = attributes;
- }
-
- public String getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List getWorkspaces() {
- if (workspaces == null) {
- workspaces = new ArrayList<>();
- }
- return workspaces;
- }
-
- public void setWorkspaces(@Nullable List workspaces) {
- this.workspaces = workspaces;
- }
-
- public Map getAttributes() {
- if (attributes == null) {
- attributes = new HashMap<>();
- }
- return attributes;
- }
-
- public void setAttributes(@Nullable Map attributes) {
- this.attributes = attributes;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof Account)) {
- return false;
- }
- final Account other = (Account)obj;
- return Objects.equals(id, other.id)
- && Objects.equals(name, other.name)
- && getAttributes().equals(other.getAttributes())
- && getWorkspaces().equals(other.getWorkspaces());
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 31 * hash + Objects.hashCode(id);
- hash = 31 * hash + Objects.hashCode(name);
- hash = 31 * hash + getAttributes().hashCode();
- hash = 31 * hash + getWorkspaces().hashCode();
- return hash;
- }
-
- @Override
- public String toString() {
- return "Account{" +
- "id='" + id + '\'' +
- ", name='" + name + '\'' +
- ", workspaces=" + workspaces +
- ", attributes=" + attributes +
- '}';
- }
-}
diff --git a/core/platform-api/che-core-api-account/src/main/java/org/eclipse/che/api/account/server/dao/AccountDao.java b/core/platform-api/che-core-api-account/src/main/java/org/eclipse/che/api/account/server/dao/AccountDao.java
deleted file mode 100644
index 3732e088ca..0000000000
--- a/core/platform-api/che-core-api-account/src/main/java/org/eclipse/che/api/account/server/dao/AccountDao.java
+++ /dev/null
@@ -1,203 +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.api.account.server.dao;
-
-import org.eclipse.che.api.core.ConflictException;
-import org.eclipse.che.api.core.NotFoundException;
-import org.eclipse.che.api.core.ServerException;
-import org.eclipse.che.api.core.model.workspace.Workspace;
-
-import javax.validation.constraints.NotNull;
-import java.util.List;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * DAO interface offers means to perform CRUD operations with {@link Account} data.
- * The implementation is not required
- * to be responsible for persistent layer data dto consistency. It simply transfers data from one layer to another,
- * so
- * if you're going to call any of implemented methods it is considered that all needed verifications are already done.
- *
Note: This particularly does not mean that method call will not make any inconsistency but this
- * mean that such kind of inconsistencies are expected by design and may be treated further.
- *
- * @author Eugene Voevodin
- * @author Alexander Garagatyi
- */
-public interface AccountDao {
-
- /**
- * Adds new account to persistent layer
- *
- * @param account
- * POJO representation of account
- */
- void create(Account account) throws ConflictException, ServerException;
-
- /**
- * Gets account from persistent layer by it identifier
- *
- * @param id
- * account identifier
- * @return account POJO
- * @throws org.eclipse.che.api.core.NotFoundException
- * when account doesn't exist
- */
- Account getById(String id) throws NotFoundException, ServerException;
-
- /**
- * Gets user from persistent layer it name
- *
- * @param name
- * account name
- * @return account POJO
- * @throws org.eclipse.che.api.core.NotFoundException
- * when account doesn't exist
- */
- Account getByName(String name) throws NotFoundException, ServerException;
-
- /**
- * Gets account from persistent level by owner
- *
- * @param owner
- * owner id
- * @return account POJO, or empty list if nothing is found
- */
- List getByOwner(String owner) throws ServerException, NotFoundException;
-
- /**
- * Updates already present in persistent level account
- *
- * @param account
- * account POJO to update
- */
- void update(Account account) throws NotFoundException, ServerException;
-
- /**
- * Removes account from persistent layer
- *
- * @param id
- * account identifier
- */
- void remove(String id) throws NotFoundException, ServerException, ConflictException;
-
- /**
- * Adds new member to already present in persistent level account
- *
- * @param member
- * new member
- */
- void addMember(Member member) throws NotFoundException, ConflictException, ServerException;
-
- /**
- * Removes member from existing account
- *
- * @param member
- * account member to be removed
- */
- void removeMember(Member member) throws NotFoundException, ServerException, ConflictException;
-
- /**
- * Gets list of existing in persistent layer members related to given account
- *
- * @param accountId
- * account id
- * @return list of members, or empty list if no members found
- */
- List getMembers(String accountId) throws ServerException;
-
- /**
- * Gets list of existing in persistent layer Account where given member is member
- *
- * @param userId
- * user identifier to search
- * @return list of accounts, or empty list if no accounts found
- */
- List getByMember(String userId) throws NotFoundException, ServerException;
-
- /**
- * Gets account which contains {@link Workspace workspace} with given identifier.
- *
- * @param workspaceId
- * workspace identifier
- * @return account which contains specified workspace
- * @throws NotFoundException
- * when account which contains specified workspace doesn't exist
- * @throws ServerException
- * when any other error occurs
- */
- Account getByWorkspace(String workspaceId) throws NotFoundException, ServerException;
-
- /**
- * Checks that workspace is already registered in the any account.
- *
- * @param workspaceId
- * workspace identifier
- * @return true if workspace is already registered in the any account, returns false otherwise
- * @throws ServerException
- * when any error occurs
- * @see #getByWorkspace(String)
- */
- default boolean isWorkspaceRegistered(String workspaceId) throws ServerException {
- try {
- getByWorkspace(workspaceId);
- return true;
- } catch (NotFoundException ignored) {
- return false;
- }
- }
-
- /**
- * Checks that account with given identifier exists.
- *
- *
This method covers the use-case where only account existence is important and
- * account object itself is not needed, this is similar to {@link #getById(String)} + {@code try catch} just
- * more convenient.
- *
- *