portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry RegistryImporter.java HybridRegistryService.java CastorRegistryService.java
Date Wed, 14 Jul 2004 22:35:02 GMT
taylor      2004/07/14 15:35:02

  Modified:    src/java/org/apache/jetspeed/services/registry
                        RegistryImporter.java HybridRegistryService.java
                        CastorRegistryService.java
  Log:
  completed basic algorithm of registry importer into database
  
  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.3       +23 -23    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RegistryImporter.java	14 Jul 2004 19:03:22 -0000	1.2
  +++ RegistryImporter.java	14 Jul 2004 22:35:01 -0000	1.3
  @@ -30,6 +30,7 @@
    * Reads all Registry files from the file system and imports them into Registry DB
    *
    * @author <a href="mailto:susinha@cisco.com">Suchisubhra Sinha</a>
  + * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
    * @version $Id$
    */
   public class RegistryImporter
  @@ -79,7 +80,7 @@
           {
               exporterService =
                   (RegistryService) ServiceUtil.getServiceByName(
  -                    "RegistryExporter");
  +                    "Registry");
           }
           catch (org.apache.turbine.services.InstantiationException e)
           {
  @@ -132,7 +133,8 @@
           RegistryService importerService)
       {
           String msg;
  -        int count = 0;
  +        int registryCount = 0;
  +        int entryCount = 0;
           try
           {
               msg =
  @@ -144,31 +146,29 @@
               System.out.println(msg);
               logger.info(msg);
               Enumeration e = importerService.getNames();
  -            
  -            // TODO: HybridService.listDatabaseRegistries
  -            // only export database-managed registries
  -            
  +                        
               while (e.hasMoreElements())
               {
  -
  -                String name = (String) e.nextElement();
  -                Registry importRegistry = importerService.get(name);
  -                RegistryEntry exportRegistry =
  -                    exporterService.createEntry(name);
  -                Enumeration enum = importRegistry.getEntries();
  +                String registryName = (String) e.nextElement();
  +                System.out.println("Exporting Registry: " + registryName);
  +                Registry importRegistry = importerService.get(registryName);
  +                Registry exportRegistry = exporterService.get(registryName);
  +                
  +                
  +                Enumeration enum = exportRegistry.getEntries();
                   while (enum.hasMoreElements())
                   {
  +                    RegistryEntry exportEntry = (RegistryEntry) enum.nextElement();
  +                    System.out.println("Importing into Registry: " + registryName + ",
Entry = " + exportEntry.getName());
   
  -                    count++;
  -                    RegistryEntry entry = (RegistryEntry) enum.nextElement();
  -                    System.out.println("entry = " + entry.getName());
  -                    /*
  -                     TODO: left off here
  -                    entry = CastorConversion.castorToDatabase(name, entry);
  -                    if (entry != null)
  -                        exporterService.addEntry(name, entry);
  -                        */
  +                    if (registryName.equals(org.apache.jetspeed.services.Registry.SECURITY))
                   
  +                    {
  +                        importerService.addEntry(registryName, exportEntry);
  +                    }
  +                    
  +                    entryCount++;                    
                   }
  +                registryCount++;
               }
           }
           catch (Exception e)
  @@ -177,7 +177,7 @@
               e.printStackTrace();
               return false;
           }
  -        msg = "RegistryImporter completed. Exported " + count + " profiles";
  +        msg = "Registry Importer completed. Exported " + registryCount + " registries,
" + entryCount + " total registry entries.";
           System.out.println(msg);
           logger.info(msg);
           return true;
  
  
  
  1.4       +12 -20    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HybridRegistryService.java	14 Jul 2004 19:03:22 -0000	1.3
  +++ HybridRegistryService.java	14 Jul 2004 22:35:01 -0000	1.4
  @@ -61,12 +61,7 @@
        */
       public synchronized void init(ServletConfig conf) throws InitializationException
       {
  -        ResourceService serviceConf = ((TurbineServices) 
  -                TurbineServices.getInstance()).getResources(RegistryService.SERVICE_NAME);
  -
  -        hybrid = serviceConf.getBoolean("hybrid");
  -        System.out.println("Hybrid == " + hybrid);
  -        
  +        hybrid = getConfiguration().getBoolean("hybrid");        
           if (hybrid)
           {
               super.init(conf);
  @@ -76,19 +71,17 @@
           {
               // get the list of managed Registries in the Database
               
  -            ResourceService rs = serviceConf.getResources("database.default");
  -            
  -            if (rs != null)
  +            // dst ResourceService rs = serviceConf.getResources("database.default");
  +            Iterator iterator = getConfiguration().getKeys("database.default");
  +            // dst Iterator iterator = rs.getKeys();                
  +            while (iterator.hasNext())
               {
  -                Iterator iterator = rs.getKeys();                
  -                while (iterator.hasNext())
  -                {
  -                    String name = (String)iterator.next();
  -                    Registry registry = createRegistry(name);
  -                    dbRegistries.put(name, registry);
  -                    loadCache(name, registry);
  -                }                
  -            }            
  +                String key = (String)iterator.next();
  +                String name = key.substring(key.lastIndexOf(".") + 1);                
  +                Registry registry = createRegistry(key);
  +                dbRegistries.put(name, registry);
  +                loadCache(name, registry);
  +            }                
           }
           catch (Throwable t)
           {
  @@ -108,7 +101,6 @@
                   while (extent.hasNext())
                   {
                       SecurityEntry se = (SecurityEntry)extent.next();
  -                    System.out.println("Caching ... " + se.getName());
                       local.addLocalEntry((RegistryEntry)se);                    
                   }
               }
  
  
  
  1.42      +9 -20     jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/CastorRegistryService.java
  
  Index: CastorRegistryService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/CastorRegistryService.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- CastorRegistryService.java	14 Jul 2004 00:21:04 -0000	1.41
  +++ CastorRegistryService.java	14 Jul 2004 22:35:01 -0000	1.42
  @@ -319,8 +319,6 @@
           //Ensure that the servlet service is initialized
           TurbineServices.getInstance().initService(ServletService.SERVICE_NAME, conf);
   
  -        ResourceService serviceConf = ((TurbineServices) TurbineServices.getInstance())
  -                                                     .getResources(RegistryService.SERVICE_NAME);
           String mapFile = null;
           Vector names = new Vector();
           int refreshRate = 0;
  @@ -328,10 +326,10 @@
           // read the configuration keys
           try
           {
  -            directory = serviceConf.getString("directory");
  -            mapFile = serviceConf.getString("mapping", DEFAULT_MAPPING);
  -            extension = serviceConf.getString("extension", DEFAULT_EXTENSION);
  -            refreshRate = serviceConf.getInt("refreshRate", DEFAULT_REFRESH);
  +            directory = getConfiguration().getString("directory");
  +            mapFile = getConfiguration().getString("mapping", DEFAULT_MAPPING);
  +            extension = getConfiguration().getString("extension", DEFAULT_EXTENSION);
  +            refreshRate = getConfiguration().getInt("refreshRate", DEFAULT_REFRESH);
   
               mapFile = TurbineServlet.getRealPath(mapFile);
               directory = TurbineServlet.getRealPath(directory);
  @@ -345,21 +343,12 @@
           // with at least one fragment
           try
           {
  -            Map databaseManaged = loadDatabaseManagedRegistries(serviceConf);
  -            ResourceService defaults = serviceConf.getResources("default");
  -            Iterator i = defaults.getKeys();
  +            Iterator i = getConfiguration().getKeys("default");
               while (i.hasNext())
               {
  -                String name = (String) i.next();
  -                /*
  -                if (databaseManaged.containsKey(name))
  -                {
  -                    System.out.println("Skipping loading of registry: " + name);
  -                    continue;
  -                }
  -                */
  -                String fragmentFileName = defaults.getString(name);
  -
  +                String key = (String) i.next();
  +                String name = key.substring(key.indexOf(".") + 1);
  +                String fragmentFileName = getConfiguration().getString(key);
                   String absFileName = new File(directory, fragmentFileName + extension).getCanonicalPath();
                   // add this name in the list of available registries
                   names.add(name);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message