00001
00002
00003
00004
00005
00006 #include "regColl.h"
00007 #include "icatHighLevelRoutines.h"
00008
00009 int
00010 rsRegColl (rsComm_t *rsComm, collInp_t *regCollInp)
00011 {
00012 int status;
00013 rodsServerHost_t *rodsServerHost = NULL;
00014 dataObjInp_t dataObjInp;
00015 rodsObjStat_t *rodsObjStatOut = NULL;
00016
00017
00018 memset (&dataObjInp, 0, sizeof (dataObjInp));
00019
00020 rstrcpy (dataObjInp.objPath, regCollInp->collName, MAX_NAME_LEN);
00021 #if 0
00022 status = __rsObjStat (rsComm, &dataObjInp, 1, &rodsObjStatOut);
00023 #endif
00024 status = rsObjStat (rsComm, &dataObjInp, &rodsObjStatOut);
00025 if (status >= 0) {
00026 if( rodsObjStatOut != NULL ) {
00027 if (rodsObjStatOut->specColl != NULL) {
00028 rodsLog (LOG_ERROR,
00029 "rsRegColl: Reg path %s is in spec coll",
00030 dataObjInp.objPath);
00031
00032 freeRodsObjStat (rodsObjStatOut);
00033 return (SYS_REG_OBJ_IN_SPEC_COLL);
00034 }
00035 }
00036 freeRodsObjStat (rodsObjStatOut);
00037 }
00038
00039 status = getAndConnRcatHost (rsComm, MASTER_RCAT, regCollInp->collName,
00040 &rodsServerHost);
00041 if (status < 0) {
00042 return(status);
00043 }
00044 if (rodsServerHost->localFlag == LOCAL_HOST) {
00045 #ifdef RODS_CAT
00046 status = _rsRegColl (rsComm, regCollInp);
00047 #else
00048 status = SYS_NO_RCAT_SERVER_ERR;
00049 #endif
00050 } else {
00051 status = rcRegColl (rodsServerHost->conn, regCollInp);
00052 }
00053
00054 return (status);
00055 }
00056
00057 int
00058 _rsRegColl (rsComm_t *rsComm, collInp_t *collCreateInp)
00059 {
00060 #ifdef RODS_CAT
00061 int status;
00062 collInfo_t collInfo;
00063 char *tmpStr;
00064
00065 memset (&collInfo, 0, sizeof (collInfo));
00066
00067 rstrcpy (collInfo.collName, collCreateInp->collName, MAX_NAME_LEN);
00068
00069 if ((tmpStr = getValByKey (&collCreateInp->condInput,
00070 COLLECTION_TYPE_KW)) != NULL) {
00071 rstrcpy (collInfo.collType, tmpStr, NAME_LEN);
00072 if ((tmpStr = getValByKey (&collCreateInp->condInput,
00073 COLLECTION_INFO1_KW)) != NULL) {
00074 rstrcpy (collInfo.collInfo1, tmpStr, NAME_LEN);
00075 }
00076 if ((tmpStr = getValByKey (&collCreateInp->condInput,
00077 COLLECTION_INFO2_KW)) != NULL) {
00078 rstrcpy (collInfo.collInfo2, tmpStr, NAME_LEN);
00079 }
00080 }
00081 status = chlRegColl (rsComm, &collInfo);
00082 return (status);
00083 #else
00084 return (SYS_NO_RCAT_SERVER_ERR);
00085 #endif
00086 }
00087
00088 #ifdef COMPAT_201
00089 int
00090 rsRegColl201 (rsComm_t *rsComm, collInp201_t *regCollInp)
00091 {
00092 collInp_t collInp;
00093 int status;
00094
00095 collInp201ToCollInp (regCollInp, &collInp);
00096
00097 status = rsRegColl (rsComm, &collInp);
00098
00099 return status;
00100 }
00101 #endif
00102