/** * @see io.apiman.manager.api.core.IStorage#rollbackTx() */ @Override public void rollbackTx() { this.delegate.rollbackTx(); }
/** * @see io.apiman.manager.api.exportimport.read.IImportReaderDispatcher#cancel() */ @Override public void cancel() { this.storage.rollbackTx(); }
/** * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) */ @Override public void init(FilterConfig filterConfig) throws ServletException { String seederClass = System.getProperty(ISeeder.SYSTEM_PROPERTY, DefaultTestDataSeeder.class.getName()); try { ISeeder seeder = (ISeeder) Class.forName(seederClass).newInstance(); storage.beginTx(); seeder.seed(storage); storage.commitTx(); } catch (Exception e) { e.printStackTrace(); storage.rollbackTx(); throw new ServletException(e); } }
/** * @see io.apiman.manager.api.rest.contract.ISearchResource#searchApis(io.apiman.manager.api.beans.search.SearchCriteriaBean) */ @Override public SearchResultsBean<ApiSummaryBean> searchApis(SearchCriteriaBean criteria) throws OrganizationNotFoundException, InvalidSearchCriteriaException { SearchCriteriaUtil.validateSearchCriteria(criteria); try { return query.findApis(criteria); } catch (StorageException e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
/** * @see io.apiman.manager.api.rest.contract.IPolicyDefinitionResource#get(java.lang.String) */ @Override public PolicyDefinitionBean get(String policyDefinitionId) throws PolicyDefinitionNotFoundException, NotAuthorizedException { try { storage.beginTx(); PolicyDefinitionBean bean = storage.getPolicyDefinition(policyDefinitionId); if (bean == null) { throw ExceptionFactory.policyDefNotFoundException(policyDefinitionId); } storage.commitTx(); return bean; } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
/** * @see io.apiman.manager.api.rest.contract.ISearchResource#searchApis(io.apiman.manager.api.beans.search.SearchCriteriaBean) */ @Override public SearchResultsBean<ApiSummaryBean> searchApis(SearchCriteriaBean criteria) throws OrganizationNotFoundException, InvalidSearchCriteriaException { SearchCriteriaUtil.validateSearchCriteria(criteria); try { return query.findApis(criteria); } catch (StorageException e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#getApi(java.lang.String, java.lang.String) */ @Override public ApiBean getApi(String organizationId, String apiId) throws ApiNotFoundException, NotAuthorizedException { try { storage.beginTx(); ApiBean bean = storage.getApi(organizationId, apiId); if (bean == null) { throw ExceptionFactory.apiNotFoundException(apiId); } storage.commitTx(); return bean; } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#getPlanVersion(java.lang.String, java.lang.String, java.lang.String) */ @Override public PlanVersionBean getPlanVersion(String organizationId, String planId, String version) throws PlanVersionNotFoundException, NotAuthorizedException { try { storage.beginTx(); PlanVersionBean planVersion = storage.getPlanVersion(organizationId, planId, version); if (planVersion == null) { throw ExceptionFactory.planVersionNotFoundException(planId, version); } storage.commitTx(); log.debug(String.format("Got plan %s version: %s", planId, planVersion)); //$NON-NLS-1$ return planVersion; } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#getClientVersionContracts(java.lang.String, java.lang.String, java.lang.String) */ @Override public List<ContractSummaryBean> getClientVersionContracts(String organizationId, String clientId, String version) throws ClientNotFoundException, NotAuthorizedException { // Try to get the client first - will throw a ClientNotFoundException if not found. getClientVersion(organizationId, clientId, version); try { List<ContractSummaryBean> contracts = query.getClientContracts(organizationId, clientId, version); return contracts; } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { throw new SystemErrorException(e); } }
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#getClientVersionContracts(java.lang.String, java.lang.String, java.lang.String) */ @Override public List<ContractSummaryBean> getClientVersionContracts(String organizationId, String clientId, String version) throws ClientNotFoundException, NotAuthorizedException { // Try to get the client first - will throw a ClientNotFoundException if not found. getClientVersion(organizationId, clientId, version); try { List<ContractSummaryBean> contracts = query.getClientContracts(organizationId, clientId, version); return contracts; } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { throw new SystemErrorException(e); } }
/** * @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); } }
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#getContract(java.lang.String, java.lang.String, java.lang.String, java.lang.Long) */ @Override public ContractBean getContract(String organizationId, String clientId, String version, Long contractId) throws ClientNotFoundException, ContractNotFoundException, NotAuthorizedException { try { storage.beginTx(); ContractBean contract = storage.getContract(contractId); if (contract == null) throw ExceptionFactory.contractNotFoundException(contractId); storage.commitTx(); log.debug(String.format("Got contract %s: %s", contract.getId(), contract)); //$NON-NLS-1$ return contract; } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#getClient(java.lang.String, java.lang.String) */ @Override public ClientBean getClient(String organizationId, String clientId) throws ClientNotFoundException, NotAuthorizedException { try { storage.beginTx(); ClientBean clientBean = storage.getClient(organizationId, clientId); if (clientBean == null) { throw ExceptionFactory.clientNotFoundException(clientId); } storage.commitTx(); log.debug(String.format("Got client %s: %s", clientBean.getName(), clientBean)); //$NON-NLS-1$ return clientBean; } catch (AbstractRestException e) { storage.rollbackTx(); throw e; } catch (Exception e) { storage.rollbackTx(); throw new SystemErrorException(e); } }
/** * @see io.apiman.manager.api.core.IDownloadManager#createDownload(io.apiman.manager.api.beans.download.DownloadType, java.lang.String) */ @Override public DownloadBean createDownload(DownloadType type, String path) throws StorageException { DownloadBean download = new DownloadBean(); download.setExpires(new Date(System.currentTimeMillis() + DEFAULT_EXPIRES_LENGTH)); download.setId(UUID.randomUUID().toString()); download.setType(type); download.setPath(path); storage.beginTx(); try { storage.createDownload(download); storage.commitTx(); } catch (StorageException e) { storage.rollbackTx(); throw e; } return download; }
/** * @see io.apiman.manager.api.rest.contract.IUserResource#get(java.lang.String) */ @Override public UserBean get(String userId) throws UserNotFoundException { try { storage.beginTx(); UserBean user = storage.getUser(userId); if (user == null) { throw ExceptionFactory.userNotFoundException(userId); } return user; } catch (StorageException e) { throw new SystemErrorException(e); } finally { storage.rollbackTx(); } }
/** * @see io.apiman.manager.api.rest.contract.IUserResource#get(java.lang.String) */ @Override public UserBean get(String userId) throws UserNotFoundException { try { storage.beginTx(); UserBean user = storage.getUser(userId); if (user == null) { throw ExceptionFactory.userNotFoundException(userId); } return user; } catch (StorageException e) { throw new SystemErrorException(e); } finally { storage.rollbackTx(); } }
/** * @see io.apiman.manager.api.rest.contract.IRoleResource#get(java.lang.String) */ @Override public RoleBean get(String roleId) throws RoleNotFoundException, NotAuthorizedException { try { getStorage().beginTx(); RoleBean role = getStorage().getRole(roleId); if (role == null) { throw ExceptionFactory.roleNotFoundException(roleId); } return role; } catch (StorageException e) { throw new SystemErrorException(e); } finally { getStorage().rollbackTx(); } }
/** * @see io.apiman.manager.api.rest.contract.IRoleResource#get(java.lang.String) */ @Override public RoleBean get(String roleId) throws RoleNotFoundException, NotAuthorizedException { try { getStorage().beginTx(); RoleBean role = getStorage().getRole(roleId); if (role == null) { throw ExceptionFactory.roleNotFoundException(roleId); } return role; } catch (StorageException e) { throw new SystemErrorException(e); } finally { getStorage().rollbackTx(); } }
/** * @see io.apiman.manager.api.rest.contract.IRoleResource#delete(java.lang.String) */ @Override public void delete(String roleId) throws RoleNotFoundException, NotAuthorizedException { if (!securityContext.isAdmin()) throw ExceptionFactory.notAuthorizedException(); RoleBean bean = get(roleId); try { getStorage().beginTx(); getStorage().deleteRole(bean); getStorage().commitTx(); } catch (StorageException e) { getStorage().rollbackTx(); throw new SystemErrorException(e); } }
/** * @see io.apiman.manager.api.rest.contract.IRoleResource#delete(java.lang.String) */ @Override public void delete(String roleId) throws RoleNotFoundException, NotAuthorizedException { if (!securityContext.isAdmin()) throw ExceptionFactory.notAuthorizedException(); RoleBean bean = get(roleId); try { getStorage().beginTx(); getStorage().deleteRole(bean); getStorage().commitTx(); } catch (StorageException e) { getStorage().rollbackTx(); throw new SystemErrorException(e); } }