Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ReplicaMetadataCatalog.h

Go to the documentation of this file.
00001 /* -*- C++ -*-
00002  *
00003  * MetadataCatalog.cpp
00004  *
00005  * Copyright (c) 2002 CERN on behalf of the EU DataGrid.
00006  * For license conditions see LICENSE file or 
00007  * http://www.edg.org/license.html
00008  * 
00009  */
00010 
00011 
00012 #ifndef MetadataCatalog_H
00013 #define MetadataCatalog_H 1
00014 
00015 #include <string>
00016 #include <set>
00017 #include <map>
00018 #include <vector>
00019 
00020 #include "EdgReplicaMetadataCatalog/ReplicationExceptions.h"
00021 
00022 namespace EdgReplicaMetadataCatalog
00023 {
00024   
00032   struct ColumnSizes
00033   {
00034     int guidColSize;
00035     int aliasColSize;
00036     int attDefNameColSize;
00037   };
00038   
00039   struct AttributeDefinition
00040   {
00041     AttributeDefinition( const std::string& name, const std::string& type )
00042       : m_name( name ), m_type( type )
00043     {
00044     }
00045     
00046     std::string m_name;
00047     std::string m_type;
00048   };
00049   
00050   struct Mapping
00051   {
00052     Mapping(const std::string& guid, const std::string& alias,
00053             const std::vector<std::string>& aliasAttributeNames,
00054             const std::vector<std::string>& aliasAttributes,
00055             const std::vector<std::string>& guidAttributeNames,
00056             const std::vector<std::string>& guidAttributes) 
00057       : m_guid(guid), m_alias(alias), 
00058         m_aliasAttributeNames(aliasAttributeNames),
00059         m_aliasAttributes(aliasAttributes),
00060         m_guidAttributeNames(guidAttributeNames),
00061         m_guidAttributes(guidAttributes)
00062     {
00063     }
00064     
00065     std::string m_guid;
00066     std::string m_alias;
00067     std::vector<std::string> m_aliasAttributeNames;
00068     std::vector<std::string> m_aliasAttributes;
00069     std::vector<std::string> m_guidAttributeNames;
00070     std::vector<std::string> m_guidAttributes;
00071   };
00072   
00073   typedef std::pair<std::string, std::string> GuidAliasPair_t;
00074   typedef std::pair<std::string, std::string> GuidAliasPair_t;
00075   typedef std::vector<GuidAliasPair_t>        GaMap;
00076   typedef std::vector<std::string>            Aliases_t;
00077   typedef std::vector<std::string>            Guids_t;
00078   typedef std::vector<AttributeDefinition>    AttrDefs_t;
00079   
00080   class ReplicaMetadataCatalog
00081   {
00087   public:
00088     
00091     ReplicaMetadataCatalog(const std::string& url) {
00092     }
00093     
00096     virtual ~ReplicaMetadataCatalog() { };
00097     
00102     virtual const std::string& getUrl() const =0;
00103 
00115     virtual void
00116     addAlias(const std::string& guid,
00117              const std::string& alias)
00118       throw(AliasExistsException,
00119             ValueTooLongException,
00120             CommunicationException) =0;
00121                         
00128     virtual void
00129     removeAlias(const std::string& guid,
00130                 const std::string& alias)
00131       throw(CommunicationException) =0;
00132                         
00140     virtual bool
00141     aliasExists(const std::string& alias) const
00142       throw(CommunicationException) =0;
00143 
00151     virtual bool
00152     guidExists(const std::string& guid) const
00153       throw(CommunicationException) =0;
00154                         
00162     virtual const std::string
00163     guidForAlias(const std::string&  alias) const
00164       throw(NoSuchAliasException,
00165             CommunicationException) =0;
00166 
00174     virtual void
00175     getAliases(const std::string& guid,
00176                Aliases_t& vec ) const
00177       throw(NoSuchGuidException,
00178             CommunicationException) =0;
00179  
00193     virtual void
00194     createAliasAttributeDefinition(const AttributeDefinition& attrDef)
00195       throw(AttributeDefinitionExistsException,
00196             UnsupportedAttributeTypeException,
00197             EmptyAttributeNameException,
00198             ValueTooLongException,
00199             CommunicationException) =0;
00200       
00203     //                  virtual void
00204     //   createAliasAttributeDefinition(const std::string& attrName)
00205     //     throw(AttributeDefinitionExistsException,
00206     //           EmptyAttributeNameException,
00207     //                                                  ValueTooLongException,
00208     //                                                  CommunicationException) =0;
00209                         
00216     virtual void
00217     getAliasAttributeDefinitions( AttrDefs_t& ads ) const
00218       throw(CommunicationException) =0;
00219                         
00225     virtual AttributeDefinition
00226     getAliasAttributeDefinition( const std::string& attrAliasName ) const
00227       throw(CommunicationException) =0;
00228                         
00235     virtual bool
00236     aliasAttributeDefinitionExists(const std::string& attrName) const
00237       throw(CommunicationException) =0;
00238                         
00250     virtual void
00251     removeAliasAttributeDefinition(const std::string& attrName)
00252       throw(NoSuchAttributeDefinitionException,
00253             EmptyAttributeNameException,
00254             CommunicationException) =0;
00255 
00269     virtual void
00270     createGuidAttributeDefinition(const AttributeDefinition& attrDef)
00271       throw(AttributeDefinitionExistsException,
00272             UnsupportedAttributeTypeException,
00273             EmptyAttributeNameException,
00274             ValueTooLongException,
00275             CommunicationException) =0;
00276       
00278     //                  virtual void
00279     //   createGuidAttributeDefinition(const std::string& attrName)
00280     //     throw(AttributeDefinitionExistsException,
00281     //           EmptyAttributeNameException,
00282     //                                                  ValueTooLongException,
00283     //                                                  CommunicationException) =0;
00284                         
00291     virtual void
00292     getGuidAttributeDefinitions( AttrDefs_t& ads ) const
00293       throw(CommunicationException) =0;
00294                         
00300     virtual AttributeDefinition
00301     getGuidAttributeDefinition( const std::string& attrGuidName ) const
00302       throw(CommunicationException) =0;
00303                         
00310     virtual bool
00311     guidAttributeDefinitionExists(const std::string& attrName) const 
00312       throw(CommunicationException) =0;
00313                         
00325     virtual void
00326     removeGuidAttributeDefinition(const std::string& attrName)
00327       throw(NoSuchAttributeDefinitionException,
00328             EmptyAttributeNameException,
00329             CommunicationException) =0;
00330                         
00347     virtual const std::string
00348     setGuidAttribute(const std::string& guidName,
00349                      const std::string& attrDefnName,
00350                      const std::string& attrValue)
00351       throw(NoSuchAttributeDefinitionException,
00352             NoSuchGuidException,
00353             ValueTooLongException,
00354             CommunicationException) =0;
00355                         
00371     virtual const std::string
00372     setStringGuidAttribute( const std::string& guidName,
00373                             const std::string& attrDefnName,
00374                             const std::string& attrValue)
00375       throw(NoSuchAttributeDefinitionException,
00376             NoSuchGuidException,
00377             ValueTooLongException,
00378             UnappropriateAttributeTypeException,
00379             CommunicationException) =0;
00380 
00381     virtual int
00382     setIntGuidAttribute( const std::string& guidName,
00383                          const std::string& attrDefnName,
00384                          int                  attrValue)
00385       throw(NoSuchAttributeDefinitionException,
00386             NoSuchGuidException,
00387             ValueTooLongException,
00388             UnappropriateAttributeTypeException,
00389             CommunicationException) =0;
00390 
00391     virtual float
00392     setFloatGuidAttribute( const std::string& guidName,
00393                            const std::string& attrDefnName,
00394                            float                attrValue)
00395       throw(NoSuchAttributeDefinitionException,
00396             NoSuchGuidException,
00397             ValueTooLongException,
00398             UnappropriateAttributeTypeException,
00399             CommunicationException) =0;
00400 
00411     virtual const std::string
00412     getGuidAttribute(const std::string& guidName,
00413                      const std::string& attrDefnName) const
00414       throw(NoSuchGuidException,
00415             NoSuchAttributeDefinitionException,
00416             CommunicationException) =0;
00417                         
00428     virtual const std::string
00429     getStringGuidAttribute( const std::string& guidName,
00430                             const std::string& attrDefnName) const
00431       throw(NoSuchGuidException,
00432             NoSuchAttributeDefinitionException,
00433             UnappropriateAttributeTypeException,
00434             CommunicationException) =0;
00435                         
00436     virtual int
00437     getIntGuidAttribute( const std::string& guidName,
00438                          const std::string& attrDefnName) const
00439       throw(NoSuchGuidException,
00440             NoSuchAttributeDefinitionException,
00441             UnappropriateAttributeTypeException,
00442             CommunicationException) =0;
00443                         
00444     virtual float
00445     getFloatGuidAttribute( const std::string& guidName,
00446                            const std::string& attrDefnName) const
00447       throw(NoSuchGuidException,
00448             NoSuchAttributeDefinitionException,
00449             UnappropriateAttributeTypeException,
00450             CommunicationException) =0;
00451                         
00458     virtual void
00459     removeGuidAttribute(const std::string& guidName,
00460                         const std::string& attrDefnName)
00461       throw(NoSuchGuidException, NoSuchAttributeDefinitionException, CommunicationException) =0;
00462                         
00479     virtual const std::string
00480     setAliasAttribute(const std::string& aliasName,
00481                       const std::string& attrDefnName,
00482                       const std::string& attrValue)
00483       throw(NoSuchAttributeDefinitionException,
00484             NoSuchAliasException,
00485             ValueTooLongException,
00486             CommunicationException) =0;
00487     virtual const std::string
00488     setStringAliasAttribute( const std::string& aliasName,
00489                              const std::string& attrDefnName,
00490                              const std::string& attrValue)
00491       throw(NoSuchAttributeDefinitionException,
00492             NoSuchAliasException,
00493             ValueTooLongException,
00494             UnappropriateAttributeTypeException,
00495             CommunicationException) =0;
00496                         
00497     virtual int
00498     setIntAliasAttribute( const std::string& aliasName,
00499                           const std::string& attrDefnName,
00500                           int                  attrValue)
00501       throw(NoSuchAttributeDefinitionException,
00502             NoSuchAliasException,
00503             ValueTooLongException,
00504             UnappropriateAttributeTypeException,
00505             CommunicationException) =0;
00506 
00507     virtual float
00508     setFloatAliasAttribute( const std::string& aliasName,
00509                             const std::string& attrDefnName,
00510                             float                attrValue)
00511       throw(NoSuchAttributeDefinitionException,
00512             NoSuchAliasException,
00513             ValueTooLongException,
00514             UnappropriateAttributeTypeException,
00515             CommunicationException) =0;
00516 
00527     virtual const std::string
00528     getAliasAttribute(const std::string& aliasName,
00529                       const std::string& attrDefnName) const 
00530       throw(NoSuchAliasException,
00531             NoSuchAttributeDefinitionException,
00532             CommunicationException) =0;
00533 
00534     virtual const std::string
00535     getStringAliasAttribute( const std::string& aliasName,
00536                              const std::string& attrDefnName) const 
00537       throw(NoSuchAliasException,
00538             NoSuchAttributeDefinitionException,
00539             UnappropriateAttributeTypeException,
00540             CommunicationException) = 0;
00541       
00542     virtual int
00543     getIntAliasAttribute( const std::string& aliasName,
00544                           const std::string& attrDefnName) const 
00545       throw(NoSuchAliasException,
00546             NoSuchAttributeDefinitionException,
00547             UnappropriateAttributeTypeException,
00548             CommunicationException) = 0;
00549       
00550     virtual float
00551     getFloatAliasAttribute( const std::string& aliasName,
00552                             const std::string& attrDefnName) const 
00553       throw(NoSuchAliasException,
00554             NoSuchAttributeDefinitionException,
00555             UnappropriateAttributeTypeException,
00556             CommunicationException) = 0;
00557                         
00564     virtual void
00565     removeAliasAttribute(const std::string& aliasName,
00566                          const std::string& attrDefnName)
00567       throw(NoSuchAliasException, NoSuchAttributeDefinitionException, NoSuchAttributeDefinitionException, CommunicationException) =0;
00568                         
00576     virtual void setDefaultResultLength(int resultLength)
00577       throw(CommunicationException) =0;
00578                         
00585     virtual int getDefaultResultLength() const
00586       throw(CommunicationException) =0;
00587                         
00594     virtual void getColumnSizes( ColumnSizes& cs ) const
00595       throw(CommunicationException) =0;
00596 
00597 
00606     virtual void
00607     getMappingsWithAttributes(const std::vector<std::string>& guids,
00608                               std::vector<Mapping>& mappings) const
00609       throw(CommunicationException)=0;
00610 
00611 
00620     virtual void 
00621     setMappingsWithAttributes(const std::vector<Mapping>& mappings) const
00622       throw(CommunicationException, NoSuchAttributeDefinitionException,
00623             UnappropriateAttributeTypeException, AliasExistsException)=0;
00624 
00625 
00635     virtual void
00636     getMappingsByGuid(const std::string& guidPattern,
00637                       GaMap& mappings) const
00638       throw(CommunicationException) =0;
00639                         
00652     virtual void
00653     getMappingsByGuid(const std::string& guidPattern,
00654                       int                  resultLength,
00655                       GaMap&               mappings    ) const
00656       throw(CommunicationException) =0;
00657                         
00670     virtual void
00671     getMappingsByGuid(const std::string&  guidPattern,
00672                       int                   resultLength,
00673                       int                   resultStart,
00674                       GaMap&                mappings    ) const
00675       throw(CommunicationException) =0;
00676                         
00686     virtual void
00687     getMappingsByAlias(const std::string& aliasPattern,
00688                        GaMap&               mappings) const
00689       throw(CommunicationException) =0;
00690                         
00701     virtual void
00702     getMappingsByAlias(const std::string&  aliasPattern,
00703                        int                   resultLength,
00704                        GaMap&                mappings) const
00705       throw(CommunicationException) =0;
00706                         
00718     virtual void
00719     getMappingsByAlias(const std::string&  aliasPattern,
00720                        int                   resultLength,
00721                        int                   resultStart,
00722                        GaMap&                mappings) const
00723       throw(CommunicationException) =0;
00724                         
00736     virtual void
00737     getMappingsByGuidAttribute(const std::string& name,
00738                                const std::string& value,
00739                                GaMap&               mappings) const
00740       throw(NoSuchAttributeDefinitionException,
00741             CommunicationException) =0;
00742                         
00755     virtual void
00756     getMappingsByGuidAttribute(const std::string& name,
00757                                const std::string& value,
00758                                int                  resultLength,
00759                                GaMap&               mappings) const
00760       throw(NoSuchAttributeDefinitionException,
00761             CommunicationException) =0;
00762                         
00776     virtual void
00777     getMappingsByGuidAttribute(const std::string& name,
00778                                const std::string& value,
00779                                int                  resultLength,
00780                                int                  resultStart,
00781                                GaMap&               mappings) const
00782       throw(NoSuchAttributeDefinitionException,
00783             CommunicationException) =0;
00784                         
00796     virtual void
00797     getMappingsByAliasAttribute(const std::string& name,
00798                                 const std::string& value,
00799                                 GaMap&             mappings) const
00800       throw(NoSuchAttributeDefinitionException,
00801             CommunicationException) =0;
00802                         
00815     virtual void
00816     getMappingsByAliasAttribute(const std::string& name,
00817                                 const std::string& value,
00818                                 int                resultLength,
00819                                 GaMap&             mappings) const
00820       throw(NoSuchAttributeDefinitionException,
00821             CommunicationException) =0;
00822                         
00836     virtual void
00837     getMappingsByAliasAttribute(const std::string& name,
00838                                 const std::string& value,
00839                                 int                resultLength,
00840                                 int                resultStart,
00841                                 GaMap&             mappings) const
00842       throw(NoSuchAttributeDefinitionException,
00843             CommunicationException) =0;
00844 
00851     virtual void
00852     getMappingsByAttribute( const std::string& SQLQuery, 
00853                             int          resultLength,
00854                             GaMap&               mappings ) const
00855       throw(CommunicationException) = 0;
00856       
00864     virtual void
00865     getMappingsByAttribute( const std::string& SQLQuery, 
00866                             int          resultLength, 
00867                             int          resultStart,
00868                             GaMap&               mappings ) const
00869       throw(CommunicationException) = 0;
00870 
00871 
00883     virtual void
00884     getMappingsWithAttributes( const std::string& SQLQuery, 
00885                                int resultLength,
00886                                std::vector<Mapping>& mappings) const
00887       throw(NoSuchAttributeDefinitionException,
00888             InvalidQueryException,
00889             CommunicationException)=0;
00890 
00903     virtual void
00904     getMappingsWithAttributes( const std::string& SQLQuery, 
00905                                int resultLength, 
00906                                int resultStart,
00907                                std::vector<Mapping>& mappings) const
00908       throw(NoSuchAttributeDefinitionException,
00909             InvalidQueryException,
00910             CommunicationException)=0;
00911 
00915     virtual const std::string getVersion() const
00916       throw(CommunicationException) =0;
00917       
00921     virtual const std::string getInterfaceVersion() const
00922       throw(CommunicationException) =0;
00923       
00927     virtual const std::string getSchemaVersion() const
00928       throw(CommunicationException) =0;
00929       
00936     virtual const std::string ping() const
00937       throw(CommunicationException) =0;
00938 
00939 #ifdef WITH_WP2_SECURITY
00940     /* For defining the desired role and policy after the lrc
00941      * object has laready been created
00942      */
00943     virtual int addRoleAndPolicy(char *role,
00944                                  char *policy,
00945                                  char *defaultrole,
00946                                  char *defaultpolicy)=0;
00947 
00948     virtual void clearRoleAndPolicy()=0;
00949 
00950 #endif
00951 
00952   };
00953 }
00954 
00955 #endif // MetadataCatalog_H
00956 
00957                          
00958         
The EU DataGrid Project. All rights reserved.