This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sample.xslt; | |
import java.util.Random; | |
import net.sf.saxon.s9api.ExtensionFunction; | |
import net.sf.saxon.s9api.ItemType; | |
import net.sf.saxon.s9api.OccurrenceIndicator; | |
import net.sf.saxon.s9api.QName; | |
import net.sf.saxon.s9api.SaxonApiException; | |
import net.sf.saxon.s9api.SequenceType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.mule.api.MuleEventContext; | |
import org.mule.api.lifecycle.Callable; | |
import org.mule.api.transport.PropertyScope; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.security.ldap.userdetails.LdapUserDetailsImpl; | |
public class UserACLExtractor implements Callable { | |
private static final Logger log = LoggerFactory.getLogger(UserACLExtractor.class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.mule.api.transport.OutputHandler | |
// store the current payload at the time the script is invoked | |
// (i.e. the back-end response stream/iterator) | |
def itr = payload; | |
// return a Groovy closure / lambda | |
return {evt, out -> | |
// define a stream XML builder object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
* The software in this package is published under the terms of the CPAL v1.0 | |
* license, a copy of which has been included with this distribution in the | |
* LICENSE.txt file. | |
*/ | |
package org.mule.api.transport; | |
import org.mule.api.MuleEvent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// no need to use builder here, just raw Groovy map syntax | |
//get DOMCategory to get access to GPATH style operations like getNode getNodeAt etc. | |
import au.com.sixtree.java.esb.mapper.DOMCategory; | |
//declare a java.util.Map to hold results | |
def result = [:] | |
//get input root element | |
def _in = payload.documentElement | |
use(DOMCategory) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//import GroovyMap to get a handle to the transformation method - toXmlDom() | |
import au.com.sixtree.esb.mapper.GroovyMap | |
//DOMCategory to get us xpath style operations eg.getNode, getAttributes while traversing through the xml | |
import au.com.sixtree.java.esb.mapper.DOMCategory | |
import groovy.xml.XmlUtil; | |
//import static codeset cross-referencing helper class, see below for lookups | |
import au.com.sixtree.java.esb.mapper.ValueCrossReferenceHelper; | |
return GroovyMap.toXmlDom(payload) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//import the GroovyMap | |
import au.com.sixtree.esb.mapper.GroovyMap | |
//We have a customized version of DOMCategory helper class, this provides us with xpath like features to access elements | |
//The default version involves a slightly different syntax. | |
import au.com.sixtree.java.esb.mapper.DOMCategory | |
//GroovyMap's toXMLDom() method takes input as the root/documentElement of the XML tree, type @Element | |
//very similar to accessing the root element in Java - payload.getDocumentElement() | |
return GroovyMap.toXmlDom(payload.documentElement) { | |
//inputs is a list of input arguments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package au.com.sixtree.esb.mapper | |
import au.com.sixtree.esb.mapper.GroovyMap; | |
import au.com.sixtree.esb.mapper.DOMBuilder; | |
import groovy.json.JsonBuilder | |
import groovy.xml.MarkupBuilder | |
import groovy.xml.NamespaceBuilder; | |
import groovy.xml.XmlUtil | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// given | |
public abstract class Safely<R, V> { | |
public final V from(R root) { | |
try{ | |
return access(root) | |
} catch(NullPointerException npe) { | |
return null; | |
} | |
} |