taylor      2004/07/14 12:03:22

  Modified:    src/java/org/apache/jetspeed/services/registry
                        RegistryImporter.java HybridRegistryService.java
  Log:
  - make hybrid optional for running hybrid registry service as pure registry service 
when importing
  - continuing work on importer (in progress)
  
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.2       +12 -5     
jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/RegistryImporter.java
  
  Index: RegistryImporter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/RegistryImporter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RegistryImporter.java     14 Jul 2004 00:50:55 -0000      1.1
  +++ RegistryImporter.java     14 Jul 2004 19:03:22 -0000      1.2
  @@ -22,6 +22,8 @@
   import org.apache.jetspeed.om.registry.RegistryEntry;
   import org.apache.jetspeed.om.registry.Registry;
   import org.apache.jetspeed.util.ServiceUtil;
  +import org.apache.turbine.services.TurbineServices;
  +import org.apache.turbine.services.resources.ResourceService;
   import org.apache.turbine.util.TurbineConfig;
   
   /**
  @@ -50,10 +52,14 @@
           //
           try
           {
  -            String root = "/webapp";
  -            String properties = "/WEB-INF/conf/TurbineResources.properties";
  +            String root = "./webapp";
  +            String properties = "/WEB-INF/conf/RegistryImport.properties";
               TurbineConfig config = new TurbineConfig(root, properties);
  +            
               config.initialize();
  +            ResourceService serviceConf = ((TurbineServices) 
  +                    
TurbineServices.getInstance()).getResources(RegistryService.SERVICE_NAME);
  +            
           }
           catch (Exception e)
           {
  @@ -73,7 +79,7 @@
           {
               exporterService =
                   (RegistryService) ServiceUtil.getServiceByName(
  -                    "RegistryExportManager");
  +                    "RegistryExporter");
           }
           catch (org.apache.turbine.services.InstantiationException e)
           {
  @@ -91,7 +97,7 @@
           {
               importerService =
                   (RegistryService) ServiceUtil.getServiceByName(
  -                    "RegistryImportManager");
  +                    "RegistryImporter");
           }
           catch (org.apache.turbine.services.InstantiationException e)
           {
  @@ -155,6 +161,7 @@
   
                       count++;
                       RegistryEntry entry = (RegistryEntry) enum.nextElement();
  +                    System.out.println("entry = " + entry.getName());
                       /*
                        TODO: left off here
                       entry = CastorConversion.castorToDatabase(name, entry);
  
  
  
  1.3       +82 -29    
jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/HybridRegistryService.java
  
  Index: HybridRegistryService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/HybridRegistryService.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HybridRegistryService.java        14 Jul 2004 00:50:55 -0000      1.2
  +++ HybridRegistryService.java        14 Jul 2004 19:03:22 -0000      1.3
  @@ -49,24 +49,33 @@
       implements
           HybridRegistry
   {
  -    /** regsitry type keyed list of entries */
  +    /** registry type keyed list of entries */
       private Hashtable dbRegistries = new Hashtable();
       private static final JetspeedLogger logger = 
