Remove dependency on Repose by copying the remaining dependencies locally
This commit is contained in:
6
pom.xml
6
pom.xml
@@ -63,9 +63,9 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.rackspace.papi.components</groupId>
|
||||
<artifactId>translation</artifactId>
|
||||
<version>2.9.0</version>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>3.1.1.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.rackspace.cloud.api.docs.pipeline;
|
||||
|
||||
import com.rackspace.papi.components.translation.resolvers.InputStreamUriParameterResolver;
|
||||
|
||||
import com.rackspace.cloud.api.docs.pipeline.resolvers.InputStreamUriParameterResolver;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public abstract class AbstractPipeline implements Pipeline {
|
||||
private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(AbstractPipeline.class);
|
||||
private static final Logger LOG = Logger.getLogger(AbstractPipeline.class.getName());
|
||||
private final InputStreamUriParameterResolver resolver;
|
||||
|
||||
public AbstractPipeline(InputStreamUriParameterResolver resolver) {
|
||||
@@ -57,7 +58,7 @@ public abstract class AbstractPipeline implements Pipeline {
|
||||
try {
|
||||
((InputStream)source).close();
|
||||
} catch (IOException ex) {
|
||||
LOG.error("Unable to close input stream. Reason: " + ex.getMessage(), ex);
|
||||
LOG.log(Level.SEVERE, "Unable to close input stream. Reason: " + ex.getMessage(), ex);
|
||||
}
|
||||
resolver.removeStream((InputStream)source);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.rackspace.cloud.api.docs.pipeline;
|
||||
|
||||
import com.rackspace.papi.components.translation.resolvers.InputStreamUriParameterResolver;
|
||||
import com.rackspace.cloud.api.docs.pipeline.resolvers.InputStreamUriParameterResolver;
|
||||
import com.xmlcalabash.core.XProcRuntime;
|
||||
import com.xmlcalabash.io.ReadablePipe;
|
||||
import com.xmlcalabash.model.RuntimeValue;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.rackspace.cloud.api.docs.pipeline;
|
||||
|
||||
import com.rackspace.papi.components.translation.resolvers.ClassPathUriResolver;
|
||||
import com.rackspace.papi.components.translation.resolvers.InputStreamUriParameterResolver;
|
||||
import com.rackspace.cloud.api.docs.pipeline.resolvers.ClassPathUriResolver;
|
||||
import com.rackspace.cloud.api.docs.pipeline.resolvers.InputStreamUriParameterResolver;
|
||||
import com.xmlcalabash.core.XProcConfiguration;
|
||||
import com.xmlcalabash.core.XProcMessageListener;
|
||||
import com.xmlcalabash.core.XProcRuntime;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.rackspace.cloud.api.docs.pipeline.resolvers;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.URIResolver;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class ClassPathUriResolver extends SourceUriResolver {
|
||||
|
||||
public static final String CLASSPATH_PREFIX = "classpath://";
|
||||
|
||||
public ClassPathUriResolver() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ClassPathUriResolver(URIResolver parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Source resolve(String href, String base) throws TransformerException {
|
||||
|
||||
if (href != null && href.toLowerCase().startsWith(CLASSPATH_PREFIX)) {
|
||||
String path = href.substring(CLASSPATH_PREFIX.length());
|
||||
InputStream resource = getClass().getResourceAsStream(path);
|
||||
if (resource == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return new StreamSource(resource, getClass().getResource(path).toURI().toString());
|
||||
} catch (URISyntaxException ex) {
|
||||
return new StreamSource(resource);
|
||||
}
|
||||
}
|
||||
|
||||
return super.resolve(href, base);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.rackspace.cloud.api.docs.pipeline.resolvers;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.URIResolver;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.web.util.UriUtils;
|
||||
|
||||
public class InputStreamUriParameterResolver extends SourceUriResolver {
|
||||
|
||||
private static final String PREFIX = "reference:jio:";
|
||||
private final Map<String, InputStream> streams = new HashMap<String, InputStream>();
|
||||
private final List<URIResolver> resolvers = new ArrayList<URIResolver>();
|
||||
|
||||
public InputStreamUriParameterResolver() {
|
||||
super();
|
||||
}
|
||||
|
||||
public InputStreamUriParameterResolver(URIResolver parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
public void addResolver(URIResolver resolver) {
|
||||
resolvers.add(resolver);
|
||||
}
|
||||
|
||||
public String addStream(InputStream inputStreamReference) {
|
||||
String key = getHref(inputStreamReference);
|
||||
streams.put(key, inputStreamReference);
|
||||
return key;
|
||||
}
|
||||
|
||||
public String addStream(InputStream inputStreamReference, String name) {
|
||||
String key = getHref(name);
|
||||
streams.put(key, inputStreamReference);
|
||||
return key;
|
||||
}
|
||||
|
||||
public void removeStream(InputStream inputStreamReference) {
|
||||
String key = getHref(inputStreamReference);
|
||||
removeStream(key);
|
||||
}
|
||||
|
||||
public void removeStream(String name) {
|
||||
streams.remove(name);
|
||||
}
|
||||
|
||||
public String getHref(InputStream inputStreamReference) {
|
||||
try {
|
||||
return PREFIX + UriUtils.encodePathSegment(inputStreamReference.toString(), "utf-8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
return PREFIX + inputStreamReference.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public String getHref(String name) {
|
||||
return PREFIX + name;
|
||||
}
|
||||
|
||||
public void clearStreams() {
|
||||
streams.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Source resolve(String href, String base) throws TransformerException {
|
||||
InputStream stream = streams.get(href);
|
||||
if (stream != null) {
|
||||
try {
|
||||
return new StreamSource(stream, new URI(href).toString());
|
||||
} catch (URISyntaxException ex) {
|
||||
return new StreamSource(stream);
|
||||
}
|
||||
}
|
||||
|
||||
if (!resolvers.isEmpty()) {
|
||||
for (URIResolver resolver : resolvers) {
|
||||
Source source = resolver.resolve(href, base);
|
||||
if (source != null) {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return super.resolve(href, base);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.rackspace.cloud.api.docs.pipeline.resolvers;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.URIResolver;
|
||||
|
||||
public class SourceUriResolver implements URIResolver {
|
||||
|
||||
private final URIResolver parent;
|
||||
|
||||
public SourceUriResolver() {
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
public SourceUriResolver(URIResolver parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public URIResolver getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Source resolve(String href, String base) throws TransformerException {
|
||||
|
||||
if (parent != null) {
|
||||
return parent.resolve(href, base);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user