00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "eirods_error.h"
00011 #include "eirods_catalog_properties.h"
00012
00013
00014
00015 #include "icatHighLevelRoutines.h"
00016 #include "icatMidLevelRoutines.h"
00017
00018 namespace eirods {
00019
00020
00021 catalog_properties& catalog_properties::getInstance() {
00022 static catalog_properties instance;
00023 return instance;
00024 }
00025
00026
00027
00028 error catalog_properties::capture() {
00029 rodsLong_t row_count = 0;
00030 int col_nbr = 2;
00031 char *sql_out = NULL;
00032 char *row_ptr = NULL;
00033 std::string prop_name, prop_setting;
00034
00035 int i, status = 0;
00036 eirods::error result = SUCCESS();
00037
00038 #if ORA_ICAT
00039 return ERROR(SYS_NOT_IMPLEMENTED, "Capturing catalog properties is not available for Oracle");
00040 #elif MY_ICAT
00041 return ERROR(SYS_NOT_IMPLEMENTED, "Capturing catalog properties is not available for MySQL");
00042 #endif
00043
00044
00045
00046 status = cmlGetIntegerValueFromSqlV3 ("select count(*) from pg_settings", &row_count, &icss);
00047
00048 if (status < 0) {
00049 return ERROR(status, "Unable to get row count from pg_settings");
00050 }
00051
00052
00053 sql_out = (char*)malloc(MAX_NAME_LEN*row_count*col_nbr);
00054 if (!sql_out) {
00055 return ERROR(SYS_MALLOC_ERR, "(x_x)");
00056 }
00057
00058
00059 status = cmlGetMultiRowStringValuesFromSql("select name, setting from pg_settings",
00060 sql_out, MAX_NAME_LEN, row_count*col_nbr, NULL, NULL, &icss);
00061
00062 if (status < 0) {
00063 free(sql_out);
00064 return ERROR(status, "Unable to get values from pg_settings");
00065 }
00066
00067
00068 for (i=0; i<row_count; i++) {
00069
00070 row_ptr = sql_out + i*col_nbr*MAX_NAME_LEN;
00071
00072
00073 row_ptr[MAX_NAME_LEN-1] = '\0';
00074 row_ptr[2*MAX_NAME_LEN-1] = '\0';
00075
00076
00077 prop_name.assign(row_ptr);
00078
00079
00080 prop_setting.assign(row_ptr+MAX_NAME_LEN);
00081
00082
00083 result = properties.set<std::string>(prop_name, prop_setting);
00084
00085 if (!result.ok()) {
00086 break;
00087 }
00088
00089 }
00090
00091
00092 free(sql_out);
00093
00094 return result;
00095
00096 }
00097
00098
00099 }
00100
00101
00102