irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

rsFileRename.cpp
Go to the documentation of this file.
1 
3 /* rsFileRename.c - server routine that handles the fileRename
4  * API
5  */
6 
7 /* script generated code */
8 #include "fileRename.h"
9 #include "miscServerFunct.hpp"
10 #include "fileOpr.hpp"
11 #include "dataObjOpr.hpp"
12 #include "physPath.hpp"
13 #include "rsFileRename.hpp"
14 
15 // =-=-=-=-=-=-=-
16 #include "irods_log.hpp"
17 #include "irods_file_object.hpp"
18 #include "irods_stacktrace.hpp"
20 
21 int
23  rsComm_t *rsComm,
24  fileRenameInp_t* fileRenameInp,
25  fileRenameOut_t** rename_out ) {
27  int remoteFlag;
28  int status;
29  //remoteFlag = resolveHost (&fileRenameInp->addr, &rodsServerHost);
30  irods::error ret = irods::get_host_for_hier_string( fileRenameInp->rescHier, remoteFlag, rodsServerHost );
31  if ( !ret.ok() ) {
32  irods::log( PASSMSG( "failed in call to irods::get_host_for_hier_string", ret ) );
33  return -1;
34  }
35 
36  if ( remoteFlag == LOCAL_HOST ) {
37  status = _rsFileRename( rsComm, fileRenameInp, rename_out );
38  }
39  else if ( remoteFlag == REMOTE_HOST ) {
40  status = remoteFileRename( rsComm, fileRenameInp, rename_out, rodsServerHost );
41  }
42  else {
43  if ( remoteFlag < 0 ) {
44  return remoteFlag;
45  }
46  else {
47  rodsLog( LOG_NOTICE, "rsFileRename: resolveHost returned unrecognized value %d",
48  remoteFlag );
50  }
51  }
52 
53  return status;
54 }
55 
56 int
58  rsComm_t* rsComm,
59  fileRenameInp_t* fileRenameInp,
60  fileRenameOut_t** rename_out,
62  int status;
63 
64  if ( rodsServerHost == NULL ) {
66  "remoteFileRename: Invalid rodsServerHost" );
68  }
69 
70  if ( ( status = svrToSvrConnect( rsComm, rodsServerHost ) ) < 0 ) {
71  return status;
72  }
73 
74  status = rcFileRename( rodsServerHost->conn, fileRenameInp, rename_out );
75 
76  if ( status < 0 ) {
78  "remoteFileRename: rcFileRename failed for %s",
79  fileRenameInp->newFileName );
80  }
81 
82  return status;
83 }
84 
85 // =-=-=-=-=-=-=-
86 // local function which makes the call to rename via the resource plugin
88  rsComm_t* _comm,
89  fileRenameInp_t* _rename_inp,
90  fileRenameOut_t** _rename_out ) {
91  // =-=-=-=-=-=-=-
92  // FIXME: need to check resource permission and vault permission
93  // when RCAT is available
94  // mkDirForFilePath( _comm, "/", _rename_inp->newFileName, getDefDirMode () ); - The actual file path depends on the resource
95 
96  // =-=-=-=-=-=-=-
97  // make the call to rename via the resource plugin
98  irods::file_object_ptr file_obj(
100  _comm,
101  _rename_inp->objPath,
102  _rename_inp->oldFileName,
103  _rename_inp->rescHier,
104  0, 0, 0 ) );
105  irods::error rename_err = fileRename( _comm, file_obj, _rename_inp->newFileName );
106 
107  // =-=-=-=-=-=-=-
108  // report errors if any
109  if ( !rename_err.ok() ) {
110  std::stringstream msg;
111  msg << "fileRename failed for [";
112  msg << _rename_inp->oldFileName;
113  msg << "] to [";
114  msg << _rename_inp->newFileName;
115  msg << "]";
116  irods::error err = PASSMSG( msg.str(), rename_err );
117  irods::log( err );
118  }
119 
120  // =-=-=-=-=-=-=-
121  // percolate possible change in phy path up
122  ( *_rename_out ) = ( fileRenameOut_t* ) malloc( sizeof( fileRenameOut_t ) );
123  snprintf(
124  ( *_rename_out )->file_name, sizeof( ( *_rename_out )->file_name ),
125  "%s", file_obj->physical_path().c_str() );
126 
127  return rename_err.code();
128 
129 } // _rsFileRename
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
rcFileRename
int rcFileRename(rcComm_t *conn, fileRenameInp_t *fileRenameInp, fileRenameOut_t **)
Definition: rcFileRename.cpp:24
SYS_UNRECOGNIZED_REMOTE_FLAG
@ SYS_UNRECOGNIZED_REMOTE_FLAG
Definition: rodsErrorTable.h:88
irods_file_object.hpp
irods_stacktrace.hpp
fileRenameOut_t
Definition: fileRename.h:16
REMOTE_HOST
#define REMOTE_HOST
Definition: rodsConnect.h:45
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
fileRenameInp_t::newFileName
char newFileName[(1024+64)]
Definition: fileRename.h:10
irods_resource_backport.hpp
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
rsFileRename
int rsFileRename(rsComm_t *rsComm, fileRenameInp_t *fileRenameInp, fileRenameOut_t **rename_out)
Definition: rsFileRename.cpp:22
fileRenameInp_t
Definition: fileRename.h:7
rsFileRename.hpp
irods::error::code
long long code() const
Definition: irods_error.cpp:194
remoteFileRename
int remoteFileRename(rsComm_t *rsComm, fileRenameInp_t *fileRenameInp, fileRenameOut_t **rename_out, rodsServerHost_t *rodsServerHost)
Definition: rsFileRename.cpp:57
fileRename
irods::error fileRename(rsComm_t *, irods::first_class_object_ptr, const std::string &)
Definition: fileDriver.cpp:453
irods::get_host_for_hier_string
error get_host_for_hier_string(const std::string &, int &, rodsServerHost_t *&)
Definition: irods_resource_backport.cpp:581
SYS_INVALID_SERVER_HOST
@ SYS_INVALID_SERVER_HOST
Definition: rodsErrorTable.h:89
svrToSvrConnect
int svrToSvrConnect(rsComm_t *rsComm, rodsServerHost_t *rodsServerHost)
Definition: miscServerFunct.cpp:106
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
physPath.hpp
irods::log
void log(const error &)
Definition: irods_log.cpp:13
fileRenameInp_t::rescHier
char rescHier[(1024+64)]
Definition: fileRename.h:11
fileRenameInp_t::objPath
char objPath[(1024+64)]
Definition: fileRename.h:12
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
irods::file_object
Definition: irods_file_object.hpp:19
fileOpr.hpp
rodsServerHost
Definition: rodsConnect.h:62
fileRenameInp_t::oldFileName
char oldFileName[(1024+64)]
Definition: fileRename.h:9
fileRename.h
irods::file_object_ptr
boost::shared_ptr< file_object > file_object_ptr
Definition: irods_file_object.hpp:145
_rsFileRename
int _rsFileRename(rsComm_t *_comm, fileRenameInp_t *_rename_inp, fileRenameOut_t **_rename_out)
Definition: rsFileRename.cpp:87
dataObjOpr.hpp
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irods_log.hpp