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)  

rsUnregDataObj.cpp
Go to the documentation of this file.
1 
3 /* unregDataObj.c
4  */
5 
6 #include "unregDataObj.h"
8 #include "fileDriver.hpp"
9 #include "miscServerFunct.hpp"
10 #include "rsUnregDataObj.hpp"
11 
12 #include "irods_file_object.hpp"
13 #include "irods_stacktrace.hpp"
15 
16 int
17 rsUnregDataObj( rsComm_t *rsComm, unregDataObj_t *unregDataObjInp ) {
18  int status;
20  dataObjInfo_t *dataObjInfo;
21 
22  dataObjInfo = unregDataObjInp->dataObjInfo;
23 
24  status = getAndConnRcatHost( rsComm, MASTER_RCAT, ( const char* )dataObjInfo->objPath,
25  &rodsServerHost );
26  if ( status < 0 || NULL == rodsServerHost ) { // JMC cppcheck - nullptr
27  return status;
28  }
30  std::string svc_role;
31  irods::error ret = get_catalog_service_role(svc_role);
32  if(!ret.ok()) {
33  irods::log(PASS(ret));
34  return ret.code();
35  }
36 
37  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
38  status = _rsUnregDataObj( rsComm, unregDataObjInp );
39  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
41  } else {
42  rodsLog(
43  LOG_ERROR,
44  "role not supported [%s]",
45  svc_role.c_str() );
47  }
48 
49  }
50  else {
51  status = rcUnregDataObj( rodsServerHost->conn, unregDataObjInp );
52  }
53 
54  return status;
55 }
56 
57 int
58 _rsUnregDataObj( rsComm_t *rsComm, unregDataObj_t *unregDataObjInp ) {
59  std::string svc_role;
60  irods::error ret = get_catalog_service_role(svc_role);
61  if(!ret.ok()) {
62  irods::log(PASS(ret));
63  return ret.code();
64  }
65 
66  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
67  dataObjInfo_t *dataObjInfo;
68  keyValPair_t *condInput;
69  int status;
70  irods::error ret;
71 
72  condInput = unregDataObjInp->condInput;
73  dataObjInfo = unregDataObjInp->dataObjInfo;
74 
75  status = chlUnregDataObj( rsComm, dataObjInfo, condInput );
76  if ( status < 0 ) {
77  char* sys_error = NULL;
78  const char* rods_error = rodsErrorName( status, &sys_error );
79  std::stringstream msg;
80  msg << __FUNCTION__;
81  msg << " - Failed to unregister the data object \"";
82  msg << dataObjInfo->objPath;
83  msg << "\" - ";
84  msg << rods_error << " " << sys_error;
85  ret = ERROR( status, msg.str() );
86  irods::log( ret );
87  free( sys_error );
88  }
89  else {
90  irods::file_object_ptr file_obj(
92  rsComm,
93  dataObjInfo ) );
94  ret = fileUnregistered( rsComm, file_obj );
95  if ( !ret.ok() ) {
96  std::stringstream msg;
97  msg << __FUNCTION__;
98  msg << " - Failed to signal resource that the data object \"";
99  msg << dataObjInfo->objPath;
100  msg << "\" was unregistered";
101  ret = PASSMSG( msg.str(), ret );
102  irods::log( ret );
103  status = ret.code();
104  }
105  }
106  return status;
107  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
108  return SYS_NO_RCAT_SERVER_ERR;
109  } else {
110  rodsLog(
111  LOG_ERROR,
112  "role not supported [%s]",
113  svc_role.c_str() );
115  }
116 }
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
_rsUnregDataObj
int _rsUnregDataObj(rsComm_t *rsComm, unregDataObj_t *unregDataObjInp)
Definition: rsUnregDataObj.cpp:58
NULL
#define NULL
Definition: rodsDef.h:70
rsComm_t
Definition: rcConnect.h:145
irods::CFG_SERVICE_ROLE_CONSUMER
const std::string CFG_SERVICE_ROLE_CONSUMER("consumer")
irods_configuration_keywords.hpp
rodsServerHost::localFlag
int localFlag
Definition: rodsConnect.h:68
SYS_SERVICE_ROLE_NOT_SUPPORTED
@ SYS_SERVICE_ROLE_NOT_SUPPORTED
Definition: rodsErrorTable.h:217
rodsServerHost::conn
rcComm_t * conn
Definition: rodsConnect.h:64
unregDataObj_t::condInput
keyValPair_t * condInput
Definition: unregDataObj.h:9
rsUnregDataObj.hpp
irods_file_object.hpp
irods_stacktrace.hpp
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
fileDriver.hpp
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
rodsErrorName
const char * rodsErrorName(int errorValue, char **subName)
Definition: rodsLog.cpp:373
unregDataObj_t::dataObjInfo
dataObjInfo_t * dataObjInfo
Definition: unregDataObj.h:8
rsUnregDataObj
int rsUnregDataObj(rsComm_t *rsComm, unregDataObj_t *unregDataObjInp)
Definition: rsUnregDataObj.cpp:17
irods::error::code
long long code() const
Definition: irods_error.cpp:194
irods::CFG_SERVICE_ROLE_PROVIDER
const std::string CFG_SERVICE_ROLE_PROVIDER("provider")
SYS_NO_RCAT_SERVER_ERR
@ SYS_NO_RCAT_SERVER_ERR
Definition: rodsErrorTable.h:110
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
fileUnregistered
irods::error fileUnregistered(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:657
irods::log
void log(const error &)
Definition: irods_log.cpp:13
rcUnregDataObj
int rcUnregDataObj(rcComm_t *conn, unregDataObj_t *unregDataObjInp)
Definition: rcUnregDataObj.cpp:23
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
unregDataObj_t
Definition: unregDataObj.h:7
getAndConnRcatHost
int getAndConnRcatHost(rsComm_t *rsComm, int rcatType, const char *rcatZoneHint, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:26
MASTER_RCAT
#define MASTER_RCAT
Definition: rodsDef.h:85
get_catalog_service_role
irods::error get_catalog_service_role(std::string &_role)
Definition: miscServerFunct.cpp:3153
irods::file_object
Definition: irods_file_object.hpp:19
rodsServerHost
Definition: rodsConnect.h:62
irods::file_object_ptr
boost::shared_ptr< file_object > file_object_ptr
Definition: irods_file_object.hpp:145
icatHighLevelRoutines.hpp
chlUnregDataObj
int chlUnregDataObj(rsComm_t *rsComm, dataObjInfo_t *dataObjInfo, keyValPair_t *condInput)
Definition: icatHighLevelRoutines.cpp:605
DataObjInfo::objPath
char objPath[(1024+64)]
Definition: objInfo.h:130
KeyValPair
Definition: objInfo.h:120
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
DataObjInfo
Definition: objInfo.h:129
unregDataObj.h