use of javax.xml.bind.Marshaller in project Activiti by Activiti.
the class AlfrescoArtifactExporter method writeShareConfig.
/**
* Write the Share module XML in the given conversion to the given stream.
*/
public void writeShareConfig(OutputStream out, WorkflowDefinitionConversion conversion, boolean asExtension) throws IOException {
Extension extension = AlfrescoConversionUtil.getExtension(conversion);
try {
Object toMarshall = extension;
// in a "alfresco-configuration" element instead
if (!asExtension) {
toMarshall = new AlfrescoConfiguration();
((AlfrescoConfiguration) toMarshall).setConfigurations(extension.getModules().get(0).getConfigurations());
}
Marshaller marshaller = moduleJaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.marshal(toMarshall, out);
} catch (JAXBException jaxbe) {
throw new IOException(jaxbe);
}
}
use of javax.xml.bind.Marshaller in project Activiti by Activiti.
the class AlfrescoArtifactExporter method writeContentModel.
/**
* Write the content model XML in the given conversion to the given stream.
*/
public void writeContentModel(OutputStream out, WorkflowDefinitionConversion conversion) throws IOException {
M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
try {
Marshaller marshaller = modelJaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.marshal(model, out);
} catch (JAXBException jaxbe) {
throw new IOException(jaxbe);
}
}
use of javax.xml.bind.Marshaller in project nhin-d by DirectProject.
the class XmlUtils method marshal.
/**
* Marshal an object into an XML string.
*
* @param altName
* The altName.
* @param jaxb
* The object to marshal.
* @param factory
* The factory class.
* @return a marshaled string from the object.
*/
@SuppressWarnings("unchecked")
public static String marshal(QName altName, Object jaxb, Class<?> factory) {
String ret = null;
try {
javax.xml.bind.JAXBContext jc = javax.xml.bind.JAXBContext.newInstance(factory);
Marshaller u = jc.createMarshaller();
StringWriter sw = new StringWriter();
u.marshal(new JAXBElement(altName, jaxb.getClass(), jaxb), sw);
StringBuffer sb = sw.getBuffer();
ret = new String(sb);
} catch (Exception ex) {
if (LOGGER.isWarnEnabled())
LOGGER.warn("Failed to marshal message.", ex);
}
return ret;
}
use of javax.xml.bind.Marshaller in project ORCID-Source by ORCID.
the class OrcidMarshallerContextResolver method getContext.
@Override
public Marshaller getContext(Class<?> type) {
try {
context = JAXBContext.newInstance(type);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
return new OrcidMarshallerWrapper(marshaller);
} catch (JAXBException e) {
logger.error("Cannot create new marshaller", e);
throw new WebApplicationException(getResponse(e));
}
}
use of javax.xml.bind.Marshaller in project ORCID-Source by ORCID.
the class OrcidClientGroup method toString.
@Override
public String toString() {
try {
JAXBContext context = JAXBContext.newInstance(getClass());
StringWriter writer = new StringWriter();
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(this, writer);
return writer.toString();
} catch (JAXBException e) {
return ("Unable to unmarshal because: " + e);
}
}
Aggregations