private byte[] exportRiskAnalyses() { if (!isRiskAnalysis()) { return null; } final RiskAnalysisExporter exporter = new RiskAnalysisExporter(); exporter.setCommandService(getCommandService()); exporter.setRiskAnalysisIdSet(riskAnalysisIdSet); exporter.run(); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); ExportFactory.marshal(exporter.getRisk(), bos); return bos.toByteArray(); }
/** * Export (i.e. "create XML representation of" the given cnATreeElement and its successors. For * this, child elements are exported recursively. All elements that have been processed are * returned as a list of {@code syncObject}s with their respective attributes, represented as * {@code syncAttribute}s. * * @return XML representation of elements * @throws CommandException */ private byte[] export() throws CommandException { if (getLog().isInfoEnabled()) { getLog().info("Max number of threads is: " + getMaxNumberOfThreads()); } getCache().removeAll(); final SyncVnaSchemaVersion formatVersion = createVersionData(); final SyncData syncData = new SyncData(); final ExportTransaction exportTransaction = new ExportTransaction(); for (final CnATreeElement element : elements) { exportTransaction.setElement(element); exportElement(exportTransaction); syncData.getSyncObject().add(exportTransaction.getTarget()); } exportLinks(syncData); if (getLog().isDebugEnabled()) { final Statistics s = getCache().getStatistics(); getLog().debug("Cache size: " + s.getObjectCount() + ", hits: " + s.getCacheHits()); } final SyncMapping syncMapping = new SyncMapping(); createMapping(syncMapping.getMapObjectType()); final SyncRequest syncRequest = new SyncRequest(); syncRequest.setSourceId(sourceId); syncRequest.setSyncData(syncData); syncRequest.setSyncMapping(syncMapping); syncRequest.setSyncVnaSchemaVersion(formatVersion); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); ExportFactory.marshal(syncRequest, bos); return bos.toByteArray(); }