/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#getApiRegistryJSON(java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ @Override public Response getApiRegistryJSON(String organizationId, String clientId, String version, String download) throws ClientNotFoundException, NotAuthorizedException { boolean hasPermission = securityContext.hasPermission(PermissionType.clientView, organizationId); if ("true".equals(download)) { //$NON-NLS-1$ try { String path = String.format("%s/%s/%s/%s", organizationId, clientId, version, (hasPermission ? '+' : '-' )); //$NON-NLS-1$ DownloadBean dbean = downloadManager.createDownload(DownloadType.apiRegistryJson, path); return Response.ok(dbean, MediaType.APPLICATION_JSON).build(); } catch (StorageException e) { throw new SystemErrorException(e); } } else { return getApiRegistryJSON(organizationId, clientId, version, hasPermission); } }
/** * @see io.apiman.manager.api.rest.contract.IDownloadResource#download(java.lang.String) */ @Override public Response download(String downloadId) throws DownloadNotFoundException { DownloadBean download; try { download = downloadManager.getDownload(downloadId); if (download == null) { throw new DownloadNotFoundException(); } } catch (StorageException e) { throw new DownloadNotFoundException(e); } String path = download.getPath(); ApiRegistryInfo info; switch (download.getType()) { case apiRegistryJson: info = parseApiRegistryPath(path); return orgs.getApiRegistryJSON(info.organizationId, info.clientId, info.version, info.hasPermission); case apiRegistryXml: info = parseApiRegistryPath(path); return orgs.getApiRegistryXML(info.organizationId, info.clientId, info.version, info.hasPermission); case exportJson: return system.exportData(); default: throw new DownloadNotFoundException(); } }
/** * @see io.apiman.manager.api.rest.contract.IDownloadResource#download(java.lang.String) */ @Override public Response download(String downloadId) throws DownloadNotFoundException { DownloadBean download; try { download = downloadManager.getDownload(downloadId); if (download == null) { throw new DownloadNotFoundException(); } } catch (StorageException e) { throw new DownloadNotFoundException(e); } String path = download.getPath(); ApiRegistryInfo info; switch (download.getType()) { case apiRegistryJson: info = parseApiRegistryPath(path); return orgs.getApiRegistryJSON(info.organizationId, info.clientId, info.version, info.hasPermission); case apiRegistryXml: info = parseApiRegistryPath(path); return orgs.getApiRegistryXML(info.organizationId, info.clientId, info.version, info.hasPermission); case exportJson: return system.exportData(); default: throw new DownloadNotFoundException(); } }
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#getApiRegistryXML(java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ @Override public Response getApiRegistryXML(String organizationId, String clientId, String version, String download) throws ClientNotFoundException, NotAuthorizedException { boolean hasPermission = securityContext.hasPermission(PermissionType.clientView, organizationId); if ("true".equals(download)) { //$NON-NLS-1$ try { String path = String.format("%s/%s/%s/%s", organizationId, clientId, version, (hasPermission ? '+' : '-' )); //$NON-NLS-1$ DownloadBean dbean = downloadManager.createDownload(DownloadType.apiRegistryXml, path); return Response.ok(dbean, MediaType.APPLICATION_JSON).build(); } catch (StorageException e) { throw new SystemErrorException(e); } } else { return getApiRegistryXML(organizationId, clientId, version, hasPermission); } }
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#getApiRegistryXML(java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ @Override public Response getApiRegistryXML(String organizationId, String clientId, String version, String download) throws ClientNotFoundException, NotAuthorizedException { boolean hasPermission = securityContext.hasPermission(PermissionType.clientView, organizationId); if ("true".equals(download)) { //$NON-NLS-1$ try { String path = String.format("%s/%s/%s/%s", organizationId, clientId, version, (hasPermission ? '+' : '-' )); //$NON-NLS-1$ DownloadBean dbean = downloadManager.createDownload(DownloadType.apiRegistryXml, path); return Response.ok(dbean, MediaType.APPLICATION_JSON).build(); } catch (StorageException e) { throw new SystemErrorException(e); } } else { return getApiRegistryXML(organizationId, clientId, version, hasPermission); } }
/** * @see io.apiman.manager.api.rest.contract.IOrganizationResource#getApiRegistryJSON(java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ @Override public Response getApiRegistryJSON(String organizationId, String clientId, String version, String download) throws ClientNotFoundException, NotAuthorizedException { boolean hasPermission = securityContext.hasPermission(PermissionType.clientView, organizationId); if ("true".equals(download)) { //$NON-NLS-1$ try { String path = String.format("%s/%s/%s/%s", organizationId, clientId, version, (hasPermission ? '+' : '-' )); //$NON-NLS-1$ DownloadBean dbean = downloadManager.createDownload(DownloadType.apiRegistryJson, path); return Response.ok(dbean, MediaType.APPLICATION_JSON).build(); } catch (StorageException e) { throw new SystemErrorException(e); } } else { return getApiRegistryJSON(organizationId, clientId, version, hasPermission); } }
/** * @see io.apiman.manager.api.rest.contract.ISystemResource#exportData(java.lang.String) */ @Override public Response exportData(String download) { if (BooleanUtils.toBoolean(download)) { try { DownloadBean dbean = downloadManager.createDownload(DownloadType.exportJson, "/system/export"); //$NON-NLS-1$ return Response.ok(dbean, MediaType.APPLICATION_JSON).build(); } catch (StorageException e) { throw new SystemErrorException(e); } } else { if (!securityContext.isAdmin()) throw ExceptionFactory.notAuthorizedException(); return exportData(); } }
/** * @see io.apiman.manager.api.rest.contract.ISystemResource#exportData(java.lang.String) */ @Override public Response exportData(String download) { if (BooleanUtils.toBoolean(download)) { try { DownloadBean dbean = downloadManager.createDownload(DownloadType.exportJson, "/system/export"); //$NON-NLS-1$ return Response.ok(dbean, MediaType.APPLICATION_JSON).build(); } catch (StorageException e) { throw new SystemErrorException(e); } } else { if (!securityContext.isAdmin()) throw ExceptionFactory.notAuthorizedException(); return exportData(); } }