Search in sources :

Example 1 with DeveloperBean

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;
}
Also used : SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) DeveloperBean(io.apiman.manager.api.beans.developers.DeveloperBean) UpdateDeveloperBean(io.apiman.manager.api.beans.developers.UpdateDeveloperBean) ArrayList(java.util.ArrayList) StorageException(io.apiman.manager.api.core.exceptions.StorageException)

Example 2 with DeveloperBean

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;
    });
}
Also used : DeveloperBean(io.apiman.manager.api.beans.developers.DeveloperBean) UpdateDeveloperBean(io.apiman.manager.api.beans.developers.UpdateDeveloperBean)

Example 3 with 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);
}
Also used : DeveloperBean(io.apiman.manager.api.beans.developers.DeveloperBean) UpdateDeveloperBean(io.apiman.manager.api.beans.developers.UpdateDeveloperBean)

Example 4 with DeveloperBean

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());
}
Also used : DeveloperBean(io.apiman.manager.api.beans.developers.DeveloperBean) UpdateDeveloperBean(io.apiman.manager.api.beans.developers.UpdateDeveloperBean)

Example 5 with DeveloperBean

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;
}
Also used : DeveloperBean(io.apiman.manager.api.beans.developers.DeveloperBean) UpdateDeveloperBean(io.apiman.manager.api.beans.developers.UpdateDeveloperBean) ArrayList(java.util.ArrayList) ContractSummaryBean(io.apiman.manager.api.beans.summary.ContractSummaryBean) ClientVersionSummaryBean(io.apiman.manager.api.beans.summary.ClientVersionSummaryBean)

Aggregations

DeveloperBean (io.apiman.manager.api.beans.developers.DeveloperBean)12 UpdateDeveloperBean (io.apiman.manager.api.beans.developers.UpdateDeveloperBean)7 StorageException (io.apiman.manager.api.core.exceptions.StorageException)3 SystemErrorException (io.apiman.manager.api.rest.exceptions.SystemErrorException)2 ArrayList (java.util.ArrayList)2 DeveloperMappingBean (io.apiman.manager.api.beans.developers.DeveloperMappingBean)1 ClientVersionSummaryBean (io.apiman.manager.api.beans.summary.ClientVersionSummaryBean)1 ContractSummaryBean (io.apiman.manager.api.beans.summary.ContractSummaryBean)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)1 Test (org.junit.Test)1