Pre-processing Mashup
To implement pre-processing
1. Write the logic to handle pre-processing as a Java class or use Java libraries, as needed.
2. Add the custom Java classes to the classpath for the Presto Server. Copy them to:
![*](bullet.gif)
The external configuration folder, if any, for the
Presto Server.
Important: | Deploying additional resources, such as custom XPath classes, to an external configuration folder simplifies future deployments or Presto Server clusters. |
web-apps-home/presto/WEB-INF/classes. This is the default location, but is not recommended as it complicates
Presto Server deployments.
web-apps-home/presto/WEB-INF/lib. This is the default location, but is not recommended as it complicates
Presto Server deployments.
3. Restart the Presto Server.
4. Create a mashup script with the following components:
a. <input> variables, as needed, to receive the data to be pre-processed and an <output> variable for the result. For example:
...
<operation name="getreviews">
<input name="userId" type="string" default="someone@myOrg.com" />
<input name="accessId" type="string"
default="xOtPy9Sy7JCI3Y8aNqEkZBxmkPQw/ZH8"/>
<output name="result" type="string"/>
b. Add a <script> statement to call the pre-processing logic.
This example uses JavaScript scripting and shows an encryption class that decrypts the accessId input parameter. To call the pre-processing logic in JavaScript, you must use fully qualified class names starting with the Packages keyword.
...
<output name="result" type="string" inputvariables="$accessId"
outputvariable="$accessId"/>
<script type="text/javascript">
<![CDATA[
var encrypter = new
Packages.com.myOrg.services.Encrypter("My Pass Phrase!")
accessId = encrypter.decrypt(accessId);
]]>
</script>
c. Invoke the mashable information source with the pre-processed data. For example:
...
</script>
<invoke service="AmazonREST" operation="getData"
inputvariables="'AWSECommerceService', '2007-07-16', accessId,
'ListSearch', 'WishList', userId"
filterexpr="//ns:List[ns:TotalItems > 1]"
outputvariable="$result"/>