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)  

rsDataObjUnlink.cpp
Go to the documentation of this file.
1 
3 /* This is script-generated code (for the most part). */
4 /* See dataObjUnlink.h for a description of this API call.*/
5 
6 #include "dataObjUnlink.h"
7 #include "rodsErrorTable.h"
8 #include "rodsLog.h"
9 #include "rodsConnect.h"
10 #include "icatDefines.h"
11 #include "fileUnlink.h"
12 #include "unregDataObj.h"
13 #include "objMetaOpr.hpp"
14 #include "dataObjOpr.hpp"
15 #include "specColl.hpp"
16 #include "resource.hpp"
17 #include "rsGlobalExtern.hpp"
18 #include "rcGlobalExtern.h"
19 #include "rmColl.h"
20 #include "dataObjRename.h"
21 #include "subStructFileUnlink.h"
22 #include "modDataObjMeta.h"
23 #include "phyBundleColl.h"
24 #include "dataObjRepl.h"
25 #include "regDataObj.h"
26 #include "physPath.hpp"
27 #include "rsDataObjUnlink.hpp"
28 #include "rsModDataObjMeta.hpp"
29 #include "rsDataObjRepl.hpp"
31 #include "rsFileUnlink.hpp"
32 #include "rsDataObjRename.hpp"
33 #include "rsUnregDataObj.hpp"
34 #include "rsRmColl.hpp"
35 #include "rsRegDataObj.hpp"
36 #include "rcMisc.h"
37 
41 #include "irods_at_scope_exit.hpp"
42 
43 #define RODS_SERVER
44 #include "irods_query.hpp"
45 #undef RODS_SERVER
46 
47 #include "boost/filesystem/path.hpp"
48 #include "fmt/format.h"
49 
50 #include <string>
51 #include <string_view>
52 
53 int rsDataObjUnlink( rsComm_t *rsComm, dataObjInp_t *dataObjUnlinkInp )
54 {
55  // Deprecation messages must be handled by doing the following.
56  // The native rule engine may erase all messages in the rError array.
57  // The only way to guarantee that messages are received by the client
58  // is to add them to the rError array when the function returns.
59  irods::at_scope_exit<std::function<void()>> at_scope_exit{[&] {
60  if (getValByKey(&dataObjUnlinkInp->condInput, REPL_NUM_KW)) {
61  addRErrorMsg(&rsComm->rError, DEPRECATED_PARAMETER, "-n is deprecated. Please use itrim instead.");
62  }
63  }};
64 
65  auto* recurse = getValByKey(&dataObjUnlinkInp->condInput, RECURSIVE_OPR__KW);
66  auto* replica_number = getValByKey(&dataObjUnlinkInp->condInput, REPL_NUM_KW);
67 
68  if (recurse && replica_number) {
70  }
71 
72  int status;
73  ruleExecInfo_t rei;
74  int trashPolicy;
75  dataObjInfo_t *dataObjInfoHead = NULL;
77  int rmTrashFlag = 0;
78  specCollCache_t *specCollCache = NULL;
79 
80  resolveLinkedPath( rsComm, dataObjUnlinkInp->objPath, &specCollCache,
81  &dataObjUnlinkInp->condInput );
83  ( const char* )dataObjUnlinkInp->objPath, &rodsServerHost );
84 
85  if ( status < 0 || NULL == rodsServerHost ) { // JMC cppcheck - nullptr
86  return status;
87  }
88  else if ( rodsServerHost->rcatEnabled == REMOTE_ICAT ) {
89  return rcDataObjUnlink( rodsServerHost->conn, dataObjUnlinkInp );
90  }
91 
92  // =-=-=-=-=-=-=-
93  // working on the "home zone", determine if we need to redirect to a different
94  // server in this zone for this operation. if there is a RESC_HIER_STR_KW then
95  // we know that the redirection decision has already been made
96 
97  // =-=-=-=-=-=-=-
98  // determine the resource hierarchy if one is not provided
99  if ( getValByKey( &dataObjUnlinkInp->condInput, RESC_HIER_STR_KW ) == NULL ) {
100  std::string hier;
102  rsComm, dataObjUnlinkInp, hier, &dataObjInfoHead );
103  if ( !ret.ok() ) {
104  std::stringstream msg;
105  msg << "failed in irods::resolve_resource_hierarchy for [";
106  msg << dataObjUnlinkInp->objPath << "]";
107  irods::log( PASSMSG( msg.str(), ret ) );
108 
109  if( getValByKey( &dataObjUnlinkInp->condInput, FORCE_FLAG_KW ) == NULL ) {
110  return ret.code();
111  }
112  }
113 
114  // =-=-=-=-=-=-=-
115  // we resolved the redirect and have a host, set the hier str for subsequent
116  // api calls, etc.
117  addKeyVal( &dataObjUnlinkInp->condInput, RESC_HIER_STR_KW, hier.c_str() );
118  } // if keyword
119 
120  if (getValByKey(&dataObjUnlinkInp->condInput, ADMIN_RMTRASH_KW) ||
121  getValByKey(&dataObjUnlinkInp->condInput, RMTRASH_KW))
122  {
123  if ( isTrashPath( dataObjUnlinkInp->objPath ) == False ) {
124  return SYS_INVALID_FILE_PATH;
125  }
126 
127  rmTrashFlag = 1;
128  }
129 
130  dataObjUnlinkInp->openFlags = O_WRONLY; /* set the permission checking */
131  status = getDataObjInfoIncSpecColl( rsComm, dataObjUnlinkInp, &dataObjInfoHead );
132 
133  if ( status < 0 ) {
134  char* sys_error = NULL;
135  const char* rods_error = rodsErrorName( status, &sys_error );
136  std::stringstream msg;
137  msg << __FUNCTION__;
138  msg << " - Failed to get data objects.";
139  msg << " - " << rods_error << " " << sys_error;
140  irods::error result = ERROR( status, msg.str() );
141  irods::log( result );
142  free( sys_error );
143  return status;
144  }
145 
146  if ( rmTrashFlag == 1 ) {
147  char *tmpAge;
148  int ageLimit;
149  if ( ( tmpAge = getValByKey( &dataObjUnlinkInp->condInput, AGE_KW ) ) != NULL ) {
150  ageLimit = atoi( tmpAge ) * 60;
151  if ( ( time( 0 ) - atoi( dataObjInfoHead->dataModify ) ) < ageLimit ) {
152  /* younger than ageLimit. Nothing to do */
153  freeAllDataObjInfo( dataObjInfoHead );
154  return 0;
155  }
156  }
157  }
158 
159  if (dataObjUnlinkInp->oprType == UNREG_OPR ||
160  getValByKey(&dataObjUnlinkInp->condInput, FORCE_FLAG_KW) ||
161  getValByKey(&dataObjUnlinkInp->condInput, REPL_NUM_KW) ||
162  getValByKey(&dataObjUnlinkInp->condInput, EMPTY_BUNDLE_ONLY_KW) ||
163  dataObjInfoHead->specColl ||
164  rmTrashFlag == 1)
165  {
166  status = _rsDataObjUnlink( rsComm, dataObjUnlinkInp, &dataObjInfoHead );
167  }
168  else {
169  initReiWithDataObjInp( &rei, rsComm, dataObjUnlinkInp );
170  status = applyRule( "acTrashPolicy", NULL, &rei, NO_SAVE_REI );
171  trashPolicy = rei.status;
173  free(rei.condInputData);
174 
175  if ( trashPolicy != NO_TRASH_CAN ) {
176  status = rsMvDataObjToTrash( rsComm, dataObjUnlinkInp,
177  &dataObjInfoHead );
178  freeAllDataObjInfo( dataObjInfoHead );
179  return status;
180  }
181 
182  status = _rsDataObjUnlink( rsComm, dataObjUnlinkInp, &dataObjInfoHead );
183  }
184 
185  initReiWithDataObjInp( &rei, rsComm, dataObjUnlinkInp );
186  rei.doi = dataObjInfoHead;
187  rei.status = status;
188 
189  // make resource properties available as rule session variables
191 
192  rei.status = applyRule( "acPostProcForDelete", NULL, &rei, NO_SAVE_REI );
193 
194  if ( rei.status < 0 ) {
196  "rsDataObjUnlink: acPostProcForDelete error for %s. status = %d",
197  dataObjUnlinkInp->objPath, rei.status );
198  }
199 
201  free(rei.condInputData);
202 
203  /* dataObjInfoHead may be outdated */
204  freeAllDataObjInfo( dataObjInfoHead );
205 
206  return status;
207 }
208 
210  dataObjInp_t *dataObjUnlinkInp,
211  dataObjInfo_t **dataObjInfoHead)
212 {
213  dataObjInfo_t *tmpDataObjInfo, *myDataObjInfoHead;
214  int status = chkPreProcDeleteRule( rsComm, dataObjUnlinkInp, *dataObjInfoHead );
215  if ( status < 0 ) {
216  return status;
217  }
218 
219  myDataObjInfoHead = *dataObjInfoHead;
220  if ( strstr( myDataObjInfoHead->dataType, BUNDLE_STR ) != NULL ) { // JMC - backport 4658
223  }
224 
225  if ( getValByKey( &dataObjUnlinkInp->condInput, REPL_NUM_KW ) != NULL ) {
227  }
228 
229  // =-=-=-=-=-=-=-
230  // JMC - backport 4552
231  int numSubfiles = getNumSubfilesInBunfileObj( rsComm, myDataObjInfoHead->objPath );
232  if ( numSubfiles > 0 ) {
233  if ( getValByKey( &dataObjUnlinkInp->condInput, EMPTY_BUNDLE_ONLY_KW ) != NULL ) {
234  /* not empty. Nothing to do */
235  return 0;
236  }
237  else {
238  status = _unbunAndStageBunfileObj( rsComm, dataObjInfoHead, &dataObjUnlinkInp->condInput, NULL, 1 );
239  if ( status < 0 ) {
240  /* go ahead and unlink the obj if the phy file does not
241  * exist or have problem untaring it */
243  rodsLogError( LOG_ERROR, status, "_rsDataObjUnlink:_unbunAndStageBunfileObj err for %s",
244  myDataObjInfoHead->objPath );
245  return status;
246  }
247  } // status < 0
248 
249  /* dataObjInfoHead may be outdated */
250  *dataObjInfoHead = NULL;
251  status = getDataObjInfoIncSpecColl( rsComm, dataObjUnlinkInp, dataObjInfoHead );
252 
253  if ( status < 0 ) {
254  return status;
255  }
256  } // else
257  } // if numSubfiles
258  } // if strcmp
259  // =-=-=-=-=-=-=-
260 
261  int retVal = 0;
262  tmpDataObjInfo = *dataObjInfoHead;
263  while ( tmpDataObjInfo != NULL ) {
264  status = dataObjUnlinkS( rsComm, dataObjUnlinkInp, tmpDataObjInfo );
265  if ( status < 0 ) {
266  if ( retVal == 0 ) {
267  retVal = status;
268  }
269  }
270  if ( dataObjUnlinkInp->specColl != NULL ) { /* do only one */
271  break;
272  }
273  tmpDataObjInfo = tmpDataObjInfo->next;
274  }
275 
276  if ( ( *dataObjInfoHead )->specColl == NULL ) {
277  resolveDataObjReplStatus( rsComm, dataObjUnlinkInp );
278  }
279 
280  return retVal;
281 }
282 
283 /* resolveDataObjReplStatus - a dirty copy may be deleted leaving no
284  * dirty copy. In that case, pick the newest copy and mark it dirty
285  */
286 int
287 resolveDataObjReplStatus( rsComm_t *rsComm, dataObjInp_t *dataObjUnlinkInp ) {
288  int status;
289  dataObjInfo_t *dataObjInfoHead = NULL;
290  dataObjInfo_t *newestDataObjInfo = NULL;
291  dataObjInfo_t *tmpDataObjInfo;
292 
293  if ( getValByKey( &dataObjUnlinkInp->condInput, RESC_NAME_KW ) == NULL &&
294  getValByKey( &dataObjUnlinkInp->condInput, REPL_NUM_KW ) == NULL ) {
295  return 0;
296  }
297 
298  char* accessPerm{};
299  if (!getValByKey(&dataObjUnlinkInp->condInput, ADMIN_KW)) {
300  accessPerm = ACCESS_DELETE_OBJECT;
301  }
302  else if (rsComm->clientUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH) {
304  }
305 
306  status = getDataObjInfo( rsComm, dataObjUnlinkInp,
307  &dataObjInfoHead, accessPerm, 1 );
308 
309  if ( status < 0 ) {
310  return status;
311  }
312 
313  tmpDataObjInfo = dataObjInfoHead;
314  while ( tmpDataObjInfo != NULL ) {
315  if ( tmpDataObjInfo->replStatus == 0 ) {
316  if ( newestDataObjInfo == NULL ) {
317  newestDataObjInfo = tmpDataObjInfo;
318  }
319  else if ( atoi( tmpDataObjInfo->dataModify ) >
320  atoi( newestDataObjInfo->dataModify ) ) {
321  newestDataObjInfo = tmpDataObjInfo;
322  }
323  }
324  else {
325  newestDataObjInfo = NULL;
326  break;
327  }
328  tmpDataObjInfo = tmpDataObjInfo->next;
329  }
330 
331  /* modify the repl status */
332  if ( newestDataObjInfo != NULL ) {
333  keyValPair_t regParam;
334  char tmpStr[MAX_NAME_LEN];
335  modDataObjMeta_t modDataObjMetaInp;
336 
337  memset( &regParam, 0, sizeof( regParam ) );
338  memset( &modDataObjMetaInp, 0, sizeof( modDataObjMetaInp ) );
339  snprintf( tmpStr, MAX_NAME_LEN, "%d", NEWLY_CREATED_COPY );
340  addKeyVal( &regParam, REPL_STATUS_KW, tmpStr );
341  modDataObjMetaInp.dataObjInfo = newestDataObjInfo;
342  modDataObjMetaInp.regParam = &regParam;
343 
344  status = rsModDataObjMeta( rsComm, &modDataObjMetaInp );
345 
346  clearKeyVal( &regParam );
347  }
348  freeAllDataObjInfo( dataObjInfoHead );
349  return status;
350 }
351 
353  dataObjInp_t* dataObjUnlinkInp,
354  dataObjInfo_t* dataObjInfo)
355 {
356  // Because this function may change the "oprType", we must make sure that
357  // the "oprType" is restored to it's original value before leaving. This is
358  // necessary because other replicas may not require adjustments to the "oprType"
359  // (i.e. The registered vs non-registered replica case).
360  irods::at_scope_exit restore_opr_type{[dataObjUnlinkInp, old_value = dataObjUnlinkInp->oprType] {
361  dataObjUnlinkInp->oprType = old_value;
362  }};
363 
364  // Verify if the replica is in a vault or not. If the replica is not in a vault,
365  // then the server must not delete the replica. Instead, the replica must be unregistered
366  // to avoid loss of data.
367  {
368  std::string vault_path;
369  if (const auto err = irods::get_vault_path_for_hier_string(dataObjInfo->rescHier, vault_path); !err.ok()) {
370  return SYS_INTERNAL_ERR;
371  }
372 
373  if (!has_prefix(dataObjInfo->filePath, vault_path.data())) {
374  dataObjUnlinkInp->oprType = UNREG_OPR;
375 
377  "Replica is not in a vault. Unregistering replica and leaving it on "
378  "disk as-is [data_object=%s, physical_object=%s].",
379  dataObjUnlinkInp->objPath,
380  dataObjInfo->filePath);
381  }
382  }
383 
384  int status = 0;
385  unregDataObj_t unregDataObjInp;
386 
387  if ( dataObjInfo->specColl == NULL ) {
388  if (dataObjUnlinkInp->oprType == UNREG_OPR &&
390  {
391  ruleExecInfo_t rei;
392 
393  initReiWithDataObjInp( &rei, rsComm, dataObjUnlinkInp );
394  rei.doi = dataObjInfo;
395  rei.status = DO_CHK_PATH_PERM; /* default */ // JMC - backport 4758
396 
397  // make resource properties available as rule session variables
399 
400  applyRule( "acSetChkFilePathPerm", NULL, &rei, NO_SAVE_REI );
402  free(rei.condInputData);
403 
404  if ( rei.status != NO_CHK_PATH_PERM ) {
405  // =-=-=-=-=-=-=-
406  // extract the host location from the resource hierarchy
407  std::string location;
408  irods::error ret = irods::get_loc_for_hier_string( dataObjInfo->rescHier, location );
409  if ( !ret.ok() ) {
410  irods::log( PASSMSG( "dataObjUnlinkS - failed in get_loc_for_hier_string", ret ) );
411  return ret.code();
412  }
413 
414  rodsHostAddr_t addr;
416 
417  memset( &addr, 0, sizeof( addr ) );
418  rstrcpy( addr.hostAddr, location.c_str(), NAME_LEN );
419  int remoteFlag = resolveHost( &addr, &rodsServerHost );
420  if ( remoteFlag < 0 ) {
421  // error condition?
422  }
423 
424  /* unregistering but not an admin user */
425  std::string out_path;
426  ret = resc_mgr.validate_vault_path( dataObjInfo->filePath, rodsServerHost, out_path );
427  if ( ret.ok() ) {
428  /* in the vault */
429  std::stringstream msg;
430  msg << "unregistering a data object which is in a vault [";
431  msg << dataObjInfo->filePath << "]";
432  irods::log( PASSMSG( msg.str(), ret ) );
434  }
435  }
436  }
437 
438  unregDataObjInp.dataObjInfo = dataObjInfo;
439  unregDataObjInp.condInput = &dataObjUnlinkInp->condInput;
440  status = rsUnregDataObj( rsComm, &unregDataObjInp );
441 
442  if ( status < 0 ) {
444  "dataObjUnlinkS: rsUnregDataObj error for %s. status = %d",
445  dataObjUnlinkInp->objPath, status );
446  return status;
447  }
448  }
449 
450  if ( dataObjUnlinkInp->oprType != UNREG_OPR ) {
451  // Set the in_pdmo flag
452  char* in_pdmo = getValByKey( &dataObjUnlinkInp->condInput, IN_PDMO_KW );
453  if ( in_pdmo != NULL ) {
454  rstrcpy( dataObjInfo->in_pdmo, in_pdmo, MAX_NAME_LEN );
455  }
456  else {
457  dataObjInfo->in_pdmo[0] = '\0';
458  }
459 
460  status = l3Unlink( rsComm, dataObjInfo );
461  if ( status < 0 ) {
462  int myError = getErrno( status );
464  "dataObjUnlinkS: l3Unlink error for %s. status = %d",
465  dataObjUnlinkInp->objPath, status );
466  /* allow ENOENT to go on and unregister */
467  if ( myError != ENOENT && myError != EACCES ) {
468  char orphanPath[MAX_NAME_LEN];
469  int status1 = 0;
471  "dataObjUnlinkS: orphan file %s", dataObjInfo->filePath );
472  while ( 1 ) {
473  if ( isOrphanPath( dataObjUnlinkInp->objPath ) ==
474  NOT_ORPHAN_PATH ) {
475  /* don't rename orphan path */
476  status1 = rsMkOrphanPath( rsComm, dataObjInfo->objPath,
477  orphanPath );
478  if ( status1 < 0 ) {
479  break;
480  }
481  /* reg the orphan path */
482  rstrcpy( dataObjInfo->objPath, orphanPath, MAX_NAME_LEN );
483  }
484  status1 = svrRegDataObj( rsComm, dataObjInfo );
485  if ( status1 == CAT_NAME_EXISTS_AS_DATAOBJ ||
487  continue;
488  }
489  else if ( status1 < 0 ) {
490  rodsLogError( LOG_ERROR, status1,
491  "dataObjUnlinkS: svrRegDataObj of orphan %s error",
492  dataObjInfo->objPath );
493  }
494  break;
495  }
496  return status;
497  }
498  else {
499  status = 0;
500  }
501  }
502  }
503 
504  return status;
505 }
506 
507 int
508 l3Unlink( rsComm_t *rsComm, dataObjInfo_t *dataObjInfo ) {
509  fileUnlinkInp_t fileUnlinkInp;
510  int status;
511 
512  // =-=-=-=-=-=-=-
513  // JMC - legacy resource if (getRescClass (dataObjInfo->rescInfo) == BUNDLE_CL) return 0;
514  std::string resc_class;
515  irods::error prop_err = irods::get_resource_property<std::string>(
516  dataObjInfo->rescId,
518  resc_class );
519  if ( prop_err.ok() ) {
520  if ( resc_class == irods::RESOURCE_CLASS_BUNDLE ) { //BUNDLE_CL ) {
521  return 0;
522  }
523  }
524  else {
525  std::stringstream msg;
526  msg << "failed to get property [class] for resource [";
527  msg << dataObjInfo->rescName;
528  msg << "]";
529  irods::log( PASSMSG( msg.str(), prop_err ) );
530  return -1;
531  }
532  // =-=-=-=-=-=-=-
533 
534  // =-=-=-=-=-=-=-
535  // extract the host location from the resource hierarchy
536  std::string location;
537  irods::error ret = irods::get_loc_for_hier_string( dataObjInfo->rescHier, location );
538  if ( !ret.ok() ) {
539  irods::log( PASSMSG( "l3Unlink - failed in get_loc_for_hier_string", ret ) );
540  return -1;
541  }
542 
543 
544 // irods::error resc_err = irods::is_resc_live( dataObjInfo->rescName );
545  irods::error resc_err = irods::is_hier_live( dataObjInfo->rescHier );
546  if ( !resc_err.ok() ) {
547  return resc_err.code();
548  }
549 
550 
551  if ( getStructFileType( dataObjInfo->specColl ) >= 0 ) {
552  subFile_t subFile;
553  memset( &subFile, 0, sizeof( subFile ) );
554  rstrcpy( subFile.subFilePath, dataObjInfo->subPath, MAX_NAME_LEN );
555  rstrcpy( subFile.addr.hostAddr, location.c_str(), NAME_LEN );
556  subFile.specColl = dataObjInfo->specColl;
557  status = rsSubStructFileUnlink( rsComm, &subFile );
558  }
559  else {
560  memset( &fileUnlinkInp, 0, sizeof( fileUnlinkInp ) );
561  rstrcpy( fileUnlinkInp.fileName, dataObjInfo->filePath, MAX_NAME_LEN );
562  rstrcpy( fileUnlinkInp.rescHier, dataObjInfo->rescHier, MAX_NAME_LEN );
563  rstrcpy( fileUnlinkInp.addr.hostAddr, location.c_str(), NAME_LEN );
564  rstrcpy( fileUnlinkInp.objPath, dataObjInfo->objPath, MAX_NAME_LEN );
565  rstrcpy( fileUnlinkInp.in_pdmo, dataObjInfo->in_pdmo, MAX_NAME_LEN );
566  status = rsFileUnlink( rsComm, &fileUnlinkInp );
567  }
568  return status;
569 }
570 
571 int
573  dataObjInfo_t **dataObjInfoHead ) {
574  int status;
575  char trashPath[MAX_NAME_LEN];
576  dataObjCopyInp_t dataObjRenameInp;
577 
578  if ( strstr( ( *dataObjInfoHead )->dataType, BUNDLE_STR ) != NULL ) { // JMC - backport 4658
580  }
581 
582  if ( getValByKey( &dataObjInp->condInput, DATA_ACCESS_KW ) == NULL ) {
583  addKeyVal( &dataObjInp->condInput, DATA_ACCESS_KW,
585  }
586 
587  status = getDataObjInfo( rsComm, dataObjInp, dataObjInfoHead,
589  if ( status < 0 ) {
591  "rsMvDataObjToTrash: getDataObjInfo error for %s. status = %d",
592  dataObjInp->objPath, status );
593  return status;
594  }
595 
596  status = chkPreProcDeleteRule( rsComm, dataObjInp, *dataObjInfoHead );
597  if ( status < 0 ) {
598  return status;
599  }
600 
601 
602  status = rsMkTrashPath( rsComm, dataObjInp->objPath, trashPath );
603 
604  if ( status < 0 ) {
605  return status;
606  }
607 
608  memset( &dataObjRenameInp, 0, sizeof( dataObjRenameInp ) );
609 
610  dataObjRenameInp.srcDataObjInp.oprType =
611  dataObjRenameInp.destDataObjInp.oprType = RENAME_DATA_OBJ;
612 
613  rstrcpy( dataObjRenameInp.destDataObjInp.objPath, trashPath, MAX_NAME_LEN );
614  rstrcpy( dataObjRenameInp.srcDataObjInp.objPath, dataObjInp->objPath,
615  MAX_NAME_LEN );
616 
617  status = rsDataObjRename( rsComm, &dataObjRenameInp );
618 
619  while ( status == CAT_NAME_EXISTS_AS_DATAOBJ ||
622  getErrno( status ) == EISDIR ) {
623  appendRandomToPath( dataObjRenameInp.destDataObjInp.objPath );
624  status = rsDataObjRename( rsComm, &dataObjRenameInp );
625  }
626  if ( status < 0 ) {
628  "rsMvDataObjToTrash: rcDataObjRename error for %s, status = %d",
629  dataObjRenameInp.destDataObjInp.objPath, status );
630  return status;
631  }
632  return status;
633 }
634 
635 int
636 chkPreProcDeleteRule( rsComm_t *rsComm, dataObjInp_t *dataObjUnlinkInp,
637  dataObjInfo_t *dataObjInfoHead ) {
638  dataObjInfo_t *tmpDataObjInfo;
639  ruleExecInfo_t rei;
640  int status = 0;
641 
642  initReiWithDataObjInp( &rei, rsComm, dataObjUnlinkInp );
644  free(rei.condInputData);
645  tmpDataObjInfo = dataObjInfoHead;
646  while ( tmpDataObjInfo != NULL ) {
647  /* have to go through the loop to test each copy (resource). */
648  rei.doi = tmpDataObjInfo;
649 
650  // make resource properties available as rule session variables
651  rei.condInputData = (keyValPair_t *)malloc(sizeof(keyValPair_t));
652  memset(rei.condInputData, 0, sizeof(keyValPair_t));
654 
655  status = applyRule( "acDataDeletePolicy", NULL, &rei, NO_SAVE_REI );
657  free(rei.condInputData);
658 
659  if ( status < 0 && status != NO_MORE_RULES_ERR &&
662  "chkPreProcDeleteRule: acDataDeletePolicy err for %s. stat = %d",
663  dataObjUnlinkInp->objPath, status );
664  return status;
665  }
666 
667  if ( rei.status == SYS_DELETE_DISALLOWED ) {
669  "chkPreProcDeleteRule:acDataDeletePolicy disallowed delete of %s",
670  dataObjUnlinkInp->objPath );
671  return rei.status;
672  }
673  tmpDataObjInfo = tmpDataObjInfo->next;
674  }
675  return status;
676 }
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
DataObjInp::objPath
char objPath[(1024+64)]
Definition: dataObjInpOut.h:66
SYS_CANT_MV_BUNDLE_DATA_TO_TRASH
@ SYS_CANT_MV_BUNDLE_DATA_TO_TRASH
Definition: rodsErrorTable.h:165
NO_TRASH_CAN
#define NO_TRASH_CAN
Definition: objInfo.h:263
RESC_NAME_KW
#define RESC_NAME_KW
Definition: rodsKeyWdDef.h:19
NULL
#define NULL
Definition: rodsDef.h:70
irods::RESOURCE_CLASS
const std::string RESOURCE_CLASS("resource_property_class")
appendRandomToPath
int appendRandomToPath(char *trashPath)
Definition: rcMisc.cpp:2348
irods::at_scope_exit
Definition: irods_at_scope_exit.hpp:10
regDataObj.h
rsComm_t
Definition: rcConnect.h:145
DataObjCopyInp::srcDataObjInp
dataObjInp_t srcDataObjInp
Definition: dataObjCopy.h:26
addKeyVal
int addKeyVal(keyValPair_t *condInput, const char *keyWord, const char *value)
Definition: rcMisc.cpp:789
DataObjCopyInp
Definition: dataObjCopy.h:25
DataObjInp::openFlags
int openFlags
Definition: dataObjInpOut.h:68
DataObjInfo::dataModify
char dataModify[32]
Definition: objInfo.h:151
NEWLY_CREATED_COPY
#define NEWLY_CREATED_COPY
Definition: objInfo.h:115
specColl.hpp
modDataObjMeta.h
irods::get_vault_path_for_hier_string
error get_vault_path_for_hier_string(const std::string &_hier_string, std::string &_rtn_vault_path)
Definition: irods_resource_backport.cpp:658
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
DataObjInp::specColl
specColl_t * specColl
Definition: dataObjInpOut.h:73
unregDataObj_t::condInput
keyValPair_t * condInput
Definition: unregDataObj.h:9
Subfile
Definition: objInfo.h:316
rsUnregDataObj.hpp
rodsServerHost::rcatEnabled
int rcatEnabled
Definition: rodsConnect.h:65
SYS_CANT_MV_BUNDLE_DATA_BY_COPY
@ SYS_CANT_MV_BUNDLE_DATA_BY_COPY
Definition: rodsErrorTable.h:166
RuleExecInfo::status
int status
Definition: irods_re_structs.hpp:19
resc_mgr
irods::resource_manager resc_mgr
Definition: irods_resource_manager.cpp:31
Subfile::subFilePath
char subFilePath[(1024+64)]
Definition: objInfo.h:318
CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME
@ CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME
Definition: rodsErrorTable.h:424
irods::resolve_resource_hierarchy
error resolve_resource_hierarchy(const std::string &, rsComm_t *, dataObjInp_t *, std::string &, dataObjInfo_t **_data_obj_info=0)
Definition: irods_resource_redirect.cpp:505
NO_SAVE_REI
#define NO_SAVE_REI
Definition: rodsDef.h:103
DataObjInfo::dataType
char dataType[64]
Definition: objInfo.h:133
NOT_ORPHAN_PATH
@ NOT_ORPHAN_PATH
Definition: rodsDef.h:172
SYS_TAR_STRUCT_FILE_EXTRACT_ERR
@ SYS_TAR_STRUCT_FILE_EXTRACT_ERR
Definition: rodsErrorTable.h:134
rcMisc.h
irods::is_hier_live
error is_hier_live(const std::string &)
Definition: irods_resource_backport.cpp:234
DataObjInfo::rescId
rodsLong_t rescId
Definition: objInfo.h:164
svrRegDataObj
int svrRegDataObj(rsComm_t *rsComm, dataObjInfo_t *dataObjInfo)
Definition: rsRegDataObj.cpp:120
isOrphanPath
orphanPathType_t isOrphanPath(char *myPath)
Definition: rcMisc.cpp:2473
getStructFileType
int getStructFileType(specColl_t *specColl)
Definition: objMetaOpr.cpp:386
DataObjInfo::rescHier
char rescHier[(1024+64)]
Definition: objInfo.h:132
dataObjRename.h
DataObjInfo::replStatus
int replStatus
Definition: objInfo.h:141
irods::experimental::filesystem::replica_number
replica_number
Definition: filesystem.hpp:51
RuleExecInfo::doi
dataObjInfo_t * doi
Definition: irods_re_structs.hpp:28
irods_resource_backport.hpp
Subfile::specColl
specColl_t * specColl
Definition: objInfo.h:322
REPL_NUM_KW
#define REPL_NUM_KW
Definition: rodsKeyWdDef.h:30
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
rmColl.h
rcGlobalExtern.h
DataObjInfo::filePath
char filePath[(1024+64)]
Definition: objInfo.h:137
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
irods_resource_redirect.hpp
rodsErrorName
const char * rodsErrorName(int errorValue, char **subName)
Definition: rodsLog.cpp:373
RECURSIVE_OPR__KW
#define RECURSIVE_OPR__KW
Definition: rodsKeyWdDef.h:66
rodsConnect.h
REMOTE_ICAT
#define REMOTE_ICAT
Definition: rodsConnect.h:54
getNumSubfilesInBunfileObj
int getNumSubfilesInBunfileObj(rsComm_t *rsComm, char *objPath)
Definition: objMetaOpr.cpp:766
DataObjInfo::next
struct DataObjInfo * next
Definition: objInfo.h:163
DataObjInfo::specColl
specColl_t * specColl
Definition: objInfo.h:158
CANT_UNREG_IN_VAULT_FILE
@ CANT_UNREG_IN_VAULT_FILE
Definition: rodsErrorTable.h:276
REPL_STATUS_KW
#define REPL_STATUS_KW
Definition: rodsKeyWdDef.h:32
fileUnlinkInp_t::fileName
char fileName[(1024+64)]
Definition: fileUnlink.h:9
resolveLinkedPath
int resolveLinkedPath(rsComm_t *rsComm, char *objPath, specCollCache_t **specCollCache, keyValPair_t *condInput)
Definition: specColl.cpp:711
irods::get_resc_properties_as_kvp
error get_resc_properties_as_kvp(const std::string &, keyValPair_t *)
Definition: irods_resource_backport.cpp:500
irods_query.hpp
RENAME_DATA_OBJ
#define RENAME_DATA_OBJ
Definition: dataObjInpOut.h:177
DO_CHK_PATH_PERM
#define DO_CHK_PATH_PERM
Definition: objInfo.h:247
initReiWithDataObjInp
int initReiWithDataObjInp(ruleExecInfo_t *rei, rsComm_t *rsComm, dataObjInp_t *dataObjIn)
Definition: irods_re_structs.cpp:164
SYS_INTERNAL_ERR
@ SYS_INTERNAL_ERR
Definition: rodsErrorTable.h:211
unregDataObj_t::dataObjInfo
dataObjInfo_t * dataObjInfo
Definition: unregDataObj.h:8
RuleExecInfo::condInputData
keyValPair_t * condInputData
Definition: irods_re_structs.hpp:34
rsGlobalExtern.hpp
rsComm_t::rError
rError_t rError
Definition: rcConnect.h:158
irods::error::code
long long code() const
Definition: irods_error.cpp:194
RESC_HIER_STR_KW
#define RESC_HIER_STR_KW
Definition: rodsKeyWdDef.h:225
DataObjInfo::in_pdmo
char in_pdmo[(1024+64)]
Definition: objInfo.h:162
rsComm_t::proxyUser
userInfo_t proxyUser
Definition: rcConnect.h:152
NO_CHK_PATH_PERM
#define NO_CHK_PATH_PERM
Definition: objInfo.h:246
freeAllDataObjInfo
int freeAllDataObjInfo(dataObjInfo_t *dataObjInfoHead)
Definition: rcMisc.cpp:561
rsMkOrphanPath
int rsMkOrphanPath(rsComm_t *rsComm, char *objPath, char *orphanPath)
Definition: physPath.cpp:1127
CAT_INSUFFICIENT_PRIVILEGE_LEVEL
@ CAT_INSUFFICIENT_PRIVILEGE_LEVEL
Definition: rodsErrorTable.h:445
getDataObjInfoIncSpecColl
int getDataObjInfoIncSpecColl(rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t **dataObjInfo)
Definition: dataObjOpr.cpp:1767
rsDataObjRename.hpp
getIrodsErrno
int getIrodsErrno(int irodError)
Definition: rcMisc.cpp:3272
NO_MORE_RULES_ERR
@ NO_MORE_RULES_ERR
Definition: rodsErrorTable.h:594
fileUnlinkInp_t::rescHier
char rescHier[(1024+64)]
Definition: fileUnlink.h:10
DataObjInp
Definition: dataObjInpOut.h:65
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
irods::resource_manager::validate_vault_path
error validate_vault_path(std::string, rodsServerHost_t *, std::string &)
Definition: irods_resource_manager.cpp:132
rsDataObjRename
int rsDataObjRename(rsComm_t *rsComm, dataObjCopyInp_t *dataObjRenameInp)
Definition: rsDataObjRename.cpp:42
getErrno
int getErrno(int errCode)
Definition: rcMisc.cpp:3261
RMTRASH_KW
#define RMTRASH_KW
Definition: rodsKeyWdDef.h:65
Subfile::addr
rodsHostAddr_t addr
Definition: objInfo.h:317
ADMIN_KW
#define ADMIN_KW
Definition: rodsKeyWdDef.h:62
EMPTY_BUNDLE_ONLY_KW
#define EMPTY_BUNDLE_ONLY_KW
Definition: rodsKeyWdDef.h:111
addRErrorMsg
int addRErrorMsg(rError_t *myError, int status, const char *msg)
Definition: rcMisc.cpp:121
LOCAL_PRIV_USER_AUTH
#define LOCAL_PRIV_USER_AUTH
Definition: rodsUser.h:36
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
rodsLog.h
physPath.hpp
irods::log
void log(const error &)
Definition: irods_log.cpp:13
modDataObjMeta_t::regParam
keyValPair_t * regParam
Definition: modDataObjMeta.h:9
SYS_PHY_PATH_INUSE
@ SYS_PHY_PATH_INUSE
Definition: rodsErrorTable.h:185
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
icatDefines.h
rsComm_t::clientUser
userInfo_t clientUser
Definition: rcConnect.h:153
getDataObjInfo
int getDataObjInfo(rsComm_t *rsComm, dataObjInp_t *dataObjInp, dataObjInfo_t **dataObjInfoHead, char *accessPerm, int ignoreCondInput)
Definition: dataObjOpr.cpp:87
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::error
Definition: irods_error.hpp:23
DATA_ACCESS_KW
#define DATA_ACCESS_KW
Definition: rodsKeyWdDef.h:43
AGE_KW
#define AGE_KW
Definition: rodsKeyWdDef.h:221
modDataObjMeta_t::dataObjInfo
dataObjInfo_t * dataObjInfo
Definition: modDataObjMeta.h:8
dataObjRepl.h
unregDataObj_t
Definition: unregDataObj.h:7
SYS_INVALID_FILE_PATH
@ SYS_INVALID_FILE_PATH
Definition: rodsErrorTable.h:99
getAndConnRcatHost
int getAndConnRcatHost(rsComm_t *rsComm, int rcatType, const char *rcatZoneHint, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:26
fileUnlinkInp_t::objPath
char objPath[(1024+64)]
Definition: fileUnlink.h:11
IN_PDMO_KW
#define IN_PDMO_KW
Definition: rodsKeyWdDef.h:227
DEPRECATED_PARAMETER
@ DEPRECATED_PARAMETER
Definition: rodsErrorTable.h:856
DataObjCopyInp::destDataObjInp
dataObjInp_t destDataObjInp
Definition: dataObjCopy.h:27
irods_hierarchy_parser.hpp
FORCE_FLAG_KW
#define FORCE_FLAG_KW
Definition: rodsKeyWdDef.h:13
isTrashPath
int isTrashPath(char *myPath)
Definition: rcMisc.cpp:2395
fileUnlinkInp_t::in_pdmo
char in_pdmo[(1024+64)]
Definition: fileUnlink.h:12
MASTER_RCAT
#define MASTER_RCAT
Definition: rodsDef.h:85
CAT_NAME_EXISTS_AS_COLLECTION
@ CAT_NAME_EXISTS_AS_COLLECTION
Definition: rodsErrorTable.h:448
rodsServerHost
Definition: rodsConnect.h:62
DataObjInfo::rescName
char rescName[64]
Definition: objInfo.h:131
DataObjInp::oprType
int oprType
Definition: dataObjInpOut.h:72
rodsHostAddr_t::hostAddr
char hostAddr[256]
Definition: rodsDef.h:297
UNREG_OPR
#define UNREG_OPR
Definition: dataObjInpOut.h:190
irods::RESOURCE_CLASS_BUNDLE
const std::string RESOURCE_CLASS_BUNDLE("bundle")
RuleExecInfo
Definition: irods_re_structs.hpp:18
rsModDataObjMeta
int rsModDataObjMeta(rsComm_t *rsComm, modDataObjMeta_t *modDataObjMetaInp)
Definition: rsModDataObjMeta.cpp:23
rodsLogError
void rodsLogError(int level, int errCode, char *formatStr,...)
Definition: rodsLog.cpp:422
SYS_DELETE_DISALLOWED
@ SYS_DELETE_DISALLOWED
Definition: rodsErrorTable.h:108
rcDataObjUnlink
int rcDataObjUnlink(rcComm_t *conn, dataObjInp_t *dataObjUnlinkInp)
Definition: rcDataObjUnlink.cpp:63
rsModDataObjMeta.hpp
has_prefix
int has_prefix(const char *path, const char *prefix)
Definition: rodsPath.cpp:561
CAT_NAME_EXISTS_AS_DATAOBJ
@ CAT_NAME_EXISTS_AS_DATAOBJ
Definition: rodsErrorTable.h:449
applyRule
int applyRule(char *inAction, msParamArray_t *inMsParamArray, ruleExecInfo_t *rei, int reiSaveFlag)
Definition: irods_re_structs.cpp:65
irods_at_scope_exit.hpp
resource.hpp
USER_INCOMPATIBLE_PARAMS
@ USER_INCOMPATIBLE_PARAMS
Definition: rodsErrorTable.h:288
_unbunAndStageBunfileObj
int _unbunAndStageBunfileObj(rsComm_t *rsComm, dataObjInfo_t **bunfileObjInfoHead, keyValPair_t *condInput, char **outCacheRescName, int rmBunCopyFlag)
Definition: rsDataObjRepl.cpp:1527
phyBundleColl.h
rsRmColl.hpp
DataObjInfo::objPath
char objPath[(1024+64)]
Definition: objInfo.h:130
rsRegDataObj.hpp
rodsErrorTable.h
False
#define False
Definition: parseCommandLine.h:12
userInfo_t::authInfo
authInfo_t authInfo
Definition: rodsUser.h:70
rstrcpy
char * rstrcpy(char *dest, const char *src, int maxLen)
Definition: stringOpr.cpp:51
dataObjOpr.hpp
rsUnregDataObj
int rsUnregDataObj(rsComm_t *rsComm, unregDataObj_t *unregDataObjInp)
Definition: rsUnregDataObj.cpp:17
DataObjInp::condInput
keyValPair_t condInput
Definition: dataObjInpOut.h:74
modDataObjMeta_t
Definition: modDataObjMeta.h:7
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
ACCESS_DELETE_OBJECT
#define ACCESS_DELETE_OBJECT
Definition: icatDefines.h:60
NAME_LEN
#define NAME_LEN
Definition: rodsDef.h:55
KeyValPair
Definition: objInfo.h:120
authInfo_t::authFlag
int authFlag
Definition: rodsUser.h:42
clearKeyVal
int clearKeyVal(keyValPair_t *condInput)
Definition: rcMisc.cpp:1047
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
fileUnlinkInp_t::addr
rodsHostAddr_t addr
Definition: fileUnlink.h:8
fileUnlinkInp_t
Definition: fileUnlink.h:7
DataObjInfo
Definition: objInfo.h:129
irods::UNLINK_OPERATION
const std::string UNLINK_OPERATION("UNLINK")
unregDataObj.h
rsDataObjRepl.hpp
SpecCollCache
Definition: objInfo.h:102
rsMkTrashPath
int rsMkTrashPath(rsComm_t *rsComm, char *objPath, char *trashPath)
Definition: rsRmColl.cpp:490
ADMIN_RMTRASH_KW
#define ADMIN_RMTRASH_KW
Definition: rodsKeyWdDef.h:63
objMetaOpr.hpp
resolveHost
int resolveHost(rodsHostAddr_t *addr, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:375
DataObjInfo::subPath
char subPath[(1024+64)]
Definition: objInfo.h:157
rodsHostAddr_t
Definition: rodsDef.h:296
BUNDLE_STR
#define BUNDLE_STR
Definition: phyBundleColl.h:13