00001
00002
00003
00004
00005
00006
00007
00008 #include "fileUnlink.h"
00009 #include "miscServerFunct.h"
00010
00011
00012
00013 #include "eirods_log.h"
00014 #include "eirods_file_object.h"
00015 #include "eirods_stacktrace.h"
00016 #include "eirods_resource_backport.h"
00017
00018 int
00019 rsFileUnlink (rsComm_t *rsComm, fileUnlinkInp_t *fileUnlinkInp)
00020 {
00021 rodsServerHost_t *rodsServerHost;
00022 int remoteFlag;
00023 int status;
00024
00025
00026 eirods::error ret = eirods::get_host_for_hier_string( fileUnlinkInp->rescHier, remoteFlag, rodsServerHost );
00027 if( !ret.ok() ) {
00028 eirods::log( PASSMSG( "failed in call to eirods::get_host_for_hier_string", ret ) );
00029 return -1;
00030 }
00031 if (remoteFlag == LOCAL_HOST) {
00032 status = _rsFileUnlink (rsComm, fileUnlinkInp);
00033 } else if (remoteFlag == REMOTE_HOST) {
00034 status = remoteFileUnlink (rsComm, fileUnlinkInp, rodsServerHost);
00035 } else {
00036 if (remoteFlag < 0) {
00037 return (remoteFlag);
00038 } else {
00039 rodsLog (LOG_NOTICE,
00040 "rsFileUnlink: resolveHost returned unrecognized value %d",
00041 remoteFlag);
00042 return (SYS_UNRECOGNIZED_REMOTE_FLAG);
00043 }
00044 }
00045
00046
00047
00048 return (status);
00049 }
00050
00051 int
00052 remoteFileUnlink (rsComm_t *rsComm, fileUnlinkInp_t *fileUnlinkInp,
00053 rodsServerHost_t *rodsServerHost)
00054 {
00055 int status;
00056
00057 if (rodsServerHost == NULL) {
00058 rodsLog (LOG_NOTICE,
00059 "remoteFileUnlink: Invalid rodsServerHost");
00060 return SYS_INVALID_SERVER_HOST;
00061 }
00062
00063 if ((status = svrToSvrConnect (rsComm, rodsServerHost)) < 0) {
00064 return status;
00065 }
00066
00067
00068 status = rcFileUnlink (rodsServerHost->conn, fileUnlinkInp);
00069
00070 if (status < 0) {
00071 rodsLog (LOG_NOTICE,
00072 "remoteFileUnlink: rcFileUnlink failed for %s, status = %d",
00073 fileUnlinkInp->fileName, status);
00074 }
00075
00076 return status;
00077 }
00078
00079
00080
00081 int _rsFileUnlink(
00082 rsComm_t* _comm,
00083 fileUnlinkInp_t* _unlink_inp ) {
00084 if(_unlink_inp->objPath[0] == '\0') {
00085 std::stringstream msg;
00086 msg << __FUNCTION__;
00087 msg << " - empty logical path.";
00088 eirods::log(LOG_ERROR, msg.str());
00089 return -1;
00090 }
00091
00092
00093
00094 eirods::file_object_ptr file_obj(
00095 new eirods::file_object(
00096 _comm,
00097 _unlink_inp->objPath,
00098 _unlink_inp->fileName,
00099 _unlink_inp->rescHier,
00100 0, 0, 0 ) );
00101 file_obj->in_pdmo(_unlink_inp->in_pdmo);
00102
00103 eirods::error unlink_err = fileUnlink( _comm, file_obj );
00104
00105
00106
00107 if( unlink_err.code() < 0 ) {
00108 std::stringstream msg;
00109 msg << "fileRead failed for [";
00110 msg << _unlink_inp->fileName;
00111 msg << "]";
00112 msg << unlink_err.code();
00113 eirods::error ret_err = PASSMSG( msg.str(), unlink_err );
00114 eirods::log( ret_err );
00115 }
00116
00117 return (unlink_err.code());
00118
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128