Search in sources :

Example 1 with ResourceHandler

use of com.agiletec.plugins.jacms.aps.system.services.resource.parse.ResourceHandler in project entando-core by entando.

the class ResourceManager method fillEmptyResourceFromXml.

/**
 * Valorizza una risorsa prototipo con gli elementi
 * dell'xml che rappresenta una risorsa specifica.
 * @param resource Il prototipo di risorsa da specializzare con gli attributi dell'xml.
 * @param xml L'xml della risorsa specifica.
 * @throws ApsSystemException
 */
protected void fillEmptyResourceFromXml(ResourceInterface resource, String xml) throws ApsSystemException {
    try {
        SAXParserFactory parseFactory = SAXParserFactory.newInstance();
        SAXParser parser = parseFactory.newSAXParser();
        InputSource is = new InputSource(new StringReader(xml));
        ResourceHandler handler = new ResourceHandler(resource, this.getCategoryManager());
        parser.parse(is, handler);
    } catch (Throwable t) {
        logger.error("Error loading resource", t);
        throw new ApsSystemException("Error loading resource", t);
    }
}
Also used : InputSource(org.xml.sax.InputSource) StringReader(java.io.StringReader) SAXParser(javax.xml.parsers.SAXParser) ResourceHandler(com.agiletec.plugins.jacms.aps.system.services.resource.parse.ResourceHandler) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Aggregations

ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1 ResourceHandler (com.agiletec.plugins.jacms.aps.system.services.resource.parse.ResourceHandler)1 StringReader (java.io.StringReader)1 SAXParser (javax.xml.parsers.SAXParser)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 InputSource (org.xml.sax.InputSource)1