List of usage examples for javax.xml.bind JAXBElement getValue
public T getValue()
Return the content model and attribute values for this element.
See #isNil() for a description of a property constraint when this value is null
From source file:fr.mael.microrss.xml.AtomFeedParser.java
@Override public Feed parseFeedInfo(Feed feed) throws Exception { JAXBContext jc = JAXBContext.newInstance("fr.mael.microrss.xml.atom"); Unmarshaller unmarshaller = jc.createUnmarshaller(); Object o = unmarshaller.unmarshal(new URL(feed.getUrl()).openStream()); if (o instanceof JAXBElement) { JAXBElement element = (JAXBElement) o; FeedType feedType = (FeedType) element.getValue(); String link = XMLUtil.readLinkType("link", feedType.getAuthorOrCategoryOrContributor()); feed.setIcon(Tools.getImage(Tools.getBaseUrl(link) + "/favicon.ico")); feed.setTitle(XMLUtil.readTextType("title", feedType.getAuthorOrCategoryOrContributor())); }//from ww w . j av a2 s .c o m return feed; }
From source file:edu.harvard.i2b2.crc.delegate.pm.PMResponseMessage.java
public StatusType processResult(String response) throws JAXBUtilException { StatusType status = null;//from w w w.j a v a 2s .co m try { JAXBElement jaxbElement = CRCJAXBUtil.getJAXBUtil().unMashallFromString(response); pmRespMessageType = (ResponseMessageType) jaxbElement.getValue(); // Get response message status ResponseHeaderType responseHeader = pmRespMessageType.getResponseHeader(); status = responseHeader.getResultStatus().getStatus(); String procStatus = status.getType(); String procMessage = status.getValue(); if (procStatus.equals("ERROR")) { log.info("Error reported by CRC web Service " + procMessage); } else if (procStatus.equals("WARNING")) { log.info("Warning reported by CRC web Service" + procMessage); } } catch (JAXBUtilException e) { log.error("Unable to read i2b2 response message type ", e); throw e; } return status; }
From source file:io.mapzone.controller.catalog.csw.FilterParser.java
protected void handleSpatial(JAXBElement<? extends SpatialOpsType> jaxb) { if (jaxb != null && jaxb.getValue() != null) { throw new UnsupportedOperationException("Spatial ops are not supported."); }//from ww w. j a v a2 s. co m }
From source file:com.evolveum.midpoint.model.common.expression.evaluator.PathExpressionEvaluatorFactory.java
@Override public <V extends PrismValue, D extends ItemDefinition> ExpressionEvaluator<V, D> createEvaluator( Collection<JAXBElement<?>> evaluatorElements, D outputDefinition, String contextDescription, Task task, OperationResult result) throws SchemaException { Validate.notNull(outputDefinition, "output definition must be specified for path expression evaluator"); if (evaluatorElements.size() > 1) { throw new SchemaException("More than one evaluator specified in " + contextDescription); }/*from w w w.j av a 2 s . c o m*/ JAXBElement<?> evaluatorElement = evaluatorElements.iterator().next(); Object evaluatorElementObject = evaluatorElement.getValue(); if (!(evaluatorElementObject instanceof ItemPathType)) { throw new IllegalArgumentException("Path expression cannot handle elements of type " + evaluatorElementObject.getClass().getName() + " in " + contextDescription); } // if (!(evaluatorElementObject instanceof Element)) { // throw new IllegalArgumentException("Path expression cannot handle elements of type " // + evaluatorElementObject.getClass().getName()+" in "+contextDescription); // } // XPathHolder xpath = new XPathHolder((Element)evaluatorElementObject); ItemPath path = ((ItemPathType) evaluatorElementObject).getItemPath(); return new PathExpressionEvaluator<>(path, objectResolver, outputDefinition, protector, prismContext); }
From source file:com.qpark.eip.core.model.analysis.operation.GetComplexTypeOperation.java
/** * @param message/*w w w. j ava 2 s .com*/ * the {@link JAXBElement} containing a * {@link GetComplexTypeRequestType}. * @return the {@link JAXBElement} with a {@link GetComplexTypeResponseType} * . */ @Override public final JAXBElement<GetComplexTypeResponseType> invoke( final JAXBElement<GetComplexTypeRequestType> message) { this.logger.debug("+getComplexType"); GetComplexTypeRequestType request = message.getValue(); GetComplexTypeResponseType response = this.of.createGetComplexTypeResponseType(); long start = System.currentTimeMillis(); try { String modelVersion = request.getRevision(); if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) { modelVersion = this.dao.getLastModelVersion(); } response.getComplexType().addAll(this.dao.getComplexTypesById(modelVersion, request.getId())); } catch (Throwable e) { /* Add a not covered error to the response. */ this.logger.error(e.getMessage(), e); } finally { this.logger.debug(" getComplexType duration {}", DateUtil.getDuration(start, System.currentTimeMillis())); this.logger.debug("-getComplexType #{}", response.getComplexType().size()); } return this.of.createGetComplexTypeResponse(response); }
From source file:com.qpark.eip.core.model.analysis.operation.GetElementTypeOperation.java
/** * @param message/*w w w . j av a 2s. c om*/ * the {@link JAXBElement} containing a * {@link GetElementTypeRequestType}. * @return the {@link JAXBElement} with a {@link GetElementTypeResponseType} * . */ @Override public final JAXBElement<GetElementTypeResponseType> invoke( final JAXBElement<GetElementTypeRequestType> message) { this.logger.debug("+getElementType"); GetElementTypeRequestType request = message.getValue(); GetElementTypeResponseType response = this.of.createGetElementTypeResponseType(); long start = System.currentTimeMillis(); try { String modelVersion = request.getRevision(); if (Objects.isNull(modelVersion) || modelVersion.trim().length() == 0) { modelVersion = this.dao.getLastModelVersion(); } response.getElementType().addAll(this.dao.getElementTypesById(modelVersion, request.getId())); } catch (Throwable e) { /* Add a not covered error to the response. */ this.logger.error(e.getMessage(), e); } finally { this.logger.debug(" getElementType duration {}", DateUtil.getDuration(start, System.currentTimeMillis())); this.logger.debug("-getElementType #{}", response.getElementType().size()); } return this.of.createGetElementTypeResponse(response); }
From source file:com.evolveum.midpoint.model.common.expression.evaluator.ConstExpressionEvaluatorFactory.java
@Override public <V extends PrismValue, D extends ItemDefinition> ExpressionEvaluator<V, D> createEvaluator( Collection<JAXBElement<?>> evaluatorElements, D outputDefinition, ExpressionFactory factory, String contextDescription, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException { Validate.notNull(outputDefinition,//ww w .j a va 2 s .c om "output definition must be specified for 'generate' expression evaluator"); Validate.notNull(outputDefinition, "output definition must be specified for path expression evaluator"); if (evaluatorElements.size() > 1) { throw new SchemaException("More than one evaluator specified in " + contextDescription); } JAXBElement<?> evaluatorElement = evaluatorElements.iterator().next(); Object evaluatorElementObject = evaluatorElement.getValue(); if (!(evaluatorElementObject instanceof ConstExpressionEvaluatorType)) { throw new IllegalArgumentException("Const expression cannot handle elements of type " + evaluatorElementObject.getClass().getName() + " in " + contextDescription); } return new ConstExpressionEvaluator<>((ConstExpressionEvaluatorType) evaluatorElementObject, outputDefinition, protector, constantsManager, prismContext); }
From source file:edu.harvard.i2b2.eclipse.plugins.admin.utilities.ws.OntologyResponseData.java
public StatusType processResult(String response) { StatusType status = null;/*from w w w .j a v a2s . c o m*/ try { JAXBElement jaxbElement = PFTJAXBUtil.getJAXBUtil().unMashallFromString(response); respMessageType = (ResponseMessageType) jaxbElement.getValue(); // Get response message status ResponseHeaderType responseHeader = respMessageType.getResponseHeader(); status = responseHeader.getResultStatus().getStatus(); String procStatus = status.getType(); String procMessage = status.getValue(); if (procStatus.equals("ERROR")) { log.info("Error reported by Ont web Service " + procMessage); } else if (procStatus.equals("WARNING")) { log.info("Warning reported by Ont web Service" + procMessage); } } catch (JAXBUtilException e) { // TODO Auto-generated catch block e.printStackTrace(); } return status; }
From source file:org.socialhistoryservices.pid.service.MappingsServiceImp.java
public LocAttType getLocations(Handle handle) { final StreamSource xmlSource = new StreamSource(new ByteArrayInputStream(handle.getData())); final ByteArrayOutputStream os = new ByteArrayOutputStream(); final Result result = new StreamResult(os); try {/* w w w .j av a2 s .co m*/ templates.newTransformer().transform(xmlSource, result); } catch (TransformerException e) { log.error("Handle: " + handle.getHandle()); log.error(e); return null; } final StreamSource source = new StreamSource(new ByteArrayInputStream(os.toByteArray())); final JAXBElement element = (JAXBElement) marshaller.unmarshal(source); return (LocAttType) element.getValue(); }
From source file:edu.harvard.i2b2.eclipse.plugins.admin.utilities.ws.GetStatusReportResponseMessage.java
public StatusType processResult(String response) { StatusType status = null;/*from w ww. ja v a2s.c om*/ try { JAXBElement jaxbElement = PFTJAXBUtil.getJAXBUtil().unMashallFromString(response); respMessageType = (ResponseMessageType) jaxbElement.getValue(); // Get response message status ResponseHeaderType responseHeader = respMessageType.getResponseHeader(); status = responseHeader.getResultStatus().getStatus(); String procStatus = status.getType(); String procMessage = status.getValue(); if (procStatus.equals("ERROR")) { log.info("Error reported by Ont web Service " + procMessage); } else if (procStatus.equals("WARNING")) { log.info("Warning reported by Ont web Service" + procMessage); } } catch (JAXBUtilException e) { // TODO Auto-generated catch block e.printStackTrace(); } return status; }