use of io.apiman.manager.api.beans.apis.ApiDefinitionType in project apiman by apiman.
the class OrganizationResourceImpl method updateApiDefinition.
@Override
public void updateApiDefinition(String organizationId, String apiId, String version) throws ApiVersionNotFoundException, NotAuthorizedException, InvalidApiStatusException {
securityContext.checkPermissions(PermissionType.apiEdit, organizationId);
String contentType = request.getContentType();
InputStream data;
try {
data = request.getInputStream();
} catch (IOException e) {
throw new SystemErrorException(e);
}
try {
ApiDefinitionType newDefinitionType;
if (contentType.toLowerCase().contains("application/json")) {
// $NON-NLS-1$
newDefinitionType = ApiDefinitionType.SwaggerJSON;
} else if (contentType.toLowerCase().contains("application/x-yaml")) {
// $NON-NLS-1$
newDefinitionType = ApiDefinitionType.SwaggerYAML;
} else if (contentType.toLowerCase().contains("application/wsdl+xml")) {
// $NON-NLS-1$
newDefinitionType = ApiDefinitionType.WSDL;
} else {
// $NON-NLS-1$
throw new SystemErrorException(Messages.i18n.format("InvalidApiDefinitionContentType", contentType));
}
apiService.setApiDefinition(organizationId, apiId, version, newDefinitionType, data);
// $NON-NLS-1$
LOGGER.debug("Updated API definition for {0}", apiId);
} finally {
IOUtils.closeQuietly(data);
}
}
Aggregations