46 #include <string_view>
49 #include <boost/regex.hpp>
50 #include <boost/lexical_cast.hpp>
67 #define AP_READ "read"
68 #define AP_WRITE "write"
70 #define AP_NULL "null"
82 #define PASSWORD_SCRAMBLE_PREFIX ".E_"
83 #define PASSWORD_KEY_ENV_VAR "IRODS_DATABASE_USER_PASSWORD_SALT"
84 #define PASSWORD_DEFAULT_KEY "a9_3fker"
86 #define MAX_HOST_STR 2700
111 #define PATH_SEPARATOR irods::get_virtual_path_separator().c_str()
123 const std::string input( fullUserNameIn );
124 boost::smatch matches;
131 const boost::regex expression(
"((\\w|[-.@])+)(#([^#]*))?" );
133 const bool matched = boost::regex_match( input, matches, expression );
134 if ( !matched || matches.str( 1 ).size() >=
NAME_LEN ||
135 matches.str( 1 ).size() < 1 ||
136 matches.str( 4 ).size() >=
NAME_LEN ||
137 matches.str( 1 ) ==
"." ||
138 matches.str( 1 ) ==
".." ) {
139 if ( userName !=
NULL ) {
142 if ( userZone !=
NULL ) {
147 if ( userName !=
NULL ) {
148 snprintf( userName,
NAME_LEN,
"%s", matches.str( 1 ).c_str() );
150 if ( userZone !=
NULL ) {
151 snprintf( userZone,
NAME_LEN,
"%s", matches.str( 4 ).c_str() );
154 catch (
const boost::exception& ) {
168 "incoming fco is null" );
172 _pg = boost::dynamic_pointer_cast <
183 "failed to dynamic cast to postgres_object_ptr" );
197 "%s cmlExecuteNoAnswerSql(rollback) succeeded", functionName );
201 "%s cmlExecuteNoAnswerSql(rollback) failure %d",
216 std::string& _zone ) {
225 std::vector<std::string> bindVars;
226 bindVars.push_back(
"local" );
228 (
char* )
"select zone_name from R_ZONE_MAIN where zone_type_name=?",
255 const std::string& _resc_name,
273 std::string resc_id_str;
274 ret = irods::lexical_cast<std::string>(resc_id, resc_id_str);
280 std::vector<std::string> bindVars;
281 bindVars.push_back( resc_id_str );
283 (
char* )
"select count(data_id) from R_DATA_MAIN where resc_id=?",
295 const std::string& _data_name,
296 const std::string& _collection,
297 const std::string& _user_name,
298 const std::string& _zone ) {
304 "%s :: [%s] [%s] [%s] [%s]",
314 std::vector<std::string> bind_vars;
315 bind_vars.push_back( _data_name );
316 bind_vars.push_back( _collection );
318 "select count(DISTINCT DM.data_id) from R_DATA_MAIN DM, R_COLL_MAIN CM where DM.data_name like ? and DM.coll_id=CM.coll_id and CM.coll_name like ?",
326 "failed to get object count" );
329 if( 0 == num_data_objects ) {
330 std::string msg =
"no data objects found for collection ";
332 msg +=
" and object name ";
344 std::vector<std::string> bind_vars;
346 "select token_id from R_TOKN_MAIN where token_name = 'modify metadata' and token_namespace = 'access_type'",
353 "query for modify metadata token_id failed" );
362 std::string query =
"select min(max_access_type_id) from ( select max(access_type_id) max_access_type_id from ( select access_type_id, DM.data_id from R_DATA_MAIN DM, R_OBJT_ACCESS OA, R_USER_GROUP UG, R_USER_MAIN UM, R_COLL_MAIN CM where DM.data_name like ? and DM.coll_id=CM.coll_id and CM.coll_name like ? and UM.user_name=? and UM.zone_name = ? and UM.user_type_name!='rodsgroup' and UM.user_id = UG.user_id and OA.object_id = DM.data_id and UG.group_user_id = OA.user_id ) group by data_id )";
364 std::string query =
"select min(max_access_type_id) from ( select max(access_type_id) max_access_type_id from ( select access_type_id, DM.data_id from R_DATA_MAIN DM, R_OBJT_ACCESS OA, R_USER_GROUP UG, R_USER_MAIN UM, R_COLL_MAIN CM where DM.data_name like ? and DM.coll_id=CM.coll_id and CM.coll_name like ? and UM.user_name=? and UM.zone_name = ? and UM.user_type_name!='rodsgroup' and UM.user_id = UG.user_id and OA.object_id = DM.data_id and UG.group_user_id = OA.user_id ) as foo group by data_id ) as bar";
366 std::vector<std::string> bind_vars;
367 bind_vars.push_back( _data_name.c_str() );
368 bind_vars.push_back( _collection.c_str() );
369 bind_vars.push_back( _user_name.c_str() );
370 bind_vars.push_back( _zone.c_str() );
383 if ( access_permission < access_needed ) {
395 std::string query =
"select count( max ) from ( select max(access_type_id) max from ( select access_type_id, DM.data_id from R_DATA_MAIN DM, R_OBJT_ACCESS OA, R_USER_GROUP UG, R_USER_MAIN UM, R_COLL_MAIN CM where DM.data_name like ? and DM.coll_id=CM.coll_id and CM.coll_name like ? and UM.user_name=? and UM.zone_name = ? and UM.user_type_name!='rodsgroup' and UM.user_id = UG.user_id and OA.object_id = DM.data_id and UG.group_user_id = OA.user_id ) group by data_id )";
397 std::string query =
"select count( max ) from ( select max(access_type_id) max from ( select access_type_id, DM.data_id from R_DATA_MAIN DM, R_OBJT_ACCESS OA, R_USER_GROUP UG, R_USER_MAIN UM, R_COLL_MAIN CM where DM.data_name like ? and DM.coll_id=CM.coll_id and CM.coll_name like ? and UM.user_name=? and UM.zone_name = ? and UM.user_type_name!='rodsgroup' and UM.user_id = UG.user_id and OA.object_id = DM.data_id and UG.group_user_id = OA.user_id ) as foo group by data_id ) as baz";
399 std::vector<std::string> bind_vars;
400 bind_vars.push_back( _data_name.c_str() );
401 bind_vars.push_back( _collection.c_str() );
402 bind_vars.push_back( _user_name.c_str() );
403 bind_vars.push_back( _zone.c_str() );
406 &access_permission_count,
413 "query for access permission count failed" );
416 if( num_data_objects > access_permission_count ) {
417 std::stringstream msg;
418 msg <<
"access denined - num_data_objects "
420 <<
" > access_permission_count "
421 << access_permission_count;
431 return CODE( num_data_objects );
451 "delete from R_OBJT_METAMAP where object_id=?" );
475 "delete from R_META_MAIN where meta_id in (select meta_id from R_META_MAIN minus select meta_id from R_OBJT_METAMAP)" );
480 "delete from R_META_MAIN where meta_id not in (select meta_id from R_OBJT_METAMAP)" );
484 "delete from R_META_MAIN where meta_id in (select meta_id from R_META_MAIN except select meta_id from R_OBJT_METAMAP)" );
510 struct addrinfo hint;
511 memset(&hint, 0,
sizeof(hint));
512 hint.ai_family = AF_INET;
513 struct addrinfo *p_addrinfo;
515 if (ret_getaddrinfo_with_retry) {
516 return ret_getaddrinfo_with_retry;
518 freeaddrinfo(p_addrinfo);
529 snprintf( errMsg, 150,
530 "Warning, resource host address '%s' is not a valid DNS entry, hostname_resolves_to_ipv4 failed.",
534 if ( strcmp( _hostAddress,
"localhost" ) == 0 ) {
536 "Warning, resource host address 'localhost' will not work properly as it maps to the local host from each client." );
545 if (0 == path.compare(
"/")) {
546 const std::string error_message =
"root directory cannot be used as vault path.";
557 const std::string& _new_child ) {
564 std::string resc_name;
566 parser.set_string( _new_child );
567 parser.first_child( resc_name );
580 std::vector<std::string> bindVars;
581 bindVars.push_back( resc_name );
582 bindVars.push_back( zone );
584 "select resc_parent from R_RESC_MAIN where resc_name=? and zone_name=?",
589 std::stringstream ss;
590 ss <<
"Child resource \"" << resc_name <<
"\" not found";
596 return ERROR(
status,
"error encountered in query for _childIsValid" );
599 else if ( strlen( parent ) != 0 ) {
601 std::stringstream ss;
602 ss <<
"Child resource \"" << resc_name <<
"\" already has a parent \"" << parent <<
"\"";
610 const std::string& _child_resc_id,
611 const std::string& _parent_resc_id,
612 const std::string& _parent_child_context ) {
627 "update R_RESC_MAIN set resc_parent=?, resc_parent_context=?, modify_ts=? "
632 return ERROR(
status,
"cmlExecuteNoAnswerSql failed" );
645 const std::string& _resc_name,
657 if ( 0 == obj_count ) {
671 boost::regex re(
"^(?=.{1,63}$)\\w+(-\\w+)*$" );
673 if ( !boost::regex_match( _resc_name, re ) ) {
674 std::stringstream msg;
675 msg <<
"validate_resource_name failed for resource [";
697 std::vector<std::string> bindVars;
698 bindVars.push_back( rescId );
700 "select resc_parent from R_RESC_MAIN where resc_id=?",
705 std::stringstream ss;
706 ss <<
"Resource \"" << rescId <<
"\" not found";
714 if ( strlen( parent ) != 0 ) {
718 std::vector<std::string> bindVars;
719 bindVars.push_back( rescId );
721 "select resc_id from R_RESC_MAIN where resc_parent=?",
730 if ( strlen( children ) != 0 ) {
737 bool _userInRUserAuth(
const char* userName,
const char* zoneName,
const char* auth_name ) {
744 std::vector<std::string> bindVars;
745 bindVars.push_back( userName );
746 bindVars.push_back( zoneName );
747 bindVars.push_back( auth_name );
749 "select user_id from R_USER_AUTH where user_id=(select user_id from R_USER_MAIN where user_name=? and zone_name=?) and user_auth_name=?",
750 &iVal, bindVars, &
icss );
765 return ( !std::isalnum( _c ) &&
773 std::string _zone_name ) {
774 std::string::iterator itr = std::find_if( _zone_name.begin(),
777 if ( itr != _zone_name.end() || _zone_name.length() >=
NAME_LEN ) {
778 std::stringstream msg;
779 msg <<
"validate_zone_name failed for zone [";
811 if ( strlen( logicalParentDirName ) == 0 ) {
812 snprintf( logicalParentDirName,
sizeof( logicalParentDirName ),
"%s",
PATH_SEPARATOR );
813 snprintf( logicalEndName,
sizeof( logicalEndName ),
"%s", collInfo->
collName + 1 );
829 snprintf( errMsg, 100,
"collection '%s' is unknown",
830 logicalParentDirName );
859 std::vector<std::string> bindVars;
860 bindVars.push_back( collInfo->
collName );
861 bindVars.push_back( collInfo->
collName );
863 "select coll_id from R_COLL_MAIN where parent_coll_name=? union select coll_id from R_DATA_MAIN where coll_id=(select coll_id from R_COLL_MAIN where coll_name=?)",
864 &iVal, bindVars, &
icss );
880 "delete from R_COLL_MAIN where coll_name=? and coll_id=?",
884 "_delColl cmlExecuteNoAnswerSql delete failure %d",
896 "delete from R_OBJT_ACCESS where object_id=?",
900 "_delColl cmlExecuteNoAnswerSql delete access failure %d",
917 "chlModColl cmlAudit3 failure %d",
933 const char* _challenge,
934 const char* _user_name,
935 const char* _response ) {
941 else if ( !_challenge ) {
944 else if ( !_user_name ) {
947 else if ( !_response ) {
966 irods::auth_ptr auth_plugin = boost::dynamic_pointer_cast< irods::auth >( ptr );
970 ret = auth_plugin->call <
const char*,
const char*,
const char* > ( 0,
irods::AUTH_AGENT_AUTH_VERIFY, auth_obj, _challenge, _user_name, _response );
986 char *cp1, *cp2, *cp3;
994 for ( i = 0; i < len; i++ ) {
995 if ( *cp1++ != *cp2++ ) {
999 snprintf( pw2,
sizeof( pw2 ),
"%s", cp1 );
1001 if ( cp3 ==
NULL ) {
1021 if ( cp1 ==
NULL ) {
1048 std::vector<std::string> bindVars;
1052 "select rcat_password from R_USER_PASSWORD, R_USER_MAIN where user_name=? and R_USER_MAIN.zone_name=? and R_USER_MAIN.user_id = R_USER_PASSWORD.user_id",
1069 pwLen1 = strlen( upassword );
1073 cp = strstr( upassword, rand );
1078 pwLen2 = strlen( upassword );
1083 snprintf( errMsg, 250,
1084 "Error with password encoding. This can be caused by not connecting directly to the ICAT host, not using password authentication (using GSI or Kerberos instead), or entering your password incorrectly (if prompted)." );
1088 strcpy(
out, upassword );
1096 if ( strcmp( typeStr,
"-d" ) == 0 ) {
1099 if ( strcmp( typeStr,
"-D" ) == 0 ) {
1102 if ( strcmp( typeStr,
"-c" ) == 0 ) {
1105 if ( strcmp( typeStr,
"-C" ) == 0 ) {
1108 if ( strcmp( typeStr,
"-r" ) == 0 ) {
1111 if ( strcmp( typeStr,
"-R" ) == 0 ) {
1114 if ( strcmp( typeStr,
"-u" ) == 0 ) {
1117 if ( strcmp( typeStr,
"-U" ) == 0 ) {
1132 const char* access ) {
1154 if ( *
type ==
'\0' ) {
1163 if ( *
name ==
'\0' ) {
1176 if ( strlen( logicalParentDirName ) == 0 ) {
1177 snprintf( logicalParentDirName,
sizeof( logicalParentDirName ),
"%s",
PATH_SEPARATOR );
1178 snprintf( logicalEndName,
sizeof( logicalEndName ),
"%s",
name );
1207 snprintf( errMsg, 100,
"collection '%s' is unknown",
1224 return PASS( ret ).code();
1232 std::vector<std::string> bindVars;
1233 bindVars.push_back(
name );
1234 bindVars.push_back( zone );
1236 "select resc_id from R_RESC_MAIN where resc_name=? and zone_name=?",
1237 &objId, bindVars, &
icss );
1257 if ( userZone[0] ==
'\0' ) {
1261 return PASS( ret ).code();
1263 snprintf( userZone,
sizeof( userZone ),
"%s", zone.c_str() );
1271 std::vector<std::string> bindVars;
1272 bindVars.push_back( userName );
1273 bindVars.push_back( userZone );
1275 "select user_id from R_USER_MAIN where user_name=? and zone_name=?",
1276 &objId, bindVars, &
icss );
1303 if ( *units !=
'\0' ) {
1308 std::vector<std::string> bindVars;
1309 bindVars.push_back( attribute );
1310 bindVars.push_back(
value );
1311 bindVars.push_back( units );
1313 "select meta_id from R_META_MAIN where meta_attr_name=? and meta_attr_value=? and meta_attr_unit=?",
1314 &iVal, bindVars, &
icss );
1322 std::vector<std::string> bindVars;
1323 bindVars.push_back( attribute );
1324 bindVars.push_back(
value );
1326 "select meta_id from R_META_MAIN where meta_attr_name=? and meta_attr_value=? and (meta_attr_unit='' or meta_attr_unit IS NULL)",
1327 &iVal, bindVars, &
icss );
1365 snprintf( nextStr,
sizeof nextStr,
"%lld", seqNum );
1380 "insert into R_META_MAIN (meta_id, meta_attr_name, meta_attr_value, meta_attr_unit, create_ts, modify_ts) values (?, ?, ?, ?, ?, ?)",
1393 return boost::regex_replace( inPath, boost::regex(
"[%_\\\\]" ),
"\\\\$&" );
1398 int _modInheritance(
int inheritFlag,
int recursiveFlag,
const char *collIdStr,
const char *pathName ) {
1400 const char* newValue = inheritFlag == 1 ?
"1" :
"0";
1407 if ( recursiveFlag == 0 ) {
1417 "update R_COLL_MAIN set coll_inheritance=?, modify_ts=? where coll_id=?",
1433 "update R_COLL_MAIN set coll_inheritance=?, modify_ts=? where coll_name = ? or coll_name like ? ESCAPE '\\'",
1437 "update R_COLL_MAIN set coll_inheritance=?, modify_ts=? where coll_name = ? or coll_name like ?",
1447 snprintf( auditStr,
sizeof( auditStr ),
"inheritance %srecursive %s",
1448 recursiveFlag ?
"" :
"non-",
1459 "_modInheritance cmlAudit5 failure %d",
1485 char mySQL1[] =
"select sum(quota_usage), UM1.user_id, R_QUOTA_USAGE.resc_id from R_QUOTA_USAGE, R_QUOTA_MAIN, R_USER_MAIN UM1, R_USER_GROUP, R_USER_MAIN UM2 where R_QUOTA_MAIN.user_id = UM1.user_id and UM1.user_type_name = 'rodsgroup' and R_USER_GROUP.group_user_id = UM1.user_id and UM2.user_id = R_USER_GROUP.user_id and R_QUOTA_USAGE.user_id = UM2.user_id and R_QUOTA_MAIN.resc_id = R_QUOTA_USAGE.resc_id group by UM1.user_id, R_QUOTA_USAGE.resc_id";
1489 char mySQL2a[] =
"select sum(quota_usage), R_QUOTA_MAIN.quota_limit, UM1.user_id from R_QUOTA_USAGE, R_QUOTA_MAIN, R_USER_MAIN UM1, R_USER_GROUP, R_USER_MAIN UM2 where R_QUOTA_MAIN.user_id = UM1.user_id and UM1.user_type_name = 'rodsgroup' and R_USER_GROUP.group_user_id = UM1.user_id and UM2.user_id = R_USER_GROUP.user_id and R_QUOTA_USAGE.user_id = UM2.user_id and R_QUOTA_USAGE.resc_id != %s and R_QUOTA_MAIN.resc_id = %s group by UM1.user_id, R_QUOTA_MAIN.quota_limit";
1492 char mySQL3a[] =
"update R_QUOTA_MAIN set quota_over= %s - ?, modify_ts=? where user_id=? and %s - ? > quota_over";
1502 "update R_QUOTA_MAIN set quota_over = -quota_limit", &
icss );
1516 "update R_QUOTA_MAIN set quota_over = (select distinct R_QUOTA_USAGE.quota_usage - R_QUOTA_MAIN.quota_limit from R_QUOTA_USAGE where R_QUOTA_MAIN.user_id = R_QUOTA_USAGE.user_id and R_QUOTA_MAIN.resc_id = R_QUOTA_USAGE.resc_id) where exists (select 1 from R_QUOTA_USAGE where R_QUOTA_MAIN.user_id = R_QUOTA_USAGE.user_id and R_QUOTA_MAIN.resc_id = R_QUOTA_USAGE.resc_id)",
1518 "update R_QUOTA_MAIN, R_QUOTA_USAGE set R_QUOTA_MAIN.quota_over = R_QUOTA_USAGE.quota_usage - R_QUOTA_MAIN.quota_limit where R_QUOTA_MAIN.user_id = R_QUOTA_USAGE.user_id and R_QUOTA_MAIN.resc_id = R_QUOTA_USAGE.resc_id",
1520 "update R_QUOTA_MAIN set quota_over = quota_usage - quota_limit from R_QUOTA_USAGE where R_QUOTA_MAIN.user_id = R_QUOTA_USAGE.user_id and R_QUOTA_MAIN.resc_id = R_QUOTA_USAGE.resc_id",
1538 for ( rowsFound = 0;; rowsFound++ ) {
1540 if ( rowsFound == 0 ) {
1541 status =
cmlGetFirstRowFromSql(
"select sum(quota_usage), R_QUOTA_MAIN.user_id from R_QUOTA_USAGE, R_QUOTA_MAIN where R_QUOTA_MAIN.user_id = R_QUOTA_USAGE.user_id and R_QUOTA_MAIN.resc_id = '0' group by R_QUOTA_MAIN.user_id",
1542 &statementNum, 0, &
icss );
1557 status2 =
cmlExecuteNoAnswerSql(
"update R_QUOTA_MAIN set quota_over=?-quota_limit, modify_ts=? where user_id=? and ?-quota_limit > quota_over and resc_id='0'",
1562 if ( status2 != 0 ) {
1573 for ( rowsFound = 0;; rowsFound++ ) {
1575 if ( rowsFound == 0 ) {
1593 status2 =
cmlExecuteNoAnswerSql(
"update R_QUOTA_MAIN set quota_over=?-quota_limit, modify_ts=? where user_id=? and ?-quota_limit > quota_over and R_QUOTA_MAIN.resc_id=?",
1598 if ( status2 != 0 ) {
1616 snprintf( mySQL2b,
sizeof mySQL2b, mySQL2a,
1617 "cast('0' as integer)",
"cast('0' as integer)" );
1618 snprintf( mySQL3b,
sizeof mySQL3b, mySQL3a,
1619 "cast(? as integer)",
"cast(? as integer)" );
1621 snprintf( mySQL2b,
sizeof mySQL2b, mySQL2a,
"'0'",
"'0'" );
1622 snprintf( mySQL3b,
sizeof mySQL3b, mySQL3a,
"?",
"?" );
1624 snprintf( mySQL2b,
sizeof mySQL2b, mySQL2a,
1625 "cast('0' as bigint)",
"cast('0' as bigint)" );
1626 snprintf( mySQL3b,
sizeof mySQL3b, mySQL3a,
1627 "cast(? as bigint)",
"cast(? as bigint)" );
1633 for ( rowsFound = 0;; rowsFound++ ) {
1635 if ( rowsFound == 0 ) {
1659 if ( status2 != 0 ) {
1696 snprintf( zoneToUse,
sizeof( zoneToUse ),
"%s", zone.c_str() );
1701 if ( userZone[0] !=
'\0' ) {
1710 std::vector<std::string> bindVars;
1711 bindVars.push_back( userName2 );
1712 bindVars.push_back( zoneToUse );
1714 "select user_id from R_USER_MAIN where user_name=? and R_USER_MAIN.zone_name=? and user_type_name!='rodsgroup'",
1723 strncpy( userIdStr, userId,
NAME_LEN );
1741 snprintf( zoneToUse,
sizeof( zoneToUse ),
"%s", zone.c_str() );
1746 if ( groupZone[0] !=
'\0' ) {
1755 std::vector<std::string> bindVars;
1756 bindVars.push_back( groupName2 );
1757 bindVars.push_back( zoneToUse );
1759 "select user_id from R_USER_MAIN where user_name=? and R_USER_MAIN.zone_name=? and user_type_name='rodsgroup'",
1768 strncpy( groupIdStr, groupId,
NAME_LEN );
1775 struct addrinfo hint;
1776 memset(&hint, 0,
sizeof(hint));
1777 hint.ai_family = AF_INET;
1778 struct addrinfo *p_addrinfo;
1780 if (ret_getaddrinfo_with_retry) {
1781 return ret_getaddrinfo_with_retry;
1783 sprintf(_buf,
"%s", inet_ntoa(
reinterpret_cast<struct sockaddr_in*
>(p_addrinfo->ai_addr)->sin_addr));
1784 freeaddrinfo(p_addrinfo);
1791 static char ipAddr[50];
1794 rodsLog(
LOG_ERROR,
"convertHostToIp convert_hostname_to_dotted_decimal_ipv4_and_store_in_buffer error. status [%d]",
status );
1831 const char* _mode ) {
1858 std::string
mode( _mode );
1867 if (
mode.find(
"sql" ) != std::string::npos ) {
1917 const auto& db_type = db_plugin_map.begin()->first;
1918 const auto& db_plugin = db_plugin_map.begin()->second;
1924 }
catch (
const boost::exception&
e ) {
1934 "failed to open db connection" );
1957 rodsLog(
LOG_DEBUG,
"[%s:%d] PAM property not found", __FUNCTION__, __LINE__);
2002 "failed to close db connection" );
2019 const char* _access ) {
2038 return ERROR(
status,
"checkAndGetObjectId failed" );
2051 std::string* _zone ) {
2079 const std::string* _resc,
2101 if ( !_data_obj_info ||
2123 int status = 0, upCols = 0;
2134 const char* whereColsAndConds[10];
2135 const char* whereValues[10];
2137 int numConditions = 0;
2140 std::vector<const char *> updateCols;
2141 std::vector<const char *> updateVals;
2143 const std::vector<std::string_view> regParamNames = {
2169 const std::vector<std::string_view> colNames = {
2195 int doingDataSize = 0;
2196 char dataSizeString[
NAME_LEN] =
"";
2198 char *neededAccess = 0;
2212 std::string update_resc_id_str;
2214 bool update_resc_id =
false;
2216 std::size_t i = 0, j = 0;
2217 for (i = 0, j = 0; i < regParamNames.size(); i++) {
2218 theVal =
getValByKey(_reg_param, regParamNames[i].data());
2220 if(colNames[i] ==
"resc_name") {
2223 else if(colNames[i] ==
"resc_hier") {
2224 updateCols.push_back(
"resc_id" );
2229 update_resc_id_str = boost::lexical_cast<std::string>(resc_id);
2230 updateVals.push_back( update_resc_id_str.c_str() );
2233 updateCols.push_back(colNames[i].data());
2234 updateVals.push_back(theVal);
2237 if ( std::string(
"resc_id" ) == colNames[i] || std::string(
"resc_hier") == colNames[i]) {
2238 update_resc_id =
true;
2243 if (colNames[i] ==
"data_expiry_ts") {
2244 if ( strlen( theVal ) < 11 ) {
2245 static char theVal2[20];
2247 myTimeValue = atoll( theVal );
2248 snprintf( theVal2,
sizeof theVal2,
"%011d", (
int )myTimeValue );
2249 updateVals[j] = theVal2;
2256 if (colNames[i] ==
"modify_ts") {
2257 if ( strlen( theVal ) < 11 ) {
2258 static char theVal3[20];
2260 myTimeValue = atoll( theVal );
2261 snprintf( theVal3,
sizeof theVal3,
"%011d", (
int )myTimeValue );
2262 updateVals[j] = theVal3;
2268 snprintf( dataSizeString,
sizeof( dataSizeString ),
"%s", theVal );
2278 std::stringstream msg;
2279 msg << __FUNCTION__;
2280 msg <<
" - Invalid data type specified.";
2298 if ( upCols == 1 && strcmp( updateCols[0],
"chksum" ) == 0 ) {
2305 if ( theVal !=
NULL ) {
2309 if ( _data_obj_info->
dataId <= 0 ) {
2318 std::vector<std::string> bindVars;
2319 bindVars.push_back( logicalDirName );
2321 "select coll_id from R_COLL_MAIN where coll_name=?", &iVal,
2327 snprintf( errMsg, 100,
"collection '%s' is unknown",
2333 "failed with unknown collection" );
2341 std::vector<std::string> bindVars;
2342 bindVars.push_back( objIdString );
2343 bindVars.push_back( logicalFileName );
2345 "select data_id from R_DATA_MAIN where coll_id=? and data_name=?",
2346 &iVal, bindVars, &
icss );
2349 std::stringstream msg;
2350 msg << __FUNCTION__;
2351 msg <<
" - Failed to find file in database by its logical path.";
2356 "failed with unknown file" );
2359 _data_obj_info->
dataId = iVal;
2369 objIdString, &
icss );
2373 "cmlTicketUpdateWriteBytes failed" );
2388 if ( theVal !=
NULL && upCols == 1 &&
2389 strcmp( updateCols[0],
"data_path" ) == 0 ) {
2398 len = strlen( theVal );
2399 if ( strncmp( theVal, _data_obj_info->
objPath, len ) == 0 ) {
2416 "failed with no permission" );
2421 whereColsAndConds[0] =
"data_id=";
2423 whereValues[0] = idVal;
2431 std::string where_resc_id_str;
2437 if ( update_resc_id || strlen( _data_obj_info->
rescHier ) <= 0 ) {
2439 whereColsAndConds[j] =
"data_repl_num=";
2441 whereValues[j] = replNum1;
2448 where_resc_id_str = boost::lexical_cast<std::string>(
id);
2450 whereColsAndConds[j] =
"resc_id=";
2451 whereValues[j] = where_resc_id_str.c_str();
2489 updateCols.push_back(
"data_is_dirty" );
2491 updateVals.push_back( newCopy );
2506 j = numConditions - 1;
2507 whereColsAndConds[j] =
"data_repl_num!=";
2509 whereValues[j] = replNum1;
2511 updateCols[0] =
"data_is_dirty";
2513 updateVals[0] = oldCopy;
2518 whereColsAndConds, whereValues, 1,
2519 numConditions, &
icss );
2524 "chlModDataObjMeta cmlModifySingleTable failure for other replicas %d",
2529 "cmlModifySingleTable failure for other replicas" );
2537 "chlModDataObjMeta cmlModifySingleTable failure %d",
2541 "cmlModifySingleTable failure" );
2548 "chlModDataObjMeta cmlExecuteNoAnswerSql commit failure %d",
2575 if ( !_data_obj_info ) {
2607 char data_expiry_ts[] = {
"00000000000" };
2626 return ERROR( seqNum,
"chlRegDataObj cmlGetNextSeqVal failure" );
2629 _data_obj_info->
dataId = seqNum;
2647 std::stringstream errMsg;
2648 errMsg <<
"collection '" << logicalDirName <<
"' is unknown";
2652 std::stringstream errMsg;
2653 errMsg <<
"no permission to update collection '" << logicalDirName <<
"'";
2656 return ERROR( iVal,
"" );
2665 std::vector<std::string> bindVars;
2666 bindVars.push_back( _data_obj_info->
objPath );
2668 "select coll_id from R_COLL_MAIN where coll_name=?",
2669 &iVal, bindVars, &
icss );
2689 if (0 == strcmp(_data_obj_info->
dataModify,
"")) {
2693 std::string resc_id_str = boost::lexical_cast<std::string>(_data_obj_info->
rescId);
2719 "insert into R_DATA_MAIN (data_id, coll_id, data_name, data_repl_num, data_version, data_type_name, data_size, resc_id, data_path, data_owner_name, data_owner_zone, data_is_dirty, data_checksum, data_mode, create_ts, modify_ts, data_expiry_ts, resc_name, resc_hier, resc_group_name) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
2723 "chlRegDataObj cmlExecuteNoAnswerSql failure %d",
status );
2725 return ERROR(
status,
"chlRegDataObj cmlExecuteNoAnswerSql failure" );
2737 if ( inheritFlag ) {
2749 "insert into R_OBJT_ACCESS (object_id, user_id, access_type_id, create_ts, modify_ts) (select ?, user_id, access_type_id, ?, ? from R_OBJT_ACCESS where object_id = ?)",
2753 "chlRegDataObj cmlExecuteNoAnswerSql insert access failure %d",
2756 return ERROR(
status,
"cmlExecuteNoAnswerSql insert access failure" );
2771 "insert into R_OBJT_ACCESS values (?, (select user_id from R_USER_MAIN where user_name=? and zone_name=?), (select token_id from R_TOKN_MAIN where token_namespace = 'access_type' and token_name = ?), ?, ?)",
2775 "chlRegDataObj cmlExecuteNoAnswerSql insert access failure %d",
2778 return ERROR(
status,
"cmlExecuteNoAnswerSql insert access failure" );
2787 "chlRegDataObj cmlAudit3 failure %d",
2798 "chlRegDataObj cmlExecuteNoAnswerSql commit failure %d",
2800 return ERROR(
status,
"cmlExecuteNoAnswerSql commit failure" );
2826 !_src_data_obj_info ||
2827 !_dst_data_obj_info ||
2834 if( _dst_data_obj_info->
rescId <= 0 ) {
2835 std::stringstream msg;
2836 msg <<
"invalid resource id "
2837 << _dst_data_obj_info->
rescId
2839 << _dst_data_obj_info->
objPath
2872 char theColls[] =
"data_id, \
2895 const int IX_DATA_REPL_NUM = 3;
2897 const int IX_RESC_ID = 10;
2898 const int IX_DATA_PATH = 11;
2900 const int IX_DATA_MODE = 19;
2901 const int IX_CREATE_TS = 21;
2902 const int IX_MODIFY_TS = 22;
2903 const int IX_RESC_NAME2 = 23;
2904 const int IX_DATA_PATH2 = 24;
2905 const int IX_DATA_ID2 = 25;
2918 if ( _cond_input !=
NULL ) {
2920 if ( theVal !=
NULL ) {
2948 return ERROR(
status,
"cmlCheckDataObjOnly failed" );
2958 std::vector<std::string> bindVars;
2959 bindVars.push_back( objIdString );
2961 "select max(data_repl_num) from R_DATA_MAIN where data_id = ?",
2962 &iVal, bindVars, &
icss );
2967 return ERROR(
status,
"cmlGetIntegerValueFromSql failed" );
2970 nextReplNum = iVal + 1;
2971 snprintf( nextRepl,
sizeof nextRepl,
"%d", nextReplNum );
2972 _dst_data_obj_info->
replNum = nextReplNum;
2975 "select %s from R_DATA_MAIN where data_id = ? and data_repl_num = ?",
2981 std::vector<std::string> bindVars;
2982 bindVars.push_back( objIdString );
2983 bindVars.push_back( replNumString );
2988 return ERROR(
status,
"cmlGetOneRowFromSqlV2 failed" );
2990 statementNumber =
status;
2992 std::string resc_id_str = boost::lexical_cast<std::string>(_dst_data_obj_info->
rescId);
2994 cVal[IX_DATA_REPL_NUM] = nextRepl;
2996 cVal[IX_RESC_ID] = (
char*)resc_id_str.c_str();
2997 cVal[IX_DATA_PATH] = _dst_data_obj_info->
filePath;
2998 cVal[IX_DATA_MODE] = _dst_data_obj_info->
dataMode;
3001 cVal[IX_MODIFY_TS] = myTime;
3002 cVal[IX_CREATE_TS] = myTime;
3004 cVal[IX_RESC_NAME2] = (
char*)resc_id_str.c_str();
3005 cVal[IX_DATA_PATH2] = _dst_data_obj_info->
filePath;
3006 cVal[IX_DATA_ID2] = objIdString;
3012 #if (defined ORA_ICAT || defined MY_ICAT) // JMC - backport 4685
3014 snprintf(
tSQL,
MAX_SQL_SIZE,
"insert into R_DATA_MAIN ( %s ) select ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? from DUAL where not exists (select data_id from R_DATA_MAIN where resc_id=? and data_path=? and data_id=?)",
3018 snprintf(
tSQL,
MAX_SQL_SIZE,
"insert into R_DATA_MAIN ( %s ) select ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? where not exists (select data_id from R_DATA_MAIN where resc_id=? and data_path=? and data_id=?)",
3028 "chlRegReplica cmlExecuteNoAnswerSql(insert) failure %d",
3032 if (free_status != 0) {
3033 rodsLog(
LOG_ERROR,
"db_reg_replica_op: cmlFreeStatement0 failure [%d]", free_status);
3035 return ERROR(
status,
"cmlExecuteNoAnswerSql(insert) failure" );
3043 if (free_status != 0) {
3044 rodsLog(
LOG_ERROR,
"db_reg_replica_op: cmlFreeStatement1 failure [%d]", free_status);
3052 return ERROR(
status,
"cmlFreeStatement failure" );
3060 "chlRegDataReplica cmlAudit3 failure %d",
3069 "chlRegReplica cmlExecuteNoAnswerSql commit failure %d",
3071 return ERROR(
status,
"cmlExecuteNoAnswerSql commit failure" );
3121 char replNumber[30];
3122 char dataObjNumber[30];
3128 dataObjNumber[0] =
'\0';
3139 if ( _cond_input !=
NULL ) {
3141 if ( theVal !=
NULL ) {
3145 if ( theVal !=
NULL ) {
3155 if ( adminMode == 0 ) {
3166 return ERROR(
status,
"cmlCheckDataObjOnly failed" );
3168 snprintf( dataObjNumber,
sizeof dataObjNumber,
"%lld",
status );
3181 snprintf( checkPath,
MAX_NAME_LEN,
"/%s/trash", zone.c_str() );
3182 len = strlen( checkPath );
3183 if ( strncmp( checkPath, logicalDirName, len ) != 0 ) {
3185 "TRASH_KW but not zone/trash path" );
3188 if ( _data_obj_info->
dataId > 0 ) {
3189 snprintf( dataObjNumber,
sizeof dataObjNumber,
"%lld",
3190 _data_obj_info->
dataId );
3194 if ( _data_obj_info->
replNum >= 0 && _data_obj_info->
dataId >= 0 ) {
3195 snprintf( dataObjNumber,
sizeof dataObjNumber,
"%lld",
3196 _data_obj_info->
dataId );
3200 "dataId and replNum required" );
3208 std::string resc_hier;
3209 if ( strlen( _data_obj_info->
rescHier ) == 0 ) {
3211 if ( _data_obj_info->
replNum >= 0 ) {
3212 snprintf( replNumber,
sizeof replNumber,
"%d", _data_obj_info->
replNum );
3214 std::vector<std::string> bindVars;
3215 bindVars.push_back( dataObjNumber );
3216 bindVars.push_back( replNumber );
3218 "select resc_id from R_DATA_MAIN where data_id=? and data_repl_num=?",
3219 &resc_id, bindVars, &
icss );
3222 return ERROR(
status,
"cmlGetStringValueFromSql failed" );
3227 std::vector<std::string> bindVars;
3228 bindVars.push_back( dataObjNumber );
3230 "select resc_id from R_DATA_MAIN where data_id=? and data_repl_num=?",
3231 &resc_id, bindVars, &
icss );
3234 return ERROR(
status,
"cmlGetStringValueFromSql failed" );
3240 resc_hier = std::string( _data_obj_info->
rescHier );
3245 if ( _data_obj_info->
replNum >= 0 ) {
3246 snprintf( replNumber,
sizeof replNumber,
"%d", _data_obj_info->
replNum );
3253 "delete from R_DATA_MAIN where coll_id=(select coll_id from R_COLL_MAIN where coll_name=?) and data_name=? and data_repl_num=?" );
3261 "delete from R_DATA_MAIN where coll_id=(select coll_id from R_COLL_MAIN where coll_name=?) and data_name=?" );
3268 snprintf( errMsg, 100,
"data object '%s' is unknown",
3274 return ERROR(
status,
"cmlExecuteNoAnswerSql failed" );
3285 if ( dataObjNumber[0] !=
'\0' ) {
3293 "delete from R_OBJT_ACCESS where object_id=? and not exists (select * from R_DATA_MAIN where data_id=?)", &
icss );
3300 if ( dataObjNumber[0] !=
'\0' ) {
3313 "chlUnregDataObj cmlAudit3 failure %d",
3323 "chlUnregDataObj cmlExecuteNoAnswerSql commit failure %d",
3325 return ERROR(
status,
"cmlExecuteNoAnswerSql commit failure" );
3387 return ERROR( seqNum,
"cmlGetNextSeqVal failure" );
3389 snprintf( ruleExecIdNum,
MAX_NAME_LEN,
"%lld", seqNum );
3414 "insert into R_RULE_EXEC (rule_exec_id, rule_name, rei_file_path, user_name, exe_address, exe_time, exe_frequency, priority, estimated_exe_time, notification_addr, create_ts, modify_ts) values (?,?,?,?,?,?,?,?,?,?,?,?)",
3418 "chlRegRuleExec cmlExecuteNoAnswerSql(insert) failure %d",
status );
3420 return ERROR(
status,
"cmlExecuteNoAnswerSql(insert) failure" );
3431 "chlRegRuleExec cmlAudit3 failure %d",
3440 "chlRegRuleExec cmlExecuteNoAnswerSql commit failure %d",
3442 return ERROR(
status,
"cmlExecuteNoAnswerSql commit failure" );
3497 char *regParamNames[] = {
3505 char *colNames[] = {
3506 "rule_name",
"rei_file_path",
"user_name",
3507 "exe_address",
"exe_time",
"exe_frequency",
"priority",
3508 "estimated_exe_time",
"notification_addr",
3509 "last_exe_time",
"exe_status",
3510 "create_ts",
"modify_ts",
3519 for ( i = 0, j = 0; strcmp( regParamNames[i],
"END" ); i++ ) {
3520 theVal =
getValByKey( _reg_param, regParamNames[i] );
3521 if ( theVal !=
NULL ) {
3547 "chlModRuleExec cmlExecuteNoAnswer(update) failure %d",
3549 return ERROR(
status,
"cmlExecuteNoAnswer(update) failure" );
3559 "chlModRuleExec cmlAudit3 failure %d",
3569 "chlModRuleExecMeta cmlExecuteNoAnswerSql commit failure %d",
3571 return ERROR(
status,
"cmlExecuteNoAnswerSql commit failure" );
3582 const char* _re_id ) {
3629 std::vector<std::string> bindVars;
3630 bindVars.push_back( _re_id );
3632 "select user_name from R_RULE_EXEC where rule_exec_id=?",
3650 "delete from R_RULE_EXEC where rule_exec_id=?",
3654 "chlDelRuleExec delete failure %d",
3667 "chlDelRuleExec cmlAudit3 failure %d",
3676 "chlDelRuleExec cmlExecuteNoAnswerSql commit failure %d",
3678 return ERROR(
status,
"cmlExecuteNoAnswerSql commit failure" );
3689 const std::string& _resc_name,
3690 std::string& _resc_id,
3691 std::string& _resc_parent ) {
3701 ret = resc->get_property<std::string>(
3717 _resc_id = boost::lexical_cast<std::string>(resc_id);
3718 }
catch( boost::bad_lexical_cast& ) {
3719 std::stringstream msg;
3720 msg <<
"failed to cast " << resc_id;
3732 std::map<std::string, std::string> *_resc_input ) {
3735 std::map<std::string, std::string>& resc_input = *_resc_input;
3754 child_parser.
list( c_map );
3759 "child map is empty" );
3762 std::string child_name = c_map.begin()->first;
3763 std::string child_context = c_map.begin()->second;
3765 std::string child_resource_id;
3766 std::string child_parent_name;
3776 child_parent_name.c_str());
3782 if(!child_parent_name.empty()) {
3783 std::stringstream msg;
3784 msg <<
"Encountered an error adding '"
3786 <<
"' as a child resource.";
3797 std::string parent_resource_id;
3798 std::string parent_parent_name;
3802 parent_parent_name);
3807 child_parent_name.c_str());
3816 "_canConnectToCatalog failed");
3829 "Currently, resources must be in the local zone" );
3833 "resources must be in the local zone");
3861 std::map<std::string, std::string> *_resc_input ) {
3865 if ( !_resc_input ) {
3871 std::map<std::string, std::string>& resc_input = *_resc_input;
3945 return ERROR( seqNum,
"cmlGetNextSeqVal failure" );
3959 "Currently, resources must be in the local zone" );
4003 "insert into R_RESC_MAIN (resc_id, resc_name, zone_name, resc_type_name, resc_class_name, resc_net, resc_def_path, create_ts, modify_ts, resc_children, resc_context, resc_parent) values (?,?,?,?,?,?,?,?,?,?,?,?)",
4008 "chlRegResc cmlExectuteNoAnswerSql(insert) failure %d",
4011 return ERROR(
status,
"cmlExectuteNoAnswerSql(insert) failure" );
4021 "chlRegResc cmlAudit3 failure %d",
4024 return ERROR(
status,
"chlRegResc cmlAudit3 failure" );
4030 "chlRegResc cmlExecuteNoAnswerSql commit failure %d",
status );
4031 return ERROR(
status,
"cmlExecuteNoAnswerSql commit failure" );
4042 std::map<std::string, std::string> *_resc_input ) {
4046 if ( !_resc_input ) {
4052 std::map<std::string, std::string>& resc_input = *_resc_input;
4065 std::string parent_resource_id;
4066 std::string parent_parent_resource_id;
4070 parent_parent_resource_id);
4076 parser.set_string( child_string );
4078 std::string child_name;
4079 parser.first_child( child_name );
4081 std::string child_resource_id;
4082 std::string child_parent_resource_id;
4086 child_parent_resource_id);
4091 if (child_parent_resource_id != parent_resource_id) {
4099 "_canConnectToCatalog failed");
4131 const char *_resc_name,
4143 if ( !_resc_name ) {
4185 snprintf( errMsg, 150,
4186 "%s is a built-in resource needed for bundle operations.",
4193 bool has_data =
true;
4198 "%s - _rescHasData failed for [%s] %d",
4204 "failed to get object count for resource" );
4209 snprintf( errMsg, 100,
4210 "resource '%s' contains one or more dataObjects",
4228 std::vector<std::string> bindVars;
4229 bindVars.push_back( _resc_name );
4231 "select resc_id from R_RESC_MAIN where resc_name=?",
4237 snprintf( errMsg, 100,
4238 "resource '%s' does not exist",
4241 return ERROR(
status,
"resource does not exits" );
4244 return ERROR(
status,
"resource does not exist" );
4249 snprintf( errMsg, 100,
4250 "resource '%s' has a parent or child",
4261 "delete from R_RESC_MAIN where resc_name=?",
4266 snprintf( errMsg, 100,
4267 "resource '%s' does not exist",
4270 return ERROR(
status,
"resource does not exist" );
4273 return ERROR(
status,
"resource does not exist" );
4289 "chlDelResc cmlAudit3 failure %d",
4303 "chlDelResc cmlExecuteNoAnswerSql commit failure %d",
4305 return ERROR(
status,
"cmlExecuteNoAnswerSql commit failure" );
4342 "chlRollback cmlExecuteNoAnswerSql failure %d",
4344 return ERROR(
status,
"chlRollback cmlExecuteNoAnswerSql failure" );
4381 "chlCommit cmlExecuteNoAnswerSql failure %d",
4383 return ERROR(
status,
"chlCommit cmlExecuteNoAnswerSql failure" );
4448 snprintf( zoneToUse,
sizeof( zoneToUse ),
"%s", zone.c_str() );
4449 if ( strlen( _user_info->
rodsZone ) > 0 ) {
4450 snprintf( zoneToUse,
sizeof( zoneToUse ),
"%s", _user_info->
rodsZone );
4455 return ERROR(
status,
"Invalid username format" );
4457 if ( zoneName[0] !=
'\0' ) {
4472 std::vector<std::string> bindVars;
4473 bindVars.push_back( userName2 );
4474 bindVars.push_back( zoneToUse );
4476 "select user_id from R_USER_MAIN where user_name=? and zone_name=?",
4477 iValStr, 200, bindVars, &
icss );
4486 return ERROR(
status,
"failed getting user from table" );
4495 "delete from R_USER_MAIN where user_name=? and zone_name=?",
4502 return ERROR(
status,
"cmlExecuteNoAnswerSql for delete user failed" );
4510 "delete from R_USER_PASSWORD where user_id=?",
4515 "chlDelUserRE delete password failure %d",
4517 snprintf( errMsg,
sizeof errMsg,
"Error removing password entry" );
4520 return ERROR(
status,
"Error removing password entry" );
4531 "delete from R_USER_GROUP where user_id=? or group_user_id=?",
4536 "chlDelUserRE delete user_group entry failure %d",
4538 snprintf( errMsg,
sizeof errMsg,
"Error removing user_group entry" );
4541 return ERROR(
status,
"Error removing user_group entry" );
4550 "delete from R_USER_AUTH where user_id=?",
4555 "chlDelUserRE delete user_auth entries failure %d",
4557 snprintf( errMsg,
sizeof errMsg,
"Error removing user_auth entries" );
4560 return ERROR(
status,
"Error removing user_auth entries" );
4567 snprintf( userStr,
sizeof userStr,
"%s#%s",
4568 userName2, zoneToUse );
4577 "chlDelUserRE cmlAudit3 failure %d",
4580 return ERROR(
status,
"chlDelUserRE cmlAudit3 failure" );
4651 if ( status2 != 0 ) {
4652 return ERROR( status2,
"no group admin access" );
4663 if ( strlen( logicalParentDirName ) == 0 ) {
4664 snprintf( logicalParentDirName,
sizeof( logicalParentDirName ),
"%s",
PATH_SEPARATOR );
4665 snprintf( logicalEndName,
sizeof( logicalEndName ),
"%s", _coll_info->
collName + 1 );
4673 std::vector<std::string> bindVars;
4674 bindVars.push_back( logicalParentDirName );
4676 "select coll_id from R_COLL_MAIN where coll_name=?",
4677 &iVal, bindVars, &
icss );
4682 snprintf( errMsg,
sizeof errMsg,
4683 "collection '%s' is unknown, cannot create %s under it",
4684 logicalParentDirName, logicalEndName );
4701 "insert into R_COLL_MAIN (coll_id, parent_coll_name, coll_name, coll_owner_name, coll_owner_zone, coll_type, coll_info1, coll_info2, create_ts, modify_ts) values (%s, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
4715 return ERROR(
status,
"Invalid username format" );
4717 if ( zoneName[0] ==
'\0' ) {
4743 snprintf( errMsg, 100,
"Error %d %s",
4745 "CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME"
4751 "chlRegCollByAdmin cmlExecuteNoAnswerSQL(insert) failure %d"
4754 return ERROR(
status,
"cmlExecuteNoAnswerSQL(insert) failure" );
4768 "insert into R_OBJT_ACCESS values (%s, (select user_id from R_USER_MAIN where user_name=? and zone_name=?), (select token_id from R_TOKN_MAIN where token_namespace = 'access_type' and token_name = ?), ?, ?)",
4776 "chlRegCollByAdmin cmlExecuteNoAnswerSql(insert access) failure %d",
4779 return ERROR(
status,
"cmlExecuteNoAnswerSql(insert access) failure" );
4792 "chlRegCollByAdmin cmlAudit4 failure %d",
4859 if ( strlen( logicalParentDirName ) == 0 ) {
4860 snprintf( logicalParentDirName,
sizeof( logicalParentDirName ),
"%s",
PATH_SEPARATOR );
4861 snprintf( logicalEndName,
sizeof( logicalEndName ),
"%s", _coll_info->
collName + 1 );
4878 snprintf( errMsg, 100,
"collection '%s' is unknown",
4879 logicalParentDirName );
4884 return ERROR(
status,
"cmlCheckDirAndGetInheritFlag failed" );
4893 std::vector<std::string> bindVars;
4894 bindVars.push_back( logicalEndName );
4895 bindVars.push_back( collIdNum );
4897 "select data_id from R_DATA_MAIN where data_name=? and coll_id=?",
4898 &iVal, bindVars, &
icss );
4924 "insert into R_COLL_MAIN (coll_id, parent_coll_name, coll_name, coll_owner_name, coll_owner_zone, coll_type, coll_info1, coll_info2, create_ts, modify_ts) values (%s, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
4930 "chlRegColl cmlExecuteNoAnswerSql(insert) failure %d",
status );
4932 return ERROR(
status,
"cmlExecuteNoAnswerSql(insert) failure" );
4939 if ( inheritFlag ) {
4950 "insert into R_OBJT_ACCESS (object_id, user_id, access_type_id, create_ts, modify_ts) (select %s, user_id, access_type_id, ?, ? from R_OBJT_ACCESS where object_id = ?)",
4973 "update R_COLL_MAIN set coll_inheritance=?, modify_ts=? where coll_id=?",
4984 "update R_COLL_MAIN set coll_inheritance=?, modify_ts=? where coll_id=%s",
4997 "insert into R_OBJT_ACCESS values (%s, (select user_id from R_USER_MAIN where user_name=? and zone_name=?), (select token_id from R_TOKN_MAIN where token_namespace = 'access_type' and token_name = ?), ?, ?)",
5006 "chlRegColl cmlExecuteNoAnswerSql(insert access) failure %d",
5009 return ERROR(
status,
"cmlExecuteNoAnswerSql(insert access) failure" );
5022 "chlRegColl cmlAudit4 failure %d",
5031 "chlRegColl cmlExecuteNoAnswerSql commit failure %d",
5033 return ERROR(
status,
"cmlExecuteNoAnswerSql commit failure" );
5095 std::stringstream errMsg;
5096 errMsg <<
"collection '" << _coll_info->
collName <<
"' is unknown";
5107 std::stringstream errMsg;
5108 errMsg <<
"no permission to update collection '" << _coll_info->
collName <<
"'";
5117 return ERROR( iVal,
"cmlCheckDir failed" );
5121 std::string
tSQL(
"update R_COLL_MAIN set " );
5124 if ( strlen( _coll_info->
collType ) > 0 ) {
5125 if ( strcmp( _coll_info->
collType,
"NULL_SPECIAL_VALUE" ) == 0 ) {
5132 tSQL +=
"coll_type=? ";
5136 if ( strlen( _coll_info->
collInfo1 ) > 0 ) {
5137 if ( strcmp( _coll_info->
collInfo1,
"NULL_SPECIAL_VALUE" ) == 0 ) {
5147 tSQL +=
"coll_info1=? ";
5151 if ( strlen( _coll_info->
collInfo2 ) > 0 ) {
5152 if ( strcmp( _coll_info->
collInfo2,
"NULL_SPECIAL_VALUE" ) == 0 ) {
5162 tSQL +=
"coll_info2=? ";
5186 tSQL +=
" modify_ts=? where coll_name=?";
5195 "chlModColl cmlExecuteNoAnswerSQL(update) failure %d",
status );
5196 return ERROR(
status,
"cmlExecuteNoAnswerSQL(update) failure" );
5200 snprintf( iValStr,
sizeof iValStr,
"%lld", iVal );
5209 "chlModColl cmlAudit3 failure %d",
5222 const char* _zone_name,
5223 const char* _zone_type,
5224 const char* _zone_conn_info,
5225 const char* _zone_comment ) {
5278 if ( strncmp( _zone_type,
"remote", 6 ) != 0 ) {
5280 "Currently, only zones of type 'remote' are allowed" );
5307 "insert into R_ZONE_MAIN (zone_id, zone_name, zone_type_name, zone_conn_string, r_comment, create_ts, modify_ts) values (%s, ?, 'remote', ?, ?, ?, ?)",