Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | Friends
Arc::URLLocation Class Reference

Class to hold a resolved URL location. More...

#include <URL.h>

Inheritance diagram for Arc::URLLocation:
Inheritance graph
[legend]
Collaboration diagram for Arc::URLLocation:
Collaboration graph
[legend]

List of all members.

Public Types

enum  Scope { base, onelevel, subtree }
 Scope for LDAP URLs. More...

Public Member Functions

 URLLocation (const std::string &url)
 Creates a URLLocation from a string representaion.
 URLLocation (const std::string &url, const std::string &name)
 Creates a URLLocation from a string representaion and a name.
 URLLocation (const URL &url)
 Creates a URLLocation from a URL.
 URLLocation (const URL &url, const std::string &name)
 Creates a URLLocation from a URL and a name.
 URLLocation (const std::map< std::string, std::string > &options, const std::string &name)
 Creates a URLLocation from options and a name.
virtual ~URLLocation ()
 URLLocation destructor.
const std::string & Name () const
 Returns the URLLocation name.
virtual std::string str () const
 Returns a string representation of the URLLocation.
virtual std::string fullstr () const
 Returns a string representation including options and locations.
const std::string & Protocol () const
 Returns the protocol of the URL.
void ChangeProtocol (const std::string &newprot)
 Changes the protocol of the URL.
bool IsSecureProtocol () const
 Indicates whether the protocol is secure or not.
const std::string & Username () const
 Returns the username of the URL.
const std::string & Passwd () const
 Returns the password of the URL.
const std::string & Host () const
 Returns the hostname of the URL.
void ChangeHost (const std::string &newhost)
 Changes the hostname of the URL.
int Port () const
 Returns the port of the URL.
void ChangePort (int newport)
 Changes the port of the URL.
const std::string & Path () const
 Returns the path of the URL.
std::string FullPath () const
 Returns the path of the URL with all options attached.
void ChangePath (const std::string &newpath)
 Changes the path of the URL.
const std::map< std::string,
std::string > & 
HTTPOptions () const
 Returns HTTP options if any.
const std::string & HTTPOption (const std::string &option, const std::string &undefined="") const
 Returns the value of an HTTP option.
const std::list< std::string > & LDAPAttributes () const
 Returns the LDAP attributes if any.
void AddLDAPAttribute (const std::string &attribute)
 Adds an LDAP attribute.
Scope LDAPScope () const
 Returns the LDAP scope.
void ChangeLDAPScope (const Scope newscope)
 Changes the LDAP scope.
const std::string & LDAPFilter () const
 Returns the LDAP filter.
void ChangeLDAPFilter (const std::string &newfilter)
 Changes the LDAP filter.
const std::map< std::string,
std::string > & 
Options () const
 Returns URL options if any.
const std::string & Option (const std::string &option, const std::string &undefined="") const
 Returns the value of a URL option.
const std::map< std::string,
std::string > & 
MetaDataOptions () const
 Returns metadata options if any.
const std::string & MetaDataOption (const std::string &option, const std::string &undefined="") const
 Returns the value of a metadata option.
void AddOption (const std::string &option, const std::string &value, bool overwrite=true)
 Adds a URL option.
const std::list< URLLocation > & Locations () const
 Returns the locations if any.
const std::map< std::string,
std::string > & 
CommonLocOptions () const
 Returns the common location options if any.
const std::string & CommonLocOption (const std::string &option, const std::string &undefined="") const
 Returns the value of a common location option.
virtual std::string ConnectionURL () const
 Returns a string representation with protocol, host and port only.
bool operator< (const URL &url) const
 Compares one URL to another.
bool operator== (const URL &url) const
 Is one URL equal to another?
 operator bool () const
 Check if instance holds valid URL.
bool operator! () const
std::map< std::string,
std::string > 
ParseOptions (const std::string &optstring, char separator)
 Parse a string of options separated by separator into an attribute->value map.

Static Public Member Functions

