00001
00002
00003 #include "subStructFileOpen.h"
00004 #include "miscServerFunct.h"
00005 #include "dataObjOpr.h"
00006
00007
00008
00009 #include "eirods_structured_object.h"
00010
00011
00012
00013 int
00014 rsSubStructFileOpen (rsComm_t *rsComm, subFile_t *subFile)
00015 {
00016 rodsServerHost_t *rodsServerHost;
00017 int remoteFlag;
00018 int fd;
00019
00020 remoteFlag = resolveHost (&subFile->addr, &rodsServerHost);
00021
00022 if (remoteFlag == LOCAL_HOST) {
00023 fd = _rsSubStructFileOpen (rsComm, subFile);
00024 } else if (remoteFlag == REMOTE_HOST) {
00025 fd = remoteSubStructFileOpen (rsComm, subFile, rodsServerHost);
00026 } else {
00027 if (remoteFlag < 0) {
00028 return (remoteFlag);
00029 } else {
00030 rodsLog (LOG_NOTICE,
00031 "rsSubStructFileOpen: resolveHost returned unrecognized value %d",
00032 remoteFlag);
00033 return (SYS_UNRECOGNIZED_REMOTE_FLAG);
00034 }
00035 }
00036
00037 return (fd);
00038 }
00039
00040 int
00041 remoteSubStructFileOpen (rsComm_t *rsComm, subFile_t *subFile,
00042 rodsServerHost_t *rodsServerHost)
00043 {
00044 int fd;
00045 int status;
00046
00047 if (rodsServerHost == NULL) {
00048 rodsLog (LOG_NOTICE,
00049 "remoteSubStructFileOpen: Invalid rodsServerHost");
00050 return SYS_INVALID_SERVER_HOST;
00051 }
00052
00053 if ((status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00054 return status;
00055 }
00056
00057 fd = rcSubStructFileOpen (rodsServerHost->conn, subFile);
00058
00059 if (fd < 0) {
00060 rodsLog (LOG_NOTICE,
00061 "remoteSubStructFileOpen: rcSubStructFileOpen failed for %s, status = %d",
00062 subFile->subFilePath, fd);
00063 }
00064
00065 return fd;
00066 }
00067
00068 int
00069 _rsSubStructFileOpen(
00070 rsComm_t* _comm,
00071 subFile_t* _sub_file ) {
00072
00073
00074 eirods::structured_object_ptr struct_obj(
00075 new eirods::structured_object(
00076 *_sub_file ) );
00077 struct_obj->comm( _comm );
00078 struct_obj->resc_hier( eirods::EIRODS_LOCAL_USE_ONLY_RESOURCE );
00079
00080
00081
00082 eirods::error open_err = fileOpen( _comm, struct_obj );
00083 if( !open_err.ok() ) {
00084 std::stringstream msg;
00085 msg << "failed on call to fileOpen for [";
00086 msg << struct_obj->sub_file_path();
00087 msg << "]";
00088 eirods::log( PASSMSG( msg.str(), open_err ) );
00089 return open_err.code();
00090
00091 } else {
00092 return open_err.code();
00093
00094 }
00095
00096 }
00097
00098