use of org.eclipse.epp.internal.mpc.core.util.JavaPlatformTransportFactory in project epp.mpc by eclipse.
the class MappedTransportFactory method getTransport.
public ITransport getTransport() {
return new ITransport() {
private final ITransport delegateTransport = delegate.getTransport();
public InputStream stream(URI location, IProgressMonitor monitor) throws FileNotFoundException, ServiceUnavailableException, CoreException {
URI mapped = mapping.get(location);
if (mapped == null) {
if (location.getQuery() != null || location.getFragment() != null) {
try {
URI stripped = new URI(location.getScheme(), location.getHost(), location.getPath(), null);
mapped = mapping.get(stripped);
} catch (URISyntaxException e) {
}
}
}
if (mapped == null) {
mapped = location;
} else if (!mapped.getScheme().toLowerCase().startsWith("http")) {
ITransport nonHttpTransport = getNonHttpTransport(delegate, delegateTransport);
if (nonHttpTransport != null) {
return nonHttpTransport.stream(mapped, monitor);
}
}
return delegateTransport.stream(mapped, monitor);
}
private ITransport getNonHttpTransport(ITransportFactory delegate, ITransport delegateTransport) {
ITransport nonHttpTransport = delegateTransport;
if (delegate instanceof HttpClientTransportFactory) {
FallbackTransportFactory fallbackFactory = new FallbackTransportFactory();
fallbackFactory.setPrimaryFactory(delegate);
delegate = fallbackFactory;
}
if (delegate instanceof FallbackTransportFactory) {
FallbackTransportFactory fallbackFactory = (FallbackTransportFactory) delegate;
ITransportFactory primaryFactory = fallbackFactory.getPrimaryFactory();
if (primaryFactory instanceof HttpClientTransportFactory) {
ITransportFactory secondaryFactory = fallbackFactory.getFallbackFactory();
if (secondaryFactory != null) {
nonHttpTransport = secondaryFactory.getTransport();
}
}
}
if (nonHttpTransport instanceof HttpClientTransport) {
nonHttpTransport = new JavaPlatformTransportFactory().getTransport();
}
return nonHttpTransport;
}
};
}
Aggregations