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)  

rsModColl.cpp
Go to the documentation of this file.
1 
3 /* modColl.c
4  */
5 
6 #include "rsModColl.hpp"
7 #include "modColl.h"
8 #include "rcMisc.h"
10 #include "miscServerFunct.hpp"
12 
13 int
14 rsModColl( rsComm_t *rsComm, collInp_t *modCollInp ) {
15  int status;
17 
19  rsComm,
21  ( const char* )modCollInp->collName,
22  &rodsServerHost );
23  if ( status < 0 || NULL == rodsServerHost ) { // JMC cppcheck - nullptr
24  return status;
25  }
27  std::string svc_role;
28  irods::error ret = get_catalog_service_role(svc_role);
29  if(!ret.ok()) {
30  irods::log(PASS(ret));
31  return ret.code();
32  }
33 
34  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
35  status = _rsModColl( rsComm, modCollInp );
36  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
38  } else {
39  rodsLog(
40  LOG_ERROR,
41  "role not supported [%s]",
42  svc_role.c_str() );
44  }
45  }
46  else {
47  status = rcModColl( rodsServerHost->conn, modCollInp );
48  }
49 
50  return status;
51 }
52 
53 int
54 _rsModColl( rsComm_t *rsComm, collInp_t *modCollInp ) {
55  std::string svc_role;
56  irods::error ret = get_catalog_service_role(svc_role);
57  if(!ret.ok()) {
58  irods::log(PASS(ret));
59  return ret.code();
60  }
61 
62  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
63  int status;
64  collInfo_t collInfo;
65  char *tmpStr;
66 
67  int i;
68  ruleExecInfo_t rei2;
69 
70  memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
71  rei2.rsComm = rsComm;
72  if ( rsComm != NULL ) {
73  rei2.uoic = &rsComm->clientUser;
74  rei2.uoip = &rsComm->proxyUser;
75  }
76 
77  memset( &collInfo, 0, sizeof( collInfo ) );
78 
79  rstrcpy( collInfo.collName, modCollInp->collName, MAX_NAME_LEN );
80 
81  if ((tmpStr = getValByKey(&modCollInp->condInput, COLLECTION_TYPE_KW))) {
82  rstrcpy(collInfo.collType, tmpStr, NAME_LEN);
83  }
84 
85  if ((tmpStr = getValByKey(&modCollInp->condInput, COLLECTION_INFO1_KW))) {
86  rstrcpy(collInfo.collInfo1, tmpStr, MAX_NAME_LEN);
87  }
88 
89  if ((tmpStr = getValByKey(&modCollInp->condInput, COLLECTION_INFO2_KW))) {
90  rstrcpy(collInfo.collInfo2, tmpStr, MAX_NAME_LEN);
91  }
92 
93  if ((tmpStr = getValByKey(&modCollInp->condInput, COLLECTION_MTIME_KW))) {
94  rstrcpy(collInfo.collModify, tmpStr, TIME_LEN);
95  }
96 
98  rei2.coi = &collInfo;
99  i = applyRule( "acPreProcForModifyCollMeta", NULL, &rei2, NO_SAVE_REI );
100  if ( i < 0 ) {
101  if ( rei2.status < 0 ) {
102  i = rei2.status;
103  }
105  "rsGeneralAdmin:acPreProcForModifyCollMeta error for %s,stat=%d",
106  modCollInp->collName, i );
107  return i;
108  }
111  status = chlModColl( rsComm, &collInfo );
112 
114  if ( status >= 0 ) {
115  i = applyRule( "acPostProcForModifyCollMeta", NULL, &rei2, NO_SAVE_REI );
116  if ( i < 0 ) {
117  if ( rei2.status < 0 ) {
118  i = rei2.status;
119  }
121  "rsGeneralAdmin:acPostProcForModifyCollMeta error for %s,stat=%d",
122  modCollInp->collName, i );
123  return i;
124  }
125  }
128  /* XXXX need to commit */
129  if ( status >= 0 ) {
130  status = chlCommit( rsComm );
131  }
132  else {
133  chlRollback( rsComm );
134  }
135 
136  return status;
137  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
138  return SYS_NO_RCAT_SERVER_ERR;
139  } else {
140  rodsLog(
141  LOG_ERROR,
142  "role not supported [%s]",
143  svc_role.c_str() );
145  }
146 }
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
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
modColl.h
CollInp
Definition: dataObjInpOut.h:157
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
NO_SAVE_REI
#define NO_SAVE_REI
Definition: rodsDef.h:103
rcMisc.h
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
rsModColl
int rsModColl(rsComm_t *rsComm, collInp_t *modCollInp)
Definition: rsModColl.cpp:14
chlCommit
int chlCommit(rsComm_t *rsComm)
Definition: icatHighLevelRoutines.cpp:1090
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
CollInfo
Definition: objInfo.h:177
irods::error::code
long long code() const
Definition: irods_error.cpp:194
rsComm_t::proxyUser
userInfo_t proxyUser
Definition: rcConnect.h:152
TIME_LEN
#define TIME_LEN
Definition: rodsDef.h:54
rsModColl.hpp
irods::CFG_SERVICE_ROLE_PROVIDER
const std::string CFG_SERVICE_ROLE_PROVIDER("provider")
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
chlRollback
int chlRollback(rsComm_t *rsComm)
Definition: icatHighLevelRoutines.cpp:1039
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
irods::log
void log(const error &)
Definition: irods_log.cpp:13
rsComm_t::clientUser
userInfo_t clientUser
Definition: rcConnect.h:153
rcModColl
int rcModColl(rcComm_t *conn, collInp_t *modCollInp)
Definition: rcModColl.cpp:23
irods::error
Definition: irods_error.hpp:23
_rsModColl
int _rsModColl(rsComm_t *rsComm, collInp_t *modCollInp)
Definition: rsModColl.cpp:54
miscServerFunct.hpp
getAndConnRcatHost
int getAndConnRcatHost(rsComm_t *rsComm, int rcatType, const char *rcatZoneHint, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:26
CollInfo::collInfo2
char collInfo2[(1024+64)]
Definition: objInfo.h:193
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
RuleExecInfo
Definition: irods_re_structs.hpp:18
applyRule
int applyRule(char *inAction, msParamArray_t *inMsParamArray, ruleExecInfo_t *rei, int reiSaveFlag)
Definition: irods_re_structs.cpp:65
CollInfo::collModify
char collModify[32]
Definition: objInfo.h:189
COLLECTION_MTIME_KW
#define COLLECTION_MTIME_KW
Definition: rodsKeyWdDef.h:70
icatHighLevelRoutines.hpp
CollInp::collName
char collName[(1024+64)]
Definition: dataObjInpOut.h:158
CollInfo::collType
char collType[64]
Definition: objInfo.h:191
CollInfo::collInfo1
char collInfo1[(1024+64)]
Definition: objInfo.h:192
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
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
CollInfo::collName
char collName[(1024+64)]
Definition: objInfo.h:179
chlModColl
int chlModColl(rsComm_t *rsComm, collInfo_t *collInfo)
Definition: icatHighLevelRoutines.cpp:1302