wam         2004/02/10 07:34:57

  Modified:    src/share/org/apache/slide/common Namespace.java
  Log:
  cleanup
  configure properties and content indexer in Domain.xml
  
  Revision  Changes    Path
  1.57      +115 -180  jakarta-slide/src/share/org/apache/slide/common/Namespace.java
  
  Index: Namespace.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Namespace.java,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- Namespace.java    12 Dec 2003 03:04:23 -0000      1.56
  +++ Namespace.java    10 Feb 2004 15:34:57 -0000      1.57
  @@ -67,14 +67,14 @@
   import java.util.Enumeration;
   import java.util.Hashtable;
   import java.util.Vector;
  -
   import javax.transaction.Status;
   import javax.transaction.SystemException;
   import javax.transaction.TransactionManager;
  -
   import org.apache.slide.authenticate.CredentialsToken;
   import org.apache.slide.content.ContentInterceptor;
   import org.apache.slide.store.ContentStore;
  +import org.apache.slide.store.DefaultIndexer;
  +import org.apache.slide.store.IndexStore;
   import org.apache.slide.store.LockStore;
   import org.apache.slide.store.NodeStore;
   import org.apache.slide.store.RevisionDescriptorStore;
  @@ -141,6 +141,9 @@
       public static final String REVISION_DESCRIPTOR_STORE =
           "revisiondescriptorstore";
       public static final String CONTENT_STORE = "contentstore";
  +    public static final String PROPERTIES_INDEX_STORE = "propertiesindexer";
  +    public static final String CONTENT_INDEX_STORE = "contentindexer";
  +    
       
       
       /**
  @@ -152,6 +155,8 @@
       protected static final String I_CREATESTORELISTENERCLASS_DEFAULT = 
"org.apache.slide.webdav.util.UriHandler";
       
       protected static Class createStoreListenerClass;
  +    
  +    
       static {
           try {
               String createStoreListenerClassName = 
Domain.getParameter(I_CREATESTORELISTENERCLASS, I_CREATESTORELISTENERCLASS_DEFAULT);
  @@ -387,64 +392,68 @@
                   store.setParameters(parameters);
                   stores.put(scope, store);
                   
  -                // Now assigning the child stores
  -                Object nodeStore = childStores.get(NODE_STORE);
  -                if (nodeStore instanceof String) {
  -                    // Resolving reference
  -                    store.setNodeStore((NodeStore) childStores.get(nodeStore));
  -                } else {
  -                    store.setNodeStore((NodeStore) nodeStore);
  -                }
  +                Object o = null;
                   
  -                Object securityStore = childStores.get(SECURITY_STORE);
  -                if (securityStore instanceof String) {
  -                    // Resolving reference
  -                    store.setSecurityStore
  -                        ((SecurityStore) childStores.get(securityStore));
  -                } else {
  -                    store.setSecurityStore
  -                        ((SecurityStore) securityStore);
  -                }
  +                // assign NodeStore
  +                NodeStore nodeStore =
  +                    (NodeStore) dereferenceStore (NODE_STORE, childStores);
                   
  -                Object lockStore = childStores.get(LOCK_STORE);
  -                if (lockStore instanceof String) {
  -                    store.setLockStore
  -                        ((LockStore) childStores.get(lockStore));
  -                } else {
  -                    store.setLockStore((LockStore) lockStore);
  -                }
  +                store.setNodeStore (nodeStore);
                   
  -                Object revisionDescriptorsStore = childStores
  -                    .get(REVISION_DESCRIPTORS_STORE);
  -                if (revisionDescriptorsStore instanceof String) {
  -                    store.setRevisionDescriptorsStore
  -                        ((RevisionDescriptorsStore) childStores
  -                             .get(revisionDescriptorsStore));
  -                } else {
  -                    store.setRevisionDescriptorsStore
  -                        ((RevisionDescriptorsStore) revisionDescriptorsStore);
  -                }
  +                // assign SecurityStore
  +                SecurityStore securityStore =
  +                    (SecurityStore) dereferenceStore (SECURITY_STORE, childStores);
  +                
  +                store.setSecurityStore (securityStore);
  +                
  +                // assign LockStore
  +                LockStore lockStore =
  +                    (LockStore) dereferenceStore (LOCK_STORE, childStores);
  +                
  +                store.setLockStore (lockStore);
  +                
  +                // assign RevisionDescriptorsStore
  +                RevisionDescriptorsStore revisionDescriptorsStore =
  +                    (RevisionDescriptorsStore) dereferenceStore
  +                    (REVISION_DESCRIPTORS_STORE, childStores);
  +                
  +                store.setRevisionDescriptorsStore (revisionDescriptorsStore);
  +                
  +                // assign RevisionDescriptorStore
  +                RevisionDescriptorStore revisionDescriptorStore =
  +                    (RevisionDescriptorStore) dereferenceStore
  +                    (REVISION_DESCRIPTOR_STORE, childStores);
                   
  -                Object revisionDescriptorStore = childStores
  -                    .get(REVISION_DESCRIPTOR_STORE);
  -                if (revisionDescriptorStore instanceof String) {
  -                    store.setRevisionDescriptorStore
  -                        ((RevisionDescriptorStore) childStores
  -                             .get(revisionDescriptorStore));
  -                } else {
  -                    store.setRevisionDescriptorStore
  -                        ((RevisionDescriptorStore) revisionDescriptorStore);
  +                store.setRevisionDescriptorStore (revisionDescriptorStore);
  +                
  +                // assign ContentStore
  +                ContentStore contentStore =
  +                    (ContentStore) dereferenceStore (CONTENT_STORE, childStores);
  +                
  +                store.setContentStore (contentStore);
  +                
  +                // assign PropertiesIndexStore
  +                IndexStore propertiesIndexer =
  +                    (IndexStore) dereferenceStore (PROPERTIES_INDEX_STORE, 
childStores);
  +                
  +                if (propertiesIndexer == null) {
  +                    propertiesIndexer = new DefaultIndexer 
(revisionDescriptorStore);
  +                    childStores.put (PROPERTIES_INDEX_STORE, propertiesIndexer);
                   }
                   
  -                Object contentStore = childStores.get(CONTENT_STORE);
  -                if (contentStore instanceof String) {
  -                    // Resolving reference
  -                    store.setContentStore
  -                        ((ContentStore) childStores.get(contentStore));
  -                } else {
  -                    store.setContentStore((ContentStore) contentStore);
  +                store.setPropertiesIndexer (propertiesIndexer);
  +                
  +                // assign ContentIndexStore
  +                IndexStore contentIndexer =
  +                    (IndexStore) dereferenceStore (CONTENT_INDEX_STORE, 
childStores);
  +                
  +                if (contentIndexer == null) {
  +                    contentIndexer = new DefaultIndexer (contentStore);
  +                    childStores.put (CONTENT_INDEX_STORE, contentIndexer);
                   }
                   
  +                store.setContentIndexer (contentIndexer);
  +                
                   // set the scope in the father and child stores
                   store.setScope(scope);
                   
  @@ -472,6 +481,19 @@
       }
       
       
  +    Object dereferenceStore (String storeType, Hashtable childStores) {
  +        Object result;
  +        
  +        Object o = childStores.get(storeType);
  +        if (o instanceof String) {
  +            result = childStores.get(o);
  +        } else {
  +            result = o;
  +        }
  +        return result;
  +    }
  +    
  +    
       /**
        * At the end of the service registration, this service is called to
        * perform any required initialization task.
  @@ -784,7 +806,7 @@
               
               SlideToken slideToken = new SlideTokenImpl(new CredentialsToken(""));
               slideToken.setForceStoreEnlistment(true);
  -
  +            
               // First, we create the root node
               Uri rootUri = getUri(slideToken, "/");
               SubjectNode rootNode = new SubjectNode("/");
  @@ -957,148 +979,61 @@
           
           Hashtable currentStoreChildStores = new Hashtable();
           
  +        String key = NODE_STORE;
  +        
           // Loading node store (if any)
  -        try {
  -            Configuration nodeStoreDefinition =
  -                storeDefinition.getConfiguration(NODE_STORE);
  -            try {
  -                Configuration referenceDefinition =
  -                    storeDefinition.getConfiguration(REFERENCE);
  -                currentStoreChildStores.put
  -                    (NODE_STORE, referenceDefinition.getAttribute("store"));
  -                getLogger().log("Node store references " + 
referenceDefinition.getAttribute("store"),LOG_CHANNEL,Logger.INFO);
  -            } catch (ConfigurationException ex) {
  -                getLogger().log("Node store: " + 
nodeStoreDefinition.getAttribute("classname"),LOG_CHANNEL,Logger.INFO);
  -                NodeStore nodeStore =
  -                    (NodeStore) loadChildStore(nodeStoreDefinition,
  -                                               storeParameters);
  -                if (nodeStore != null) {
  -                    currentStoreChildStores.put(NODE_STORE, nodeStore);
  -                }
  -            }
  -        } catch (Exception e) {
  -        }
  +        getChildStore (storeDefinition, NODE_STORE, currentStoreChildStores, 
storeParameters);
           
           // Loading security store (if any)
  -        try {
  -            Configuration securityStoreDefinition =
  -                storeDefinition.getConfiguration(SECURITY_STORE);
  -            try {
  -                Configuration referenceDefinition =
  -                    securityStoreDefinition.getConfiguration(REFERENCE);
  -                currentStoreChildStores.put
  -                    (SECURITY_STORE,
  -                     referenceDefinition.getAttribute("store"));
  -                getLogger().log("Security store references " + 
referenceDefinition.getAttribute("store"),LOG_CHANNEL,Logger.INFO);
  -            } catch (ConfigurationException ex) {
  -                getLogger().log("Security store: " + 
securityStoreDefinition.getAttribute("classname"),LOG_CHANNEL,Logger.INFO);
  -                SecurityStore securityStore =
  -                    (SecurityStore) loadChildStore(securityStoreDefinition,
  -                                                   storeParameters);
  -                if (securityStore != null) {
  -                    currentStoreChildStores.put(SECURITY_STORE, securityStore);
  -                }
  -            }
  -        } catch (Exception e) {
  -        }
  +        getChildStore (storeDefinition, SECURITY_STORE, currentStoreChildStores, 
storeParameters);
           
           // Loading lock store (if any)
  -        try {
  -            Configuration lockStoreDefinition =
  -                storeDefinition.getConfiguration(LOCK_STORE);
  -            try {
  -                Configuration referenceDefinition =
  -                    lockStoreDefinition.getConfiguration(REFERENCE);
  -                currentStoreChildStores.put
  -                    (LOCK_STORE, referenceDefinition.getAttribute("store"));
  -                getLogger().log("Lock store store references " + 
referenceDefinition.getAttribute("store"),LOG_CHANNEL,Logger.INFO);
  -            } catch (ConfigurationException ex) {
  -                getLogger().log("Lock store store: " + 
lockStoreDefinition.getAttribute("classname"),LOG_CHANNEL,Logger.INFO);
  -                LockStore lockStore =
  -                    (LockStore) loadChildStore(lockStoreDefinition,
  -                                               storeParameters);
  -                if (lockStore != null) {
  -                    currentStoreChildStores.put(LOCK_STORE, lockStore);
  -                }
  -            }
  -        } catch (Exception e) {
  -        }
  +        getChildStore (storeDefinition, LOCK_STORE, currentStoreChildStores, 
storeParameters);
           
           // Loading revision descriptors store (if any)
  -        try {
  -            Configuration revisionDescriptorsStoreDefinition =
  -                storeDefinition.getConfiguration
  -                (REVISION_DESCRIPTORS_STORE);
  -            try {
  -                Configuration referenceDefinition =
  -                    revisionDescriptorsStoreDefinition
  -                    .getConfiguration(REFERENCE);
  -                currentStoreChildStores.put
  -                    (REVISION_DESCRIPTORS_STORE,
  -                     referenceDefinition.getAttribute("store"));
  -                getLogger().log("Revision descriptors store references " + 
referenceDefinition.getAttribute("store"),LOG_CHANNEL,Logger.INFO);
  -            } catch (ConfigurationException ex) {
  -                getLogger().log("Revision descriptors store: " + 
revisionDescriptorsStoreDefinition.getAttribute("classname"),LOG_CHANNEL,Logger.INFO);
  -                RevisionDescriptorsStore revisionDescriptorsStore =
  -                    (RevisionDescriptorsStore) loadChildStore
  -                    (revisionDescriptorsStoreDefinition, storeParameters);
  -                if (revisionDescriptorsStore != null) {
  -                    currentStoreChildStores.put(REVISION_DESCRIPTORS_STORE,
  -                                                revisionDescriptorsStore);
  -                }
  -            }
  -        } catch (Exception e) {
  -        }
  +        getChildStore (storeDefinition, REVISION_DESCRIPTORS_STORE, 
currentStoreChildStores, storeParameters);
           
           // Loading revision descriptor store (if any)
  -        try {
  -            Configuration revisionDescriptorStoreDefinition =
  -                storeDefinition.getConfiguration(REVISION_DESCRIPTOR_STORE);
  -            try {
  -                Configuration referenceDefinition =
  -                    revisionDescriptorStoreDefinition
  -                    .getConfiguration(REFERENCE);
  -                currentStoreChildStores.put
  -                    (REVISION_DESCRIPTOR_STORE,
  -                     referenceDefinition.getAttribute("store"));
  -                getLogger().log("Revision descriptor store references " + 
referenceDefinition.getAttribute("store"),LOG_CHANNEL,Logger.INFO);
  -            } catch (ConfigurationException ex) {
  -                getLogger().log("Revision descriptor store: " + 
revisionDescriptorStoreDefinition.getAttribute("classname"),LOG_CHANNEL,Logger.INFO);
  -                RevisionDescriptorStore revisionDescriptorStore =
  -                    (RevisionDescriptorStore) loadChildStore
  -                    (revisionDescriptorStoreDefinition, storeParameters);
  -                if (revisionDescriptorStore != null) {
  -                    currentStoreChildStores.put(REVISION_DESCRIPTOR_STORE,
  -                                                revisionDescriptorStore);
  -                }
  -            }
  -        } catch (Exception e) {
  -        }
  +        getChildStore (storeDefinition, REVISION_DESCRIPTOR_STORE, 
currentStoreChildStores, storeParameters);
           
           // Loading content store (if any)
  +        getChildStore (storeDefinition, CONTENT_STORE, currentStoreChildStores, 
storeParameters);
  +        
  +        // Loading descriptorindexstore store (if any)
  +        getChildStore (storeDefinition, PROPERTIES_INDEX_STORE, 
currentStoreChildStores, storeParameters);
  +        
  +        // Loading contentindexstore store (if any)
  +        getChildStore (storeDefinition, CONTENT_INDEX_STORE, 
currentStoreChildStores, storeParameters);
  +        
  +        // load default indexer, if no indexer defined
  +        
  +        childStores.put(storeName, currentStoreChildStores);
  +        
  +    }
  +    
  +    private void getChildStore(Configuration storeDefinition, String key, Hashtable 
currentStoreChildStores, Hashtable storeParameters)
  +    {
           try {
  -            Configuration contentStoreDefinition =
  -                storeDefinition.getConfiguration(CONTENT_STORE);
  +            Configuration localStoreDefinition =
  +                storeDefinition.getConfiguration(key);
               try {
                   Configuration referenceDefinition =
  -                    contentStoreDefinition.getConfiguration(REFERENCE);
  +                    localStoreDefinition.getConfiguration(REFERENCE);
                   currentStoreChildStores.put
  -                    (CONTENT_STORE, referenceDefinition.getAttribute("store"));
  -                getLogger().log("Content store references " + 
referenceDefinition.getAttribute("store"),LOG_CHANNEL,Logger.INFO);
  +                    (key, referenceDefinition.getAttribute("store"));
  +                getLogger().log(key + " references " + 
referenceDefinition.getAttribute("store"),LOG_CHANNEL,Logger.INFO);
               } catch (ConfigurationException ex) {
  -                getLogger().log("Content store: " + 
contentStoreDefinition.getAttribute("classname"),LOG_CHANNEL,Logger.INFO);
  -                ContentStore contentStore =
  -                    (ContentStore) loadChildStore(contentStoreDefinition,
  -                                                  storeParameters);
  -                if (contentStore != null) {
  -                    currentStoreChildStores.put(CONTENT_STORE, contentStore);
  +                getLogger().log(key + ": " + 
localStoreDefinition.getAttribute("classname"),LOG_CHANNEL,Logger.INFO);
  +                Service store =
  +                    loadChildStore(localStoreDefinition,
  +                                   storeParameters);
  +                
  +                if (store != null) {
  +                    currentStoreChildStores.put(key, store);
                   }
               }
           } catch (Exception e) {
           }
  -        
  -        childStores.put(storeName, currentStoreChildStores);
  -        
       }
       
       
  @@ -1216,7 +1151,7 @@
               }
               catch( Exception x ) {
                   Domain.warn( "Notification of store creation "+
  -                             "(namespace="+namespaceName+", scope="+scope+", 
store="+storeName+") failed: "+x.getMessage() );
  +                                "(namespace="+namespaceName+", scope="+scope+", 
store="+storeName+") failed: "+x.getMessage() );
               }
           }
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to