use of io.apiman.manager.api.beans.apis.ApiVersionBean in project apiman by apiman.
the class RestHelper method hideSensitiveDataFromApiVersionBean.
/**
* This method will hide sensitive data, such as created by, from the result
*
* @param apiVersionBean the apiVersionBean
* @return the apiVersionBean without sensitive data
*/
public static ApiVersionBean hideSensitiveDataFromApiVersionBean(ApiVersionBean apiVersionBean) {
ApiBean api = new ApiBean();
api.setId(apiVersionBean.getApi().getId());
api.setName(apiVersionBean.getApi().getName());
api.setDescription(apiVersionBean.getApi().getDescription());
OrganizationBean org = new OrganizationBean();
org.setId(apiVersionBean.getApi().getOrganization().getId());
org.setName(apiVersionBean.getApi().getOrganization().getName());
org.setDescription(apiVersionBean.getApi().getOrganization().getDescription());
api.setOrganization(org);
ApiVersionBean apiVersion = new ApiVersionBean();
apiVersion.setApi(api);
apiVersion.setStatus(apiVersionBean.getStatus());
apiVersion.setEndpointType(apiVersionBean.getEndpointType());
apiVersion.setEndpointContentType(apiVersionBean.getEndpointContentType());
apiVersion.setGateways(apiVersionBean.getGateways());
apiVersion.setPublicAPI(apiVersionBean.isPublicAPI());
apiVersion.setPlans(apiVersionBean.getPlans());
apiVersion.setVersion(apiVersionBean.getVersion());
apiVersion.setDefinitionType(apiVersionBean.getDefinitionType());
return apiVersion;
}
use of io.apiman.manager.api.beans.apis.ApiVersionBean in project apiman by apiman.
the class EsStorage method getApiVersion.
/**
* @see io.apiman.manager.api.core.IStorage#getApiVersion(java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public ApiVersionBean getApiVersion(String organizationId, String apiId, String version) throws StorageException {
Map<String, Object> source = getEntity(INDEX_MANAGER_POSTFIX_API_VERSION, id(organizationId, apiId, version));
if (source == null) {
return null;
}
ApiVersionBean bean = EsMarshalling.unmarshallApiVersion(source);
bean.setApi(getApi(organizationId, apiId));
return bean;
}
use of io.apiman.manager.api.beans.apis.ApiVersionBean in project apiman by apiman.
the class EsStorage method getAllApiVersions.
/**
* @see io.apiman.manager.api.core.IStorage#getAllApiVersions(java.lang.String, java.lang.String)
*/
@SuppressWarnings("nls")
@Override
public Iterator<ApiVersionBean> getAllApiVersions(String organizationId, String apiId) throws StorageException {
BoolQueryBuilder qb = QueryBuilders.boolQuery();
List<QueryBuilder> filter = qb.filter();
filter.add(QueryBuilders.termQuery("organizationId", organizationId));
filter.add(QueryBuilders.termQuery("apiId", apiId));
return getAll(INDEX_MANAGER_POSTFIX_API_VERSION, new // $NON-NLS-1$
IUnmarshaller<ApiVersionBean>() {
@Override
public ApiVersionBean unmarshal(Map<String, Object> source) {
return EsMarshalling.unmarshallApiVersion(source);
}
}, qb);
}
use of io.apiman.manager.api.beans.apis.ApiVersionBean in project apiman by apiman.
the class EsMarshallingTest method testMarshallApiVersionBean.
/**
* Test method for {@link io.apiman.manager.api.es.EsMarshalling#marshall(io.apiman.manager.api.beans.apis.ApiVersionBean)}.
*/
@Test
public void testMarshallApiVersionBean() throws Exception {
ApiVersionBean bean = createBean(ApiVersionBean.class);
XContentBuilder builder = EsMarshalling.marshall(bean);
Assert.assertEquals("{\"organizationId\":\"ID\",\"organizationName\":\"NAME\",\"apiId\":\"ID\",\"apiName\":\"NAME\",\"apiDescription\":\"DESCRIPTION\",\"version\":\"VERSION\",\"status\":\"Created\",\"createdBy\":\"CREATEDBY\",\"createdOn\":1,\"modifiedBy\":\"MODIFIEDBY\",\"modifiedOn\":1,\"publishedOn\":1,\"retiredOn\":1,\"publicAPI\":true,\"endpoint\":\"ENDPOINT\",\"endpointType\":\"rest\",\"endpointContentType\":\"json\",\"parsePayload\":true,\"disableKeysStrip\":true,\"definitionType\":\"None\",\"definitionUrl\":\"DEFINITIONURL\",\"gateways\":[{\"gatewayId\":\"GATEWAYID\"}],\"plans\":[{\"planId\":\"PLANID\",\"version\":\"VERSION\"}],\"endpointProperties\":{\"KEY-1\":\"VALUE-1\",\"KEY-2\":\"VALUE-2\"}}", Strings.toString(builder));
}
use of io.apiman.manager.api.beans.apis.ApiVersionBean in project apiman by apiman.
the class OrganizationResourceImpl method deleteApi.
/**
* @see IOrganizationResource#deleteApi(java.lang.String, java.lang.String)
*/
@Override
public void deleteApi(@PathParam("organizationId") String organizationId, @PathParam("apiId") String apiId) throws OrganizationNotFoundException, NotAuthorizedException, EntityStillActiveException {
securityContext.checkPermissions(PermissionType.apiAdmin, organizationId);
try {
storage.beginTx();
ApiBean api = getApiFromStorage(organizationId, apiId);
Iterator<ApiVersionBean> apiVersions = storage.getAllApiVersions(organizationId, apiId);
Iterable<ApiVersionBean> iterable = () -> apiVersions;
List<ApiVersionBean> apiVersionBeans = StreamSupport.stream(iterable.spliterator(), false).collect(toList());
List<ApiVersionBean> registeredElems = apiVersionBeans.stream().filter(clientVersion -> clientVersion.getStatus() == ApiStatus.Published).limit(5).collect(toList());
if (!registeredElems.isEmpty()) {
throw ExceptionFactory.entityStillActiveExceptionApiVersions(registeredElems);
}
for (ApiVersionBean apiVersion : apiVersionBeans) {
// add apiBean to apiVersionBean, otherwise deleteApiDefinition fails for EsStorage
apiVersion.setApi(api);
if (apiVersionHasApiDefinition(apiVersion)) {
storage.deleteApiDefinition(apiVersion);
}
}
storage.deleteApi(api);
storage.commitTx();
// $NON-NLS-1$
log.debug("Deleted API: " + api.getName());
} catch (AbstractRestException e) {
storage.rollbackTx();
throw e;
} catch (Exception e) {
storage.rollbackTx();
throw new SystemErrorException(e);
}
}
Aggregations