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 *rsComm,
00083 fileUnlinkInp_t *fileUnlinkInp )
00084 {
00085 if(fileUnlinkInp->objPath[0] == '\0') {
00086 std::stringstream msg;
00087 msg << __FUNCTION__;
00088 msg << " - empty logical path.";
00089 eirods::log(LOG_ERROR, msg.str());
00090 return -1;
00091 }
00092
00093
00094
00095 eirods::file_object file_obj( rsComm, fileUnlinkInp->objPath, fileUnlinkInp->fileName, fileUnlinkInp->rescHier, 0, 0, 0 );
00096 if(fileUnlinkInp->in_pdmo) {
00097 file_obj.in_pdmo(true);
00098 } else {
00099 file_obj.in_pdmo(false);
00100 }
00101
00102 eirods::error unlink_err = fileUnlink( rsComm, file_obj );
00103
00104
00105
00106 if( unlink_err.code() < 0 ) {
00107 std::stringstream msg;
00108 msg << "fileRead failed for [";
00109 msg << fileUnlinkInp->fileName;
00110 msg << "]";
00111 msg << unlink_err.code();
00112 eirods::error ret_err = PASSMSG( msg.str(), unlink_err );
00113 eirods::log( ret_err );
00114 }
00115
00116 return (unlink_err.code());
00117
00118 }
00119
00120
00121
00122
00123
00124
00125
00126
00127