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( rsComm_t* _comm,
00071 subFile_t* _sub_file ) {
00072
00073 eirods::structured_object struct_obj( *_sub_file );
00074 struct_obj.comm( _comm );
00075
00076 struct_obj.resc_hier( eirods::EIRODS_LOCAL_USE_ONLY_RESOURCE );
00077
00078 eirods::error err = fileCreate( _comm, struct_obj );
00079
00080 if( !err.ok() ) {
00081 std::stringstream msg;
00082 msg << "_rsSubStructFileCreate - failed on call to fileCreate for [";
00083 msg << struct_obj.sub_file_path();
00084 eirods::log( ERROR( -1, msg.str() ) );
00085 return 0;
00086
00087 } else {
00088 return err.code();
00089
00090 }
00091
00092 }
00093