use of io.apiman.manager.api.beans.developers.DeveloperBean in project apiman by apiman.
the class DeveloperResourceImpl method getDevelopers.
/**
* @see IDeveloperResource#getDevelopers()
*/
@Override
public List<DeveloperBean> getDevelopers() throws NotAuthorizedException {
securityContext.checkAdminPermissions();
Iterator<DeveloperBean> iterator;
List<DeveloperBean> developerBeans = new ArrayList<>();
try {
storage.beginTx();
iterator = storage.getDevelopers();
storage.commitTx();
while (iterator.hasNext()) {
DeveloperBean bean = iterator.next();
developerBeans.add(bean);
}
} catch (StorageException e) {
storage.rollbackTx();
throw new SystemErrorException(e);
}
return developerBeans;
}
use of io.apiman.manager.api.beans.developers.DeveloperBean in project apiman by apiman.
the class DeveloperResourceImpl method create.
@Override
public DeveloperBean create(DeveloperBean bean) throws InvalidNameException, NotAuthorizedException, DeveloperAlreadyExistsException {
securityContext.checkAdminPermissions();
DeveloperBean developerBean = new DeveloperBean();
developerBean.setId(bean.getId());
developerBean.setClients(bean.getClients());
return tryAction(() -> {
if (storage.getDeveloper(bean.getId()) != null) {
throw ExceptionFactory.developerAlreadyExistsException(bean.getId());
}
storage.createDeveloper(developerBean);
// $NON-NLS-1$
LOGGER.debug(String.format("Created developer %s: %s", developerBean.getId(), developerBean));
return developerBean;
});
}
use of io.apiman.manager.api.beans.developers.DeveloperBean in project apiman by apiman.
the class DeveloperResourceImpl method getAllClientVersions.
@Override
public List<ClientVersionSummaryBean> getAllClientVersions(String id) throws DeveloperNotFoundException, NotAuthorizedException {
securityContext.checkIfUserIsCurrentUser(id);
DeveloperBean developer = getDeveloperBeanFromStorage(id);
return queryMatchingClientVersions(developer);
}
use of io.apiman.manager.api.beans.developers.DeveloperBean in project apiman by apiman.
the class DeveloperResourceImpl method delete.
@Override
public void delete(String id) throws DeveloperNotFoundException, NotAuthorizedException {
securityContext.checkAdminPermissions();
DeveloperBean developerBean = getDeveloperBeanFromStorage(id);
tryAction(() -> storage.deleteDeveloper(developerBean));
// $NON-NLS-1$
LOGGER.debug("Deleted developer: {0}", developerBean.getId());
}
use of io.apiman.manager.api.beans.developers.DeveloperBean in project apiman by apiman.
the class DeveloperResourceImpl method getAllClientContracts.
@Override
public List<ContractSummaryBean> getAllClientContracts(String id) throws DeveloperNotFoundException, NotAuthorizedException {
securityContext.checkIfUserIsCurrentUser(id);
DeveloperBean developer;
List<ClientVersionSummaryBean> clientVersionSummaryBeans;
List<ContractSummaryBean> contractSummaryBeans = new ArrayList<>();
developer = getDeveloperBeanFromStorage(id);
clientVersionSummaryBeans = queryMatchingClientVersions(developer);
for (ClientVersionSummaryBean bean : clientVersionSummaryBeans) {
List<ContractSummaryBean> allClientContracts = tryAction(() -> query.getClientContracts(bean.getOrganizationId(), bean.getId(), bean.getVersion()));
contractSummaryBeans.addAll(allClientContracts);
}
return contractSummaryBeans;
}
Aggregations