@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((ctlSchemaId == null) ? 0 : ctlSchemaId.hashCode()); result = prime * result + ((exportMethod == null) ? 0 : exportMethod.hashCode()); return result; }
/** * Exports a CTL schema and all of its dependencies depending on the export method specified. */ public FileData downloadCtlSchemaByAppToken(CTLSchemaDto ctlSchemaDto, CTLSchemaExportMethod method, String appToken) { final FileDataResponseExtractor extractor = new FileDataResponseExtractor(); MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>(); parameters.add("fqn", ctlSchemaDto.getMetaInfo().getFqn()); parameters.add("version", Integer.toString(ctlSchemaDto.getVersion())); if (ctlSchemaDto.getMetaInfo().getApplicationId() != null) { parameters.add("applicationToken", appToken); } parameters.add("method", method.name()); RequestCallback request = new DataRequestCallback<>(parameters); return restTemplate.execute(restTemplate.getUrl() + "CTL/exportSchema", HttpMethod.POST, request, extractor); }
try { FileData output = ctlService.exportCtlSchemaByAppToken( fqn, version, applicationToken, CTLSchemaExportMethod.valueOf(method.toUpperCase())); ServletUtils.prepareDisposition(request, response, output.getFileName()); response.setContentType(output.getContentType());
@Override @Cacheable(CTL_CACHE) public FileData getExportedCtlSchema(CtlSchemaExportKey key) throws KaaAdminServiceException { try { CTLSchemaDto schemaFound = controlService.getCtlSchemaById(key.getCtlSchemaId()); Utils.checkNotNull(schemaFound); switch (key.getExportMethod()) { case SHALLOW: return controlService.exportCtlSchemaShallow(schemaFound); case FLAT: return controlService.exportCtlSchemaFlat(schemaFound); case DEEP: return controlService.exportCtlSchemaDeep(schemaFound); case LIBRARY: return controlService.exportCtlSchemaFlatAsLibrary(schemaFound); default: throw new IllegalArgumentException( "The export method " + key.getExportMethod().name() + " is not currently supported!"); } } catch (ControlServiceException ex) { throw Utils.handleException(ex); } }
@Override public FileData exportCtlSchema(String fqn, int version, String applicationId, CTLSchemaExportMethod method) throws KaaAdminServiceException { try { this.checkCtlSchemaFqn(fqn); this.checkCtlSchemaVersion(version); String tenantId = getCurrentUser().getTenantId(); CTLSchemaDto schemaFound = controlService.getCtlSchemaByFqnVersionTenantIdAndApplicationId( fqn, version, tenantId, applicationId); Utils.checkNotNull(schemaFound); checkCtlSchemaReadScope( schemaFound.getMetaInfo().getTenantId(), schemaFound.getMetaInfo().getApplicationId()); switch (method) { case SHALLOW: return controlService.exportCtlSchemaShallow(schemaFound); case FLAT: return controlService.exportCtlSchemaFlat(schemaFound); case DEEP: return controlService.exportCtlSchemaDeep(schemaFound); default: throw new IllegalArgumentException( "The export method " + method.name() + " is not currently supported!"); } } catch (Exception cause) { throw Utils.handleException(cause); } }