Search in sources :

Example 1 with IDataTemplatingStrategy

use of org.apereo.portal.io.xml.IDataTemplatingStrategy in project uPortal by Jasig.

the class TemplateDataTenantOperationsListener method importQueue.

/**
 * Imports the specified entities in the proper order.
 */
private void importQueue(final ITenant tenant, final Map<PortalDataKey, Set<BucketTuple>> queue, final StringBuilder importReport) throws Exception {
    final StandardEvaluationContext ctx = new StandardEvaluationContext();
    ctx.setRootObject(new RootObjectImpl(tenant));
    IDataTemplatingStrategy templating = new SpELDataTemplatingStrategy(portalSpELService, ctx);
    Document doc = null;
    try {
        for (PortalDataKey pdk : dataKeyImportOrder) {
            Set<BucketTuple> bucket = queue.get(pdk);
            if (bucket != null) {
                log.debug("Importing the specified PortalDataKey tenant '{}':  {}", tenant.getName(), pdk.getName());
                for (BucketTuple tuple : bucket) {
                    doc = tuple.getDocument();
                    Source data = templating.processTemplates(doc, tuple.getResource().getURL().toString());
                    dataHandlerService.importData(data, pdk);
                    importReport.append(createImportReportLineItem(pdk, tuple));
                }
            }
        }
    } catch (Exception e) {
        log.error("Failed to process the specified template document:\n{}", (doc != null ? doc.asXML() : "null"), e);
        throw e;
    }
}
Also used : StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) SpELDataTemplatingStrategy(org.apereo.portal.io.xml.SpELDataTemplatingStrategy) IDataTemplatingStrategy(org.apereo.portal.io.xml.IDataTemplatingStrategy) PortalDataKey(org.apereo.portal.io.xml.PortalDataKey) Document(org.dom4j.Document) Source(javax.xml.transform.Source) URISyntaxException(java.net.URISyntaxException)

Aggregations

URISyntaxException (java.net.URISyntaxException)1 Source (javax.xml.transform.Source)1 IDataTemplatingStrategy (org.apereo.portal.io.xml.IDataTemplatingStrategy)1 PortalDataKey (org.apereo.portal.io.xml.PortalDataKey)1 SpELDataTemplatingStrategy (org.apereo.portal.io.xml.SpELDataTemplatingStrategy)1 Document (org.dom4j.Document)1 StandardEvaluationContext (org.springframework.expression.spel.support.StandardEvaluationContext)1