diff --git a/src/XrdCl/XrdClFileOperations.hh b/src/XrdCl/XrdClFileOperations.hh index 0bec146a5bf..ecc5f571cc7 100644 --- a/src/XrdCl/XrdClFileOperations.hh +++ b/src/XrdCl/XrdClFileOperations.hh @@ -1298,8 +1298,6 @@ namespace XrdCl return DelXAttrBulkImpl( file, std::move( attrs ) ); } - // TODO - //---------------------------------------------------------------------------- //! ListXAttr bulk operation (@see FileOperation) //---------------------------------------------------------------------------- diff --git a/src/XrdCl/XrdClFileSystemOperations.hh b/src/XrdCl/XrdClFileSystemOperations.hh index 6f90fea53ae..25c2d909285 100644 --- a/src/XrdCl/XrdClFileSystemOperations.hh +++ b/src/XrdCl/XrdClFileSystemOperations.hh @@ -981,6 +981,556 @@ namespace XrdCl } }; typedef PrepareImpl Prepare; + + //---------------------------------------------------------------------------- + //! SetXAttr operation (@see FileOperation) + //---------------------------------------------------------------------------- + template + class SetXAttrFsImpl: public FileSystemOperation, + Arg, Arg, Arg> + { + public: + + //------------------------------------------------------------------------ + //! Inherit constructors from FileOperation (@see FileOperation) + //------------------------------------------------------------------------ + using FileSystemOperation, Arg, + Arg, Arg>::FileSystemOperation; + + //------------------------------------------------------------------------ + //! Argument indexes in the args tuple + //------------------------------------------------------------------------ + enum { PathArg, NameArg, ValueArg }; + + //------------------------------------------------------------------------ + //! @return : name of the operation (@see Operation) + //------------------------------------------------------------------------ + std::string ToString() + { + return "SetXAttrFsImpl"; + } + + protected: + + //------------------------------------------------------------------------ + //! RunImpl operation (@see Operation) + //! + //! @param params : container with parameters forwarded from + //! previous operation + //! @return : status of the operation + //------------------------------------------------------------------------ + XRootDStatus RunImpl() + { + try + { + std::string path = std::get( this->args ).Get(); + std::string name = std::get( this->args ).Get(); + std::string value = std::get( this->args ).Get(); + // wrap the arguments with a vector + std::vector attrs; + attrs.push_back( xattr_t( std::move( name ), std::move( value ) ) ); + // wrap the PipelineHandler so the response gets unpacked properly + UnpackXAttrStatus *handler = new UnpackXAttrStatus( this->handler.get() ); + XRootDStatus st = this->filesystem->SetXAttr( path, attrs, handler ); + if( !st.IsOK() ) delete handler; + return st; + } + catch( const PipelineException& ex ) + { + return ex.GetError(); + } + catch( const std::exception& ex ) + { + return XRootDStatus( stError, ex.what() ); + } + } + }; + + //---------------------------------------------------------------------------- + //! Factory for creating SetXAttrFsImpl objects (as there is another SetXAttr + //! in File there would be a clash of typenames). + //---------------------------------------------------------------------------- + inline SetXAttrFsImpl SetXAttr( FileSystem *fs, Arg path, + Arg name, Arg value ) + { + return SetXAttrFsImpl( fs, std::move( path ), std::move( name ), + std::move( value ) ); + } + + //---------------------------------------------------------------------------- + //! Factory for creating SetXAttrFsImpl objects (as there is another SetXAttr + //! in File there would be a clash of typenames). + //---------------------------------------------------------------------------- + inline SetXAttrFsImpl SetXAttr( FileSystem &fs, Arg path, + Arg name, Arg value ) + { + return SetXAttrFsImpl( fs, std::move( path ), std::move( name ), + std::move( value ) ); + } + + //---------------------------------------------------------------------------- + //! SetXAttr bulk operation (@see FileOperation) + //---------------------------------------------------------------------------- + template + class SetXAttrFsBulkImpl: public FileSystemOperation>, Arg, Arg>> + { + public: + + //------------------------------------------------------------------------ + //! Inherit constructors from FileOperation (@see FileOperation) + //------------------------------------------------------------------------ + using FileSystemOperation>, + Arg, Arg>>::FileSystemOperation; + + //------------------------------------------------------------------------ + //! Argument indexes in the args tuple + //------------------------------------------------------------------------ + enum { PathArg, AttrsArg }; + + //------------------------------------------------------------------------ + //! @return : name of the operation (@see Operation) + //------------------------------------------------------------------------ + std::string ToString() + { + return "SetXAttrBulkImpl"; + } + + + protected: + + //------------------------------------------------------------------------ + //! RunImpl operation (@see Operation) + //! + //! @return : status of the operation + //------------------------------------------------------------------------ + XRootDStatus RunImpl() + { + try + { + std::string path = std::get( this->args ).Get(); + std::vector attrs = std::get( this->args ).Get(); + return this->filesystem->SetXAttr( path, attrs, this->handler.get() ); + } + catch( const PipelineException& ex ) + { + return ex.GetError(); + } + catch( const std::exception& ex ) + { + return XRootDStatus( stError, ex.what() ); + } + } + }; + + //---------------------------------------------------------------------------- + //! Factory for creating SetXAttrFsBulkImpl objects (as there is another SetXAttr + //! in FileSystem there would be a clash of typenames). + //---------------------------------------------------------------------------- + inline SetXAttrFsBulkImpl SetXAttr( FileSystem *fs, Arg path, + Arg> attrs ) + { + return SetXAttrFsBulkImpl( fs, std::move( path ), std::move( attrs ) ); + } + + //---------------------------------------------------------------------------- + //! Factory for creating SetXAttrFsBulkImpl objects (as there is another SetXAttr + //! in FileSystem there would be a clash of typenames). + //---------------------------------------------------------------------------- + inline SetXAttrFsBulkImpl SetXAttr( FileSystem &fs, Arg path, + Arg> attrs ) + { + return SetXAttrFsBulkImpl( fs, std::move( path ), std::move( attrs ) ); + } + + //---------------------------------------------------------------------------- + //! GetXAttr operation (@see FileOperation) + //---------------------------------------------------------------------------- + template + class GetXAttrFsImpl: public FileSystemOperation, + Arg, Arg> + { + public: + + //------------------------------------------------------------------------ + //! Inherit constructors from FileOperation (@see FileOperation) + //------------------------------------------------------------------------ + using FileSystemOperation, + Arg, Arg>::FileSystemOperation; + + //------------------------------------------------------------------------ + //! Argument indexes in the args tuple + //------------------------------------------------------------------------ + enum { PathArg, NameArg }; + + //------------------------------------------------------------------------ + //! @return : name of the operation (@see Operation) + //------------------------------------------------------------------------ + std::string ToString() + { + return "GetXAttrFsImpl"; + } + + protected: + + //------------------------------------------------------------------------ + //! RunImpl operation (@see Operation) + //! + //! @return : status of the operation + //------------------------------------------------------------------------ + XRootDStatus RunImpl() + { + try + { + std::string path = std::get( this->args ).Get(); + std::string name = std::get( this->args ).Get(); + // wrap the argument with a vector + std::vector attrs; + attrs.push_back( std::move( name ) ); + // wrap the PipelineHandler so the response gets unpacked properly + UnpackXAttr *handler = new UnpackXAttr( this->handler.get() ); + XRootDStatus st = this->filesystem->GetXAttr( path, attrs, handler ); + if( !st.IsOK() ) delete handler; + return st; + } + catch( const PipelineException& ex ) + { + return ex.GetError(); + } + catch( const std::exception& ex ) + { + return XRootDStatus( stError, ex.what() ); + } + } + }; + + //---------------------------------------------------------------------------- + //! Factory for creating GetXAttrFsImpl objects (as there is another GetXAttr + //! in File there would be a clash of typenames). + //---------------------------------------------------------------------------- + inline GetXAttrFsImpl GetXAttr( FileSystem *fs, Arg path, + Arg name ) + { + return GetXAttrFsImpl( fs, std::move( path ), std::move( name ) ); + } + + //---------------------------------------------------------------------------- + //! Factory for creating GetXAttrFsImpl objects (as there is another GetXAttr + //! in File there would be a clash of typenames). + //---------------------------------------------------------------------------- + inline GetXAttrFsImpl GetXAttr( FileSystem &fs, Arg path, + Arg name ) + { + return GetXAttrFsImpl( fs, std::move( path ), std::move( name ) ); + } + + //---------------------------------------------------------------------------- + //! GetXAttr bulk operation (@see FileOperation) + //---------------------------------------------------------------------------- + template + class GetXAttrFsBulkImpl: public FileSystemOperation>, Arg, Arg>> + { + public: + + //------------------------------------------------------------------------ + //! Inherit constructors from FileOperation (@see FileOperation) + //------------------------------------------------------------------------ + using FileSystemOperation>, + Arg, Arg>>::FileSystemOperation; + + //------------------------------------------------------------------------ + //! Argument indexes in the args tuple + //------------------------------------------------------------------------ + enum { PathArg, NamesArg }; + + //------------------------------------------------------------------------ + //! @return : name of the operation (@see Operation) + //------------------------------------------------------------------------ + std::string ToString() + { + return "GetXAttrFsBulkImpl"; + } + + + protected: + + //------------------------------------------------------------------------ + //! RunImpl operation (@see Operation) + //! + //! @return : status of the operation + //------------------------------------------------------------------------ + XRootDStatus RunImpl() + { + try + { + std::string path = std::get( this->args ).Get(); + std::vector attrs = std::get( this->args ).Get(); + return this->filesystem->GetXAttr( path, attrs, this->handler.get() ); + } + catch( const PipelineException& ex ) + { + return ex.GetError(); + } + catch( const std::exception& ex ) + { + return XRootDStatus( stError, ex.what() ); + } + } + }; + + //---------------------------------------------------------------------------- + //! Factory for creating GetXAttrFsBulkImpl objects (as there is another GetXAttr in + //! FileSystem there would be a clash of typenames). + //---------------------------------------------------------------------------- + inline GetXAttrFsBulkImpl GetXAttr( FileSystem *fs, Arg path, + Arg> attrs ) + { + return GetXAttrFsBulkImpl( fs, std::move( path ), std::move( attrs ) ); + } + + //---------------------------------------------------------------------------- + //! Factory for creating GetXAttrFsBulkImpl objects (as there is another GetXAttr in + //! FileSystem there would be a clash of typenames). + //---------------------------------------------------------------------------- + inline GetXAttrFsBulkImpl GetXAttr( FileSystem &fs, Arg path, + Arg> attrs ) + { + return GetXAttrFsBulkImpl( fs, std::move( path ), std::move( attrs ) ); + } + + //---------------------------------------------------------------------------- + //! DelXAttr operation (@see FileOperation) + //---------------------------------------------------------------------------- + template + class DelXAttrFsImpl: public FileSystemOperation, + Arg, Arg> + { + public: + + //------------------------------------------------------------------------ + //! Inherit constructors from FileOperation (@see FileOperation) + //------------------------------------------------------------------------ + using FileSystemOperation, Arg, + Arg>::FileSystemOperation; + + //------------------------------------------------------------------------ + //! Argument indexes in the args tuple + //------------------------------------------------------------------------ + enum { PathArg, NameArg }; + + //------------------------------------------------------------------------ + //! @return : name of the operation (@see Operation) + //------------------------------------------------------------------------ + std::string ToString() + { + return "DelXAttrFsImpl"; + } + + protected: + + //------------------------------------------------------------------------ + //! RunImpl operation (@see Operation) + //! + //! @param params : container with parameters forwarded from + //! previous operation + //! @return : status of the operation + //------------------------------------------------------------------------ + XRootDStatus RunImpl() + { + try + { + std::string path = std::get( this->args ).Get(); + std::string name = std::get( this->args ).Get(); + // wrap the argument with a vector + std::vector attrs; + attrs.push_back( std::move( name ) ); + // wrap the PipelineHandler so the response gets unpacked properly + UnpackXAttrStatus *handler = new UnpackXAttrStatus( this->handler.get() ); + XRootDStatus st = this->filesystem->DelXAttr( path, attrs, handler ); + if( !st.IsOK() ) delete handler; + return st; + } + catch( const PipelineException& ex ) + { + return ex.GetError(); + } + catch( const std::exception& ex ) + { + return XRootDStatus( stError, ex.what() ); + } + } + }; + + //---------------------------------------------------------------------------- + //! Factory for creating DelXAttrFsImpl objects (as there is another DelXAttr + //! in File there would be a clash of typenames). + //---------------------------------------------------------------------------- + inline DelXAttrFsImpl DelXAttr( FileSystem *fs, Arg path, + Arg name ) + { + return DelXAttrFsImpl( fs, std::move( path ), std::move( name ) ); + } + + //---------------------------------------------------------------------------- + //! Factory for creating DelXAttrFsImpl objects (as there is another DelXAttr + //! in File there would be a clash of typenames). + //---------------------------------------------------------------------------- + inline DelXAttrFsImpl DelXAttr( FileSystem &fs, Arg path, + Arg name ) + { + return DelXAttrFsImpl( fs, std::move( path ), std::move( name ) ); + } + + //---------------------------------------------------------------------------- + //! DelXAttr bulk operation (@see FileOperation) + //---------------------------------------------------------------------------- + template + class DelXAttrFsBulkImpl: public FileSystemOperation>, Arg, Arg>> + { + public: + + //------------------------------------------------------------------------ + //! Inherit constructors from FileOperation (@see FileOperation) + //------------------------------------------------------------------------ + using FileSystemOperation>, + Arg, Arg>>::FileSystemOperation; + + //------------------------------------------------------------------------ + //! Argument indexes in the args tuple + //------------------------------------------------------------------------ + enum { PathArg, NamesArg }; + + //------------------------------------------------------------------------ + //! @return : name of the operation (@see Operation) + //------------------------------------------------------------------------ + std::string ToString() + { + return "DelXAttrBulkImpl"; + } + + + protected: + + //------------------------------------------------------------------------ + //! RunImpl operation (@see Operation) + //! + //! @param params : container with parameters forwarded from + //! previous operation + //! @return : status of the operation + //------------------------------------------------------------------------ + XRootDStatus RunImpl() + { + try + { + std::string path = std::get( this->args ).Get(); + std::vector attrs = std::get( this->args ).Get(); + return this->filesystem->DelXAttr( path, attrs, this->handler.get() ); + } + catch( const PipelineException& ex ) + { + return ex.GetError(); + } + catch( const std::exception& ex ) + { + return XRootDStatus( stError, ex.what() ); + } + } + }; + + //---------------------------------------------------------------------------- + //! Factory for creating DelXAttrFsBulkImpl objects (as there is another DelXAttr + //! in FileSystem there would be a clash of typenames). + //---------------------------------------------------------------------------- + inline DelXAttrFsBulkImpl DelXAttr( FileSystem *fs, Arg path, + Arg> attrs ) + { + return DelXAttrFsBulkImpl( fs, std::move( path ), std::move( attrs ) ); + } + + //---------------------------------------------------------------------------- + //! Factory for creating DelXAttrFsBulkImpl objects (as there is another DelXAttr + //! in FileSystem there would be a clash of typenames). + //---------------------------------------------------------------------------- + inline DelXAttrFsBulkImpl DelXAttr( FileSystem &fs, Arg path, + Arg> attrs ) + { + return DelXAttrFsBulkImpl( fs, std::move( path ), std::move( attrs ) ); + } + + //---------------------------------------------------------------------------- + //! ListXAttr bulk operation (@see FileOperation) + //---------------------------------------------------------------------------- + template + class ListXAttrFsImpl: public FileSystemOperation>, Arg> + { + public: + + //------------------------------------------------------------------------ + //! Inherit constructors from FileOperation (@see FileOperation) + //------------------------------------------------------------------------ + using FileSystemOperation>, + Arg>::FileSystemOperation; + + //------------------------------------------------------------------------ + //! Argument indexes in the args tuple + //------------------------------------------------------------------------ + enum { PathArg }; + + //------------------------------------------------------------------------ + //! @return : name of the operation (@see Operation) + //------------------------------------------------------------------------ + std::string ToString() + { + return "ListXAttrFsImpl"; + } + + protected: + + //------------------------------------------------------------------------ + //! RunImpl operation (@see Operation) + //! + //! @param params : container with parameters forwarded from + //! previous operation + //! @return : status of the operation + //------------------------------------------------------------------------ + XRootDStatus RunImpl() + { + try + { + std::string path = std::get( this->args ).Get(); + return this->filesystem->ListXAttr( path, this->handler.get() ); + } + catch( const PipelineException& ex ) + { + return ex.GetError(); + } + catch( const std::exception& ex ) + { + return XRootDStatus( stError, ex.what() ); + } + } + }; + + //---------------------------------------------------------------------------- + //! Factory for creating ListXAttrFsImpl objects (as there is another ListXAttr + //! in FileSystem there would be a clash of typenames). + //---------------------------------------------------------------------------- + inline ListXAttrFsImpl ListXAttr( FileSystem *fs, Arg path ) + { + return ListXAttrFsImpl( fs, std::move( path ) ); + } + + //---------------------------------------------------------------------------- + //! Factory for creating ListXAttrFsImpl objects (as there is another ListXAttr + //! in FileSystem there would be a clash of typenames). + //---------------------------------------------------------------------------- + inline ListXAttrFsImpl ListXAttr( FileSystem &fs, Arg path ) + { + return ListXAttrFsImpl( fs, std::move( path ) ); + } } #endif // __XRD_CL_FILE_SYSTEM_OPERATIONS_HH__