List of usage examples for javax.xml.bind JAXBElement JAXBElement
public JAXBElement(QName name, Class<T> declaredType, T value)
From source file:edu.duke.cabig.c3pr.domain.scheduler.runtime.job.CCTSNotificationMessageJob.java
private String serialize(Notification notification) { try {/*from w ww . ja va2 s . com*/ JAXBContext context = JAXBContext.newInstance(Notification.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); JAXBElement<Notification> jaxbElement = new JAXBElement<Notification>( new QName(CCTS_NOTIFICATIONS_NS, "notification"), Notification.class, notification); CharArrayWriter writer = new CharArrayWriter(); m.marshal(jaxbElement, writer); return String.valueOf(writer.toCharArray()); } catch (JAXBException e) { throw new RuntimeException(e); } }
From source file:com.athena.peacock.controller.common.component.RHEVMRestTemplate.java
@SuppressWarnings({ "unchecked", "rawtypes" }) private static String marshal(Object obj, String rootElementName) { StringWriter sw = new StringWriter(); try {//from w ww. ja va 2 s .c o m JAXBContext jaxbCtx = JAXBContext.newInstance(obj.getClass().getPackage().getName()); Marshaller marshaller = jaxbCtx.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(new JAXBElement(new QName(rootElementName), obj.getClass(), obj), sw); sw.close(); } catch (PropertyException e) { e.printStackTrace(); } catch (JAXBException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return sw.toString(); }
From source file:cz.cas.lib.proarc.common.export.mets.JhoveUtility.java
/** * Merges the mix from the device and from the image * * @param source/*from w w w . j a va 2 s. co m*/ * @param deviceMix */ public static void mergeMix(Mix source, MixType deviceMix) { if (deviceMix != null) { if (deviceMix.getImageCaptureMetadata() != null) { DOMResult domResult = new DOMResult(); MixUtils.marshal(domResult, new JAXBElement<ImageCaptureMetadataType>(new QName("uri", "local"), ImageCaptureMetadataType.class, deviceMix.getImageCaptureMetadata()), true); ImageCaptureMetadataType imageCaptureMtd = MixUtils.unmarshal(new DOMSource(domResult.getNode()), ImageCaptureMetadataType.class); source.setImageCaptureMetadata(imageCaptureMtd); } } }
From source file:com.searchbox.collection.oppfin.EENCollection.java
public ItemReader<Profile> reader() throws RemoteException { return new ItemReader<Profile>() { IPODServiceSOAPProxy eenService; ProfileQueryRequest request;/*from w w w .j av a 2s . c o m*/ List<Profile> profiles; Date date = new Date(System.currentTimeMillis()); Date start = new Date(System.currentTimeMillis()); DateFormat dfmt = new DateFormatManager("YYYYMMdd").getDateFormatInstance(); { // Get the service eenService = new IPODServiceSOAPProxy(); // Set the password request = new ProfileQueryRequest(); request.setUsername(env.getProperty(EEN_SERVICE_USER, EEN_SERVICE_USER_DEFAULT)); request.setPassword(env.getProperty(EEN_SERVICE_PWD, EEN_SERVICE_PWD_DEFAULT)); // Start with an empty list of profiles profiles = new ArrayList<Profile>(); date = start; } public void fillProfiles(Date from, Date to) { try { LOGGER.info("Fill Profile - ", from.toString(), to.toString()); // time to get some new profiles... JAXBElement<String> jaxbDeadlineDateAfter = new JAXBElement(new QName( "http://schemas.datacontract.org/2004/07/EEN.Merlin.Backend.Core.BO.PODService", "DeadlineDateAfter"), String.class, dfmt.format(from)); JAXBElement<String> jaxbDeadlineDateBefore = new JAXBElement(new QName( "http://schemas.datacontract.org/2004/07/EEN.Merlin.Backend.Core.BO.PODService", "DeadlineDateBefore"), String.class, dfmt.format(to)); request.setDeadlineDateAfter(jaxbDeadlineDateAfter); request.setDeadlineDateBefore(jaxbDeadlineDateBefore); Profile[] newProfiles = eenService.getProfiles(request); EENCollection.LOGGER.info("adding: " + newProfiles.length + " new profiles"); profiles.addAll(Arrays.asList(newProfiles)); } catch (Exception e) { LOGGER.error("Could not load profiles: " + e); } } public Profile read() throws RemoteException { if (start.after(DateUtils.addYears(date, 3))) { return null; } if (profiles.isEmpty()) { while (start.before(DateUtils.addYears(date, 1)) && profiles.isEmpty()) { Date end = DateUtils.addDays(start, 5); EENCollection.LOGGER.info("Fetching EEN profiles from deadline date " + dfmt.format(start) + " to deadline date" + dfmt.format(end)); fillProfiles(start, end); start = end; } if (start.after(DateUtils.addYears(date, 3))) { return null; } } if (profiles.size() == 0) { return null; } return profiles.remove(0); } }; }
From source file:hydrograph.ui.engine.helper.ConverterHelper.java
public void addExternalJaxbOperation(List<JAXBElement<?>> operationList, ExternalWidgetData externalExpressionData) { if (externalExpressionData != null) { TypeExternalSchema typeExternalSchema = new TypeExternalSchema(); typeExternalSchema.setUri("../" + externalExpressionData.getFilePath()); JAXBElement<TypeExternalSchema> externalExpression = new JAXBElement<TypeExternalSchema>( OperationsExpressionType.INCLUDE_EXTERNAL_OPERATION.getQName(), TypeExternalSchema.class, typeExternalSchema);/*w w w . j a v a 2s.c o m*/ operationList.add(externalExpression); } }
From source file:nl.ordina.bag.etl.dao.AbstractBAGMutatiesDAO.java
@Override public void insert(final BAGMutatie mutatie) throws DAOException { try {// www . java 2s . c o m jdbcTemplate.update(new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { try { PreparedStatement ps = connection.prepareStatement("insert into bag_mutatie (" + "id," + "tijdstip_verwerking," + "volgnr_verwerking," + "object_type," + "mutatie_product" + ") values ((select nvl(max(id),0) + 1 from bag_mutatie),?,?,?,?)"); ps.setTimestamp(1, Utils.toTimestamp(mutatie.getTijdstipVerwerking())); ps.setLong(2, mutatie.getVolgnrVerwerking()); ps.setInt(3, mutatie.getObjectType().ordinal()); ps.setString(4, XMLMessageBuilder.getInstance(MutatieProduct.class) .handle(new JAXBElement<MutatieProduct>(new QName( "http://www.kadaster.nl/schemas/bag-verstrekkingen/extract-producten-lvc/v20090901", "Mutatie-product"), MutatieProduct.class, mutatie.getMutatieProduct()))); return ps; } catch (JAXBException e) { throw new DAOException(e); } } }); } catch (DataAccessException e) { throw new DAOException(e); } }
From source file:in.gov.uidai.core.aua.client.KYCClient.java
private String generateSignedAuthXML(Auth auth) throws JAXBException, Exception { StringWriter authXML = new StringWriter(); JAXBElement authElement = new JAXBElement( new QName("http://www.uidai.gov.in/auth/uid-auth-request/1.0", "Auth"), Auth.class, auth); JAXBContext.newInstance(Auth.class).createMarshaller().marshal(authElement, authXML); boolean includeKeyInfo = true; if (System.getenv().get("SKIP_DIGITAL_SIGNATURE_AUTH_ONLY") != null) { return authXML.toString(); } else {/*ww w.j av a 2 s . co m*/ return this.digitalSignator.signXML(authXML.toString(), includeKeyInfo); } }
From source file:com.evolveum.midpoint.prism.util.JaxbTestUtil.java
public String marshalToString(Objectable objectable, Map<String, Object> properties) throws JAXBException { QName elementQName = determineElementQName(objectable); JAXBElement<Object> jaxbElement = new JAXBElement<Object>(elementQName, (Class) objectable.getClass(), objectable);// w w w.j av a2 s .c om return marshalElementToString(jaxbElement, properties); }
From source file:com.evolveum.midpoint.testing.model.client.sample.Upload.java
private static String marshalResult(OperationResultType result) { if (result == null) { return ""; } else {//from w w w. jav a 2 s. c o m try { return marshalObject(new JAXBElement<>(new QName("result"), OperationResultType.class, result)); } catch (JAXBException | FileNotFoundException e) { error = true; return ("Couldn't marshall result: " + e.getMessage()); } } }
From source file:hydrograph.ui.engine.helper.ConverterHelper.java
private JAXBElement<?> getOperationOrExpression(MappingSheetRow mappingSheetRow, int operationID, List<BasicSchemaGridRow> schemaGridRows) { if (mappingSheetRow != null) { if (!mappingSheetRow.isExpression()) { TypeTransformOperation operation = new TypeTransformOperation(); operation.setId(mappingSheetRow.getOperationID()); operation.setInputFields(getOperationInputFields(mappingSheetRow)); operation.setProperties(getOperationProperties(mappingSheetRow.getNameValueProperty())); operation.setOutputFields(getOperationOutputFields(mappingSheetRow, schemaGridRows)); if (StringUtils.isNotBlank(mappingSheetRow.getOperationClassPath())) { operation.setClazz(mappingSheetRow.getOperationClassPath()); }/* w w w .j a va2s. c o m*/ JAXBElement<TypeTransformOperation> jaxbElement = new JAXBElement( OperationsExpressionType.OPERATION.getQName(), TypeTransformOperation.class, operation); return jaxbElement; } else { TypeTransformExpression expression = new TypeTransformExpression(); expression.setId(mappingSheetRow.getOperationID()); expression.setInputFields(getExpressionInputFields(mappingSheetRow)); expression.setProperties(getOperationProperties(mappingSheetRow.getNameValueProperty())); expression.setOutputFields(getExpressionOutputField(mappingSheetRow, schemaGridRows)); if (Constants.AGGREGATE.equalsIgnoreCase(component.getComponentName()) || Constants.CUMULATE.equalsIgnoreCase(component.getComponentName())) { expression.setAccumulatorInitalValue(mappingSheetRow.getAccumulator()); } else if (Constants.GROUP_COMBINE.equalsIgnoreCase(component.getComponentName())) { expression.setAccumulatorInitalValue(mappingSheetRow.getAccumulator()); if (StringUtils .isNotBlank(mappingSheetRow.getMergeExpressionDataForGroupCombine().getExpression())) { expression.setMergeExpr( mappingSheetRow.getMergeExpressionDataForGroupCombine().getExpression()); } } if (StringUtils.isNotBlank(mappingSheetRow.getExpressionEditorData().getExpression())) { expression.setExpr(mappingSheetRow.getExpressionEditorData().getExpression()); } JAXBElement<TypeTransformExpression> jaxbElement = new JAXBElement( OperationsExpressionType.EXPRESSION.getQName(), TypeTransformExpression.class, expression); return jaxbElement; } } return null; }