You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2004/07/14 02:50:55 UTC
cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry RegistryImporter.java HybridRegistry.java HybridRegistryService.java
taylor 2004/07/13 17:50:55
Modified: src/java/org/apache/jetspeed/services/registry
HybridRegistryService.java
Added: src/java/org/apache/jetspeed/services/registry
RegistryImporter.java HybridRegistry.java
Log:
Registry Importer (not complete)
Provide list of DatabaseManaged registries to the exporter
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 +26 -2 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HybridRegistryService.java 13 Jul 2004 22:53:44 -0000 1.1
+++ HybridRegistryService.java 14 Jul 2004 00:50:55 -0000 1.2
@@ -20,6 +20,7 @@
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.List;
import javax.servlet.ServletConfig;
@@ -42,7 +43,11 @@
* @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
* @version $Id$
*/
-public class HybridRegistryService extends CastorRegistryService
+public class HybridRegistryService
+ extends
+ CastorRegistryService
+ implements
+ HybridRegistry
{
/** regsitry type keyed list of entries */
private Hashtable dbRegistries = new Hashtable();
@@ -120,6 +125,25 @@
return Collections.enumeration(result);
}
+ public List listDatabaseRegistries()
+ {
+ ArrayList result = new ArrayList();
+ result.addAll(dbRegistries.keySet());
+ return result;
+ }
+
+ public List listFileRegistries()
+ {
+ ArrayList result = new ArrayList();
+ Enumeration names = super.getNames();
+ if (names != null)
+ {
+ result.addAll(Collections.list(names));
+ }
+ return result;
+ }
+
+
public Registry get(String registryName)
{
Registry registry = (Registry)dbRegistries.get(registryName);
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/RegistryImporter.java
Index: RegistryImporter.java
===================================================================
/*
* Copyright 2000-2001,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jetspeed.services.registry;
import java.util.Enumeration;
import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
import org.apache.jetspeed.services.logging.JetspeedLogger;
import org.apache.jetspeed.services.registry.RegistryService;
import org.apache.jetspeed.om.registry.RegistryEntry;
import org.apache.jetspeed.om.registry.Registry;
import org.apache.jetspeed.util.ServiceUtil;
import org.apache.turbine.util.TurbineConfig;
/**
* Reads all Registry files from the file system and imports them into Registry DB
*
* @author <a href="mailto:susinha@cisco.com">Suchisubhra Sinha</a>
* @version $Id: RegistryImporter.java,v 1.1 2004/07/14 00:50:55 taylor Exp $
*/
public class RegistryImporter
{
/**
* Static initialization of the logger for this class
*/
private static final JetspeedLogger logger =
JetspeedLogFactoryService.getLogger(RegistryImporter.class.getName());
protected boolean check = true;
public RegistryImporter()
{
}
public static void main(String args[])
{
System.out.println("***** Registry Importer *****");
boolean checkImport = true;
//
// initialize and bootstrap services
//
try
{
String root = "/webapp";
String properties = "/WEB-INF/conf/TurbineResources.properties";
TurbineConfig config = new TurbineConfig(root, properties);
config.initialize();
}
catch (Exception e)
{
String msg =
"Registry Importer: error initializing Turbine configuration";
logger.error(msg, e);
System.out.println(msg);
e.printStackTrace();
System.exit(0);
}
//
// get a handle to the exporter service
//
RegistryService exporterService = null;
RegistryService importerService = null;
try
{
exporterService =
(RegistryService) ServiceUtil.getServiceByName(
"RegistryExportManager");
}
catch (org.apache.turbine.services.InstantiationException e)
{
String msg =
"Registry Importer: error loading Registry Exporter Service";
logger.error(msg, e);
System.out.println(msg);
e.printStackTrace();
System.exit(0);
}
//
// get a handle to the importer service
//
try
{
importerService =
(RegistryService) ServiceUtil.getServiceByName(
"RegistryImportManager");
}
catch (org.apache.turbine.services.InstantiationException e)
{
String msg =
"Registry Importer: error loading Registry Importer Service";
logger.error(msg, e);
System.out.println(msg);
e.printStackTrace();
System.exit(0);
}
if (exporterService
.getClass()
.getName()
.equals(importerService.getClass().getName()))
{
String msg =
"Registry Importer Error: Importer Class cannot equal Exporter Class.";
logger.error(msg);
System.out.println(msg);
System.exit(0);
}
RegistryImporter importer = new RegistryImporter();
boolean ran = importer.run(exporterService, importerService);
if (ran)
{
System.out.println("**** Registry Importer - completed");
}
System.exit(1);
}
public boolean run(
RegistryService exporterService,
RegistryService importerService)
{
String msg;
int count = 0;
try
{
msg =
"Running with Importer Service: " + importerService.getClass();
System.out.println(msg);
logger.info(msg);
msg =
"Running with Exporter Service: " + exporterService.getClass();
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();
while (enum.hasMoreElements())
{
count++;
RegistryEntry entry = (RegistryEntry) enum.nextElement();
/*
TODO: left off here
entry = CastorConversion.castorToDatabase(name, entry);
if (entry != null)
exporterService.addEntry(name, entry);
*/
}
}
}
catch (Exception e)
{
logger.error("Error importing: ", e);
e.printStackTrace();
return false;
}
msg = "RegistryImporter completed. Exported " + count + " profiles";
System.out.println(msg);
logger.info(msg);
return true;
}
}
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/HybridRegistry.java
Index: HybridRegistry.java
===================================================================
/*
* Copyright 2000-2001,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jetspeed.services.registry;
import java.util.List;
/**
* Interface for manipulating Hybrid registries
*
* @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
* @version $Id: HybridRegistry.java,v 1.1 2004/07/14 00:50:55 taylor Exp $
*/
public interface HybridRegistry
{
/**
* List of all registries managed in the database.
*/
public List listDatabaseRegistries();
/**
* List of all registries managed in the file system.
*/
public List listFileRegistries();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org