00001
00002
00003
00004
00005
00006 #include "modColl.h"
00007 #include "icatHighLevelRoutines.h"
00008
00009 int
00010 rsModColl (rsComm_t *rsComm, collInp_t *modCollInp)
00011 {
00012 int status;
00013 rodsServerHost_t *rodsServerHost = NULL;
00014
00015 status = getAndConnRcatHost (rsComm, MASTER_RCAT, modCollInp->collName,
00016 &rodsServerHost);
00017 if (status < 0 || NULL == rodsServerHost ) {
00018 return(status);
00019 }
00020 if (rodsServerHost->localFlag == LOCAL_HOST) {
00021 #ifdef RODS_CAT
00022 status = _rsModColl (rsComm, modCollInp);
00023 #else
00024 status = SYS_NO_RCAT_SERVER_ERR;
00025 #endif
00026 } else {
00027 status = rcModColl (rodsServerHost->conn, modCollInp);
00028 }
00029
00030 return (status);
00031 }
00032
00033 int
00034 _rsModColl (rsComm_t *rsComm, collInp_t *modCollInp)
00035 {
00036 #ifdef RODS_CAT
00037 int status;
00038 collInfo_t collInfo;
00039 char *tmpStr;
00040
00041 int i;
00042 ruleExecInfo_t rei2;
00043
00044 memset ((char*)&rei2, 0, sizeof (ruleExecInfo_t));
00045 rei2.rsComm = rsComm;
00046 if (rsComm != NULL) {
00047 rei2.uoic = &rsComm->clientUser;
00048 rei2.uoip = &rsComm->proxyUser;
00049 }
00050
00051 memset (&collInfo, 0, sizeof (collInfo));
00052
00053 rstrcpy (collInfo.collName, modCollInp->collName, MAX_NAME_LEN);
00054
00055 if ((tmpStr = getValByKey (&modCollInp->condInput,
00056 COLLECTION_TYPE_KW)) != NULL) {
00057 rstrcpy (collInfo.collType, tmpStr, NAME_LEN);
00058 }
00059 if ((tmpStr = getValByKey (&modCollInp->condInput,
00060 COLLECTION_INFO1_KW)) != NULL) {
00061 rstrcpy (collInfo.collInfo1, tmpStr, MAX_NAME_LEN);
00062 }
00063 if ((tmpStr = getValByKey (&modCollInp->condInput,
00064 COLLECTION_INFO2_KW)) != NULL) {
00065 rstrcpy (collInfo.collInfo2, tmpStr, MAX_NAME_LEN);
00066 }
00067
00068 rei2.coi = &collInfo;
00069 i = applyRule("acPreProcForModifyCollMeta",NULL, &rei2, NO_SAVE_REI);
00070 if (i < 0) {
00071 if (rei2.status < 0) {
00072 i = rei2.status;
00073 }
00074 rodsLog (LOG_ERROR,
00075 "rsGeneralAdmin:acPreProcForModifyCollMeta error for %s,stat=%d",
00076 modCollInp->collName, i);
00077 return i;
00078 }
00079
00080
00081 status = chlModColl (rsComm, &collInfo);
00082
00083
00084 if (status >= 0) {
00085 i = applyRule("acPostProcForModifyCollMeta",NULL, &rei2, NO_SAVE_REI);
00086 if (i < 0) {
00087 if (rei2.status < 0) {
00088 i = rei2.status;
00089 }
00090 rodsLog (LOG_ERROR,
00091 "rsGeneralAdmin:acPostProcForModifyCollMeta error for %s,stat=%d",
00092 modCollInp->collName, i);
00093 return i;
00094 }
00095 }
00096
00097
00098
00099 if (status >= 0) {
00100 status = chlCommit(rsComm);
00101 }
00102 else {
00103 chlRollback(rsComm);
00104 }
00105
00106 return (status);
00107 #else
00108 return (SYS_NO_RCAT_SERVER_ERR);
00109 #endif
00110 }
00111
00112 #ifdef COMPAT_201
00113 int
00114 rsModColl201 (rsComm_t *rsComm, collInp201_t *modCollInp)
00115 {
00116 collInp_t collInp;
00117 int status;
00118
00119 collInp201ToCollInp (modCollInp, &collInp);
00120
00121 status = rsModColl (rsComm, &collInp);
00122
00123 return status;
00124 }
00125 #endif
00126