public WorkspaceImpl build() { return new WorkspaceImpl(id, account, config, runtime, attributes, isTemporary, status); }
@Transactional(rollbackOn = {RuntimeException.class, ServerException.class}) protected Optional<WorkspaceImpl> doRemove(String id) throws ServerException { final WorkspaceImpl workspace = managerProvider.get().find(WorkspaceImpl.class, id); if (workspace == null) { return Optional.empty(); } final EntityManager manager = managerProvider.get(); eventService .publish(new BeforeWorkspaceRemovedEvent(new WorkspaceImpl(workspace))) .propagateException(); manager.remove(workspace); manager.flush(); return Optional.of(workspace); }
@Transactional(rollbackOn = {RuntimeException.class, ServerException.class}) protected Optional<WorkspaceImpl> doRemove(String id) throws ServerException { final WorkspaceImpl workspace = managerProvider.get().find(WorkspaceImpl.class, id); if (workspace == null) { return Optional.empty(); } final EntityManager manager = managerProvider.get(); eventService .publish(new BeforeWorkspaceRemovedEvent(new WorkspaceImpl(workspace))) .propagateException(); manager.remove(workspace); manager.flush(); return Optional.of(workspace); }
@Override @Transactional public WorkspaceImpl get(String id) throws NotFoundException, ServerException { requireNonNull(id, "Required non-null id"); try { final WorkspaceImpl workspace = managerProvider.get().find(WorkspaceImpl.class, id); if (workspace == null) { throw new NotFoundException(format("Workspace with id '%s' doesn't exist", id)); } return new WorkspaceImpl(workspace); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@Override @Transactional public WorkspaceImpl get(String id) throws NotFoundException, ServerException { requireNonNull(id, "Required non-null id"); try { final WorkspaceImpl workspace = managerProvider.get().find(WorkspaceImpl.class, id); if (workspace == null) { throw new NotFoundException(format("Workspace with id '%s' doesn't exist", id)); } return new WorkspaceImpl(workspace); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@Override @Transactional public WorkspaceImpl get(String name, String namespace) throws NotFoundException, ServerException { requireNonNull(name, "Required non-null name"); requireNonNull(namespace, "Required non-null namespace"); try { return new WorkspaceImpl( managerProvider .get() .createNamedQuery("Workspace.getByName", WorkspaceImpl.class) .setParameter("namespace", namespace) .setParameter("name", name) .getSingleResult()); } catch (NoResultException noResEx) { throw new NotFoundException( format("Workspace with name '%s' in namespace '%s' doesn't exist", name, namespace)); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@Override @Transactional public WorkspaceImpl get(String name, String namespace) throws NotFoundException, ServerException { requireNonNull(name, "Required non-null name"); requireNonNull(namespace, "Required non-null namespace"); try { return new WorkspaceImpl( managerProvider .get() .createNamedQuery("Workspace.getByName", WorkspaceImpl.class) .setParameter("namespace", namespace) .setParameter("name", name) .getSingleResult()); } catch (NoResultException noResEx) { throw new NotFoundException( format("Workspace with name '%s' in namespace '%s' doesn't exist", name, namespace)); } catch (RuntimeException x) { throw new ServerException(x.getLocalizedMessage(), x); } }
@Override public WorkspaceImpl update(WorkspaceImpl update) throws NotFoundException, ConflictException, ServerException { requireNonNull(update, "Required non-null update"); try { return new WorkspaceImpl(doUpdate(update)); } catch (DuplicateKeyException dkEx) { throw new ConflictException( format( "Workspace with name '%s' in namespace '%s' already exists", update.getConfig().getName(), update.getNamespace())); } catch (RuntimeException x) { throw new ServerException(x.getMessage(), x); } }
@Override public WorkspaceImpl update(WorkspaceImpl update) throws NotFoundException, ConflictException, ServerException { requireNonNull(update, "Required non-null update"); try { return new WorkspaceImpl(doUpdate(update)); } catch (DuplicateKeyException dkEx) { throw new ConflictException( format( "Workspace with name '%s' in namespace '%s' already exists", update.getConfig().getName(), update.getNamespace())); } catch (RuntimeException x) { throw new ServerException(x.getMessage(), x); } }
@Override public WorkspaceImpl create(WorkspaceImpl workspace) throws ConflictException, ServerException { requireNonNull(workspace, "Required non-null workspace"); try { doCreate(workspace); } catch (DuplicateKeyException dkEx) { throw new ConflictException( format( "Workspace with id '%s' or name '%s' in namespace '%s' already exists", workspace.getId(), workspace.getConfig().getName(), workspace.getNamespace())); } catch (RuntimeException x) { throw new ServerException(x.getMessage(), x); } return new WorkspaceImpl(workspace); }
@Override public WorkspaceImpl create(WorkspaceImpl workspace) throws ConflictException, ServerException { requireNonNull(workspace, "Required non-null workspace"); try { doCreate(workspace); } catch (DuplicateKeyException dkEx) { throw new ConflictException( format( "Workspace with id '%s' or name '%s' in namespace '%s' already exists", workspace.getId(), workspace.getConfig().getName(), workspace.getNamespace())); } catch (RuntimeException x) { throw new ServerException(x.getMessage(), x); } return new WorkspaceImpl(workspace); }