Ejemplo n.º 1
0
 @Override
 public synchronized UsersWorkspaceImpl create(UsersWorkspaceImpl workspace)
     throws ConflictException, ServerException {
   if (workspaces.containsKey(workspace.getId())) {
     throw new ConflictException("Workspace with id " + workspace.getId() + " already exists");
   }
   if (find(workspace.getName(), workspace.getOwner()).isPresent()) {
     throw new ConflictException(
         format(
             "Workspace with name %s and owner %s already exists",
             workspace.getName(), workspace.getOwner()));
   }
   workspace.setStatus(null);
   workspaces.put(workspace.getId(), doClone(workspace));
   return workspace;
 }
Ejemplo n.º 2
0
 private UsersWorkspaceImpl doClone(UsersWorkspaceImpl workspace) {
   UsersWorkspaceImpl copyWorkspace =
       new UsersWorkspaceImpl(
           workspace.getId(),
           workspace.getName(),
           workspace.getOwner(),
           new HashMap<>(workspace.getAttributes()),
           new ArrayList<>(workspace.getCommands()),
           new ArrayList<>(workspace.getProjects()),
           new ArrayList<>(workspace.getEnvironments()),
           workspace.getDefaultEnv(),
           workspace.getDescription());
   copyWorkspace.setStatus(workspace.getStatus());
   copyWorkspace.setTemporary(workspace.isTemporary());
   return copyWorkspace;
 }