ARC SDK
WSCommonPlugin.h
1 // -*- indent-tabs-mode: nil -*-
2 
3 #ifndef __ARC_WSCOMMONPLUGIN_H__
4 #define __ARC_WSCOMMONPLUGIN_H__
5 
6 #include <string>
7 
8 #include <arc/compute/Endpoint.h>
9 #include <arc/URL.h>
10 
11 namespace Arc {
12 
14 
23 template <class T> class WSCommonPlugin : public T {
24 public:
25  WSCommonPlugin(PluginArgument* parg) : T(parg) {}
27 
34  virtual bool isEndpointNotSupported(const Endpoint& endpoint) const {
35  const std::string::size_type pos = endpoint.URLString.find("://");
36  if (pos != std::string::npos) {
37  const std::string proto = lower(endpoint.URLString.substr(0, pos));
38  return ((proto != "http") && (proto != "https"));
39  }
40  return false;
41  }
42 
44 
52  static URL CreateURL(std::string service) {
53  std::string::size_type pos = service.find("://");
54  if (pos == std::string::npos) {
55  service = "https://" + service + "/arex";
56  } else {
57  const std::string proto = lower(service.substr(0,pos));
58  if((proto != "http") && (proto != "https")) return URL();
59  }
60 
61  return service;
62  }
63 };
64 
65 } // namespace Arc
66 
67 #endif // __ARC_WSCOMMONPLUGIN_H__
Arc namespace contains all core ARC classes.
Definition: ArcConfig.h:11
std::string URLString
The string representation of the URL of the Endpoint.
Definition: Endpoint.h:230
Represents an endpoint of a service with a given interface type and capabilities. ...
Definition: Endpoint.h:68
virtual bool isEndpointNotSupported(const Endpoint &endpoint) const
Check that endpoint is WS endpoint.
Definition: WSCommonPlugin.h:34
static URL CreateURL(std::string service)
Create WS endpoint URL from the provided service endpoint string.
Definition: WSCommonPlugin.h:52
Class to represent general URLs.
Definition: URL.h:88
std::string lower(const std::string &s)
This method converts the given string to lower case.
A general wrapping class that adds common functions for all ARC WS-interface plugins.
Definition: WSCommonPlugin.h:23