Repository: oodt Updated Branches: refs/heads/master 944f662bd -> 3903325ce
OODT-887 fix the remaning blockers Project: http://git-wip-us.apache.org/repos/asf/oodt/repo Commit: http://git-wip-us.apache.org/repos/asf/oodt/commit/ef02b60c Tree: http://git-wip-us.apache.org/repos/asf/oodt/tree/ef02b60c Diff: http://git-wip-us.apache.org/repos/asf/oodt/diff/ef02b60c Branch: refs/heads/master Commit: ef02b60cf22bb026ed7c304ca6587b2163ac0b4d Parents: 06b5dec Author: Tom Barber <[email protected]> Authored: Sat Oct 10 13:50:22 2015 +0100 Committer: Tom Barber <[email protected]> Committed: Sat Oct 10 13:50:22 2015 +0100 ---------------------------------------------------------------------- .../cas/pushpull/protocol/ProtocolHandler.java | 85 +++++++++++--------- 1 file changed, 47 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oodt/blob/ef02b60c/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolHandler.java ---------------------------------------------------------------------- diff --git a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolHandler.java b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolHandler.java index e572ee3..b8f3b61 100644 --- a/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolHandler.java +++ b/pushpull/src/main/java/org/apache/oodt/cas/pushpull/protocol/ProtocolHandler.java @@ -129,49 +129,58 @@ public class ProtocolHandler { public Protocol getAppropriateProtocolBySite(RemoteSite remoteSite, boolean allowReuse) throws ProtocolException { Protocol protocol = null; - if ((allowReuse && ((protocol = reuseProtocols.get(remoteSite.getURL())) == null)) - || !allowReuse) { - ProtocolFactory protocolFactory = this.urlAndProtocolFactory - .get(remoteSite.getURL()); - if (protocolFactory == null) { - LinkedList<Class<ProtocolFactory>> protocolClasses = pi - .getProtocolClassesForProtocolType(remoteSite.getURL() - .getProtocol()); - for (Class<ProtocolFactory> clazz : protocolClasses) { - try { - if ((protocol = (protocolFactory = clazz.newInstance()) - .newInstance()) != null) { - if (!connect(protocol, remoteSite, true)) { - LOG.log( - Level.WARNING, - "ProtocolFactory " - + protocolFactory.getClass().getCanonicalName() - + " is not compatible with server at " - + remoteSite.getURL()); - protocol = null; - } else { - this.urlAndProtocolFactory.put(remoteSite.getURL().toURI(), - protocolFactory); - break; + try { + if ((allowReuse && ((protocol = reuseProtocols.get(remoteSite.getURL().toURI())) == null)) + || !allowReuse) { + ProtocolFactory protocolFactory = null; + try { + protocolFactory = this.urlAndProtocolFactory + .get(remoteSite.getURL().toURI()); + } catch (URISyntaxException e) { + LOG.log(Level.SEVERE, "could not convert url to uri: Message: " + e.getMessage()); + } + if (protocolFactory == null) { + LinkedList<Class<ProtocolFactory>> protocolClasses = pi + .getProtocolClassesForProtocolType(remoteSite.getURL() + .getProtocol()); + for (Class<ProtocolFactory> clazz : protocolClasses) { + try { + if ((protocol = (protocolFactory = clazz.newInstance()) + .newInstance()) != null) { + if (!connect(protocol, remoteSite, true)) { + LOG.log( + Level.WARNING, + "ProtocolFactory " + + protocolFactory.getClass().getCanonicalName() + + " is not compatible with server at " + + remoteSite.getURL()); + protocol = null; + } else { + this.urlAndProtocolFactory.put(remoteSite.getURL().toURI(), + protocolFactory); + break; + } } + } catch (Exception e) { + LOG.log(Level.WARNING, "Failed to instanciate protocol " + clazz + + " for " + remoteSite.getURL()); } - } catch (Exception e) { - LOG.log(Level.WARNING, "Failed to instanciate protocol " + clazz - + " for " + remoteSite.getURL()); } + if (protocol == null) + throw new ProtocolException("Failed to get appropriate protocol for " + + remoteSite); + } else { + connect(protocol = protocolFactory.newInstance(), remoteSite, false); } - if (protocol == null) - throw new ProtocolException("Failed to get appropriate protocol for " - + remoteSite); - } else { - connect(protocol = protocolFactory.newInstance(), remoteSite, false); + if (allowReuse) + try { + this.reuseProtocols.put(remoteSite.getURL().toURI(), protocol); + } catch (URISyntaxException e) { + LOG.log(Level.SEVERE, "Couildn't covert URL to URI Mesage: " + e.getMessage()); + } } - if (allowReuse) - try { - this.reuseProtocols.put(remoteSite.getURL().toURI(), protocol); - } catch (URISyntaxException e) { - LOG.log(Level.SEVERE, "Couildn't covert URL to URI Mesage: " + e.getMessage()); - } + } catch (URISyntaxException e) { + LOG.log(Level.SEVERE, "could not convert url to uri: Message: "+e.getMessage()); } return protocol; }