JetspeedLogFactoryService.getLogger(HybridRegistryService.class.getName());
  +    private boolean hybrid = true;
           
  -        
  +    
       /**
        * This is the early initialization method called by the
        * Turbine <code>Service</code> framework
        */
       public synchronized void init(ServletConfig conf) throws InitializationException
       {
  -        super.init(conf);
  +        ResourceService serviceConf = ((TurbineServices) 
  +                
TurbineServices.getInstance()).getResources(RegistryService.SERVICE_NAME);
  +
  +        hybrid = serviceConf.getBoolean("hybrid");
  +        System.out.println("Hybrid == " + hybrid);
  +        
  +        if (hybrid)
  +        {
  +            super.init(conf);
  +        }
   
           try
           {
               // get the list of managed Registries in the Database
  -            ResourceService serviceConf = ((TurbineServices) 
  -                    
TurbineServices.getInstance()).getResources(RegistryService.SERVICE_NAME);
  +            
               ResourceService rs = serviceConf.getResources("database.default");
               
               if (rs != null)
  @@ -79,16 +88,13 @@
                       dbRegistries.put(name, registry);
                       loadCache(name, registry);
                   }                
  -            }
  -
  -
  -            
  +            }            
           }
           catch (Throwable t)
           {
               throw new InitializationException("Unable to initialize 
HybridRegistryService, missing config keys");
           }
  -        
  +        setInit(true);        
       }
       
       private void loadCache(String registryName, Registry registry)
  @@ -116,11 +122,14 @@
       public Enumeration getNames()
       {
           ArrayList result = new ArrayList();
  -        Enumeration names = super.getNames();
  -        if (names != null)
  +        if (hybrid)
           {
  -            result.addAll(Collections.list(names));            
  -        }        
  +            Enumeration names = super.getNames();
  +            if (names != null)
  +            {
  +                result.addAll(Collections.list(names));            
  +            }
  +        }
           result.addAll(dbRegistries.keySet());
           return Collections.enumeration(result);        
       }
  @@ -135,11 +144,14 @@
       public List listFileRegistries()
       {
           ArrayList result = new ArrayList();
  -        Enumeration names = super.getNames();
  -        if (names != null)
  +        if (hybrid)
           {
  -            result.addAll(Collections.list(names));            
  -        }        
  +            Enumeration names = super.getNames();
  +            if (names != null)
  +            {
  +                result.addAll(Collections.list(names));            
  +            }
  +        }
           return result;                
       }
       
  @@ -147,7 +159,7 @@
       public Registry get(String registryName)
       {
           Registry registry = (Registry)dbRegistries.get(registryName);
  -        if (null == registry)
  +        if (null == registry && hybrid)
           {
               return super.get(registryName);
           }        
  @@ -159,7 +171,11 @@
           Registry registry = (Registry)dbRegistries.get(registryName);
           if (null == registry)
           {
  -            return super.createEntry(registryName);
  +            if (hybrid)
  +            {
  +                return super.createEntry(registryName);
  +            }
  +            return null; 
           }            
           
           return registry.createEntry();
  @@ -171,7 +187,11 @@
           Registry registry = (Registry)dbRegistries.get(registryName);
           if (null == registry)
           {            
  -            return super.getEntry(registryName, entryName);
  +            if (hybrid)
  +            {            
  +                return super.getEntry(registryName, entryName);
  +            }
  +            return null;
           }            
                   
           try
  @@ -220,7 +240,10 @@
           LocalRegistry registry = (LocalRegistry)dbRegistries.get(registryName);
           if (null == registry)
           {
  -            super.addEntry(registryName, entry);            
  +            if (hybrid)
  +            {            
  +                super.addEntry(registryName, entry);
  +            }
               return;
           }            
           if (entry == null)
  @@ -236,15 +259,21 @@
           LocalRegistry registry = (LocalRegistry)dbRegistries.get(registryName);
           if (null == registry)
           {
  -            super.removeEntry(registryName, entryName);            
  -            return;
  +            if (hybrid)
  +            {
  +                super.removeEntry(registryName, entryName);
  +            }
  +            return;            
           }                    
           if (entryName == null)
           {
               return;
  -        }        
  -        SecurityDbEntryPeer.removeSecurityEntry(entryName);        
  -        registry.removeLocalEntry(entryName);
  +        }
  +        if (registryName.equals(org.apache.jetspeed.services.Registry.SECURITY))
  +        {                                         
  +                SecurityDbEntryPeer.removeSecurityEntry(entryName);        
  +                registry.removeLocalEntry(entryName);
  +        }
       }
   
       public void saveEntry(String registryName, RegistryEntry entry) throws 
RegistryException
  @@ -252,7 +281,10 @@
           LocalRegistry registry = (LocalRegistry)dbRegistries.get(registryName);
           if (null == registry)
           {
  -            super.saveEntry(registryName, entry);            
  +            if (hybrid)
  +            {
  +                super.saveEntry(registryName, entry);
  +            }
               return;
           }
           if (entry == null)
  @@ -280,6 +312,27 @@
               }
           }
           
  +    }
  +    
  +    /** Late init method from Turbine Service model */
  +    public void init() throws InitializationException
  +    {
  +        if (hybrid)
  +        {
  +            super.init();
  +        }
  +    }
  +
  +    /**
  +     * This is the shutdown method called by the
  +     * Turbine <code>Service</code> framework
  +     */
  +    public void shutdown()
  +    {
  +        if (hybrid)
  +        {
  +            super.shutdown();
  +        }
       }
       
   }
  
  
  

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

Reply via email to