List of usage examples for javax.xml.bind JAXBElement JAXBElement
public JAXBElement(QName name, Class<T> declaredType, T value)
From source file:org.jasig.portlet.blackboardvcportlet.dao.ws.impl.MultimediaWSDaoTest.java
@Override @Test/*ww w . ja v a 2 s . c o m*/ public void getRepositoryMultimediasTest() throws Exception { //return empty set like it is expecting when(sasWebServiceOperations.marshalSendAndReceiveToSAS(any(String.class), any(Object.class))).thenReturn( new JAXBElement<BlackboardMultimediaResponseCollection>(new QName("http://sas.elluminate.com"), BlackboardMultimediaResponseCollection.class, new BlackboardMultimediaResponseCollection())); super.getRepositoryMultimediasTest(); }
From source file:be.fedict.eid.pkira.contracts.EIDPKIRAContractsClient.java
/** * Marshals the document to XML./*from w w w. j a v a2 s. c om*/ * * @param contractDocument * document to marshal. * @return the text in the XML. * @throws XmlMarshallingException * when this fails. */ public <T extends EIDPKIRAContractType> void marshal(T contractDocument, Class<T> clazz, Writer writer) throws XmlMarshallingException { QName qname = new QName(NAMESPACE, getElementNameForType(clazz)); JAXBElement<T> jaxbElement = new JAXBElement<T>(qname, clazz, contractDocument); try { getMarshaller().marshal(jaxbElement, writer); } catch (JAXBException e) { throw new XmlMarshallingException("Cannot marshal XML object.", e); } }
From source file:in.gov.uidai.core.aua.client.OtpClient.java
private String generateSignedOtpXML(Otp otp) throws JAXBException, Exception { StringWriter otpXML = new StringWriter(); JAXBElement element = new JAXBElement(new QName("http://www.uidai.gov.in/auth/otp/1.6", "Otp"), Otp.class, otp);/* w w w .j a va2 s . c o m*/ JAXBContext.newInstance(Otp.class).createMarshaller().marshal(element, otpXML); boolean includeKeyInfo = true; if (System.getenv().get("SKIP_DIGITAL_SIGNATURE") != null) { return otpXML.toString(); } else { System.out.println(otpXML); return this.digitalSignator.signXML(otpXML.toString(), includeKeyInfo); } }
From source file:hydrograph.ui.engine.converter.impl.UniqueSequenceConverter.java
@Override protected List<JAXBElement<?>> getOperations() { logger.debug("Generating TypeTransformOperation data :{}", properties.get(Constants.PARAM_NAME)); List<JAXBElement<?>> operationList = null; if (StringUtils.isNotBlank(newFieldName)) { operationList = new ArrayList<>(); TypeTransformOperation operation = new TypeTransformOperation(); operation.setId(defaultOperationId); operation.setOutputFields(getOutPutFields()); JAXBElement<TypeTransformOperation> jaxbElement = new JAXBElement( OperationsExpressionType.OPERATION.getQName(), TypeTransformOperation.class, operation); operationList.add(jaxbElement);/*from w ww . j a va2 s. co m*/ } return operationList; }
From source file:com.vangent.hieos.services.xds.bridge.utils.JUnitHelper.java
/** * Method description/*from w w w . j a va 2 s . com*/ * * * * * @param file * @param count * @param documentIds * @return * * @throws Exception */ public static OMElement createOMRequest(String file, int count, String[] documentIds) throws Exception { ObjectFactory factory = new ObjectFactory(); SubmitDocumentRequest sdr = factory.createSubmitDocumentRequest(); IdType pid = factory.createIdType(); pid.setRoot("1.3.6.1.4.1.21367.2005.3.7.6fa11e467880478"); sdr.setPatientId(pid); ClassLoader classLoader = JUnitHelper.class.getClassLoader(); DocumentsType documents = factory.createDocumentsType(); for (int i = 0; i < count; ++i) { DocumentType document = factory.createDocumentType(); if ((documentIds != null) && (documentIds.length > i)) { document.setId(documentIds[i]); } CodeType type = factory.createCodeType(); type.setCode("51855-5"); type.setCodeSystem("2.16.840.1.113883.6.1"); document.setType(type); ByteArrayOutputStream bos = new ByteArrayOutputStream(); InputStream is = classLoader.getResourceAsStream(file); assertNotNull(is); IOUtils.copy(is, bos); document.setContent(bos.toByteArray()); documents.getDocument().add(document); } sdr.setDocuments(documents); QName qname = new QName(URIConstants.XDSBRIDGE_URI, "SubmitDocumentRequest"); JAXBContext jc = JAXBContext.newInstance(SubmitDocumentRequest.class); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); JAXBElement element = new JAXBElement(qname, sdr.getClass(), sdr); StringWriter sw = new StringWriter(); marshaller.marshal(element, sw); String xml = sw.toString(); logger.debug(xml); OMElement result = AXIOMUtil.stringToOM(OMAbstractFactory.getOMFactory(), xml); List<OMElement> list = XPathHelper.selectNodes(result, "./ns:Documents/ns:Document/ns:Content", URIConstants.XDSBRIDGE_URI); for (OMElement contentNode : list) { OMText binaryNode = (OMText) contentNode.getFirstOMChild(); if (binaryNode != null) { binaryNode.setOptimize(true); } } return result; }
From source file:in.gov.uidai.auth.aua.httpclient.OtpClient.java
private String generateSignedOtpXML(Otp otp) throws JAXBException, Exception { StringWriter otpXML = new StringWriter(); JAXBElement<Otp> element = new JAXBElement<Otp>( new QName("http://www.uidai.gov.in/authentication/otp/1.0", "Otp"), Otp.class, otp); JAXBContext.newInstance(Otp.class).createMarshaller().marshal(element, otpXML); boolean includeKeyInfo = true; if (System.getenv().get("SKIP_DIGITAL_SIGNATURE") != null) { return otpXML.toString(); } else {// w w w . j a v a 2 s . com return this.digitalSignator.signXML(otpXML.toString(), includeKeyInfo); } }
From source file:org.javelin.sws.ext.bind.jaxb.JaxbTest.java
@Test public void unmarshalSameQNames() throws Exception { JAXBContext ctx = JAXBContext.newInstance(org.javelin.sws.ext.bind.jaxb.context1.MyClassJ1.class, org.javelin.sws.ext.bind.jaxb.context2.MyClassJ2.class); Marshaller m = ctx.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); log.info("context1"); org.javelin.sws.ext.bind.jaxb.context1.MyClassJ1 mc1 = new org.javelin.sws.ext.bind.jaxb.context1.MyClassJ1(); mc1.setP(new MyProperty1()); m.marshal(new JAXBElement<org.javelin.sws.ext.bind.jaxb.context1.MyClassJ1>(new QName("a", "a"), org.javelin.sws.ext.bind.jaxb.context1.MyClassJ1.class, mc1), System.out); log.info("context2"); org.javelin.sws.ext.bind.jaxb.context2.MyClassJ2 mc2 = new org.javelin.sws.ext.bind.jaxb.context2.MyClassJ2(); mc2.setP(new MyProperty2()); m.marshal(new JAXBElement<org.javelin.sws.ext.bind.jaxb.context2.MyClassJ2>(new QName("a", "a"), org.javelin.sws.ext.bind.jaxb.context2.MyClassJ2.class, mc2), System.out); Object object = ctx.createUnmarshaller().unmarshal( new StreamSource( new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n" + "<ns2:a xmlns=\"urn:x\" xmlns:ns2=\"a\">\r\n" + " <p/>\r\n" + "</ns2:a>")), org.javelin.sws.ext.bind.jaxb.context2.MyClassJ2.class); log.info("Class: {}", ((JAXBElement<?>) object).getValue().getClass()); }
From source file:org.jasig.portlet.blackboardvcportlet.dao.ws.impl.MultimediaWSDaoTest.java
@Override @Test/*from w ww . j a v a 2s. c om*/ public void getSessionRepositoryMultimediasTest() throws Exception { when(sasWebServiceOperations.marshalSendAndReceiveToSAS(any(String.class), any(Object.class))).thenReturn( new JAXBElement<BlackboardMultimediaResponseCollection>(new QName("http://sas.elluminate.com"), BlackboardMultimediaResponseCollection.class, new BlackboardMultimediaResponseCollection())); super.getSessionRepositoryMultimediasTest(); }
From source file:com.netflix.subtitles.ttml.TtmlParagraphResolver.java
private static <T> T deepCopy(T object, Class<T> clazz, String packages) { try {/*from ww w. ja v a 2 s . c om*/ JAXBContext jaxbContext = JAXBContext.newInstance(packages); // create marshaller which disable validation step Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setEventHandler(event -> true); // create unmarshaller which disable validation step Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setEventHandler(event -> true); JAXBElement<T> contentObject = new JAXBElement<>(new QName(clazz.getName()), clazz, object); return unmarshaller.unmarshal(new JAXBSource(marshaller, contentObject), clazz).getValue(); } catch (JAXBException e) { throw new ParseException("Time overlaps in <p> cannot be resolved.", e); } }
From source file:in.gov.uidai.core.aua.client.BfdClient.java
private String generateSignedBfdXML(Bfd bfd) throws JAXBException, Exception { StringWriter bfdXML = new StringWriter(); JAXBElement bfdElement = new JAXBElement( new QName("http://www.uidai.gov.in/auth/uid-bfd-request/1.0", "Bfd"), Bfd.class, bfd); JAXBContext.newInstance(Bfd.class).createMarshaller().marshal(bfdElement, bfdXML); boolean includeKeyInfo = true; if (System.getenv().get("SKIP_DIGITAL_SIGNATURE") != null) { return bfdXML.toString(); } else {//from w w w . ja v a2 s. c om return this.digitalSignator.signXML(bfdXML.toString(), includeKeyInfo); } }