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
01207 rei->status = parseMspForDataObjInp (inpParam1, dataObjInp,
01208 &myDataObjInp, 1);
01209
01210 if (rei->status < 0) {
01211 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01212 "msiDataObjPut: input inpParam1 error. status = %d", rei->status);
01213 return (rei->status);
01214 }
01215
01216 rei->status = parseMspForCondInp (inpParam2, &dataObjInp->condInput,
01217 DEST_RESC_NAME_KW);
01218
01219 if (rei->status < 0) {
01220 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01221 "msiDataObjPut: input inpParam2 error. status = %d", rei->status);
01222 return (rei->status);
01223 }
01224
01225 #if 0
01226 rei->status = parseMspForCondInp (inpParam3, &dataObjInp->condInput,
01227 LOCAL_PATH_KW);
01228 #else
01229 validKwFlags = LOCAL_PATH_FLAG | DEST_RESC_NAME_FLAG | FILE_PATH_FLAG |
01230 REPL_NUM_FLAG | DATA_TYPE_FLAG | VERIFY_CHKSUM_FLAG |
01231 ALL_FLAG | FORCE_FLAG_FLAG | NUM_THREADS_FLAG | OBJ_PATH_FLAG;
01232 rei->status = parseMsKeyValStrForDataObjInp (msKeyValStr, dataObjInp,
01233 LOCAL_PATH_KW, validKwFlags, &outBadKeyWd);
01234 #endif
01235
01236 if (rei->status < 0) {
01237 if (outBadKeyWd != NULL) {
01238 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01239 "msiDataObjPut: input keyWd - %s error. status = %d",
01240 outBadKeyWd, rei->status);
01241 free (outBadKeyWd);
01242 } else {
01243 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01244 "msiDataObjPut: input msKeyValStr error. status = %d",
01245 rei->status);
01246 }
01247 return (rei->status);
01248 }
01249
01250 myMsParamArray = (msParamArray_t*)malloc (sizeof (msParamArray_t));
01251 memset (myMsParamArray, 0, sizeof (msParamArray_t));
01252
01253 rei->status = addMsParam (myMsParamArray, CL_PUT_ACTION, DataObjInp_MS_T,
01254 (void *) dataObjInp, NULL);
01255
01256 if (rei->status < 0) {
01257 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01258 "msiDataObjPut: addMsParam error. status = %d", rei->status);
01259 return (rei->status);
01260 }
01261
01262
01263 rei->status = sendAndRecvBranchMsg (rsComm, rsComm->apiInx,
01264 SYS_SVR_TO_CLI_MSI_REQUEST, (void *) myMsParamArray, NULL);
01265
01266 if (rei->status >= 0) {
01267 fillIntInMsParam (outParam, rei->status);
01268 } else {
01269 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01270 "msiDataObjPut: rsDataObjPut failed for %s, status = %d",
01271 dataObjInp->objPath,
01272 rei->status);
01273 }
01274
01275 return (rei->status);
01276 }
01277
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 int
01334 msiDataObjGet (msParam_t *inpParam1, msParam_t *msKeyValStr,
01335 msParam_t *outParam, ruleExecInfo_t *rei)
01336 {
01337 rsComm_t *rsComm;
01338 dataObjInp_t *dataObjInp, *myDataObjInp;
01339 msParamArray_t *myMsParamArray;
01340 char *outBadKeyWd;
01341 int validKwFlags;
01342
01343 RE_TEST_MACRO (" Calling msiDataObjGet")
01344
01345 if (rei == NULL || rei->rsComm == NULL) {
01346 rodsLog (LOG_ERROR,
01347 "msiDataObjGet: input rei or rsComm is NULL");
01348 return (SYS_INTERNAL_NULL_INPUT_ERR);
01349 }
01350
01351 rsComm = rei->rsComm;
01352
01353 dataObjInp = (dataObjInp_t*)malloc (sizeof (dataObjInp_t));
01354
01355 rei->status = parseMspForDataObjInp (inpParam1, dataObjInp,
01356 &myDataObjInp, 1);
01357
01358 if (rei->status < 0) {
01359 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01360 "msiDataObjGet: input inpParam1 error. status = %d",
01361 rei->status);
01362 return (rei->status);
01363 }
01364
01365 #if 0
01366 rei->status = parseMspForCondInp (inpParam2, &dataObjInp->condInput,
01367 LOCAL_PATH_KW);
01368 #else
01369 validKwFlags = LOCAL_PATH_FLAG | FORCE_FLAG_FLAG | NUM_THREADS_FLAG |
01370 RESC_NAME_FLAG | REPL_NUM_FLAG | VERIFY_CHKSUM_FLAG | OBJ_PATH_FLAG;
01371 rei->status = parseMsKeyValStrForDataObjInp (msKeyValStr, dataObjInp,
01372 LOCAL_PATH_KW, validKwFlags, &outBadKeyWd);
01373 #endif
01374
01375 if (rei->status < 0) {
01376 if (outBadKeyWd != NULL) {
01377 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01378 "msiDataObjGet: input keyWd - %s error. status = %d",
01379 outBadKeyWd, rei->status);
01380 free (outBadKeyWd);
01381 } else {
01382 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01383 "msiDataObjGet: input msKeyValStr error. status = %d",
01384 rei->status);
01385 }
01386 return (rei->status);
01387 }
01388
01389 myMsParamArray = (msParamArray_t*)malloc (sizeof (msParamArray_t));
01390 memset (myMsParamArray, 0, sizeof (msParamArray_t));
01391
01392 rei->status = addMsParam (myMsParamArray, CL_GET_ACTION, DataObjInp_MS_T,
01393 (void *) dataObjInp, NULL);
01394
01395 if (rei->status < 0) {
01396 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01397 "msiDataObjGet: addMsParam error. status = %d",
01398 rei->status);
01399 return (rei->status);
01400 }
01401
01402
01403 rei->status = sendAndRecvBranchMsg (rsComm, rsComm->apiInx,
01404 SYS_SVR_TO_CLI_MSI_REQUEST, (void *) myMsParamArray, NULL);
01405
01406 if (rei->status >= 0) {
01407 fillIntInMsParam (outParam, rei->status);
01408 } else {
01409 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01410 "msiDataObjGet: rsDataObjGet failed for %s, status = %d",
01411 dataObjInp->objPath, rei->status);
01412 }
01413
01414 return (rei->status);
01415 }
01416
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 int
01462 msiDataObjGetWithOptions (msParam_t *inpParam1, msParam_t *inpParam2,
01463 msParam_t *srcrescParam, msParam_t *outParam, ruleExecInfo_t *rei)
01464 {
01465 rsComm_t *rsComm;
01466 dataObjInp_t *dataObjInp, *myDataObjInp;
01467 msParamArray_t *myMsParamArray;
01468
01469 RE_TEST_MACRO (" Calling msiDataObjGetWithOptions")
01470
01471 if (rei == NULL || rei->rsComm == NULL) {
01472 rodsLog (LOG_ERROR,
01473 "msiDataObjGetWithOptions: input rei or rsComm is NULL");
01474 return (SYS_INTERNAL_NULL_INPUT_ERR);
01475 }
01476
01477 rsComm = rei->rsComm;
01478
01479 dataObjInp = (dataObjInp_t*)malloc (sizeof (dataObjInp_t));
01480
01481 rei->status = parseMspForDataObjInp (inpParam1, dataObjInp,
01482 &myDataObjInp, 1);
01483
01484 if (rei->status < 0) {
01485 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01486 "msiDataObjGetWithOptions: input inpParam1 error. status = %d",
01487 rei->status);
01488 return (rei->status);
01489 }
01490
01491 rei->status = parseMspForCondInp (inpParam2, &dataObjInp->condInput,
01492 LOCAL_PATH_KW);
01493
01494 if (rei->status < 0) {
01495 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01496 "msiDataObjGetWithOptions: input inpParam2 error. status = %d",
01497 rei->status);
01498 return (rei->status);
01499 }
01500
01501 rei->status = parseMspForCondInp (srcrescParam, &dataObjInp->condInput,
01502 RESC_NAME_KW);
01503
01504 if (rei->status < 0) {
01505 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01506 "msiDataObjGetWithOptions: input srcrescParam error. status = %d",
01507 rei->status);
01508 return (rei->status);
01509 }
01510
01511 myMsParamArray = (msParamArray_t*)malloc (sizeof (msParamArray_t));
01512 memset (myMsParamArray, 0, sizeof (msParamArray_t));
01513
01514 rei->status = addMsParam (myMsParamArray, CL_GET_ACTION, DataObjInp_MS_T,
01515 (void *) dataObjInp, NULL);
01516
01517 if (rei->status < 0) {
01518 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01519 "msiDataObjGetWithOptions: addMsParam error. status = %d",
01520 rei->status);
01521 return (rei->status);
01522 }
01523
01524
01525 rei->status = sendAndRecvBranchMsg (rsComm, rsComm->apiInx,
01526 SYS_SVR_TO_CLI_MSI_REQUEST, (void *) myMsParamArray, NULL);
01527
01528 if (rei->status >= 0) {
01529 fillIntInMsParam (outParam, rei->status);
01530 } else {
01531 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01532 "msiDataObjGetWithOptions: rsDataObjGet failed, status = %d",
01533 rei->status);
01534 }
01535
01536 return (rei->status);
01537 }
01538
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 int
01584 msiDataObjChksum (msParam_t *inpParam1, msParam_t *msKeyValStr,
01585 msParam_t *outParam, ruleExecInfo_t *rei)
01586 {
01587 rsComm_t *rsComm;
01588 dataObjInp_t dataObjInp, *myDataObjInp;
01589 char *chksum = NULL;
01590 char *outBadKeyWd;
01591 int validKwFlags;
01592
01593 RE_TEST_MACRO (" Calling msiDataObjChksum")
01594
01595 if (rei == NULL || rei->rsComm == NULL) {
01596 rodsLog (LOG_ERROR,
01597 "msiDataObjChksum: input rei or rsComm is NULL");
01598 return (SYS_INTERNAL_NULL_INPUT_ERR);
01599 }
01600
01601 rsComm = rei->rsComm;
01602
01603
01604 rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
01605 &myDataObjInp, 1);
01606
01607 if (rei->status < 0) {
01608 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01609 "msiDataObjChksum: input inpParam1 error. status = %d", rei->status);
01610 return (rei->status);
01611 }
01612
01613 #if 0
01614 if ((rei->status = parseMspForCondKw (inpParam2, &myDataObjInp->condInput))
01615 < 0) {
01616 #else
01617 validKwFlags = CHKSUM_ALL_FLAG | FORCE_CHKSUM_FLAG | REPL_NUM_FLAG |
01618 OBJ_PATH_FLAG | VERIFY_CHKSUM_FLAG;
01619 if ((rei->status = parseMsKeyValStrForDataObjInp (msKeyValStr,
01620 myDataObjInp, KEY_WORD_KW, validKwFlags, &outBadKeyWd)) < 0) {
01621 #endif
01622 if (outBadKeyWd != NULL) {
01623 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01624 "msiDataObjChksum: input keyWd - %s error. status = %d",
01625 outBadKeyWd, rei->status);
01626 free (outBadKeyWd);
01627 } else {
01628 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01629 "msiDataObjChksum: input msKeyValStr error. status = %d",
01630 rei->status);
01631 }
01632 return (rei->status);
01633 }
01634
01635 rei->status = rsDataObjChksum (rsComm, myDataObjInp, &chksum);
01636
01637 if (myDataObjInp == &dataObjInp) {
01638 clearKeyVal (&myDataObjInp->condInput);
01639 }
01640
01641 if (rei->status >= 0) {
01642 fillStrInMsParam (outParam, chksum);
01643 free (chksum);
01644 } else {
01645 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01646 "msiDataObjChksum: rsDataObjChksum failed for %s, status = %d",
01647 myDataObjInp->objPath ,
01648 rei->status);
01649 }
01650
01651 return (rei->status);
01652 }
01653
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 int
01694 msiDataObjPhymv (msParam_t *inpParam1, msParam_t *inpParam2,
01695 msParam_t *inpParam3, msParam_t *inpParam4, msParam_t *inpParam5,
01696 msParam_t *outParam, ruleExecInfo_t *rei)
01697 {
01698 rsComm_t *rsComm;
01699 dataObjInp_t dataObjInp, *myDataObjInp;
01700 transferStat_t *transStat = NULL;
01701
01702 RE_TEST_MACRO (" Calling msiDataObjPhymv")
01703
01704 if (rei == NULL || rei->rsComm == NULL) {
01705 rodsLog (LOG_ERROR,
01706 "msiDataObjPhymv: input rei or rsComm is NULL");
01707 return (SYS_INTERNAL_NULL_INPUT_ERR);
01708 }
01709
01710 rsComm = rei->rsComm;
01711
01712
01713
01714 if ((rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
01715 &myDataObjInp, 0)) < 0) {
01716 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01717 "msiDataObjPhymv: input inpParam1 error. status = %d", rei->status);
01718 return (rei->status);
01719 }
01720
01721 if ((rei->status = parseMspForCondInp (inpParam2, &myDataObjInp->condInput,
01722 DEST_RESC_NAME_KW)) < 0) {
01723 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01724 "msiDataObjPhymv: input inpParam2 error. status = %d", rei->status);
01725 return (rei->status);
01726 }
01727
01728 if ((rei->status = parseMspForCondInp (inpParam3, &myDataObjInp->condInput,
01729 RESC_NAME_KW)) < 0) {
01730 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01731 "msiDataObjPhymv: input inpParam3 error. status = %d", rei->status);
01732 return (rei->status);
01733 }
01734
01735 if ((rei->status = parseMspForCondInp (inpParam4, &myDataObjInp->condInput,
01736 REPL_NUM_KW)) < 0) {
01737 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01738 "msiDataObjPhymv: input inpParam4 error. status = %d", rei->status);
01739 return (rei->status);
01740 }
01741
01742 if ((rei->status = parseMspForCondInp (inpParam5, &myDataObjInp->condInput,
01743 IRODS_ADMIN_KW)) < 0) {
01744 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01745 "msiDataObjPhymv: input inpParam5 error. status = %d", rei->status);
01746 return (rei->status);
01747 }
01748
01749 rei->status = rsDataObjPhymv (rsComm, myDataObjInp, &transStat);
01750
01751 if (transStat != NULL) {
01752 free (transStat);
01753 }
01754
01755 if (myDataObjInp == &dataObjInp) {
01756 clearKeyVal (&myDataObjInp->condInput);
01757 }
01758
01759 if (rei->status >= 0) {
01760 fillIntInMsParam (outParam, rei->status);
01761 } else {
01762 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01763 "msiDataObjPhymv: rsDataObjPhymv failed for %s, status = %d",
01764 myDataObjInp->objPath,
01765 rei->status);
01766 }
01767
01768 return (rei->status);
01769 }
01770
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 int
01810 msiDataObjRename (msParam_t *inpParam1, msParam_t *inpParam2,
01811 msParam_t *inpParam3, msParam_t *outParam, ruleExecInfo_t *rei)
01812 {
01813 rsComm_t *rsComm;
01814 dataObjCopyInp_t dataObjRenameInp, *myDataObjRenameInp;
01815 dataObjInp_t *myDataObjInp;
01816
01817 RE_TEST_MACRO (" Calling msiDataObjRename")
01818
01819 if (rei == NULL || rei->rsComm == NULL) {
01820 rodsLog (LOG_ERROR,
01821 "msiDataObjRename: input rei or rsComm is NULL");
01822 return (SYS_INTERNAL_NULL_INPUT_ERR);
01823 }
01824
01825 rsComm = rei->rsComm;
01826
01827
01828 rei->status = parseMspForDataObjCopyInp (inpParam1, &dataObjRenameInp,
01829 &myDataObjRenameInp);
01830
01831 if (rei->status < 0) {
01832 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01833 "msiDataObjRename: input inpParam1 error. status = %d", rei->status);
01834 return (rei->status);
01835 }
01836
01837
01838 rei->status = parseMspForDataObjInp (inpParam2,
01839 &myDataObjRenameInp->destDataObjInp, &myDataObjInp, 1);
01840
01841 if (rei->status < 0) {
01842 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01843 "msiDataObjRename: input inpParam2 error. status = %d", rei->status);
01844 return (rei->status);
01845 }
01846
01847 if (inpParam3 != NULL) {
01848 int myInt;
01849 myInt = parseMspForPosInt (inpParam3);
01850 if (myInt > 0) {
01851 myDataObjRenameInp->srcDataObjInp.oprType = RENAME_COLL;
01852 } else {
01853 myDataObjRenameInp->srcDataObjInp.oprType = RENAME_DATA_OBJ;
01854 }
01855 }
01856
01857 rei->status = rsDataObjRename (rsComm, myDataObjRenameInp);
01858
01859 if (rei->status >= 0) {
01860 fillIntInMsParam (outParam, rei->status);
01861 } else {
01862 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01863 "msiDataObjRename: rsDataObjRename failed for %s, status = %d",
01864 myDataObjRenameInp->srcDataObjInp.objPath,
01865 rei->status);
01866 }
01867
01868 return (rei->status);
01869 }
01870
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 int
01911 msiDataObjTrim (msParam_t *inpParam1, msParam_t *inpParam2,
01912 msParam_t *inpParam3, msParam_t *inpParam4, msParam_t *inpParam5,
01913 msParam_t *outParam, ruleExecInfo_t *rei)
01914 {
01915 rsComm_t *rsComm;
01916 dataObjInp_t dataObjInp, *myDataObjInp;
01917
01918 RE_TEST_MACRO (" Calling msiDataObjTrim")
01919
01920 if (rei == NULL || rei->rsComm == NULL) {
01921 rodsLog (LOG_ERROR,
01922 "msiDataObjTrim: input rei or rsComm is NULL");
01923 return (SYS_INTERNAL_NULL_INPUT_ERR);
01924 }
01925
01926 rsComm = rei->rsComm;
01927
01928
01929
01930 if ((rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
01931 &myDataObjInp, 0)) < 0) {
01932 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01933 "msiDataObjTrim: input inpParam1 error. status = %d", rei->status);
01934 return (rei->status);
01935 }
01936
01937 if ((rei->status = parseMspForCondInp (inpParam2, &myDataObjInp->condInput, RESC_NAME_KW)) < 0) {
01938 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01939 "msiDataObjTrim: input inpParam2 error. status = %d", rei->status);
01940 return (rei->status);
01941 }
01942
01943 if ((rei->status = parseMspForCondInp (inpParam3, &myDataObjInp->condInput,
01944 REPL_NUM_KW)) < 0) {
01945 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01946 "msiDataObjTrim: input inpParam3 error. status = %d", rei->status);
01947 return (rei->status);
01948 }
01949
01950 if ((rei->status = parseMspForCondInp (inpParam4, &myDataObjInp->condInput,
01951 COPIES_KW)) < 0) {
01952 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01953 "msiDataObjTrim: input inpParam4 error. status = %d", rei->status);
01954 return (rei->status);
01955 }
01956
01957 if ((rei->status = parseMspForCondInp (inpParam5, &myDataObjInp->condInput,
01958 IRODS_ADMIN_KW)) < 0) {
01959 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01960 "msiDataObjTrim: input inpParam5 error. status = %d", rei->status);
01961 return (rei->status);
01962 }
01963
01964 rei->status = rsDataObjTrim (rsComm, myDataObjInp);
01965
01966 if (myDataObjInp == &dataObjInp) {
01967 clearKeyVal (&myDataObjInp->condInput);
01968 }
01969
01970 if (rei->status >= 0) {
01971 fillIntInMsParam (outParam, rei->status);
01972 } else {
01973 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
01974 "msiDataObjTrim: rsDataObjTrim failed for %s, status = %d",
01975 myDataObjInp->objPath,
01976 rei->status);
01977 }
01978
01979 return (rei->status);
01980 }
01981
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 int
02019 msiCollCreate (msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *outParam, ruleExecInfo_t *rei)
02020 {
02021 rsComm_t *rsComm;
02022 collInp_t collCreateInp, *myCollCreateInp;
02023 int flags;
02024
02025 RE_TEST_MACRO (" Calling msiCollCreate")
02026
02027 if (rei == NULL || rei->rsComm == NULL) {
02028 rodsLog (LOG_ERROR,
02029 "msiCollCreate: input rei or rsComm is NULL");
02030 return (SYS_INTERNAL_NULL_INPUT_ERR);
02031 }
02032
02033 rsComm = rei->rsComm;
02034
02035
02036 rei->status = parseMspForCollInp (inpParam1, &collCreateInp,
02037 &myCollCreateInp, 1);
02038
02039 if (rei->status < 0) {
02040 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02041 "msiCollCreate: input inpParam1 error. status = %d", rei->status);
02042 return (rei->status);
02043 }
02044
02045 flags = parseMspForPosInt (inpParam2);
02046
02047 if (flags > 0)
02048 addKeyVal (&collCreateInp.condInput, RECURSIVE_OPR__KW, "");
02049 rei->status = rsCollCreate (rsComm, myCollCreateInp);
02050
02051 if (rei->status >= 0) {
02052 fillIntInMsParam (outParam, rei->status);
02053 } else {
02054 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02055 "msiCollCreate: rsCollCreate failed %s, status = %d",
02056 collCreateInp.collName,
02057 rei->status);
02058 }
02059
02060 if (myCollCreateInp == &collCreateInp) {
02061 clearKeyVal (&myCollCreateInp->condInput);
02062 }
02063
02064 return (rei->status);
02065 }
02066
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 int
02113 msiRmColl (msParam_t *inpParam1, msParam_t *msKeyValStr, msParam_t *outParam, ruleExecInfo_t *rei)
02114 {
02115 rsComm_t *rsComm;
02116 collInp_t rmCollInp, *myRmCollInp;
02117 char *outBadKeyWd;
02118 int validKwFlags;
02119
02120 RE_TEST_MACRO (" Calling msiRmColl")
02121
02122 if (rei == NULL || rei->rsComm == NULL) {
02123 rodsLog (LOG_ERROR,
02124 "msiRmColl: input rei or rsComm is NULL");
02125 return (SYS_INTERNAL_NULL_INPUT_ERR);
02126 }
02127
02128 rsComm = rei->rsComm;
02129
02130
02131 rei->status = parseMspForCollInp (inpParam1, &rmCollInp,
02132 &myRmCollInp, 1);
02133
02134 if (rei->status < 0) {
02135 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02136 "msiRmColl: input inpParam1 error. status = %d", rei->status);
02137 return (rei->status);
02138 }
02139
02140 #if 0
02141 if ((rei->status = parseMspForCondKw (inpParam2, &myRmCollInp->condInput))
02142 < 0) {
02143 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02144 "msiRmColl: input inpParam2 error. status = %d", rei->status);
02145 return (rei->status);
02146 }
02147 #else
02148 validKwFlags = IRODS_RMTRASH_FLAG | IRODS_ADMIN_RMTRASH_FLAG |
02149 FORCE_FLAG_FLAG | COLL_NAME_FLAG;
02150 if ((rei->status = parseMsKeyValStrForCollInp (msKeyValStr,
02151 myRmCollInp, KEY_WORD_KW, validKwFlags, &outBadKeyWd)) < 0) {
02152 if (outBadKeyWd != NULL) {
02153 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02154 "msiRmColl: input keyWd - %s error. status = %d",
02155 outBadKeyWd, rei->status);
02156 free (outBadKeyWd);
02157 } else {
02158 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02159 "msiRmColl: input msKeyValStr error. status = %d",
02160 rei->status);
02161 }
02162 return (rei->status);
02163 }
02164 #endif
02165
02166 addKeyVal (&myRmCollInp->condInput, RECURSIVE_OPR__KW, "");
02167
02168 rei->status = rsRmColl (rsComm, myRmCollInp, NULL);
02169
02170 if (rei->status >= 0) {
02171 fillIntInMsParam (outParam, rei->status);
02172 } else {
02173 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02174 "msiRmColl: rsRmColl failed for %s, status = %d",
02175 myRmCollInp->collName,
02176 rei->status);
02177 }
02178
02179 if (myRmCollInp == &rmCollInp) {
02180 clearKeyVal (&myRmCollInp->condInput);
02181 }
02182
02183 return (rei->status);
02184 }
02185
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 int
02236 msiReplColl (msParam_t *coll, msParam_t *destRescName, msParam_t *options,
02237 msParam_t *outParam, ruleExecInfo_t *rei)
02238 {
02239 rsComm_t *rsComm;
02240 collInp_t collInp, *myCollInp;
02241 int i, continueInx, status;
02242 transferStat_t *transStat = NULL;
02243 strArray_t optArray;
02244 genQueryInp_t genQueryInp;
02245 genQueryOut_t *genQueryOut = NULL;
02246 dataObjInp_t dataObjInp;
02247
02248 RE_TEST_MACRO (" Calling msiReplColl")
02249
02250 if (rei == NULL || rei->rsComm == NULL) {
02251 rodsLog (LOG_ERROR,
02252 "msiReplColl: input rei or rsComm is NULL");
02253 return (SYS_INTERNAL_NULL_INPUT_ERR);
02254 }
02255
02256 rsComm = rei->rsComm;
02257
02258
02259 rei->status = parseMspForCollInp (coll, &collInp,
02260 &myCollInp, 0);
02261 if (rei->status < 0) {
02262 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02263 "msiReplColl: input inpParam1 error. status = %d", rei->status);
02264 return (rei->status);
02265 }
02266
02267
02268
02269 memset (&dataObjInp, 0, sizeof (dataObjInp_t));
02270 rei->status = parseMspForCondInp (destRescName,
02271 &(&dataObjInp)->condInput, DEST_RESC_NAME_KW);
02272 if (rei->status < 0) {
02273 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02274 "msiReplColl: input inpParam2 error. status = %d", rei->status);
02275 return (rei->status);
02276 }
02277
02278
02279
02280 if ( (strlen((char*)options->inOutStruct)>0) &&
02281 (0!=strcmp((char*)options->inOutStruct,"null")) )
02282 {
02283 memset (&optArray, 0, sizeof (optArray));
02284 status = parseMultiStr ((char *)options->inOutStruct, &optArray);
02285 if (status <= 0)
02286 {
02287 rodsLog (LOG_ERROR,
02288 "msiReplColl: Could not parse options string '%s'",
02289 options->inOutStruct);
02290 }
02291 for(i=0; i<optArray.len; i++)
02292 {
02293 char *option;
02294 option= &optArray.value[i*optArray.size];
02295 if ( strcmp(option,ALL_KW) &&
02296 strcmp(option,IRODS_ADMIN_KW) &&
02297 strcmp(option,"backupMode")
02298 )
02299 {
02300 rodsLog (LOG_ERROR,"msiReplColl: invalid option: '%s'",option);
02301 continue;
02302 }
02303 if (strcmp(option,"backupMode")==0)
02304 addKeyVal (&(dataObjInp.condInput), BACKUP_RESC_NAME_KW,
02305 (char *)destRescName->inOutStruct);
02306 else
02307 addKeyVal (&(dataObjInp.condInput), option, "");
02308 }
02309 }
02310
02311
02312 memset (&genQueryInp, 0, sizeof (genQueryInp));
02313 status = rsQueryDataObjInCollReCur (rsComm, myCollInp->collName,
02314 &genQueryInp, &genQueryOut, NULL, 1);
02315 if (status < 0 && status != CAT_NO_ROWS_FOUND) {
02316 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02317 "msiReplColl: msiReplColl error for %s, stat=%d",
02318 myCollInp->collName, status);
02319 rei->status=status;
02320 return (rei->status);
02321 }
02322 while (rei->status >= 0) {
02323 sqlResult_t *subColl, *dataObj;
02324
02325 if ((subColl = getSqlResultByInx (genQueryOut, COL_COLL_NAME))
02326 == NULL) {
02327 rodsLog (LOG_ERROR,
02328 "msiReplColl: msiReplColl for COL_COLL_NAME failed");
02329 rei->status=UNMATCHED_KEY_OR_INDEX;
02330 return (rei->status);
02331 }
02332
02333 if ((dataObj = getSqlResultByInx (genQueryOut, COL_DATA_NAME))
02334 == NULL) {
02335 rodsLog (LOG_ERROR,
02336 "msiReplColl: msiReplColl for COL_DATA_NAME failed");
02337 rei->status=UNMATCHED_KEY_OR_INDEX;
02338 return (rei->status);
02339 }
02340
02341 for (i = 0; i < genQueryOut->rowCnt; i++) {
02342 char *tmpSubColl, *tmpDataName;
02343
02344 tmpSubColl = &subColl->value[subColl->len * i];
02345 tmpDataName = &dataObj->value[dataObj->len * i];
02346 snprintf (dataObjInp.objPath, MAX_NAME_LEN, "%s/%s",tmpSubColl, tmpDataName);
02347
02348
02349
02350
02351 rmKeyVal( &dataObjInp.condInput, RESC_HIER_STR_KW );
02352 rmKeyVal( &dataObjInp.condInput, DEST_RESC_HIER_STR_KW );
02353
02354 rei->status = rsDataObjRepl (rsComm, &dataObjInp, &transStat);
02355 if (rei->status<0)
02356 {
02357 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02358 "msiReplColl: rsDataObjRepl failed %s, status = %d",
02359 (&dataObjInp)->objPath,
02360 rei->status);
02361 }
02362 if (transStat != NULL) {
02363 free (transStat);
02364 }
02365 }
02366
02367 continueInx = genQueryOut->continueInx;
02368 freeGenQueryOut (&genQueryOut);
02369 if (continueInx > 0) {
02370
02371 genQueryInp.continueInx = continueInx;
02372 rei->status = rsGenQuery (rsComm, &genQueryInp, &genQueryOut);
02373 } else {
02374 break;
02375 }
02376 }
02377
02378 clearKeyVal (&dataObjInp.condInput);
02379
02380 if (rei->status >= 0) {
02381 fillIntInMsParam (outParam, rei->status);
02382 } else {
02383 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02384 "dataObjInp: msiReplColl failed (should have catched earlier) %s, status = %d",
02385 (&dataObjInp)->objPath,
02386 rei->status);
02387 }
02388 return (rei->status);
02389 }
02390
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 int
02436 msiPhyPathReg (msParam_t *inpParam1, msParam_t *inpParam2,
02437 msParam_t *inpParam3, msParam_t *inpParam4, msParam_t *outParam,
02438 ruleExecInfo_t *rei)
02439 {
02440 rsComm_t *rsComm;
02441 dataObjInp_t dataObjInp, *myDataObjInp;
02442
02443 RE_TEST_MACRO (" Calling msiPhyPathReg")
02444
02445 if (rei == NULL || rei->rsComm == NULL) {
02446 rodsLog (LOG_ERROR,
02447 "msiPhyPathReg: input rei or rsComm is NULL");
02448 return (SYS_INTERNAL_NULL_INPUT_ERR);
02449 }
02450
02451 rsComm = rei->rsComm;
02452
02453
02454 rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
02455 &myDataObjInp, 1);
02456
02457 if (rei->status < 0) {
02458 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02459 "msiPhyPathReg: input inpParam1 error. status = %d", rei->status);
02460 return (rei->status);
02461 }
02462
02463 if ((rei->status = parseMspForCondInp (inpParam2, &myDataObjInp->condInput,
02464 DEST_RESC_NAME_KW)) < 0) {
02465 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02466 "msiDataObjPhymv: input inpParam2 error. status = %d", rei->status);
02467 return (rei->status);
02468 }
02469
02470 if ((rei->status = parseMspForCondInp (inpParam3, &myDataObjInp->condInput,
02471 FILE_PATH_KW)) < 0) {
02472 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02473 "msiDataObjPhymv: input inpParam3 error. status = %d", rei->status);
02474 return (rei->status);
02475 }
02476
02477 if ((rei->status = parseMspForPhyPathReg (inpParam4,
02478 &myDataObjInp->condInput)) < 0) {
02479 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02480 "msiPhyPathReg: input inpParam4 error. status = %d", rei->status);
02481 return (rei->status);
02482 }
02483
02484 rei->status = rsPhyPathReg (rsComm, myDataObjInp);
02485
02486 if (myDataObjInp == &dataObjInp) {
02487 clearKeyVal (&myDataObjInp->condInput);
02488 }
02489
02490 if (rei->status >= 0) {
02491 fillIntInMsParam (outParam, rei->status);
02492 } else {
02493 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02494 "msiPhyPathReg: rsPhyPathReg failed for %s, status = %d",
02495 myDataObjInp->objPath,
02496 rei->status);
02497 }
02498
02499 return (rei->status);
02500 }
02501
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 int
02536 msiObjStat (msParam_t *inpParam1, msParam_t *outParam, ruleExecInfo_t *rei)
02537 {
02538 rsComm_t *rsComm;
02539 dataObjInp_t dataObjInp, *myDataObjInp;
02540 rodsObjStat_t *rodsObjStatOut = NULL;
02541
02542 RE_TEST_MACRO (" Calling msiObjStat")
02543
02544 if (rei == NULL || rei->rsComm == NULL) {
02545 rodsLog (LOG_ERROR,
02546 "msiObjStat: input rei or rsComm is NULL");
02547 return (SYS_INTERNAL_NULL_INPUT_ERR);
02548 }
02549
02550 rsComm = rei->rsComm;
02551
02552
02553 rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
02554 &myDataObjInp, 0);
02555
02556 if (rei->status < 0) {
02557 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02558 "msiObjStat: input inpParam1 error. status = %d", rei->status);
02559 return (rei->status);
02560 }
02561
02562 #if 0
02563 rei->status = __rsObjStat (rsComm, myDataObjInp, 1, &rodsObjStatOut);
02564 #endif
02565 rei->status = rsObjStat (rsComm, myDataObjInp, &rodsObjStatOut);
02566
02567 if (rei->status >= 0) {
02568 fillMsParam (outParam, NULL, RodsObjStat_MS_T, rodsObjStatOut, NULL);
02569 } else {
02570 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02571 "msiObjStat: rsObjStat failed for %s, status = %d",
02572 myDataObjInp->objPath,
02573 rei->status);
02574 }
02575
02576 return (rei->status);
02577 }
02578
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 int
02629 msiDataObjRsync (msParam_t *inpParam1, msParam_t *inpParam2,
02630 msParam_t *inpParam3, msParam_t *inpParam4, msParam_t *outParam,
02631 ruleExecInfo_t *rei)
02632 {
02633 rsComm_t *rsComm;
02634 dataObjInp_t dataObjInp, *myDataObjInp;
02635 msParamArray_t *outParamArray = NULL;
02636 char *rsyncMode;
02637 char *targCollection, *tmpPtr;
02638 char targPath[MAX_NAME_LEN];
02639
02640 RE_TEST_MACRO (" Calling msiDataObjRsync")
02641
02642 if (rei == NULL || rei->rsComm == NULL) {
02643 rodsLog (LOG_ERROR,
02644 "msiDataObjRsync: input rei or rsComm is NULL");
02645 return (SYS_INTERNAL_NULL_INPUT_ERR);
02646 }
02647
02648 rsComm = rei->rsComm;
02649
02650
02651 rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
02652 &myDataObjInp, 1);
02653
02654 if (rei->status < 0) {
02655 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02656 "msiDataObjRsync: input inpParam1 error. status = %d", rei->status);
02657 return (rei->status);
02658 }
02659
02660 if ((rei->status = parseMspForCondInp (inpParam2, &myDataObjInp->condInput,
02661 RSYNC_MODE_KW)) < 0) {
02662 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02663 "msiDataObjRsync: input inpParam2 error. status = %d", rei->status);
02664 return (rei->status);
02665 }
02666
02667
02668 if ((rei->status = parseMspForCondInp (inpParam3, &myDataObjInp->condInput,
02669 DEST_RESC_NAME_KW)) < 0) {
02670 #if 0
02671 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02672 "msiDataObjRsync: input inpParam3 error. status = %d", rei->status);
02673 return (rei->status);
02674 #endif
02675 }
02676
02677 if ((rei->status = parseMspForCondInp (inpParam4, &myDataObjInp->condInput,
02678 RSYNC_DEST_PATH_KW)) < 0) {
02679 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02680 "msiDataObjRsync: input inpParam4 error. status = %d", rei->status);
02681 return (rei->status);
02682 }
02683
02684
02685
02686
02687 rsyncMode = getValByKey (&myDataObjInp->condInput, RSYNC_MODE_KW);
02688 if (rsyncMode == NULL) {
02689 rodsLog (LOG_ERROR,
02690 "msiDataObjRsync: RSYNC_MODE_KW input is missing");
02691 rei->status = USER_RSYNC_NO_MODE_INPUT_ERR;
02692 return (rei->status);
02693 }
02694
02695 if (strcmp (rsyncMode, IRODS_TO_LOCAL) == 0 ||
02696 strcmp (rsyncMode, LOCAL_TO_IRODS) == 0) {
02697 rodsLog (LOG_ERROR,
02698 "msiDataObjRsync: local/iRODS rsync not supported for %s",
02699 myDataObjInp->objPath);
02700 rei->status = NO_LOCAL_FILE_RSYNC_IN_MSI;
02701 return (rei->status);
02702 } else if (strcmp (rsyncMode, IRODS_TO_COLLECTION) == 0) {
02703 targCollection = getValByKey (&myDataObjInp->condInput,
02704 RSYNC_DEST_PATH_KW);
02705 if (targCollection == NULL) {
02706 rodsLog (LOG_ERROR,
02707 "msiDataObjRsync: RSYNC_DEST_PATH_KW input for %s is missing",
02708 myDataObjInp->objPath);
02709 rei->status = USER_INPUT_PATH_ERR;
02710 return (rei->status);
02711 }
02712 tmpPtr = strchr (myDataObjInp->objPath + 1, '/');
02713 if (tmpPtr == NULL) {
02714 rodsLog (LOG_ERROR,
02715 "msiDataObjRsync: problem parsing %s", myDataObjInp->objPath);
02716 rei->status = USER_INPUT_PATH_ERR;
02717 return (rei->status);
02718 }
02719 snprintf (targPath, MAX_NAME_LEN, "%s%s", targCollection, tmpPtr);
02720 addKeyVal (&myDataObjInp->condInput, RSYNC_MODE_KW, IRODS_TO_IRODS);
02721 addKeyVal (&myDataObjInp->condInput, RSYNC_DEST_PATH_KW, targPath);
02722 }
02723
02724 rei->status = rsDataObjRsync (rsComm, myDataObjInp, &outParamArray);
02725
02726 if (outParamArray != NULL) {
02727 clearMsParamArray (outParamArray, 1);
02728 free (outParamArray);
02729 }
02730 if (myDataObjInp == &dataObjInp) {
02731 clearKeyVal (&myDataObjInp->condInput);
02732 }
02733
02734 if (rei->status >= 0) {
02735 fillIntInMsParam (outParam, rei->status);
02736 } else {
02737 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02738 "msiDataObjRsync: rsDataObjRsync failed for %s, status = %d",
02739 myDataObjInp->objPath,
02740 rei->status);
02741 }
02742
02743 return (rei->status);
02744 }
02745
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 int
02787 msiCollRsync (msParam_t *inpParam1, msParam_t *inpParam2,
02788 msParam_t *inpParam3, msParam_t *inpParam4, msParam_t *outParam,
02789 ruleExecInfo_t *rei)
02790 {
02791 rsComm_t *rsComm;
02792 dataObjInp_t dataObjInp;
02793 char *rsyncMode;
02794 char *srcColl = NULL;
02795 char *destColl = NULL;
02796
02797 RE_TEST_MACRO (" Calling msiCollRsync")
02798
02799 if (rei == NULL || rei->rsComm == NULL) {
02800 rodsLog (LOG_ERROR,
02801 "msiCollRsync: input rei or rsComm is NULL");
02802 return (SYS_INTERNAL_NULL_INPUT_ERR);
02803 }
02804
02805 rsComm = rei->rsComm;
02806
02807 bzero (&dataObjInp, sizeof (dataObjInp));
02808
02809
02810 srcColl = parseMspForStr (inpParam1);
02811
02812 if (srcColl == NULL) {
02813 rei->status = SYS_INVALID_FILE_PATH;
02814 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02815 "msiCollRsync: input inpParam1 error. status = %d", rei->status);
02816 return (rei->status);
02817 }
02818
02819
02820 destColl = parseMspForStr (inpParam2);
02821
02822 if (destColl == NULL) {
02823 rei->status = SYS_INVALID_FILE_PATH;
02824 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02825 "msiCollRsync: input inpParam2 error. status = %d", rei->status);
02826 return (rei->status);
02827 }
02828
02829 if ((rei->status = parseMspForCondInp (inpParam3, &dataObjInp.condInput,
02830 DEST_RESC_NAME_KW)) < 0) {
02831 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02832 "msiCollRsync: input inpParam3 error. status = %d", rei->status);
02833 return (rei->status);
02834 }
02835
02836 if ((rei->status = parseMspForCondInp (inpParam4, &dataObjInp.condInput,
02837 RSYNC_MODE_KW)) < 0) {
02838 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02839 "msiCollRsync: input inpParam4 error. status = %d", rei->status);
02840 return (rei->status);
02841 }
02842
02843
02844
02845
02846 rsyncMode = getValByKey (&dataObjInp.condInput, RSYNC_MODE_KW);
02847 if (rsyncMode == NULL) {
02848 rodsLog (LOG_ERROR,
02849 "msiCollRsync: RSYNC_MODE_KW input is missing");
02850 rei->status = USER_RSYNC_NO_MODE_INPUT_ERR;
02851 return (rei->status);
02852 }
02853
02854 if (strcmp (rsyncMode, IRODS_TO_LOCAL) == 0 ||
02855 strcmp (rsyncMode, LOCAL_TO_IRODS) == 0) {
02856 rodsLog (LOG_ERROR,
02857 "msiCollRsync: local/iRODS rsync not supported for %s",
02858 srcColl);
02859 rei->status = NO_LOCAL_FILE_RSYNC_IN_MSI;
02860 return (rei->status);
02861 }
02862
02863 rei->status = _rsCollRsync (rsComm, &dataObjInp, srcColl, destColl);
02864
02865 clearKeyVal (&dataObjInp.condInput);
02866
02867 if (rei->status >= 0) {
02868 fillIntInMsParam (outParam, rei->status);
02869 } else {
02870 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
02871 "msiCollRsync: rsDataObjRsync failed for %s, status = %d",
02872 srcColl,
02873 rei->status);
02874 }
02875
02876 return (rei->status);
02877 }
02878
02879 int
02880 _rsCollRsync (rsComm_t *rsComm, dataObjInp_t *dataObjInp,
02881 char *srcColl, char *destColl)
02882 {
02883 collInp_t openCollInp;
02884 collEnt_t *collEnt;
02885 int handleInx;
02886 char parPath[MAX_NAME_LEN], childPath[MAX_NAME_LEN];
02887 char destChildPath[MAX_NAME_LEN];
02888 msParamArray_t *outParamArray = NULL;
02889 int status = 0;
02890 int status1 = 0;
02891
02892 memset (&openCollInp, 0, sizeof (openCollInp));
02893 rstrcpy (openCollInp.collName, srcColl, MAX_NAME_LEN);
02894 openCollInp.flags = 0;
02895 handleInx = rsOpenCollection (rsComm, &openCollInp);
02896 if (handleInx < 0) {
02897 rodsLog (LOG_ERROR,
02898 "_rsCollRsync: rsOpenCollection of %s error. status = %d",
02899 openCollInp.collName, handleInx);
02900 return (handleInx);
02901 }
02902
02903 #if 0
02904 if (CollHandle[handleInx].rodsObjStat->specColl != NULL) {
02905 rodsLog (LOG_ERROR,
02906 "_rsCollRsync: unable to rsync mounted collection %s", srcColl);
02907 rsCloseCollection (rsComm, &handleInx);
02908 return (0);
02909 }
02910 #endif
02911
02912 rsMkCollR (rsComm, "/", destColl);
02913 while ((status1 = rsReadCollection (rsComm, &handleInx, &collEnt)) >= 0) {
02914 if (collEnt->objType == DATA_OBJ_T) {
02915 snprintf (dataObjInp->objPath, MAX_NAME_LEN, "%s/%s",
02916 srcColl, collEnt->dataName);
02917 snprintf (destChildPath, MAX_NAME_LEN, "%s/%s",
02918 destColl, collEnt->dataName);
02919 addKeyVal (&dataObjInp->condInput, RSYNC_DEST_PATH_KW,
02920 destChildPath);
02921 status = rsDataObjRsync (rsComm, dataObjInp, &outParamArray);
02922 if (outParamArray != NULL) {
02923 clearMsParamArray (outParamArray, 1);
02924 free (outParamArray);
02925 }
02926 } else if (collEnt->objType == COLL_OBJ_T) {
02927 if ((status = splitPathByKey (
02928 collEnt->collName, parPath, childPath, '/')) < 0) {
02929 rodsLogError (LOG_ERROR, status,
02930 "_rsCollRsync:: splitPathByKey for %s error, status = %d",
02931 collEnt->collName, status);
02932 return (status);
02933 }
02934 snprintf (destChildPath, MAX_NAME_LEN, "%s/%s",
02935 destColl, childPath);
02936
02937 status = _rsCollRsync (rsComm, dataObjInp, collEnt->collName,
02938 destChildPath);
02939 }
02940 free (collEnt);
02941 if (status < 0) break;
02942 }
02943 rsCloseCollection (rsComm, &handleInx);
02944 if (status1 < 0 && status1 != CAT_NO_ROWS_FOUND)
02945 return status1;
02946 else
02947 return status;
02948 }
02949
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 int
03001 msiExecCmd (msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *inpParam3,
03002 msParam_t *inpParam4, msParam_t *inpParam5, msParam_t *outParam,
03003 ruleExecInfo_t *rei)
03004 {
03005 rsComm_t *rsComm;
03006 execCmd_t execCmdInp, *myExecCmdInp;
03007 execCmdOut_t *execCmdOut = NULL;
03008 char *tmpPtr;
03009
03010 RE_TEST_MACRO (" Calling msiExecCmd")
03011
03012 if (rei == NULL || rei->rsComm == NULL) {
03013 rodsLog (LOG_ERROR,
03014 "msiExecCmd: input rei or rsComm is NULL");
03015 return (SYS_INTERNAL_NULL_INPUT_ERR);
03016 }
03017
03018 rsComm = rei->rsComm;
03019
03020
03021 rei->status = parseMspForExecCmdInp (inpParam1, &execCmdInp,
03022 &myExecCmdInp);
03023
03024 if (rei->status < 0) {
03025 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03026 "msiExecCmd: input inpParam1 error. status = %d", rei->status);
03027 return (rei->status);
03028 }
03029
03030 if ((tmpPtr = parseMspForStr (inpParam2)) != NULL) {
03031 rstrcpy (myExecCmdInp->cmdArgv, tmpPtr, HUGE_NAME_LEN);
03032 }
03033
03034 if ((tmpPtr = parseMspForStr (inpParam3)) != NULL) {
03035 rstrcpy (myExecCmdInp->execAddr, tmpPtr, MAX_NAME_LEN);
03036 }
03037
03038 if ((tmpPtr = parseMspForStr (inpParam4)) != NULL) {
03039 rstrcpy (myExecCmdInp->hintPath, tmpPtr, MAX_NAME_LEN);
03040 }
03041
03042 if (parseMspForPosInt (inpParam5) > 0) {
03043 myExecCmdInp->addPathToArgv = 1;
03044 }
03045
03046 if (strlen (rei->ruleName) > 0 &&
03047 strcmp (rei->ruleName, EXEC_MY_RULE_KW) != 0) {
03048
03049 addKeyVal(&myExecCmdInp->condInput, EXEC_CMD_RULE_KW, rei->ruleName);
03050 }
03051 rei->status = rsExecCmd (rsComm, myExecCmdInp, &execCmdOut);
03052
03053 if (myExecCmdInp == &execCmdInp) {
03054 clearKeyVal (&myExecCmdInp->condInput);
03055 }
03056
03057 if (execCmdOut != NULL) {
03058 fillMsParam (outParam, NULL, ExecCmdOut_MS_T, execCmdOut, NULL);
03059 }
03060
03061 if (rei->status < 0) {
03062 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03063 "msiExecCmd: rsExecCmd failed for %s, status = %d",
03064 myExecCmdInp->cmd,
03065 rei->status);
03066 }
03067
03068 return (rei->status);
03069 }
03070
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 int
03132 msiCollRepl (msParam_t *collection, msParam_t *msKeyValStr, msParam_t *status,
03133 ruleExecInfo_t *rei)
03134 {
03135
03136 collInp_t collInpCache, *collInp;
03137 char *outBadKeyWd;
03138 int validKwFlags;
03139
03140
03141 rsComm_t *rsComm;
03142
03143
03144
03145
03146
03147 RE_TEST_MACRO (" Calling msiCollRepl")
03148
03149
03150 if (rei == NULL || rei->rsComm == NULL) {
03151 rodsLog (LOG_ERROR, "msiCollRepl: inp rei or rsComm is NULL.");
03152 return (SYS_INTERNAL_NULL_INPUT_ERR);
03153 }
03154
03155 rsComm = rei->rsComm;
03156
03157
03158
03159
03160 rei->status =
03161 parseMspForCollInp (collection, &collInpCache, &collInp, 0);
03162
03163 if (rei->status < 0) {
03164 rodsLog (LOG_ERROR,
03165 "msiCollRepl: input collection error. status = %d", rei->status);
03166 return (rei->status);
03167 }
03168
03169
03170
03171 #if 0
03172 rei->status = parseMspForCondInp (targetResc,
03173 &collInp->condInput, DEST_RESC_NAME_KW);
03174 #else
03175 validKwFlags = COLL_NAME_FLAG | DEST_RESC_NAME_FLAG |
03176 BACKUP_RESC_NAME_FLAG | RESC_NAME_FLAG | UPDATE_REPL_FLAG |
03177 REPL_NUM_FLAG | ALL_FLAG | IRODS_ADMIN_FLAG | VERIFY_CHKSUM_FLAG;
03178 rei->status = parseMsKeyValStrForCollInp (msKeyValStr, collInp,
03179 DEST_RESC_NAME_KW, validKwFlags, &outBadKeyWd);
03180 #endif
03181
03182 if (rei->status < 0) {
03183 if (outBadKeyWd != NULL) {
03184 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03185 "msiCollRepl: input keyWd - %s error. status = %d",
03186 outBadKeyWd, rei->status);
03187 free (outBadKeyWd);
03188 } else {
03189 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03190 "msiCollRepl: input msKeyValStr error. status = %d",
03191 rei->status);
03192 }
03193 return (rei->status);
03194 }
03195
03196
03197
03198
03199 rei->status = rsCollRepl (rsComm, collInp, NULL);
03200
03201
03202
03203
03204 fillIntInMsParam (status, rei->status);
03205
03206 return (rei->status);
03207 }
03208
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 int
03257 msiDataObjPutWithOptions (msParam_t *inpParam1, msParam_t *inpParam2,
03258 msParam_t *inpParam3,msParam_t *inpOverwriteParam,
03259 msParam_t *inpAllCopiesParam, msParam_t *outParam, ruleExecInfo_t *rei)
03260 {
03261 rsComm_t *rsComm;
03262 dataObjInp_t *dataObjInp, *myDataObjInp;
03263 msParamArray_t *myMsParamArray;
03264
03265 RE_TEST_MACRO (" Calling msiDataObjPut")
03266
03267 if (rei == NULL || rei->rsComm == NULL) {
03268 rodsLog (LOG_ERROR,
03269 "msiDataObjPut: input rei or rsComm is NULL");
03270 return (SYS_INTERNAL_NULL_INPUT_ERR);
03271 }
03272
03273 rsComm = rei->rsComm;
03274
03275 dataObjInp = (dataObjInp_t*)malloc (sizeof (dataObjInp_t));
03276
03277 rei->status = parseMspForDataObjInp (inpParam1, dataObjInp,
03278 &myDataObjInp, 1);
03279
03280 if (rei->status < 0) {
03281 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03282 "msiDataObjPut: input inpParam1 error. status = %d", rei->status);
03283 return (rei->status);
03284 }
03285
03286 rei->status = parseMspForCondInp (inpParam2, &dataObjInp->condInput,
03287 DEST_RESC_NAME_KW);
03288
03289 if (rei->status < 0) {
03290 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03291 "msiDataObjPut: input inpParam2 error. status = %d", rei->status);
03292 return (rei->status);
03293 }
03294
03295
03296 rei->status = parseMspForCondInp (inpParam3, &dataObjInp->condInput,
03297 LOCAL_PATH_KW);
03298
03299 if (rei->status < 0) {
03300 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03301 "msiDataObjPut: input inpParam3 error. status = %d", rei->status);
03302 return (rei->status);
03303 }
03304
03305 if (inpOverwriteParam != NULL &&
03306 strcmp((char*)inpOverwriteParam->inOutStruct, FORCE_FLAG_KW) == 0 )
03307 rei->status = parseMspForCondInp (inpOverwriteParam,
03308 &dataObjInp->condInput,FORCE_FLAG_KW);
03309
03310 if (inpAllCopiesParam !=NULL &&
03311 strcmp((char*)inpAllCopiesParam->inOutStruct, ALL_KW) == 0 )
03312 rei->status = parseMspForCondInp (inpAllCopiesParam,
03313 &dataObjInp->condInput,ALL_KW);
03314
03315 myMsParamArray = (msParamArray_t*)malloc (sizeof (msParamArray_t));
03316 memset (myMsParamArray, 0, sizeof (msParamArray_t));
03317
03318 rei->status = addMsParam (myMsParamArray, CL_PUT_ACTION, DataObjInp_MS_T,
03319 (void *) dataObjInp, NULL);
03320
03321 if (rei->status < 0) {
03322 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03323 "msiDataObjPut: addMsParam error. status = %d", rei->status);
03324 return (rei->status);
03325 }
03326
03327
03328 rei->status = sendAndRecvBranchMsg (rsComm, rsComm->apiInx,
03329 SYS_SVR_TO_CLI_MSI_REQUEST, (void *) myMsParamArray, NULL);
03330
03331 if (rei->status >= 0) {
03332 fillIntInMsParam (outParam, rei->status);
03333 } else {
03334 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03335 "msiDataObjPut: rsDataObjPut failed for %s, status = %d",
03336 dataObjInp->objPath,
03337 rei->status);
03338 }
03339
03340 return (rei->status);
03341 }
03342
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 int
03384 msiDataObjReplWithOptions (msParam_t *inpParam1, msParam_t *inpParam2,
03385 msParam_t *inpParam3, msParam_t *outParam, ruleExecInfo_t *rei)
03386 {
03387 rsComm_t *rsComm;
03388 dataObjInp_t dataObjInp, *myDataObjInp;
03389 transferStat_t *transStat = NULL;
03390
03391 RE_TEST_MACRO (" Calling msiDataObjReplWithOptions")
03392
03393 if (rei == NULL || rei->rsComm == NULL) {
03394 rodsLog (LOG_ERROR,
03395 "msiDataObjReplWithOptions: input rei or rsComm is NULL");
03396 return (SYS_INTERNAL_NULL_INPUT_ERR);
03397 }
03398
03399 rsComm = rei->rsComm;
03400
03401
03402 rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
03403 &myDataObjInp, 0);
03404
03405 if (rei->status < 0) {
03406 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03407 "msiDataObjReplWithOptions: input inpParam1 error. status = %d",
03408 rei->status);
03409 return (rei->status);
03410 }
03411
03412 rei->status = parseMspForCondInp (inpParam2, &myDataObjInp->condInput,
03413 DEST_RESC_NAME_KW);
03414
03415 if (rei->status < 0) {
03416 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03417 "msiDataObjReplWithOptions: input inpParam2 error. status = %d",
03418 rei->status);
03419 return (rei->status);
03420 }
03421
03422 if ((rei->status = parseMspForCondKw (inpParam3, &myDataObjInp->condInput))
03423 < 0) {
03424 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03425 "msiDataObjReplWithOptions: input inpParam3 error. status = %d",
03426 rei->status);
03427 return (rei->status);
03428 }
03429
03430 rei->status = rsDataObjRepl (rsComm, myDataObjInp, &transStat);
03431
03432 if (myDataObjInp == &dataObjInp) {
03433 clearKeyVal (&myDataObjInp->condInput);
03434 }
03435
03436 if (transStat != NULL) {
03437 free (transStat);
03438 }
03439
03440 if (rei->status >= 0) {
03441 fillIntInMsParam (outParam, rei->status);
03442 } else {
03443 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03444 "msiDataObjReplWithOptions: rsDataObjRepl failed %s, status = %d",
03445 myDataObjInp->objPath, rei->status);
03446 }
03447
03448 return (rei->status);
03449 }
03450
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 int
03494 msiDataObjChksumWithOptions (msParam_t *inpParam1, msParam_t *inpParam2,
03495 msParam_t *inpParam3, msParam_t *outParam, ruleExecInfo_t *rei)
03496 {
03497 rsComm_t *rsComm;
03498 dataObjInp_t dataObjInp, *myDataObjInp;
03499 char *chksum = NULL;
03500
03501 RE_TEST_MACRO (" Calling msiDataObjChksumWithOptions")
03502
03503 if (rei == NULL || rei->rsComm == NULL) {
03504 rodsLog (LOG_ERROR,
03505 "msiDataObjChksumRepl: input rei or rsComm is NULL");
03506 return (SYS_INTERNAL_NULL_INPUT_ERR);
03507 }
03508
03509 rsComm = rei->rsComm;
03510
03511
03512 rei->status = parseMspForDataObjInp (inpParam1, &dataObjInp,
03513 &myDataObjInp, 1);
03514
03515 if (rei->status < 0) {
03516 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03517 "msiDataObjChksumWithOptions: input inpParam1 error. status = %d",
03518 rei->status);
03519 return (rei->status);
03520 }
03521
03522 if ((rei->status = parseMspForCondKw (inpParam2,
03523 &myDataObjInp->condInput)) < 0) {
03524 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03525 "msiDataObjChksumWithOptions: input inpParam2 error. status = %d",
03526 rei->status);
03527 return (rei->status);
03528 }
03529
03530 if (inpParam3 != NULL && strcmp( inpParam3->type, STR_MS_T) == 0) {
03531 if (strcmp ((char *) inpParam3->inOutStruct, CHKSUM_ALL_KW) == 0) {
03532 if ((rei->status = parseMspForCondKw (inpParam3,
03533 &myDataObjInp->condInput)) < 0) {
03534 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03535 "msiDataObjChksumWithOptions: input inpParam3 error.stat=%d",
03536 rei->status);
03537 return (rei->status);
03538 }
03539 } else {
03540
03541 if ((rei->status = parseMspForCondInp (inpParam3,
03542 &myDataObjInp->condInput, REPL_NUM_KW)) < 0) {
03543 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03544 "msiDataObjChksumWithOptions: input inpParam3 error.stat=%d",
03545 rei->status);
03546 return (rei->status);
03547 }
03548 }
03549 }
03550 rei->status = rsDataObjChksum (rsComm, myDataObjInp, &chksum);
03551
03552 if (myDataObjInp == &dataObjInp) {
03553 clearKeyVal (&myDataObjInp->condInput);
03554 }
03555
03556 if (rei->status >= 0) {
03557 fillStrInMsParam (outParam, chksum);
03558 free (chksum);
03559 } else {
03560 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03561 "msiDataObjChksumWithOptions: rsDataObjChksum failed for %s,stat=%d",
03562 myDataObjInp->objPath, rei->status);
03563 }
03564
03565 return (rei->status);
03566 }
03567
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 int
03608 msiTarFileExtract (msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *inpParam3, msParam_t *outParam, ruleExecInfo_t *rei)
03609 {
03610 rsComm_t *rsComm;
03611 structFileExtAndRegInp_t structFileExtAndRegInp,
03612 *myStructFileExtAndRegInp;
03613 keyValPair_t regParam;
03614 modDataObjMeta_t modDataObjMetaInp;
03615 int rc1;
03616 char origDataType[NAME_LEN];
03617
03618 RE_TEST_MACRO (" Calling msiTarFileExtract")
03619
03620 if (rei == NULL || rei->rsComm == NULL) {
03621 rodsLog (LOG_ERROR,
03622 "msiTarFileExtract: input rei or rsComm is NULL");
03623 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
03624 return (rei->status);
03625 }
03626
03627 rsComm = rei->rsComm;
03628
03629
03630
03631
03632
03633 if ( inpParam1 == NULL || inpParam2 == NULL ) {
03634 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03635 "msiTarFileExtract: input Param1 and/or Param2 are NULL");
03636 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
03637 return (rei->status);
03638 }
03639
03640 if (strcmp (inpParam1->type, STR_MS_T) == 0) {
03641 bzero (&structFileExtAndRegInp, sizeof (structFileExtAndRegInp));
03642 myStructFileExtAndRegInp = &structFileExtAndRegInp;
03643 strncpy ((char*)myStructFileExtAndRegInp->objPath, (char*)inpParam1->inOutStruct,
03644 MAX_NAME_LEN);
03645 } else if (strcmp (inpParam1->type, StructFileExtAndRegInp_MS_T) == 0) {
03646 myStructFileExtAndRegInp =
03647 (structFileExtAndRegInp_t *) inpParam1->inOutStruct;
03648 } else {
03649 rei->status = UNKNOWN_PARAM_IN_RULE_ERR;
03650 return (rei->status);
03651 }
03652
03653 if ( strcmp (inpParam2->type, STR_MS_T) == 0 ) {
03654 if (strcmp ((char *) inpParam2->inOutStruct, "null") != 0) {
03655 strncpy ((char*)myStructFileExtAndRegInp->collection,
03656 (char*)inpParam2->inOutStruct, MAX_NAME_LEN);
03657 }
03658 } else {
03659 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03660 "msiTarFileExtract: Unsupported input Param2 type %s",
03661 inpParam2->type);
03662 rei->status = UNKNOWN_PARAM_IN_RULE_ERR;
03663 return (rei->status);
03664 }
03665
03666 if ( strcmp (inpParam3->type, STR_MS_T) == 0 && inpParam3 != NULL &&
03667 strcmp ( (char *) inpParam3->inOutStruct, "null") != 0) {
03668 addKeyVal(&myStructFileExtAndRegInp->condInput, DEST_RESC_NAME_KW,
03669 (char *) inpParam3->inOutStruct);
03670
03671 addKeyVal(&myStructFileExtAndRegInp->condInput, RESC_NAME_KW,
03672 (char *) inpParam3->inOutStruct);
03673 }
03674
03675 if (rei->doi != NULL) {
03676
03677
03678 strncpy(origDataType, rei->doi->dataType, NAME_LEN);
03679
03680 memset(®Param, 0, sizeof(regParam));
03681 addKeyVal(®Param, DATA_TYPE_KW, "tar file");
03682 modDataObjMetaInp.dataObjInfo = rei->doi;
03683 modDataObjMetaInp.regParam = ®Param;
03684 rc1 = rsModDataObjMeta(rsComm, &modDataObjMetaInp);
03685 }
03686
03687
03688 rei->status = rsStructFileExtAndReg (rsComm, myStructFileExtAndRegInp);
03689 if ( rei->status < 0 && rei->doi != NULL) {
03690 rodsLog (LOG_ERROR, "msiTarFileExtract: tar file extraction failed");
03691
03692
03693 memset(®Param, 0, sizeof(regParam));
03694 addKeyVal(®Param, DATA_TYPE_KW, origDataType);
03695 rc1 = rsModDataObjMeta(rsComm, &modDataObjMetaInp);
03696 }
03697
03698 fillIntInMsParam (outParam, rei->status);
03699
03700 return (rei->status);
03701 }
03702
03703
03704
03705
03706
03707
03708
03709
03710
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 int
03743 msiTarFileCreate (msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *inpParam3, msParam_t *inpParam4, ruleExecInfo_t *rei)
03744 {
03745 rsComm_t *rsComm;
03746 structFileExtAndRegInp_t structFileExtAndRegInp,
03747 *myStructFileExtAndRegInp;
03748
03749 RE_TEST_MACRO (" Calling msiTarFileCreate")
03750
03751 if (rei == NULL || rei->rsComm == NULL) {
03752 rodsLog (LOG_ERROR,
03753 "msiTarFileCreate: input rei or rsComm is NULL");
03754 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
03755 return (rei->status);
03756 }
03757
03758 rsComm = rei->rsComm;
03759
03760
03761
03762
03763
03764 if ( inpParam1 == NULL || inpParam2 == NULL ) {
03765 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03766 "msiTarFileCreate: input Param1 and/or Param2 are NULL");
03767 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
03768 return (rei->status);
03769 }
03770
03771 if (strcmp (inpParam1->type, STR_MS_T) == 0) {
03772 bzero (&structFileExtAndRegInp, sizeof (structFileExtAndRegInp));
03773 myStructFileExtAndRegInp = &structFileExtAndRegInp;
03774 strncpy ((char*)myStructFileExtAndRegInp->objPath, (char*)inpParam1->inOutStruct,
03775 MAX_NAME_LEN);
03776 } else if (strcmp (inpParam1->type, StructFileExtAndRegInp_MS_T) == 0) {
03777 myStructFileExtAndRegInp =
03778 (structFileExtAndRegInp_t *) inpParam1->inOutStruct;
03779 } else {
03780 rei->status = UNKNOWN_PARAM_IN_RULE_ERR;
03781 return (rei->status);
03782 }
03783
03784 if ( strcmp (inpParam2->type, STR_MS_T) == 0 ) {
03785 if (strcmp ((char *) inpParam2->inOutStruct, "null") != 0) {
03786 strncpy ((char*)myStructFileExtAndRegInp->collection,
03787 (char*)inpParam2->inOutStruct, MAX_NAME_LEN);
03788 }
03789 } else {
03790 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03791 "msiTarFileExtract: Unsupported input Param2 type %s",
03792 inpParam2->type);
03793 rei->status = UNKNOWN_PARAM_IN_RULE_ERR;
03794 return (rei->status);
03795 }
03796
03797 if ( strcmp (inpParam3->type, STR_MS_T) == 0 && inpParam3 != NULL &&
03798 strcmp ( (char *) inpParam3->inOutStruct, "null") != 0) {
03799 addKeyVal(&myStructFileExtAndRegInp->condInput, DEST_RESC_NAME_KW,
03800 (char *) inpParam3->inOutStruct);
03801 }
03802
03803 if ( strcmp (inpParam4->type, STR_MS_T) == 0 && inpParam4 != NULL &&
03804 strcmp ( (char *) inpParam4->inOutStruct, "force") == 0) {
03805 addKeyVal(&myStructFileExtAndRegInp->condInput, FORCE_FLAG_KW, "");
03806 }
03807
03808
03809 rei->status = rsStructFileBundle (rsComm, myStructFileExtAndRegInp);
03810
03811 return (rei->status);
03812
03813 }
03814
03815
03816
03817
03818
03819
03820
03821
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 int
03861 msiPhyBundleColl (msParam_t *inpParam1, msParam_t *inpParam2, msParam_t *outParam, ruleExecInfo_t *rei)
03862 {
03863 rsComm_t *rsComm;
03864 structFileExtAndRegInp_t structFileExtAndRegInp,
03865 *myStructFileExtAndRegInp;
03866 int len1, len2;
03867 char *inpStr, rescName[NAME_LEN], *pstr1, *pstr2, attr[MAX_NAME_LEN];
03868
03869 RE_TEST_MACRO (" Calling msiPhyBundleColl")
03870
03871 if (rei == NULL || rei->rsComm == NULL) {
03872 rodsLog (LOG_ERROR,
03873 "msiPhyBundleColl: input rei or rsComm is NULL");
03874 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
03875 return (rei->status);
03876 }
03877
03878 rsComm = rei->rsComm;
03879
03880
03881
03882
03883
03884
03885 if ( inpParam1 == NULL) {
03886 rodsLogAndErrorMsg (LOG_ERROR, &rsComm->rError, rei->status,
03887 "msiPhyBundleColl: input Param1 is NULL");
03888 rei->status = SYS_INTERNAL_NULL_INPUT_ERR;
03889 return (rei->status);
03890 }
03891
03892
03893 if (strcmp (inpParam1->type, STR_MS_T) == 0) {
03894 bzero (&structFileExtAndRegInp, sizeof (structFileExtAndRegInp));
03895 myStructFileExtAndRegInp = &structFileExtAndRegInp;
03896 strncpy ((char*)myStructFileExtAndRegInp->collection, (char*)inpParam1->inOutStruct,
03897 MAX_NAME_LEN);
03898
03899 } else if (strcmp (inpParam1->type, StructFileExtAndRegInp_MS_T) == 0) {
03900 myStructFileExtAndRegInp =
03901 (structFileExtAndRegInp_t *) inpParam1->inOutStruct;
03902
03903 } else {
03904
03905 rei->status = UNKNOWN_PARAM_IN_RULE_ERR;
03906 return (rei->status);
03907 }
03908
03909 if( strcmp (inpParam2->type, STR_MS_T) == 0 && inpParam2 != NULL &&
03910
03911 strcmp ( (char *) inpParam2->inOutStruct, "null") != 0) {
03912 inpStr = (char *) inpParam2->inOutStruct;
03913
03914 pstr1 = strstr(inpStr, "++++");
03915 if ( pstr1 != NULL ) {
03916 len1 = strlen(inpStr) - strlen(pstr1);
03917 if ( len1 > 0 ) {
03918 strncpy(rescName, inpStr, len1);
03919 addKeyVal(&myStructFileExtAndRegInp->condInput, DEST_RESC_NAME_KW, rescName);
03920 }
03921 pstr2 = strstr(pstr1 + 4, "=");
03922 if ( pstr2 != NULL ) {
03923 len2 = strlen(pstr1 + 4) - strlen(pstr2);
03924 memset(attr, 0, sizeof(attr));
03925 strncpy(attr, pstr1 + 4, len2);
03926 if ( len2 > 0 ) {
03927 if ( strcmp(attr, "N") == 0 ) {
03928 addKeyVal(&myStructFileExtAndRegInp->condInput, MAX_SUB_FILE_KW, pstr2 + 1);
03929 }
03930 }
03931 }
03932 }
03933 else {
03934 addKeyVal(&myStructFileExtAndRegInp->condInput, DEST_RESC_NAME_KW, inpStr);
03935 }
03936
03937
03938 }
03939
03940
03941 rei->status = rsPhyBundleColl (rsComm, myStructFileExtAndRegInp);
03942
03943
03944 fillIntInMsParam (outParam, rei->status);
03945
03946
03947 return (rei->status);
03948
03949 }
03950