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)  

reNaraMetaData.cpp
Go to the documentation of this file.
1 
6 #include "reNaraMetaData.hpp"
7 #include "apiHeaderAll.h"
8 #include "irods_stacktrace.hpp"
9 #include "rodsConnect.h"
10 #include "rsModAVUMetadata.hpp"
11 
12 #include "irods_log.hpp"
14 
43 int
45  FILE *fp;
46  char str[500];
47  char *substring;
48  int counter;
49  int flag;
50  char attr[100];
51  char value[500];
52  modAVUMetadataInp_t modAVUMetadataInp;
53  int status;
54  /* specify the location of the metadata file here */
55  char metafile[MAX_NAME_LEN];
56 
57  std::string re_dir;
59  "reConfigs",
60  re_dir );
61  if ( !ret.ok() ) {
62  irods::log( PASS( ret ) );
63  return ret.code();
64  }
65 
66  snprintf(
67  metafile,
68  MAX_NAME_LEN, "%-s/%-s",
69  re_dir.c_str(),
71 
72  if ( ( fp = fopen( metafile, "r" ) ) == NULL ) {
74  "msiExtractNaraMetadata: Cannot open the metadata file %s.", metafile );
75  return UNIX_FILE_OPEN_ERR;
76  }
77 
78  memset( &modAVUMetadataInp, 0, sizeof( modAVUMetadataInp ) );
79  modAVUMetadataInp.arg0 = "add";
80 
81  while ( !feof( fp ) ) {
82  counter = 0;
83  flag = 0;
84  if ( fgets( str, 500, fp ) ) {
85  substring = strtok( str, "|" );
86  while ( substring != NULL ) {
87  if ( flag == 0 && strcmp( substring, rei->doi->objPath ) == 0 ) {
88  flag = 2;
89  }
90 
91  if ( counter == 1 ) {
92  if ( strlen( substring ) >= sizeof( attr ) ) {
94  "attr: [%s] is too long for attr, which may only be %ju characters in length.",
95  ( uintmax_t )sizeof( attr ) );
96  }
97  snprintf( attr, sizeof( attr ), "%s", substring );
98  }
99  if ( flag == 2 && counter == 2 ) {
100  if ( strlen( substring ) >= sizeof( value ) ) {
102  "value: [%s] is too long for value, which may only be %ju characters in length.",
103  ( uintmax_t )sizeof( value ) );
104  }
105  snprintf( value, sizeof( value ), "%s", substring );
106  /*Call the function to insert metadata here.*/
107  modAVUMetadataInp.arg1 = "-d";
108  modAVUMetadataInp.arg2 = rei->doi->objPath;
109  modAVUMetadataInp.arg3 = attr;
110  modAVUMetadataInp.arg4 = value;
111  modAVUMetadataInp.arg5 = "";
112  status = rsModAVUMetadata( rei->rsComm, &modAVUMetadataInp );
113  if ( status < 0 ) {
114  irods::log( ERROR( status, "rsModAVUMetadata failed." ) );
115  }
116  rodsLog( LOG_DEBUG, "msiExtractNaraMetadata: %s:%s", attr, value );
117  }
118  substring = strtok( NULL, "|" );
119  counter++;
120  }
121  }
122  }
123  fclose( fp );
124  return 0;
125 }
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
NULL
#define NULL
Definition: rodsDef.h:70
modAVUMetadataInp_t::arg0
char * arg0
Definition: modAVUMetadata.h:7
irods_get_full_path_for_config_file.hpp
irods_stacktrace.hpp
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
reNaraMetaData.hpp
modAVUMetadataInp_t::arg2
char * arg2
Definition: modAVUMetadata.h:9
NARA_META_DATA_FILE
#define NARA_META_DATA_FILE
Definition: reNaraMetaData.hpp:18
RuleExecInfo::doi
dataObjInfo_t * doi
Definition: irods_re_structs.hpp:28
irods::get_full_path_for_unmoved_configs
error get_full_path_for_unmoved_configs(const std::string &, std::string &)
Definition: irods_get_full_path_for_config_file.cpp:43
modAVUMetadataInp_t::arg4
char * arg4
Definition: modAVUMetadata.h:11
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
rodsConnect.h
rsModAVUMetadata.hpp
RuleExecInfo::rsComm
rsComm_t * rsComm
Definition: irods_re_structs.hpp:22
UNIX_FILE_OPEN_ERR
@ UNIX_FILE_OPEN_ERR
Definition: rodsErrorTable.h:300
irods::error::code
long long code() const
Definition: irods_error.cpp:194
LOG_DEBUG
#define LOG_DEBUG
Definition: rodsLog.h:23
MAX_NAME_LEN
#define MAX_NAME_LEN
Definition: rodsDef.h:61
modAVUMetadataInp_t::arg3
char * arg3
Definition: modAVUMetadata.h:10
get_irods_version.value
dictionary value
Definition: get_irods_version.py:27
irods.pypyodbc.status
status
Definition: pypyodbc.py:467
irods::log
void log(const error &)
Definition: irods_log.cpp:13
rsModAVUMetadata
int rsModAVUMetadata(rsComm_t *rsComm, modAVUMetadataInp_t *modAVUMetadataInp)
Definition: rsModAVUMetadata.cpp:13
modAVUMetadataInp_t
Definition: modAVUMetadata.h:6
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::error
Definition: irods_error.hpp:23
apiHeaderAll.h
RuleExecInfo
Definition: irods_re_structs.hpp:18
DataObjInfo::objPath
char objPath[(1024+64)]
Definition: objInfo.h:130
modAVUMetadataInp_t::arg5
char * arg5
Definition: modAVUMetadata.h:12
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irods_log.hpp
msiExtractNaraMetadata
int msiExtractNaraMetadata(ruleExecInfo_t *rei)
Definition: reNaraMetaData.cpp:44
modAVUMetadataInp_t::arg1
char * arg1
Definition: modAVUMetadata.h:8