00001
00002
00003
00004
00005
00006 #include "syncMountedColl.h"
00007 #include "rodsLog.h"
00008 #include "icatDefines.h"
00009 #include "objMetaOpr.h"
00010 #include "collection.h"
00011 #include "resource.h"
00012 #include "rsGlobalExtern.h"
00013 #include "rcGlobalExtern.h"
00014 #include "reGlobalsExtern.h"
00015 #include "miscServerFunct.h"
00016 #include "apiHeaderAll.h"
00017
00018
00019
00020 #include "eirods_resource_backport.h"
00021
00022 int
00023 rsSyncMountedColl (rsComm_t *rsComm, dataObjInp_t *syncMountedCollInp)
00024 {
00025 rodsLog( LOG_NOTICE, "rsSyncMountedColl - start" );
00026
00027 int status;
00028 rodsObjStat_t *rodsObjStatOut = NULL;
00029 dataObjInp_t myDataObjInp;
00030 int remoteFlag;
00031 rodsServerHost_t *rodsServerHost;
00032
00033 status = collStat (rsComm, syncMountedCollInp, &rodsObjStatOut);
00034 if (status < 0 || NULL == rodsObjStatOut) return status;
00035
00036 if (rodsObjStatOut->specColl == NULL) {
00037 freeRodsObjStat (rodsObjStatOut);
00038 rodsLog (LOG_ERROR,
00039 "rsSyncMountedColl: %s not a mounted collection",
00040 syncMountedCollInp->objPath);
00041 return (SYS_COLL_NOT_MOUNTED_ERR);
00042 }
00043
00044 bzero (&myDataObjInp, sizeof (myDataObjInp));
00045 rstrcpy (myDataObjInp.objPath, rodsObjStatOut->specColl->objPath,
00046 MAX_NAME_LEN);
00047 remoteFlag = getAndConnRemoteZone (rsComm, &myDataObjInp, &rodsServerHost,
00048 REMOTE_OPEN);
00049
00050 if (remoteFlag < 0) {
00051 return (remoteFlag);
00052 } else if (remoteFlag == REMOTE_HOST) {
00053 status = rcSyncMountedColl (rodsServerHost->conn,
00054 syncMountedCollInp);
00055 } else {
00056 status = _rsSyncMountedColl (rsComm, rodsObjStatOut->specColl,
00057 syncMountedCollInp->oprType);
00058 }
00059
00060 freeRodsObjStat (rodsObjStatOut);
00061
00062 rodsLog( LOG_NOTICE, "rsSyncMountedColl - done" );
00063
00064 return (status);
00065 }
00066
00067 int
00068 _rsSyncMountedColl (rsComm_t *rsComm, specColl_t *specColl, int oprType)
00069 {
00070 int status;
00071
00072 if (getStructFileType (specColl) >= 0) {
00073 structFileOprInp_t structFileOprInp;
00074 rescInfo_t rescInfo;
00075
00076 if (strlen (specColl->resource) == 0) {
00077
00078 return (0);
00079 }
00080
00081 memset (&structFileOprInp, 0, sizeof (structFileOprInp));
00082
00083
00084
00085
00086
00087
00088
00089 eirods::error err = eirods::get_resc_info( specColl->resource, rescInfo );
00090 if( !err.ok() ) {
00091 std::stringstream msg;
00092 msg << "_rsSyncMountedColl - failed to resolve resource ";
00093 msg << specColl->resource;
00094 eirods::log( PASS( false, -1, msg.str(), err ) );
00095 }
00096
00097
00098
00099 std::string location;
00100 eirods::error ret = eirods::get_loc_for_hier_string( specColl->rescHier, location );
00101 if( !ret.ok() ) {
00102 eirods::log( PASSMSG( "_rsSyncMountedColl - failed in get_loc_for_hier_String", ret ) );
00103 return -1;
00104 }
00105
00106
00107 addKeyVal( &structFileOprInp.condInput, RESC_HIER_STR_KW, specColl->rescHier );
00108 rstrcpy (structFileOprInp.addr.hostAddr, location.c_str(), NAME_LEN);
00109 structFileOprInp.oprType = oprType;
00110 structFileOprInp.specColl = specColl;
00111 status = rsStructFileSync (rsComm, &structFileOprInp);
00112
00113
00114 } else {
00115 status = SYS_COLL_NOT_MOUNTED_ERR;
00116 }
00117
00118 return (status);
00119 }
00120