private ResourceMeta filter ( Path path , ResourceMeta resourceMeta , Operation op ) { ResourceMetaBuilder resourceMetaBuilder = StorageUtil . create ( new HashMap < String , String > ( resourceMeta . getMeta ( ) ) ) ; final HasInputStream result ; switch ( op ) { case READ : case UPDATE : case CREATE : try { if ( op == Operation . CREATE ) { result = plugin . createResource ( path , resourceMetaBuilder , resourceMeta ) ; } else if ( op == Operation . READ ) { result = plugin . readResource ( path , resourceMetaBuilder , resourceMeta ) ; } else { result = plugin . updateResource ( path , resourceMetaBuilder , resourceMeta ) ; } } catch ( Throwable e ) { throw new StorageException ( "Converter Plugin " + providerName + " threw exception during " + op + ": " + e . getMessage ( ) , e , StorageException . Event . valueOf ( op . toString ( ) ) , path ) ; } break ; default : throw new IllegalStateException ( ) ; } logger . debug ( "Plugin(" + providerName + "):" + op + ":" + path + ";" + ( null == result ? "_" : "+" ) + ":" + resourceMetaBuilder . getResourceMeta ( ) ) ; //construct the new data return StorageUtil . withStream ( null == result ? resourceMeta : result , resourceMetaBuilder . getResourceMeta ( ) ) ; }
perform appropriate plugin filter method based on the operation enacted