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)  

fileDriver.cpp
Go to the documentation of this file.
1 
4 /* fileDriver.c - The general driver for all file types. */
5 
6 #include "fileDriver.hpp"
7 #include "irods_log.hpp"
9 #include "irods_data_object.hpp"
10 #include "irods_stacktrace.hpp"
11 
14 
15 // =-=-=-=-=-=-=-
16 // Top Level Interface for Resource Plugin POSIX create
18  rsComm_t* _comm,
20  // =-=-=-=-=-=-=-
21  // retrieve the resource name given the object
24  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
25  if ( !ret_err.ok() ) {
26  irods::log( ret_err );
27  return PASSMSG( "failed to resolve resource", ret_err );
28  }
29 
30  // =-=-=-=-=-=-=-
31  // make the call to the "create" interface
32  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
33  ret_err = resc->call( _comm, irods::RESOURCE_OP_CREATE, _object );
34 
35  // =-=-=-=-=-=-=-
36  // pass along an error from the interface or return SUCCESS
37  if ( !ret_err.ok() ) {
38  return PASSMSG( "failed to call 'create'", ret_err );
39  }
40  else {
41  return CODE( ret_err.code() );
42  }
43 
44 
45 } // fileCreate
46 
47 // =-=-=-=-=-=-=-
48 // Top Level Interface for Resource Plugin POSIX open
50  rsComm_t* _comm,
52  // =-=-=-=-=-=-=-
53  // retrieve the resource name given the object
56  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
57  if ( !ret_err.ok() ) {
58  return PASSMSG( "failed to resolve resource", ret_err );
59  }
60 
61  // =-=-=-=-=-=-=-
62  // make the call to the "open" interface
63  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
64  ret_err = resc->call( _comm, irods::RESOURCE_OP_OPEN, _object );
65 
66  // =-=-=-=-=-=-=-
67  // pass along an error from the interface or return SUCCESS
68  if ( !ret_err.ok() ) {
69  return PASSMSG( "failed to call 'open'", ret_err );
70 
71  }
72  else {
73  return CODE( ret_err.code() );
74 
75  }
76 
77 } // fileOpen
78 
79 // =-=-=-=-=-=-=-
80 // Top Level Interface for Resource Plugin POSIX read
82  rsComm_t* _comm,
84  void* _buf,
85  int _len ) {
86  // =-=-=-=-=-=-=-
87  // retrieve the resource name given the object
90  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
91  if ( !ret_err.ok() ) {
92  return PASSMSG( "failed to resolve resource", ret_err );
93  }
94 
95  // =-=-=-=-=-=-=-
96  // make the call to the "read" interface
97  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
98  ret_err = resc->call< void*, int >( _comm, irods::RESOURCE_OP_READ, _object, _buf, _len );
99 
100  // =-=-=-=-=-=-=-
101  // pass along an error from the interface or return SUCCESS
102  if ( !ret_err.ok() ) {
103  return PASSMSG( "failed to call 'read'", ret_err );
104  }
105  else {
106  return CODE( ret_err.code() );
107  }
108 
109 } // fileRead
110 
111 // =-=-=-=-=-=-=-
112 // Top Level Interface for Resource Plugin POSIX write
114  rsComm_t* _comm,
116  void* _buf,
117  int _len ) {
118  // =-=-=-=-=-=-=-
119  // retrieve the resource name given the object
120  irods::plugin_ptr ptr;
121  irods::resource_ptr resc;
122  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
123  if ( !ret_err.ok() ) {
124  return PASSMSG( "failed to resolve resource", ret_err );
125  }
126 
127  // =-=-=-=-=-=-=-
128  // make the call to the "write" interface
129  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
130  ret_err = resc->call< void*, int >( _comm, irods::RESOURCE_OP_WRITE, _object, _buf, _len );
131 
132  // =-=-=-=-=-=-=-
133  // pass along an error from the interface or return SUCCESS
134  if ( !ret_err.ok() ) {
135  return PASSMSG( "failed to call 'write'", ret_err );
136  }
137  else {
138  std::stringstream msg;
139  msg << "Write successful.";
140  return PASSMSG( msg.str(), ret_err );
141  }
142 
143 } // fileWrite
144 
145 // =-=-=-=-=-=-=-
146 // Top Level Interface for Resource Plugin POSIX close
148  rsComm_t* _comm,
150  // =-=-=-=-=-=-=-
151  // retrieve the resource name given the path
152  irods::plugin_ptr ptr;
153  irods::resource_ptr resc;
154  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
155  if ( !ret_err.ok() ) {
156  return PASSMSG( "failed to resolve resource", ret_err );
157  }
158 
159  // =-=-=-=-=-=-=-
160  // make the call to the "close" interface
161  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
162  ret_err = resc->call( _comm, irods::RESOURCE_OP_CLOSE, _object );
163 
164  // =-=-=-=-=-=-=-
165  // pass along an error from the interface or return SUCCESS
166  if ( !ret_err.ok() ) {
167  return PASSMSG( "failed to call 'close'", ret_err );
168  }
169  else {
170  return CODE( ret_err.code() );
171  }
172 
173 } // fileClose
174 
175 // =-=-=-=-=-=-=-
176 // Top Level Interface for Resource Plugin POSIX unlink
178  rsComm_t* _comm,
180  // =-=-=-=-=-=-=-
181  // retrieve the resource name given the path
182  irods::plugin_ptr ptr;
183  irods::resource_ptr resc;
184  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
185  if ( !ret_err.ok() ) {
186  return PASSMSG( "failed to resolve resource", ret_err );
187  }
188 
189  // =-=-=-=-=-=-=-
190  // make the call to the "unlink" interface
191  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
192  ret_err = resc->call( _comm, irods::RESOURCE_OP_UNLINK, _object );
193 
194  // =-=-=-=-=-=-=-
195  // pass along an error from the interface or return SUCCESS
196  if ( !ret_err.ok() ) {
197  return PASSMSG( "failed to call 'unlink'", ret_err );
198  }
199  else {
200  return CODE( ret_err.code() );
201  }
202 
203 } // fileUnlink
204 
205 // =-=-=-=-=-=-=-
206 // Top Level Interface for Resource Plugin POSIX stat
208  rsComm_t* _comm,
210  struct stat* _statbuf ) {
211  // =-=-=-=-=-=-=-
212  // retrieve the resource name given the path
213  irods::plugin_ptr ptr;
214  irods::resource_ptr resc;
215  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
216  if ( !ret_err.ok() ) {
217  return PASSMSG( "failed to resolve resource", ret_err );
218  }
219 
220  // =-=-=-=-=-=-=-
221  // make the call to the "stat" interface
222  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
223  ret_err = resc->call< struct stat* >( _comm, irods::RESOURCE_OP_STAT, _object, _statbuf );
224 
225  // =-=-=-=-=-=-=-
226  // pass along an error from the interface or return SUCCESS
227  if ( !ret_err.ok() ) {
228  return PASSMSG( "failed to call 'stat'", ret_err );
229  }
230  else {
231  return CODE( ret_err.code() );
232  }
233 
234 } // fileStat
235 
236 // =-=-=-=-=-=-=-
237 // Top Level Interface for Resource Plugin POSIX lseek
239  rsComm_t* _comm,
241  long long _offset,
242  int _whence ) {
243  // =-=-=-=-=-=-=-
244  // retrieve the resource name given the path
245  irods::plugin_ptr ptr;
246  irods::resource_ptr resc;
247  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
248  if ( !ret_err.ok() ) {
249  return PASSMSG( "failed to resolve resource", ret_err );
250  }
251 
252  // =-=-=-=-=-=-=-
253  // make the call to the "lseek" interface
254  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
255  ret_err = resc->call< long long, int >( _comm, irods::RESOURCE_OP_LSEEK, _object, _offset, _whence );
256 
257  // =-=-=-=-=-=-=-
258  // pass along an error from the interface or return SUCCESS
259  if ( !ret_err.ok() ) {
260  return PASSMSG( "failed to call 'lseek'", ret_err );
261  }
262  else {
263  return CODE( ret_err.code() );
264  }
265 
266 } // fileLseek
267 
268 // =-=-=-=-=-=-=-
269 // Top Level Interface for Resource Plugin POSIX mkdir
271  rsComm_t* _comm,
273  // =-=-=-=-=-=-=-
274  // retrieve the resource name given the path
275  irods::plugin_ptr ptr;
276  irods::resource_ptr resc;
277  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
278  if ( !ret_err.ok() ) {
279  return PASSMSG( "failed to resolve resource", ret_err );
280  }
281 
282  // =-=-=-=-=-=-=-
283  // make the call to the "mkdir" interface
284  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
285  ret_err = resc->call( _comm, irods::RESOURCE_OP_MKDIR, _object );
286 
287  // =-=-=-=-=-=-=-
288  // pass along an error from the interface or return SUCCESS
289  if ( !ret_err.ok() ) {
290  return PASSMSG( "failed to call 'mkdir'", ret_err );
291  }
292  else {
293  return CODE( ret_err.code() );
294  }
295 
296 } // fileMkdir
297 
298 
299 // =-=-=-=-=-=-=-
300 // Top Level Interface for Resource Plugin POSIX chmod
302  rsComm_t* _comm,
304  int _mode ) {
305  // =-=-=-=-=-=-=-
306  // retrieve the resource name given the path
307  irods::plugin_ptr ptr;
308  irods::resource_ptr resc;
309  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
310  if ( !ret_err.ok() ) {
311  return PASSMSG( "failed to resolve resource", ret_err );
312  }
313 
314  // =-=-=-=-=-=-=-
315  // make the call to the "chmod" interface
316  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
317  ret_err = resc->call( _comm, irods::RESOURCE_OP_CHMOD, _object, _mode );
318 
319  // =-=-=-=-=-=-=-
320  // pass along an error from the interface or return SUCCESS
321  if ( !ret_err.ok() ) {
322  return PASSMSG( "failed to call 'chmod'", ret_err );
323  }
324  else {
325  return CODE( ret_err.code() );
326  }
327 
328 } // fileChmod
329 
330 // =-=-=-=-=-=-=-
331 // Top Level Interface for Resource Plugin POSIX rmdir
333  rsComm_t* _comm,
335  // =-=-=-=-=-=-=-
336  // retrieve the resource name given the path
337  irods::plugin_ptr ptr;
338  irods::resource_ptr resc;
339  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
340  if ( !ret_err.ok() ) {
341  return PASSMSG( "failed to resolve resource", ret_err );
342  }
343 
344  // =-=-=-=-=-=-=-
345  // make the call to the "rmdir" interface
346  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
347  ret_err = resc->call( _comm, irods::RESOURCE_OP_RMDIR, _object );
348 
349  // =-=-=-=-=-=-=-
350  // pass along an error from the interface or return SUCCESS
351  if ( !ret_err.ok() ) {
352  return PASSMSG( "failed to call 'rmdir'", ret_err );
353  }
354  else {
355  return CODE( ret_err.code() );
356  }
357 
358 } // fileRmdir
359 
360 // =-=-=-=-=-=-=-
361 // Top Level Interface for Resource Plugin POSIX opendir
363  rsComm_t* _comm,
365  // =-=-=-=-=-=-=-
366  // retrieve the resource name given the path
367  irods::plugin_ptr ptr;
368  irods::resource_ptr resc;
369  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
370  if ( !ret_err.ok() ) {
371  return PASSMSG( "failed to resolve resource", ret_err );
372  }
373 
374  // =-=-=-=-=-=-=-
375  // make the call to the "opendir" interface
376  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
377  ret_err = resc->call( _comm, irods::RESOURCE_OP_OPENDIR, _object );
378 
379  // =-=-=-=-=-=-=-
380  // pass along an error from the interface or return SUCCESS
381  if ( !ret_err.ok() ) {
382  return PASSMSG( "failed to call 'opendir'", ret_err );
383  }
384  else {
385  return CODE( ret_err.code() );
386  }
387 
388 } // fileOpendir
389 
390 // =-=-=-=-=-=-=-
391 // Top Level Interface for Resource Plugin POSIX closedir
393  rsComm_t* _comm,
395  // =-=-=-=-=-=-=-
396  // retrieve the resource name given the path
397  irods::plugin_ptr ptr;
398  irods::resource_ptr resc;
399  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
400  if ( !ret_err.ok() ) {
401  return PASSMSG( "failed to resolve resource", ret_err );
402  }
403 
404  // =-=-=-=-=-=-=-
405  // make the call to the "closedir" interface
406  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
407  ret_err = resc->call( _comm, irods::RESOURCE_OP_CLOSEDIR, _object );
408 
409  // =-=-=-=-=-=-=-
410  // pass along an error from the interface or return SUCCESS
411  if ( !ret_err.ok() ) {
412  return PASSMSG( "failed to call 'closedir'", ret_err );
413  }
414  else {
415  return CODE( ret_err.code() );
416  }
417 
418 } // fileClosedir
419 
420 // =-=-=-=-=-=-=-
421 // Top Level Interface for Resource Plugin POSIX readdir
423  rsComm_t* _comm,
425  struct rodsDirent** _dirent_ptr ) {
426  // =-=-=-=-=-=-=-
427  // retrieve the resource name given the path
428  irods::plugin_ptr ptr;
429  irods::resource_ptr resc;
430  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
431  if ( !ret_err.ok() ) {
432  return PASSMSG( "failed to resolve resource", ret_err );
433  }
434 
435  // =-=-=-=-=-=-=-
436  // make the call to the "readdir" interface
437  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
438  ret_err = resc->call< struct rodsDirent** >( _comm, irods::RESOURCE_OP_READDIR, _object, _dirent_ptr );
439 
440  // =-=-=-=-=-=-=-
441  // pass along an error from the interface or return SUCCESS
442  if ( !ret_err.ok() ) {
443  return PASSMSG( "failed to call 'readdir'", ret_err );
444  }
445  else {
446  return CODE( ret_err.code() );
447  }
448 
449 } // fileReaddir
450 
451 // =-=-=-=-=-=-=-
452 // Top Level Interface for Resource Plugin POSIX rename
454  rsComm_t* _comm,
456  const std::string& _new_file_name ) {
457  // =-=-=-=-=-=-=-
458  // retrieve the resource name given the path
459  irods::plugin_ptr ptr;
460  irods::resource_ptr resc;
461  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
462  if ( !ret_err.ok() ) {
463  return PASSMSG( "failed to resolve resource", ret_err );
464  }
465 
466  // =-=-=-=-=-=-=-
467  // make the call to the "rename" interface
468  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
469  ret_err = resc->call< const char* >( _comm, irods::RESOURCE_OP_RENAME, _object, _new_file_name.c_str() );
470 
471  // =-=-=-=-=-=-=-
472  // pass along an error from the interface or return SUCCESS
473  if ( !ret_err.ok() ) {
474  return PASSMSG( "failed to call 'rename'", ret_err );
475  }
476  else {
477  return CODE( ret_err.code() );
478  }
479 
480 } // fileRename
481 
482 // =-=-=-=-=-=-=-
483 // Top Level Interface for Resource Plugin freespace
485  rsComm_t* _comm,
487  // =-=-=-=-=-=-=-
488  // retrieve the resource name given the path
489  irods::plugin_ptr ptr;
490  irods::resource_ptr resc;
491  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
492  if ( !ret_err.ok() ) {
493  return PASSMSG( "failed to resolve resource", ret_err );
494  }
495 
496  // =-=-=-=-=-=-=-
497  // make the call to the "freespace" interface
498  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
499  ret_err = resc->call( _comm, irods::RESOURCE_OP_FREESPACE, _object );
500 
501  // =-=-=-=-=-=-=-
502  // pass along an error from the interface or return SUCCESS
503  if ( !ret_err.ok() ) {
504  return PASSMSG( "failed to call 'stage'", ret_err );
505  }
506  else {
507  return CODE( ret_err.code() );
508  }
509 
510 } // fileGetFsFreeSpace
511 
512 // =-=-=-=-=-=-=-
513 // Top Level Interface for Resource Plugin truncate
515  rsComm_t* _comm,
517  // =-=-=-=-=-=-=-
518  // retrieve the resource name given the path
519  irods::plugin_ptr ptr;
520  irods::resource_ptr resc;
521  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
522  if ( !ret_err.ok() ) {
523  return PASSMSG( "failed to resolve resource", ret_err );
524  }
525 
526  // =-=-=-=-=-=-=-
527  // make the call to the "truncate" interface
528  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
529  ret_err = resc->call( _comm, irods::RESOURCE_OP_TRUNCATE, _object );
530 
531  // =-=-=-=-=-=-=-
532  // pass along an error from the interface or return SUCCESS
533  if ( !ret_err.ok() ) {
534  return PASSMSG( "failed to call 'truncate'", ret_err );
535  }
536  else {
537  return CODE( ret_err.code() );
538  }
539 
540 } // fileTruncate
541 
542 // =-=-=-=-=-=-=-
543 // Top Level Interface for Resource Plugin StageToCache
545  rsComm_t* _comm,
547  const std::string& _cache_file_name ) {
548  // =-=-=-=-=-=-=-
549  // trap empty file name
550  if ( _cache_file_name.empty() ) {
551  irods::error ret_err = ERROR( SYS_INVALID_INPUT_PARAM, "fileStageToCache - File Name is Empty." );
552  irods::log( ret_err );
553  return ret_err;
554  }
555 
556  // =-=-=-=-=-=-=-
557  // retrieve the resource name given the path
558  irods::plugin_ptr ptr;
559  irods::resource_ptr resc;
560  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
561  if ( !ret_err.ok() ) {
562  return PASSMSG( "failed to resolve resource", ret_err );
563  }
564 
565  // =-=-=-=-=-=-=-
566  // make the call to the "stagetocache" interface
567  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
568  ret_err = resc->call< const char* >( _comm, irods::RESOURCE_OP_STAGETOCACHE, _object, _cache_file_name.c_str() );
569 
570  // =-=-=-=-=-=-=-
571  // pass along an error from the interface or return SUCCESS
572  if ( !ret_err.ok() ) {
573  return PASSMSG( "failed to call 'stagetocache'", ret_err );
574  }
575  else {
576  return SUCCESS();
577  }
578 
579 } // fileStageToCache
580 
581 // =-=-=-=-=-=-=-
582 // Top Level Interface for Resource Plugin SyncToArch
584  rsComm_t* _comm,
586  const std::string& _cache_file_name ) {
587  // =-=-=-=-=-=-=-
588  // trap empty file name
589  if ( _cache_file_name.empty() ) {
590  irods::error ret_err = ERROR( SYS_INVALID_INPUT_PARAM, "fileSyncToArch - File Name is Empty." );
591  irods::log( ret_err );
592  return ret_err;
593  }
594 
595  // =-=-=-=-=-=-=-
596  // retrieve the resource name given the path
597  irods::plugin_ptr ptr;
598  irods::resource_ptr resc;
599  irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
600  if ( !ret_err.ok() ) {
601  return PASSMSG( "failed to resolve resource", ret_err );
602  }
603 
604  // =-=-=-=-=-=-=-
605  // make the call to the "synctoarch" interface
606  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
607  ret_err = resc->call< const char* >( _comm, irods::RESOURCE_OP_SYNCTOARCH, _object, _cache_file_name.c_str() );
608 
609  // =-=-=-=-=-=-=-
610  // pass along an error from the interface or return SUCCESS
611  if ( !ret_err.ok() ) {
612  return PASSMSG( "failed to call 'synctoarch'", ret_err );
613  }
614  else {
615  return SUCCESS();
616  }
617 
618 } // fileSyncToArch
619 
620 // =-=-=-=-=-=-=-
621 // File registered with the database
623  rsComm_t* _comm,
625  irods::error result = SUCCESS();
626  irods::error ret;
627  // =-=-=-=-=-=-=-
628  // retrieve the resource name given the object
629  irods::plugin_ptr ptr;
630  irods::resource_ptr resc;
631  ret = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
632  if ( !ret.ok() ) {
633  std::stringstream msg;
634  msg << __FUNCTION__;
635  msg << " - Failed to resolve resource.";
636  result = PASSMSG( msg.str(), ret );
637 
638  }
639  else {
640  // =-=-=-=-=-=-=-
641  // make the call to the "registered" interface
642  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
643  ret = resc->call( _comm, irods::RESOURCE_OP_REGISTERED, _object );
644  if ( !ret.ok() ) {
645  std::stringstream msg;
646  msg << __FUNCTION__;
647  msg << " - Failed to call registered interface.";
648  result = PASSMSG( msg.str(), ret );
649  }
650  }
651 
652  return result;
653 } // fileRegistered
654 
655 // =-=-=-=-=-=-=-
656 // File unregistered with the database
658  rsComm_t* _comm,
660  irods::error result = SUCCESS();
661  irods::error ret;
662  // =-=-=-=-=-=-=-
663  // retrieve the resource name given the object
664  irods::plugin_ptr ptr;
665  irods::resource_ptr resc;
666  ret = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
667  if ( !ret.ok() ) {
668  std::stringstream msg;
669  msg << __FUNCTION__;
670  msg << " - Failed to resolve resource.";
671  result = PASSMSG( msg.str(), ret );
672  }
673  else {
674 
675  // =-=-=-=-=-=-=-
676  // make the call to the "open" interface
677  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
678  ret = resc->call( _comm, irods::RESOURCE_OP_UNREGISTERED, _object );
679  if ( !ret.ok() ) {
680  std::stringstream msg;
681  msg << __FUNCTION__;
682  msg << " - Failed to call unregistered interface.";
683  result = PASSMSG( msg.str(), ret );
684  }
685  }
686 
687  return result;
688 } // fileUnregistered
689 
690 // =-=-=-=-=-=-=-
691 // File modified with the database
693  rsComm_t* _comm,
695  irods::error result = SUCCESS();
696  irods::error ret;
697  // =-=-=-=-=-=-=-
698  // downcast - this must be called on a descendant of data object
699  irods::data_object_ptr data_obj = boost::dynamic_pointer_cast< irods::data_object >( _object );
700  std::string resc_hier = data_obj->resc_hier();
701  if ( !resc_hier.empty() ) {
702  // =-=-=-=-=-=-=-
703  // retrieve the resource name given the object
704  irods::plugin_ptr ptr;
705  irods::resource_ptr resc;
706  ret = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
707  if ( !ret.ok() ) {
708  std::stringstream msg;
709  msg << __FUNCTION__;
710  msg << " - Failed to resolve resource.";
711  result = PASSMSG( msg.str(), ret );
712  }
713  else {
714 
715  // =-=-=-=-=-=-=-
716  // make the call to the "modified" interface
717  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
718  ret = resc->call( _comm, irods::RESOURCE_OP_MODIFIED, _object );
719  if ( !ret.ok() ) {
720  std::stringstream msg;
721  msg << __FUNCTION__;
722  msg << " - Failed to call modified interface.";
723  result = PASSMSG( msg.str(), ret );
724  }
725  }
726  }
727  else {
728  // NOOP okay for struct file objects
729  }
730 
731  return result;
732 
733 } // fileModified
734 
735 // =-=-=-=-=-=-=-
736 // File modified with the database
738  rsComm_t* _comm,
740  const std::string& _operation ) {
741  irods::error result = SUCCESS();
742  irods::error ret;
743  // =-=-=-=-=-=-=-
744  // downcast - this must be called on a descendant of data object
745  irods::data_object_ptr data_obj = boost::dynamic_pointer_cast< irods::data_object >( _object );
746  std::string resc_hier = data_obj->resc_hier();
747  if ( !resc_hier.empty() ) {
748  // =-=-=-=-=-=-=-
749  // retrieve the resource name given the object
750  irods::plugin_ptr ptr;
751  irods::resource_ptr resc;
752  ret = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
753  if ( !ret.ok() ) {
754  std::stringstream msg;
755  msg << "Failed to resolve resource.";
756  result = PASSMSG( msg.str(), ret );
757  }
758  else {
759 
760  // =-=-=-=-=-=-=-
761  // make the call to the "open" interface
762  resc = boost::dynamic_pointer_cast< irods::resource >( ptr );
763  ret = resc->call< const std::string* >(
764  _comm,
766  _object,
767  &_operation );
768  if ( !ret.ok() ) {
769  std::stringstream msg;
770  msg << "Failed to call notify interface.";
771  result = PASSMSG( msg.str(), ret );
772  }
773  }
774  }
775  else {
776  // NOOP okay for struct file objects
777  }
778 
779  return result;
780 
781 } // fileNotify
irods::plugin_ptr
boost::shared_ptr< plugin_base > plugin_ptr
Definition: irods_first_class_object.hpp:18
fileClose
irods::error fileClose(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:147
rsComm_t
Definition: rcConnect.h:145
fileLseek
irods::error fileLseek(rsComm_t *_comm, irods::first_class_object_ptr _object, long long _offset, int _whence)
Definition: fileDriver.cpp:238
fileRegistered
irods::error fileRegistered(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:622
fileTruncate
irods::error fileTruncate(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:514
irods::RESOURCE_OP_STAT
const std::string RESOURCE_OP_STAT("resource_stat")
fileNotify
irods::error fileNotify(rsComm_t *_comm, irods::first_class_object_ptr _object, const std::string &_operation)
Definition: fileDriver.cpp:737
irods::RESOURCE_OP_MODIFIED
const std::string RESOURCE_OP_MODIFIED("resource_modified")
irods::RESOURCE_OP_CLOSEDIR
const std::string RESOURCE_OP_CLOSEDIR("resource_closedir")
irods_stacktrace.hpp
irods::data_object_ptr
boost::shared_ptr< data_object > data_object_ptr
Definition: irods_data_object.hpp:17
irods::resource_ptr
boost::shared_ptr< resource > resource_ptr
Definition: irods_resource_types.hpp:11
irods_data_object.hpp
irods::RESOURCE_OP_READDIR
const std::string RESOURCE_OP_READDIR("resource_readdir")
irods::RESOURCE_OP_READ
const std::string RESOURCE_OP_READ("resource_read")
irods::RESOURCE_OP_FREESPACE
const std::string RESOURCE_OP_FREESPACE("resource_freespace")
irods::RESOURCE_OP_LSEEK
const std::string RESOURCE_OP_LSEEK("resource_lseek")
PASSMSG
#define PASSMSG(message_, prev_error_)
Definition: irods_error.hpp:119
fileClosedir
irods::error fileClosedir(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:392
fileDriver.hpp
fileGetFsFreeSpace
irods::error fileGetFsFreeSpace(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:484
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
fileUnlink
irods::error fileUnlink(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:177
irods_resource_plugin.hpp
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
fileUnregistered
irods::error fileUnregistered(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:657
irods::RESOURCE_OP_TRUNCATE
const std::string RESOURCE_OP_TRUNCATE("resource_truncate")
irods::RESOURCE_OP_RENAME
const std::string RESOURCE_OP_RENAME("resource_rename")
fileMkdir
irods::error fileMkdir(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:270
irods::error::code
long long code() const
Definition: irods_error.cpp:194
irods::first_class_object_ptr
boost::shared_ptr< first_class_object > first_class_object_ptr
Definition: irods_first_class_object.hpp:47
irods.pypyodbc.long
long
Definition: pypyodbc.py:43
fileStat
irods::error fileStat(rsComm_t *_comm, irods::first_class_object_ptr _object, struct stat *_statbuf)
Definition: fileDriver.cpp:207
irods_resource_constants.hpp
fileOpendir
irods::error fileOpendir(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:362
fileRead
irods::error fileRead(rsComm_t *_comm, irods::first_class_object_ptr _object, void *_buf, int _len)
Definition: fileDriver.cpp:81
irods::RESOURCE_OP_CREATE
const std::string RESOURCE_OP_CREATE("resource_create")
irods::RESOURCE_OP_NOTIFY
const std::string RESOURCE_OP_NOTIFY("resource_notify")
irods::RESOURCE_INTERFACE
const std::string RESOURCE_INTERFACE("irods_resource_interface")
irods::RESOURCE_OP_WRITE
const std::string RESOURCE_OP_WRITE("resource_write")
fileRmdir
irods::error fileRmdir(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:332
irods::RESOURCE_OP_CHMOD
const std::string RESOURCE_OP_CHMOD("resource_chmod")
fileCreate
irods::error fileCreate(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:17
irods::RESOURCE_OP_CLOSE
const std::string RESOURCE_OP_CLOSE("resource_close")
irods::log
void log(const error &)
Definition: irods_log.cpp:13
rodsDirent
Definition: rodsType.h:70
irods::RESOURCE_OP_UNLINK
const std::string RESOURCE_OP_UNLINK("resource_unlink")
irods::RESOURCE_OP_RMDIR
const std::string RESOURCE_OP_RMDIR("resource_rmdir")
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::RESOURCE_OP_UNREGISTERED
const std::string RESOURCE_OP_UNREGISTERED("resource_unregistered")
irods::error
Definition: irods_error.hpp:23
fileRename
irods::error fileRename(rsComm_t *_comm, irods::first_class_object_ptr _object, const std::string &_new_file_name)
Definition: fileDriver.cpp:453
irods::RESOURCE_OP_REGISTERED
const std::string RESOURCE_OP_REGISTERED("resource_registered")
irods::RESOURCE_OP_MKDIR
const std::string RESOURCE_OP_MKDIR("resource_mkdir")
irods::RESOURCE_OP_OPENDIR
const std::string RESOURCE_OP_OPENDIR("resource_opendir")
irods::RESOURCE_OP_STAGETOCACHE
const std::string RESOURCE_OP_STAGETOCACHE("resource_stagetocache")
fileModified
irods::error fileModified(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:692
fileSyncToArch
irods::error fileSyncToArch(rsComm_t *_comm, irods::first_class_object_ptr _object, const std::string &_cache_file_name)
Definition: fileDriver.cpp:583
irods_resource_manager.hpp
irods::RESOURCE_OP_SYNCTOARCH
const std::string RESOURCE_OP_SYNCTOARCH("resource_synctoarch")
fileStageToCache
irods::error fileStageToCache(rsComm_t *_comm, irods::first_class_object_ptr _object, const std::string &_cache_file_name)
Definition: fileDriver.cpp:544
fileChmod
irods::error fileChmod(rsComm_t *_comm, irods::first_class_object_ptr _object, int _mode)
Definition: fileDriver.cpp:301
fileWrite
irods::error fileWrite(rsComm_t *_comm, irods::first_class_object_ptr _object, void *_buf, int _len)
Definition: fileDriver.cpp:113
fileOpen
irods::error fileOpen(rsComm_t *_comm, irods::first_class_object_ptr _object)
Definition: fileDriver.cpp:49
fileReaddir
irods::error fileReaddir(rsComm_t *_comm, irods::first_class_object_ptr _object, struct rodsDirent **_dirent_ptr)
Definition: fileDriver.cpp:422
CODE
#define CODE(code_)
Definition: irods_error.hpp:120
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irods::RESOURCE_OP_OPEN
const std::string RESOURCE_OP_OPEN("resource_open")
irods_log.hpp