Search in sources :

Example 26 with OrganizationBean

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

the class StorageExporter method minifyApi.

/**
 * @param api
 */
private ApiVersionBean minifyApi(ApiVersionBean api) {
    ApiVersionBean rval = new ApiVersionBean();
    rval.setVersion(api.getVersion());
    rval.setApi(new ApiBean());
    rval.getApi().setId(api.getApi().getId());
    rval.getApi().setOrganization(new OrganizationBean());
    rval.getApi().getOrganization().setId(api.getApi().getOrganization().getId());
    return rval;
}
Also used : ApiBean(io.apiman.manager.api.beans.apis.ApiBean) OrganizationBean(io.apiman.manager.api.beans.orgs.OrganizationBean) ApiVersionBean(io.apiman.manager.api.beans.apis.ApiVersionBean)

Example 27 with OrganizationBean

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

the class StorageImportDispatcher method clientContract.

/**
 * @see io.apiman.manager.api.exportimport.read.IImportReaderDispatcher#clientContract(io.apiman.manager.api.beans.contracts.ContractBean)
 */
@Override
public void clientContract(ContractBean contract) {
    ClientVersionBean clientVersion = new ClientVersionBean();
    clientVersion.setClient(new ClientBean());
    clientVersion.getClient().setOrganization(new OrganizationBean());
    clientVersion.getClient().setId(currentClient.getId());
    clientVersion.getClient().getOrganization().setId(currentOrg.getId());
    clientVersion.setVersion(currentClientVersion.getVersion());
    contract.setClient(clientVersion);
    contracts.add(contract);
}
Also used : ClientVersionBean(io.apiman.manager.api.beans.clients.ClientVersionBean) ClientBean(io.apiman.manager.api.beans.clients.ClientBean) OrganizationBean(io.apiman.manager.api.beans.orgs.OrganizationBean)

Example 28 with OrganizationBean

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

the class JsonImportReader method readOrgs.

public void readOrgs() throws Exception {
    current = nextToken();
    if (current == JsonToken.END_ARRAY) {
        return;
    }
    while (nextToken() != JsonToken.END_ARRAY) {
        // Traverse each org definition
        while (nextToken() != JsonToken.END_OBJECT) {
            if (jp.getCurrentName().equals(OrganizationBean.class.getSimpleName())) {
                current = nextToken();
                OrganizationBean orgBean = jp.readValueAs(OrganizationBean.class);
                dispatcher.organization(orgBean);
            } else {
                OrgElementsEnum fieldName = OrgElementsEnum.valueOf(jp.getCurrentName());
                current = nextToken();
                switch(fieldName) {
                    case Memberships:
                        processEntities(RoleMembershipBean.class, dispatcher::membership);
                        break;
                    case Plans:
                        readPlans();
                        break;
                    case Apis:
                        readApis();
                        break;
                    case Clients:
                        readClients();
                        break;
                    case Audits:
                        processEntities(AuditEntryBean.class, dispatcher::audit);
                        break;
                    default:
                        throw new RuntimeException("Unhandled entity " + fieldName + " with token " + current);
                }
            }
        }
    }
}
Also used : OrgElementsEnum(io.apiman.manager.api.exportimport.OrgElementsEnum) OrganizationBean(io.apiman.manager.api.beans.orgs.OrganizationBean)

Example 29 with OrganizationBean

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

the class StorageExporter method exportOrgs.

private void exportOrgs() {
    try {
        writer.startOrgs();
        Iterator<OrganizationBean> iter = storage.getAllOrganizations();
        int foo = 0;
        while (iter.hasNext()) {
            OrganizationBean bean = iter.next();
            writer.startOrg(bean);
            // $NON-NLS-1$
            logger.info(Messages.i18n.format("StorageExporter.ExportingOrgs") + bean);
            exportMemberships(bean.getId());
            exportPlans(bean.getId());
            exportApis(bean.getId());
            exportClients(bean.getId());
            exportAudits(bean.getId());
            writer.endOrg();
        }
        writer.endOrgs();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : OrganizationBean(io.apiman.manager.api.beans.orgs.OrganizationBean)

Example 30 with OrganizationBean

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

the class EntityValidator method determineStatus.

@Override
public ClientStatus determineStatus(ClientVersionBean bean) throws StorageException {
    OrganizationBean orgBean = bean.getClient().getOrganization();
    ClientBean cb = bean.getClient();
    ArrayList<ContractBean> contracts = Lists.newArrayList(storage.getAllContracts(orgBean.getId(), cb.getId(), bean.getVersion()));
    return determineStatus(bean, contracts);
}
Also used : ClientBean(io.apiman.manager.api.beans.clients.ClientBean) OrganizationBean(io.apiman.manager.api.beans.orgs.OrganizationBean) ContractBean(io.apiman.manager.api.beans.contracts.ContractBean)

Aggregations

OrganizationBean (io.apiman.manager.api.beans.orgs.OrganizationBean)49 StorageException (io.apiman.manager.api.core.exceptions.StorageException)20 ContractBean (io.apiman.manager.api.beans.contracts.ContractBean)14 ApiBean (io.apiman.manager.api.beans.apis.ApiBean)13 ApiVersionBean (io.apiman.manager.api.beans.apis.ApiVersionBean)13 NewOrganizationBean (io.apiman.manager.api.beans.orgs.NewOrganizationBean)13 PlanBean (io.apiman.manager.api.beans.plans.PlanBean)13 IOException (java.io.IOException)13 ApiPlanBean (io.apiman.manager.api.beans.apis.ApiPlanBean)12 ClientBean (io.apiman.manager.api.beans.clients.ClientBean)12 UpdateOrganizationBean (io.apiman.manager.api.beans.orgs.UpdateOrganizationBean)12 PlanVersionBean (io.apiman.manager.api.beans.plans.PlanVersionBean)10 Date (java.util.Date)10 ClientVersionBean (io.apiman.manager.api.beans.clients.ClientVersionBean)9 SystemErrorException (io.apiman.manager.api.rest.exceptions.SystemErrorException)9 GatewayAuthenticationException (io.apiman.manager.api.gateway.GatewayAuthenticationException)8 ApiVersionNotFoundException (io.apiman.manager.api.rest.exceptions.ApiVersionNotFoundException)8 ClientVersionNotFoundException (io.apiman.manager.api.rest.exceptions.ClientVersionNotFoundException)8 GatewayNotFoundException (io.apiman.manager.api.rest.exceptions.GatewayNotFoundException)8 EntityManager (javax.persistence.EntityManager)8