00001
00002
00003
00004
00005
00006
00007
00008 #include "rmCollOld.h"
00009 #include "collCreate.h"
00010 #include "icatHighLevelRoutines.h"
00011 #include "rodsLog.h"
00012 #include "icatDefines.h"
00013 #include "dataObjRename.h"
00014 #include "dataObjOpr.h"
00015 #include "objMetaOpr.h"
00016 #include "collection.h"
00017 #include "specColl.h"
00018 #include "fileRmdir.h"
00019 #include "subStructFileRmdir.h"
00020 #include "genQuery.h"
00021 #include "dataObjUnlink.h"
00022
00023 #include "eirods_resource_backport.h"
00024
00025 int
00026 rsRmCollOld (rsComm_t *rsComm, collInp_t *rmCollInp)
00027 {
00028 int status;
00029 rodsServerHost_t *rodsServerHost = NULL;
00030
00031
00032 status = getAndConnRcatHost (rsComm, MASTER_RCAT, rmCollInp->collName,
00033 &rodsServerHost);
00034 if (status < 0 || NULL == rodsServerHost ) {
00035 return(status);
00036 }
00037
00038 if (rodsServerHost->localFlag == LOCAL_HOST) {
00039 #ifdef RODS_CAT
00040 status = _rsRmCollOld (rsComm, rmCollInp);
00041 #else
00042 status = SYS_NO_RCAT_SERVER_ERR;
00043 #endif
00044 } else {
00045 status = rcRmCollOld (rodsServerHost->conn, rmCollInp);
00046 }
00047
00048 return (status);
00049 }
00050
00051 int
00052 _rsRmCollOld (rsComm_t *rsComm, collInp_t *rmCollInp)
00053 {
00054 int status;
00055 dataObjInfo_t *dataObjInfo = NULL;
00056
00057 #if 0
00058 dataObjInp_t dataObjInp;
00059 memset (&dataObjInp, 0, sizeof (dataObjInp));
00060 rstrcpy (dataObjInp.objPath, rmCollInp->collName, MAX_NAME_LEN);
00061 #endif
00062 status = resolvePathInSpecColl (rsComm, rmCollInp->collName,
00063 WRITE_COLL_PERM, 0, &dataObjInfo);
00064
00065
00066 if (status == COLL_OBJ_T && dataObjInfo->specColl != NULL) {
00067 status = svrRmSpecColl (rsComm, rmCollInp, dataObjInfo);
00068 } else {
00069 status = svrRmCollOld (rsComm, rmCollInp);
00070 }
00071
00072 return (0);
00073 }
00074
00075 int
00076 svrRmCollOld (rsComm_t *rsComm, collInp_t *rmCollInp)
00077 {
00078 int status;
00079 collInfo_t collInfo;
00080
00081 if (getValByKey (&rmCollInp->condInput, RECURSIVE_OPR__KW) != NULL) {
00082 status = _rsRmCollRecurOld (rsComm, rmCollInp);
00083 return (status);
00084 }
00085
00086 memset (&collInfo, 0, sizeof (collInfo));
00087
00088 rstrcpy (collInfo.collName, rmCollInp->collName, MAX_NAME_LEN);
00089 #ifdef RODS_CAT
00090 if (getValByKey (&rmCollInp->condInput, IRODS_ADMIN_RMTRASH_KW) != NULL) {
00091 status = chlDelCollByAdmin (rsComm, &collInfo);
00092 if (status >= 0) {
00093 chlCommit(rsComm);
00094 }
00095 } else {
00096 status = chlDelColl (rsComm, &collInfo);
00097 }
00098 return (status);
00099 #else
00100 return (SYS_NO_RCAT_SERVER_ERR);
00101 #endif
00102 }
00103
00104 int
00105 _rsRmCollRecurOld (rsComm_t *rsComm, collInp_t *rmCollInp)
00106 {
00107 int status;
00108 ruleExecInfo_t rei;
00109 int trashPolicy;
00110
00111 if (getValByKey (&rmCollInp->condInput, FORCE_FLAG_KW) != NULL) {
00112 status = rsPhyRmCollRecurOld (rsComm, rmCollInp);
00113 } else {
00114 initReiWithDataObjInp (&rei, rsComm, NULL);
00115 status = applyRule ("acTrashPolicy", NULL, &rei, NO_SAVE_REI);
00116 trashPolicy = rei.status;
00117
00118 if (trashPolicy != NO_TRASH_CAN) {
00119 status = rsMvCollToTrash (rsComm, rmCollInp);
00120 return status;
00121 } else {
00122 status = rsPhyRmCollRecurOld (rsComm, rmCollInp);
00123 }
00124 }
00125
00126 return (status);
00127 }
00128
00129 int
00130 rsPhyRmCollRecurOld (rsComm_t *rsComm, collInp_t *rmCollInp)
00131 {
00132 int status, i;
00133 int savedStatus = 0;
00134 genQueryInp_t genQueryInp;
00135 genQueryOut_t *genQueryOut = NULL;
00136 dataObjInp_t dataObjInp;
00137 int collLen;
00138 int continueInx;
00139 collInfo_t collInfo;
00140 collInp_t tmpCollInp;
00141 int rmtrashFlag;
00142
00143 memset (&dataObjInp, 0, sizeof (dataObjInp));
00144 memset (&tmpCollInp, 0, sizeof (tmpCollInp));
00145 addKeyVal (&tmpCollInp.condInput, FORCE_FLAG_KW, "");
00146 addKeyVal (&dataObjInp.condInput, FORCE_FLAG_KW, "");
00147
00148 if (getValByKey (&rmCollInp->condInput, IRODS_ADMIN_RMTRASH_KW) != NULL) {
00149 if (isTrashPath (rmCollInp->collName) == False) {
00150 return (SYS_INVALID_FILE_PATH);
00151 }
00152 if (rsComm->clientUser.authInfo.authFlag != LOCAL_PRIV_USER_AUTH) {
00153 return(CAT_INSUFFICIENT_PRIVILEGE_LEVEL);
00154 }
00155 addKeyVal (&tmpCollInp.condInput, IRODS_ADMIN_RMTRASH_KW, "");
00156 addKeyVal (&dataObjInp.condInput, IRODS_ADMIN_RMTRASH_KW, "");
00157 rmtrashFlag = 2;
00158
00159 } else if (getValByKey (&rmCollInp->condInput, IRODS_RMTRASH_KW) != NULL) {
00160 if (isTrashPath (rmCollInp->collName) == False) {
00161 return (SYS_INVALID_FILE_PATH);
00162 }
00163 addKeyVal (&tmpCollInp.condInput, IRODS_RMTRASH_KW, "");
00164 addKeyVal (&dataObjInp.condInput, IRODS_RMTRASH_KW, "");
00165 rmtrashFlag = 1;
00166 }
00167
00168 collLen = strlen (rmCollInp->collName);
00169
00170
00171
00172 memset (&genQueryInp, 0, sizeof (genQueryInp));
00173
00174 status = rsQueryDataObjInCollReCur (rsComm, rmCollInp->collName,
00175 &genQueryInp, &genQueryOut, NULL, 1);
00176
00177 if (status < 0 && status != CAT_NO_ROWS_FOUND) {
00178 rodsLog (LOG_ERROR,
00179 "rsPhyRmCollRecurOld: rsQueryDataObjInCollReCur error for %s, stat=%d",
00180 rmCollInp->collName, status);
00181 return (status);
00182 }
00183
00184 while (status >= 0) {
00185 sqlResult_t *subColl, *dataObj;
00186
00187 if ((subColl = getSqlResultByInx (genQueryOut, COL_COLL_NAME))
00188 == NULL) {
00189 rodsLog (LOG_ERROR,
00190 "rsPhyRmCollRecurOld: getSqlResultByInx for COL_COLL_NAME failed");
00191 return (UNMATCHED_KEY_OR_INDEX);
00192 }
00193
00194 if ((dataObj = getSqlResultByInx (genQueryOut, COL_DATA_NAME))
00195 == NULL) {
00196 rodsLog (LOG_ERROR,
00197 "rsPhyRmCollRecurOld: getSqlResultByInx for COL_DATA_NAME failed");
00198 return (UNMATCHED_KEY_OR_INDEX);
00199 }
00200
00201 for (i = 0; i < genQueryOut->rowCnt; i++) {
00202 char *tmpSubColl, *tmpDataName;
00203
00204 tmpSubColl = &subColl->value[subColl->len * i];
00205 tmpDataName = &dataObj->value[dataObj->len * i];
00206
00207 snprintf (dataObjInp.objPath, MAX_NAME_LEN, "%s/%s",
00208 tmpSubColl, tmpDataName);
00209 status = rsDataObjUnlink (rsComm, &dataObjInp);
00210 if (status < 0) {
00211 rodsLog (LOG_ERROR,
00212 "rsPhyRmCollRecurOld:rsDataObjUnlink failed for %s. stat = %d",
00213 dataObjInp.objPath, status);
00214
00215 savedStatus = status;
00216 }
00217 }
00218
00219 continueInx = genQueryOut->continueInx;
00220
00221 freeGenQueryOut (&genQueryOut);
00222
00223 if (continueInx > 0) {
00224
00225 genQueryInp.continueInx = continueInx;
00226 status = rsGenQuery (rsComm, &genQueryInp, &genQueryOut);
00227 } else {
00228 break;
00229 }
00230 }
00231
00232 clearKeyVal (&dataObjInp.condInput);
00233
00234
00235
00236
00237 status = rsQueryCollInColl (rsComm, rmCollInp->collName, &genQueryInp,
00238 &genQueryOut);
00239
00240 while (status >= 0) {
00241 sqlResult_t *subColl;
00242
00243 if ((subColl = getSqlResultByInx (genQueryOut, COL_COLL_NAME))
00244 == NULL) {
00245 rodsLog (LOG_ERROR,
00246 "rsPhyRmCollRecurOld: getSqlResultByInx for COL_COLL_NAME failed");
00247 return (UNMATCHED_KEY_OR_INDEX);
00248 }
00249
00250 for (i = 0; i < genQueryOut->rowCnt; i++) {
00251 char *tmpSubColl;
00252
00253 tmpSubColl = &subColl->value[subColl->len * i];
00254 if ((int) strlen (tmpSubColl) < collLen)
00255 continue;
00256
00257 rstrcpy (tmpCollInp.collName, tmpSubColl, MAX_NAME_LEN);
00258 status = rsPhyRmCollRecurOld (rsComm, &tmpCollInp);
00259 if (status < 0) {
00260 rodsLogError (LOG_ERROR, status,
00261 "rsPhyRmCollRecurOld: rsPhyRmCollRecurOld of %s failed, status = %d",
00262 tmpSubColl, status);
00263 savedStatus = status;
00264 }
00265 }
00266 continueInx = genQueryOut->continueInx;
00267
00268 freeGenQueryOut (&genQueryOut);
00269
00270 if (continueInx > 0) {
00271
00272 genQueryInp.continueInx = continueInx;
00273 status = rsGenQuery (rsComm, &genQueryInp, &genQueryOut);
00274 } else {
00275 break;
00276 }
00277 }
00278 clearKeyVal (&tmpCollInp.condInput);
00279
00280
00281 memset (&collInfo, 0, sizeof (collInfo));
00282
00283 rstrcpy (collInfo.collName, rmCollInp->collName, MAX_NAME_LEN);
00284 #ifdef RODS_CAT
00285 if (rmtrashFlag > 0 && isTrashHome (rmCollInp->collName) > 0) {
00286
00287 status = 0;
00288 } else {
00289 memset (&collInfo, 0, sizeof (collInfo));
00290 rstrcpy (collInfo.collName, rmCollInp->collName, MAX_NAME_LEN);
00291 if (rmtrashFlag == 2) {
00292 status = chlDelCollByAdmin (rsComm, &collInfo);
00293 if (status >= 0) {
00294 chlCommit(rsComm);
00295 }
00296 } else {
00297 status = chlDelColl (rsComm, &collInfo);
00298 }
00299 }
00300
00301 if (status < 0) {
00302 rodsLog (LOG_ERROR,
00303 "rsPhyRmCollRecurOld: chlDelColl of %s failed, status = %d",
00304 rmCollInp->collName, status);
00305 }
00306
00307 clearGenQueryInp (&genQueryInp);
00308
00309 if (savedStatus < 0) {
00310 return (savedStatus);
00311 } else if (status == CAT_NO_ROWS_FOUND) {
00312 return (0);
00313 } else {
00314 return (status);
00315 }
00316 #else
00317 return (SYS_NO_RCAT_SERVER_ERR);
00318 #endif
00319 }
00320
00321 int
00322 rsMvCollToTrash (rsComm_t *rsComm, collInp_t *rmCollInp)
00323 {
00324 int status;
00325 char trashPath[MAX_NAME_LEN];
00326 dataObjCopyInp_t dataObjRenameInp;
00327 genQueryInp_t genQueryInp;
00328 genQueryOut_t *genQueryOut = NULL;
00329 int continueInx;
00330 dataObjInfo_t dataObjInfo;
00331
00332
00333
00334 memset (&genQueryInp, 0, sizeof (genQueryInp));
00335 status = rsQueryDataObjInCollReCur (rsComm, rmCollInp->collName,
00336 &genQueryInp, &genQueryOut, ACCESS_DELETE_OBJECT, 0);
00337
00338 memset (&dataObjInfo, 0, sizeof (dataObjInfo));
00339 while (status >= 0) {
00340 sqlResult_t *subColl, *dataObj, *rescName;
00341 ruleExecInfo_t rei;
00342
00343
00344
00345 if ((subColl = getSqlResultByInx (genQueryOut, COL_COLL_NAME))
00346 == NULL) {
00347 rodsLog (LOG_ERROR,
00348 "rsMvCollToTrash: getSqlResultByInx for COL_COLL_NAME failed");
00349 return (UNMATCHED_KEY_OR_INDEX);
00350 }
00351
00352 if ((dataObj = getSqlResultByInx (genQueryOut, COL_DATA_NAME))
00353 == NULL) {
00354 rodsLog (LOG_ERROR,
00355 "rsMvCollToTrash: getSqlResultByInx for COL_DATA_NAME failed");
00356 return (UNMATCHED_KEY_OR_INDEX);
00357 }
00358
00359 if ((rescName = getSqlResultByInx (genQueryOut, COL_D_RESC_NAME))
00360 == NULL) {
00361 rodsLog (LOG_ERROR,
00362 "rsMvCollToTrash: getSqlResultByInx for COL_D_RESC_NAME failed");
00363 return (UNMATCHED_KEY_OR_INDEX);
00364 }
00365
00366 snprintf (dataObjInfo.objPath, MAX_NAME_LEN, "%s/%s",
00367 subColl->value, dataObj->value);
00368 rstrcpy (dataObjInfo.rescName, rescName->value, NAME_LEN);
00369
00370 initReiWithDataObjInp (&rei, rsComm, NULL);
00371 rei.doi = &dataObjInfo;
00372
00373 status = applyRule ("acDataDeletePolicy", NULL, &rei, NO_SAVE_REI);
00374
00375 if (status < 0 && status != NO_MORE_RULES_ERR &&
00376 status != SYS_DELETE_DISALLOWED) {
00377 rodsLog (LOG_NOTICE,
00378 "rsMvCollToTrash: acDataDeletePolicy error for %s. status = %d",
00379 dataObjInfo.objPath, status);
00380 return (status);
00381 }
00382
00383 if (rei.status == SYS_DELETE_DISALLOWED) {
00384 rodsLog (LOG_NOTICE,
00385 "rsMvCollToTrash:disallowed for %s via DataDeletePolicy,status=%d",
00386 dataObjInfo.objPath, rei.status);
00387 return (rei.status);
00388 }
00389
00390 continueInx = genQueryOut->continueInx;
00391
00392 freeGenQueryOut (&genQueryOut);
00393
00394 if (continueInx > 0) {
00395
00396 genQueryInp.continueInx = continueInx;
00397 status = rsGenQuery (rsComm, &genQueryInp, &genQueryOut);
00398 } else {
00399 break;
00400 }
00401 }
00402
00403 if (status < 0 && status != CAT_NO_ROWS_FOUND) {
00404 rodsLog (LOG_ERROR,
00405 "rsMvCollToTrash: rsQueryDataObjInCollReCur error for %s, stat=%d",
00406 rmCollInp->collName, status);
00407 return (status);
00408 }
00409
00410 status = rsMkTrashPath (rsComm, rmCollInp->collName, trashPath);
00411
00412 if (status < 0) {
00413 appendRandomToPath (trashPath);
00414 status = rsMkTrashPath (rsComm, rmCollInp->collName, trashPath);
00415 if (status < 0) {
00416 return (status);
00417 }
00418 }
00419
00420 memset (&dataObjRenameInp, 0, sizeof (dataObjRenameInp));
00421
00422 dataObjRenameInp.srcDataObjInp.oprType =
00423 dataObjRenameInp.destDataObjInp.oprType = RENAME_COLL;
00424
00425 rstrcpy (dataObjRenameInp.destDataObjInp.objPath, trashPath, MAX_NAME_LEN);
00426 rstrcpy (dataObjRenameInp.srcDataObjInp.objPath, rmCollInp->collName,
00427 MAX_NAME_LEN);
00428
00429 status = rsDataObjRename (rsComm, &dataObjRenameInp);
00430
00431 while (status == CAT_NAME_EXISTS_AS_COLLECTION) {
00432 appendRandomToPath (dataObjRenameInp.destDataObjInp.objPath);
00433 status = rsDataObjRename (rsComm, &dataObjRenameInp);
00434 #if 0
00435 if (status < 0) {
00436 rodsLog (LOG_ERROR,
00437 "mvCollToTrash: rcDataObjRename error for %s",
00438 dataObjRenameInp.destDataObjInp.objPath);
00439 return (status);
00440 }
00441 #endif
00442 }
00443
00444 if (status < 0) {
00445 rodsLog (LOG_ERROR,
00446 "mvCollToTrash: rcDataObjRename error for %s, status = %d",
00447 dataObjRenameInp.destDataObjInp.objPath, status);
00448 return (status);
00449 }
00450
00451 return (status);
00452 }
00453
00454 int
00455 rsMkTrashPath (rsComm_t *rsComm, char *objPath, char *trashPath)
00456 {
00457 int status;
00458 char *tmpStr;
00459 char startTrashPath[MAX_NAME_LEN];
00460 char destTrashColl[MAX_NAME_LEN], myFile[MAX_NAME_LEN];
00461 char *trashPathPtr;
00462
00463 trashPathPtr = trashPath;
00464 *trashPathPtr = '/';
00465 trashPathPtr++;
00466 tmpStr = objPath + 1;
00467
00468 while (*tmpStr != '\0') {
00469 *trashPathPtr = *tmpStr;
00470 trashPathPtr ++;
00471 if (*tmpStr == '/') {
00472 tmpStr ++;
00473 break;
00474 }
00475 tmpStr ++;
00476 }
00477
00478 if (*tmpStr == '\0') {
00479 rodsLog (LOG_ERROR,
00480 "rsMkTrashPath: input path %s too short", objPath);
00481 return (USER_INPUT_PATH_ERR);
00482 }
00483
00484
00485
00486 if (strncmp (tmpStr, "home/", 5) == 0) {
00487 int nameLen;
00488 tmpStr += 5;
00489 nameLen = strlen (rsComm->clientUser.userName);
00490 if (strncmp (tmpStr, rsComm->clientUser.userName, nameLen) == 0 &&
00491 (*(tmpStr + nameLen) == '/' || *(tmpStr + nameLen) == '#')) {
00492
00493 tmpStr = strchr (tmpStr, '/') + 1;
00494 }
00495 }
00496
00497
00498
00499 *trashPathPtr = '\0';
00500 snprintf (startTrashPath, MAX_NAME_LEN, "%strash/home", trashPath);
00501
00502
00503
00504 if (rsComm->clientUser.authInfo.authFlag == REMOTE_USER_AUTH ||
00505 rsComm->clientUser.authInfo.authFlag == REMOTE_PRIV_USER_AUTH) {
00506
00507 snprintf (trashPathPtr, MAX_NAME_LEN, "trash/home/%s#%s/%s",
00508 rsComm->clientUser.userName, rsComm->clientUser.rodsZone, tmpStr);
00509 } else {
00510 snprintf (trashPathPtr, MAX_NAME_LEN, "trash/home/%s/%s",
00511 rsComm->clientUser.userName, tmpStr);
00512 }
00513
00514 if ((status = splitPathByKey (trashPath, destTrashColl, myFile, '/')) < 0) {
00515 rodsLog (LOG_ERROR,
00516 "rsMkTrashPath: splitPathByKey error for %s ", trashPath);
00517 return (USER_INPUT_PATH_ERR);
00518 }
00519
00520 status = rsMkCollR (rsComm, startTrashPath, destTrashColl);
00521
00522 if (status < 0) {
00523 rodsLog (LOG_ERROR,
00524 "rsMkTrashPath: rsMkCollR error for startPath %s, destPath %s ",
00525 startTrashPath, destTrashColl);
00526 }
00527
00528 return (status);
00529 }
00530
00531 int
00532 svrRmSpecColl (rsComm_t *rsComm, collInp_t *rmCollInp,
00533 dataObjInfo_t *dataObjInfo)
00534 {
00535 int status;
00536
00537 if (getValByKey (&rmCollInp->condInput, RECURSIVE_OPR__KW) != NULL) {
00538
00539 status = svrRmSpecCollRecur (rsComm, dataObjInfo);
00540 } else {
00541
00542 status = l3Rmdir (rsComm, dataObjInfo);
00543 }
00544 return (status);
00545 }
00546
00547 int
00548 l3Rmdir (rsComm_t *rsComm, dataObjInfo_t *dataObjInfo)
00549 {
00550 int rescTypeInx;
00551 fileRmdirInp_t fileRmdirInp;
00552 int status;
00553
00554
00555
00556 std::string location;
00557 eirods::error ret = eirods::get_loc_for_hier_string( dataObjInfo->rescHier, location );
00558 if( !ret.ok() ) {
00559 eirods::log( PASSMSG( "l3Rmdir - failed in get_loc_for_hier_string", ret ) );
00560 return -1;
00561 }
00562
00563 if (getStructFileType (dataObjInfo->specColl) >= 0) {
00564 subFile_t subFile;
00565 memset (&subFile, 0, sizeof (subFile));
00566 rstrcpy (subFile.subFilePath, dataObjInfo->subPath, MAX_NAME_LEN );
00567 rstrcpy (subFile.addr.hostAddr, location.c_str(), NAME_LEN );
00568 subFile.specColl = dataObjInfo->specColl;
00569 status = rsSubStructFileRmdir (rsComm, &subFile);
00570 } else {
00571 #if 0 // JMC legacy resource
00572 rescTypeInx = dataObjInfo->rescInfo->rescTypeInx;
00573
00574 switch (RescTypeDef[rescTypeInx].rescCat) {
00575 case FILE_CAT:
00576 #endif // JMC legacy resource
00577 memset (&fileRmdirInp, 0, sizeof (fileRmdirInp));
00578 fileRmdirInp.fileType = static_cast<fileDriverType_t>(-1);
00579 rstrcpy (fileRmdirInp.dirName, dataObjInfo->filePath, MAX_NAME_LEN);
00580 rstrcpy (fileRmdirInp.addr.hostAddr, location.c_str(), NAME_LEN);
00581 status = rsFileRmdir (rsComm, &fileRmdirInp);
00582 #if 0 // JMC legacy resource
00583 break;
00584
00585 default:
00586 rodsLog (LOG_NOTICE,
00587 "l3Rmdir: rescCat type %d is not recognized",
00588 RescTypeDef[rescTypeInx].rescCat);
00589 status = SYS_INVALID_RESC_TYPE;
00590 break;
00591 }
00592 #endif // JMC legacy resource
00593 }
00594 return (status);
00595 }
00596
00597 int
00598 svrRmSpecCollRecur (rsComm_t *rsComm, dataObjInfo_t *dataObjInfo)
00599 {
00600 int status, i;
00601 dataObjInfo_t myDataObjInfo;
00602 genQueryOut_t *genQueryOut = NULL;
00603 dataObjInp_t dataObjInp;
00604 int continueInx;
00605 int savedStatus = 0;
00606
00607 myDataObjInfo = *dataObjInfo;
00608 memset (&dataObjInp, 0, sizeof (dataObjInp));
00609 rstrcpy (dataObjInp.objPath, dataObjInfo->objPath, MAX_NAME_LEN);
00610 status = rsQuerySpecColl (rsComm, &dataObjInp, &genQueryOut);
00611
00612 while (status >= 0) {
00613 sqlResult_t *subColl, *dataObj;
00614
00615 if ((subColl = getSqlResultByInx (genQueryOut, COL_COLL_NAME))
00616 == NULL) {
00617 rodsLog (LOG_ERROR,
00618 "svrRmSpecCollRecur:getSqlResultByInx COL_COLL_NAME failed");
00619 return (UNMATCHED_KEY_OR_INDEX);
00620 }
00621
00622 if ((dataObj = getSqlResultByInx (genQueryOut, COL_DATA_NAME))
00623 == NULL) {
00624 rodsLog (LOG_ERROR,
00625 "svrRmSpecCollRecur: getSqlResultByInx COL_DATA_NAME failed");
00626 return (UNMATCHED_KEY_OR_INDEX);
00627 }
00628
00629 for (i = 0; i < genQueryOut->rowCnt; i++) {
00630 char *tmpSubColl, *tmpDataName;
00631
00632 tmpSubColl = &subColl->value[subColl->len * i];
00633 tmpDataName = &dataObj->value[dataObj->len * i];
00634
00635 snprintf (myDataObjInfo.objPath, MAX_NAME_LEN, "%s/%s",
00636 tmpSubColl, tmpDataName);
00637
00638 status = getMountedSubPhyPath (dataObjInfo->objPath,
00639 dataObjInfo->filePath, myDataObjInfo.objPath,
00640 myDataObjInfo.filePath);
00641 if (status < 0) {
00642 rodsLog (LOG_ERROR,
00643 "svrRmSpecCollRecur:getMountedSubPhyPat err for %s,stat=%d",
00644 myDataObjInfo.filePath, status);
00645 savedStatus = status;
00646 }
00647
00648 if (strlen (tmpDataName) > 0) {
00649 status = l3Unlink (rsComm, &myDataObjInfo);
00650 } else {
00651 status = svrRmSpecCollRecur (rsComm, &myDataObjInfo);
00652 }
00653
00654 if (status < 0) {
00655 rodsLog (LOG_NOTICE,
00656 "svrRmSpecCollRecur: l3Unlink error for %s. status = %d",
00657 myDataObjInfo.objPath, status);
00658 savedStatus = status;
00659 }
00660 }
00661 continueInx = genQueryOut->continueInx;
00662
00663 freeGenQueryOut (&genQueryOut);
00664
00665 if (continueInx > 0) {
00666
00667 dataObjInp.openFlags = continueInx;
00668 status = rsQuerySpecColl (rsComm, &dataObjInp, &genQueryOut);
00669 } else {
00670 break;
00671 }
00672 }
00673
00674 status = l3Rmdir (rsComm, dataObjInfo);
00675 if (status < 0) savedStatus = status;
00676
00677 return (savedStatus);
00678 }
00679
00680 #ifdef COMPAT_201
00681 int
00682 rsRmCollOld201 (rsComm_t *rsComm, collInp201_t *rmCollInp)
00683 {
00684 collInp_t collInp;
00685 int status;
00686
00687 collInp201ToCollInp (rmCollInp, &collInp);
00688
00689 status = rsRmCollOld (rsComm, &collInp);
00690
00691 return status;
00692 }
00693
00694 #endif