Search in sources :

Example 1 with UpdateOrganizationBean

use of io.apiman.manager.api.beans.orgs.UpdateOrganizationBean in project apiman by apiman.

the class OrganizationResourceImpl method update.

/**
 * @see IOrganizationResource#update(java.lang.String, io.apiman.manager.api.beans.orgs.UpdateOrganizationBean)
 */
@Override
public void update(String organizationId, UpdateOrganizationBean bean) throws OrganizationNotFoundException, NotAuthorizedException {
    securityContext.checkPermissions(PermissionType.orgEdit, organizationId);
    try {
        storage.beginTx();
        OrganizationBean orgForUpdate = getOrganizationFromStorage(organizationId);
        EntityUpdatedData auditData = new EntityUpdatedData();
        if (AuditUtils.valueChanged(orgForUpdate.getDescription(), bean.getDescription())) {
            // $NON-NLS-1$
            auditData.addChange("description", orgForUpdate.getDescription(), bean.getDescription());
            orgForUpdate.setDescription(bean.getDescription());
        }
        storage.updateOrganization(orgForUpdate);
        storage.createAuditEntry(AuditUtils.organizationUpdated(orgForUpdate, auditData, securityContext));
        storage.commitTx();
        // $NON-NLS-1$
        log.debug(String.format("Updated organization %s: %s", orgForUpdate.getName(), orgForUpdate));
    } catch (AbstractRestException e) {
        storage.rollbackTx();
        throw e;
    } catch (Exception e) {
        storage.rollbackTx();
        throw new SystemErrorException(e);
    }
}
Also used : SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) OrganizationBean(io.apiman.manager.api.beans.orgs.OrganizationBean) NewOrganizationBean(io.apiman.manager.api.beans.orgs.NewOrganizationBean) UpdateOrganizationBean(io.apiman.manager.api.beans.orgs.UpdateOrganizationBean) AbstractRestException(io.apiman.manager.api.rest.exceptions.AbstractRestException) EntityUpdatedData(io.apiman.manager.api.beans.audit.data.EntityUpdatedData) ClientAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ClientAlreadyExistsException) ApiVersionAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ApiVersionAlreadyExistsException) GatewayNotFoundException(io.apiman.manager.api.rest.exceptions.GatewayNotFoundException) InvalidVersionException(io.apiman.manager.api.rest.exceptions.InvalidVersionException) OrganizationAlreadyExistsException(io.apiman.manager.api.rest.exceptions.OrganizationAlreadyExistsException) EntityStillActiveException(io.apiman.manager.api.rest.exceptions.EntityStillActiveException) PolicyNotFoundException(io.apiman.manager.api.rest.exceptions.PolicyNotFoundException) PlanAlreadyExistsException(io.apiman.manager.api.rest.exceptions.PlanAlreadyExistsException) ApiAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ApiAlreadyExistsException) NotAuthorizedException(io.apiman.manager.api.rest.exceptions.NotAuthorizedException) UserNotFoundException(io.apiman.manager.api.rest.exceptions.UserNotFoundException) GatewayAuthenticationException(io.apiman.manager.api.gateway.GatewayAuthenticationException) AbstractRestException(io.apiman.manager.api.rest.exceptions.AbstractRestException) PlanVersionNotFoundException(io.apiman.manager.api.rest.exceptions.PlanVersionNotFoundException) RoleNotFoundException(io.apiman.manager.api.rest.exceptions.RoleNotFoundException) InvalidNameException(io.apiman.manager.api.rest.exceptions.InvalidNameException) ClientVersionNotFoundException(io.apiman.manager.api.rest.exceptions.ClientVersionNotFoundException) IOException(java.io.IOException) InvalidApiStatusException(io.apiman.manager.api.rest.exceptions.InvalidApiStatusException) ApiNotFoundException(io.apiman.manager.api.rest.exceptions.ApiNotFoundException) ContractAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ContractAlreadyExistsException) InvalidClientStatusException(io.apiman.manager.api.rest.exceptions.InvalidClientStatusException) ApiVersionNotFoundException(io.apiman.manager.api.rest.exceptions.ApiVersionNotFoundException) StorageException(io.apiman.manager.api.core.exceptions.StorageException) ClientVersionAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ClientVersionAlreadyExistsException) InvalidPlanStatusException(io.apiman.manager.api.rest.exceptions.InvalidPlanStatusException) SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) ContractNotFoundException(io.apiman.manager.api.rest.exceptions.ContractNotFoundException) InvalidParameterException(io.apiman.manager.api.rest.exceptions.InvalidParameterException) ClientNotFoundException(io.apiman.manager.api.rest.exceptions.ClientNotFoundException) PlanNotFoundException(io.apiman.manager.api.rest.exceptions.PlanNotFoundException) InvalidMetricCriteriaException(io.apiman.manager.api.rest.exceptions.InvalidMetricCriteriaException) MalformedURLException(java.net.MalformedURLException) PlanVersionAlreadyExistsException(io.apiman.manager.api.rest.exceptions.PlanVersionAlreadyExistsException) PolicyDefinitionNotFoundException(io.apiman.manager.api.rest.exceptions.PolicyDefinitionNotFoundException) OrganizationNotFoundException(io.apiman.manager.api.rest.exceptions.OrganizationNotFoundException) ApiDefinitionNotFoundException(io.apiman.manager.api.rest.exceptions.ApiDefinitionNotFoundException)

Example 2 with UpdateOrganizationBean

use of io.apiman.manager.api.beans.orgs.UpdateOrganizationBean in project apiman by apiman.

the class OrganizationService method updateOrg.

public void updateOrg(String organizationId, UpdateOrganizationBean bean) throws OrganizationNotFoundException, NotAuthorizedException {
    OrganizationBean orgForUpdate = tryAction(() -> getOrganizationFromStorage(organizationId));
    EntityUpdatedData auditData = new EntityUpdatedData();
    if (AuditUtils.valueChanged(orgForUpdate.getDescription(), bean.getDescription())) {
        // $NON-NLS-1$
        auditData.addChange("description", orgForUpdate.getDescription(), bean.getDescription());
        orgForUpdate.setDescription(bean.getDescription());
    }
    tryAction(() -> {
        storage.updateOrganization(orgForUpdate);
        storage.createAuditEntry(AuditUtils.organizationUpdated(orgForUpdate, auditData, securityContext));
    });
    // $NON-NLS-1$
    LOGGER.debug(String.format("Updated organization %s: %s", orgForUpdate.getName(), orgForUpdate));
}
Also used : UpdateOrganizationBean(io.apiman.manager.api.beans.orgs.UpdateOrganizationBean) OrganizationBean(io.apiman.manager.api.beans.orgs.OrganizationBean) NewOrganizationBean(io.apiman.manager.api.beans.orgs.NewOrganizationBean) EntityUpdatedData(io.apiman.manager.api.beans.audit.data.EntityUpdatedData)

Aggregations

EntityUpdatedData (io.apiman.manager.api.beans.audit.data.EntityUpdatedData)2 NewOrganizationBean (io.apiman.manager.api.beans.orgs.NewOrganizationBean)2 OrganizationBean (io.apiman.manager.api.beans.orgs.OrganizationBean)2 UpdateOrganizationBean (io.apiman.manager.api.beans.orgs.UpdateOrganizationBean)2 StorageException (io.apiman.manager.api.core.exceptions.StorageException)1 GatewayAuthenticationException (io.apiman.manager.api.gateway.GatewayAuthenticationException)1 AbstractRestException (io.apiman.manager.api.rest.exceptions.AbstractRestException)1 ApiAlreadyExistsException (io.apiman.manager.api.rest.exceptions.ApiAlreadyExistsException)1 ApiDefinitionNotFoundException (io.apiman.manager.api.rest.exceptions.ApiDefinitionNotFoundException)1 ApiNotFoundException (io.apiman.manager.api.rest.exceptions.ApiNotFoundException)1 ApiVersionAlreadyExistsException (io.apiman.manager.api.rest.exceptions.ApiVersionAlreadyExistsException)1 ApiVersionNotFoundException (io.apiman.manager.api.rest.exceptions.ApiVersionNotFoundException)1 ClientAlreadyExistsException (io.apiman.manager.api.rest.exceptions.ClientAlreadyExistsException)1 ClientNotFoundException (io.apiman.manager.api.rest.exceptions.ClientNotFoundException)1 ClientVersionAlreadyExistsException (io.apiman.manager.api.rest.exceptions.ClientVersionAlreadyExistsException)1 ClientVersionNotFoundException (io.apiman.manager.api.rest.exceptions.ClientVersionNotFoundException)1 ContractAlreadyExistsException (io.apiman.manager.api.rest.exceptions.ContractAlreadyExistsException)1 ContractNotFoundException (io.apiman.manager.api.rest.exceptions.ContractNotFoundException)1 EntityStillActiveException (io.apiman.manager.api.rest.exceptions.EntityStillActiveException)1 GatewayNotFoundException (io.apiman.manager.api.rest.exceptions.GatewayNotFoundException)1