Skip to content

Commit

Permalink
Changes for this version include:
Browse files Browse the repository at this point in the history
- now ISO services are returned as distributions of a dataset and no longer as separate datasets
- removed outdated mappings from XSLT
- removed unused dependencies and resources
- updated dependency versions
- many minor fixes
  • Loading branch information
einspanier committed May 29, 2019
1 parent eca00d0 commit 3044d82
Show file tree
Hide file tree
Showing 13 changed files with 426 additions and 1,226 deletions.
11 changes: 0 additions & 11 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,3 @@ The names "Spring" and "Spring Framework" must not be used to
endorse or promote products derived from this software without
prior written permission. For written permission, please contact
rod.johnson@interface21.com or juergen.hoeller@interface21.com.

=========================================================================
== H2 Notice ==
=========================================================================

This software contains unmodified binary redistributions for
H2 database engine (http://www.h2database.com/),
which is dual licensed and available under the MPL 2.0
(Mozilla Public License) or under the EPL 1.0 (Eclipse Public License).
An original copy of the license agreement can be found at:
http://www.h2database.com/html/license.html
11 changes: 2 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,8 @@
</pluginManagement>
</build>
<properties>
<camel.version>2.22.2</camel.version>
<spring.version>5.0.10.RELEASE</spring.version>
<!--
<oai-pmh.base.url.external>http://localhost:8080/omdf</oai-pmh.base.url.external>
<db.item.csw.TYPE>inspire</db.item.csw.TYPE>
<db.item.csw.URL>http://localhost:8080/soapServices/CSWStartup</db.item.csw.URL>
<db.item.ckan.TYPE>ckan</db.item.ckan.TYPE>
<db.item.ckan.URL>http://localhost:9090</db.item.ckan.URL>
-->
<camel.version>2.24.0</camel.version>
<spring.version>5.1.6.RELEASE</spring.version>
</properties>
<profiles>
<profile>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package eu.odp.harvest.geo.oai.xslt;

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.xml.XsltUriResolver;
import org.apache.camel.impl.DefaultExchange;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.methods.GetMethod;
Expand All @@ -14,33 +18,62 @@

/**
* Resolves a document reference for protocols "http" or "https" in an XSL document with HTTP client.
* It can also invoke custom Camel routes to get documents for protocol type "direct".
* For all other URIs uses the default resolver base don classpath.
*/
public class HttpAwareUriResolver extends XsltUriResolver {

private final static Logger LOG = Logger.getLogger(HttpAwareUriResolver.class);

private static HttpClient httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
private ProducerTemplate template;
private CamelContext context;

public HttpAwareUriResolver(CamelContext context, String location) {
/**
* Constructor.
* @param context Camel Context
* @param location location
* @param template producer template used to call other Camel routes
*/
public HttpAwareUriResolver(CamelContext context, String location, ProducerTemplate template) {
super(context, location);
this.template = template;
this.context = context;
}

@Override
public Source resolve(String href, String base) throws TransformerException {
if (href.startsWith("http:") || href.startsWith("https:")) {
if (href.startsWith("direct:getCoupledServices")) {
try {
return resolveRoute(href);
}
catch (Exception e) {
LOG.error("Error resolving direct resource " + href, e);
throw new TransformerException("Error resolving direct resource " + href, e);
}
}
else if (href.startsWith("http:") || href.startsWith("https:")) {
try {
return resolveHttp(href);
}
catch (Exception e) {
LOG.error("Error resolving resource " + href, e);
throw new TransformerException("Error resolving resource " + href, e);
LOG.error("Error resolving http resource " + href, e);
throw new TransformerException("Error resolving http resource " + href, e);
}
}
else {
return super.resolve(href, base);
}
}

private Source resolveRoute(String href) {
Exchange exchange = new DefaultExchange(context, ExchangePattern.InOut);
String[] parts = href.split("\\?");
exchange.getIn().setHeader("resourceIdentifiers", parts[1]);
template.send(parts[0], exchange);
return new StreamSource(exchange.getOut().getBody(java.io.InputStream.class));
}

private Source resolveHttp(String href) throws Exception {
GetMethod method = new GetMethod(href);
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
package eu.odp.harvest.geo.oai.xslt;

import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.xslt.XsltUriResolverFactory;

import javax.xml.transform.URIResolver;

/**
* Factory class for custom XSLT URI resolver.
*/
public class HttpAwareUriResolverFactory implements XsltUriResolverFactory {
private ProducerTemplate template;

/**
* Factory method.
* @param camelContext camel context
* @param resourceUri URI to be resolved
* @return URI resolver
*/
public URIResolver createUriResolver(CamelContext camelContext, String resourceUri) {
return new HttpAwareUriResolver(camelContext, resourceUri);
return new HttpAwareUriResolver(camelContext, resourceUri, template);
}

/**
* Sets the producer template.
* @param template producer template
*/
public void setProducer(ProducerTemplate template) {
this.template = template;
}
}
Loading

0 comments on commit 3044d82

Please sign in to comment.