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)  

regUtil.cpp
Go to the documentation of this file.
1 
3 #include "rodsPath.h"
4 #include "rodsErrorTable.h"
5 #include "rodsLog.h"
6 #include "regUtil.h"
7 #include "miscUtil.h"
8 #include "checksum.hpp"
9 #include "rcGlobalExtern.h"
10 
11 int
12 regUtil( rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs,
13  rodsPathInp_t *rodsPathInp ) {
14  if ( rodsPathInp == NULL ) {
15  return USER__NULL_INPUT_ERR;
16  }
17 
18  dataObjInp_t dataObjOprInp;
19  initCondForReg( myRodsEnv, myRodsArgs, &dataObjOprInp );
20 
21  int savedStatus = 0;
22  for ( int i = 0; i < rodsPathInp->numSrc; i++ ) {
23  rodsPath_t * destPath = &rodsPathInp->destPath[i]; /* iRODS path */
24  rodsPath_t * srcPath = &rodsPathInp->srcPath[i]; /* file Path */
25 
26  getRodsObjType( conn, destPath );
27 
28  if ( destPath->objState == EXIST_ST &&
29  myRodsArgs->force == False &&
30  myRodsArgs->mountCollection == False &&
31  myRodsArgs->regRepl != True ) {
33  "regUtil: iRODSPath %s already exist", destPath->outPath );
35  }
36 
37  rodsEnv env;
38  int ret = getRodsEnv( &env );
39  if ( ret < 0 ) {
40  rodsLogError( LOG_ERROR, ret, "regUtil: getRodsEnv failed" );
41  return ret;
42  }
43  int status = 0;
44  if ( myRodsArgs->checksum == True ) {
45  addKeyVal( &dataObjOprInp.condInput, REG_CHKSUM_KW, "" );
46  }
47  else if ( myRodsArgs->verifyChecksum == True ) {
48  addKeyVal( &dataObjOprInp.condInput, VERIFY_CHKSUM_KW, "" );
49  }
50 
51  addKeyVal( &dataObjOprInp.condInput, FILE_PATH_KW, srcPath->outPath );
52  rstrcpy( dataObjOprInp.objPath, destPath->outPath, MAX_NAME_LEN );
53 
54  status = rcPhyPathReg( conn, &dataObjOprInp );
55 
56  /* XXXX may need to return a global status */
57  if ( status < 0 &&
60  "regUtil: reg error for %s, status = %d",
61  destPath->outPath, status );
62  savedStatus = status;
63  }
64  else if ( status == CAT_NO_ROWS_FOUND && myRodsArgs->regRepl == True ) {
65  savedStatus = CAT_UNKNOWN_COLLECTION;
66  }
67  }
68  return savedStatus;
69 }
70 
71 int
72 initCondForReg( rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjInp_t *dataObjOprInp ) {
73  if ( dataObjOprInp == NULL ) {
75  "initCondForReg: NULL dataObjOprInp input" );
76  return USER__NULL_INPUT_ERR;
77  }
78 
79  memset( dataObjOprInp, 0, sizeof( dataObjInp_t ) );
80 
81  if ( rodsArgs == NULL ) {
82  return 0;
83  }
84 
85  if ( rodsArgs->dataType == True ) {
86  if ( rodsArgs->dataTypeString == NULL ) {
87  addKeyVal( &dataObjOprInp->condInput, DATA_TYPE_KW, "generic" );
88  }
89  else {
90  addKeyVal( &dataObjOprInp->condInput, DATA_TYPE_KW,
91  rodsArgs->dataTypeString );
92  }
93  }
94  else {
95  addKeyVal( &dataObjOprInp->condInput, DATA_TYPE_KW, "generic" );
96  }
97 
98  if ( rodsArgs->collection == True ) {
99  addKeyVal( &dataObjOprInp->condInput, COLLECTION_KW, "" );
100  }
101 
102  if ( rodsArgs->force == True ) {
103  addKeyVal( &dataObjOprInp->condInput, FORCE_FLAG_KW, "" );
104  }
105 
106  if ( rodsArgs->resource == True ) {
107  if ( rodsArgs->resourceString == NULL ) {
109  "initCondForReg: NULL resourceString error" );
110  return USER__NULL_INPUT_ERR;
111  }
112  else {
113  addKeyVal(
114  &dataObjOprInp->condInput,
116  rodsArgs->resourceString );
117  }
118  }
119  else if ( myRodsEnv != NULL && strlen( myRodsEnv->rodsDefResource ) > 0 ) {
120  addKeyVal( &dataObjOprInp->condInput, DEST_RESC_NAME_KW,
121  myRodsEnv->rodsDefResource );
122  }
123 
124  if ( rodsArgs->rescGroup == True ) {
125  if ( rodsArgs->resource != True ) {
127  "initCondForReg: rescGroup must be input together with -Rresource" );
128  return USER__NULL_INPUT_ERR;
129  }
130  else if ( rodsArgs->rescGroupString == NULL ) {
132  "initCondForReg: NULL rescGroupString error" );
133  return USER__NULL_INPUT_ERR;
134  }
135 
136  }
137  if ( rodsArgs->regRepl == True ) {
138  addKeyVal( &dataObjOprInp->condInput, REG_REPL_KW, "" );
139  }
140 
141  if ( rodsArgs->excludeFile == True ) {
142  if ( rodsArgs->excludeFileString == NULL ) {
143  rodsLog( LOG_ERROR, "initCondForReg: NULL excludeFileString error" );
144  return USER__NULL_INPUT_ERR;
145  }
146  else {
147  addKeyVal( &dataObjOprInp->condInput, EXCLUDE_FILE_KW,
148  rodsArgs->excludeFileString );
149  }
150  }
151 
152  return 0;
153 }
154 
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
DataObjInp::objPath
char objPath[(1024+64)]
Definition: dataObjInpOut.h:66
rcComm_t
Definition: rcConnect.h:95
NULL
#define NULL
Definition: rodsDef.h:70
True
#define True
Definition: parseCommandLine.h:11
rodsArguments_t::excludeFileString
char * excludeFileString
Definition: parseCommandLine.h:133
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
rodsPath.h
getRodsEnv
int getRodsEnv(rodsEnv *myRodsEnv)
Definition: getRodsEnv.cpp:112
rodsArguments_t::rescGroup
int rescGroup
Definition: parseCommandLine.h:42
REG_REPL_KW
#define REG_REPL_KW
Definition: rodsKeyWdDef.h:104
rodsArguments_t
Definition: parseCommandLine.h:14
RodsPathInp
Definition: rodsPath.h:33
rcPhyPathReg
int rcPhyPathReg(rcComm_t *conn, dataObjInp_t *phyPathRegInp)
Definition: rcPhyPathReg.cpp:71
env
Definition: restructs.hpp:226
rodsArguments_t::dataTypeString
char * dataTypeString
Definition: parseCommandLine.h:55
rodsArguments_t::collection
int collection
Definition: parseCommandLine.h:31
checksum.hpp
RodsPath::objState
objStat_t objState
Definition: rodsPath.h:20
rodsArguments_t::resource
int resource
Definition: parseCommandLine.h:86
rodsArguments_t::excludeFile
int excludeFile
Definition: parseCommandLine.h:132
rcGlobalExtern.h
RodsPathInp::srcPath
rodsPath_t * srcPath
Definition: rodsPath.h:35
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
DATA_TYPE_KW
#define DATA_TYPE_KW
Definition: rodsKeyWdDef.h:23
rodsArguments_t::rescGroupString
char * rescGroupString
Definition: parseCommandLine.h:43
regUtil
int regUtil(rcComm_t *conn, rodsEnv *myRodsEnv, rodsArguments_t *myRodsArgs, rodsPathInp_t *rodsPathInp)
Definition: regUtil.cpp:12
REG_CHKSUM_KW
#define REG_CHKSUM_KW
Definition: rodsKeyWdDef.h:15
rodsArguments_t::checksum
int checksum
Definition: parseCommandLine.h:52
DEST_RESC_NAME_KW
#define DEST_RESC_NAME_KW
Definition: rodsKeyWdDef.h:20
RodsPathInp::destPath
rodsPath_t * destPath
Definition: rodsPath.h:36
rodsArguments_t::verifyChecksum
int verifyChecksum
Definition: parseCommandLine.h:53
CAT_UNKNOWN_COLLECTION
@ CAT_UNKNOWN_COLLECTION
Definition: rodsErrorTable.h:429
COLLECTION_KW
#define COLLECTION_KW
Definition: rodsKeyWdDef.h:61
initCondForReg
int initCondForReg(rodsEnv *myRodsEnv, rodsArguments_t *rodsArgs, dataObjInp_t *dataObjOprInp)
Definition: regUtil.cpp:72
regUtil.h
DataObjInp
Definition: dataObjInpOut.h:65
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
rodsLog.h
rodsArguments_t::resourceString
char * resourceString
Definition: parseCommandLine.h:87
rodsArguments_t::force
int force
Definition: parseCommandLine.h:38
rodsEnv::rodsDefResource
char rodsDefResource[64]
Definition: getRodsEnv.h:17
rodsArguments_t::mountCollection
int mountCollection
Definition: parseCommandLine.h:61
RodsPath::outPath
char outPath[(1024+64)]
Definition: rodsPath.h:24
FORCE_FLAG_KW
#define FORCE_FLAG_KW
Definition: rodsKeyWdDef.h:13
rodsArguments_t::regRepl
int regRepl
Definition: parseCommandLine.h:123
CAT_NO_ROWS_FOUND
@ CAT_NO_ROWS_FOUND
Definition: rodsErrorTable.h:423
VERIFY_CHKSUM_KW
#define VERIFY_CHKSUM_KW
Definition: rodsKeyWdDef.h:16
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
RodsPathInp::numSrc
int numSrc
Definition: rodsPath.h:34
CAT_NAME_EXISTS_AS_DATAOBJ
@ CAT_NAME_EXISTS_AS_DATAOBJ
Definition: rodsErrorTable.h:449
EXCLUDE_FILE_KW
#define EXCLUDE_FILE_KW
Definition: rodsKeyWdDef.h:220
EXIST_ST
@ EXIST_ST
Definition: rodsType.h:49
rodsErrorTable.h
False
#define False
Definition: parseCommandLine.h:12
RodsPath
Definition: rodsPath.h:18
miscUtil.h
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
rodsEnv
Definition: getRodsEnv.h:8
FILE_PATH_KW
#define FILE_PATH_KW
Definition: rodsKeyWdDef.h:28
getRodsObjType
int getRodsObjType(rcComm_t *conn, rodsPath_t *rodsPath)
Definition: miscUtil.cpp:200
rodsArguments_t::dataType
int dataType
Definition: parseCommandLine.h:54
USER__NULL_INPUT_ERR
@ USER__NULL_INPUT_ERR
Definition: rodsErrorTable.h:247