00001
00002
00003
00004 #include "miscServerFunct.h"
00005 #include "dataObjOpr.h"
00006 #include "subStructFileCreate.h"
00007
00008
00009
00010 #include "eirods_structured_object.h"
00011 #include "eirods_log.h"
00012
00013 int
00014 rsSubStructFileCreate (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 = _rsSubStructFileCreate (rsComm, subFile);
00024 } else if (remoteFlag == REMOTE_HOST) {
00025 fd = remoteSubStructFileCreate (rsComm, subFile, rodsServerHost);
00026 } else {
00027 if (remoteFlag < 0) {
00028 return (remoteFlag);
00029 } else {
00030 rodsLog (LOG_NOTICE,
00031 "rsSubStructFileCreate: resolveHost returned unrecognized value %d",
00032 remoteFlag);
00033 return (SYS_UNRECOGNIZED_REMOTE_FLAG);
00034 }
00035 }
00036
00037 return (fd);
00038 }
00039
00040 int
00041 remoteSubStructFileCreate (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 "remoteSubStructFileCreate: Invalid rodsServerHost");
00050 return SYS_INVALID_SERVER_HOST;
00051 }
00052
00053 if ((status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00054 return status;
00055 }
00056
00057 fd = rcSubStructFileCreate (rodsServerHost->conn, subFile);
00058
00059 if (fd < 0) {
00060 rodsLog (LOG_NOTICE,
00061 "remoteSubStructFileCreate: rcSubStructFileCreate failed for %s, status = %d",
00062 subFile->subFilePath, fd);
00063 }
00064
00065 return fd;
00066 }
00067
00068
00069
00070 int _rsSubStructFileCreate(
00071 rsComm_t* _comm,
00072 subFile_t* _sub_file ) {
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 eirods::error err = fileCreate( _comm, struct_obj );
00081 if( !err.ok() ) {
00082 std::stringstream msg;
00083 msg << "failed on call to fileCreate for [";
00084 msg << struct_obj->sub_file_path();
00085 eirods::log( PASSMSG( msg.str(), err ) );
00086 return 0;
00087
00088 } else {
00089 return err.code();
00090
00091 }
00092
00093 }
00094