Package org.apache.oodt.cas.protocol

Examples of org.apache.oodt.cas.protocol.Protocol


        }
    }

    Protocol getNextAvaliableSession(RemoteSiteFile file) throws CrawlerException {
        // wait for available session, then load it
        Protocol session;
        while ((session = getSession(file)) == null) {
            try {
                waitMainThread();
            } catch (InterruptedException e1) {
            }
View Full Code Here


     *             If downloading session Protocol has to be reconnected and
     *             there is an error communicating with the server
     */
    synchronized Protocol getSession(RemoteSiteFile file) throws CrawlerException {
        try {
            Protocol session = null;
      if (file.getSite().getMaxConnections() < 0
          || file.getSite().getMaxConnections() > this.getCurrentlyDownloadingFiles().size()) {
              if (avaliableSessions.size() > 0) {
                  session = modifyAvailableSessionForPath(file);
              } else if (numberOfSessions < max_sessions) {
View Full Code Here

        true);
    }

    Protocol modifyAvailableSessionForPath(RemoteSiteFile file)
            throws ProtocolException, RemoteConnectionException {
        Protocol session = getAvailableSession();
        if (!file.getSite().getURL().getHost().equals(
                file.getSite().getURL().getHost())
                || !protocolHandler.isProtocolConnected(session)) {
            protocolHandler.disconnect(session);
            session = protocolHandler.getAppropriateProtocol(file, /* reuse */
 
View Full Code Here

        threadController.execute(new Runnable() {
            @Override
            public void run() {
                boolean successful = false;
                int retries = 0;
                Protocol curSession = session;

                if (FileRetrievalSystem.this.dListener != null)
                    FileRetrievalSystem.this.dListener
                            .downloadStarted(remoteFile.getProtocolFile());
View Full Code Here

   */
  public Protocol getAppropriateProtocol(RemoteSiteFile pFile,
      boolean allowReuse, boolean navigateToPathLoc)
      throws RemoteConnectionException {
    try {
      Protocol protocol = getAppropriateProtocol(pFile, allowReuse);
      if (protocol != null && navigateToPathLoc) {
        if (pFile.isDir())
          this.cd(protocol, pFile);
        else if (pFile.getParent() != null)
          this.cd(protocol, new RemoteSiteFile(pFile.getParent(), pFile.getSite()));
View Full Code Here

    return this.getAppropriateProtocolBySite(pFile.getSite(), allowReuse);
  }

  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) {
View Full Code Here

   @Override
   public void execute(ActionMessagePrinter printer)
         throws CmdLineActionException {
      try {
         if (factory != null) {
            Protocol protocol = factory.newInstance();
            if (lastVerificationResult = verifier.verify(protocol, getSite(),
                  getAuthentication())) {
               printer.println("Protocol '"
                     + protocol.getClass().getCanonicalName()
                     + "' PASSED verification!");
            } else {
               printer.println("Protocol '"
                     + protocol.getClass().getCanonicalName()
                     + "' FAILED verification!");
            }
         } else {
            Protocol protocol = getProtocolManager().getProtocolBySite(
                  getSite(), getAuthentication(), verifier);
            if (lastVerificationResult = protocol != null) {
               printer.println("Protocol '"
                     + protocol.getClass().getCanonicalName()
                     + "' PASSED verification!");
            } else {
               printer.println("No Protocol determined, FAILED verification!");
            }
         }
View Full Code Here

         if (localFile == null) {
            throw new Exception("Failed to create tempory local file");
         }

         ProtocolManager protocolManager = getProtocolManager();
         Protocol fromProtocol = protocolManager.getProtocolBySite(fromUri,
               getAuthentication(fromUri), verifier);
         if (fromProtocol == null) {
            throw new Exception("Failed to get protocol for 'from' URI '"
                  + fromUri + "'");
         }

         Protocol toProtocol = protocolManager.getProtocolBySite(toUri,
               getAuthentication(toUri), verifier);
         if (toProtocol == null) {
            throw new Exception("Failed to get protocol for 'to' URI '" + toUri
                  + "'");
         }

         fromProtocol
               .get(new ProtocolFile(fromUri.getPath(), false), localFile);
         toProtocol.put(localFile, new ProtocolFile(toUri.getPath(), false));
      } catch (Exception e) {
         throw new CmdLineActionException(
               "Failed to transfer between 2 protocols : " + e.getMessage(), e);
      }
   }
View Full Code Here

  private ProtocolVerifierFactory verifierFactory;

  @Override
  public void execute(ActionMessagePrinter printer) throws CmdLineActionException {
    try {
      Protocol protocol = getProtocolManager().getProtocolBySite(
          getSite(), getAuthentication(), verifierFactory.newInstance());
      List<ProtocolFile> files = protocol.ls();
      for (ProtocolFile file : files) {
        if (file.isDir() && Pattern.matches(directoryRegex, file.getName())) {
          try {
            protocol.delete(file);
            printer.println("Success: " + file.getPath());
          } catch (Exception e) {
            printer.println("Failed: " + file.getPath());
          }
        }
View Full Code Here

    public Protocol getProtocolBySite(URI site, Authentication auth, ProtocolVerifier verifier) {
      if (verifiedMap.containsKey(site)) {
        return verifiedMap.get(site).newInstance();
      } else {
        for (ProtocolFactory factory : protocolConfig.getFactoriesBySite(site)) {
          Protocol protocol = null;
          try {
            protocol = factory.newInstance();
            if (verifier == null || verifier.verify(protocol, site, auth)) {
              verifiedMap.put(site, factory);
              if (protocol.connected()) {
                protocol.close();
              }
              protocol.connect(site.getHost(), auth);
              return protocol;
            }
          } catch (Exception e) {
          LOG.warning("Failed to create/verify protocol from factory '"
              + factory.getClass().getCanonicalName()
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.protocol.Protocol

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.