@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 {
                throw new SystemErrorException(Messages.i18n.format("InvalidApiDefinitionContentType", contentType)); //$NON-NLS-1$
            }
            apiService.setApiDefinition(organizationId, apiId, version, newDefinitionType, data);
            LOGGER.debug("Updated API definition for {0}", apiId); //$NON-NLS-1$
        } finally {
            IOUtils.closeQuietly(data);
        }
    }
REST layer for Organization

TODO(msavy): split this into multiple interfaces & impls (ApiResource, ClientAppResource, etc).

@author eric.wittmann@redhat.com
@author marc@blackparrotlabs.io
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/OrganizationResourceImpl.java