Search in sources :

Example 16 with ParserException

use of org.codice.ddf.parser.ParserException in project ddf by codice.

the class XmlParser method getContext.

private JAXBContext getContext(List<String> contextPath, ClassLoader loader) throws ParserException {
    String joinedPath = CTX_JOINER.join(contextPath);
    JAXBContext jaxbContext;
    try {
        jaxbContext = jaxbContextCache.get(new CacheKey(joinedPath, loader));
    } catch (ExecutionException e) {
        LOGGER.info("Unable to create JAXB context using context path: {}", joinedPath, e);
        throw new ParserException("Unable to create XmlParser", e.getCause());
    }
    return jaxbContext;
}
Also used : ParserException(org.codice.ddf.parser.ParserException) JAXBContext(javax.xml.bind.JAXBContext) ExecutionException(java.util.concurrent.ExecutionException)

Example 17 with ParserException

use of org.codice.ddf.parser.ParserException in project ddf by codice.

the class MetacardMarshaller method getRegistryPackageAsXml.

/**
     * Converts the RegistryPackageType into an xml string
     *
     * @param registryPackage Registry package to convert
     * @return Ebrim xml string
     * @throws ParserException
     */
public String getRegistryPackageAsXml(RegistryPackageType registryPackage) throws ParserException {
    try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
        JAXBElement<RegistryPackageType> registryObjectTypeJAXBElement = EbrimConstants.RIM_FACTORY.createRegistryPackage(registryPackage);
        parser.marshal(marshalConfigurator, registryObjectTypeJAXBElement, outputStream);
        return new String(outputStream.toByteArray(), StandardCharsets.UTF_8);
    } catch (IOException e) {
        throw new ParserException("Error parsing registry package to ebrim xml", e);
    }
}
Also used : ParserException(org.codice.ddf.parser.ParserException) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

ParserException (org.codice.ddf.parser.ParserException)17 ArrayList (java.util.ArrayList)7 ParserConfigurator (org.codice.ddf.parser.ParserConfigurator)7 IOException (java.io.IOException)5 Map (java.util.Map)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 JAXBElement (javax.xml.bind.JAXBElement)4 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)4 InputStream (java.io.InputStream)3 UsernameTokenType (org.apache.cxf.ws.security.sts.provider.model.secext.UsernameTokenType)3 Metacard (ddf.catalog.data.Metacard)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Principal (java.security.Principal)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 CallbackHandler (javax.security.auth.callback.CallbackHandler)2 JAXBContext (javax.xml.bind.JAXBContext)2 ExternalIdentifierType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType)2 STSPropertiesMBean (org.apache.cxf.sts.STSPropertiesMBean)2 ReceivedToken (org.apache.cxf.sts.request.ReceivedToken)2 TokenValidator (org.apache.cxf.sts.token.validator.TokenValidator)2