Examples of ExporterMessages


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

     * @param syn
     * @return
     * @throws XMLStreamException
     */
    private void exportSingle(XMLStreamWriter wrt, Synchronizer<?, ?> syn) throws XMLStreamException {
        ExporterMessages messages = new ExporterMessages();

        messagesPerExporter.put(syn.getClass().getName(), messages);

        wrt.writeStartElement(SynchronizationConstants.EXPORT_NAMESPACE, SynchronizationConstants.ENTITIES_EXPORT_ELEMENT);
        wrt.writeAttribute(SynchronizationConstants.ID_ATTRIBUTE, syn.getClass().getName());

        Exporter<?, ?> exp = syn.getExporter();
        ExportingIterator<?> it = exp.getExportingIterator();

        DefaultImportConfigurationDescriptor importConfig = getDefaultImportConfiguraton(syn);

        if (importConfig != null) {
            try {
                configurationMarshaller.marshal(importConfig, wrt);
            } catch (JAXBException e) {
                throw new XMLStreamException(e);
            }
        }

        messages.setPerEntityErrorMessages(new ArrayList<String>());
        messages.setPerEntityNotes(new ArrayList<String>());

        while (it.hasNext()) {
            it.next();

            wrt.writeStartElement(SynchronizationConstants.EXPORT_NAMESPACE, SynchronizationConstants.ENTITY_EXPORT_ELEMENT);

            wrt.writeStartElement(SynchronizationConstants.EXPORT_NAMESPACE, SynchronizationConstants.DATA_ELEMENT);

            Exception exportError = null;
            try {
                it.export(new ExportWriter(wrt));
            } catch (XMLStreamException e) {
                //there's not much we can do about these but to give up.
                throw e;
            } catch (Exception e) {
                exportError = e;
            }

            wrt.writeEndElement(); //data

            if (exportError == null) {
                String notes = it.getNotes();

                if (notes != null) {
                    messages.getPerEntityNotes().add(notes);
                    wrt.writeStartElement(SynchronizationConstants.EXPORT_NAMESPACE, SynchronizationConstants.NOTES_ELEMENT);
                    wrt.writeCharacters(notes);
                    wrt.writeEndElement();
                }
            } else {
                String message = ThrowableUtil.getStackAsString(exportError);
                messages.getPerEntityErrorMessages().add(message);
                wrt.writeStartElement(SynchronizationConstants.EXPORT_NAMESPACE, SynchronizationConstants.ERROR_MESSAGE_ELEMENT);
                wrt.writeCharacters(message);
                wrt.writeEndElement();
            }

            wrt.writeEndElement(); //entity
        }

        String notes = exp.getNotes();

        messages.setExporterNotes(notes);

        if (notes != null) {
            wrt.writeStartElement(SynchronizationConstants.EXPORT_NAMESPACE, SynchronizationConstants.NOTES_ELEMENT);
            wrt.writeCharacters(notes);
            wrt.writeEndElement();
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.