Examples of ExportWrapper


Examples of org.rhq.core.domain.sync.ExportWrapper

    }
   
    @Override
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public ExportReport exportAllSubsystems(Subject subject) {
        ExportWrapper localExport = exportAllSubsystemsLocally(subject);

        byte[] buffer = new byte[65536];

        ByteArrayOutputStream out = new ByteArrayOutputStream(10240); //10KB is a reasonable minimum size of an export

        try {
            int cnt = 0;
            while ((cnt = localExport.getExportFile().read(buffer)) != -1) {
                out.write(buffer, 0, cnt);
            }

            return new ExportReport(localExport.getMessagesPerExporter(), out.toByteArray());
        } catch (Exception e) {
            return new ExportReport(e.getMessage());
        } finally {
            try {
                out.close();
            } catch (Exception e) {
                //this doesn't happen - out is backed by just an array
                LOG.error("Closing a byte array output stream failed. This should never happen.");
            }

            try {
                localExport.getExportFile().close();
            } catch (Exception e) {
                LOG.warn("Failed to close the export file stream.", e);
            }
        }
    }
View Full Code Here

Examples of org.rhq.core.domain.sync.ExportWrapper

    public ExportWrapper exportAllSubsystemsLocally(Subject subject) {
        Set<Synchronizer<?, ?>> allSynchronizers = getInitializedSynchronizers(subject);
        Map<String, ExporterMessages> messages = new HashMap<String, ExporterMessages>();

        try {
            return new ExportWrapper(messages, new ExportingInputStream(allSynchronizers, messages));
        } catch (IOException e) {
            throw new IllegalStateException("Failed to initialize the export.", e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.