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)  

rsSpecificQuery.cpp
Go to the documentation of this file.
1 
4 /* See specificQuery.h for a description of this API call.*/
5 
6 #include "specificQuery.h"
8 #include "miscUtil.h"
9 #include "rcMisc.h"
10 #include "irods_log.hpp"
11 #include "miscServerFunct.hpp"
13 #include "rsSpecificQuery.hpp"
14 
15 int
16 rsSpecificQuery( rsComm_t *rsComm, specificQueryInp_t *specificQueryInp,
17  genQueryOut_t **genQueryOut ) {
19  int status;
20  char *zoneHint = "";
21 
22  /* zoneHint = getZoneHintForGenQuery (genQueryInp); (need something like this?) */
23  zoneHint = getValByKey( &specificQueryInp->condInput, ZONE_KW );
24 
25  status = getAndConnRcatHost( rsComm, SLAVE_RCAT, ( const char* )zoneHint,
26  &rodsServerHost );
27  if ( status < 0 ) {
28  return status;
29  }
30 
32  std::string svc_role;
33  irods::error ret = get_catalog_service_role(svc_role);
34  if(!ret.ok()) {
35  irods::log(PASS(ret));
36  return ret.code();
37  }
38 
39  if( irods::CFG_SERVICE_ROLE_PROVIDER == svc_role ) {
40  status = _rsSpecificQuery( rsComm, specificQueryInp, genQueryOut );
41  } else if( irods::CFG_SERVICE_ROLE_CONSUMER == svc_role ) {
43  "rsSpecificQuery error. RCAT is not configured on this host" );
45  } else {
46  rodsLog(
47  LOG_ERROR,
48  "role not supported [%s]",
49  svc_role.c_str() );
51  }
52 
53  }
54  else {
56  specificQueryInp, genQueryOut );
57  }
58  if ( status < 0 && status != CAT_NO_ROWS_FOUND ) {
60  "rsSpecificQuery: rcSpecificQuery failed, status = %d", status );
61  }
62  return status;
63 }
64 
65 int
66 _rsSpecificQuery( rsComm_t *rsComm, specificQueryInp_t *specificQueryInp,
67  genQueryOut_t **genQueryOut ) {
68  int status;
69 
70  *genQueryOut = ( genQueryOut_t* )malloc( sizeof( genQueryOut_t ) );
71  memset( ( char * )*genQueryOut, 0, sizeof( genQueryOut_t ) );
72 
73  status = chlSpecificQuery( *specificQueryInp, *genQueryOut );
74 
76  int i;
77  i = addRErrorMsg( &rsComm->rError, 0, "The SQL is not pre-defined.\n See 'iadmin h asq' (add specific query)" );
78  if ( i < 0 ) {
79  irods::log( i, "addErrorMsg failed" );
80  }
81  }
82 
83  if ( status < 0 ) {
84  clearGenQueryOut( *genQueryOut );
85  free( *genQueryOut );
86  *genQueryOut = NULL;
87  if ( status != CAT_NO_ROWS_FOUND ) {
89  "_rsSpecificQuery: specificQuery status = %d", status );
90  }
91  return status;
92  }
93  return status;
94 }
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
getValByKey
char * getValByKey(const keyValPair_t *condInput, const char *keyWord)
Definition: rcMisc.cpp:675
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
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
rsSpecificQuery
int rsSpecificQuery(rsComm_t *rsComm, specificQueryInp_t *specificQueryInp, genQueryOut_t **genQueryOut)
Definition: rsSpecificQuery.cpp:16
rcMisc.h
LOCAL_HOST
#define LOCAL_HOST
Definition: rodsConnect.h:44
_rsSpecificQuery
int _rsSpecificQuery(rsComm_t *rsComm, specificQueryInp_t *specificQueryInp, genQueryOut_t **genQueryOut)
Definition: rsSpecificQuery.cpp:66
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
specificQueryInp_t::condInput
keyValPair_t condInput
Definition: specificQuery.h:17
specificQueryInp_t
Definition: specificQuery.h:8
rsComm_t::rError
rError_t rError
Definition: rcConnect.h:158
irods::error::code
long long code() const
Definition: irods_error.cpp:194
rsSpecificQuery.hpp
clearGenQueryOut
void clearGenQueryOut(void *)
Definition: rcMisc.cpp:1150
CAT_UNKNOWN_SPECIFIC_QUERY
@ CAT_UNKNOWN_SPECIFIC_QUERY
Definition: rodsErrorTable.h:459
chlSpecificQuery
int chlSpecificQuery(specificQueryInp_t specificQueryInp, genQueryOut_t *genQueryOut)
Definition: icatHighLevelRoutines.cpp:4183
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
GenQueryOut
Definition: rodsGenQuery.h:67
addRErrorMsg
int addRErrorMsg(rError_t *myError, int status, const char *msg)
Definition: rcMisc.cpp:121
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
zoneHint
char zoneHint[(1024+64)]
Definition: lsUtil.cpp:13
irods::log
void log(const error &)
Definition: irods_log.cpp:13
LOG_NOTICE
#define LOG_NOTICE
Definition: rodsLog.h:33
irods::error
Definition: irods_error.hpp:23
miscServerFunct.hpp
getAndConnRcatHost
int getAndConnRcatHost(rsComm_t *rsComm, int rcatType, const char *rcatZoneHint, rodsServerHost_t **rodsServerHost)
Definition: rodsConnect.cpp:26
specificQuery.h
get_catalog_service_role
irods::error get_catalog_service_role(std::string &_role)
Definition: miscServerFunct.cpp:3153
rodsServerHost
Definition: rodsConnect.h:62
CAT_NO_ROWS_FOUND
@ CAT_NO_ROWS_FOUND
Definition: rodsErrorTable.h:423
icatHighLevelRoutines.hpp
SLAVE_RCAT
#define SLAVE_RCAT
Definition: rodsDef.h:86
ZONE_KW
#define ZONE_KW
Definition: rodsKeyWdDef.h:80
miscUtil.h
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
rcSpecificQuery
int rcSpecificQuery(rcComm_t *conn, specificQueryInp_t *specificQueryInp, genQueryOut_t **genQueryOut)
Definition: rcSpecificQuery.cpp:49
irods_log.hpp