static std::string OptionString (const std::map< std::string, std::string > &options, char separator)
 Returns a string representation of the options given in the options map.

Static Protected Member Functions

static std::string BaseDN2Path (const std::string &)
 a private method that converts an ldap basedn to a path.
static std::string Path2BaseDN (const std::string &)
 a private method that converts an ldap path to a basedn.

Protected Attributes

std::string name
 the URLLocation name as registered in the indexing service.
std::string protocol
 the url protocol.
std::string username
 username of the url.
std::string passwd
 password of the url.
std::string host
 hostname of the url.
bool ip6addr
 if host is IPv6 numerical address notation.
int port
 portnumber of the url.
std::string path
 the url path.
std::map< std::string,
std::string > 
httpoptions
 HTTP options of the url.
std::map< std::string,
std::string > 
metadataoptions
 Meta data options.
std::list< std::string > ldapattributes
 LDAP attributes of the url.
Scope ldapscope
 LDAP scope of the url.
std::string ldapfilter
 LDAP filter of the url.
std::map< std::string,
std::string > 
urloptions
 options of the url.
std::list< URLLocationlocations
 locations for index server URLs.
std::map< std::string,
std::string > 
commonlocoptions
 common location options for index server URLs.
bool valid
 flag to describe validity of URL

Friends

std::ostream & operator<< (std::ostream &out, const URL &u)
 Overloaded operator << to print a URL.

Detailed Description

Class to hold a resolved URL location.

It is specific to file indexing service registrations.

Definition at line 283 of file URL.h.


Member Enumeration Documentation

enum Arc::URL::Scope [inherited]

Scope for LDAP URLs.

Enumerator:
base 
onelevel 
subtree 

Definition at line 88 of file URL.h.


Constructor & Destructor Documentation

Arc::URLLocation::URLLocation ( const std::string &  url)

Creates a URLLocation from a string representaion.

Definition at line 896 of file URL.cpp.

    : URL(url) {}
Arc::URLLocation::URLLocation ( const std::string &  url,
const std::string &  name 
)

Creates a URLLocation from a string representaion and a name.

Definition at line 899 of file URL.cpp.

    : URL(url),
      name(name) {}

Creates a URLLocation from a URL.

Definition at line 904 of file URL.cpp.

    : URL(url) {}
Arc::URLLocation::URLLocation ( const URL url,
const std::string &  name 
)

Creates a URLLocation from a URL and a name.

Definition at line 907 of file URL.cpp.

    : URL(url),
      name(name) {}
Arc::URLLocation::URLLocation ( const std::map< std::string, std::string > &  options,
const std::string &  name 
)

Creates a URLLocation from options and a name.

Definition at line 912 of file URL.cpp.

    : URL(),
      name(name) {
    urloptions = options;
  }

URLLocation destructor.

Definition at line 923 of file URL.cpp.

{}

Member Function Documentation

void Arc::URL::AddLDAPAttribute ( const std::string &  attribute) [inherited]

Adds an LDAP attribute.

Definition at line 577 of file URL.cpp.

                                                       {
    ldapattributes.push_back(attribute);
  }

Here is the caller graph for this function:

void Arc::URL::AddOption ( const std::string &  option,
const std::string &  value,
bool  overwrite = true 
) [inherited]

Adds a URL option.

Definition at line 611 of file URL.cpp.

                                      {
    if (!overwrite && urloptions.find(option) != urloptions.end())
      return;
    urloptions[option] = value;
  }

Here is the caller graph for this function:

std::string Arc::URL::BaseDN2Path ( const std::string &  basedn) [static, protected, inherited]

a private method that converts an ldap basedn to a path.

Definition at line 823 of file URL.cpp.

                                                    {

    std::string::size_type pos, pos2;
    // mds-vo-name=local, o=grid --> o=grid/mds-vo-name=local
    std::string newpath;

    pos = basedn.size();
    while ((pos2 = basedn.rfind(",", pos - 1)) != std::string::npos) {
      std::string tmppath = basedn.substr(pos2 + 1, pos - pos2 - 1);
      tmppath = tmppath.substr(tmppath.find_first_not_of(' '));
      newpath += tmppath + '/';
      pos = pos2;
    }

    newpath += basedn.substr(0, pos);

    return newpath;
  }
