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:com.inmobi.grill.client.GrillMetadataClient.java
public XStorageTableElement getStorageOfFactTable(String factName, String storageName) { WebTarget target = getMetastoreWebTarget(); JAXBElement<XStorageTableElement> element = target.path("facts").path(factName).path("storages") .path(storageName).queryParam("sessionid", this.connection.getSessionHandle()) .request(MediaType.APPLICATION_XML).get(new GenericType<JAXBElement<XStorageTableElement>>() { });//from w ww .j a v a 2s.co m return element.getValue(); }
From source file:edu.harvard.iq.dvn.core.harvest.HarvesterServiceBean.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public ResumptionTokenType harvestFromIdentifiers(Logger hdLogger, ResumptionTokenType resumptionToken, HarvestingDataverse dataverse, String from, String until, List<Long> harvestedStudyIds, List<String> failedIdentifiers, MutableBoolean harvestErrorOccurred) throws java.io.IOException, ParserConfigurationException, SAXException, TransformerException, JAXBException { String encodedSet = dataverse.getHarvestingSet() == null ? null : URLEncoder.encode(dataverse.getHarvestingSet(), "UTF-8"); ListIdentifiers listIdentifiers = null; if (resumptionToken == null) { listIdentifiers = new ListIdentifiers(dataverse.getServerUrl(), from, until, encodedSet, URLEncoder.encode(dataverse.getHarvestFormatType().getMetadataPrefix(), "UTF-8")); } else {//from w w w. j a v a 2 s. c o m hdLogger.log(Level.INFO, "harvestFromIdentifiers(), resumptionToken=" + resumptionToken.getValue()); listIdentifiers = new ListIdentifiers(dataverse.getServerUrl(), resumptionToken.getValue()); } Document doc = listIdentifiers.getDocument(); // JAXBContext jc = JAXBContext.newInstance("edu.harvard.hmdc.vdcnet.jaxb.oai"); // Unmarshaller unmarshaller = jc.createUnmarshaller(); JAXBElement unmarshalObj = (JAXBElement) unmarshaller.unmarshal(doc); OAIPMHtype oaiObj = (OAIPMHtype) unmarshalObj.getValue(); if (oaiObj.getError() != null && oaiObj.getError().size() > 0) { if (oaiObj.getError().get(0).getCode().equals(OAIPMHerrorcodeType.NO_RECORDS_MATCH)) { hdLogger.info("ListIdentifiers returned NO_RECORDS_MATCH - no studies found to be harvested."); } else { handleOAIError(hdLogger, oaiObj, "calling listIdentifiers, oaiServer= " + dataverse.getServerUrl() + ",from=" + from + ",until=" + until + ",encodedSet=" + encodedSet + ",format=" + dataverse.getHarvestFormatType().getMetadataPrefix()); throw new EJBException("Received OAI Error response calling ListIdentifiers"); } } else { ListIdentifiersType listIdentifiersType = oaiObj.getListIdentifiers(); if (listIdentifiersType != null) { resumptionToken = listIdentifiersType.getResumptionToken(); for (Iterator it = listIdentifiersType.getHeader().iterator(); it.hasNext();) { HeaderType header = (HeaderType) it.next(); MutableBoolean getRecordErrorOccurred = new MutableBoolean(false); Long studyId = getRecord(hdLogger, dataverse, header.getIdentifier(), dataverse.getHarvestFormatType().getMetadataPrefix(), getRecordErrorOccurred); if (studyId != null) { harvestedStudyIds.add(studyId); } if (getRecordErrorOccurred.booleanValue() == true) { failedIdentifiers.add(header.getIdentifier()); } } } } String logMsg = "Returning from harvestFromIdentifiers"; if (resumptionToken == null) { logMsg += " resumptionToken is null"; } else if (!StringUtil.isEmpty(resumptionToken.getValue())) { logMsg += " resumptionToken is " + resumptionToken.getValue(); } else { // Some OAIServers return an empty resumptionToken element when all // the identifiers have been sent, so need to check for this, and // treat it as if resumptiontoken is null. logMsg += " resumptionToken is empty, setting return value to null."; resumptionToken = null; } hdLogger.info(logMsg); return resumptionToken; }
From source file:esg.node.components.registry.RegistrationGleaner.java
public synchronized RegistrationGleaner loadMyRegistration(String filename) throws ESGFRegistryException { log.info("Loading my registration info from " + filename); try {/*from ww w .j a va 2 s . c o m*/ JAXBContext jc = JAXBContext.newInstance(Registration.class); Unmarshaller u = jc.createUnmarshaller(); JAXBElement<Registration> root = u.unmarshal(new StreamSource(new File(filename)), Registration.class); myRegistration = root.getValue(); sync(); } catch (Exception e) { throw new ESGFRegistryException("Unable to properly load local Registration from [" + filename + "]", e); } return this; }
From source file:org.jasig.portlet.emailpreview.dao.exchange.ExchangeAccountDaoImpl.java
private ResponseMessageType sendMessageAndExtractSingleResponse(BaseRequestType soapRequest, String soapAction, MailStoreConfiguration config) { BaseResponseMessageType soapResponse = sendSoapRequest(soapRequest, soapAction, config); boolean warning = false; boolean error = false; StringBuilder msg = new StringBuilder(); List<JAXBElement<? extends ResponseMessageType>> responseMessages = soapResponse.getResponseMessages() .getCreateItemResponseMessagesAndDeleteItemResponseMessagesAndGetItemResponseMessages(); for (JAXBElement<? extends ResponseMessageType> resp : responseMessages) { if (ResponseClassType.ERROR.equals(resp.getValue().getResponseClass())) { error = true;// w w w.ja va 2s . c o m msg.append("Error: ").append(resp.getValue().getResponseCode().value()).append(": ") .append(resp.getValue().getMessageText()).append("\n"); } else if (ResponseClassType.WARNING.equals(resp.getValue().getResponseClass())) { warning = true; msg.append("Warning: ").append(resp.getValue().getResponseCode().value()).append(": ") .append(resp.getValue().getMessageText()).append("\n"); } } if (warning || error) { StringBuilder errorMessage = new StringBuilder("Unexpected response from soap action: " + soapAction + ".\nSoap Request: " + soapRequest.toString() + "\n"); errorMessage.append(msg); if (error) { throw new EmailPreviewException("Error performing Exchange web service action " + soapAction + ". Error code is " + errorMessage.toString()); } log.warn("Received warning response to soap request " + soapAction + ". Error text is:\n" + errorMessage.toString()); throw new EmailPreviewException("Unable to perform " + soapAction + " operation; try again later. Message text: " + errorMessage.toString()); } // Currently all message requests return only one value, except a multi-delete or multi-readUpdate // in which we only care about having an error or not. return responseMessages.get(0).getValue(); }
From source file:com.athena.chameleon.engine.core.analyzer.parser.WebXMLParser.java
/** * <pre>// w w w . j a va 2 s . co m * web.xml ?? ? filter ? filter-mapping? , UTF-8? filter ? ? * filter UTF-8? filter ? filter-mapping? . * </pre> * @param obj * @param path * @return * @throws JAXBException * @throws IOException */ private Object checkEncodignFilter(Object obj, String path) throws JAXBException, IOException { String[] charSet = { "UTF-8", "UTF8" }; boolean hasEncodingFilter = false; boolean hasUTF8EncodingFilter = false; if (obj instanceof com.athena.chameleon.engine.entity.xml.webapp.v2_5.WebAppType) { com.athena.chameleon.engine.entity.xml.webapp.v2_5.WebAppType webApp = (com.athena.chameleon.engine.entity.xml.webapp.v2_5.WebAppType) obj; // webApp? <filter />, <filter-mapping />? ? List<JAXBElement<?>> elementList = webApp.getDescriptionAndDisplayNameAndIcon(); Object o = null; List<com.athena.chameleon.engine.entity.xml.webapp.v2_5.ParamValueType> paramList = null; com.athena.chameleon.engine.entity.xml.webapp.v2_5.FilterNameType filtername = null; for (JAXBElement<?> element : elementList) { o = element.getValue(); if (o instanceof com.athena.chameleon.engine.entity.xml.webapp.v2_5.FilterType) { filtername = ((com.athena.chameleon.engine.entity.xml.webapp.v2_5.FilterType) o) .getFilterName(); paramList = ((com.athena.chameleon.engine.entity.xml.webapp.v2_5.FilterType) o).getInitParam(); for (com.athena.chameleon.engine.entity.xml.webapp.v2_5.ParamValueType param : paramList) { // init-param? param-name? encoding? ? if (param.getParamName().getValue().toLowerCase().equals("encoding")) { hasEncodingFilter = true; // param-value UTF-8? ? if (ArrayUtils.contains(charSet, param.getParamValue().getValue().toUpperCase())) { hasUTF8EncodingFilter = true; break; } } } if (hasEncodingFilter) { break; } } } // encoding filter UTF-8? ? filter ? filter-mapping . if (hasEncodingFilter && !hasUTF8EncodingFilter) { JAXBElement<?> f = null; JAXBElement<?> fm = null; for (JAXBElement<?> element : elementList) { o = element.getValue(); if (o instanceof com.athena.chameleon.engine.entity.xml.webapp.v2_5.FilterType) { if (((com.athena.chameleon.engine.entity.xml.webapp.v2_5.FilterType) o).getFilterName() .getValue().equals(filtername.getValue())) { f = element; } } else if (o instanceof com.athena.chameleon.engine.entity.xml.webapp.v2_5.FilterMappingType) { if (((com.athena.chameleon.engine.entity.xml.webapp.v2_5.FilterMappingType) o) .getFilterName().getValue().equals(filtername.getValue())) { fm = element; } } } webApp.getDescriptionAndDisplayNameAndIcon().remove(f); webApp.getDescriptionAndDisplayNameAndIcon().remove(fm); } if (!hasUTF8EncodingFilter) { // <filter> element com.athena.chameleon.engine.entity.xml.webapp.v2_5.FilterType filter = new com.athena.chameleon.engine.entity.xml.webapp.v2_5.FilterType(); com.athena.chameleon.engine.entity.xml.webapp.v2_5.FilterNameType filterName = new com.athena.chameleon.engine.entity.xml.webapp.v2_5.FilterNameType(); filterName.setValue("UTF_EncodingFilter"); filter.setFilterName(filterName); com.athena.chameleon.engine.entity.xml.webapp.v2_5.FullyQualifiedClassType filterClass = new com.athena.chameleon.engine.entity.xml.webapp.v2_5.FullyQualifiedClassType(); filterClass.setValue("com.osc.filters.SetCharacterEncodingFilter"); filter.setFilterClass(filterClass); // <init-param> element com.athena.chameleon.engine.entity.xml.webapp.v2_5.ParamValueType paramValue = new com.athena.chameleon.engine.entity.xml.webapp.v2_5.ParamValueType(); com.athena.chameleon.engine.entity.xml.webapp.v2_5.String strName = new com.athena.chameleon.engine.entity.xml.webapp.v2_5.String(); strName.setValue("encoding"); com.athena.chameleon.engine.entity.xml.webapp.v2_5.XsdStringType strValue = new com.athena.chameleon.engine.entity.xml.webapp.v2_5.XsdStringType(); strValue.setValue("UTF-8"); paramValue.setParamName(strName); paramValue.setParamValue(strValue); filter.getInitParam().add(paramValue); paramValue = new com.athena.chameleon.engine.entity.xml.webapp.v2_5.ParamValueType(); strName = new com.athena.chameleon.engine.entity.xml.webapp.v2_5.String(); strName.setValue("forceEncoding"); strValue = new com.athena.chameleon.engine.entity.xml.webapp.v2_5.XsdStringType(); strValue.setValue("UTF-8"); paramValue.setParamName(strName); paramValue.setParamValue(strValue); filter.getInitParam().add(paramValue); // <filter-mapping> elemnet com.athena.chameleon.engine.entity.xml.webapp.v2_5.FilterMappingType filterMapping = new com.athena.chameleon.engine.entity.xml.webapp.v2_5.FilterMappingType(); com.athena.chameleon.engine.entity.xml.webapp.v2_5.UrlPatternType urlPattern = new com.athena.chameleon.engine.entity.xml.webapp.v2_5.UrlPatternType(); urlPattern.setValue("/*"); filterMapping.getUrlPatternOrServletName().add(urlPattern); filterMapping.setFilterName(filterName); // <web-app>? filter com.athena.chameleon.engine.entity.xml.webapp.v2_5.ObjectFactory factory = new com.athena.chameleon.engine.entity.xml.webapp.v2_5.ObjectFactory(); webApp.getDescriptionAndDisplayNameAndIcon().add(factory.createWebAppTypeFilter(filter)); webApp.getDescriptionAndDisplayNameAndIcon() .add(factory.createWebAppTypeFilterMapping(filterMapping)); try { // Filter ?? fileCopy(new File(WebXMLParser.class.getResource("/lib/osc-filters.jar").getFile()), new File(path, "lib/osc-filters.jar")); // web.xml String xmlData = JaxbUtils.marshal( com.athena.chameleon.engine.entity.xml.webapp.v2_5.WebAppType.class.getPackage() .getName(), webApp, new String[] { "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" }); rewrite(new File(path, "web.xml"), xmlData.replaceAll(" standalone=\"yes\"", "").replaceAll(" standalone=\"true\"", "")); logger.debug("web.xml has been modified.\n{}", xmlData); } catch (JAXBException e) { logger.error("JAXBException has occurred.", e); throw e; } catch (IOException e) { logger.error("IOException has occurred.", e); throw e; } } return webApp; } else if (obj instanceof com.athena.chameleon.engine.entity.xml.webapp.v2_4.WebAppType) { com.athena.chameleon.engine.entity.xml.webapp.v2_4.WebAppType webApp = (com.athena.chameleon.engine.entity.xml.webapp.v2_4.WebAppType) obj; // webApp? <filter />, <filter-mapping />? ? List<Object> elementList = webApp.getDescriptionAndDisplayNameAndIcon(); List<com.athena.chameleon.engine.entity.xml.webapp.v2_4.ParamValueType> paramList = null; com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterNameType filtername = null; for (Object element : elementList) { if (element instanceof com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterType) { filtername = ((com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterType) element) .getFilterName(); paramList = ((com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterType) element) .getInitParam(); for (com.athena.chameleon.engine.entity.xml.webapp.v2_4.ParamValueType param : paramList) { // init-param? param-name? encoding? ? if (param.getParamName().getValue().toLowerCase().equals("encoding")) { hasEncodingFilter = true; // param-value UTF-8? ? if (ArrayUtils.contains(charSet, param.getParamValue().getValue().toUpperCase())) { hasUTF8EncodingFilter = true; break; } } } if (hasEncodingFilter) { break; } } } // encoding filter UTF-8? ? filter ? filter-mapping . if (hasEncodingFilter && !hasUTF8EncodingFilter) { com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterType f = null; com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterMappingType fm = null; for (Object element : elementList) { if (element instanceof com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterType) { if (((com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterType) element) .getFilterName().getValue().equals(filtername.getValue())) { f = (com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterType) element; } } else if (element instanceof com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterMappingType) { if (((com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterMappingType) element) .getFilterName().getValue().equals(filtername.getValue())) { fm = (com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterMappingType) element; } } } webApp.getDescriptionAndDisplayNameAndIcon().remove(f); webApp.getDescriptionAndDisplayNameAndIcon().remove(fm); } if (!hasUTF8EncodingFilter) { // <filter> element com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterType filter = new com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterType(); com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterNameType filterName = new com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterNameType(); filterName.setValue("UTF_EncodingFilter"); filter.setFilterName(filterName); com.athena.chameleon.engine.entity.xml.webapp.v2_4.FullyQualifiedClassType filterClass = new com.athena.chameleon.engine.entity.xml.webapp.v2_4.FullyQualifiedClassType(); filterClass.setValue("com.osc.filters.SetCharacterEncodingFilter"); filter.setFilterClass(filterClass); // <init-param> element com.athena.chameleon.engine.entity.xml.webapp.v2_4.ParamValueType paramValue = new com.athena.chameleon.engine.entity.xml.webapp.v2_4.ParamValueType(); com.athena.chameleon.engine.entity.xml.webapp.v2_4.String strName = new com.athena.chameleon.engine.entity.xml.webapp.v2_4.String(); strName.setValue("encoding"); com.athena.chameleon.engine.entity.xml.webapp.v2_4.XsdStringType strValue = new com.athena.chameleon.engine.entity.xml.webapp.v2_4.XsdStringType(); strValue.setValue("UTF-8"); paramValue.setParamName(strName); paramValue.setParamValue(strValue); filter.getInitParam().add(paramValue); paramValue = new com.athena.chameleon.engine.entity.xml.webapp.v2_4.ParamValueType(); strName = new com.athena.chameleon.engine.entity.xml.webapp.v2_4.String(); strName.setValue("forceEncoding"); strValue = new com.athena.chameleon.engine.entity.xml.webapp.v2_4.XsdStringType(); strValue.setValue("UTF-8"); paramValue.setParamName(strName); paramValue.setParamValue(strValue); filter.getInitParam().add(paramValue); // <filter-mapping> elemnet com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterMappingType filterMapping = new com.athena.chameleon.engine.entity.xml.webapp.v2_4.FilterMappingType(); com.athena.chameleon.engine.entity.xml.webapp.v2_4.UrlPatternType urlPattern = new com.athena.chameleon.engine.entity.xml.webapp.v2_4.UrlPatternType(); urlPattern.setValue("/*"); filterMapping.setUrlPattern(urlPattern); filterMapping.setFilterName(filterName); // <web-app>? filter webApp.getDescriptionAndDisplayNameAndIcon().add(filter); webApp.getDescriptionAndDisplayNameAndIcon().add(filterMapping); try { // Filter ?? fileCopy(new File(WebXMLParser.class.getResource("/lib/osc-filters.jar").getFile()), new File(path, "lib/osc-filters.jar")); // web.xml String xmlData = JaxbUtils.marshal( com.athena.chameleon.engine.entity.xml.webapp.v2_4.WebAppType.class.getPackage() .getName(), webApp, new String[] { "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" }); rewrite(new File(path, "web.xml"), xmlData.replaceAll(" standalone=\"yes\"", "").replaceAll(" standalone=\"true\"", "")); logger.debug("web.xml has been modified.\n{}", xmlData); } catch (JAXBException e) { logger.error("JAXBException has occurred.", e); throw e; } catch (IOException e) { logger.error("IOException has occurred.", e); throw e; } } return webApp; } else { com.athena.chameleon.engine.entity.xml.webapp.v2_3.WebApp webApp = (com.athena.chameleon.engine.entity.xml.webapp.v2_3.WebApp) obj; // webApp? <filter />, <filter-mapping />? ? List<com.athena.chameleon.engine.entity.xml.webapp.v2_3.Filter> filterList = webApp.getFilter(); com.athena.chameleon.engine.entity.xml.webapp.v2_3.FilterName filtername = null; List<com.athena.chameleon.engine.entity.xml.webapp.v2_3.InitParam> initParamList = null; for (com.athena.chameleon.engine.entity.xml.webapp.v2_3.Filter filter : filterList) { filtername = filter.getFilterName(); initParamList = filter.getInitParam(); for (com.athena.chameleon.engine.entity.xml.webapp.v2_3.InitParam initParam : initParamList) { if (initParam.getParamName().getvalue().toLowerCase().equals("encoding")) { hasEncodingFilter = true; // param-value UTF-8? ? if (ArrayUtils.contains(charSet, initParam.getParamValue().getvalue().toUpperCase())) { hasUTF8EncodingFilter = true; break; } } } if (hasEncodingFilter) { break; } } // encoding filter UTF-8? ? filter ? filter-mapping . if (hasEncodingFilter && !hasUTF8EncodingFilter) { com.athena.chameleon.engine.entity.xml.webapp.v2_3.Filter filter = null; for (com.athena.chameleon.engine.entity.xml.webapp.v2_3.Filter f : filterList) { if (f.getFilterName().getvalue().equals(filtername.getvalue())) { filter = f; } } List<com.athena.chameleon.engine.entity.xml.webapp.v2_3.FilterMapping> filterMappingList = webApp .getFilterMapping(); com.athena.chameleon.engine.entity.xml.webapp.v2_3.FilterMapping filterMapping = null; for (com.athena.chameleon.engine.entity.xml.webapp.v2_3.FilterMapping fm : filterMappingList) { if (fm.getFilterName().getvalue().equals(filtername.getvalue())) { filterMapping = fm; } } webApp.getFilter().remove(filter); webApp.getFilterMapping().remove(filterMapping); } if (!hasUTF8EncodingFilter) { // <filter> element com.athena.chameleon.engine.entity.xml.webapp.v2_3.Filter filter = new com.athena.chameleon.engine.entity.xml.webapp.v2_3.Filter(); com.athena.chameleon.engine.entity.xml.webapp.v2_3.FilterName filterName = new com.athena.chameleon.engine.entity.xml.webapp.v2_3.FilterName(); filterName.setvalue("UTF_EncodingFilter"); filter.setFilterName(filterName); com.athena.chameleon.engine.entity.xml.webapp.v2_3.FilterClass filterClass = new com.athena.chameleon.engine.entity.xml.webapp.v2_3.FilterClass(); filterClass.setvalue("com.osc.filters.SetCharacterEncodingFilter"); filter.setFilterClass(filterClass); // <init-param> element com.athena.chameleon.engine.entity.xml.webapp.v2_3.InitParam initParam = new com.athena.chameleon.engine.entity.xml.webapp.v2_3.InitParam(); com.athena.chameleon.engine.entity.xml.webapp.v2_3.ParamName paramName = new com.athena.chameleon.engine.entity.xml.webapp.v2_3.ParamName(); com.athena.chameleon.engine.entity.xml.webapp.v2_3.ParamValue paramValue = new com.athena.chameleon.engine.entity.xml.webapp.v2_3.ParamValue(); paramName.setvalue("encoding"); paramValue.setvalue("UTF-8"); initParam.setParamName(paramName); initParam.setParamValue(paramValue); filter.getInitParam().add(initParam); initParam = new com.athena.chameleon.engine.entity.xml.webapp.v2_3.InitParam(); paramName = new com.athena.chameleon.engine.entity.xml.webapp.v2_3.ParamName(); paramValue = new com.athena.chameleon.engine.entity.xml.webapp.v2_3.ParamValue(); paramName.setvalue("forceEncoding"); paramValue.setvalue("UTF-8"); initParam.setParamName(paramName); initParam.setParamValue(paramValue); filter.getInitParam().add(initParam); // <filter-mapping> elemnet com.athena.chameleon.engine.entity.xml.webapp.v2_3.FilterMapping filterMapping = new com.athena.chameleon.engine.entity.xml.webapp.v2_3.FilterMapping(); com.athena.chameleon.engine.entity.xml.webapp.v2_3.UrlPattern urlPattern = new com.athena.chameleon.engine.entity.xml.webapp.v2_3.UrlPattern(); urlPattern.setvalue("/*"); filterMapping.getUrlPatternOrServletName().add(urlPattern); filterMapping.setFilterName(filterName); // <web-app>? filter webApp.getFilter().add(filter); webApp.getFilterMapping().add(filterMapping); try { // Filter ?? fileCopy(new File(WebXMLParser.class.getResource("/lib/osc-filters.jar").getFile()), new File(path, "lib/osc-filters.jar")); // web.xml String xmlData = JaxbUtils.marshal( com.athena.chameleon.engine.entity.xml.webapp.v2_3.WebApp.class.getPackage().getName(), webApp, "<!DOCTYPE web-app PUBLIC \"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN\" \"http://java.sun.com/dtd/web-app_2_3.dtd\">"); rewrite(new File(path, "web.xml"), xmlData.replaceAll(" standalone=\"yes\"", "").replaceAll(" standalone=\"true\"", "")); logger.debug("web.xml has been modified.\n{}", xmlData); } catch (JAXBException e) { logger.error("JAXBException has occurred.", e); throw e; } catch (IOException e) { logger.error("IOException has occurred.", e); throw e; } } return webApp; } }
From source file:com.evolveum.midpoint.testing.model.client.sample.TestExchangeConnector.java
private static <T> T unmarshallFile(File file) throws JAXBException, FileNotFoundException { JAXBContext jc = ModelClientUtil.instantiateJaxbContext(); Unmarshaller unmarshaller = jc.createUnmarshaller(); InputStream is = null;/* w w w.j a v a2 s . c om*/ JAXBElement<T> element = null; try { is = new FileInputStream(file); element = (JAXBElement<T>) unmarshaller.unmarshal(is); } finally { if (is != null) { IOUtils.closeQuietly(is); } } if (element == null) { return null; } return element.getValue(); }
From source file:com.bluexml.xforms.controller.mapping.MappingToolCommon.java
/** * Unmarshal./* ww w.ja v a 2 s .co m*/ * * @param alfrescoNode * the alfresco node * @return the com.bluexml.xforms.controller.alfresco.binding. class * @throws JAXBException * the JAXB exception */ public static synchronized GenericClass unmarshal(Document alfrescoNode) throws JAXBException { JAXBElement<GenericClass> alfrescoClass = alfrescoUnmarshaller.unmarshal(alfrescoNode, GenericClass.class); return alfrescoClass.getValue(); }
From source file:be.fedict.eid.applet.service.signer.ooxml.OOXMLSignatureVerifier.java
@SuppressWarnings("unchecked") public List<String> getSignatureResourceNames(byte[] document) throws IOException, JAXBException { List<String> signatureResourceNames = new LinkedList<String>(); ZipInputStream zipInputStream = new ZipInputStream(new ByteArrayInputStream(document)); ZipEntry zipEntry;/*from w w w.j a va 2 s .com*/ while (null != (zipEntry = zipInputStream.getNextEntry())) { if ("_rels/.rels".equals(zipEntry.getName())) { break; } } if (null == zipEntry) { LOG.debug("no _rels/.rels relationship part present"); return signatureResourceNames; } String dsOriginPart = null; JAXBElement<CTRelationships> packageRelationshipsElement = (JAXBElement<CTRelationships>) this.relationshipsUnmarshaller .unmarshal(zipInputStream); CTRelationships packageRelationships = packageRelationshipsElement.getValue(); List<CTRelationship> packageRelationshipList = packageRelationships.getRelationship(); for (CTRelationship packageRelationship : packageRelationshipList) { if (DIGITAL_SIGNATURE_ORIGIN_REL_TYPE.equals(packageRelationship.getType())) { dsOriginPart = packageRelationship.getTarget(); break; } } if (null == dsOriginPart) { LOG.debug("no Digital Signature Origin part present"); return signatureResourceNames; } LOG.debug("Digital Signature Origin part: " + dsOriginPart); String dsOriginName = dsOriginPart.substring(dsOriginPart.lastIndexOf("/") + 1); LOG.debug("Digital Signature Origin base: " + dsOriginName); String dsOriginSegment = dsOriginPart.substring(0, dsOriginPart.lastIndexOf("/")) + "/"; LOG.debug("Digital Signature Origin segment: " + dsOriginSegment); String dsOriginRels = dsOriginSegment + "_rels/" + dsOriginName + ".rels"; LOG.debug("Digital Signature Origin relationship part: " + dsOriginRels); zipInputStream = new ZipInputStream(new ByteArrayInputStream(document)); while (null != (zipEntry = zipInputStream.getNextEntry())) { if (dsOriginRels.equals(zipEntry.getName())) { break; } } if (null == zipEntry) { LOG.debug("no Digital Signature Origin relationship part present"); return signatureResourceNames; } JAXBElement<CTRelationships> dsoRelationshipsElement = (JAXBElement<CTRelationships>) this.relationshipsUnmarshaller .unmarshal(zipInputStream); CTRelationships dsoRelationships = dsoRelationshipsElement.getValue(); List<CTRelationship> dsoRelationshipList = dsoRelationships.getRelationship(); for (CTRelationship dsoRelationship : dsoRelationshipList) { if (DIGITAL_SIGNATURE_REL_TYPE.equals(dsoRelationship.getType())) { String signatureResourceName = dsOriginSegment + dsoRelationship.getTarget(); signatureResourceNames.add(signatureResourceName); } } return signatureResourceNames; }
From source file:com.inmobi.grill.client.GrillMetadataClient.java
public List<XPartition> getPartitionsOfFactTable(String factName, String storage, String filter) { WebTarget target = getMetastoreWebTarget(); JAXBElement<PartitionList> elements = target.path("facts").path(factName).path("storages").path(storage) .path("partitions").queryParam("sessionid", this.connection.getSessionHandle()) .queryParam("filter", filter).request(MediaType.APPLICATION_XML) .get(new GenericType<JAXBElement<PartitionList>>() { });/*w w w.j a va 2 s . c o m*/ return elements.getValue().getXPartition(); }
From source file:com.inmobi.grill.client.GrillMetadataClient.java
public List<XPartition> getAllPartitionsOfDimension(String dimName, String storage, String filter) { WebTarget target = getMetastoreWebTarget(); JAXBElement<PartitionList> partList = target.path("dimensions").path(dimName).path("storages").path(storage) .path("partitions").queryParam("sessionid", this.connection.getSessionHandle()) .queryParam("filter", filter).request(MediaType.APPLICATION_XML) .get(new GenericType<JAXBElement<PartitionList>>() { });//from ww w . j a va2 s.co m return partList.getValue().getXPartition(); }