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)  

rsRegDataObj.cpp
Go to the documentation of this file.
1 
3 /* regDataObj.c
4  */
5 
6 #include "regDataObj.h"
8 #include "fileDriver.hpp"
9 #include "miscServerFunct.hpp"
10 #include "rsRegDataObj.hpp"
11 
12 #include "irods_file_object.hpp"
14 
15 /* rsRegDataObj - This call is strictly an API handler and should not be
16  * called directly in the server. For server calls, use svrRegDataObj
17  */
18 int
19 rsRegDataObj( rsComm_t *rsComm, dataObjInfo_t *dataObjInfo,
20  dataObjInfo_t **outDataObjInfo ) {
21  int status;
23 
24  *outDataObjInfo = NULL;
25 
26  status = getAndConnRcatHost( rsComm, MASTER_RCAT, ( const char* )dataObjInfo->objPath,
27  &rodsServerHost );
28  if ( status < 0 || NULL == rodsServerHost ) { // JMC cppcheck - nullptr
29  return status;
30  }
31 
33  std::string svc_role;
34  irods::error ret = get_catalog_service_role(svc_role);
35  if(!ret.ok()) {
36  irods::log(PASS(ret));
37  return ret.code();
38  }
39 
40  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
41  status = _rsRegDataObj( rsComm, dataObjInfo );
42  if ( status >= 0 ) {
43  *outDataObjInfo = ( dataObjInfo_t * ) malloc( sizeof( dataObjInfo_t ) );
44  /* fake pointers will be deleted by the packing */
45  //**outDataObjInfo = *dataObjInfo;
46  memcpy( *outDataObjInfo, dataObjInfo, sizeof( dataObjInfo_t ) );
47  }
48  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
50  } else {
51  rodsLog(
52  LOG_ERROR,
53  "role not supported [%s]",
54  svc_role.c_str() );
56  }
57  }
58  else {
59  status = rcRegDataObj( rodsServerHost->conn, dataObjInfo,
60  outDataObjInfo );
61  }
62  return status;
63 }
64 
65 int
66 _rsRegDataObj( rsComm_t *rsComm, dataObjInfo_t *dataObjInfo ) {
67  std::string svc_role;
68  irods::error ret = get_catalog_service_role(svc_role);
69  if(!ret.ok()) {
70  irods::log(PASS(ret));
71  return ret.code();
72  }
73 
74  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
75  int status;
76  irods::error ret;
77  status = chlRegDataObj( rsComm, dataObjInfo );
78  if ( status < 0 ) {
79  char* sys_error = NULL;
80  const char* rods_error = rodsErrorName( status, &sys_error );
81  std::stringstream msg;
82  msg << __FUNCTION__;
83  msg << " - Failed to register data object \"" << dataObjInfo->objPath << "\"";
84  msg << " - " << rods_error << " " << sys_error;
85  ret = ERROR( status, msg.str() );
86  irods::log( ret );
87  free( sys_error );
88  }
89  else {
90  irods::file_object_ptr file_obj(
92  rsComm,
93  dataObjInfo ) );
94  ret = fileRegistered( rsComm, file_obj );
95  if ( !ret.ok() ) {
96  std::stringstream msg;
97  msg << __FUNCTION__;
98  msg << " - Failed to signal resource that the data object \"";
99  msg << dataObjInfo->objPath;
100  msg << "\" was registered";
101  ret = PASSMSG( msg.str(), ret );
102  irods::log( ret );
103  status = ret.code();
104  }
105  }
106  return status;
107  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
108  return SYS_NO_RCAT_SERVER_ERR;
109  } else {
110  rodsLog(
111  LOG_ERROR,
112  "role not supported [%s]",
113  svc_role.c_str() );
115  }
116 
117 }
118 
119 int
120 svrRegDataObj( rsComm_t *rsComm, dataObjInfo_t *dataObjInfo ) {
121  int status;
123 
124  if ( dataObjInfo->specColl != NULL ) {
126  "svrRegDataObj: Reg path %s is in spec coll",
127  dataObjInfo->objPath );
129  }
130 
131  status = getAndConnRcatHost( rsComm, MASTER_RCAT, ( const char* )dataObjInfo->objPath,
132  &rodsServerHost );
133  if ( status < 0 || NULL == rodsServerHost ) { // JMC cppcheck - nullptr
134  return status;
135  }
136 
137  if ( rodsServerHost->localFlag == LOCAL_HOST ) {
138  std::string svc_role;
139  irods::error ret = get_catalog_service_role(svc_role);
140  if(!ret.ok()) {
141  irods::log(PASS(ret));
142  return ret.code();
143  }
144 
145  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
146  status = _rsRegDataObj( rsComm, dataObjInfo );
147  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
149  } else {
150  rodsLog(
151  LOG_ERROR,
152  "role not supported [%s]",
153  svc_role.c_str() );
155  }
156  }
157  else {
158  dataObjInfo_t *outDataObjInfo = NULL;
159  status = rcRegDataObj( rodsServerHost->conn, dataObjInfo,
160  &outDataObjInfo );
161  if ( status >= 0 && NULL != outDataObjInfo ) { // JMC cppcheck - nullptr
162  dataObjInfo->dataId = outDataObjInfo->dataId;
163  clearKeyVal( &outDataObjInfo->condInput );
164  free( outDataObjInfo );
165  }
166  }
167 
168  return status;
169 }
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
NULL
#define NULL
Definition: rodsDef.h:70
regDataObj.h
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
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
irods_file_object.hpp
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
_rsRegDataObj
int _rsRegDataObj(rsComm_t *rsComm, dataObjInfo_t *dataObjInfo)
Definition: rsRegDataObj.cpp:66
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
DataObjInfo::condInput
keyValPair_t condInput
Definition: objInfo.h:161
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
fileDriver.hpp
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
rodsErrorName
const char * rodsErrorName(int errorValue, char **subName)
Definition: rodsLog.cpp:373
DataObjInfo::dataId
rodsLong_t dataId
Definition: objInfo.h:143
DataObjInfo::specColl
specColl_t * specColl
Definition: objInfo.h:158
rcRegDataObj
int rcRegDataObj(rcComm_t *conn, dataObjInfo_t *dataObjInfo, dataObjInfo_t **outDataObjInfo)
Definition: rcRegDataObj.cpp:24
irods::error::code
long long code() const
Definition: irods_error.cpp:194
chlRegDataObj
int chlRegDataObj(rsComm_t *rsComm, dataObjInfo_t *dataObjInfo)
Definition: icatHighLevelRoutines.cpp:491
irods::CFG_SERVICE_ROLE_PROVIDER
const std::string CFG_SERVICE_ROLE_PROVIDER("provider")
SYS_NO_RCAT_SERVER_ERR
@ SYS_NO_RCAT_SERVER_ERR
Definition: rodsErrorTable.h:110
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
irods::log
void log(const error &)
Definition: irods_log.cpp:13
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
getAndConnRcatHost
int getAndConnRcatHost(rsComm_t *rsComm, int rcatType, const char *rcatZoneHint, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:26
fileRegistered
irods::error fileRegistered(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:622
SYS_REG_OBJ_IN_SPEC_COLL
@ SYS_REG_OBJ_IN_SPEC_COLL
Definition: rodsErrorTable.h:124
MASTER_RCAT
#define MASTER_RCAT
Definition: rodsDef.h:85
svrRegDataObj
int svrRegDataObj(rsComm_t *rsComm, dataObjInfo_t *dataObjInfo)
Definition: rsRegDataObj.cpp:120
get_catalog_service_role
irods::error get_catalog_service_role(std::string &_role)
Definition: miscServerFunct.cpp:3153
irods::file_object
Definition: irods_file_object.hpp:19
rodsServerHost
Definition: rodsConnect.h:62
irods::file_object_ptr
boost::shared_ptr< file_object > file_object_ptr
Definition: irods_file_object.hpp:145
rsRegDataObj
int rsRegDataObj(rsComm_t *rsComm, dataObjInfo_t *dataObjInfo, dataObjInfo_t **outDataObjInfo)
Definition: rsRegDataObj.cpp:19
icatHighLevelRoutines.hpp
DataObjInfo::objPath
char objPath[(1024+64)]
Definition: objInfo.h:130
rsRegDataObj.hpp
clearKeyVal
int clearKeyVal(keyValPair_t *condInput)
Definition: rcMisc.cpp:1047
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
DataObjInfo
Definition: objInfo.h:129