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:be.fedict.eid.pkira.xkmsws.util.XMLMarshallingUtil.java
@SuppressWarnings("unchecked") public BulkRegisterResultType unmarshalByteArrayToBulkRegisterResultType(Document response) throws XKMSClientException { try {//from w w w . ja v a 2 s .c o m Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); JAXBElement<BulkRegisterResultType> unmarshalled = (JAXBElement<BulkRegisterResultType>) unmarshaller .unmarshal(response); return unmarshalled.getValue(); } catch (JAXBException e) { throw new XKMSClientException("Cannot unmarshal message.", e); } }
From source file:com.evolveum.midpoint.prism.marshaller.JaxbDomHack.java
/** * This is used in a form of "fromAny" to parse elements from a JAXB getAny method to prism. *///from www . j av a2s . com public <IV extends PrismValue, ID extends ItemDefinition, C extends Containerable> Item<IV, ID> parseRawElement( Object element, PrismContainerDefinition<C> definition) throws SchemaException { Validate.notNull(definition, "Attempt to parse raw element in a container without definition"); QName elementName = JAXBUtil.getElementQName(element); ItemDefinition itemDefinition = definition.findItemDefinition(elementName); if (itemDefinition == null) { itemDefinition = locateItemDefinition(definition, elementName, element); if (itemDefinition == null) { throw new SchemaException("No definition for item " + elementName); } } PrismContext prismContext = definition.getPrismContext(); Item<IV, ID> subItem; if (element instanceof Element) { // DOM Element subItem = prismContext.parserFor((Element) element).name(elementName).definition(itemDefinition) .parseItem(); } else if (element instanceof JAXBElement<?>) { // JAXB Element JAXBElement<?> jaxbElement = (JAXBElement<?>) element; Object jaxbBean = jaxbElement.getValue(); if (itemDefinition == null) { throw new SchemaException("No definition for item " + elementName + " in container " + definition + " (parsed from raw element)", elementName); } if (itemDefinition instanceof PrismPropertyDefinition<?>) { // property PrismProperty<Object> property = ((PrismPropertyDefinition<Object>) itemDefinition).instantiate(); property.setRealValue(jaxbBean); subItem = (Item<IV, ID>) property; } else if (itemDefinition instanceof PrismContainerDefinition<?>) { if (jaxbBean instanceof Containerable) { PrismContainer<?> container = ((PrismContainerDefinition<?>) itemDefinition).instantiate(); PrismContainerValue subValue = ((Containerable) jaxbBean).asPrismContainerValue(); container.add(subValue); subItem = (Item<IV, ID>) container; } else { throw new IllegalArgumentException("Unsupported JAXB bean " + jaxbBean.getClass()); } } else if (itemDefinition instanceof PrismReferenceDefinition) { // TODO if (jaxbBean instanceof Referencable) { PrismReference reference = ((PrismReferenceDefinition) itemDefinition).instantiate(); PrismReferenceValue refValue = ((Referencable) jaxbBean).asReferenceValue(); reference.merge(refValue); subItem = (Item<IV, ID>) reference; } else { throw new IllegalArgumentException("Unsupported JAXB bean" + jaxbBean); } } else { throw new IllegalArgumentException("Unsupported definition type " + itemDefinition.getClass()); } } else { throw new IllegalArgumentException("Unsupported element type " + element.getClass()); } return subItem; }
From source file:esg.node.components.registry.LasSistersGleaner.java
public LasServers createLasServersFromString(String lasServersContentString) { log.info("Loading my LAS LasServers info from \n" + lasServersContentString + "\n"); LasServers fromContentLasServers = null; try {/* ww w . j a v a 2 s . co m*/ JAXBContext jc = JAXBContext.newInstance(LasServers.class); Unmarshaller u = jc.createUnmarshaller(); JAXBElement<LasServers> root = u.unmarshal(new StreamSource(new StringReader(lasServersContentString)), LasServers.class); fromContentLasServers = root.getValue(); } catch (Exception e) { log.error(e); } return fromContentLasServers; }
From source file:org.n52.youngs.harvest.KvpCswSource.java
@Override public Collection<SourceRecord> getRecords(long startPosition, long maxRecords, Report report) { log.debug("Requesting {} records from catalog starting at {}", maxRecords, startPosition); Collection<SourceRecord> records = Lists.newArrayList(); String recordsRequest = createRequest(startPosition, maxRecords); log.trace("GetRecords request: {}", recordsRequest); try {//from w w w . j ava 2 s .c om InputStream response = Request.Get(recordsRequest).execute().returnContent().asStream(); JAXBElement<GetRecordsResponseType> jaxb_response = unmarshaller.unmarshal(new StreamSource(response), GetRecordsResponseType.class); BigInteger numberOfRecordsReturned = jaxb_response.getValue().getSearchResults() .getNumberOfRecordsReturned(); log.debug("Got response with {} records", numberOfRecordsReturned); List<Object> nodes = jaxb_response.getValue().getSearchResults().getAny(); if (!nodes.isEmpty()) { log.trace("Found {} \"any\" nodes.", nodes.size()); nodes.stream().filter(n -> n instanceof Node).map(n -> (Node) n).map(n -> new NodeSourceRecord(n)) .forEach(records::add); } List<JAXBElement<? extends AbstractRecordType>> jaxb_records = jaxb_response.getValue() .getSearchResults().getAbstractRecord(); if (!jaxb_records.isEmpty()) { log.trace("Found {} \"AbstractRecordType\" records.", jaxb_records.size()); DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); jaxb_records.stream().map(type -> { return getNode(type, context, db); }).filter(Objects::nonNull).map(n -> new NodeSourceRecord(n)).forEach(records::add); } } catch (IOException | JAXBException | ParserConfigurationException e) { log.error("Could not retrieve records using url {}", recordsRequest, e); report.addMessage(String.format("Error retrieving record from endpoint %s: %s", this, e)); } return records; }
From source file:be.fedict.hsm.client.HSMProxyClient.java
/** * Gives back the list of key aliases available within the HSM Proxy key * store for the set application credential. * // w w w . ja v a 2s.com * @return the list of aliases. */ public Set<String> getAliases() { GetAliasesRequest getAliasesRequest = this.hsmObjectFactory.createGetAliasesRequest(); getAliasesRequest.setProfile(DSSConstants.HSM_PROXY_DSS_PROFILE_URI); String requestId = "request-" + UUID.randomUUID().toString(); getAliasesRequest.setRequestID(requestId); ResponseBaseType response = this.dssPort.getAliases(getAliasesRequest); // TODO: error handling List<Object> optionalOutputContentList = response.getOptionalOutputs().getAny(); Set<String> aliases = new HashSet<String>(); for (Object optionalOutputContent : optionalOutputContentList) { LOG.debug("optional output type: " + optionalOutputContent.getClass().getName()); if (optionalOutputContent instanceof KeySelector) { KeySelector keySelector = (KeySelector) optionalOutputContent; KeyInfoType keyInfo = keySelector.getKeyInfo(); List<Object> keyInfoContent = keyInfo.getContent(); for (Object keyInfoObject : keyInfoContent) { if (keyInfoObject instanceof JAXBElement) { JAXBElement jaxbElement = (JAXBElement) keyInfoObject; String alias = (String) jaxbElement.getValue(); aliases.add(alias); } } } } return aliases; }
From source file:esg.node.components.registry.AzsWhitelistGleaner.java
public AzsWhitelist createAzsWhitelistFromString(String azsWhitelistContentString) { log.info("Loading my AZS Whitelist info from \n" + azsWhitelistContentString + "\n"); AzsWhitelist fromContentAzsWhitelist = null; try {//from w w w. j av a 2 s.c om JAXBContext jc = JAXBContext.newInstance(AzsWhitelist.class); Unmarshaller u = jc.createUnmarshaller(); JAXBElement<AzsWhitelist> root = u .unmarshal(new StreamSource(new StringReader(azsWhitelistContentString)), AzsWhitelist.class); fromContentAzsWhitelist = root.getValue(); } catch (Exception e) { log.error(e); } return fromContentAzsWhitelist; }
From source file:esg.node.components.registry.IdpWhitelistGleaner.java
public IdpWhitelist createIdpWhitelistFromString(String idpWhitelistContentString) { log.info("Loading my IDP Whitelist info from \n" + idpWhitelistContentString + "\n"); IdpWhitelist fromContentIdpWhitelist = null; try {/*w w w. j ava2 s . c om*/ JAXBContext jc = JAXBContext.newInstance(IdpWhitelist.class); Unmarshaller u = jc.createUnmarshaller(); JAXBElement<IdpWhitelist> root = u .unmarshal(new StreamSource(new StringReader(idpWhitelistContentString)), IdpWhitelist.class); fromContentIdpWhitelist = root.getValue(); } catch (Exception e) { log.error(e); } return fromContentIdpWhitelist; }
From source file:ee.ria.xroad.common.conf.globalconf.SharedParameters.java
private void cacheSecurityServers() { // Map of XML ID fields mapped to client IDs Map<String, ClientId> clientIds = getClientIds(); for (SecurityServerType securityServer : confType.getSecurityServer()) { // Cache the server. for (byte[] certHash : securityServer.getAuthCertHash()) { serverByAuthCert.put(encodeBase64(certHash), securityServer); }//from ww w . j av a 2s .co m // Add owner of the security server. MemberType owner = (MemberType) securityServer.getOwner(); addServerClient(createMemberId(owner), securityServer); // cache security server information by serverId SecurityServerId securityServerId = SecurityServerId.create(confType.getInstanceIdentifier(), owner.getMemberClass().getCode(), owner.getMemberCode(), securityServer.getServerCode()); securityServersById.put(securityServerId, securityServer); // Add clients of the security server. for (JAXBElement<?> client : securityServer.getClient()) { Object val = client.getValue(); if (val instanceof MemberType) { addServerClient(createMemberId((MemberType) val), securityServer); } else if (val instanceof SubsystemType) { addServerClient(clientIds.get(((SubsystemType) val).getId()), securityServer); } } } }
From source file:edu.harvard.i2b2.pm.ws.ServicesMessage.java
/** * The constructor//from w ww . ja va2 s . c o m */ public ServicesMessage(String requestPdo) throws I2B2Exception { JAXBUtil jaxbUtil = MessageFactory.getJAXBUtil(); //new JAXBUtil(JAXBConstant.DEFAULT_PACKAGE_NAME); try { log.debug("Begin unmarshall of XML"); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(requestPdo); if (jaxbElement == null) { throw new I2B2Exception("Null value from unmashall for PDO xml : " + requestPdo); } log.debug("Finished unmarshall of XML"); this.reqMessageType = (RequestMessageType) jaxbElement.getValue(); } catch (JAXBUtilException e) { e.printStackTrace(); log.error(e.getMessage(), e); throw new I2B2Exception("Umashaller error: " + e.getMessage() + requestPdo, e); } }
From source file:org.wallerlab.yoink.molecular.service.translator.MolecularSystemTranslator.java
private void checkIfMoleculeList(Object elementMoleculeList) { @SuppressWarnings("unchecked") JAXBElement<MoleculeList> element = (JAXBElement<MoleculeList>) elementMoleculeList; if (element.getDeclaredType() == MoleculeList.class) { MoleculeList moleculeList = (MoleculeList) element.getValue(); loopOverElementsInCmlMoleculeList(moleculeList); }/*from w ww.j ava2s. c om*/ }