00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "reDataObjOpr.h"
00010 #include "apiHeaderAll.h"
00011 #include "rsApiHandler.h"
00012 #include "collection.h"
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 int
00060 msiDataObjCreate (msParam_t *inpParam1, msParam_t *msKeyValStr,
00061 msParam_t *outParam, ruleExecInfo_t *rei)
00062 {
00063 rsComm_t *rsComm;
00064 dataObjInp_t dataObjInp, *myDataObjInp;
00065 char *outBadKeyWd;
00066 int validKwFlags;
00067
00068 RE_TEST_MACRO (" Calling msiDataObjCreate")
00069
00070 if (rei == NULL || rei->rsComm == NULL) {
00071 rodsLog (LOG_ERROR,
00072 "msiDataObjCreate: input rei or rsComm is NULL");
00073 return (SYS_INTERNAL_NULL_INPUT_ERR);
00074 }
00075
00076 rsComm = rei->rsComm;
00077
00078
00079 rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
00080 &myDataObjInp, 0);
00081
00082 if (rei->status < 0) {
00083 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00084 "msiDataObjCreate: input inpParam1 error. status = %d", rei->status);
00085 return (rei->status);
00086 }
00087
00088 #if 0
00089 rei->status = parseMspForCondInp (inpParam2, &myDataObjInp->condInput,
00090 DEST_RESC_NAME_KW);
00091 #else
00092 validKwFlags = DEST_RESC_NAME_FLAG | CREATE_MODE_FLAG | DATA_TYPE_FLAG |
00093 FORCE_FLAG_FLAG | DATA_SIZE_FLAGS | OBJ_PATH_FLAG;
00094 rei->status = parseMsKeyValStrForDataObjInp (msKeyValStr, myDataObjInp,
00095 DEST_RESC_NAME_KW, validKwFlags, &outBadKeyWd);
00096 #endif
00097
00098 if (rei->status < 0) {
00099 if (outBadKeyWd != NULL) {
00100 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00101 "msiDataObjCreate: input keyWd - %s error. status = %d",
00102 outBadKeyWd, rei->status);
00103 free (outBadKeyWd);
00104 } else {
00105 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00106 "msiDataObjCreate: input msKeyValStr error. status = %d",
00107 rei->status);
00108 }
00109 return (rei->status);
00110 }
00111
00112 rei->status = rsDataObjCreate (rsComm, myDataObjInp);
00113
00114 if (myDataObjInp == &dataObjInp) {
00115 clearKeyVal (&myDataObjInp->condInput);
00116 }
00117
00118 if (rei->status >= 0) {
00119 fillIntInMsParam (outParam, rei->status);
00120 } else {
00121 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00122 "msiDataObjCreate: rsDataObjCreate failed for %s, status = %d",
00123 myDataObjInp->objPath,
00124 rei->status);
00125 }
00126
00127 return (rei->status);
00128 }
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 int
00179 msiDataObjOpen (msParam_t *inpParam, msParam_t *outParam,
00180 ruleExecInfo_t *rei)
00181 {
00182 rsComm_t *rsComm;
00183 dataObjInp_t dataObjInp, *myDataObjInp;
00184 char *outBadKeyWd = NULL;
00185 int validKwFlags;
00186
00187 RE_TEST_MACRO (" Calling msiDataObjOpen")
00188
00189 if (rei == NULL || rei->rsComm == NULL) {
00190 rodsLog (LOG_ERROR,
00191 "msiDataObjOpen: input rei or rsComm is NULL");
00192 return (SYS_INTERNAL_NULL_INPUT_ERR);
00193 }
00194
00195 rsComm = rei->rsComm;
00196
00197
00198 if (strcmp (inpParam->type, STR_MS_T) == 0) {
00199 bzero (&dataObjInp, sizeof (dataObjInp));
00200 myDataObjInp = &dataObjInp;
00201 validKwFlags = OBJ_PATH_FLAG | RESC_NAME_FLAG | OPEN_FLAGS_FLAG |
00202 REPL_NUM_FLAG;
00203 rei->status = parseMsKeyValStrForDataObjInp (inpParam, myDataObjInp,
00204 OBJ_PATH_KW, validKwFlags, &outBadKeyWd);
00205 }else {
00206 rei->status = parseMspForDataObjInp (inpParam, &dataObjInp,
00207 &myDataObjInp, 0);
00208 }
00209
00210 if (rei->status < 0) {
00211 if (outBadKeyWd != NULL) {
00212 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00213 "msiDataObjOpen: input keyWd - %s error. status = %d",
00214 outBadKeyWd, rei->status);
00215 free (outBadKeyWd);
00216 } else {
00217 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00218 "msiDataObjOpen: input msKeyValStr error. status = %d",
00219 rei->status);
00220 }
00221 return (rei->status);
00222 }
00223
00224 #if 0
00225 if (strcmp (inpParam->type, STR_MS_T) == 0) {
00226 myDataObjInp->openFlags = O_RDWR;
00227 }
00228 #endif
00229 rei->status = rsDataObjOpen (rsComm, myDataObjInp);
00230 if (rei->status >= 0) {
00231 fillIntInMsParam (outParam, rei->status);
00232 } else {
00233 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00234 "msiDataObjOpen: rsDataObjOpen failed for %s, status = %d",
00235 dataObjInp.objPath,
00236 rei->status);
00237 }
00238
00239 return (rei->status);
00240 }
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276 int
00277 msiDataObjClose (msParam_t *inpParam, msParam_t *outParam, ruleExecInfo_t *rei)
00278 {
00279 rsComm_t *rsComm;
00280 openedDataObjInp_t dataObjCloseInp, *myDataObjCloseInp;
00281
00282 RE_TEST_MACRO (" Calling msiDataObjClose")
00283
00284 if (rei == NULL || rei->rsComm == NULL) {
00285 rodsLog (LOG_ERROR,
00286 "msiDataObjClose: input rei or rsComm is NULL");
00287 return (SYS_INTERNAL_NULL_INPUT_ERR);
00288 }
00289
00290 rsComm = rei->rsComm;
00291
00292 if (inpParam == NULL) {
00293 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
00294 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00295 "msiDataObjClose: input inpParam is NULL");
00296 return (rei->status);
00297 }
00298
00299 if (strcmp (inpParam->type, DataObjCloseInp_MS_T) == 0) {
00300 myDataObjCloseInp = (openedDataObjInp_t*)inpParam->inOutStruct;
00301 } else {
00302 int myInt;
00303
00304 myInt = parseMspForPosInt (inpParam);
00305 if (myInt >= 0) {
00306 memset (&dataObjCloseInp, 0, sizeof (dataObjCloseInp));
00307 dataObjCloseInp.l1descInx = myInt;
00308 myDataObjCloseInp = &dataObjCloseInp;
00309 } else {
00310 rei->status = myInt;
00311 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00312 "msiDataObjClose: parseMspForPosInt error for param1.");
00313 return (rei->status);
00314 }
00315 }
00316
00317 rei->status = rsDataObjClose (rsComm, myDataObjCloseInp);
00318 if (rei->status >= 0) {
00319 fillIntInMsParam (outParam, rei->status);
00320 } else {
00321 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00322 "msiDataObjClose: rsDataObjClose failed, status = %d",
00323 rei->status);
00324 }
00325
00326 return (rei->status);
00327 }
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365 int
00366 msiDataObjLseek (msParam_t *inpParam1, msParam_t *inpParam2,
00367 msParam_t *inpParam3, msParam_t *outParam,
00368 ruleExecInfo_t *rei)
00369 {
00370 rsComm_t *rsComm;
00371 openedDataObjInp_t dataObjLseekInp, *myDataObjLseekInp;
00372 fileLseekOut_t *dataObjLseekOut = NULL;
00373
00374 RE_TEST_MACRO (" Calling msiDataObjLseek")
00375
00376 if (rei == NULL || rei->rsComm == NULL) {
00377 rodsLog (LOG_ERROR,
00378 "msiDataObjLseek: input rei or rsComm is NULL");
00379 return (SYS_INTERNAL_NULL_INPUT_ERR);
00380 }
00381
00382 rsComm = rei->rsComm;
00383
00384 if (inpParam1 == NULL) {
00385 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
00386 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00387 "msiDataObjLseek: input inpParam1 is NULL");
00388 return (rei->status);
00389 }
00390
00391 if (strcmp (inpParam1->type, STR_MS_T) == 0) {
00392
00393 memset (&dataObjLseekInp, 0, sizeof (dataObjLseekInp));
00394 dataObjLseekInp.l1descInx = atoi ((char*)inpParam1->inOutStruct);
00395 myDataObjLseekInp = &dataObjLseekInp;
00396 } else if (strcmp (inpParam1->type, INT_MS_T) == 0) {
00397 memset (&dataObjLseekInp, 0, sizeof (dataObjLseekInp));
00398 dataObjLseekInp.l1descInx = *(int *)inpParam1->inOutStruct;
00399 myDataObjLseekInp = &dataObjLseekInp;
00400 } else if (strcmp (inpParam1->type, DataObjLseekInp_MS_T) == 0) {
00401 myDataObjLseekInp = (openedDataObjInp_t*)inpParam1->inOutStruct;
00402 } else {
00403 rei->status = USER_PARAM_TYPE_ERR;
00404 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00405 "msiDataObjLseek: Unsupported input Param type %s",
00406 inpParam1->type);
00407 return (rei->status);
00408 }
00409
00410 if (inpParam2 != NULL) {
00411 if (strcmp (inpParam2->type, INT_MS_T) == 0) {
00412 myDataObjLseekInp->offset = *(int *)inpParam2->inOutStruct;
00413 } else if (strcmp (inpParam2->type, STR_MS_T) == 0) {
00414
00415 if (strcmp ((char *) inpParam2->inOutStruct, "null") != 0) {
00416 myDataObjLseekInp->offset = strtoll ((char*)inpParam2->inOutStruct,
00417 0, 0);
00418 }
00419 } else if (strcmp (inpParam2->type, DOUBLE_MS_T) == 0) {
00420 myDataObjLseekInp->offset = *(rodsLong_t *)inpParam2->inOutStruct;
00421 } else {
00422 rei->status = USER_PARAM_TYPE_ERR;
00423 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00424 "msiDataObjLseek: Unsupported input Param type %s",
00425 inpParam2->type);
00426 return (rei->status);
00427 }
00428 }
00429
00430 if (inpParam3 != NULL) {
00431
00432 if (strcmp (inpParam3->type, STR_MS_T) == 0) {
00433 if (strcmp ((char *) inpParam3->inOutStruct, "SEEK_SET") == 0) {
00434 myDataObjLseekInp->whence = SEEK_SET;
00435 } else if (strcmp ((char *) inpParam3->inOutStruct,
00436 "SEEK_CUR") == 0) {
00437 myDataObjLseekInp->whence = SEEK_CUR;
00438 } else if (strcmp ((char *) inpParam3->inOutStruct,
00439 "SEEK_END") == 0) {
00440 myDataObjLseekInp->whence = SEEK_END;
00441 } else if (strcmp ((char *) inpParam3->inOutStruct, "null") != 0) {
00442 myDataObjLseekInp->whence = atoi ((char*)inpParam3->inOutStruct);
00443 }
00444 } else if (strcmp (inpParam3->type, INT_MS_T) == 0) {
00445 myDataObjLseekInp->whence = *(int *)inpParam3->inOutStruct;
00446 } else {
00447 rei->status = USER_PARAM_TYPE_ERR;
00448 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00449 "msiDataObjLseek: Unsupported input Param type %s",
00450 inpParam3->type);
00451 return (rei->status);
00452 }
00453 }
00454
00455 if (myDataObjLseekInp->whence != SEEK_SET &&
00456 myDataObjLseekInp->whence != SEEK_CUR &&
00457 myDataObjLseekInp->whence != SEEK_END) {
00458 rei->status = USER_PARAM_TYPE_ERR;
00459 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00460 "msiDataObjLseek: Unsupported input whence value %d",
00461 myDataObjLseekInp->whence);
00462 return (rei->status);
00463 }
00464
00465 rei->status = rsDataObjLseek (rsComm, myDataObjLseekInp, &dataObjLseekOut);
00466 if (rei->status >= 0) {
00467 if (outParam != NULL) {
00468 fillMsParam (outParam, NULL, DataObjLseekOut_MS_T,
00469 dataObjLseekOut, NULL);
00470 } else {
00471 free (dataObjLseekOut);
00472 }
00473 } else {
00474 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00475 "msiDataObjLseek: rsDataObjLseek failed, status = %d",
00476 rei->status);
00477 }
00478
00479 return (rei->status);
00480 }
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517 int
00518 msiDataObjRead (msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *outParam, ruleExecInfo_t *rei)
00519 {
00520 rsComm_t *rsComm;
00521 openedDataObjInp_t dataObjReadInp, *myDataObjReadInp;
00522 bytesBuf_t *dataObjReadOutBBuf = NULL;
00523 int myInt;
00524
00525 RE_TEST_MACRO (" Calling msiDataObjRead")
00526
00527 if (rei == NULL || rei->rsComm == NULL) {
00528 rodsLog (LOG_ERROR,
00529 "msiDataObjRead: input rei or rsComm is NULL");
00530 return (SYS_INTERNAL_NULL_INPUT_ERR);
00531 }
00532
00533 rsComm = rei->rsComm;
00534
00535 if (inpParam1 == NULL) {
00536 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
00537 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00538 "msiDataObjRead: input inpParam1 is NULL");
00539 return (rei->status);
00540 }
00541
00542 if (strcmp (inpParam1->type, DataObjReadInp_MS_T) == 0) {
00543 myDataObjReadInp = (openedDataObjInp_t*)inpParam1->inOutStruct;
00544 } else {
00545 myInt = parseMspForPosInt (inpParam1);
00546 if (myInt >= 0) {
00547 memset (&dataObjReadInp, 0, sizeof (dataObjReadInp));
00548 dataObjReadInp.l1descInx = myInt;
00549 myDataObjReadInp = &dataObjReadInp;
00550 } else {
00551 rei->status = myInt;
00552 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00553 "msiDataObjRead: parseMspForPosInt error for param1.");
00554 return (rei->status);
00555 }
00556 }
00557
00558 if (inpParam2 != NULL) {
00559 myInt = parseMspForPosInt (inpParam2);
00560
00561 if (myInt < 0) {
00562 if (myInt != SYS_NULL_INPUT) {
00563 rei->status = myInt;
00564 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00565 "msiDataObjRead: parseMspForPosInt error for param2.");
00566 return (rei->status);
00567 }
00568 } else {
00569 myDataObjReadInp->len = myInt;
00570 }
00571 }
00572
00573 dataObjReadOutBBuf = (bytesBuf_t *) malloc (sizeof (bytesBuf_t));
00574 memset (dataObjReadOutBBuf, 0, sizeof (bytesBuf_t));
00575
00576 rei->status = rsDataObjRead (rsComm, myDataObjReadInp, dataObjReadOutBBuf);
00577
00578 if (rei->status >= 0) {
00579 fillBufLenInMsParam (outParam, rei->status, dataObjReadOutBBuf);
00580 } else {
00581 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00582 "msiDataObjRead: rsDataObjRead failed, status = %d",
00583 rei->status);
00584 }
00585
00586 return (rei->status);
00587 }
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625 int
00626 msiDataObjWrite (msParam_t *inpParam1, msParam_t *inpParam2,
00627 msParam_t *outParam, ruleExecInfo_t *rei)
00628 {
00629 rsComm_t *rsComm;
00630 openedDataObjInp_t dataObjWriteInp, *myDataObjWriteInp;
00631 int myInt;
00632 bytesBuf_t tmpBBuf, *myBBuf;
00633 execCmdOut_t *myExecCmdOut;
00634 msParam_t *mP;
00635
00636 RE_TEST_MACRO (" Calling msiDataObjWrite")
00637
00638 if (rei == NULL || rei->rsComm == NULL) {
00639 rodsLog (LOG_ERROR, "msiDataObjWrite: input rei or rsComm is NULL");
00640 return (SYS_INTERNAL_NULL_INPUT_ERR);
00641 }
00642
00643 rsComm = rei->rsComm;
00644
00645 if ((strcmp((char *)inpParam2->inOutStruct,"stdout") == 0) ||
00646 (strcmp((char *) inpParam2->inOutStruct,"stderr") == 0)) {
00647 if ((mP = getMsParamByLabel (rei->msParamArray, "ruleExecOut")) == NULL)
00648 return(NO_VALUES_FOUND);
00649 myExecCmdOut = (execCmdOut_t*)mP->inOutStruct;
00650 if (strcmp((char *) inpParam2->inOutStruct,"stdout") == 0){
00651 free(inpParam2->inOutStruct);
00652 inpParam2->inOutStruct = 0;
00653 if( myExecCmdOut->stdoutBuf.len > 0 ) {
00654 inpParam2->inOutStruct = strdup((char *) myExecCmdOut->stdoutBuf.buf);
00655 }
00656 }
00657 else {
00658 free(inpParam2->inOutStruct);
00659 if( myExecCmdOut->stdoutBuf.len > 0 ) {
00660 inpParam2->inOutStruct = strdup((char *) myExecCmdOut->stderrBuf.buf);
00661 }
00662 }
00663 inpParam2->type = strdup(STR_MS_T);
00664 }
00665
00666 if (inpParam1 == NULL || (inpParam2->inpOutBuf == NULL &&
00667 inpParam2->inOutStruct == NULL)) {
00668 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
00669 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00670 "msiDataObjWrite: input inpParam1 or inpOutBuf or inOutStruct is NULL");
00671 return (rei->status);
00672 }
00673
00674 if (strcmp (inpParam1->type, DataObjWriteInp_MS_T) == 0) {
00675 myDataObjWriteInp = (openedDataObjInp_t*)inpParam1->inOutStruct;
00676 } else {
00677 myInt = parseMspForPosInt (inpParam1);
00678 if (myInt >= 0) {
00679 memset (&dataObjWriteInp, 0, sizeof (dataObjWriteInp));
00680 dataObjWriteInp.l1descInx = myInt;
00681 myDataObjWriteInp = &dataObjWriteInp;
00682 } else {
00683 rei->status = myInt;
00684 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00685 "msiDataObjWrite: parseMspForPosInt error for param1.");
00686 return (rei->status);
00687 }
00688 }
00689
00690 if (inpParam2 != NULL) {
00691 if (strcmp (inpParam2->type, STR_MS_T) == 0) {
00692 tmpBBuf.len = myDataObjWriteInp->len =
00693 strlen ((char*)inpParam2->inOutStruct) + 1;
00694 tmpBBuf.buf = inpParam2->inOutStruct;
00695 myBBuf = &tmpBBuf;
00696 } else {
00697 myInt = parseMspForPosInt (inpParam2);
00698 if (myInt < 0) {
00699 if (myInt != SYS_NULL_INPUT) {
00700 rei->status = myInt;
00701 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00702 "msiDataObjWrite: parseMspForPosInt error for param2.");
00703 return (rei->status);
00704 }
00705 } else {
00706 myDataObjWriteInp->len = myInt;
00707 }
00708 myBBuf = inpParam2->inpOutBuf;
00709 }
00710 }
00711
00712 rei->status = rsDataObjWrite (rsComm, myDataObjWriteInp, myBBuf);
00713
00714 if (rei->status >= 0) {
00715 fillIntInMsParam (outParam, rei->status);
00716 } else {
00717 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00718 "msiDataObjWrite: rsDataObjWrite failed, status = %d",
00719 rei->status);
00720 }
00721
00722 return (rei->status);
00723 }
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774 int
00775 msiDataObjUnlink (msParam_t *inpParam, msParam_t *outParam,
00776 ruleExecInfo_t *rei)
00777 {
00778 rsComm_t *rsComm;
00779 dataObjInp_t dataObjInp, *myDataObjInp;
00780 char *outBadKeyWd = NULL;
00781 int validKwFlags;
00782
00783 RE_TEST_MACRO (" Calling msiDataObjUnlink")
00784
00785 if (rei == NULL || rei->rsComm == NULL) {
00786 rodsLog (LOG_ERROR,
00787 "msiDataObjUnlink: input rei or rsComm is NULL");
00788 return (SYS_INTERNAL_NULL_INPUT_ERR);
00789 }
00790
00791 rsComm = rei->rsComm;
00792
00793
00794 if (strcmp (inpParam->type, STR_MS_T) == 0) {
00795 bzero (&dataObjInp, sizeof (dataObjInp));
00796 myDataObjInp = &dataObjInp;
00797 validKwFlags = OBJ_PATH_FLAG | FORCE_FLAG_FLAG | REPL_NUM_FLAG |
00798 IRODS_RMTRASH_FLAG | IRODS_ADMIN_RMTRASH_FLAG;
00799 rei->status = parseMsKeyValStrForDataObjInp (inpParam, myDataObjInp,
00800 OBJ_PATH_KW, validKwFlags, &outBadKeyWd);
00801 } else {
00802 rei->status = parseMspForDataObjInp (inpParam, &dataObjInp,
00803 &myDataObjInp, 0);
00804 }
00805
00806 if (rei->status < 0) {
00807 if (outBadKeyWd != NULL) {
00808 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00809 "msiDataObjUnlink: input keyWd - %s error. status = %d",
00810 outBadKeyWd, rei->status);
00811 free (outBadKeyWd);
00812 } else {
00813 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00814 "msiDataObjUnlink: input msKeyValStr error. status = %d",
00815 rei->status);
00816 }
00817 return (rei->status);
00818 }
00819
00820 rei->status = rsDataObjUnlink (rsComm, myDataObjInp);
00821 if (rei->status >= 0) {
00822 fillIntInMsParam (outParam, rei->status);
00823 } else {
00824 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00825 "msiDataObjUnlink: rsDataObjUnlink failed for %s, status = %d",
00826 myDataObjInp->objPath,
00827 rei->status);
00828 }
00829
00830 return (rei->status);
00831 }
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900 int
00901 msiDataObjRepl (msParam_t *inpParam1, msParam_t *msKeyValStr,
00902 msParam_t *outParam, ruleExecInfo_t *rei)
00903 {
00904 rsComm_t *rsComm;
00905 dataObjInp_t dataObjInp, *myDataObjInp;
00906 transferStat_t *transStat = NULL;
00907 char *outBadKeyWd;
00908 int validKwFlags;
00909
00910 RE_TEST_MACRO (" Calling msiDataObjRepl")
00911
00912 if (rei == NULL || rei->rsComm == NULL) {
00913 rodsLog (LOG_ERROR,
00914 "msiDataObjRepl: input rei or rsComm is NULL");
00915 return (SYS_INTERNAL_NULL_INPUT_ERR);
00916 }
00917
00918 rsComm = rei->rsComm;
00919
00920
00921 rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
00922 &myDataObjInp, 0);
00923
00924 if (rei->status < 0) {
00925 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00926 "msiDataObjRepl: input inpParam1 error. status = %d", rei->status);
00927 return (rei->status);
00928 }
00929
00930 #if 0
00931 rei->status = parseMspForCondInp (inpParam2, &myDataObjInp->condInput,
00932 DEST_RESC_NAME_KW);
00933 #else
00934 validKwFlags = OBJ_PATH_FLAG | DEST_RESC_NAME_FLAG | NUM_THREADS_FLAG |
00935 BACKUP_RESC_NAME_FLAG | RESC_NAME_FLAG | UPDATE_REPL_FLAG |
00936 REPL_NUM_FLAG | ALL_FLAG | IRODS_ADMIN_FLAG | VERIFY_CHKSUM_FLAG |
00937 RBUDP_TRANSFER_FLAG | RBUDP_SEND_RATE_FLAG | RBUDP_PACK_SIZE_FLAG;
00938 rei->status = parseMsKeyValStrForDataObjInp (msKeyValStr, myDataObjInp,
00939 DEST_RESC_NAME_KW, validKwFlags, &outBadKeyWd);
00940 #endif
00941
00942 if (rei->status < 0) {
00943 if (outBadKeyWd != NULL) {
00944 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00945 "msiDataObjRepl: input keyWd - %s error. status = %d",
00946 outBadKeyWd, rei->status);
00947 free (outBadKeyWd);
00948 } else {
00949 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00950 "msiDataObjRepl: input msKeyValStr error. status = %d",
00951 rei->status);
00952 }
00953 return (rei->status);
00954 }
00955
00956 rei->status = rsDataObjRepl (rsComm, myDataObjInp, &transStat);
00957
00958 if (myDataObjInp == &dataObjInp) {
00959 clearKeyVal (&myDataObjInp->condInput);
00960 }
00961
00962 if (transStat != NULL) {
00963 free (transStat);
00964 }
00965
00966 if (rei->status >= 0) {
00967 fillIntInMsParam (outParam, rei->status);
00968 } else {
00969 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
00970 "msiDataObjRepl: rsDataObjRepl failed %s, status = %d",
00971 myDataObjInp->objPath,
00972 rei->status);
00973 }
00974
00975 return (rei->status);
00976 }
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032 int
01033 msiDataObjCopy (msParam_t *inpParam1, msParam_t *inpParam2,
01034 msParam_t *msKeyValStr, msParam_t *outParam, ruleExecInfo_t *rei)
01035 {
01036 rsComm_t *rsComm;
01037 dataObjCopyInp_t dataObjCopyInp, *myDataObjCopyInp;
01038 dataObjInp_t *myDataObjInp;
01039 transferStat_t *transStat = NULL;
01040 char *outBadKeyWd;
01041 int validKwFlags;
01042
01043 RE_TEST_MACRO (" Calling msiDataObjCopy")
01044
01045 if (rei == NULL || rei->rsComm == NULL) {
01046 rodsLog (LOG_ERROR,
01047 "msiDataObjCopy: input rei or rsComm is NULL");
01048 return (SYS_INTERNAL_NULL_INPUT_ERR);
01049 }
01050
01051 rsComm = rei->rsComm;
01052
01053 rei->status = parseMspForDataObjCopyInp( inpParam1, &dataObjCopyInp, &myDataObjCopyInp );
01054
01055
01056 if (rei->status < 0) {
01057 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01058 "msiDataObjCopy: input inpParam1 error. status = %d", rei->status);
01059 return (rei->status);
01060 }
01061
01062
01063 rei->status = parseMspForDataObjInp (inpParam2, &myDataObjCopyInp->destDataObjInp, &myDataObjInp, 1);
01064
01065
01066 if (rei->status < 0) {
01067 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01068 "msiDataObjCopy: input inpParam2 error. status = %d", rei->status);
01069 return (rei->status);
01070 }
01071
01072 #if 0
01073 rei->status = parseMspForCondInp (inpParam3,
01074 &myDataObjCopyInp->destDataObjInp.condInput, DEST_RESC_NAME_KW);
01075 #else
01076 validKwFlags = OBJ_PATH_FLAG | DEST_RESC_NAME_FLAG | FILE_PATH_FLAG |
01077 DATA_TYPE_FLAG | VERIFY_CHKSUM_FLAG |
01078 FORCE_FLAG_FLAG | NUM_THREADS_FLAG;
01079 rei->status = parseMsKeyValStrForDataObjInp( msKeyValStr, &myDataObjCopyInp->destDataObjInp,
01080 DEST_RESC_NAME_KW, validKwFlags, &outBadKeyWd);
01081
01082 #endif
01083
01084 if (rei->status < 0) {
01085 if (outBadKeyWd != NULL) {
01086 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01087 "msiDataObjCopy: input keyWd - %s error. status = %d",
01088 outBadKeyWd, rei->status);
01089 free (outBadKeyWd);
01090 } else {
01091 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01092 "msiDataObjCopy: input msKeyValStr error. status = %d",
01093 rei->status);
01094 }
01095 return (rei->status);
01096 }
01097
01098 if (rei->status < 0) {
01099 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01100 "msiDataObjCopy: input inpParam2 error. status = %d", rei->status);
01101 return (rei->status);
01102 }
01103
01104 rei->status = rsDataObjCopy (rsComm, myDataObjCopyInp, &transStat);
01105 if (transStat != NULL) {
01106 free (transStat);
01107 }
01108
01109 if (myDataObjCopyInp == &dataObjCopyInp) {
01110 clearKeyVal (&myDataObjCopyInp->destDataObjInp.condInput);
01111 }
01112
01113 if (rei->status >= 0) {
01114 fillIntInMsParam (outParam, rei->status);
01115 } else {
01116 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01117 "msiDataObjCopy: rsDataObjCopy failed for %s, status = %d",
01118 myDataObjCopyInp->srcDataObjInp.objPath,
01119 rei->status);
01120 }
01121
01122 return (rei->status);
01123 }
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185 int
01186 msiDataObjPut (msParam_t *inpParam1, msParam_t *inpParam2,
01187 msParam_t *msKeyValStr, msParam_t *outParam, ruleExecInfo_t *rei)
01188 {
01189 rsComm_t *rsComm;
01190 dataObjInp_t *dataObjInp, *myDataObjInp;
01191 msParamArray_t *myMsParamArray;
01192 char *outBadKeyWd;
01193 int validKwFlags;
01194
01195 RE_TEST_MACRO (" Calling msiDataObjPut")
01196
01197 if (rei == NULL || rei->rsComm == NULL) {
01198 rodsLog (LOG_ERROR,
01199 "msiDataObjPut: input rei or rsComm is NULL");
01200 return (SYS_INTERNAL_NULL_INPUT_ERR);
01201 }
01202
01203 rsComm = rei->rsComm;
01204
01205 dataObjInp = (dataObjInp_t*)malloc (sizeof (dataObjInp_t));
01206 memset(dataObjInp, 0, sizeof (dataObjInp_t));
01207
01208
01209 rei->status = parseMspForDataObjInp (inpParam1, dataObjInp,
01210 &myDataObjInp, 1);
01211
01212 if (rei->status < 0) {
01213 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01214 "msiDataObjPut: input inpParam1 error. status = %d", rei->status);
01215 return (rei->status);
01216 }
01217
01218 rei->status = parseMspForCondInp (inpParam2, &dataObjInp->condInput,
01219 DEST_RESC_NAME_KW);
01220
01221 if (rei->status < 0) {
01222 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01223 "msiDataObjPut: input inpParam2 error. status = %d", rei->status);
01224 return (rei->status);
01225 }
01226
01227 #if 0
01228 rei->status = parseMspForCondInp (inpParam3, &dataObjInp->condInput,
01229 LOCAL_PATH_KW);
01230 #else
01231 validKwFlags = LOCAL_PATH_FLAG | DEST_RESC_NAME_FLAG | FILE_PATH_FLAG |
01232 REPL_NUM_FLAG | DATA_TYPE_FLAG | VERIFY_CHKSUM_FLAG |
01233 ALL_FLAG | FORCE_FLAG_FLAG | NUM_THREADS_FLAG | OBJ_PATH_FLAG;
01234 rei->status = parseMsKeyValStrForDataObjInp (msKeyValStr, dataObjInp,
01235 LOCAL_PATH_KW, validKwFlags, &outBadKeyWd);
01236 #endif
01237
01238 if (rei->status < 0) {
01239 if (outBadKeyWd != NULL) {
01240 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01241 "msiDataObjPut: input keyWd - %s error. status = %d",
01242 outBadKeyWd, rei->status);
01243 free (outBadKeyWd);
01244 } else {
01245 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01246 "msiDataObjPut: input msKeyValStr error. status = %d",
01247 rei->status);
01248 }
01249 return (rei->status);
01250 }
01251
01252 myMsParamArray = (msParamArray_t*)malloc (sizeof (msParamArray_t));
01253 memset (myMsParamArray, 0, sizeof (msParamArray_t));
01254
01255 rei->status = addMsParam (myMsParamArray, CL_PUT_ACTION, DataObjInp_MS_T,
01256 (void *) dataObjInp, NULL);
01257
01258 if (rei->status < 0) {
01259 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01260 "msiDataObjPut: addMsParam error. status = %d", rei->status);
01261 return (rei->status);
01262 }
01263
01264
01265 rei->status = sendAndRecvBranchMsg (rsComm, rsComm->apiInx,
01266 SYS_SVR_TO_CLI_MSI_REQUEST, (void *) myMsParamArray, NULL);
01267
01268 if (rei->status >= 0) {
01269 fillIntInMsParam (outParam, rei->status);
01270 } else {
01271 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01272 "msiDataObjPut: rsDataObjPut failed for %s, status = %d",
01273 dataObjInp->objPath,
01274 rei->status);
01275 }
01276
01277 return (rei->status);
01278 }
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335 int
01336 msiDataObjGet (msParam_t *inpParam1, msParam_t *msKeyValStr,
01337 msParam_t *outParam, ruleExecInfo_t *rei)
01338 {
01339 rsComm_t *rsComm;
01340 dataObjInp_t *dataObjInp, *myDataObjInp;
01341 msParamArray_t *myMsParamArray;
01342 char *outBadKeyWd;
01343 int validKwFlags;
01344
01345 RE_TEST_MACRO (" Calling msiDataObjGet")
01346
01347 if (rei == NULL || rei->rsComm == NULL) {
01348 rodsLog (LOG_ERROR,
01349 "msiDataObjGet: input rei or rsComm is NULL");
01350 return (SYS_INTERNAL_NULL_INPUT_ERR);
01351 }
01352
01353 rsComm = rei->rsComm;
01354
01355 dataObjInp = (dataObjInp_t*)malloc (sizeof (dataObjInp_t));
01356
01357 rei->status = parseMspForDataObjInp (inpParam1, dataObjInp,
01358 &myDataObjInp, 1);
01359
01360 if (rei->status < 0) {
01361 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01362 "msiDataObjGet: input inpParam1 error. status = %d",
01363 rei->status);
01364 return (rei->status);
01365 }
01366
01367 #if 0
01368 rei->status = parseMspForCondInp (inpParam2, &dataObjInp->condInput,
01369 LOCAL_PATH_KW);
01370 #else
01371 validKwFlags = LOCAL_PATH_FLAG | FORCE_FLAG_FLAG | NUM_THREADS_FLAG |
01372 RESC_NAME_FLAG | REPL_NUM_FLAG | VERIFY_CHKSUM_FLAG | OBJ_PATH_FLAG;
01373 rei->status = parseMsKeyValStrForDataObjInp (msKeyValStr, dataObjInp,
01374 LOCAL_PATH_KW, validKwFlags, &outBadKeyWd);
01375 #endif
01376
01377 if (rei->status < 0) {
01378 if (outBadKeyWd != NULL) {
01379 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01380 "msiDataObjGet: input keyWd - %s error. status = %d",
01381 outBadKeyWd, rei->status);
01382 free (outBadKeyWd);
01383 } else {
01384 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01385 "msiDataObjGet: input msKeyValStr error. status = %d",
01386 rei->status);
01387 }
01388 return (rei->status);
01389 }
01390
01391 myMsParamArray = (msParamArray_t*)malloc (sizeof (msParamArray_t));
01392 memset (myMsParamArray, 0, sizeof (msParamArray_t));
01393
01394 rei->status = addMsParam (myMsParamArray, CL_GET_ACTION, DataObjInp_MS_T,
01395 (void *) dataObjInp, NULL);
01396
01397 if (rei->status < 0) {
01398 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01399 "msiDataObjGet: addMsParam error. status = %d",
01400 rei->status);
01401 return (rei->status);
01402 }
01403
01404
01405 rei->status = sendAndRecvBranchMsg (rsComm, rsComm->apiInx,
01406 SYS_SVR_TO_CLI_MSI_REQUEST, (void *) myMsParamArray, NULL);
01407
01408 if (rei->status >= 0) {
01409 fillIntInMsParam (outParam, rei->status);
01410 } else {
01411 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01412 "msiDataObjGet: rsDataObjGet failed for %s, status = %d",
01413 dataObjInp->objPath, rei->status);
01414 }
01415
01416 return (rei->status);
01417 }
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463 int
01464 msiDataObjGetWithOptions (msParam_t *inpParam1, msParam_t *inpParam2,
01465 msParam_t *srcrescParam, msParam_t *outParam, ruleExecInfo_t *rei)
01466 {
01467 rsComm_t *rsComm;
01468 dataObjInp_t *dataObjInp, *myDataObjInp;
01469 msParamArray_t *myMsParamArray;
01470
01471 RE_TEST_MACRO (" Calling msiDataObjGetWithOptions")
01472
01473 if (rei == NULL || rei->rsComm == NULL) {
01474 rodsLog (LOG_ERROR,
01475 "msiDataObjGetWithOptions: input rei or rsComm is NULL");
01476 return (SYS_INTERNAL_NULL_INPUT_ERR);
01477 }
01478
01479 rsComm = rei->rsComm;
01480
01481 dataObjInp = (dataObjInp_t*)malloc (sizeof (dataObjInp_t));
01482
01483 rei->status = parseMspForDataObjInp (inpParam1, dataObjInp,
01484 &myDataObjInp, 1);
01485
01486 if (rei->status < 0) {
01487 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01488 "msiDataObjGetWithOptions: input inpParam1 error. status = %d",
01489 rei->status);
01490 return (rei->status);
01491 }
01492
01493 rei->status = parseMspForCondInp (inpParam2, &dataObjInp->condInput,
01494 LOCAL_PATH_KW);
01495
01496 if (rei->status < 0) {
01497 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01498 "msiDataObjGetWithOptions: input inpParam2 error. status = %d",
01499 rei->status);
01500 return (rei->status);
01501 }
01502
01503 rei->status = parseMspForCondInp (srcrescParam, &dataObjInp->condInput,
01504 RESC_NAME_KW);
01505
01506 if (rei->status < 0) {
01507 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01508 "msiDataObjGetWithOptions: input srcrescParam error. status = %d",
01509 rei->status);
01510 return (rei->status);
01511 }
01512
01513 myMsParamArray = (msParamArray_t*)malloc (sizeof (msParamArray_t));
01514 memset (myMsParamArray, 0, sizeof (msParamArray_t));
01515
01516 rei->status = addMsParam (myMsParamArray, CL_GET_ACTION, DataObjInp_MS_T,
01517 (void *) dataObjInp, NULL);
01518
01519 if (rei->status < 0) {
01520 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01521 "msiDataObjGetWithOptions: addMsParam error. status = %d",
01522 rei->status);
01523 return (rei->status);
01524 }
01525
01526
01527 rei->status = sendAndRecvBranchMsg (rsComm, rsComm->apiInx,
01528 SYS_SVR_TO_CLI_MSI_REQUEST, (void *) myMsParamArray, NULL);
01529
01530 if (rei->status >= 0) {
01531 fillIntInMsParam (outParam, rei->status);
01532 } else {
01533 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01534 "msiDataObjGetWithOptions: rsDataObjGet failed, status = %d",
01535 rei->status);
01536 }
01537
01538 return (rei->status);
01539 }
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585 int
01586 msiDataObjChksum (msParam_t *inpParam1, msParam_t *msKeyValStr,
01587 msParam_t *outParam, ruleExecInfo_t *rei)
01588 {
01589 rsComm_t *rsComm;
01590 dataObjInp_t dataObjInp, *myDataObjInp;
01591 char *chksum = NULL;
01592 char *outBadKeyWd;
01593 int validKwFlags;
01594
01595 RE_TEST_MACRO (" Calling msiDataObjChksum")
01596
01597 if (rei == NULL || rei->rsComm == NULL) {
01598 rodsLog (LOG_ERROR,
01599 "msiDataObjChksum: input rei or rsComm is NULL");
01600 return (SYS_INTERNAL_NULL_INPUT_ERR);
01601 }
01602
01603 rsComm = rei->rsComm;
01604
01605
01606 rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
01607 &myDataObjInp, 1);
01608
01609 if (rei->status < 0) {
01610 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01611 "msiDataObjChksum: input inpParam1 error. status = %d", rei->status);
01612 return (rei->status);
01613 }
01614
01615 #if 0
01616 if ((rei->status = parseMspForCondKw (inpParam2, &myDataObjInp->condInput))
01617 < 0) {
01618 #else
01619 validKwFlags = CHKSUM_ALL_FLAG | FORCE_CHKSUM_FLAG | REPL_NUM_FLAG |
01620 OBJ_PATH_FLAG | VERIFY_CHKSUM_FLAG;
01621 if ((rei->status = parseMsKeyValStrForDataObjInp (msKeyValStr,
01622 myDataObjInp, KEY_WORD_KW, validKwFlags, &outBadKeyWd)) < 0) {
01623 #endif
01624 if (outBadKeyWd != NULL) {
01625 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01626 "msiDataObjChksum: input keyWd - %s error. status = %d",
01627 outBadKeyWd, rei->status);
01628 free (outBadKeyWd);
01629 } else {
01630 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01631 "msiDataObjChksum: input msKeyValStr error. status = %d",
01632 rei->status);
01633 }
01634 return (rei->status);
01635 }
01636
01637 rei->status = rsDataObjChksum (rsComm, myDataObjInp, &chksum);
01638
01639 if (myDataObjInp == &dataObjInp) {
01640 clearKeyVal (&myDataObjInp->condInput);
01641 }
01642
01643 if (rei->status >= 0) {
01644 fillStrInMsParam (outParam, chksum);
01645 free (chksum);
01646 } else {
01647 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01648 "msiDataObjChksum: rsDataObjChksum failed for %s, status = %d",
01649 myDataObjInp->objPath ,
01650 rei->status);
01651 }
01652
01653 return (rei->status);
01654 }
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691
01692
01693
01694
01695 int
01696 msiDataObjPhymv (msParam_t *inpParam1, msParam_t *inpParam2,
01697 msParam_t *inpParam3, msParam_t *inpParam4, msParam_t *inpParam5,
01698 msParam_t *outParam, ruleExecInfo_t *rei)
01699 {
01700 rsComm_t *rsComm;
01701 dataObjInp_t dataObjInp, *myDataObjInp;
01702 transferStat_t *transStat = NULL;
01703
01704 RE_TEST_MACRO (" Calling msiDataObjPhymv")
01705
01706 if (rei == NULL || rei->rsComm == NULL) {
01707 rodsLog (LOG_ERROR,
01708 "msiDataObjPhymv: input rei or rsComm is NULL");
01709 return (SYS_INTERNAL_NULL_INPUT_ERR);
01710 }
01711
01712 rsComm = rei->rsComm;
01713
01714
01715
01716 if ((rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
01717 &myDataObjInp, 0)) < 0) {
01718 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01719 "msiDataObjPhymv: input inpParam1 error. status = %d", rei->status);
01720 return (rei->status);
01721 }
01722
01723 if ((rei->status = parseMspForCondInp (inpParam2, &myDataObjInp->condInput,
01724 DEST_RESC_NAME_KW)) < 0) {
01725 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01726 "msiDataObjPhymv: input inpParam2 error. status = %d", rei->status);
01727 return (rei->status);
01728 }
01729
01730 if ((rei->status = parseMspForCondInp (inpParam3, &myDataObjInp->condInput,
01731 RESC_NAME_KW)) < 0) {
01732 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01733 "msiDataObjPhymv: input inpParam3 error. status = %d", rei->status);
01734 return (rei->status);
01735 }
01736
01737 if ((rei->status = parseMspForCondInp (inpParam4, &myDataObjInp->condInput,
01738 REPL_NUM_KW)) < 0) {
01739 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01740 "msiDataObjPhymv: input inpParam4 error. status = %d", rei->status);
01741 return (rei->status);
01742 }
01743
01744 if ((rei->status = parseMspForCondInp (inpParam5, &myDataObjInp->condInput,
01745 IRODS_ADMIN_KW)) < 0) {
01746 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01747 "msiDataObjPhymv: input inpParam5 error. status = %d", rei->status);
01748 return (rei->status);
01749 }
01750
01751 rei->status = rsDataObjPhymv (rsComm, myDataObjInp, &transStat);
01752
01753 if (transStat != NULL) {
01754 free (transStat);
01755 }
01756
01757 if (myDataObjInp == &dataObjInp) {
01758 clearKeyVal (&myDataObjInp->condInput);
01759 }
01760
01761 if (rei->status >= 0) {
01762 fillIntInMsParam (outParam, rei->status);
01763 } else {
01764 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01765 "msiDataObjPhymv: rsDataObjPhymv failed for %s, status = %d",
01766 myDataObjInp->objPath,
01767 rei->status);
01768 }
01769
01770 return (rei->status);
01771 }
01772
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811 int
01812 msiDataObjRename (msParam_t *inpParam1, msParam_t *inpParam2,
01813 msParam_t *inpParam3, msParam_t *outParam, ruleExecInfo_t *rei)
01814 {
01815 rsComm_t *rsComm;
01816 dataObjCopyInp_t dataObjRenameInp, *myDataObjRenameInp;
01817 dataObjInp_t *myDataObjInp;
01818
01819 RE_TEST_MACRO (" Calling msiDataObjRename")
01820
01821 if (rei == NULL || rei->rsComm == NULL) {
01822 rodsLog (LOG_ERROR,
01823 "msiDataObjRename: input rei or rsComm is NULL");
01824 return (SYS_INTERNAL_NULL_INPUT_ERR);
01825 }
01826
01827 rsComm = rei->rsComm;
01828
01829
01830 rei->status = parseMspForDataObjCopyInp (inpParam1, &dataObjRenameInp,
01831 &myDataObjRenameInp);
01832
01833 if (rei->status < 0) {
01834 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01835 "msiDataObjRename: input inpParam1 error. status = %d", rei->status);
01836 return (rei->status);
01837 }
01838
01839
01840 rei->status = parseMspForDataObjInp (inpParam2,
01841 &myDataObjRenameInp->destDataObjInp, &myDataObjInp, 1);
01842
01843 if (rei->status < 0) {
01844 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01845 "msiDataObjRename: input inpParam2 error. status = %d", rei->status);
01846 return (rei->status);
01847 }
01848
01849 if (inpParam3 != NULL) {
01850 int myInt;
01851 myInt = parseMspForPosInt (inpParam3);
01852 if (myInt > 0) {
01853 myDataObjRenameInp->srcDataObjInp.oprType = RENAME_COLL;
01854 } else {
01855 myDataObjRenameInp->srcDataObjInp.oprType = RENAME_DATA_OBJ;
01856 }
01857 }
01858
01859 rei->status = rsDataObjRename (rsComm, myDataObjRenameInp);
01860
01861 if (rei->status >= 0) {
01862 fillIntInMsParam (outParam, rei->status);
01863 } else {
01864 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01865 "msiDataObjRename: rsDataObjRename failed for %s, status = %d",
01866 myDataObjRenameInp->srcDataObjInp.objPath,
01867 rei->status);
01868 }
01869
01870 return (rei->status);
01871 }
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910
01911
01912 int
01913 msiDataObjTrim (msParam_t *inpParam1, msParam_t *inpParam2,
01914 msParam_t *inpParam3, msParam_t *inpParam4, msParam_t *inpParam5,
01915 msParam_t *outParam, ruleExecInfo_t *rei)
01916 {
01917 rsComm_t *rsComm;
01918 dataObjInp_t dataObjInp, *myDataObjInp;
01919
01920 RE_TEST_MACRO (" Calling msiDataObjTrim")
01921
01922 if (rei == NULL || rei->rsComm == NULL) {
01923 rodsLog (LOG_ERROR,
01924 "msiDataObjTrim: input rei or rsComm is NULL");
01925 return (SYS_INTERNAL_NULL_INPUT_ERR);
01926 }
01927
01928 rsComm = rei->rsComm;
01929
01930
01931
01932 if ((rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
01933 &myDataObjInp, 0)) < 0) {
01934 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01935 "msiDataObjTrim: input inpParam1 error. status = %d", rei->status);
01936 return (rei->status);
01937 }
01938
01939 if ((rei->status = parseMspForCondInp (inpParam2, &myDataObjInp->condInput, RESC_NAME_KW)) < 0) {
01940 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01941 "msiDataObjTrim: input inpParam2 error. status = %d", rei->status);
01942 return (rei->status);
01943 }
01944
01945 if ((rei->status = parseMspForCondInp (inpParam3, &myDataObjInp->condInput,
01946 REPL_NUM_KW)) < 0) {
01947 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01948 "msiDataObjTrim: input inpParam3 error. status = %d", rei->status);
01949 return (rei->status);
01950 }
01951
01952 if ((rei->status = parseMspForCondInp (inpParam4, &myDataObjInp->condInput,
01953 COPIES_KW)) < 0) {
01954 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01955 "msiDataObjTrim: input inpParam4 error. status = %d", rei->status);
01956 return (rei->status);
01957 }
01958
01959 if ((rei->status = parseMspForCondInp (inpParam5, &myDataObjInp->condInput,
01960 IRODS_ADMIN_KW)) < 0) {
01961 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01962 "msiDataObjTrim: input inpParam5 error. status = %d", rei->status);
01963 return (rei->status);
01964 }
01965
01966 rei->status = rsDataObjTrim (rsComm, myDataObjInp);
01967
01968 if (myDataObjInp == &dataObjInp) {
01969 clearKeyVal (&myDataObjInp->condInput);
01970 }
01971
01972 if (rei->status >= 0) {
01973 fillIntInMsParam (outParam, rei->status);
01974 } else {
01975 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01976 "msiDataObjTrim: rsDataObjTrim failed for %s, status = %d",
01977 myDataObjInp->objPath,
01978 rei->status);
01979 }
01980
01981 return (rei->status);
01982 }
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020 int
02021 msiCollCreate (msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *outParam, ruleExecInfo_t *rei)
02022 {
02023 rsComm_t *rsComm;
02024 collInp_t collCreateInp, *myCollCreateInp;
02025 int flags;
02026
02027 RE_TEST_MACRO (" Calling msiCollCreate")
02028
02029 if (rei == NULL || rei->rsComm == NULL) {
02030 rodsLog (LOG_ERROR,
02031 "msiCollCreate: input rei or rsComm is NULL");
02032 return (SYS_INTERNAL_NULL_INPUT_ERR);
02033 }
02034
02035 rsComm = rei->rsComm;
02036
02037
02038 rei->status = parseMspForCollInp (inpParam1, &collCreateInp,
02039 &myCollCreateInp, 1);
02040
02041 if (rei->status < 0) {
02042 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02043 "msiCollCreate: input inpParam1 error. status = %d", rei->status);
02044 return (rei->status);
02045 }
02046
02047 flags = parseMspForPosInt (inpParam2);
02048
02049 if (flags > 0)
02050 addKeyVal (&collCreateInp.condInput, RECURSIVE_OPR__KW, "");
02051 rei->status = rsCollCreate (rsComm, myCollCreateInp);
02052
02053 if (rei->status >= 0) {
02054 fillIntInMsParam (outParam, rei->status);
02055 } else {
02056 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02057 "msiCollCreate: rsCollCreate failed %s, status = %d",
02058 collCreateInp.collName,
02059 rei->status);
02060 }
02061
02062 if (myCollCreateInp == &collCreateInp) {
02063 clearKeyVal (&myCollCreateInp->condInput);
02064 }
02065
02066 return (rei->status);
02067 }
02068
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082
02083
02084
02085
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114 int
02115 msiRmColl (msParam_t *inpParam1, msParam_t *msKeyValStr, msParam_t *outParam, ruleExecInfo_t *rei)
02116 {
02117 rsComm_t *rsComm;
02118 collInp_t rmCollInp, *myRmCollInp;
02119 char *outBadKeyWd;
02120 int validKwFlags;
02121
02122 RE_TEST_MACRO (" Calling msiRmColl")
02123
02124 if (rei == NULL || rei->rsComm == NULL) {
02125 rodsLog (LOG_ERROR,
02126 "msiRmColl: input rei or rsComm is NULL");
02127 return (SYS_INTERNAL_NULL_INPUT_ERR);
02128 }
02129
02130 rsComm = rei->rsComm;
02131
02132
02133 rei->status = parseMspForCollInp (inpParam1, &rmCollInp,
02134 &myRmCollInp, 1);
02135
02136 if (rei->status < 0) {
02137 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02138 "msiRmColl: input inpParam1 error. status = %d", rei->status);
02139 return (rei->status);
02140 }
02141
02142 #if 0
02143 if ((rei->status = parseMspForCondKw (inpParam2, &myRmCollInp->condInput))
02144 < 0) {
02145 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02146 "msiRmColl: input inpParam2 error. status = %d", rei->status);
02147 return (rei->status);
02148 }
02149 #else
02150 validKwFlags = IRODS_RMTRASH_FLAG | IRODS_ADMIN_RMTRASH_FLAG |
02151 FORCE_FLAG_FLAG | COLL_NAME_FLAG;
02152 if ((rei->status = parseMsKeyValStrForCollInp (msKeyValStr,
02153 myRmCollInp, KEY_WORD_KW, validKwFlags, &outBadKeyWd)) < 0) {
02154 if (outBadKeyWd != NULL) {
02155 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02156 "msiRmColl: input keyWd - %s error. status = %d",
02157 outBadKeyWd, rei->status);
02158 free (outBadKeyWd);
02159 } else {
02160 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02161 "msiRmColl: input msKeyValStr error. status = %d",
02162 rei->status);
02163 }
02164 return (rei->status);
02165 }
02166 #endif
02167
02168 addKeyVal (&myRmCollInp->condInput, RECURSIVE_OPR__KW, "");
02169
02170 rei->status = rsRmColl (rsComm, myRmCollInp, NULL);
02171
02172 if (rei->status >= 0) {
02173 fillIntInMsParam (outParam, rei->status);
02174 } else {
02175 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02176 "msiRmColl: rsRmColl failed for %s, status = %d",
02177 myRmCollInp->collName,
02178 rei->status);
02179 }
02180
02181 if (myRmCollInp == &rmCollInp) {
02182 clearKeyVal (&myRmCollInp->condInput);
02183 }
02184
02185 return (rei->status);
02186 }
02187
02188
02189
02190
02191
02192
02193
02194
02195
02196
02197
02198
02199
02200
02201
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237 int
02238 msiReplColl (msParam_t *coll, msParam_t *destRescName, msParam_t *options,
02239 msParam_t *outParam, ruleExecInfo_t *rei)
02240 {
02241 rsComm_t *rsComm;
02242 collInp_t collInp, *myCollInp;
02243 int i, continueInx, status;
02244 transferStat_t *transStat = NULL;
02245 strArray_t optArray;
02246 genQueryInp_t genQueryInp;
02247 genQueryOut_t *genQueryOut = NULL;
02248 dataObjInp_t dataObjInp;
02249
02250 RE_TEST_MACRO (" Calling msiReplColl")
02251
02252 if (rei == NULL || rei->rsComm == NULL) {
02253 rodsLog (LOG_ERROR,
02254 "msiReplColl: input rei or rsComm is NULL");
02255 return (SYS_INTERNAL_NULL_INPUT_ERR);
02256 }
02257
02258 rsComm = rei->rsComm;
02259
02260
02261 rei->status = parseMspForCollInp (coll, &collInp,
02262 &myCollInp, 0);
02263 if (rei->status < 0) {
02264 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02265 "msiReplColl: input inpParam1 error. status = %d", rei->status);
02266 return (rei->status);
02267 }
02268
02269
02270
02271 memset (&dataObjInp, 0, sizeof (dataObjInp_t));
02272 rei->status = parseMspForCondInp (destRescName,
02273 &(&dataObjInp)->condInput, DEST_RESC_NAME_KW);
02274 if (rei->status < 0) {
02275 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02276 "msiReplColl: input inpParam2 error. status = %d", rei->status);
02277 return (rei->status);
02278 }
02279
02280
02281
02282 if ( (strlen((char*)options->inOutStruct)>0) &&
02283 (0!=strcmp((char*)options->inOutStruct,"null")) )
02284 {
02285 memset (&optArray, 0, sizeof (optArray));
02286 status = parseMultiStr ((char *)options->inOutStruct, &optArray);
02287 if (status <= 0)
02288 {
02289 rodsLog (LOG_ERROR,
02290 "msiReplColl: Could not parse options string '%s'",
02291 options->inOutStruct);
02292 }
02293 for(i=0; i<optArray.len; i++)
02294 {
02295 char *option;
02296 option= &optArray.value[i*optArray.size];
02297 if ( strcmp(option,ALL_KW) &&
02298 strcmp(option,IRODS_ADMIN_KW) &&
02299 strcmp(option,"backupMode")
02300 )
02301 {
02302 rodsLog (LOG_ERROR,"msiReplColl: invalid option: '%s'",option);
02303 continue;
02304 }
02305 if (strcmp(option,"backupMode")==0)
02306 addKeyVal (&(dataObjInp.condInput), BACKUP_RESC_NAME_KW,
02307 (char *)destRescName->inOutStruct);
02308 else
02309 addKeyVal (&(dataObjInp.condInput), option, "");
02310 }
02311 }
02312
02313
02314 memset (&genQueryInp, 0, sizeof (genQueryInp));
02315 status = rsQueryDataObjInCollReCur (rsComm, myCollInp->collName,
02316 &genQueryInp, &genQueryOut, NULL, 1);
02317 if (status < 0 && status != CAT_NO_ROWS_FOUND) {
02318 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02319 "msiReplColl: msiReplColl error for %s, stat=%d",
02320 myCollInp->collName, status);
02321 rei->status=status;
02322 return (rei->status);
02323 }
02324 while (rei->status >= 0) {
02325 sqlResult_t *subColl, *dataObj;
02326
02327 if ((subColl = getSqlResultByInx (genQueryOut, COL_COLL_NAME))
02328 == NULL) {
02329 rodsLog (LOG_ERROR,
02330 "msiReplColl: msiReplColl for COL_COLL_NAME failed");
02331 rei->status=UNMATCHED_KEY_OR_INDEX;
02332 return (rei->status);
02333 }
02334
02335 if ((dataObj = getSqlResultByInx (genQueryOut, COL_DATA_NAME))
02336 == NULL) {
02337 rodsLog (LOG_ERROR,
02338 "msiReplColl: msiReplColl for COL_DATA_NAME failed");
02339 rei->status=UNMATCHED_KEY_OR_INDEX;
02340 return (rei->status);
02341 }
02342
02343 for (i = 0; i < genQueryOut->rowCnt; i++) {
02344 char *tmpSubColl, *tmpDataName;
02345
02346 tmpSubColl = &subColl->value[subColl->len * i];
02347 tmpDataName = &dataObj->value[dataObj->len * i];
02348 snprintf (dataObjInp.objPath, MAX_NAME_LEN, "%s/%s",tmpSubColl, tmpDataName);
02349
02350
02351
02352
02353 rmKeyVal( &dataObjInp.condInput, RESC_HIER_STR_KW );
02354 rmKeyVal( &dataObjInp.condInput, DEST_RESC_HIER_STR_KW );
02355
02356 rei->status = rsDataObjRepl (rsComm, &dataObjInp, &transStat);
02357 if (rei->status<0)
02358 {
02359 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02360 "msiReplColl: rsDataObjRepl failed %s, status = %d",
02361 (&dataObjInp)->objPath,
02362 rei->status);
02363 }
02364 if (transStat != NULL) {
02365 free (transStat);
02366 }
02367 }
02368
02369 continueInx = genQueryOut->continueInx;
02370 freeGenQueryOut (&genQueryOut);
02371 if (continueInx > 0) {
02372
02373 genQueryInp.continueInx = continueInx;
02374 rei->status = rsGenQuery (rsComm, &genQueryInp, &genQueryOut);
02375 } else {
02376 break;
02377 }
02378 }
02379
02380 clearKeyVal (&dataObjInp.condInput);
02381
02382 if (rei->status >= 0) {
02383 fillIntInMsParam (outParam, rei->status);
02384 } else {
02385 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02386 "dataObjInp: msiReplColl failed (should have catched earlier) %s, status = %d",
02387 (&dataObjInp)->objPath,
02388 rei->status);
02389 }
02390 return (rei->status);
02391 }
02392
02393
02394
02395
02396
02397
02398
02399
02400
02401
02402
02403
02404
02405
02406
02407
02408
02409
02410
02411
02412
02413
02414
02415
02416
02417
02418
02419
02420
02421
02422
02423
02424
02425
02426
02427
02428
02429
02430
02431
02432
02433
02434
02435
02436
02437 int
02438 msiPhyPathReg (msParam_t *inpParam1, msParam_t *inpParam2,
02439 msParam_t *inpParam3, msParam_t *inpParam4, msParam_t *outParam,
02440 ruleExecInfo_t *rei)
02441 {
02442 rsComm_t *rsComm;
02443 dataObjInp_t dataObjInp, *myDataObjInp;
02444
02445 RE_TEST_MACRO (" Calling msiPhyPathReg")
02446
02447 if (rei == NULL || rei->rsComm == NULL) {
02448 rodsLog (LOG_ERROR,
02449 "msiPhyPathReg: input rei or rsComm is NULL");
02450 return (SYS_INTERNAL_NULL_INPUT_ERR);
02451 }
02452
02453 rsComm = rei->rsComm;
02454
02455
02456 rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
02457 &myDataObjInp, 1);
02458
02459 if (rei->status < 0) {
02460 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02461 "msiPhyPathReg: input inpParam1 error. status = %d", rei->status);
02462 return (rei->status);
02463 }
02464
02465 if ((rei->status = parseMspForCondInp (inpParam2, &myDataObjInp->condInput,
02466 DEST_RESC_NAME_KW)) < 0) {
02467 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02468 "msiDataObjPhymv: input inpParam2 error. status = %d", rei->status);
02469 return (rei->status);
02470 }
02471
02472 if ((rei->status = parseMspForCondInp (inpParam3, &myDataObjInp->condInput,
02473 FILE_PATH_KW)) < 0) {
02474 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02475 "msiDataObjPhymv: input inpParam3 error. status = %d", rei->status);
02476 return (rei->status);
02477 }
02478
02479 if ((rei->status = parseMspForPhyPathReg (inpParam4,
02480 &myDataObjInp->condInput)) < 0) {
02481 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02482 "msiPhyPathReg: input inpParam4 error. status = %d", rei->status);
02483 return (rei->status);
02484 }
02485
02486 rei->status = rsPhyPathReg (rsComm, myDataObjInp);
02487
02488 if (myDataObjInp == &dataObjInp) {
02489 clearKeyVal (&myDataObjInp->condInput);
02490 }
02491
02492 if (rei->status >= 0) {
02493 fillIntInMsParam (outParam, rei->status);
02494 } else {
02495 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02496 "msiPhyPathReg: rsPhyPathReg failed for %s, status = %d",
02497 myDataObjInp->objPath,
02498 rei->status);
02499 }
02500
02501 return (rei->status);
02502 }
02503
02504
02505
02506
02507
02508
02509
02510
02511
02512
02513
02514
02515
02516
02517
02518
02519
02520
02521
02522
02523
02524
02525
02526
02527
02528
02529
02530
02531
02532
02533
02534
02535
02536
02537 int
02538 msiObjStat (msParam_t *inpParam1, msParam_t *outParam, ruleExecInfo_t *rei)
02539 {
02540 rsComm_t *rsComm;
02541 dataObjInp_t dataObjInp, *myDataObjInp;
02542 rodsObjStat_t *rodsObjStatOut = NULL;
02543
02544 RE_TEST_MACRO (" Calling msiObjStat")
02545
02546 if (rei == NULL || rei->rsComm == NULL) {
02547 rodsLog (LOG_ERROR,
02548 "msiObjStat: input rei or rsComm is NULL");
02549 return (SYS_INTERNAL_NULL_INPUT_ERR);
02550 }
02551
02552 rsComm = rei->rsComm;
02553
02554
02555 rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
02556 &myDataObjInp, 0);
02557
02558 if (rei->status < 0) {
02559 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02560 "msiObjStat: input inpParam1 error. status = %d", rei->status);
02561 return (rei->status);
02562 }
02563
02564 #if 0
02565 rei->status = __rsObjStat (rsComm, myDataObjInp, 1, &rodsObjStatOut);
02566 #endif
02567 rei->status = rsObjStat (rsComm, myDataObjInp, &rodsObjStatOut);
02568
02569 if (rei->status >= 0) {
02570 fillMsParam (outParam, NULL, RodsObjStat_MS_T, rodsObjStatOut, NULL);
02571 } else {
02572 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02573 "msiObjStat: rsObjStat failed for %s, status = %d",
02574 myDataObjInp->objPath,
02575 rei->status);
02576 }
02577
02578 return (rei->status);
02579 }
02580
02581
02582
02583
02584
02585
02586
02587
02588
02589
02590
02591
02592
02593
02594
02595
02596
02597
02598
02599
02600
02601
02602
02603
02604
02605
02606
02607
02608
02609
02610
02611
02612
02613
02614
02615
02616
02617
02618
02619
02620
02621
02622
02623
02624
02625
02626
02627
02628
02629
02630 int
02631 msiDataObjRsync (msParam_t *inpParam1, msParam_t *inpParam2,
02632 msParam_t *inpParam3, msParam_t *inpParam4, msParam_t *outParam,
02633 ruleExecInfo_t *rei)
02634 {
02635 rsComm_t *rsComm;
02636 dataObjInp_t dataObjInp, *myDataObjInp;
02637 msParamArray_t *outParamArray = NULL;
02638 char *rsyncMode;
02639 char *targCollection, *tmpPtr;
02640 char targPath[MAX_NAME_LEN];
02641
02642 RE_TEST_MACRO (" Calling msiDataObjRsync")
02643
02644 if (rei == NULL || rei->rsComm == NULL) {
02645 rodsLog (LOG_ERROR,
02646 "msiDataObjRsync: input rei or rsComm is NULL");
02647 return (SYS_INTERNAL_NULL_INPUT_ERR);
02648 }
02649
02650 rsComm = rei->rsComm;
02651
02652
02653 rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
02654 &myDataObjInp, 1);
02655
02656 if (rei->status < 0) {
02657 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02658 "msiDataObjRsync: input inpParam1 error. status = %d", rei->status);
02659 return (rei->status);
02660 }
02661
02662 if ((rei->status = parseMspForCondInp (inpParam2, &myDataObjInp->condInput,
02663 RSYNC_MODE_KW)) < 0) {
02664 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02665 "msiDataObjRsync: input inpParam2 error. status = %d", rei->status);
02666 return (rei->status);
02667 }
02668
02669
02670 if ((rei->status = parseMspForCondInp (inpParam3, &myDataObjInp->condInput,
02671 DEST_RESC_NAME_KW)) < 0) {
02672 #if 0
02673 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02674 "msiDataObjRsync: input inpParam3 error. status = %d", rei->status);
02675 return (rei->status);
02676 #endif
02677 }
02678
02679 if ((rei->status = parseMspForCondInp (inpParam4, &myDataObjInp->condInput,
02680 RSYNC_DEST_PATH_KW)) < 0) {
02681 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02682 "msiDataObjRsync: input inpParam4 error. status = %d", rei->status);
02683 return (rei->status);
02684 }
02685
02686
02687
02688
02689 rsyncMode = getValByKey (&myDataObjInp->condInput, RSYNC_MODE_KW);
02690 if (rsyncMode == NULL) {
02691 rodsLog (LOG_ERROR,
02692 "msiDataObjRsync: RSYNC_MODE_KW input is missing");
02693 rei->status = USER_RSYNC_NO_MODE_INPUT_ERR;
02694 return (rei->status);
02695 }
02696
02697 if (strcmp (rsyncMode, IRODS_TO_LOCAL) == 0 ||
02698 strcmp (rsyncMode, LOCAL_TO_IRODS) == 0) {
02699 rodsLog (LOG_ERROR,
02700 "msiDataObjRsync: local/iRODS rsync not supported for %s",
02701 myDataObjInp->objPath);
02702 rei->status = NO_LOCAL_FILE_RSYNC_IN_MSI;
02703 return (rei->status);
02704 } else if (strcmp (rsyncMode, IRODS_TO_COLLECTION) == 0) {
02705 targCollection = getValByKey (&myDataObjInp->condInput,
02706 RSYNC_DEST_PATH_KW);
02707 if (targCollection == NULL) {
02708 rodsLog (LOG_ERROR,
02709 "msiDataObjRsync: RSYNC_DEST_PATH_KW input for %s is missing",
02710 myDataObjInp->objPath);
02711 rei->status = USER_INPUT_PATH_ERR;
02712 return (rei->status);
02713 }
02714 tmpPtr = strchr (myDataObjInp->objPath + 1, '/');
02715 if (tmpPtr == NULL) {
02716 rodsLog (LOG_ERROR,
02717 "msiDataObjRsync: problem parsing %s", myDataObjInp->objPath);
02718 rei->status = USER_INPUT_PATH_ERR;
02719 return (rei->status);
02720 }
02721 snprintf (targPath, MAX_NAME_LEN, "%s%s", targCollection, tmpPtr);
02722 addKeyVal (&myDataObjInp->condInput, RSYNC_MODE_KW, IRODS_TO_IRODS);
02723 addKeyVal (&myDataObjInp->condInput, RSYNC_DEST_PATH_KW, targPath);
02724 }
02725
02726 rei->status = rsDataObjRsync (rsComm, myDataObjInp, &outParamArray);
02727
02728 if (outParamArray != NULL) {
02729 clearMsParamArray (outParamArray, 1);
02730 free (outParamArray);
02731 }
02732 if (myDataObjInp == &dataObjInp) {
02733 clearKeyVal (&myDataObjInp->condInput);
02734 }
02735
02736 if (rei->status >= 0) {
02737 fillIntInMsParam (outParam, rei->status);
02738 } else {
02739 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02740 "msiDataObjRsync: rsDataObjRsync failed for %s, status = %d",
02741 myDataObjInp->objPath,
02742 rei->status);
02743 }
02744
02745 return (rei->status);
02746 }
02747
02748
02749
02750
02751
02752
02753
02754
02755
02756
02757
02758
02759
02760
02761
02762
02763
02764
02765
02766
02767
02768
02769
02770
02771
02772
02773
02774
02775
02776
02777
02778
02779
02780
02781
02782
02783
02784
02785
02786
02787
02788 int
02789 msiCollRsync (msParam_t *inpParam1, msParam_t *inpParam2,
02790 msParam_t *inpParam3, msParam_t *inpParam4, msParam_t *outParam,
02791 ruleExecInfo_t *rei)
02792 {
02793 rsComm_t *rsComm;
02794 dataObjInp_t dataObjInp;
02795 char *rsyncMode;
02796 char *srcColl = NULL;
02797 char *destColl = NULL;
02798
02799 RE_TEST_MACRO (" Calling msiCollRsync")
02800
02801 if (rei == NULL || rei->rsComm == NULL) {
02802 rodsLog (LOG_ERROR,
02803 "msiCollRsync: input rei or rsComm is NULL");
02804 return (SYS_INTERNAL_NULL_INPUT_ERR);
02805 }
02806
02807 rsComm = rei->rsComm;
02808
02809 bzero (&dataObjInp, sizeof (dataObjInp));
02810
02811
02812 srcColl = parseMspForStr (inpParam1);
02813
02814 if (srcColl == NULL) {
02815 rei->status = SYS_INVALID_FILE_PATH;
02816 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02817 "msiCollRsync: input inpParam1 error. status = %d", rei->status);
02818 return (rei->status);
02819 }
02820
02821
02822 destColl = parseMspForStr (inpParam2);
02823
02824 if (destColl == NULL) {
02825 rei->status = SYS_INVALID_FILE_PATH;
02826 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02827 "msiCollRsync: input inpParam2 error. status = %d", rei->status);
02828 return (rei->status);
02829 }
02830
02831 if ((rei->status = parseMspForCondInp (inpParam3, &dataObjInp.condInput,
02832 DEST_RESC_NAME_KW)) < 0) {
02833 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02834 "msiCollRsync: input inpParam3 error. status = %d", rei->status);
02835 return (rei->status);
02836 }
02837
02838 if ((rei->status = parseMspForCondInp (inpParam4, &dataObjInp.condInput,
02839 RSYNC_MODE_KW)) < 0) {
02840 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02841 "msiCollRsync: input inpParam4 error. status = %d", rei->status);
02842 return (rei->status);
02843 }
02844
02845
02846
02847
02848 rsyncMode = getValByKey (&dataObjInp.condInput, RSYNC_MODE_KW);
02849 if (rsyncMode == NULL) {
02850 rodsLog (LOG_ERROR,
02851 "msiCollRsync: RSYNC_MODE_KW input is missing");
02852 rei->status = USER_RSYNC_NO_MODE_INPUT_ERR;
02853 return (rei->status);
02854 }
02855
02856 if (strcmp (rsyncMode, IRODS_TO_LOCAL) == 0 ||
02857 strcmp (rsyncMode, LOCAL_TO_IRODS) == 0) {
02858 rodsLog (LOG_ERROR,
02859 "msiCollRsync: local/iRODS rsync not supported for %s",
02860 srcColl);
02861 rei->status = NO_LOCAL_FILE_RSYNC_IN_MSI;
02862 return (rei->status);
02863 }
02864
02865 rei->status = _rsCollRsync (rsComm, &dataObjInp, srcColl, destColl);
02866
02867 clearKeyVal (&dataObjInp.condInput);
02868
02869 if (rei->status >= 0) {
02870 fillIntInMsParam (outParam, rei->status);
02871 } else {
02872 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02873 "msiCollRsync: rsDataObjRsync failed for %s, status = %d",
02874 srcColl,
02875 rei->status);
02876 }
02877
02878 return (rei->status);
02879 }
02880
02881 int
02882 _rsCollRsync (rsComm_t *rsComm, dataObjInp_t *dataObjInp,
02883 char *srcColl, char *destColl)
02884 {
02885 collInp_t openCollInp;
02886 collEnt_t *collEnt;
02887 int handleInx;
02888 char parPath[MAX_NAME_LEN], childPath[MAX_NAME_LEN];
02889 char destChildPath[MAX_NAME_LEN];
02890 msParamArray_t *outParamArray = NULL;
02891 int status = 0;
02892 int status1 = 0;
02893
02894 memset (&openCollInp, 0, sizeof (openCollInp));
02895 rstrcpy (openCollInp.collName, srcColl, MAX_NAME_LEN);
02896 openCollInp.flags = 0;
02897 handleInx = rsOpenCollection (rsComm, &openCollInp);
02898 if (handleInx < 0) {
02899 rodsLog (LOG_ERROR,
02900 "_rsCollRsync: rsOpenCollection of %s error. status = %d",
02901 openCollInp.collName, handleInx);
02902 return (handleInx);
02903 }
02904
02905 #if 0
02906 if (CollHandle[handleInx].rodsObjStat->specColl != NULL) {
02907 rodsLog (LOG_ERROR,
02908 "_rsCollRsync: unable to rsync mounted collection %s", srcColl);
02909 rsCloseCollection (rsComm, &handleInx);
02910 return (0);
02911 }
02912 #endif
02913
02914 rsMkCollR (rsComm, "/", destColl);
02915 while ((status1 = rsReadCollection (rsComm, &handleInx, &collEnt)) >= 0) {
02916 if (collEnt->objType == DATA_OBJ_T) {
02917 snprintf (dataObjInp->objPath, MAX_NAME_LEN, "%s/%s",
02918 srcColl, collEnt->dataName);
02919 snprintf (destChildPath, MAX_NAME_LEN, "%s/%s",
02920 destColl, collEnt->dataName);
02921 addKeyVal (&dataObjInp->condInput, RSYNC_DEST_PATH_KW,
02922 destChildPath);
02923 status = rsDataObjRsync (rsComm, dataObjInp, &outParamArray);
02924 if (outParamArray != NULL) {
02925 clearMsParamArray (outParamArray, 1);
02926 free (outParamArray);
02927 }
02928 } else if (collEnt->objType == COLL_OBJ_T) {
02929 if ((status = splitPathByKey (
02930 collEnt->collName, parPath, childPath, '/')) < 0) {
02931 rodsLogError (LOG_ERROR, status,
02932 "_rsCollRsync:: splitPathByKey for %s error, status = %d",
02933 collEnt->collName, status);
02934 return (status);
02935 }
02936 snprintf (destChildPath, MAX_NAME_LEN, "%s/%s",
02937 destColl, childPath);
02938
02939 status = _rsCollRsync (rsComm, dataObjInp, collEnt->collName,
02940 destChildPath);
02941 }
02942 free (collEnt);
02943 if (status < 0) break;
02944 }
02945 rsCloseCollection (rsComm, &handleInx);
02946 if (status1 < 0 && status1 != CAT_NO_ROWS_FOUND)
02947 return status1;
02948 else
02949 return status;
02950 }
02951
02952
02953
02954
02955
02956
02957
02958
02959
02960
02961
02962
02963
02964
02965
02966
02967
02968
02969
02970
02971
02972
02973
02974
02975
02976
02977
02978
02979
02980
02981
02982
02983
02984
02985
02986
02987
02988
02989
02990
02991
02992
02993
02994
02995
02996
02997
02998
02999
03000
03001
03002 int
03003 msiExecCmd (msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *inpParam3,
03004 msParam_t *inpParam4, msParam_t *inpParam5, msParam_t *outParam,
03005 ruleExecInfo_t *rei)
03006 {
03007 rsComm_t *rsComm;
03008 execCmd_t execCmdInp, *myExecCmdInp;
03009 execCmdOut_t *execCmdOut = NULL;
03010 char *tmpPtr;
03011
03012 RE_TEST_MACRO (" Calling msiExecCmd")
03013
03014 if (rei == NULL || rei->rsComm == NULL) {
03015 rodsLog (LOG_ERROR,
03016 "msiExecCmd: input rei or rsComm is NULL");
03017 return (SYS_INTERNAL_NULL_INPUT_ERR);
03018 }
03019
03020 rsComm = rei->rsComm;
03021
03022
03023 rei->status = parseMspForExecCmdInp (inpParam1, &execCmdInp,
03024 &myExecCmdInp);
03025
03026 if (rei->status < 0) {
03027 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03028 "msiExecCmd: input inpParam1 error. status = %d", rei->status);
03029 return (rei->status);
03030 }
03031
03032 if ((tmpPtr = parseMspForStr (inpParam2)) != NULL) {
03033 rstrcpy (myExecCmdInp->cmdArgv, tmpPtr, HUGE_NAME_LEN);
03034 }
03035
03036 if ((tmpPtr = parseMspForStr (inpParam3)) != NULL) {
03037 rstrcpy (myExecCmdInp->execAddr, tmpPtr, MAX_NAME_LEN);
03038 }
03039
03040 if ((tmpPtr = parseMspForStr (inpParam4)) != NULL) {
03041 rstrcpy (myExecCmdInp->hintPath, tmpPtr, MAX_NAME_LEN);
03042 }
03043
03044 if (parseMspForPosInt (inpParam5) > 0) {
03045 myExecCmdInp->addPathToArgv = 1;
03046 }
03047
03048 if (strlen (rei->ruleName) > 0 &&
03049 strcmp (rei->ruleName, EXEC_MY_RULE_KW) != 0) {
03050
03051 addKeyVal(&myExecCmdInp->condInput, EXEC_CMD_RULE_KW, rei->ruleName);
03052 }
03053 rei->status = rsExecCmd (rsComm, myExecCmdInp, &execCmdOut);
03054
03055 if (myExecCmdInp == &execCmdInp) {
03056 clearKeyVal (&myExecCmdInp->condInput);
03057 }
03058
03059 if (execCmdOut != NULL) {
03060 fillMsParam (outParam, NULL, ExecCmdOut_MS_T, execCmdOut, NULL);
03061 }
03062
03063 if (rei->status < 0) {
03064 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03065 "msiExecCmd: rsExecCmd failed for %s, status = %d",
03066 myExecCmdInp->cmd,
03067 rei->status);
03068 }
03069
03070 return (rei->status);
03071 }
03072
03073
03074
03075
03076
03077
03078
03079
03080
03081
03082
03083
03084
03085
03086
03087
03088
03089
03090
03091
03092
03093
03094
03095
03096
03097
03098
03099
03100
03101
03102
03103
03104
03105
03106
03107
03108
03109
03110
03111
03112
03113
03114
03115
03116
03117
03118
03119
03120
03121
03122
03123
03124
03125
03126
03127
03128
03129
03130
03131
03132
03133 int
03134 msiCollRepl (msParam_t *collection, msParam_t *msKeyValStr, msParam_t *status,
03135 ruleExecInfo_t *rei)
03136 {
03137
03138 collInp_t collInpCache, *collInp;
03139 char *outBadKeyWd;
03140 int validKwFlags;
03141
03142
03143 rsComm_t *rsComm;
03144
03145
03146
03147
03148
03149 RE_TEST_MACRO (" Calling msiCollRepl")
03150
03151
03152 if (rei == NULL || rei->rsComm == NULL) {
03153 rodsLog (LOG_ERROR, "msiCollRepl: inp rei or rsComm is NULL.");
03154 return (SYS_INTERNAL_NULL_INPUT_ERR);
03155 }
03156
03157 rsComm = rei->rsComm;
03158
03159
03160
03161
03162 rei->status =
03163 parseMspForCollInp (collection, &collInpCache, &collInp, 0);
03164
03165 if (rei->status < 0) {
03166 rodsLog (LOG_ERROR,
03167 "msiCollRepl: input collection error. status = %d", rei->status);
03168 return (rei->status);
03169 }
03170
03171
03172
03173 #if 0
03174 rei->status = parseMspForCondInp (targetResc,
03175 &collInp->condInput, DEST_RESC_NAME_KW);
03176 #else
03177 validKwFlags = COLL_NAME_FLAG | DEST_RESC_NAME_FLAG |
03178 BACKUP_RESC_NAME_FLAG | RESC_NAME_FLAG | UPDATE_REPL_FLAG |
03179 REPL_NUM_FLAG | ALL_FLAG | IRODS_ADMIN_FLAG | VERIFY_CHKSUM_FLAG;
03180 rei->status = parseMsKeyValStrForCollInp (msKeyValStr, collInp,
03181 DEST_RESC_NAME_KW, validKwFlags, &outBadKeyWd);
03182 #endif
03183
03184 if (rei->status < 0) {
03185 if (outBadKeyWd != NULL) {
03186 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03187 "msiCollRepl: input keyWd - %s error. status = %d",
03188 outBadKeyWd, rei->status);
03189 free (outBadKeyWd);
03190 } else {
03191 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03192 "msiCollRepl: input msKeyValStr error. status = %d",
03193 rei->status);
03194 }
03195 return (rei->status);
03196 }
03197
03198
03199
03200
03201 rei->status = rsCollRepl (rsComm, collInp, NULL);
03202
03203
03204
03205
03206 fillIntInMsParam (status, rei->status);
03207
03208 return (rei->status);
03209 }
03210
03211
03212
03213
03214
03215
03216
03217
03218
03219
03220
03221
03222
03223
03224
03225
03226
03227
03228
03229
03230
03231
03232
03233
03234
03235
03236
03237
03238
03239
03240
03241
03242
03243
03244
03245
03246
03247
03248
03249
03250
03251
03252
03253
03254
03255
03256
03257
03258 int
03259 msiDataObjPutWithOptions (msParam_t *inpParam1, msParam_t *inpParam2,
03260 msParam_t *inpParam3,msParam_t *inpOverwriteParam,
03261 msParam_t *inpAllCopiesParam, msParam_t *outParam, ruleExecInfo_t *rei)
03262 {
03263 rsComm_t *rsComm;
03264 dataObjInp_t *dataObjInp, *myDataObjInp;
03265 msParamArray_t *myMsParamArray;
03266
03267 RE_TEST_MACRO (" Calling msiDataObjPut")
03268
03269 if (rei == NULL || rei->rsComm == NULL) {
03270 rodsLog (LOG_ERROR,
03271 "msiDataObjPut: input rei or rsComm is NULL");
03272 return (SYS_INTERNAL_NULL_INPUT_ERR);
03273 }
03274
03275 rsComm = rei->rsComm;
03276
03277 dataObjInp = (dataObjInp_t*)malloc (sizeof (dataObjInp_t));
03278
03279 rei->status = parseMspForDataObjInp (inpParam1, dataObjInp,
03280 &myDataObjInp, 1);
03281
03282 if (rei->status < 0) {
03283 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03284 "msiDataObjPut: input inpParam1 error. status = %d", rei->status);
03285 return (rei->status);
03286 }
03287
03288 rei->status = parseMspForCondInp (inpParam2, &dataObjInp->condInput,
03289 DEST_RESC_NAME_KW);
03290
03291 if (rei->status < 0) {
03292 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03293 "msiDataObjPut: input inpParam2 error. status = %d", rei->status);
03294 return (rei->status);
03295 }
03296
03297
03298 rei->status = parseMspForCondInp (inpParam3, &dataObjInp->condInput,
03299 LOCAL_PATH_KW);
03300
03301 if (rei->status < 0) {
03302 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03303 "msiDataObjPut: input inpParam3 error. status = %d", rei->status);
03304 return (rei->status);
03305 }
03306
03307 if (inpOverwriteParam != NULL &&
03308 strcmp((char*)inpOverwriteParam->inOutStruct, FORCE_FLAG_KW) == 0 )
03309 rei->status = parseMspForCondInp (inpOverwriteParam,
03310 &dataObjInp->condInput,FORCE_FLAG_KW);
03311
03312 if (inpAllCopiesParam !=NULL &&
03313 strcmp((char*)inpAllCopiesParam->inOutStruct, ALL_KW) == 0 )
03314 rei->status = parseMspForCondInp (inpAllCopiesParam,
03315 &dataObjInp->condInput,ALL_KW);
03316
03317 myMsParamArray = (msParamArray_t*)malloc (sizeof (msParamArray_t));
03318 memset (myMsParamArray, 0, sizeof (msParamArray_t));
03319
03320 rei->status = addMsParam (myMsParamArray, CL_PUT_ACTION, DataObjInp_MS_T,
03321 (void *) dataObjInp, NULL);
03322
03323 if (rei->status < 0) {
03324 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03325 "msiDataObjPut: addMsParam error. status = %d", rei->status);
03326 return (rei->status);
03327 }
03328
03329
03330 rei->status = sendAndRecvBranchMsg (rsComm, rsComm->apiInx,
03331 SYS_SVR_TO_CLI_MSI_REQUEST, (void *) myMsParamArray, NULL);
03332
03333 if (rei->status >= 0) {
03334 fillIntInMsParam (outParam, rei->status);
03335 } else {
03336 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03337 "msiDataObjPut: rsDataObjPut failed for %s, status = %d",
03338 dataObjInp->objPath,
03339 rei->status);
03340 }
03341
03342 return (rei->status);
03343 }
03344
03345
03346
03347
03348
03349
03350
03351
03352
03353
03354
03355
03356
03357
03358
03359
03360
03361
03362
03363
03364
03365
03366
03367
03368
03369
03370
03371
03372
03373
03374
03375
03376
03377
03378
03379
03380
03381
03382
03383
03384
03385 int
03386 msiDataObjReplWithOptions (msParam_t *inpParam1, msParam_t *inpParam2,
03387 msParam_t *inpParam3, msParam_t *outParam, ruleExecInfo_t *rei)
03388 {
03389 rsComm_t *rsComm;
03390 dataObjInp_t dataObjInp, *myDataObjInp;
03391 transferStat_t *transStat = NULL;
03392
03393 RE_TEST_MACRO (" Calling msiDataObjReplWithOptions")
03394
03395 if (rei == NULL || rei->rsComm == NULL) {
03396 rodsLog (LOG_ERROR,
03397 "msiDataObjReplWithOptions: input rei or rsComm is NULL");
03398 return (SYS_INTERNAL_NULL_INPUT_ERR);
03399 }
03400
03401 rsComm = rei->rsComm;
03402
03403
03404 rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
03405 &myDataObjInp, 0);
03406
03407 if (rei->status < 0) {
03408 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03409 "msiDataObjReplWithOptions: input inpParam1 error. status = %d",
03410 rei->status);
03411 return (rei->status);
03412 }
03413
03414 rei->status = parseMspForCondInp (inpParam2, &myDataObjInp->condInput,
03415 DEST_RESC_NAME_KW);
03416
03417 if (rei->status < 0) {
03418 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03419 "msiDataObjReplWithOptions: input inpParam2 error. status = %d",
03420 rei->status);
03421 return (rei->status);
03422 }
03423
03424 if ((rei->status = parseMspForCondKw (inpParam3, &myDataObjInp->condInput))
03425 < 0) {
03426 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03427 "msiDataObjReplWithOptions: input inpParam3 error. status = %d",
03428 rei->status);
03429 return (rei->status);
03430 }
03431
03432 rei->status = rsDataObjRepl (rsComm, myDataObjInp, &transStat);
03433
03434 if (myDataObjInp == &dataObjInp) {
03435 clearKeyVal (&myDataObjInp->condInput);
03436 }
03437
03438 if (transStat != NULL) {
03439 free (transStat);
03440 }
03441
03442 if (rei->status >= 0) {
03443 fillIntInMsParam (outParam, rei->status);
03444 } else {
03445 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03446 "msiDataObjReplWithOptions: rsDataObjRepl failed %s, status = %d",
03447 myDataObjInp->objPath, rei->status);
03448 }
03449
03450 return (rei->status);
03451 }
03452
03453
03454
03455
03456
03457
03458
03459
03460
03461
03462
03463
03464
03465
03466
03467
03468
03469
03470
03471
03472
03473
03474
03475
03476
03477
03478
03479
03480
03481
03482
03483
03484
03485
03486
03487
03488
03489
03490
03491
03492
03493
03494
03495 int
03496 msiDataObjChksumWithOptions (msParam_t *inpParam1, msParam_t *inpParam2,
03497 msParam_t *inpParam3, msParam_t *outParam, ruleExecInfo_t *rei)
03498 {
03499 rsComm_t *rsComm;
03500 dataObjInp_t dataObjInp, *myDataObjInp;
03501 char *chksum = NULL;
03502
03503 RE_TEST_MACRO (" Calling msiDataObjChksumWithOptions")
03504
03505 if (rei == NULL || rei->rsComm == NULL) {
03506 rodsLog (LOG_ERROR,
03507 "msiDataObjChksumRepl: input rei or rsComm is NULL");
03508 return (SYS_INTERNAL_NULL_INPUT_ERR);
03509 }
03510
03511 rsComm = rei->rsComm;
03512
03513
03514 rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
03515 &myDataObjInp, 1);
03516
03517 if (rei->status < 0) {
03518 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03519 "msiDataObjChksumWithOptions: input inpParam1 error. status = %d",
03520 rei->status);
03521 return (rei->status);
03522 }
03523
03524 if ((rei->status = parseMspForCondKw (inpParam2,
03525 &myDataObjInp->condInput)) < 0) {
03526 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03527 "msiDataObjChksumWithOptions: input inpParam2 error. status = %d",
03528 rei->status);
03529 return (rei->status);
03530 }
03531
03532 if (inpParam3 != NULL && strcmp( inpParam3->type, STR_MS_T) == 0) {
03533 if (strcmp ((char *) inpParam3->inOutStruct, CHKSUM_ALL_KW) == 0) {
03534 if ((rei->status = parseMspForCondKw (inpParam3,
03535 &myDataObjInp->condInput)) < 0) {
03536 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03537 "msiDataObjChksumWithOptions: input inpParam3 error.stat=%d",
03538 rei->status);
03539 return (rei->status);
03540 }
03541 } else {
03542
03543 if ((rei->status = parseMspForCondInp (inpParam3,
03544 &myDataObjInp->condInput, REPL_NUM_KW)) < 0) {
03545 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03546 "msiDataObjChksumWithOptions: input inpParam3 error.stat=%d",
03547 rei->status);
03548 return (rei->status);
03549 }
03550 }
03551 }
03552 rei->status = rsDataObjChksum (rsComm, myDataObjInp, &chksum);
03553
03554 if (myDataObjInp == &dataObjInp) {
03555 clearKeyVal (&myDataObjInp->condInput);
03556 }
03557
03558 if (rei->status >= 0) {
03559 fillStrInMsParam (outParam, chksum);
03560 free (chksum);
03561 } else {
03562 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03563 "msiDataObjChksumWithOptions: rsDataObjChksum failed for %s,stat=%d",
03564 myDataObjInp->objPath, rei->status);
03565 }
03566
03567 return (rei->status);
03568 }
03569
03570
03571
03572
03573
03574
03575
03576
03577
03578
03579
03580
03581
03582
03583
03584
03585
03586
03587
03588
03589
03590
03591
03592
03593
03594
03595
03596
03597
03598
03599
03600
03601
03602
03603
03604
03605
03606
03607
03608
03609 int
03610 msiTarFileExtract (msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *inpParam3, msParam_t *outParam, ruleExecInfo_t *rei)
03611 {
03612 rsComm_t *rsComm;
03613 structFileExtAndRegInp_t structFileExtAndRegInp,
03614 *myStructFileExtAndRegInp;
03615 keyValPair_t regParam;
03616 modDataObjMeta_t modDataObjMetaInp;
03617 int rc1;
03618 char origDataType[NAME_LEN];
03619
03620 RE_TEST_MACRO (" Calling msiTarFileExtract")
03621
03622 if (rei == NULL || rei->rsComm == NULL) {
03623 rodsLog (LOG_ERROR,
03624 "msiTarFileExtract: input rei or rsComm is NULL");
03625 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
03626 return (rei->status);
03627 }
03628
03629 rsComm = rei->rsComm;
03630
03631
03632
03633
03634
03635 if ( inpParam1 == NULL || inpParam2 == NULL ) {
03636 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03637 "msiTarFileExtract: input Param1 and/or Param2 are NULL");
03638 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
03639 return (rei->status);
03640 }
03641
03642 if (strcmp (inpParam1->type, STR_MS_T) == 0) {
03643 bzero (&structFileExtAndRegInp, sizeof (structFileExtAndRegInp));
03644 myStructFileExtAndRegInp = &structFileExtAndRegInp;
03645 strncpy ((char*)myStructFileExtAndRegInp->objPath, (char*)inpParam1->inOutStruct,
03646 MAX_NAME_LEN);
03647 } else if (strcmp (inpParam1->type, StructFileExtAndRegInp_MS_T) == 0) {
03648 myStructFileExtAndRegInp =
03649 (structFileExtAndRegInp_t *) inpParam1->inOutStruct;
03650 } else {
03651 rei->status = UNKNOWN_PARAM_IN_RULE_ERR;
03652 return (rei->status);
03653 }
03654
03655 if ( strcmp (inpParam2->type, STR_MS_T) == 0 ) {
03656 if (strcmp ((char *) inpParam2->inOutStruct, "null") != 0) {
03657 strncpy ((char*)myStructFileExtAndRegInp->collection,
03658 (char*)inpParam2->inOutStruct, MAX_NAME_LEN);
03659 }
03660 } else {
03661 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03662 "msiTarFileExtract: Unsupported input Param2 type %s",
03663 inpParam2->type);
03664 rei->status = UNKNOWN_PARAM_IN_RULE_ERR;
03665 return (rei->status);
03666 }
03667
03668 if ( strcmp (inpParam3->type, STR_MS_T) == 0 && inpParam3 != NULL &&
03669 strcmp ( (char *) inpParam3->inOutStruct, "null") != 0) {
03670 addKeyVal(&myStructFileExtAndRegInp->condInput, DEST_RESC_NAME_KW,
03671 (char *) inpParam3->inOutStruct);
03672
03673 addKeyVal(&myStructFileExtAndRegInp->condInput, RESC_NAME_KW,
03674 (char *) inpParam3->inOutStruct);
03675 }
03676
03677 if (rei->doi != NULL) {
03678
03679
03680 strncpy(origDataType, rei->doi->dataType, NAME_LEN);
03681
03682 memset(®Param, 0, sizeof(regParam));
03683 addKeyVal(®Param, DATA_TYPE_KW, "tar file");
03684 modDataObjMetaInp.dataObjInfo = rei->doi;
03685 modDataObjMetaInp.regParam = ®Param;
03686 rc1 = rsModDataObjMeta(rsComm, &modDataObjMetaInp);
03687 if (rc1 < 0)
03688 {
03689 eirods::log( ERROR (rc1, "rsModDataObjMeta failed."));
03690 }
03691 }
03692
03693
03694 rei->status = rsStructFileExtAndReg (rsComm, myStructFileExtAndRegInp);
03695 if ( rei->status < 0 && rei->doi != NULL) {
03696 rodsLog (LOG_ERROR, "msiTarFileExtract: tar file extraction failed");
03697
03698
03699 memset(®Param, 0, sizeof(regParam));
03700 addKeyVal(®Param, DATA_TYPE_KW, origDataType);
03701 rc1 = rsModDataObjMeta(rsComm, &modDataObjMetaInp);
03702 if (rc1 < 0)
03703 {
03704 eirods::log( ERROR (rc1, "rsModDataObjMeta failed."));
03705 }
03706 }
03707
03708 fillIntInMsParam (outParam, rei->status);
03709
03710 return (rei->status);
03711 }
03712
03713
03714
03715
03716
03717
03718
03719
03720
03721
03722
03723
03724
03725
03726
03727
03728
03729
03730
03731
03732
03733
03734
03735
03736
03737
03738
03739
03740
03741
03742
03743
03744
03745
03746
03747
03748
03749
03750
03751
03752 int
03753 msiTarFileCreate (msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *inpParam3, msParam_t *inpParam4, ruleExecInfo_t *rei)
03754 {
03755 rsComm_t *rsComm;
03756 structFileExtAndRegInp_t structFileExtAndRegInp,
03757 *myStructFileExtAndRegInp;
03758
03759 RE_TEST_MACRO (" Calling msiTarFileCreate")
03760
03761 if (rei == NULL || rei->rsComm == NULL) {
03762 rodsLog (LOG_ERROR,
03763 "msiTarFileCreate: input rei or rsComm is NULL");
03764 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
03765 return (rei->status);
03766 }
03767
03768 rsComm = rei->rsComm;
03769
03770
03771
03772
03773
03774 if ( inpParam1 == NULL || inpParam2 == NULL ) {
03775 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03776 "msiTarFileCreate: input Param1 and/or Param2 are NULL");
03777 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
03778 return (rei->status);
03779 }
03780
03781 if (strcmp (inpParam1->type, STR_MS_T) == 0) {
03782 bzero (&structFileExtAndRegInp, sizeof (structFileExtAndRegInp));
03783 myStructFileExtAndRegInp = &structFileExtAndRegInp;
03784 strncpy ((char*)myStructFileExtAndRegInp->objPath, (char*)inpParam1->inOutStruct,
03785 MAX_NAME_LEN);
03786 } else if (strcmp (inpParam1->type, StructFileExtAndRegInp_MS_T) == 0) {
03787 myStructFileExtAndRegInp =
03788 (structFileExtAndRegInp_t *) inpParam1->inOutStruct;
03789 } else {
03790 rei->status = UNKNOWN_PARAM_IN_RULE_ERR;
03791 return (rei->status);
03792 }
03793
03794 if ( strcmp (inpParam2->type, STR_MS_T) == 0 ) {
03795 if (strcmp ((char *) inpParam2->inOutStruct, "null") != 0) {
03796 strncpy ((char*)myStructFileExtAndRegInp->collection,
03797 (char*)inpParam2->inOutStruct, MAX_NAME_LEN);
03798 }
03799 } else {
03800 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03801 "msiTarFileExtract: Unsupported input Param2 type %s",
03802 inpParam2->type);
03803 rei->status = UNKNOWN_PARAM_IN_RULE_ERR;
03804 return (rei->status);
03805 }
03806
03807 if ( strcmp (inpParam3->type, STR_MS_T) == 0 && inpParam3 != NULL &&
03808 strcmp ( (char *) inpParam3->inOutStruct, "null") != 0) {
03809 addKeyVal(&myStructFileExtAndRegInp->condInput, DEST_RESC_NAME_KW,
03810 (char *) inpParam3->inOutStruct);
03811 }
03812
03813 if ( strcmp (inpParam4->type, STR_MS_T) == 0 && inpParam4 != NULL &&
03814 strcmp ( (char *) inpParam4->inOutStruct, "force") == 0) {
03815 addKeyVal(&myStructFileExtAndRegInp->condInput, FORCE_FLAG_KW, "");
03816 }
03817
03818
03819 rei->status = rsStructFileBundle (rsComm, myStructFileExtAndRegInp);
03820
03821 return (rei->status);
03822
03823 }
03824
03825
03826
03827
03828
03829
03830
03831
03832
03833
03834
03835
03836
03837
03838
03839
03840
03841
03842
03843
03844
03845
03846
03847
03848
03849
03850
03851
03852
03853
03854
03855
03856
03857
03858
03859
03860
03861
03862
03863
03864
03865
03866
03867
03868
03869
03870 int
03871 msiPhyBundleColl (msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *outParam, ruleExecInfo_t *rei)
03872 {
03873 rsComm_t *rsComm;
03874 structFileExtAndRegInp_t structFileExtAndRegInp,
03875 *myStructFileExtAndRegInp;
03876 int len1, len2;
03877 char *inpStr, rescName[NAME_LEN], *pstr1, *pstr2, attr[MAX_NAME_LEN];
03878
03879 RE_TEST_MACRO (" Calling msiPhyBundleColl")
03880
03881 if (rei == NULL || rei->rsComm == NULL) {
03882 rodsLog (LOG_ERROR,
03883 "msiPhyBundleColl: input rei or rsComm is NULL");
03884 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
03885 return (rei->status);
03886 }
03887
03888 rsComm = rei->rsComm;
03889
03890
03891
03892
03893
03894
03895 if ( inpParam1 == NULL) {
03896 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03897 "msiPhyBundleColl: input Param1 is NULL");
03898 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
03899 return (rei->status);
03900 }
03901
03902
03903 if (strcmp (inpParam1->type, STR_MS_T) == 0) {
03904 bzero (&structFileExtAndRegInp, sizeof (structFileExtAndRegInp));
03905 myStructFileExtAndRegInp = &structFileExtAndRegInp;
03906 strncpy ((char*)myStructFileExtAndRegInp->collection, (char*)inpParam1->inOutStruct,
03907 MAX_NAME_LEN);
03908
03909 } else if (strcmp (inpParam1->type, StructFileExtAndRegInp_MS_T) == 0) {
03910 myStructFileExtAndRegInp =
03911 (structFileExtAndRegInp_t *) inpParam1->inOutStruct;
03912
03913 } else {
03914
03915 rei->status = UNKNOWN_PARAM_IN_RULE_ERR;
03916 return (rei->status);
03917 }
03918
03919 if( strcmp (inpParam2->type, STR_MS_T) == 0 && inpParam2 != NULL &&
03920
03921 strcmp ( (char *) inpParam2->inOutStruct, "null") != 0) {
03922 inpStr = (char *) inpParam2->inOutStruct;
03923
03924 pstr1 = strstr(inpStr, "++++");
03925 if ( pstr1 != NULL ) {
03926 len1 = strlen(inpStr) - strlen(pstr1);
03927 if ( len1 > 0 ) {
03928 strncpy(rescName, inpStr, len1);
03929 addKeyVal(&myStructFileExtAndRegInp->condInput, DEST_RESC_NAME_KW, rescName);
03930 }
03931 pstr2 = strstr(pstr1 + 4, "=");
03932 if ( pstr2 != NULL ) {
03933 len2 = strlen(pstr1 + 4) - strlen(pstr2);
03934 memset(attr, 0, sizeof(attr));
03935 strncpy(attr, pstr1 + 4, len2);
03936 if ( len2 > 0 ) {
03937 if ( strcmp(attr, "N") == 0 ) {
03938 addKeyVal(&myStructFileExtAndRegInp->condInput, MAX_SUB_FILE_KW, pstr2 + 1);
03939 }
03940 }
03941 }
03942 }
03943 else {
03944 addKeyVal(&myStructFileExtAndRegInp->condInput, DEST_RESC_NAME_KW, inpStr);
03945 }
03946
03947
03948 }
03949
03950
03951 rei->status = rsPhyBundleColl (rsComm, myStructFileExtAndRegInp);
03952
03953
03954 fillIntInMsParam (outParam, rei->status);
03955
03956
03957 return (rei->status);
03958
03959 }
03960