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)  

rsModAVUMetadata.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See modAVUMetadata.h for a description of this API call.*/
5 
6 #include "modAVUMetadata.h"
7 #include "rsModAVUMetadata.hpp"
9 #include "miscServerFunct.hpp"
11 
12 int
13 rsModAVUMetadata( rsComm_t *rsComm, modAVUMetadataInp_t *modAVUMetadataInp ) {
15  int status;
16  char *myHint;
17 
18  if ( strcmp( modAVUMetadataInp->arg0, "add" ) == 0 ) {
19  myHint = modAVUMetadataInp->arg2;
20  }
21  else if ( strcmp( modAVUMetadataInp->arg0, "adda" ) == 0 ) {
22  myHint = modAVUMetadataInp->arg2;
23  }
24  else if ( strcmp( modAVUMetadataInp->arg0, "addw" ) == 0 ) {
25  myHint = modAVUMetadataInp->arg2;
26  }
27  else if ( strcmp( modAVUMetadataInp->arg0, "rmw" ) == 0 ) {
28  myHint = modAVUMetadataInp->arg2;
29  }
30  else if ( strcmp( modAVUMetadataInp->arg0, "rmi" ) == 0 ) {
31  myHint = modAVUMetadataInp->arg2;
32  }
33  else if ( strcmp( modAVUMetadataInp->arg0, "rm" ) == 0 ) {
34  myHint = modAVUMetadataInp->arg2;
35  }
36  else if ( strcmp( modAVUMetadataInp->arg0, "cp" ) == 0 ) {
37  myHint = modAVUMetadataInp->arg3;
38  }
39  else if ( strcmp( modAVUMetadataInp->arg0, "mod" ) == 0 ) {
40  myHint = modAVUMetadataInp->arg2;
41  }
42  else if ( strcmp( modAVUMetadataInp->arg0, "set" ) == 0 ) { // JMC - backport 4836
43  myHint = modAVUMetadataInp->arg2;
44  }
45  else {
46  /* assume local */
47  myHint = NULL;
48  }
49 
50  status = getAndConnRcatHost( rsComm, MASTER_RCAT, ( const char* )myHint, &rodsServerHost );
51  if ( status < 0 ) {
52  return status;
53  }
54 
56  std::string svc_role;
57  irods::error ret = get_catalog_service_role(svc_role);
58  if(!ret.ok()) {
59  irods::log(PASS(ret));
60  return ret.code();
61  }
62 
63  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
64  status = _rsModAVUMetadata( rsComm, modAVUMetadataInp );
65  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
67  } else {
68  rodsLog(
69  LOG_ERROR,
70  "role not supported [%s]",
71  svc_role.c_str() );
73  }
74 
75  }
76  else {
78  modAVUMetadataInp );
79  }
80 
81  if ( status < 0 ) {
83  "rsModAVUMetadata: rcModAVUMetadata failed" );
84  }
85  return status;
86 }
87 
88 int
89 _rsModAVUMetadata( rsComm_t *rsComm, modAVUMetadataInp_t *modAVUMetadataInp ) {
90  int status, status2;
91 
92  const char *args[MAX_NUM_OF_ARGS_IN_ACTION];
93  int argc;
94  ruleExecInfo_t rei2;
95 
96  memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
97  rei2.rsComm = rsComm;
98  if ( rsComm != NULL ) {
99  rei2.uoic = &rsComm->clientUser;
100  rei2.uoip = &rsComm->proxyUser;
101  }
102 
103  args[0] = modAVUMetadataInp->arg0; // option add, adda, rm, rmw, rmi, cp, mod, or set
104  args[1] = modAVUMetadataInp->arg1; // item type -d,-D,-c,-C,-r,-R,-u,-U
105  args[2] = modAVUMetadataInp->arg2; // item name
106  args[3] = modAVUMetadataInp->arg3; // attr name
107  args[4] = modAVUMetadataInp->arg4; // attr val
108  args[5] = modAVUMetadataInp->arg5; // attr unit
109  if ( args[5] == NULL ) { args[5] = ""; }
110  if ( strcmp( args[0], "mod" ) == 0 ) {
111  argc = 9;
112 #define ARG(arg) { int ix; if( ( ix = checkModArgType(arg) ) >= 0 ) avu[ix] = arg; }
113  if ( checkModArgType( modAVUMetadataInp->arg5 ) != 0 ) {
114  char *avu[4] = {"", "", "", ""};
115  ARG( modAVUMetadataInp->arg5 );
116  ARG( modAVUMetadataInp->arg6 );
117  ARG( modAVUMetadataInp->arg7 );
118  args[5] = "";
119  memcpy( args + 6, avu + 1, sizeof( char *[3] ) );
120  }
121  else {
122  char *avu[4] = {"", "", "", ""};
123  ARG( modAVUMetadataInp->arg6 ); /* new attr */
124  ARG( modAVUMetadataInp->arg7 ); /* new val */
125  ARG( modAVUMetadataInp->arg8 ); /* new unit */
126  memcpy( args + 6, avu + 1, sizeof( char *[3] ) );
127  }
128  }
129  else if ( strcmp( args[0], "cp" ) == 0 ) {
130  argc = 5;
131  }
132  else {
133  argc = 6;
134  }
135 
136  status2 = applyRuleArg( "acPreProcForModifyAVUMetadata", args, argc,
137  &rei2, NO_SAVE_REI );
138  if ( status2 < 0 ) {
139  if ( rei2.status < 0 ) {
140  status2 = rei2.status;
141  }
143  "rsModAVUMetadata:acPreProcForModifyAVUMetadata error for %s of type %s and option %s,stat=%d",
144  modAVUMetadataInp->arg2, modAVUMetadataInp->arg1, modAVUMetadataInp->arg0, status2 );
145  return status2;
146  }
147 
148  if ( strcmp( modAVUMetadataInp->arg0, "add" ) == 0 ) {
149  status = chlAddAVUMetadata( rsComm, 0,
150  modAVUMetadataInp->arg1,
151  modAVUMetadataInp->arg2,
152  modAVUMetadataInp->arg3,
153  modAVUMetadataInp->arg4,
154  modAVUMetadataInp->arg5 );
155  }
156  else if ( strcmp( modAVUMetadataInp->arg0, "adda" ) == 0 ) {
157  status = chlAddAVUMetadata( rsComm, 1,
158  modAVUMetadataInp->arg1,
159  modAVUMetadataInp->arg2,
160  modAVUMetadataInp->arg3,
161  modAVUMetadataInp->arg4,
162  modAVUMetadataInp->arg5 );
163  }
164  else if ( strcmp( modAVUMetadataInp->arg0, "addw" ) == 0 ) {
165  status = chlAddAVUMetadataWild( rsComm, 0,
166  modAVUMetadataInp->arg1,
167  modAVUMetadataInp->arg2,
168  modAVUMetadataInp->arg3,
169  modAVUMetadataInp->arg4,
170  modAVUMetadataInp->arg5 );
171  }
172  else if ( strcmp( modAVUMetadataInp->arg0, "rmw" ) == 0 ) {
173  status = chlDeleteAVUMetadata( rsComm, 1,
174  modAVUMetadataInp->arg1,
175  modAVUMetadataInp->arg2,
176  modAVUMetadataInp->arg3,
177  modAVUMetadataInp->arg4,
178  modAVUMetadataInp->arg5,
179  0 );
180  }
181  else if ( strcmp( modAVUMetadataInp->arg0, "rmi" ) == 0 ) {
182  status = chlDeleteAVUMetadata( rsComm, 2,
183  modAVUMetadataInp->arg1,
184  modAVUMetadataInp->arg2,
185  modAVUMetadataInp->arg3,
186  modAVUMetadataInp->arg4,
187  modAVUMetadataInp->arg5,
188  0 );
189  }
190  else if ( strcmp( modAVUMetadataInp->arg0, "rm" ) == 0 ) {
191  status = chlDeleteAVUMetadata( rsComm, 0,
192  modAVUMetadataInp->arg1,
193  modAVUMetadataInp->arg2,
194  modAVUMetadataInp->arg3,
195  modAVUMetadataInp->arg4,
196  modAVUMetadataInp->arg5,
197  0 );
198  }
199  else if ( strcmp( modAVUMetadataInp->arg0, "cp" ) == 0 ) {
200  status = chlCopyAVUMetadata( rsComm,
201  modAVUMetadataInp->arg1,
202  modAVUMetadataInp->arg2,
203  modAVUMetadataInp->arg3,
204  modAVUMetadataInp->arg4 );
205  }
206  else if ( strcmp( modAVUMetadataInp->arg0, "mod" ) == 0 ) {
207  status = chlModAVUMetadata( rsComm,
208  modAVUMetadataInp->arg1,
209  modAVUMetadataInp->arg2,
210  modAVUMetadataInp->arg3,
211  modAVUMetadataInp->arg4,
212  modAVUMetadataInp->arg5,
213  modAVUMetadataInp->arg6,
214  modAVUMetadataInp->arg7,
215  modAVUMetadataInp->arg8 );
216  }
217  else if ( strcmp( modAVUMetadataInp->arg0, "set" ) == 0 ) { // JMC - backport 4836
218  status = chlSetAVUMetadata( rsComm,
219  modAVUMetadataInp->arg1,
220  modAVUMetadataInp->arg2,
221  modAVUMetadataInp->arg3,
222  modAVUMetadataInp->arg4,
223  modAVUMetadataInp->arg5 );
224  }
225  else {
226  return CAT_INVALID_ARGUMENT;
227  }
228 
229  if ( status >= 0 ) {
230  status2 = applyRuleArg( "acPostProcForModifyAVUMetadata", args, argc, &rei2, NO_SAVE_REI );
231  if ( status2 < 0 ) {
232  if ( rei2.status < 0 ) {
233  status2 = rei2.status;
234  }
236  "rsModAVUMetadata:acPostProcForModifyAVUMetadata error for %s of type %s and option %s,stat=%d",
237  modAVUMetadataInp->arg2,
238  modAVUMetadataInp->arg1,
239  modAVUMetadataInp->arg0,
240  status2 );
241  return status2;
242  }
243  }
244 
245  return status;
246 
247 }
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
modAVUMetadataInp_t::arg0
char * arg0
Definition: modAVUMetadata.h:7
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
chlCopyAVUMetadata
int chlCopyAVUMetadata(rsComm_t *rsComm, const char *type1, const char *type2, const char *name1, const char *name2)
Definition: icatHighLevelRoutines.cpp:2779
NO_SAVE_REI
#define NO_SAVE_REI
Definition: rodsDef.h:103
modAVUMetadataInp_t::arg2
char * arg2
Definition: modAVUMetadata.h:9
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
modAVUMetadataInp_t::arg4
char * arg4
Definition: modAVUMetadata.h:11
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
rsModAVUMetadata.hpp
chlAddAVUMetadata
int chlAddAVUMetadata(rsComm_t *rsComm, int adminMode, const char *type, const char *name, const char *attribute, const char *value, const char *units)
Definition: icatHighLevelRoutines.cpp:2575
chlDeleteAVUMetadata
int chlDeleteAVUMetadata(rsComm_t *rsComm, int option, const char *type, const char *name, const char *attribute, const char *value, const char *units, int noCommit)
Definition: icatHighLevelRoutines.cpp:2711
irods::error::code
long long code() const
Definition: irods_error.cpp:194
chlSetAVUMetadata
int chlSetAVUMetadata(rsComm_t *rsComm, const char *type, const char *name, const char *attribute, const char *newValue, const char *newUnit)
Definition: icatHighLevelRoutines.cpp:2443
ARG
#define ARG(arg)
rsComm_t::proxyUser
userInfo_t proxyUser
Definition: rcConnect.h:152
modAVUMetadataInp_t::arg7
char * arg7
Definition: modAVUMetadata.h:14
irods::CFG_SERVICE_ROLE_PROVIDER
const std::string CFG_SERVICE_ROLE_PROVIDER("provider")
applyRuleArg
int applyRuleArg(const char *action, const char *args[20], int argc, ruleExecInfo_t *rei, int reiSaveFlag)
Definition: irods_re_structs.cpp:95
MAX_NUM_OF_ARGS_IN_ACTION
#define MAX_NUM_OF_ARGS_IN_ACTION
Definition: irods_re_structs.hpp:13
chlModAVUMetadata
int chlModAVUMetadata(rsComm_t *rsComm, const char *type, const char *name, const char *attribute, const char *value, const char *unitsOrChange0, const char *change1, const char *change2, const char *change3)
Definition: icatHighLevelRoutines.cpp:2639
SYS_NO_RCAT_SERVER_ERR
@ SYS_NO_RCAT_SERVER_ERR
Definition: rodsErrorTable.h:110
modAVUMetadataInp_t::arg3
char * arg3
Definition: modAVUMetadata.h:10
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
irods::log
void log(const error &)
Definition: irods_log.cpp:13
rcModAVUMetadata
int rcModAVUMetadata(rcComm_t *conn, modAVUMetadataInp_t *modAVUMetadataInp)
Definition: rcModAVUMetadata.cpp:41
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
modAVUMetadataInp_t
Definition: modAVUMetadata.h:6
rsComm_t::clientUser
userInfo_t clientUser
Definition: rcConnect.h:153
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
rsModAVUMetadata
int rsModAVUMetadata(rsComm_t *rsComm, modAVUMetadataInp_t *modAVUMetadataInp)
Definition: rsModAVUMetadata.cpp:13
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
modAVUMetadataInp_t::arg6
char * arg6
Definition: modAVUMetadata.h:13
RuleExecInfo
Definition: irods_re_structs.hpp:18
modAVUMetadata.h
checkModArgType
int checkModArgType(const char *arg)
Definition: miscServerFunct.cpp:3002
icatHighLevelRoutines.hpp
CAT_INVALID_ARGUMENT
@ CAT_INVALID_ARGUMENT
Definition: rodsErrorTable.h:431
_rsModAVUMetadata
int _rsModAVUMetadata(rsComm_t *rsComm, modAVUMetadataInp_t *modAVUMetadataInp)
Definition: rsModAVUMetadata.cpp:89
modAVUMetadataInp_t::arg5
char * arg5
Definition: modAVUMetadata.h:12
chlAddAVUMetadataWild
int chlAddAVUMetadataWild(rsComm_t *rsComm, int adminMode, const char *type, const char *name, const char *attribute, const char *value, const char *units)
Definition: icatHighLevelRoutines.cpp:2510
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
modAVUMetadataInp_t::arg1
char * arg1
Definition: modAVUMetadata.h:8
modAVUMetadataInp_t::arg8
char * arg8
Definition: modAVUMetadata.h:15