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)  

rsRegColl.cpp
Go to the documentation of this file.
1 
3 /* regColl.c
4  */
5 
6 #include "rcMisc.h"
7 #include "regColl.h"
9 #include "collection.hpp"
10 #include "miscServerFunct.hpp"
12 #include "rsRegColl.hpp"
13 #include "rsObjStat.hpp"
14 
15 int
16 rsRegColl( rsComm_t *rsComm, collInp_t *regCollInp ) {
17  int status;
19  dataObjInp_t dataObjInp;
20  rodsObjStat_t *rodsObjStatOut = NULL;
21 
22 
23  memset( &dataObjInp, 0, sizeof( dataObjInp ) );
24 
25  rstrcpy( dataObjInp.objPath, regCollInp->collName, MAX_NAME_LEN );
26  status = rsObjStat( rsComm, &dataObjInp, &rodsObjStatOut );
27  if ( status >= 0 ) {
28  if ( rodsObjStatOut != NULL ) {
29  if ( rodsObjStatOut->specColl != NULL ) { // JMC cppcheck null ptr ref
31  "rsRegColl: Reg path %s is in spec coll",
32  dataObjInp.objPath );
33  //if (rodsObjStatOut != NULL) // JMC cppcheck null ptr ref
34  freeRodsObjStat( rodsObjStatOut );
36  }
37  }
38  }
39  freeRodsObjStat( rodsObjStatOut );
40 
41  status = getAndConnRcatHost( rsComm, MASTER_RCAT, ( const char* )regCollInp->collName,
42  &rodsServerHost );
43  if ( status < 0 ) {
44  return status;
45  }
47  std::string svc_role;
48  irods::error ret = get_catalog_service_role(svc_role);
49  if(!ret.ok()) {
50  irods::log(PASS(ret));
51  return ret.code();
52  }
53 
54  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
55  status = _rsRegColl( rsComm, regCollInp );
56  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
58  } else {
59  rodsLog(
60  LOG_ERROR,
61  "role not supported [%s]",
62  svc_role.c_str() );
64  }
65 
66  }
67  else {
68  status = rcRegColl( rodsServerHost->conn, regCollInp );
69  }
70 
71  return status;
72 }
73 
74 int
75 _rsRegColl( rsComm_t *rsComm, collInp_t *collCreateInp ) {
76  std::string svc_role;
77  irods::error ret = get_catalog_service_role(svc_role);
78  if(!ret.ok()) {
79  irods::log(PASS(ret));
80  return ret.code();
81  }
82 
83  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
84  int status;
85  collInfo_t collInfo;
86  char *tmpStr;
87 
88  memset( &collInfo, 0, sizeof( collInfo ) );
89 
90  rstrcpy( collInfo.collName, collCreateInp->collName, MAX_NAME_LEN );
91 
92  if ( ( tmpStr = getValByKey( &collCreateInp->condInput, COLLECTION_TYPE_KW ) ) != NULL ) {
93  rstrcpy( collInfo.collType, tmpStr, NAME_LEN );
94  if ( ( tmpStr = getValByKey( &collCreateInp->condInput, COLLECTION_INFO1_KW ) ) != NULL ) {
95  rstrcpy( collInfo.collInfo1, tmpStr, NAME_LEN );
96  }
97  if ( ( tmpStr = getValByKey( &collCreateInp->condInput, COLLECTION_INFO2_KW ) ) != NULL ) {
98  rstrcpy( collInfo.collInfo2, tmpStr, NAME_LEN );
99  }
100  }
101 
102  status = chlRegColl( rsComm, &collInfo );
103  clearKeyVal( &collInfo.condInput );
104  return status;
105  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
106  return SYS_NO_RCAT_SERVER_ERR;
107  } else {
108  rodsLog(
109  LOG_ERROR,
110  "role not supported [%s]",
111  svc_role.c_str() );
113  }
114 }
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
getValByKey
char * getValByKey(const keyValPair_t *condInput, const char *keyWord)
Definition: rcMisc.cpp:675
DataObjInp::objPath
char objPath[(1024+64)]
Definition: dataObjInpOut.h:66
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
COLLECTION_INFO2_KW
#define COLLECTION_INFO2_KW
Definition: rodsKeyWdDef.h:69
CollInp
Definition: dataObjInpOut.h:157
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
rcRegColl
int rcRegColl(rcComm_t *conn, collInp_t *regCollInp)
Definition: rcRegColl.cpp:23
rcMisc.h
rsRegColl.hpp
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
regColl.h
rsRegColl
int rsRegColl(rsComm_t *rsComm, collInp_t *regCollInp)
Definition: rsRegColl.cpp:16
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
CollInfo
Definition: objInfo.h:177
chlRegColl
int chlRegColl(rsComm_t *rsComm, collInfo_t *collInfo)
Definition: icatHighLevelRoutines.cpp:1246
freeRodsObjStat
int freeRodsObjStat(rodsObjStat_t *rodsObjStat)
Definition: rcMisc.cpp:3537
irods::error::code
long long code() const
Definition: irods_error.cpp:194
rsObjStat
int rsObjStat(rsComm_t *rsComm, dataObjInp_t *dataObjInp, rodsObjStat_t **rodsObjStatOut)
Definition: rsObjStat.cpp:23
irods::CFG_SERVICE_ROLE_PROVIDER
const std::string CFG_SERVICE_ROLE_PROVIDER("provider")
DataObjInp
Definition: dataObjInpOut.h:65
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
COLLECTION_TYPE_KW
#define COLLECTION_TYPE_KW
Definition: rodsKeyWdDef.h:67
SYS_NO_RCAT_SERVER_ERR
@ SYS_NO_RCAT_SERVER_ERR
Definition: rodsErrorTable.h:110
CollInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:161
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
collection.hpp
irods::log
void log(const error &)
Definition: irods_log.cpp:13
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
CollInfo::condInput
keyValPair_t condInput
Definition: objInfo.h:194
CollInfo::collInfo2
char collInfo2[(1024+64)]
Definition: objInfo.h:193
SYS_REG_OBJ_IN_SPEC_COLL
@ SYS_REG_OBJ_IN_SPEC_COLL
Definition: rodsErrorTable.h:124
rsObjStat.hpp
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
_rsRegColl
int _rsRegColl(rsComm_t *rsComm, collInp_t *collCreateInp)
Definition: rsRegColl.cpp:75
icatHighLevelRoutines.hpp
CollInp::collName
char collName[(1024+64)]
Definition: dataObjInpOut.h:158
rodsObjStat
Definition: objStat.h:8
CollInfo::collType
char collType[64]
Definition: objInfo.h:191
CollInfo::collInfo1
char collInfo1[(1024+64)]
Definition: objInfo.h:192
rodsObjStat::specColl
specColl_t * specColl
Definition: objStat.h:18
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
NAME_LEN
#define NAME_LEN
Definition: rodsDef.h:55
COLLECTION_INFO1_KW
#define COLLECTION_INFO1_KW
Definition: rodsKeyWdDef.h:68
clearKeyVal
int clearKeyVal(keyValPair_t *condInput)
Definition: rcMisc.cpp:1047
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
CollInfo::collName
char collName[(1024+64)]
Definition: objInfo.h:179