Exemple #1
0
  ///////////////////////////////////////////////////////////////////////////////
  // throws : BadParameter
  void helper::check_scheme(saga::url& rm, bool local_ok)
  {
    std::string scheme(rm.get_scheme());

    if (scheme == "rns") {
    	std::cout << "RNS good" << std::endl;
    	return;
    }

    if (scheme.empty() || scheme == "file") {
      if (local_ok) {
        SAGA_LOG_DEBUG("local file.");
        return;
      } else {
        SAGA_OSSTREAM strm;
        strm << "Could not initialize file for [" << rm << "]. "
             << "Only any:// and rns:// "
             << "schemes are supported.";
        SAGA_ADAPTOR_THROW_NO_CONTEXT(SAGA_OSSTREAM_GETSTRING(strm), saga::BadParameter);
      }
    }

    //SRA : rns
    if (!(scheme == "irods" || scheme == "any")) {
      SAGA_OSSTREAM strm;
      strm << "Could not initialize file for [" << rm << "]. "
           << "Only any:// and rns:// "
           << "schemes are supported.";
      SAGA_ADAPTOR_THROW_NO_CONTEXT(SAGA_OSSTREAM_GETSTRING(strm), saga::BadParameter);
    }
  }
Exemple #2
0
  void dir_cpi_impl::sync_open (saga::filesystem::file & ret, 
                                saga::url                name, 
                                int                      openmode)
  {
    
    std::string to_open ; 
    
    /* If it is a relative path, then 
     * construct the appropriate URL and
     * create the file in the same session
     */
    if ( name.get_scheme().empty() &&
         name.get_host().empty()   &&
         name.get_path()[0] != '/' )
    {
       to_open += "sector://" ; 
       to_open += dir_ ; 
       to_open += '/' ; 
       to_open += name.get_path() ; 
       ret = saga::filesystem::file (s_, saga::url(to_open), openmode ) ; 
       return ; 
    }

    ret = saga::filesystem::file ( s_, name, openmode ) ; 
    return ; 

  }
Exemple #3
0
  bool dir_cpi_impl::resolve( saga::url const &url_, std::string &ret )
  {
    std::string temp = url_.get_host() ; 

    if( temp.empty() )
    {

       if( (! ( url_.get_path()).empty() ))
       {
           ret = url_.get_path() ; 

           if ( url_.get_scheme().empty() &&
                url_.get_host().empty()   &&
                url_.get_path ()[0] != '/' )
           {
              return true ;      
           }

           return false ;    
      }

    }

    ret = temp ; 

    return false ; 
  }
Exemple #4
0
    bool check_job_contact(saga::url& mail_uri) const {
      if (mail_uri.get_scheme() != "mailto" ||
	  mail_uri.get_path().empty()
	  // TODO mail address format check.
	  ) {
	return false;
      }
      return true;
    }
  TR1::shared_ptr <sshfs> filesystem_adaptor::get_sshfs (const saga::session & s, 
                                                         const saga::url     & u)
  {
    // only mount anything if the URL is ssh (or any) based
    if ( u.get_scheme () != "ssh" &&
         u.get_scheme () != "any" )
    {
      SAGA_ADAPTOR_THROW_NO_CONTEXT ("Cannot mount sshfs for non-ssh urls", 
                                     saga::BadParameter);
    }

    return mount_sshfs (s, u);
  }
 bool filesystem_adaptor::is_absolute (const saga::url & u)
 {
   if ( u.get_scheme   ().empty ()  &&
        u.get_host     ().empty ()  &&
        u.get_username ().empty ()  &&
        u.get_password ().empty ()  &&
        u.get_port     ()    == -1  &&
        u.get_path     ()[0] != '/' )
   {
     return false;
   }
   
   return true;
 }
//// connection pool handling - remove a handle //////////////////////////////
//
void adaptor::removeConnectionHandle (const saga::url url)
{
    // extract protocol, server & port from given url
    std::string location("");
    location.append(url.get_scheme());
    location.append("://");
    location.append(url.get_host());
    
    if( RLSConnectionPool_ == NULL )
    {
        return;
    }
    else
    {
        RLSConnectionPool_->erase(location);
    }
}
Exemple #8
0
 /**
 * adds file profile to Grid Service Object
 */
 void cpr_checkpoint_cpi_impl::sync_add_file (int &ret,
                                                saga::url url)
 {
     std::string guid;
     {//scoped lock
           adaptor_data_t d(this);
           guid = d->migol_guid;
           if ( guid == "")
           {
             SAGA_ADAPTOR_THROW (std::string ("Migol infrastructure could not be initialized."), 
                                 saga::IncorrectState);
           }
           std::cout << "cpr_checkpoint_cpi_impl::add_file: " << guid << std::endl;
     }
     
     // translate 'any' and 'cpr' url schemes to lfn, decline all others
     std::string scheme (url.get_scheme ());
     
     if ( ! scheme.empty () && 
         scheme != "gsiftp")
     {
         SAGA_OSSTREAM strm;
         strm << "cpr::migol_cpr_checkpoint_cpi_impl::add_file: "
         "cannot handle checkpoint name: " << url;
         SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::BadParameter);
     }
     
     bool result = false;
     {
         result =  migol::instance()->register_checkpoint(guid, url.get_url());
     }
     
     if (!result)
     { 
         SAGA_OSSTREAM strm;
         strm << "cpr::migol_cpr_checkpoint_cpi_impl::add_file: "
         "cannot handle checkpoint name: " << url.get_url();
         SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::BadParameter);
     }
 }
Exemple #9
0
  void dir_cpi_impl::sync_open_dir (saga::filesystem::directory & ret, 
                                    saga::url                     name, 
                                    int                           openmode)
  {

    std::string to_open ; 

    if ( name.get_scheme().empty() &&
         name.get_host().empty()   &&
         name.get_path ()[0] != '/' )
    {
       to_open += "sector://" ; 
       to_open += dir_ ; 
       to_open += '/' ; 
       to_open += name.get_path() ; 
       ret = saga::filesystem::directory ( s_, saga::url (to_open), openmode ) ; 
       return ; 
    }

    ret = saga::filesystem::directory (s_,  name, openmode ) ; 
    return ; 

  }
void dir_cpi_impl::sync_copy (saga::impl::void_t & ret, saga::url src, 
                              saga::url dst, int flags)
{
    adaptor_data_t AdaptorData(this);
    directory_instance_data_t InstanceData (this);
    
    if(dst.get_scheme().empty() && dst.get_host().empty())
    {
        SAGA_OSSTREAM strm;
        strm << "Could not copy [" << InstanceData->location_ << " -> " << dst
        << "]. Please specify scheme and/or hostname.";
        SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::BadParameter);                                     
    }
    
    if(dst.get_scheme() == "file")
    {
    	if(dst.get_host() != "localhost") {
            SAGA_OSSTREAM strm;
            strm << "Could not copy [" << InstanceData->location_ << " -> " << dst
            << "]. If target URL scheme is 'file://', only 'localhost' is accepted as host.";
           SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::BadParameter);   
        }
        
        // avoid file:// -> file:// copy.
        if (InstanceData->location_.get_scheme() != "gridftp" 
	     && InstanceData->location_.get_scheme() != "gsiftp")
	    {
            SAGA_OSSTREAM strm;
            strm << "Cannot copy file [" << InstanceData->location_ << "]. " 
                 << "Supported source URL schemes are: gridftp:// and gsiftp://";
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::adaptors::AdaptorDeclined);
	    }           

    }
    else
    {
        if(dst.get_scheme() != "gridftp" && dst.get_scheme() != "gsiftp" )
        {
            SAGA_OSSTREAM strm;
            strm << "Could not copy [" << InstanceData->location_ << " -> " << dst
            << "]. Only gridftp:// and gsiftp:// and file:// schemes are supported for target urls.";
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::BadParameter);         
        }
    }
        
    this->check_if_open ("dir_cpi_impl::sync_copy", InstanceData->location_);
    
    saga::url u_src = merge_urls(InstanceData->location_.get_url(), src);
    saga::url u_dst = merge_urls(InstanceData->location_.get_url(), dst);
    
    try {
        
        GridFTPConnection * ConnectionHandle = 
        AdaptorData->getConnectionHandleForURL(InstanceData->location_, write_log_, logfile_loc_);
        
        if(ConnectionHandle->exist(u_dst.get_url())) {
			if(ConnectionHandle->is_dir(u_dst.get_url())) {
				std::string url_path = u_dst.get_path();
				if(url_path.rfind("/") != url_path.length()-1) url_path.append("/");
				saga::url this_name; this->sync_get_name(this_name);
				url_path.append(this_name.get_path());
				u_dst.set_path(url_path);
            }
		}
        ConnectionHandle->copy_url(u_src.get_url(), u_dst.get_url());
    }
    catch( globus_gridftp_file_adaptor::exception const & e )
    {
        error_package ep = globus_gridftp_file_adaptor
        ::error_default_redirect(e, u_src.get_url());
        SAGA_OSSTREAM strm;
        strm << "Could not copy [" << u_src << " -> " << u_dst
        << "]. " << ep.error_text;
        SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), ep.saga_error);  
    }
    
}