/** * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((organization == null) ? 0 : organization.getId().hashCode()); return result; }
for (OrganizationBean bean : qr) { OrganizationSummaryBean summary = new OrganizationSummaryBean(); summary.setId(bean.getId()); summary.setName(bean.getName()); summary.setDescription(bean.getDescription()); orgs.add(summary);
/** * Unmarshals the given map source into a bean. * @param source the source * @return the organization */ public static OrganizationBean unmarshallOrganization(Map<String, Object> source) { if (source == null) { return null; } OrganizationBean bean = new OrganizationBean(); bean.setId(asString(source.get("id"))); bean.setName(asString(source.get("name"))); bean.setDescription(asString(source.get("description"))); bean.setCreatedOn(asDate(source.get("createdOn"))); bean.setCreatedBy(asString(source.get("createdBy"))); bean.setModifiedOn(asDate(source.get("modifiedOn"))); bean.setModifiedBy(asString(source.get("modifiedBy"))); postMarshall(bean); return bean; }
/** * Marshals the given bean into the given map. * @param bean the bean * @return the content builder * @throws StorageException when a storage problem occurs while storing a bean */ public static XContentBuilder marshall(OrganizationBean bean) throws StorageException { try (XContentBuilder builder = XContentFactory.jsonBuilder()) { preMarshall(bean); builder .startObject() .field("id", bean.getId()) .field("name", bean.getName()) .field("description", bean.getDescription()) .field("createdBy", bean.getCreatedBy()) .field("createdOn", bean.getCreatedOn().getTime()) .field("modifiedBy", bean.getModifiedBy()) .field("modifiedOn", bean.getModifiedOn().getTime()) .endObject(); postMarshall(bean); return builder; } catch (IOException e) { throw new StorageException(e); } }
/** * @see io.apiman.manager.api.exportimport.read.IImportReaderDispatcher#clientContract(io.apiman.manager.api.beans.contracts.ContractBean) */ @Override public void clientContract(ContractBean contract) { ClientVersionBean avb = new ClientVersionBean(); avb.setClient(new ClientBean()); avb.getClient().setOrganization(new OrganizationBean()); avb.getClient().setId(currentClient.getId()); avb.getClient().getOrganization().setId(currentOrg.getId()); avb.setVersion(currentClientVersion.getVersion()); contract.setClient(avb); contracts.add(contract); }
if (AuditUtils.valueChanged(orgForUpdate.getDescription(), bean.getDescription())) { auditData.addChange("description", orgForUpdate.getDescription(), bean.getDescription()); //$NON-NLS-1$ orgForUpdate.setDescription(bean.getDescription()); log.debug(String.format("Updated organization %s: %s", orgForUpdate.getName(), orgForUpdate)); //$NON-NLS-1$ } catch (AbstractRestException e) { storage.rollbackTx();
/** * @see io.apiman.manager.api.exportimport.read.IImportReaderDispatcher#organization(io.apiman.manager.api.beans.orgs.OrganizationBean) */ @Override public void organization(OrganizationBean org) { currentOrg = org; try { logger.info(Messages.i18n.format("StorageImportDispatcher.ImportingOrg") + org.getName()); //$NON-NLS-1$ storage.createOrganization(org); } catch (StorageException e) { error(e); } }
@Override public ContractBean unmarshal(Map<String, Object> source) { ContractBean contract = EsMarshalling.unmarshallContract(source); String apiOrgId = (String) source.get("apiOrganizationId"); String apiId = (String) source.get("apiId"); String apiVersion = (String) source.get("apiVersion"); String planId = (String) source.get("planId"); String planVersion = (String) source.get("planVersion"); ApiVersionBean svb = new ApiVersionBean(); svb.setVersion(apiVersion); svb.setApi(new ApiBean()); svb.getApi().setOrganization(new OrganizationBean()); svb.getApi().setId(apiId); svb.getApi().getOrganization().setId(apiOrgId); PlanVersionBean pvb = new PlanVersionBean(); pvb.setVersion(planVersion); pvb.setPlan(new PlanBean()); pvb.getPlan().setOrganization(new OrganizationBean()); pvb.getPlan().setId(planId); pvb.getPlan().getOrganization().setId(apiOrgId); contract.setPlan(pvb); contract.setApi(svb); return contract; } }, query);
/** * Marshals the given bean into the given map. * @param bean the bean * @return the content builder * @throws StorageException when a storage problem occurs while storing a bean */ public static XContentBuilder marshall(OrganizationBean bean) throws StorageException { try (XContentBuilder builder = XContentFactory.jsonBuilder()) { preMarshall(bean); builder .startObject() .field("id", bean.getId()) .field("name", bean.getName()) .field("description", bean.getDescription()) .field("createdBy", bean.getCreatedBy()) .field("createdOn", bean.getCreatedOn().getTime()) .field("modifiedBy", bean.getModifiedBy()) .field("modifiedOn", bean.getModifiedOn().getTime()) .endObject(); postMarshall(bean); return builder; } catch (IOException e) { throw new StorageException(e); } }
/** * @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; }
if (AuditUtils.valueChanged(orgForUpdate.getDescription(), bean.getDescription())) { auditData.addChange("description", orgForUpdate.getDescription(), bean.getDescription()); //$NON-NLS-1$ orgForUpdate.setDescription(bean.getDescription()); log.debug(String.format("Updated organization %s: %s", orgForUpdate.getName(), orgForUpdate)); //$NON-NLS-1$ } catch (AbstractRestException e) { storage.rollbackTx();
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#get(java.lang.String) */ @Override public OrganizationBean get(String organizationId) throws OrganizationNotFoundException, NotAuthorizedException { try { storage.beginTx(); OrganizationBean organizationBean = storage.getOrganization(organizationId); if (organizationBean == null) { throw ExceptionFactory.organizationNotFoundException(organizationId); } storage.commitTx(); log.debug(String.format("Got organization %s: %s", organizationBean.getName(), organizationBean)); //$NON-NLS-1$ return organizationBean; } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
@Override public ContractBean unmarshal(Map<String, Object> source) { ContractBean contract = EsMarshalling.unmarshallContract(source); String apiOrgId = (String) source.get("apiOrganizationId"); String apiId = (String) source.get("apiId"); String apiVersion = (String) source.get("apiVersion"); String planId = (String) source.get("planId"); String planVersion = (String) source.get("planVersion"); ApiVersionBean svb = new ApiVersionBean(); svb.setVersion(apiVersion); svb.setApi(new ApiBean()); svb.getApi().setOrganization(new OrganizationBean()); svb.getApi().setId(apiId); svb.getApi().getOrganization().setId(apiOrgId); PlanVersionBean pvb = new PlanVersionBean(); pvb.setVersion(planVersion); pvb.setPlan(new PlanBean()); pvb.getPlan().setOrganization(new OrganizationBean()); pvb.getPlan().setId(planId); pvb.getPlan().getOrganization().setId(apiOrgId); contract.setPlan(pvb); contract.setApi(svb); return contract; } }, query);
/** * Unmarshals the given map source into a bean. * @param source the source * @return the organization */ public static OrganizationBean unmarshallOrganization(Map<String, Object> source) { if (source == null) { return null; } OrganizationBean bean = new OrganizationBean(); bean.setId(asString(source.get("id"))); bean.setName(asString(source.get("name"))); bean.setDescription(asString(source.get("description"))); bean.setCreatedOn(asDate(source.get("createdOn"))); bean.setCreatedBy(asString(source.get("createdBy"))); bean.setModifiedOn(asDate(source.get("modifiedOn"))); bean.setModifiedBy(asString(source.get("modifiedBy"))); postMarshall(bean); return bean; }
/** * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((organization == null) ? 0 : organization.getId().hashCode()); return result; }
for (OrganizationBean bean : qr) { OrganizationSummaryBean summary = new OrganizationSummaryBean(); summary.setId(bean.getId()); summary.setName(bean.getName()); summary.setDescription(bean.getDescription()); orgs.add(summary);
/** * @param plan */ private PlanVersionBean minifyPlan(PlanVersionBean plan) { PlanVersionBean rval = new PlanVersionBean(); rval.setVersion(plan.getVersion()); rval.setPlan(new PlanBean()); rval.getPlan().setId(plan.getPlan().getId()); rval.getPlan().setOrganization(new OrganizationBean()); rval.getPlan().getOrganization().setId(plan.getPlan().getOrganization().getId()); return rval; }