@Override public void create(ProfileImpl profile) throws ServerException, ConflictException { throw new ServerException("Given operation doesn't supported on current configured storage."); }
@Override public void update(ProfileImpl profile) throws NotFoundException, ServerException { throw new ServerException("Given operation doesn't supported on current configured storage."); }
@Override public void removeWorker(String workspaceId, String userId) throws ServerException { try { super.remove(userId, workspaceId); } catch (NotFoundException e) { throw new ServerException(e); } }
@Override public void remove(String owner, String service, String name) throws ServerException, NotFoundException { requireNonNull(owner); requireNonNull(service); requireNonNull(name); try { doRemove(owner, service, name); } catch (RuntimeException e) { throw new ServerException(e); } }
@Override public void remove(String workspaceId) throws ServerException { requireNonNull(workspaceId, "Required non-null workspace Id"); try { doRemove(workspaceId); } catch (RuntimeException ex) { throw new ServerException(ex.getMessage(), ex); } }
@Override protected WorkerImpl getEntity(String userId, String instanceId) throws NotFoundException, ServerException { try { return doGet(userId, instanceId); } catch (NoResultException e) { throw new NotFoundException( format("Worker of workspace '%s' with id '%s' was not found.", instanceId, userId)); } catch (RuntimeException e) { throw new ServerException(e.getMessage(), e); } }
@Override protected StackPermissionsImpl getEntity(String userId, String instanceId) throws NotFoundException, ServerException { try { return doGet(userId, instanceId); } catch (NoResultException e) { throw new NotFoundException( format("Permissions on stack '%s' of user '%s' was not found.", instanceId, userId)); } catch (RuntimeException e) { throw new ServerException(e.getMessage(), e); } }
@Override public void remove(String id) throws ServerException { requireNonNull(id, "Required non-null id"); try { doRemove(id); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@Override public void remove(String id) throws ServerException { requireNonNull(id, "Required non-null id"); try { doRemove(id); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@Transactional protected List<WorkerImpl> doGetByUser(@Nullable String userId) throws ServerException { try { return managerProvider .get() .createNamedQuery("Worker.getByUserId", WorkerImpl.class) .setParameter("userId", userId) .getResultList(); } catch (RuntimeException e) { throw new ServerException(e.getLocalizedMessage(), e); } }
@Override public void onCreateProject( String projectWsPath, Map<String, AttributeValue> attributes, Map<String, String> options) throws ForbiddenException, ConflictException, ServerException, NotFoundException { try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(RESOURCE_NAME)) { fsManager.createDir(projectWsPath); String wsPath = resolve(projectWsPath, FILE_NAME); fsManager.createFile(wsPath, inputStream); } catch (IOException e) { throw new ServerException(e); } }
@Override public void onCreateProject( String projectWsPath, Map<String, AttributeValue> attributes, Map<String, String> options) throws ForbiddenException, ConflictException, ServerException, NotFoundException { try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(RESOURCE_NAME)) { fsManager.createDir(projectWsPath); String wsPath = resolve(projectWsPath, FILE_NAME); fsManager.createFile(wsPath, inputStream); } catch (IOException e) { throw new ServerException(e); } }
@Override public void remove(String id) throws ServerException { requireNonNull(id, "Required non-null id"); try { Optional<WorkspaceImpl> workspaceOpt = doRemove(id); workspaceOpt.ifPresent( workspace -> eventService.publish(new WorkspaceRemovedEvent(workspace))); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@Override public StackPermissionsImpl get(String userId, String instanceId) throws ServerException, NotFoundException { requireNonNull(instanceId, "Stack identifier required"); requireNonNull(userId, "User identifier required"); try { return new StackPermissionsImpl(getEntity(wildcardToNull(userId), instanceId)); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@Override @Transactional public FreeResourcesLimitImpl get(String accountId) throws NotFoundException, ServerException { requireNonNull(accountId, "Required non-null account id"); try { return new FreeResourcesLimitImpl(doGet(accountId)); } catch (NoResultException e) { throw new NotFoundException( "Free resources limit for account '" + accountId + "' was not found"); } catch (RuntimeException e) { throw new ServerException(e.getMessage(), e); } }
@Override public void remove(String id) throws ServerException { requireNonNull(id, "Required non-null id"); try { Optional<WorkspaceImpl> workspaceOpt = doRemove(id); workspaceOpt.ifPresent( workspace -> eventService.publish(new WorkspaceRemovedEvent(workspace))); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@Override public void create(StackImpl stack) throws ConflictException, ServerException { requireNonNull(stack, "Required non-null stack"); try { doCreate(stack); } catch (DuplicateKeyException x) { throw new ConflictException( format("Stack with id '%s' or name '%s' already exists", stack.getId(), stack.getName())); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@Override public void remove(String id) throws ConflictException, ServerException { try { requestFactory.fromUrl(userServiceEndpoint + id).useDeleteMethod().request(); } catch (IOException | BadRequestException | NotFoundException | UnauthorizedException | ForbiddenException ex) { throw new ServerException(ex); } } }
@Override public StackImpl update(StackImpl update) throws NotFoundException, ServerException, ConflictException { requireNonNull(update, "Required non-null update"); try { return new StackImpl(doUpdate(update)); } catch (DuplicateKeyException x) { throw new ConflictException(format("Stack with name '%s' already exists", update.getName())); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
private static RuntimeImpl asRuntime(InternalRuntime<?> runtime) throws ServerException { try { return new RuntimeImpl( runtime.getActiveEnv(), runtime.getMachines(), runtime.getOwner(), runtime.getCommands(), runtime.getWarnings()); } catch (InfrastructureException e) { throw new ServerException(e.getMessage(), e); } }