void Arc::URL::ChangeHost ( const std::string &  newhost) [inherited]

Changes the hostname of the URL.

Definition at line 471 of file URL.cpp.

                                               {
    host = lower(newhost);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void Arc::URL::ChangeLDAPFilter ( const std::string &  newfilter) [inherited]

Changes the LDAP filter.

Definition at line 593 of file URL.cpp.

                                                       {
    ldapfilter = newfilter;
  }

Here is the caller graph for this function:

void Arc::URL::ChangeLDAPScope ( const Scope  newscope) [inherited]

Changes the LDAP scope.

Definition at line 585 of file URL.cpp.

                                                {
    ldapscope = newscope;
  }

Here is the caller graph for this function:

void Arc::URL::ChangePath ( const std::string &  newpath) [inherited]

Changes the path of the URL.

Definition at line 521 of file URL.cpp.

                                               {
    path = newpath;

    // parse basedn in case of ldap-protocol
    if (protocol == "ldap") {
      if (path.find("/") != std::string::npos)
        path = Path2BaseDN(path);

    // add absolute path for relative file URLs
    } else if (protocol == "file" || protocol == "urllist") {
      if(!Glib::path_is_absolute(path)) {
        char cwd[PATH_MAX];
        if (getcwd(cwd, PATH_MAX))
          path = Glib::build_filename(cwd, path);
      }
    }

    // for generic URL just make sure path has leading /
    else if ((path[0] != '/') && (!path.empty())) {
      URLLogger.msg(WARNING, "Attempt to assign relative path to URL - making it absolute");
      path = "/" + path;
    }

  }

Here is the call graph for this function:

Here is the caller graph for this function:

void Arc::URL::ChangePort ( int  newport) [inherited]

Changes the port of the URL.

Definition at line 479 of file URL.cpp.

                                  {
    port = newport;
  }
void Arc::URL::ChangeProtocol ( const std::string &  newprot) [inherited]

Changes the protocol of the URL.

Definition at line 443 of file URL.cpp.

                                                   {
    protocol = lower(newprot);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string & Arc::URL::CommonLocOption ( const std::string &  option,
const std::string &  undefined = "" 
) const [inherited]

Returns the value of a common location option.

Parameters:
optionThe option whose value is returned.
undefinedThis value is returned if the common location option is not defined.

Definition at line 626 of file URL.cpp.

                                                                            {
    std::map<std::string, std::string>::const_iterator
    opt = commonlocoptions.find(option);
    if (opt != commonlocoptions.end())
      return opt->second;
    else
      return undefined;
  }
const std::map< std::string, std::string > & Arc::URL::CommonLocOptions ( ) const [inherited]

Returns the common location options if any.

Definition at line 622 of file URL.cpp.

                                                                  {
    return commonlocoptions;
  }

Here is the caller graph for this function:

std::string Arc::URL::ConnectionURL ( ) const [virtual, inherited]

Returns a string representation with protocol, host and port only.

Definition at line 796 of file URL.cpp.

                                     {

    std::string urlstr;
    if (!protocol.empty())
      urlstr = protocol + "://";

    if (!host.empty()) {
      if(ip6addr)
        urlstr += "[" + host + "]";
      else
        urlstr += host;
    }

    if (port != -1)
      urlstr += ':' + tostring(port);

    return urlstr;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

std::string Arc::URL::FullPath ( ) const [inherited]

Returns the path of the URL with all options attached.

Definition at line 487 of file URL.cpp.

                                {
    std::string fullpath;

    if (!path.empty())
      fullpath += path;

    if (!httpoptions.empty())
      fullpath += '?' + OptionString(httpoptions, '&');

    if (!ldapattributes.empty() || (ldapscope != base) || !ldapfilter.empty())
      fullpath += '?' + AttributeString(ldapattributes, ',');

    if ((ldapscope != base) || !ldapfilter.empty()) {
      switch (ldapscope) {
      case base:
        fullpath += "?base";
        break;

      case onelevel:
        fullpath += "?one";
        break;

      case subtree:
        fullpath += "?sub";
        break;
      }
    }

    if (!ldapfilter.empty())
      fullpath += '?' + ldapfilter;

    return fullpath;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

std::string Arc::URLLocation::fullstr ( ) const [virtual]

Returns a string representation including options and locations.

Reimplemented from Arc::URL.

Definition at line 933 of file URL.cpp.

                                       {

    if (*this)
      return URL::fullstr();
    else if (urloptions.empty())
      return name;
    else
      return name + ';' + OptionString(urloptions, ';');
  }

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string & Arc::URL::Host ( ) const [inherited]

Returns the hostname of the URL.

Definition at line 467 of file URL.cpp.

                                   {
    return host;
  }
const std::string & Arc::URL::HTTPOption ( const std::string &  option,
const std::string &  undefined = "" 
) const [inherited]

Returns the value of an HTTP option.

Parameters:
optionThe option whose value is returned.
undefinedThis value is returned if the HTTP option is not defined.

Definition at line 550 of file URL.cpp.

                                                                       {
    std::map<std::string, std::string>::const_iterator
    opt = httpoptions.find(option);
    if (opt != httpoptions.end())
      return opt->second;
    else
      return undefined;
  }

Here is the caller graph for this function:

const std::map< std::string, std::string > & Arc::URL::HTTPOptions ( ) const [inherited]

Returns HTTP options if any.

Definition at line 546 of file URL.cpp.

                                                             {
    return httpoptions;
  }

Here is the caller graph for this function:

bool Arc::URL::IsSecureProtocol ( ) const [inherited]

Indicates whether the protocol is secure or not.

Definition at line 447 of file URL.cpp.

                                   {
    return protocol == "gsiftp" ||
           protocol == "https" ||
           protocol == "httpg" ||
           protocol == "rc" ||
           protocol == "rls" ||
           protocol == "srm" ||
           protocol == "arc" ||
           protocol == "fireman" ||
           protocol == "lfc";
  }

Here is the caller graph for this function:

const std::list< std::string > & Arc::URL::LDAPAttributes ( ) const [inherited]

Returns the LDAP attributes if any.

Definition at line 573 of file URL.cpp.

                                                      {
    return ldapattributes;
  }

Here is the caller graph for this function:

const std::string & Arc::URL::LDAPFilter ( ) const [inherited]

Returns the LDAP filter.

Definition at line 589 of file URL.cpp.

                                         {
    return ldapfilter;
  }

Here is the caller graph for this function:

URL::Scope Arc::URL::LDAPScope ( ) const [inherited]

Returns the LDAP scope.

Definition at line 581 of file URL.cpp.

                                {
    return ldapscope;
  }

Here is the caller graph for this function:

const std::list< URLLocation > & Arc::URL::Locations ( ) const [inherited]

Returns the locations if any.

Definition at line 618 of file URL.cpp.

                                                   {
    return locations;
  }

Here is the caller graph for this function:

const std::string & Arc::URL::MetaDataOption ( const std::string &  option,
const std::string &  undefined = "" 
) const [inherited]

Returns the value of a metadata option.

Parameters:
optionThe option whose value is returned.
undefinedThis value is returned if the metadata option is not defined.

Definition at line 564 of file URL.cpp.

                                                                           {
    std::map<std::string, std::string>::const_iterator opt = metadataoptions.find(option);
    if (opt != metadataoptions.end())
      return opt->second;
    else
      return undefined;
  }

Here is the caller graph for this function:

const std::map< std::string, std::string > & Arc::URL::MetaDataOptions ( ) const [inherited]

Returns metadata options if any.

Definition at line 560 of file URL.cpp.

                                                                 {
    return metadataoptions;
  }

Here is the caller graph for this function:

const std::string & Arc::URLLocation::Name ( void  ) const

Returns the URLLocation name.

Definition at line 919 of file URL.cpp.

                                           {
    return name;
  }
Arc::URL::operator bool ( void  ) const [inherited]

Check if instance holds valid URL.

Reimplemented in SRMURL.

Definition at line 865 of file URL.cpp.

                           {
    return valid;
  }
bool Arc::URL::operator! ( void  ) const [inherited]

Reimplemented in SRMURL.

Definition at line 869 of file URL.cpp.

                            {
    return !valid;
  }
bool Arc::URL::operator< ( const URL url) const [inherited]

Compares one URL to another.

Definition at line 815 of file URL.cpp.

                                          {
    return (str() < url.str());
  }

Here is the call graph for this function:

bool Arc::URL::operator== ( const URL url) const [inherited]

Is one URL equal to another?

Definition at line 819 of file URL.cpp.

                                           {
    return (str() == url.str());
  }

Here is the call graph for this function:

const std::string & Arc::URL::Option ( const std::string &  option,
const std::string &  undefined = "" 
) const [inherited]

Returns the value of a URL option.

Parameters:
optionThe option whose value is returned.
undefinedThis value is returned if the URL option is not defined.

Definition at line 601 of file URL.cpp.

                                                                   {
    std::map<std::string, std::string>::const_iterator
    opt = urloptions.find(option);
    if (opt != urloptions.end())
      return opt->second;
    else
      return undefined;
  }

Here is the caller graph for this function:

const std::map< std::string, std::string > & Arc::URL::Options ( ) const [inherited]

Returns URL options if any.

Definition at line 597 of file URL.cpp.

                                                         {
    return urloptions;
  }

Here is the caller graph for this function:

std::string Arc::URL::OptionString ( const std::map< std::string, std::string > &  options,
char  separator 
) [static, inherited]

Returns a string representation of the options given in the options map.

Definition at line 873 of file URL.cpp.

                                                                                    {

    std::string optstring;

    if (options.empty())
      return optstring;

    for (std::map<std::string, std::string>::const_iterator
         it = options.begin(); it != options.end(); it++) {
      if (it != options.begin())
        optstring += separator;
      optstring += it->first + '=' + it->second;
    }
    return optstring;
  }

Here is the caller graph for this function:

std::map< std::string, std::string > Arc::URL::ParseOptions ( const std::string &  optstring,
char  separator 
) [inherited]

Parse a string of options separated by separator into an attribute->value map.

Definition at line 26 of file URL.cpp.

                                                                                           {

    std::map<std::string, std::string> options;

    if (optstring.empty())
      return options;

    std::string::size_type pos = 0;
    while (pos != std::string::npos) {

      std::string::size_type pos2 = optstring.find(separator, pos);

      std::string opt = (pos2 == std::string::npos ?
                         optstring.substr(pos) :
                         optstring.substr(pos, pos2 - pos));

      pos = pos2;
      if (pos != std::string::npos)
        pos++;

      pos2 = opt.find('=');
      std::string option_name, option_value = "";
      if (pos2 == std::string::npos) {
        option_name = opt;
      } else {
        option_name = opt.substr(0, pos2);
        option_value = opt.substr(pos2 + 1);
      }
      options[option_name] = option_value;
    }
    return options;
  }

Here is the caller graph for this function:

const std::string & Arc::URL::Passwd ( ) const [inherited]

Returns the password of the URL.

Definition at line 463 of file URL.cpp.

                                     {
    return passwd;
  }

Here is the caller graph for this function:

const std::string & Arc::URL::Path ( ) const [inherited]

Returns the path of the URL.

Definition at line 483 of file URL.cpp.

                                   {
    return path;
  }
std::string Arc::URL::Path2BaseDN ( const std::string &  newpath) [static, protected, inherited]

a private method that converts an ldap path to a basedn.

Definition at line 842 of file URL.cpp.

                                                     {

    if (newpath.empty())
      return "";

    std::string basedn;
    std::string::size_type pos, pos2;

    pos = newpath.size();
    while ((pos2 = newpath.rfind("/", pos - 1)) != std::string::npos) {
      if (pos2 == 0) break;
      basedn += newpath.substr(pos2 + 1, pos - pos2 - 1) + ", ";
      pos = pos2;
    }

    if (pos2 == std::string::npos)
      basedn += newpath.substr(0, pos);
    else
      basedn += newpath.substr(pos2 + 1, pos - pos2 - 1);

    return basedn;
  }

Here is the caller graph for this function:

int Arc::URL::Port ( ) const [inherited]

Returns the port of the URL.

Definition at line 475 of file URL.cpp.

                      {
    return port;
  }

Here is the caller graph for this function:

const std::string & Arc::URL::Protocol ( ) const [inherited]

Returns the protocol of the URL.

Definition at line 439 of file URL.cpp.

                                       {
    return protocol;
  }
std::string Arc::URLLocation::str ( ) const [virtual]

Returns a string representation of the URLLocation.

Reimplemented from Arc::URL.

Definition at line 925 of file URL.cpp.

                                   {

    if (*this)
      return URL::str();
    else
      return name;
  }

Here is the caller graph for this function:

const std::string & Arc::URL::Username ( ) const [inherited]

Returns the username of the URL.

Definition at line 459 of file URL.cpp.

                                       {
    return username;
  }

Here is the caller graph for this function:


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const URL u 
) [friend, inherited]

Overloaded operator << to print a URL.

Definition at line 891 of file URL.cpp.

                                                          {
    return (out << url.str());
  }

Member Data Documentation

std::map<std::string, std::string> Arc::URL::commonlocoptions [protected, inherited]

common location options for index server URLs.

Definition at line 265 of file URL.h.

std::string Arc::URL::host [protected, inherited]

hostname of the url.

Definition at line 232 of file URL.h.

std::map<std::string, std::string> Arc::URL::httpoptions [protected, inherited]

HTTP options of the url.

Definition at line 244 of file URL.h.

bool Arc::URL::ip6addr [protected, inherited]

if host is IPv6 numerical address notation.

Definition at line 235 of file URL.h.

std::list<std::string> Arc::URL::ldapattributes [protected, inherited]

LDAP attributes of the url.

Definition at line 250 of file URL.h.

std::string Arc::URL::ldapfilter [protected, inherited]

LDAP filter of the url.

Definition at line 256 of file URL.h.

Scope Arc::URL::ldapscope [protected, inherited]

LDAP scope of the url.

Definition at line 253 of file URL.h.

std::list<URLLocation> Arc::URL::locations [protected, inherited]

locations for index server URLs.

Definition at line 262 of file URL.h.

std::map<std::string, std::string> Arc::URL::metadataoptions [protected, inherited]

Meta data options.

Definition at line 247 of file URL.h.

std::string Arc::URLLocation::name [protected]

the URLLocation name as registered in the indexing service.

Definition at line 317 of file URL.h.

std::string Arc::URL::passwd [protected, inherited]

password of the url.

Definition at line 229 of file URL.h.

std::string Arc::URL::path [protected, inherited]

the url path.

Definition at line 241 of file URL.h.

int Arc::URL::port [protected, inherited]

portnumber of the url.

Definition at line 238 of file URL.h.

std::string Arc::URL::protocol [protected, inherited]

the url protocol.

Definition at line 223 of file URL.h.

std::map<std::string, std::string> Arc::URL::urloptions [protected, inherited]

options of the url.

Definition at line 259 of file URL.h.

std::string Arc::URL::username [protected, inherited]

username of the url.

Definition at line 226 of file URL.h.

bool Arc::URL::valid [protected, inherited]

flag to describe validity of URL

Reimplemented in SRMURL.

Definition at line 268 of file URL.h.


The documentation for this class was generated from the following files: