irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

rsGetHierarchyForResc.cpp
Go to the documentation of this file.
1 
3 /* unregDataObj.c
4  */
5 
7 #include "getHierarchyForResc.h"
8 #include "irods_stacktrace.hpp"
9 #include "miscServerFunct.hpp"
12 
13 // =-=-=-=-=-=-=-
14 // local implementation which makes the icat high level
15 // call to compute the hierarchy for a given resource
18  getHierarchyForRescOut_t** _out ) {
19  // =-=-=-=-=-=-=-
20  // icat high level calls only work on a server
21  // connected to the database
22  std::string svc_role;
23  irods::error ret = get_catalog_service_role(svc_role);
24  if(!ret.ok()) {
25  irods::log(PASS(ret));
26  return ret.code();
27  }
28 
29  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
30  // =-=-=-=-=-=-=-
31  // allocate the outgoing structure
32  ( *_out ) = ( getHierarchyForRescOut_t* )malloc( sizeof( getHierarchyForRescOut_t ) );
33  bzero( ( *_out ), sizeof( getHierarchyForRescOut_t ) );
34 
35  // =-=-=-=-=-=-=-
36  // get local zone
37  char* zone_name = getLocalZoneName();
38 
39  // =-=-=-=-=-=-=-
40  // make the chl call to get the hierarchy
41  std::string hier;
43  _inp->resc_name_,
44  zone_name,
45  hier );
46  snprintf( ( *_out )->resc_hier_, MAX_NAME_LEN, "%s", hier.c_str() );
47 
48  return status;
49  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
51  } else {
52  rodsLog(
53  LOG_ERROR,
54  "role not supported [%s]",
55  svc_role.c_str() );
57  }
58 
59 
60 } // _rsGetHierarchyForResc
61 
62 // =-=-=-=-=-=-=-
63 // connect to the icat server and issue the
64 // api call, if we are on the icat server run
65 // the icat highlevel function to compute the
66 // heirarchy of a resource in a composition (tree)
67 // starting at the root to the given resource
69  rsComm_t* _comm,
71  getHierarchyForRescOut_t** _out ) {
72  // =-=-=-=-=-=-=-
73  // get local zone
74  char* zone_name = getLocalZoneName();
75 
76  // =-=-=-=-=-=-=-
77  // use zone as hint to get the icat connectoin
78  rodsServerHost_t* svr_host = NULL;
80  _comm,
82  ( const char* )zone_name,
83  &svr_host );
84  if ( status < 0 || NULL == svr_host ) {
85  return status;
86  }
87 
88  // =-=-=-=-=-=-=-
89  // if we are on the icat server run the fetch,
90  // otherwise redirect to the icat server
91  if ( svr_host->localFlag == LOCAL_HOST ) {
92  std::string svc_role;
93  irods::error ret = get_catalog_service_role(svc_role);
94  if(!ret.ok()) {
95  irods::log(PASS(ret));
96  return ret.code();
97  }
98  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
99  status = _rsGetHierarchyForResc( _inp, _out );
100  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
102  } else {
103  rodsLog(
104  LOG_ERROR,
105  "role not supported [%s]",
106  svc_role.c_str() );
108  }
109 
110  }
111  else {
112  status = rcGetHierarchyForResc( svr_host->conn, _inp, _out );
113  }
114 
115  return status;
116 
117 } // rsGetHierarchyForResc
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
irods::CFG_SERVICE_ROLE_CONSUMER
const std::string CFG_SERVICE_ROLE_CONSUMER("consumer")
irods_configuration_keywords.hpp
rodsServerHost::localFlag
int localFlag
Definition: rodsConnect.h:68
SYS_SERVICE_ROLE_NOT_SUPPORTED
@ SYS_SERVICE_ROLE_NOT_SUPPORTED
Definition: rodsErrorTable.h:217
GetHierarchyForRescOut
Definition: getHierarchyForResc.h:12
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
irods_stacktrace.hpp
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
manual_cleanup.zone_name
zone_name
Definition: manual_cleanup.py:16
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
rsGetHierarchyForResc.hpp
irods::error::code
long long code() const
Definition: irods_error.cpp:194
GetHierarchyForRescInp
Definition: getHierarchyForResc.h:7
irods::CFG_SERVICE_ROLE_PROVIDER
const std::string CFG_SERVICE_ROLE_PROVIDER("provider")
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
SYS_NO_RCAT_SERVER_ERR
@ SYS_NO_RCAT_SERVER_ERR
Definition: rodsErrorTable.h:110
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
GetHierarchyForRescInp::resc_name_
char resc_name_[(1024+64)]
Definition: getHierarchyForResc.h:8
irods::log
void log(const error &)
Definition: irods_log.cpp:13
irods::error
Definition: irods_error.hpp:23
_rsGetHierarchyForResc
int _rsGetHierarchyForResc(getHierarchyForRescInp_t *_inp, getHierarchyForRescOut_t **_out)
Definition: rsGetHierarchyForResc.cpp:16
miscServerFunct.hpp
getLocalZoneName
char * getLocalZoneName()
Definition: rodsConnect.cpp:685
getAndConnRcatHost
int getAndConnRcatHost(rsComm_t *rsComm, int rcatType, const char *rcatZoneHint, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:26
MASTER_RCAT
#define MASTER_RCAT
Definition: rodsDef.h:85
get_catalog_service_role
irods::error get_catalog_service_role(std::string &_role)
Definition: miscServerFunct.cpp:3153
rodsServerHost
Definition: rodsConnect.h:62
getHierarchyForResc.h
icatHighLevelRoutines.hpp
rsGetHierarchyForResc
int rsGetHierarchyForResc(rsComm_t *_comm, getHierarchyForRescInp_t *_inp, getHierarchyForRescOut_t **_out)
Definition: rsGetHierarchyForResc.cpp:68
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
rcGetHierarchyForResc
int rcGetHierarchyForResc(rcComm_t *server_comm_ptr, getHierarchyForRescInp_t *incoming_resc_name, getHierarchyForRescOut_t **full_hier_to_resc)
Definition: rcGetHierarchyForResc.cpp:6
chlGetHierarchyForResc
int chlGetHierarchyForResc(const std::string &resc_name, const std::string &zone_name, std::string &hierarchy)
Definition: icatHighLevelRoutines.cpp:4347