~ubuntu-branches/ubuntu/trusty/nordugrid-arc/trusty

« back to all changes in this revision

Viewing changes to src/hed/acc/ARC1/JobListRetrieverPluginARC1.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2012-12-13 16:41:31 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20121213164131-wii0p2fcv7e3en93
Tags: 2.0.1-1
* 2.0.1 Release
* Drop patches accepted upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- indent-tabs-mode: nil -*-
 
2
 
 
3
#ifdef HAVE_CONFIG_H
 
4
#include <config.h>
 
5
#endif
 
6
 
 
7
#include <arc/StringConv.h>
 
8
#include <arc/data/DataBuffer.h>
 
9
#include <arc/data/DataHandle.h>
 
10
 
 
11
#include "JobListRetrieverPluginARC1.h"
 
12
 
 
13
namespace Arc {
 
14
 
 
15
  Logger JobListRetrieverPluginARC1::logger(Logger::getRootLogger(), "JobListRetrieverPlugin.WSRFGLUE2");
 
16
 
 
17
  bool JobListRetrieverPluginARC1::isEndpointNotSupported(const Endpoint& endpoint) const {
 
18
    const std::string::size_type pos = endpoint.URLString.find("://");
 
19
    if (pos != std::string::npos) {
 
20
      const std::string proto = lower(endpoint.URLString.substr(0, pos));
 
21
      return ((proto != "http") && (proto != "https"));
 
22
    }
 
23
    
 
24
    return false;
 
25
  }
 
26
 
 
27
  static URL CreateURL(std::string service) {
 
28
    std::string::size_type pos1 = service.find("://");
 
29
    if (pos1 == std::string::npos) {
 
30
      service = "https://" + service;
 
31
    } else {
 
32
      std::string proto = lower(service.substr(0,pos1));
 
33
      if((proto != "http") && (proto != "https")) return URL();
 
34
    }
 
35
    // Default port other than 443?
 
36
    // Default path?
 
37
    
 
38
    return service;
 
39
  }
 
40
 
 
41
  EndpointQueryingStatus JobListRetrieverPluginARC1::Query(const UserConfig& uc, const Endpoint& endpoint, std::list<Job>& jobs, const EndpointQueryOptions<Job>&) const {
 
42
    EndpointQueryingStatus s(EndpointQueryingStatus::FAILED);
 
43
 
 
44
    URL url(CreateURL(endpoint.URLString));
 
45
    if (!url) {
 
46
      return s;
 
47
    }
 
48
 
 
49
    logger.msg(DEBUG, "Collecting Job (A-REX jobs) information.");
 
50
 
 
51
    DataHandle dir_url(url, uc);
 
52
    if (!dir_url) {
 
53
      logger.msg(INFO, "Failed retrieving job IDs: Unsupported url (%s) given", url.str());
 
54
      return s;
 
55
    }
 
56
 
 
57
    dir_url->SetSecure(false);
 
58
    std::list<FileInfo> files;
 
59
    if (!dir_url->List(files, DataPoint::INFO_TYPE_NAME)) {
 
60
      if (files.empty()) {
 
61
        logger.msg(INFO, "Failed retrieving job IDs");
 
62
        return s;
 
63
      }
 
64
      logger.msg(VERBOSE, "Error encoutered during job ID retrieval. All job IDs might not have been retrieved");
 
65
    }
 
66
 
 
67
    for (std::list<FileInfo>::const_iterator file = files.begin();
 
68
         file != files.end(); file++) {
 
69
      Job j;
 
70
      j.JobID = url;
 
71
      j.JobID.ChangePath(j.JobID.Path() + "/" + file->GetName());
 
72
      j.InterfaceName = "org.nordugrid.xbes";
 
73
      j.IDFromEndpoint = "<ActivityIdentifier><Address>" + url.fullstr() + "</Address></ActivityIdentifier>";
 
74
      j.Cluster = url;
 
75
      jobs.push_back(j);
 
76
    }
 
77
 
 
78
    s = EndpointQueryingStatus::SUCCESSFUL;
 
79
 
 
80
    return s;
 
81
  }
 
82
 
 
83
} // namespace Arc