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)  

rsDataObjWrite.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See dataObjWrite.h for a description of this API call.*/
5 
6 #include "dataObjWrite.h"
7 #include "rodsLog.h"
8 #include "objMetaOpr.hpp"
9 #include "subStructFileWrite.h"
10 #include "fileWrite.h"
11 #include "rsGlobalExtern.hpp"
12 #include "rcGlobalExtern.h"
13 #include "subStructFileRead.h" /* XXXXX can be taken out when structFile api done */
14 #include "rsDataObjWrite.hpp"
15 #include "rsSubStructFileWrite.hpp"
16 #include "rsFileWrite.hpp"
17 
18 // =-=-=-=-=-=-=-
21 #include "irods_file_object.hpp"
23 
24 
25 int
26 applyRuleForPostProcForWrite( rsComm_t *rsComm, bytesBuf_t *dataObjWriteInpBBuf, char *objPath ) {
27  if ( ReadWriteRuleState != ON_STATE ) {
28  return 0;
29  }
30 
31  ruleExecInfo_t rei2;
32  memset( ( char* )&rei2, 0, sizeof( ruleExecInfo_t ) );
33  msParamArray_t msParamArray;
34  memset( ( char* )&msParamArray, 0, sizeof( msParamArray_t ) );
35 
36  if ( rsComm != NULL ) {
37  rei2.rsComm = rsComm;
38  rei2.uoic = &rsComm->clientUser;
39  rei2.uoip = &rsComm->proxyUser;
40  }
41  rei2.doi = ( dataObjInfo_t* )malloc( sizeof( dataObjInfo_t ) );
42  memset(rei2.doi,0,sizeof(dataObjInfo_t));
43 
44  snprintf( rei2.doi->objPath, sizeof( rei2.doi->objPath ), "%s", objPath );
45 
46  memset( &msParamArray, 0, sizeof( msParamArray ) );
47  int * myInOutStruct = ( int* )malloc( sizeof( int ) );
48  *myInOutStruct = dataObjWriteInpBBuf->len;
49  addMsParamToArray( &msParamArray, "*WriteBuf", BUF_LEN_MS_T, myInOutStruct,
50  dataObjWriteInpBBuf, 0 );
51  int status = applyRule( "acPostProcForDataObjWrite(*WriteBuf)", &msParamArray, &rei2, NO_SAVE_REI );
52  free( rei2.doi );
53  if ( status < 0 ) {
54  if ( rei2.status < 0 ) {
55  status = rei2.status;
56  }
58  "rsDataObjWrite: acPostProcForDataObjWrite error=%d", status );
59  clearMsParamArray( &msParamArray, 0 );
60  return status;
61  }
62  clearMsParamArray( &msParamArray, 0 );
63 
64  return 0;
65 
66 }
67 
69  rsComm_t* rsComm,
70  openedDataObjInp_t* dataObjWriteInp,
71  bytesBuf_t* dataObjWriteInpBBuf ) {
72  int bytesWritten = 0;
73  int l1descInx = dataObjWriteInp->l1descInx;
74 
75  if ( l1descInx < 2 || l1descInx >= NUM_L1_DESC ) {
76  rodsLog(
77  LOG_NOTICE,
78  "rsDataObjWrite: l1descInx %d out of range",
79  l1descInx );
81  }
82 
83  if ( L1desc[l1descInx].inuseFlag != FD_INUSE ) {
84  return BAD_INPUT_DESC_INDEX;
85  }
86 
87  if ( L1desc[l1descInx].remoteZoneHost != NULL ) {
88  // =-=-=-=-=-=-=-
89  // cross zone operation
90  dataObjWriteInp->l1descInx = L1desc[l1descInx].remoteL1descInx;
91  bytesWritten = rcDataObjWrite(
92  L1desc[l1descInx].remoteZoneHost->conn,
93  dataObjWriteInp,
94  dataObjWriteInpBBuf );
95  dataObjWriteInp->l1descInx = l1descInx;
96  }
97  else {
99  rsComm,
100  dataObjWriteInpBBuf,
101  L1desc[l1descInx].dataObjInfo->objPath );
102  if ( i < 0 ) {
103  return i;
104  }
105 
106  // =-=-=-=-=-=-=-
107  // notify the resource hierarchy that something is afoot
108  irods::file_object_ptr file_obj(
109  new irods::file_object(
110  rsComm,
111  L1desc[l1descInx].dataObjInfo ) );
112  char* pdmo_kw = getValByKey( &dataObjWriteInp->condInput, IN_PDMO_KW );
113  if ( pdmo_kw != NULL ) {
114  file_obj->in_pdmo( pdmo_kw );
115  }
116  irods::error ret = fileNotify(
117  rsComm,
118  file_obj,
120  if ( !ret.ok() ) {
121  std::stringstream msg;
122  msg << "Failed to signal the resource that the data object \"";
123  msg << L1desc[l1descInx].dataObjInfo->objPath;
124  msg << "\" was modified.";
125  ret = PASSMSG( msg.str(), ret );
126  irods::log( ret );
127  return ret.code();
128  }
129 
130  dataObjWriteInp->len = dataObjWriteInpBBuf->len;
131  bytesWritten = l3Write(
132  rsComm,
133  l1descInx,
134  dataObjWriteInp->len,
135  dataObjWriteInpBBuf );
136  }
137 
138  return bytesWritten;
139 }
140 
141 int
142 l3Write( rsComm_t *rsComm, int l1descInx, int len,
143  bytesBuf_t *dataObjWriteInpBBuf ) {
144  fileWriteInp_t fileWriteInp;
145  int bytesWritten;
146 
147  dataObjInfo_t *dataObjInfo;
148  dataObjInfo = L1desc[l1descInx].dataObjInfo;
149 
150  std::string location;
151  irods::error ret = irods::get_loc_for_hier_string( dataObjInfo->rescHier, location );
152  if ( !ret.ok() ) {
153  irods::log( PASSMSG( "l3Write - failed in get_loc_for_hier_string", ret ) );
154  return -1;
155  }
156 
157  if ( getStructFileType( dataObjInfo->specColl ) >= 0 ) {
158  subStructFileFdOprInp_t subStructFileWriteInp;
159  memset( &subStructFileWriteInp, 0, sizeof( subStructFileWriteInp ) );
160  subStructFileWriteInp.type = dataObjInfo->specColl->type;
161  subStructFileWriteInp.fd = L1desc[l1descInx].l3descInx;
162  subStructFileWriteInp.len = len;
163  rstrcpy( subStructFileWriteInp.addr.hostAddr, location.c_str(), NAME_LEN );
164  rstrcpy( subStructFileWriteInp.resc_hier, dataObjInfo->rescHier, MAX_NAME_LEN );
165  bytesWritten = rsSubStructFileWrite( rsComm, &subStructFileWriteInp, dataObjWriteInpBBuf );
166  }
167  else {
168  memset( &fileWriteInp, 0, sizeof( fileWriteInp ) );
169  fileWriteInp.fileInx = L1desc[l1descInx].l3descInx;
170  fileWriteInp.len = len;
171  bytesWritten = rsFileWrite( rsComm, &fileWriteInp, dataObjWriteInpBBuf );
172 
173  if ( bytesWritten > 0 ) {
174  auto& bw = L1desc[l1descInx].bytesWritten;
175 
176  if (bw == -1) {
177  bw = bytesWritten;
178  }
179  else {
180  bw += bytesWritten;
181  }
182  }
183  }
184 
185  return bytesWritten;
186 }
187 
188 int
189 _l3Write( rsComm_t *rsComm, int l3descInx,
190  void *buf, int len ) {
191  fileWriteInp_t fileWriteInp;
192  bytesBuf_t dataObjWriteInpBBuf;
193  int bytesWritten;
194 
195  dataObjWriteInpBBuf.len = len;
196  dataObjWriteInpBBuf.buf = buf;
197  memset( &fileWriteInp, 0, sizeof( fileWriteInp ) );
198  fileWriteInp.fileInx = l3descInx;
199  fileWriteInp.len = len;
200  bytesWritten = rsFileWrite( rsComm, &fileWriteInp,
201  &dataObjWriteInpBBuf );
202  return bytesWritten;
203 }
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
OpenedDataObjInp
Definition: dataObjInpOut.h:104
L1desc
l1desc_t L1desc[1026]
Definition: irods_server_globals.cpp:29
rsFileWrite.hpp
NULL
#define NULL
Definition: rodsDef.h:70
SubStructFileFdOpr::addr
rodsHostAddr_t addr
Definition: subStructFileRead.h:9
rsComm_t
Definition: rcConnect.h:145
l3Write
int l3Write(rsComm_t *rsComm, int l1descInx, int len, bytesBuf_t *dataObjWriteInpBBuf)
Definition: rsDataObjWrite.cpp:142
rsFileWrite
int rsFileWrite(rsComm_t *rsComm, fileWriteInp_t *fileWriteInp, bytesBuf_t *fileWriteInpBBuf)
Definition: rsFileWrite.cpp:20
SubStructFileFdOpr::len
int len
Definition: subStructFileRead.h:12
rsDataObjWrite.hpp
BytesBuf::buf
void * buf
Definition: rodsDef.h:199
ReadWriteRuleState
irodsStateFlag_t ReadWriteRuleState
Definition: irods_server_globals.cpp:74
rsSubStructFileWrite
int rsSubStructFileWrite(rsComm_t *rsComm, subStructFileFdOprInp_t *subStructFileWriteInp, bytesBuf_t *subStructFileWriteOutBBuf)
Definition: rsSubStructFileWrite.cpp:13
irods_file_object.hpp
OpenedDataObjInp::l1descInx
int l1descInx
Definition: dataObjInpOut.h:105
NO_SAVE_REI
#define NO_SAVE_REI
Definition: rodsDef.h:103
BUF_LEN_MS_T
#define BUF_LEN_MS_T
Definition: msParam.h:25
l1desc::remoteL1descInx
int remoteL1descInx
Definition: objDesc.hpp:52
SpecColl::type
structFileType_t type
Definition: objInfo.h:78
fileNotify
irods::error fileNotify(rsComm_t *_comm, irods::first_class_object_ptr _object, const std::string &)
Definition: fileDriver.cpp:737
l1desc::dataObjInfo
dataObjInfo_t * dataObjInfo
Definition: objDesc.hpp:42
getStructFileType
int getStructFileType(specColl_t *specColl)
Definition: objMetaOpr.cpp:386
DataObjInfo::rescHier
char rescHier[(1024+64)]
Definition: objInfo.h:132
irods_resource_backport.hpp
fileWriteInp_t
Definition: fileWrite.h:7
l1desc::l3descInx
int l3descInx
Definition: objDesc.hpp:35
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
fileWriteInp_t::len
int len
Definition: fileWrite.h:9
rcGlobalExtern.h
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
irods_resource_redirect.hpp
DataObjInfo::specColl
specColl_t * specColl
Definition: objInfo.h:158
SubStructFileFdOpr
Definition: subStructFileRead.h:8
BytesBuf::len
int len
Definition: rodsDef.h:198
fileWrite.h
rsGlobalExtern.hpp
clearMsParamArray
int clearMsParamArray(msParamArray_t *msParamArray, int freeStruct)
Definition: msParam.cpp:447
subStructFileWrite.h
irods::error::code
long long code() const
Definition: irods_error.cpp:194
rsComm_t::proxyUser
userInfo_t proxyUser
Definition: rcConnect.h:152
fileWriteInp_t::fileInx
int fileInx
Definition: fileWrite.h:8
OpenedDataObjInp::len
int len
Definition: dataObjInpOut.h:106
rsSubStructFileWrite.hpp
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
dataObjWrite.h
rodsLog.h
ON_STATE
@ ON_STATE
Definition: rodsDef.h:168
irods::log
void log(const error &)
Definition: irods_log.cpp:13
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
rsComm_t::clientUser
userInfo_t clientUser
Definition: rcConnect.h:153
BytesBuf
Definition: rodsDef.h:197
irods::error
Definition: irods_error.hpp:23
NUM_L1_DESC
#define NUM_L1_DESC
Definition: objDesc.hpp:24
addMsParamToArray
int addMsParamToArray(msParamArray_t *msParamArray, const char *label, const char *type, void *inOutStruct, bytesBuf_t *inpOutBuf, int replFlag)
Definition: msParam.cpp:47
BAD_INPUT_DESC_INDEX
@ BAD_INPUT_DESC_INDEX
Definition: rodsErrorTable.h:266
FD_INUSE
#define FD_INUSE
Definition: fileOpr.hpp:21
SubStructFileFdOpr::resc_hier
char resc_hier[(1024+64)]
Definition: subStructFileRead.h:13
OpenedDataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:111
IN_PDMO_KW
#define IN_PDMO_KW
Definition: rodsKeyWdDef.h:227
SubStructFileFdOpr::fd
int fd
Definition: subStructFileRead.h:11
irods_hierarchy_parser.hpp
SubStructFileFdOpr::type
structFileType_t type
Definition: subStructFileRead.h:10
irods::file_object
Definition: irods_file_object.hpp:19
rodsHostAddr_t::hostAddr
char hostAddr[256]
Definition: rodsDef.h:297
l1desc::bytesWritten
rodsLong_t bytesWritten
Definition: objDesc.hpp:45
_l3Write
int _l3Write(rsComm_t *rsComm, int l3descInx, void *buf, int len)
Definition: rsDataObjWrite.cpp:189
irods::file_object_ptr
boost::shared_ptr< file_object > file_object_ptr
Definition: irods_file_object.hpp:145
RuleExecInfo
Definition: irods_re_structs.hpp:18
applyRuleForPostProcForWrite
int applyRuleForPostProcForWrite(rsComm_t *rsComm, bytesBuf_t *dataObjWriteInpBBuf, char *objPath)
Definition: rsDataObjWrite.cpp:26
irods::WRITE_OPERATION
const std::string WRITE_OPERATION("WRITE")
applyRule
int applyRule(char *inAction, msParamArray_t *inMsParamArray, ruleExecInfo_t *rei, int reiSaveFlag)
Definition: irods_re_structs.cpp:65
DataObjInfo::objPath
char objPath[(1024+64)]
Definition: objInfo.h:130
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
MsParamArray
Definition: msParam.h:84
irods::get_loc_for_hier_string
error get_loc_for_hier_string(const std::string &_hier, std::string &_loc)
Definition: irods_resource_backport.cpp:633
SYS_FILE_DESC_OUT_OF_RANGE
@ SYS_FILE_DESC_OUT_OF_RANGE
Definition: rodsErrorTable.h:87
NAME_LEN
#define NAME_LEN
Definition: rodsDef.h:55
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
buf
static char buf[64+50+1]
Definition: rsAuthRequest.cpp:21
DataObjInfo
Definition: objInfo.h:129
rcDataObjWrite
int rcDataObjWrite(rcComm_t *conn, openedDataObjInp_t *dataObjWriteInp, bytesBuf_t *dataObjWriteInpBBuf)
Definition: rcDataObjWrite.cpp:79
rsDataObjWrite
int rsDataObjWrite(rsComm_t *rsComm, openedDataObjInp_t *dataObjWriteInp, bytesBuf_t *dataObjWriteInpBBuf)
Definition: rsDataObjWrite.cpp:68
objMetaOpr.hpp
subStructFileRead.h