00001 /** 00002 * @file icatGeneralMS.c 00003 * 00004 */ 00005 00006 /*** Copyright (c), The Regents of the University of California *** 00007 *** For more information please refer to files in the COPYRIGHT directory ***/ 00008 #include "reGlobalsExtern.h" 00009 #include "icatHighLevelRoutines.h" 00010 #include "objMetaOpr.h" 00011 00012 /** \mainpage iRODS Documentation 00013 00014 This documentation is generated from the iRODS code. 00015 00016 \section overview Overview 00017 - http://www.irods.org 00018 00019 - <a href="globals.html">Full Alphabetical List of Microservices</a> 00020 00021 - <a href="workflow.html">Rule Engine Workflow Microservices</a> 00022 - #msiGoodFailure - Useful when you want to fail but no recovery initiated 00023 - #msiSleep - Sleep 00024 00025 \section msicore Core Microservices 00026 00027 \subsection msiruleengine Rule Engine Microservices 00028 - #msiAdmChangeCoreIRB - Changes the core.irb file from the client 00029 - #msiAdmAppendToTopOfCoreIRB - Prepends another irb file to the core.irb file 00030 - #msiAdmAddAppRuleStruct - Adds application level IRB rules and DVM and FNM mappings to the rule engine 00031 - #msiAdmClearAppRuleStruct - Clears application level IRB rules and DVM and FNM mappings that were loaded into the rule engine 00032 00033 - #msiAdmShowIRB - Displays the currently loaded rules 00034 - #msiAdmShowDVM - Displays the currently loaded data variable mappings 00035 - #msiAdmShowFNM - Displays the currently loaded microservices and action (function) name mappings 00036 00037 - #msiAdmReadRulesFromFileIntoStruct - Reads a rule configuration file into a rule structure 00038 - #msiAdmInsertRulesFromStructIntoDB - Writes a rule structure into the current rule base 00039 - #msiGetRulesFromDBIntoStruct - Populates a rule structure with rules from the given base name 00040 - #msiAdmWriteRulesFromStructIntoFile - Writes to file the rules within a given rule structure 00041 00042 - #msiAdmReadDVMapsFromFileIntoStruct - Reads a DVM configuration file into a DVM structure 00043 - #msiAdmInsertDVMapsFromStructIntoDB - Writes a DVM structure into the current DVM base 00044 - #msiGetDVMapsFromDBIntoStruct - Populates a DVM structure with DVMs from the given base name 00045 - #msiAdmWriteDVMapsFromStructIntoFile - Writes to file the DVMs within a given DVM structure 00046 00047 - #msiAdmReadFNMapsFromFileIntoStruct - Reads a FNM configuration file into a FNM structure 00048 - #msiAdmInsertFNMapsFromStructIntoDB - Writes an FNM structure into the current FNM base 00049 - #msiGetFNMapsFromDBIntoStruct - Populates an FNM structure with FNMs from the given base name 00050 - #msiAdmWriteFNMapsFromStructIntoFile - Writes to file the FNMs within a given FNM structure 00051 00052 - #msiAdmReadMSrvcsFromFileIntoStruct - Reads a microservice configuration file into a microservice structure 00053 - #msiAdmInsertMSrvcsFromStructIntoDB - Writes a microservice structure into the current microservices base 00054 - #msiGetMSrvcsFromDBIntoStruct - Populates a microservice structure with microservices from the given base name 00055 - #msiAdmWriteMSrvcsFromStructIntoFile - Writes to file the microservices within a given microservice structure 00056 00057 \subsection msihelper Helper Microservices 00058 Can be called by client through irule. 00059 - #msiGetStdoutInExecCmdOut - Gets stdout buffer from ExecCmdOut into buffer 00060 - #msiGetStderrInExecCmdOut - Gets stderr buffer from ExecCmdOut into buffer 00061 - #msiWriteRodsLog - Writes a message into the server rodsLog 00062 - #msiAddKeyValToMspStr - Adds a key and value to existing msKeyValStr 00063 - #msiSplitPath - Splits a pathname into parent and child values 00064 - #msiGetSessionVarValue - Gets the value of a session variable in the rei 00065 - #msiExit - Add a user message to the error stack 00066 00067 \subsection msidatabase Database Object (DBO) and DB Resource (DBR) Microservices 00068 Can be called by client through irule. 00069 - #msiDboExec - Execute a database object on a DBR 00070 - #msiDbrCommit - Executes a commit on a DBR 00071 - #msiDbrRollback - Executes a rollback on a DBR 00072 00073 \subsection msilowlevel Data Object Low-level Microservices 00074 Can be called by client through irule. 00075 - #msiDataObjCreate - Create a data object 00076 - #msiDataObjOpen - Open a data object 00077 - #msiDataObjClose - Close an opened data object 00078 - #msiDataObjLseek - Repositions the read/write offset of an open data object 00079 - #msiDataObjRead - Read an opened data object 00080 - #msiDataObjWrite - Write to an opened data object 00081 00082 \subsection msidataobject Data Object Microservices 00083 Can be called by client through irule. 00084 - #msiDataObjUnlink - Delete a data object 00085 - #msiDataObjRepl - Replicate a data object 00086 - #msiDataObjCopy - Copy a data object 00087 - #msiDataObjGet - Get a data object 00088 - #msiDataObjPut - Put a data object 00089 - #msiDataObjChksum - Checksum a data object 00090 - #msiDataObjPhymv - Move a data object from one resource to another 00091 - #msiDataObjRename - Rename a data object 00092 - #msiDataObjTrim - Trim the replicas of a data object 00093 - #msiPhyPathReg - Register a physical file into iRODS 00094 - #msiObjStat - Stat an iRODS object 00095 - #msiDataObjRsync - Syncs a data object from a source to a destination 00096 - #msiCollRsync - Recursively syncs a source collection to a target collection 00097 - #msiGetObjType - Finds if a given value is a data, coll, resc, ... 00098 - #msiCheckPermission - Check if a data object permission is the same as the one given 00099 - #msiCheckOwner - Check if the user is the owner of the data object 00100 - #msiSetReplComment - Sets the data_comments attribute of a data object 00101 00102 \subsection msicollection Collection Microservices 00103 - #msiCollCreate - Create a collection 00104 - #msiCollRepl - Replicate all files in a collection 00105 - #msiRmColl - Delete a collection 00106 - #msiAutoReplicateService - Checks and repairs up to n replicas 00107 - #msiDataObjAutoMove - Used to automatically move the newly created file into a destination collection 00108 - #msiTarFileExtract - Extracts a tar object file into a target collection 00109 - #msiTarFileCreate - Creates a tar object file from a target collection 00110 - #msiPhyBundleColl - Bundles a collection into a number of tar files, similar to the iphybun command 00111 00112 \subsection msiproxy Proxy Command Microservices 00113 - #msiExecCmd - Remotely execute a command 00114 00115 \subsection msiicat iCAT Microservices 00116 iCAT System Services 00117 - #msiVacuum - Postgres vacuum - done periodically 00118 - #msiQuota - Calculates storage usage and sets quota values 00119 - #msiCommit - Commits the database transaction 00120 - #msiRollback - Rollback the current database transaction 00121 - #msiSetACL - Changes the ACL for a given pathname, either a collection or a data object 00122 - #msiCreateUser - Creates a new user 00123 - #msiDeleteUser - Deletes a user 00124 - #msiAddUserToGroup - Adds a user to a group 00125 - #msiCreateCollByAdmin - Creates a collection by administrator 00126 - #msiDeleteCollByAdmin - Deletes a collection by administrator 00127 - #msiRenameLocalZone - Renames the local zone by updating various tables 00128 - #msiRenameCollection - Renames a collection; used via a rule with the above #msiRenameLocalZone 00129 - #msiExecStrCondQuery - Creates an iCAT query, given a condition string, and executes it and returns the values 00130 - #msiExecStrCondQueryWithOptions - Like #msiExecStrCondQuery, with extra options 00131 - #msiExecGenQuery - Executes a given general query structure and returns results 00132 - #msiMakeQuery - Creates a psuedo-SQL query, given a select list and a condition list 00133 - #msiGetMoreRows - Continues an unfinished query and #msiExecStrCondQuery and returns results 00134 - #msiCloseGenQuery - Closes an unfinished query. Based on #msiGetMoreRows. 00135 - #msiMakeGenQuery - A combination of #msiMakeQuery and #msiExecGenQuery and returns the results of the execution 00136 - #msiGetContInxFromGenQueryOut - Gets continue index value generated by #msiExecGenQuery 00137 - #msiAddSelectFieldToGenQuery - Sets a select field in a genQueryInp_t 00138 - #msiPrintGenQueryInp - Prints the given GenQueryInp_MS_T to the given target buffer 00139 - #msiAddConditionToGenQuery - Adds a condition to a genQueryInp_t 00140 - #msiPrintGenQueryOutToBuffer - Writes the contents of a GenQueryOut_MS_T into a BUF_LEN_MS_T 00141 - #msiDeleteUnusedAVUs - Deletes unused AVUs from the iCAT 00142 00143 \subsection msirda Rule-oriented Database Access Microservices 00144 - #msiRdaToStdout - Calls new RDA functions to interface to an arbitrary database returning results in stdout 00145 - #msiRdaToDataObj - As above but stores results in an iRODS DataObject 00146 - #msiRdaNoResults - As above, performs a SQL operation but without resulting output 00147 - #msiRdaCommit - Commit changes to the database 00148 - #msiRdaRollback - Rollback (don't commit) changes to the database 00149 00150 \subsection msixmsg XMessaging System Microservices 00151 - #msiXmsgServerConnect - Connects to the XMessage Server as designate by iRODS Environment file/variable 00152 - #msiXmsgCreateStream - Creates a new Message Stream 00153 - #msiCreateXmsgInp - Creates an Xmsg packet, given all information values 00154 - #msiSendXmsg - Sends an Xmsg packet 00155 - #msiRcvXmsg - Receives an Xmsg packet 00156 - #msiXmsgServerDisConnect - Disconnects from the XMessage Server 00157 - #readXMsg - Reads a message packet from an XMsgStream 00158 - #writeXMsg - Writes a given string into an XMsgStream 00159 00160 \subsection msistring String Manipulation Microservices 00161 - #msiStrlen - Returns the length of a given string 00162 - #msiStrchop - Removes the last character of a given string 00163 - #msiSubstr - Returns a substring of the given string 00164 00165 \subsection msiemail Email Microservices 00166 - #msiSendMail - Sends email 00167 - #msiSendStdoutAsEmail - Sends rei's stdout as email 00168 00169 \subsection msikv Key-Value (Attr-Value) Microservices 00170 - #writeKeyValPairs - Writes key-value pairs to stdout or stderr and with given separator 00171 - #msiPrintKeyValPair - Prints key-value pairs to rei's stdout separated by = 00172 - #msiGetValByKey - Extracts the corresponding value, given a key and a keyValPair struct 00173 - #msiString2KeyValPair - Converts a \%-separated key=value pair strings into keyValPair structure 00174 - #msiStrArray2String - Converts an array of strings to a string separated by \%-signs 00175 - #msiAssociateKeyValuePairsToObj - Ingests object metadata into iCAT from a AVU structure 00176 - #msiRemoveKeyValuePairsFromObj - Removes object metadata from iCAT using a AVU structure 00177 - #msiSetKeyValuePairsToObj - Ingests or overwrites object metadata into iCAT from a AVU structure 00178 - #msiAddKeyVal - Adds a new key and value to a keyValPair_t 00179 00180 \subsection msiotheruser Other User Microservices 00181 - #msiExtractNaraMetadata - Extracts NARA style metadata from a local configuration file 00182 - #msiApplyDCMetadataTemplate - Adds Dublin Core Metadata fields to an object or collection 00183 - #msiRegisterData - Registers a new data object 00184 - #writeBytesBuf - Writes the buffer in an inOutStruct to stdout or stderr 00185 - #msiStrToBytesBuf - Converts a string to a bytesBuf_t 00186 - #msiFreeBuffer - Frees a buffer in an inOutStruct, or stdout or stderr 00187 - #writePosInt - Writes an integer to stdout or stderr 00188 - #msiGetDiffTime - Returns the difference between two system timestamps given in unix format (stored in string) 00189 - #msiGetSystemTime - Returns the local system time of server 00190 - #msiHumanToSystemTime - Converts a human readable date to a system timestamp 00191 - #msiGetIcatTime - Returns the system time for the iCAT server 00192 - #msiGetTaggedValueFromString - Gets the value from a file in tagged-format (psuedo-XML), given a tag-name 00193 - #msiExtractTemplateMDFromBuf - Extracts AVU info using template 00194 - #msiReadMDTemplateIntoTagStruct - Loads template file contents into tag structure 00195 00196 \subsection msisystem System Microservices 00197 Can only be called by the server process 00198 - #msiSetDefaultResc - Sets the default resource 00199 - #msiSetNoDirectRescInp - Sets a list of resources that cannot be used by a normal user directly 00200 - #msiSetRescSortScheme - Sets the scheme for selecting the best resource to use 00201 - #msiSetMultiReplPerResc - Sets the number of copies per resource to unlimited 00202 - #msiSetDataObjPreferredResc - Specifies the preferred copy to use, if the data has multiple copies 00203 - #msiSetDataObjAvoidResc - Specifies the copy to avoid 00204 - #msiSetGraftPathScheme - Sets the scheme for composing the physical path in the vault to GRAFT_PATH 00205 - #msiSetRandomScheme - Sets the the scheme for composing the physical path in the vault to RANDOM 00206 - #msiSetResource - sets the resource from default 00207 - #msiSortDataObj - Sort the replica randomly when choosing which copy to use 00208 - #msiSetNumThreads - specify the parameters for determining the number of threads to use for data transfer 00209 - #msiSysChksumDataObj - Checksums a data object 00210 - #msiSysReplDataObj - Replicates a data object 00211 - #msiSysMetaModify - Modifies system metadata 00212 - #msiStageDataObj - Stages the data object to the specified resource before operation 00213 - #msiNoChkFilePathPerm - Does not check file path permission when registering 00214 - #msiNoTrashCan - Sets the policy to no trash can 00215 - #msiSetPublicUserOpr - Sets a list of operations that can be performed by the user "public" 00216 - #msiCheckHostAccessControl - Sets the access control policy 00217 - #msiServerMonPerf - Monitors the servers' activity and performance 00218 - #msiFlushMonStat - Flushes the servers' monitoring statistics 00219 - #msiDigestMonStat - Calculates and stores a digest performance value for each connected resource 00220 - #msiDeleteDisallowed - Sets the policy for determining certain data cannot be deleted 00221 - #msiSetDataTypeFromExt - Gets the data type based on file name extension 00222 - #msiSetReServerNumProc - Sets the number of processes for the rule engine server 00223 - #msiSetRescQuotaPolicy - Sets the resource quota to on or off 00224 - #msiListEnabledMS - Returns the list of compiled microservices on the local iRODS server 00225 - #msiSetBulkPutPostProcPolicy - Sets whether acPostProcForPut should be run after a bulk put 00226 00227 \section msiadmin Admin Microservices 00228 Can only be called by an administrator 00229 - #msiServerBackup - Copies iRODS server files to the local resource 00230 - #msiSetQuota - Sets disk usage quota for a user or group 00231 00232 \section msimodules Module Microservices 00233 00234 \subsection msiera ERA - Electronic Records Archives Program 00235 - #msiRecursiveCollCopy - Recursively copies a collection and its contents including metadata 00236 - #msiGetDataObjACL - Gets ACL (Access Control List) for a data object in | separated format 00237 - #msiGetCollectionACL- Gets ACL (Access Control List) for a collection in | separated format 00238 - #msiGetDataObjAVUs - Retrieves metadata AVU triplets for a data object and returns them as an XML file 00239 - #msiGetDataObjPSmeta - Retrieves metadata AVU triplets for a data object in | separated format 00240 - #msiGetCollectionPSmeta- Retrieves metadata AVU triplets for a collection in | separated format 00241 - #msiGetDataObjAIP - Gets the Archival Information Package of a data object in XML format 00242 - #msiLoadMetadataFromDataObj - Parses an iRODS object for new metadata AVUs from | separated format 00243 - #msiExportRecursiveCollMeta - Exports metadata AVU triplets for a collection and its contents in | separated format 00244 - #msiCopyAVUMetadata - Copies metadata triplets from an iRODS object to another 00245 - #msiStripAVUs - Strips a data object of its metadata AVU triplets 00246 - #msiGetUserInfo - Gets Information about user 00247 - #msiGetUserACL - Gets User ACL for all objects and collections 00248 - #msiCreateUserAccountsFromDataObj - Creates new user from information in an iRODS data object 00249 - #msiLoadUserModsFromDataObj - Modifies user information from information in an iRODS data object 00250 - #msiDeleteUsersFromDataObj - Deletes user from information in an iRODS data object 00251 - #msiLoadACLFromDataObj - Loads ACL from information in an iRODS data object 00252 - #msiGetAuditTrailInfoByUserID - Retrieves Audit Trail information for a user ID 00253 - #msiGetAuditTrailInfoByObjectID - Retrieves Audit Trail information for an object ID 00254 - #msiGetAuditTrailInfoByActionID - Retrieves Audit Trail information for a given action ID 00255 - #msiGetAuditTrailInfoByKeywords - Retrieves Audit Trail information by keywords in the comment field 00256 - #msiGetAuditTrailInfoByTimeStamp - Retrieves Audit Trail information by timestamp period 00257 - #msiSetDataType - Sets data type for an object 00258 - #msiGuessDataType - Guesses the data type of an object based on its file extension 00259 - #msiMergeDataCopies - Custom microservice for NARA consolidation rule 00260 - #msiFlagDataObjwithAVU - Flags a data object with an AVU 00261 - #msiGetCollectionContentsReport - Returns the number of objects in a collection by data type 00262 - #msiGetCollectionSize - Returns the object count and total disk usage of a collection 00263 - #msiGetObjectPath - Returns the path of an iRODS object 00264 - #msiCollectionSpider - Applies a microservice sequence to all data objects in a collection, recursively 00265 - #msiIsColl - Checks if an iRODS path is a collection. For use in workflows 00266 - #msiIsData - Checks if an iRODS path is a data object (an iRODS file). For use in workflows 00267 - #msiStructFileBundle - Bundles a collection for export 00268 - #msiFlagInfectedObjs - Parses output from clamscan and flags infected objects 00269 - #msiStoreVersionWithTS - Creates a timestamped backup version of an iRODS data object 00270 00271 \subsection msiurl URL 00272 - #msiFtpGet - Gets a remote file using FTP and writes it to an iRODS object 00273 - #msiTwitterPost - Posts a message to twitter.com 00274 00275 \subsection msixml XML 00276 - #msiLoadMetadataFromXml - Loads AVU metadata from an XML file of AVU triplets 00277 - #msiXmlDocSchemaValidate - Validates an XML file against an XSD schema, both iRODS objects 00278 - #msiXsltApply - Returns the xml object after applying the xslt transformation, given an xml object and an xslt object 00279 00280 \subsection msimsodrivers Microservice Object (MSO) Drivers 00281 - #msiobjget_dbo - Gets a DBO object 00282 - #msiobjput_dbo - Puts a DBO object 00283 - #msiobjget_http - Gets an HTTP/HTTPS/FTP object 00284 - #msiobjput_http - Puts an HTTP/HTTPS/FTP object 00285 - #msiobjget_irods - Gets an iRODS object 00286 - #msiobjput_irods - Puts an iRODS object 00287 - #msiobjget_slink - Gets an SLINK object 00288 - #msiobjput_slink - Puts an SLINK object 00289 - #msiobjget_srb - Gets an SRB object 00290 - #msiobjput_srb - Puts an SRB object 00291 - #msiobjget_test - Gets a test object 00292 - #msiobjput_test - Puts a test object 00293 - #msiobjget_z3950 - Gets a Z39.50 object 00294 - #msiobjput_z3950 - Puts a Z39.50 object 00295 00296 \subsection msiimage Image 00297 - #msiImageConvert - Reads a source image file and write it out as a new image file in a chosen format 00298 - #msiImageGetProperties - Gets the properties of an image file 00299 - #msiImageScale - Reads a source image file, scale it up or down in size, and write it out as a new image file in a chosen format 00300 00301 \subsection msihdf HDF 00302 - #msiH5File_open - Opens an HDF file 00303 - #msiH5File_close - Closes an HDF file 00304 - #msiH5Dataset_read - Reads data from an HDF file 00305 - #msiH5Dataset_read_attribute - Reads data attribute from an HDF file 00306 - #msiH5Group_read_attribute - Reads attributes of a group in an HDF file 00307 00308 \subsection msiproperties Properties 00309 - #msiPropertiesNew - Creates a new empty property list 00310 - #msiPropertiesClear - Clears a property list 00311 - #msiPropertiesClone - Clones a property list, returning a new property list 00312 - #msiPropertiesAdd - Adds a property and value to a property list. If the property is already in the list, its value is changed. Otherwise the property is added. 00313 - #msiPropertiesRemove - Removes a property from the list 00314 - #msiPropertiesGet - Gets the value of a property in a property list. The property list is left unmodified. 00315 - #msiPropertiesSet - Sets the value of a property in a property list. If the property is already in the list, its value is changed. Otherwise the property is added. 00316 - #msiPropertiesExists - Returns true (integer 1) if the keyword has a property value in the property list, and false (integer 0) otherwise. The property list is unmodified. 00317 - #msiPropertiesToString - Converts a property list into a string buffer. The property list is left unmodified. 00318 - #msiPropertiesFromString - Parses a string into a new property list. The existing property list, if any, is deleted. 00319 00320 \subsection msiwebservices Web Services 00321 - #msiGetQuote - Returns stock quotation (delayed by web service) using web service provided by http://www.webserviceX.NET 00322 - #msiIp2location - Returns host name and other details given an ipaddress using web service provided by http://ws.fraudlabs.com/ 00323 - #msiConvertCurrency - Returns conversion rate for currencies from one country to another using web service provided by http://www.webserviceX.NET/ 00324 - #msiObjByName - Returns position and type of an astronomical object given a name from the NASA/IPAC Extragalactic Database (NED) using web service at http://voservices.net/NED/ws_v2_0/NED.asmx 00325 - #msiSdssImgCutout_GetJpeg - Returns an image buffer given a position and cutout from the SDSS Image Cut Out service using web service provided by http://skyserver.sdss.org 00326 00327 \subsection msiguinot Guinot 00328 - #msiGetFormattedSystemTime - Returns the local system time 00329 00330 \subsection msiz3950 Z3950 00331 - #msiz3950Submit - Retrieves a record from a Z39.50 server 00332 00333 **/ 00334 00335 00336 00337 00338 00339 /** 00340 * \fn msiGetIcatTime (msParam_t *timeOutParam, msParam_t *typeInParam, ruleExecInfo_t *rei) 00341 * 00342 * \brief This function returns the system time for the iCAT server 00343 * 00344 * \module core 00345 * 00346 * \since pre-2.1 00347 * 00348 * \author DICE 00349 * \date 2008 00350 * 00351 * \usage See clients/icommands/test/rules3.0/ 00352 * 00353 * \param[out] timeOutParam - a msParam of type STR_MS_T 00354 * \param[in] typeInParam - a msParam of type STR_MS_T 00355 * \li "icat" or "unix" will return seconds since epoch 00356 * \li otherwise, human friendly 00357 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00358 * handled by the rule engine. The user does not include rei as a 00359 * parameter in the rule invocation. 00360 * 00361 * \DolVarDependence none 00362 * \DolVarModified none 00363 * \iCatAttrDependence none 00364 * \iCatAttrModified none 00365 * \sideeffect none 00366 * 00367 * \return integer 00368 * \retval 0 on success 00369 * \pre none 00370 * \post none 00371 * \sa none 00372 **/ 00373 int 00374 msiGetIcatTime(msParam_t* timeOutParam, msParam_t* typeInParam, ruleExecInfo_t *rei) 00375 { 00376 char *type; 00377 char tStr0[TIME_LEN],tStr[TIME_LEN]; 00378 int i; 00379 00380 type = (char*)typeInParam->inOutStruct; 00381 00382 if (!strcmp(type,"icat") || !strcmp(type,"unix")) { 00383 getNowStr(tStr); 00384 } 00385 else { /* !strcmp(type,"human") */ 00386 getNowStr(tStr0); 00387 getLocalTimeFromRodsTime(tStr0,tStr); 00388 } 00389 i = fillStrInMsParam (timeOutParam,tStr); 00390 return(i); 00391 } 00392 00393 /** 00394 * \fn msiVacuum (ruleExecInfo_t *rei) 00395 * 00396 * \brief Postgres vacuum, done periodically to optimize indices and performance 00397 * 00398 * \module core 00399 * 00400 * \since pre-2.1 00401 * 00402 * \author Wayne Schroeder 00403 * \date December 2006 00404 * 00405 * \note The effect of this is that iCAT database gets vacuumed. 00406 * This microservice works with PostgreSQL only. 00407 * 00408 * \note This is run via an 'iadmin' command (iadmin pv) via a rule 00409 * in the core.irb. It is not designed for general use in other 00410 * situations (i.e. don't call this from other rules). 00411 * 00412 * \usage See clients/icommands/test/rules3.0/ 00413 * 00414 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00415 * handled by the rule engine. The user does not include rei as a 00416 * parameter in the rule invocation. 00417 * 00418 * \DolVarDependence none 00419 * \DolVarModified none 00420 * \iCatAttrDependence none 00421 * \iCatAttrModified none 00422 * \sideeffect none 00423 * 00424 * \return integer 00425 * \retval 0 on success 00426 * \pre none 00427 * \post none 00428 * \sa none 00429 **/ 00430 int 00431 msiVacuum(ruleExecInfo_t *rei) 00432 { 00433 int i; 00434 rodsLog(LOG_NOTICE, "msiVacuum called\n"); 00435 00436 i = doForkExec("/usr/bin/perl", "./vacuumdb.pl"); 00437 00438 if (i) { 00439 rodsLog(LOG_ERROR, "msiVacuum doForkExec failure\n"); 00440 } 00441 00442 rodsLog(LOG_NOTICE, "msiVacuum done\n"); 00443 00444 return(0); 00445 } 00446 00447 00448 /** 00449 * \fn msiQuota (ruleExecInfo_t *rei) 00450 * 00451 * \brief Calculates storage usage and sets quota values (over/under/how-much). 00452 * 00453 * \module core 00454 * 00455 * \since pre-2.3 00456 * 00457 * \author Wayne Schroeder 00458 * \date January 2010 00459 * 00460 * \note Causes the iCAT quota tables to be updated. 00461 * 00462 * \note This is run via an admin rule 00463 * 00464 * \usage See clients/icommands/test/rules3.0/ and https://www.irods.org/index.php/Quotas 00465 * 00466 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00467 * handled by the rule engine. The user does not include rei as a 00468 * parameter in the rule invocation. 00469 * 00470 * \DolVarDependence rei->rsComm->clientUser.authFlag (must be admin) 00471 * \DolVarModified none 00472 * \iCatAttrDependence Utilizes ICAT data-object information 00473 * \iCatAttrModified Updates the quota tables 00474 * \sideeffect none 00475 * \return integer 00476 * \retval 0 on success 00477 * \pre none 00478 * \post none 00479 * \sa none 00480 **/ 00481 int 00482 msiQuota(ruleExecInfo_t *rei) 00483 { 00484 int status; 00485 00486 #ifdef RODS_CAT 00487 rodsLog(LOG_NOTICE, "msiQuota/chlCalcUsageAndQuota called\n"); 00488 status = chlCalcUsageAndQuota(rei->rsComm); 00489 #else 00490 status = SYS_NO_RCAT_SERVER_ERR; 00491 #endif 00492 return(status); 00493 } 00494 00495 /** 00496 *\fn msiSetResource (msParam_t *xrescName, ruleExecInfo_t *rei) 00497 * 00498 * \brief This microservice sets the resource as part of a workflow execution. 00499 * 00500 * \module core 00501 * 00502 * \since pre-2.1 00503 * 00504 * \author DICE 00505 * \date 2008 00506 * 00507 * \note This microservice sets the resource as part of a workflow execution. 00508 * 00509 * \usage See clients/icommands/test/rules3.0/ 00510 * 00511 * \param[in] xrescName - is a msParam of type STR_MS_T 00512 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00513 * handled by the rule engine. The user does not include rei as a 00514 * parameter in the rule invocation. 00515 * 00516 * \DolVarDependence none 00517 * \DolVarModified none 00518 * \iCatAttrDependence none 00519 * \iCatAttrModified none 00520 * \sideeffect none 00521 * 00522 * \return integer 00523 * \retval 0 on success 00524 * \pre none 00525 * \post none 00526 * \sa none 00527 **/ 00528 int msiSetResource(msParam_t* xrescName, ruleExecInfo_t *rei) 00529 { 00530 char *rescName; 00531 00532 rescName = (char *) xrescName->inOutStruct; 00533 if (reTestFlag > 0 ) { 00534 if (reTestFlag == LOG_TEST_1) 00535 rodsLog (LOG_NOTICE," Calling msiSetResource\n"); 00536 } 00537 00538 strcpy(rei->doi->rescName,rescName); 00539 return(0); 00540 } 00541 00542 00543 /** 00544 * \fn msiCheckOwner (ruleExecInfo_t *rei) 00545 * 00546 * \brief This microservice checks whether the user is the owner 00547 * 00548 * \module core 00549 * 00550 * \since pre-2.1 00551 * 00552 * \author DICE 00553 * \date 2008 00554 * 00555 * \usage See clients/icommands/test/rules3.0/ 00556 * 00557 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00558 * handled by the rule engine. The user does not include rei as a 00559 * parameter in the rule invocation. 00560 * 00561 * \DolVarDependence none 00562 * \DolVarModified none 00563 * \iCatAttrDependence none 00564 * \iCatAttrModified none 00565 * \sideeffect none 00566 * 00567 * \return integer 00568 * \retval 0 on success 00569 * \pre none 00570 * \post none 00571 * \sa none 00572 **/ 00573 int msiCheckOwner(ruleExecInfo_t *rei) 00574 { 00575 if (reTestFlag > 0 ) { 00576 if (reTestFlag == LOG_TEST_1) 00577 rodsLog (LOG_NOTICE," Calling msiCheckOwner\n"); 00578 } 00579 00580 if (!strcmp(rei->doi->dataOwnerName,rei->uoic->userName) && 00581 !strcmp(rei->doi->dataOwnerZone,rei->uoic->rodsZone)) 00582 return(0); 00583 else 00584 return(ACTION_FAILED_ERR); 00585 00586 } 00587 00588 /** 00589 * \fn msiCheckPermission (msParam_t *xperm, ruleExecInfo_t *rei) 00590 * 00591 * \brief This microservice checks the authorization permission (whether or not permission is granted) 00592 * 00593 * \module core 00594 * 00595 * \since pre-2.1 00596 * 00597 * \author DICE 00598 * \date 2008 00599 * 00600 * \usage See clients/icommands/test/rules3.0/ 00601 * 00602 * \param[in] xperm - a msParam of type STR_MS_T 00603 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00604 * handled by the rule engine. The user does not include rei as a 00605 * parameter in the rule invocation. 00606 * 00607 * \DolVarDependence none 00608 * \DolVarModified none 00609 * \iCatAttrDependence none 00610 * \iCatAttrModified none 00611 * \sideeffect none 00612 * 00613 * \return integer 00614 * \retval 0 on success 00615 * \pre none 00616 * \post none 00617 * \sa none 00618 **/ 00619 int msiCheckPermission(msParam_t* xperm, ruleExecInfo_t *rei) 00620 { 00621 char *perm; 00622 00623 perm = (char *) xperm->inOutStruct; 00624 if (reTestFlag > 0 ) { 00625 if (reTestFlag == LOG_TEST_1) 00626 rodsLog (LOG_NOTICE," Calling msiCheckPermission\n"); 00627 } 00628 if (strstr(rei->doi->dataAccess,perm) != NULL) 00629 return(0); 00630 else 00631 return(ACTION_FAILED_ERR); 00632 00633 } 00634 00635 00636 /** 00637 * \fn msiCheckAccess(msParam_t *inObjName, msParam_t * inOperation, msParam_t * outResult, ruleExecInfo_t *rei) 00638 * 00639 * \brief This microservice checks the access permission to perform a given operation 00640 * 00641 * \module core 00642 * 00643 * \since 3.0 00644 * 00645 * \author Arcot Rajasekar 00646 * \date July 2011 00647 * 00648 * \usage See clients/icommands/test/rules3.0/ 00649 * 00650 * \param[in] inObjName - name of Object. A param of type STR_MS_T 00651 * \param[in] inOperation - type of Operation that will be performed. A param of type STR_MS_T. 00652 * \param[out] outResult - result of the operation. 0 for failure and 1 for success. a param of type INT_MS_T. 00653 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00654 * handled by the rule engine. The user does not include rei as a 00655 * parameter in the rule invocation. 00656 * 00657 * \DolVarDependence none 00658 * \DolVarModified none 00659 * \iCatAttrDependence none 00660 * \iCatAttrModified none 00661 * \sideeffect none 00662 * 00663 * \return integer 00664 * \retval 0 on success 00665 * \pre none 00666 * \post none 00667 * \sa none 00668 **/ 00669 int msiCheckAccess(msParam_t *inObjName, msParam_t * inOperation, 00670 msParam_t * outResult, ruleExecInfo_t *rei) 00671 { 00672 char *objName, *oper; 00673 char objType[MAX_NAME_LEN]; 00674 int i; 00675 char *user; 00676 char *zone; 00677 00678 RE_TEST_MACRO (" Calling msiCheckAccess"); 00679 00680 if (inObjName == NULL || inObjName->inOutStruct == NULL || 00681 inObjName->type == NULL || strcmp(inObjName->type, STR_MS_T) != 0 ) 00682 return (USER_PARAM_TYPE_ERR); 00683 00684 if (inOperation == NULL || inOperation->inOutStruct == NULL || 00685 inOperation->type == NULL || strcmp(inOperation->type, STR_MS_T) != 0 ) 00686 return (USER_PARAM_TYPE_ERR); 00687 00688 if (rei == NULL || rei->rsComm == NULL) 00689 return (SYS_INTERNAL_NULL_INPUT_ERR); 00690 00691 if (strlen(rei->rsComm->clientUser.userName) == 0 || 00692 strlen(rei->rsComm->clientUser.rodsZone) == 0) 00693 return (SYS_INTERNAL_NULL_INPUT_ERR); 00694 00695 oper = (char *) inOperation->inOutStruct; 00696 objName = (char *) inObjName->inOutStruct; 00697 user = rei->rsComm->clientUser.userName; 00698 zone = rei->rsComm->clientUser.rodsZone; 00699 00700 i = getObjType(rei->rsComm, objName, objType); 00701 if (i < 0) 00702 return(i); 00703 00704 i = checkPermissionByObjType(rei->rsComm, objName, objType, user, zone, oper); 00705 if (i < 0) 00706 return(i); 00707 fillIntInMsParam (outResult, i); 00708 00709 return(0); 00710 00711 } 00712 00713 00714 /** 00715 * \fn msiCommit (ruleExecInfo_t *rei) 00716 * 00717 * \brief This microservice commits pending database transactions, 00718 * registering the new state information into the iCAT. 00719 * 00720 * \module core 00721 * 00722 * \since pre-2.1 00723 * 00724 * \author Wayne Schroeder 00725 * \date June 2009 00726 * 00727 * \note This is used to commit changes (in any) into the iCAT 00728 * database as part of a rule and microservice chain. See core.irb 00729 * for examples. In other cases, iCAT updates and inserts are 00730 * automatically committed into the iCAT Database as part of the 00731 * normal operations (in the 'C' code). 00732 * 00733 * \usage See clients/icommands/test/rules3.0/ 00734 * 00735 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00736 * handled by the rule engine. The user does not include rei as a 00737 * parameter in the rule invocation. 00738 * 00739 * \DolVarDependence none 00740 * \DolVarModified none 00741 * \iCatAttrDependence commits pending updates (if any) 00742 * \iCatAttrModified pending updates (if any) are committed into the iCAT db 00743 * \sideeffect none 00744 * 00745 * \return integer 00746 * \retval (status) 00747 * \pre none 00748 * \post none 00749 * \sa none 00750 **/ 00751 int 00752 msiCommit(ruleExecInfo_t *rei) { 00753 int status; 00754 00755 /**** This is Just a Test Stub ****/ 00756 if (reTestFlag > 0 ) { 00757 if (reTestFlag == LOG_TEST_1) { 00758 rodsLog (LOG_NOTICE," Calling msiCommit\n"); 00759 } 00760 if (reLoopBackFlag > 0) 00761 return(0); 00762 } 00763 /**** This is Just a Test Stub ****/ 00764 #ifdef RODS_CAT 00765 status = chlCommit(rei->rsComm); 00766 #else 00767 status = SYS_NO_RCAT_SERVER_ERR; 00768 #endif 00769 return(status); 00770 } 00771 00772 /** 00773 * \fn msiRollback (ruleExecInfo_t *rei) 00774 * 00775 * \brief This function deletes user and collection information from the iCAT by rolling back the database transaction 00776 * 00777 * \module core 00778 * 00779 * \since pre-2.1 00780 * 00781 * \author Wayne Schroeder 00782 * \date June 2009 00783 * 00784 * \note This is used to not-commit changes into the iCAT database as 00785 * part of a rule and microservice chain. See core.irb for examples. 00786 * In other cases, iCAT updates and inserts are automatically 00787 * rolled-back as part of the normal operations (in the 'C' code). 00788 * 00789 * \usage See clients/icommands/test/rules3.0/ 00790 * 00791 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00792 * handled by the rule engine. The user does not include rei as a 00793 * parameter in the rule invocation. 00794 * 00795 * \DolVarDependence none 00796 * \DolVarModified none 00797 * \iCatAttrDependence pending updates (if any) are canceled 00798 * \iCatAttrModified pending updates (if any) are canceled 00799 * \sideeffect none 00800 * 00801 * \return integer 00802 * \retval 0 on success 00803 * \pre none 00804 * \post none 00805 * \sa none 00806 **/ 00807 int 00808 msiRollback(ruleExecInfo_t *rei) 00809 { 00810 int status; 00811 /**** This is Just a Test Stub ****/ 00812 if (reTestFlag > 0 ) { 00813 if (reTestFlag == LOG_TEST_1) { 00814 rodsLog (LOG_NOTICE," Calling msiRollback\n"); 00815 } 00816 if (reLoopBackFlag > 0) 00817 return(0); 00818 } 00819 /**** This is Just a Test Stub ****/ 00820 00821 00822 #ifdef RODS_CAT 00823 status = chlRollback(rei->rsComm); 00824 #else 00825 status = SYS_NO_RCAT_SERVER_ERR; 00826 #endif 00827 return(status); 00828 } 00829 00830 /** 00831 * \fn msiSetACL (msParam_t *recursiveFlag, msParam_t *accessLevel, msParam_t *userName, msParam_t *pathName, ruleExecInfo_t *rei) 00832 * 00833 * \brief This microservice changes the ACL for a given pathname, 00834 * either a collection or a data object. 00835 * 00836 * \module core 00837 * 00838 * \since 2.3 00839 * 00840 * \author Jean-Yves Nief 00841 * \date 2010-02-11 00842 * 00843 * \note This microservice modifies the access rights on a given iRODS object or 00844 * collection. For the collections, the modification can be recursive and the 00845 * inheritence bit can be changed as well. 00846 * For admin mode, add MOD_ADMIN_MODE_PREFIX to the access level string, 00847 * e.g: msiSetACL("default", "admin:read", "rods", *path) 00848 * 00849 * \usage See clients/icommands/test/rules3.0/ 00850 * 00851 * \param[in] recursiveFlag - a STR_MS_T, either "default" or "recursive". "recursive" 00852 * is only relevant if set with accessLevel set to "inherit". 00853 * \param[in] accessLevel - a STR_MS_T containing one of the following: 00854 * \li read 00855 * \li write 00856 * \li own 00857 * \li inherit 00858 * \li null 00859 * \param[in] userName - a STR_MS_T, the user name or group name who will have ACL changed. 00860 * \param[in] pathName - a STR_MS_T, the collection or data object that will have its ACL changed. 00861 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00862 * handled by the rule engine. The user does not include rei as a 00863 * parameter in the rule invocation. 00864 * 00865 * \DolVarDependence $userName and/or $objPath and/or $collName 00866 * \DolVarModified none 00867 * \iCatAttrDependence none 00868 * \iCatAttrModified none 00869 * \sideeffect none 00870 * 00871 * \return integer 00872 * \retval 0 on success 00873 * \pre N/A 00874 * \post N/A 00875 * \sa N/A 00876 **/ 00877 int msiSetACL (msParam_t *recursiveFlag, msParam_t *accessLevel, msParam_t *userName, 00878 msParam_t *pathName, ruleExecInfo_t *rei) { 00879 char *acl, *path, *recursiveFlg, *user, uname[NAME_LEN], *zone; 00880 int recFlg, rc; 00881 modAccessControlInp_t modAccessControlInp; 00882 rsComm_t *rsComm = 0; // JMC cppcheck - uninit var 00883 00884 RE_TEST_MACRO (" Calling msiSetACL") 00885 /* the above line is needed for loop back testing using irule -i option */ 00886 00887 if ( recursiveFlag == NULL || accessLevel == NULL || userName == NULL || 00888 pathName == NULL ) { 00889 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status, 00890 "msiSetACL: one of the input parameter is NULL"); 00891 return (SYS_INTERNAL_NULL_INPUT_ERR); 00892 } 00893 00894 recFlg = 0; /* non recursive mode */ 00895 if ( strcmp (recursiveFlag->type, STR_MS_T) == 0 ) { 00896 recursiveFlg = (char *) recursiveFlag->inOutStruct; 00897 if ( strcmp(recursiveFlg,"recursive") == 0 ) { 00898 /* recursive mode */ 00899 recFlg = 1; 00900 } 00901 } 00902 else { 00903 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status, 00904 "msiSetACL: Unsupported input recursiveFlag type %i", 00905 recursiveFlag->type); 00906 return (USER_PARAM_TYPE_ERR); 00907 } 00908 00909 if ( strcmp (accessLevel->type, STR_MS_T) == 0 ) { 00910 acl = (char *) accessLevel->inOutStruct; 00911 } 00912 else { 00913 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status, 00914 "msiSetACL: Unsupported input accessLevel type %s", 00915 accessLevel->type); 00916 return (USER_PARAM_TYPE_ERR); 00917 } 00918 00919 if ( strcmp (userName->type, STR_MS_T) == 0 ) { 00920 user = (char *) userName->inOutStruct; 00921 } 00922 else { 00923 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status, 00924 "msiSetACL: Unsupported input userName type %s", 00925 userName->type); 00926 return (USER_PARAM_TYPE_ERR); 00927 } 00928 00929 if ( strcmp (pathName->type, STR_MS_T) == 0 ) { 00930 path = (char *) pathName->inOutStruct; 00931 } 00932 else { 00933 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status, 00934 "msiSetACL: Unsupported input pathName type %s", 00935 pathName->type); 00936 return (USER_PARAM_TYPE_ERR); 00937 } 00938 00939 rsComm = rei->rsComm; 00940 modAccessControlInp.recursiveFlag = recFlg; 00941 modAccessControlInp.accessLevel = acl; 00942 if ( strchr(user, '#') == NULL ) { 00943 modAccessControlInp.userName = user; 00944 modAccessControlInp.zone = rei->uoic->rodsZone; 00945 } 00946 else { 00947 zone = strchr(user, '#') + 1; 00948 memset(uname, '\0', NAME_LEN); 00949 strncpy(uname, user, strlen(user) - strlen(zone) - 1); 00950 modAccessControlInp.userName = uname; 00951 modAccessControlInp.zone = zone; 00952 } 00953 modAccessControlInp.path = path; 00954 rc = rsModAccessControl(rsComm, &modAccessControlInp); 00955 if ( rc < 0 ) { 00956 rodsLog (LOG_NOTICE, "msiSetACL: ACL modifications has failed for user %s on object %s, error = %i\n", user, path, rc); 00957 } 00958 00959 return (rc); 00960 } 00961 00962 /** 00963 * \fn msiDeleteUnusedAVUs (ruleExecInfo_t *rei) 00964 * 00965 * \brief This microservice deletes unused AVUs from the iCAT. See 'iadmin rum'. 00966 * 00967 * \module core 00968 * 00969 * \since post-2.3 00970 * 00971 * \author Wayne Schroeder 00972 * \date April 13, 2010 00973 * 00974 * \note See 'iadmin help rum'. Do not call this directly. 00975 * 00976 * \usage See clients/icommands/test/rules3.0/ 00977 * 00978 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00979 * handled by the rule engine. The user does not include rei as a 00980 * parameter in the rule invocation. 00981 * 00982 * \DolVarDependence rei->rsComm->clientUser.authFlag (must be admin) 00983 * \DolVarModified none 00984 * \iCatAttrDependence check AVU table 00985 * \iCatAttrModified update AVU table 00986 * \sideeffect none 00987 * 00988 * \return integer 00989 * \retval (status) 00990 * \pre none 00991 * \post none 00992 * \sa none 00993 **/ 00994 int 00995 msiDeleteUnusedAVUs(ruleExecInfo_t *rei) 00996 { 00997 int status; 00998 00999 /**** This is Just a Test Stub ****/ 01000 if (reTestFlag > 0 ) { 01001 if (reTestFlag == LOG_TEST_1) { 01002 rodsLog (LOG_NOTICE," Calling msiDeleteUnusedAVUs\n"); 01003 } 01004 if (reLoopBackFlag > 0) 01005 return(0); 01006 } 01007 /**** This is Just a Test Stub ****/ 01008 01009 #ifdef RODS_CAT 01010 rodsLog(LOG_NOTICE, "msiDeleteUnusedAVUs/chlDelUnusedAVUs called\n"); 01011 status = chlDelUnusedAVUs(rei->rsComm); 01012 #else 01013 status = SYS_NO_RCAT_SERVER_ERR; 01014 #endif 01015 return(status); 01016 }