Last active
December 15, 2015 15:58
-
-
Save Vampouille/cdcc4ddb69fed5408c39 to your computer and use it in GitHub Desktop.
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
<rest> | |
<post uri="/atlas" consumes="application/json" produces="application/json" enableCORS="true"> | |
<to uri="direct:atlas"/> | |
</post> | |
</rest> | |
<route id="atlas"> | |
<from uri="direct:atlas"/> | |
<!-- Backup original Json--> | |
<setProperty propertyName="rawJson"> | |
<simple>${body}</simple> | |
</setProperty> | |
<!-- parse json --> | |
<unmarshal ref="gson"/> | |
<!-- Store parsed Json--> | |
<setProperty propertyName="rootJson"> | |
<simple>${body}</simple> | |
</setProperty> | |
<split> | |
<simple>${body[pages]}</simple> | |
<!-- Add layers property --> | |
<to uri="bean:printMerge"/> | |
<transform> | |
<simple> | |
{ "layout": "${exchangeProperty.rootJson[layout]}", | |
"outputFormat": "${exchangeProperty.rootJson[outputFormat]}", | |
"attributes": { | |
"map": { | |
"projection": "${exchangeProperty.rootJson[srs]}", | |
"dpi": ${exchangeProperty.rootJson[dpi]}, | |
"center": ${body[center]}, | |
"scale": ${body[scale]}, | |
"layers": ${exchangeProperty.layers} | |
} | |
} | |
} | |
</simple> | |
</transform> | |
<!-- Test Json validity --> | |
<!--<marshal ref="gson"/>--> | |
<!--<marshal ref="gson"/>--> | |
<log message="${body}" loggingLevel="ERROR"/> | |
<!--<marshal ref="gson"/>--> | |
<to uri="file:///tmp/log?autoCreate=true"/> | |
</split> | |
</route> |
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
public class PrintMerge { | |
@Handler | |
public void merge(Exchange ex) throws JSONException { | |
JSONObject page = new JSONObject(new JSONTokener(ex.getIn().getBody(String.class))); | |
JSONArray layers = new JSONArray(new JSONTokener(ex.getProperty("layers", String.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
<servlet> | |
<servlet-name>CamelServlet</servlet-name> | |
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class> | |
<load-on-startup>1</load-on-startup> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>CamelServlet</servlet-name> | |
<url-pattern>/apps/*</url-pattern> | |
</servlet-mapping> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment