/** * @see io.apiman.manager.api.core.IStorage#updateApiDefinition(io.apiman.manager.api.beans.apis.ApiVersionBean, java.io.InputStream) */ @Override public void updateApiDefinition(ApiVersionBean version, InputStream definitionStream) throws StorageException { delegate.updateApiDefinition(version, definitionStream); }
protected void storeApiDefinition(String organizationId, String apiId, String version, ApiDefinitionType definitionType, InputStream data) { if (!securityContext.hasPermission(PermissionType.apiEdit, organizationId)) throw ExceptionFactory.notAuthorizedException(); try { storage.beginTx(); ApiVersionBean apiVersion = storage.getApiVersion(organizationId, apiId, version); if (apiVersion == null) { throw ExceptionFactory.apiVersionNotFoundException(apiId, version); } if (apiVersion.getDefinitionType() != definitionType) { apiVersion.setDefinitionType(definitionType); storage.updateApiVersion(apiVersion); } storage.createAuditEntry(AuditUtils.apiDefinitionUpdated(apiVersion, securityContext)); storage.updateApiDefinition(apiVersion, data); apiVersion.setModifiedOn(new Date()); apiVersion.setModifiedBy(securityContext.getCurrentUser()); storage.updateApiVersion(apiVersion); storage.commitTx(); log.debug(String.format("Stored API definition %s: %s", apiId, apiVersion)); //$NON-NLS-1$ } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
protected void storeApiDefinition(String organizationId, String apiId, String version, ApiDefinitionType definitionType, InputStream data) { if (!securityContext.hasPermission(PermissionType.apiEdit, organizationId)) throw ExceptionFactory.notAuthorizedException(); try { storage.beginTx(); ApiVersionBean apiVersion = storage.getApiVersion(organizationId, apiId, version); if (apiVersion == null) { throw ExceptionFactory.apiVersionNotFoundException(apiId, version); } if (apiVersion.getDefinitionType() != definitionType) { apiVersion.setDefinitionType(definitionType); storage.updateApiVersion(apiVersion); } storage.createAuditEntry(AuditUtils.apiDefinitionUpdated(apiVersion, securityContext)); storage.updateApiDefinition(apiVersion, data); apiVersion.setModifiedOn(new Date()); apiVersion.setModifiedBy(securityContext.getCurrentUser()); storage.updateApiVersion(apiVersion); storage.commitTx(); log.debug(String.format("Stored API definition %s: %s", apiId, apiVersion)); //$NON-NLS-1$ } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
try { definition = new URL(bean.getDefinitionUrl()).openStream(); storage.updateApiDefinition(newVersion, definition); } catch (Exception e) { log.error("Unable to store API definition from: " + bean.getDefinitionUrl(), e); //$NON-NLS-1$
try { definition = new URL(bean.getDefinitionUrl()).openStream(); storage.updateApiDefinition(newVersion, definition); } catch (Exception e) { log.error("Unable to store API definition from: " + bean.getDefinitionUrl(), e); //$NON-NLS-1$