Author: deepal
Date: Thu Jan 17 00:01:23 2008
New Revision: 12387

Log:

removed collection rename support 
 - When creating DB (sample-db) if it can not create the DB then registry will 
start with in-memory DB

Modified:
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
   
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java
      (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java
      Thu Jan 17 00:01:23 2008
@@ -22,6 +22,8 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.wso2.registry.RegistryException;
 import org.wso2.registry.secure.HSQLDBInitializer;
 import org.wso2.registry.jdbc.hsql.DBUtils;
@@ -42,6 +44,8 @@
 
 public class RegistryConfigurationProcessor {
 
+    private static final Log log = 
LogFactory.getLog(RegistryConfigurationProcessor.class);
+
     /**
      * This method will read the registry.xml and using the data given in the 
file registry
      * configuration will be populated. And if the xmlLocation is null then it 
will use the one in
@@ -116,8 +120,9 @@
                             dbInitializer.createHSQLTables(dataSource);
 
                         } catch (SQLException e) {
-                            String msg = "Create sample in-process database.";
-                            throw new RegistryException(msg);
+                            dataBaseConfiguration.setConfigName("in-memory");
+                            log.info("Unable to create the sample DB , so 
crated in-memory");
+//                            throw new RegistryException(msg);
                         }
 
                     } else {

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
      (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
      Thu Jan 17 00:01:23 2008
@@ -630,41 +630,7 @@
             // if the resource is a directory then need to populate the 
dependecy table with
             // the new resource id , while keeping the old one as it is
             if (resource.isDirectory()) {
-                long resourceId = resource.getId();
-                long resourceVersionNumber = 
getLatestVerisonNumber(resourceId, conn);
-                String selectSql = "SELECT DAID, DVN FROM DEPENDENCY WHERE 
AID=? AND VN=?";
-                PreparedStatement s = conn.prepareStatement(selectSql);
-                s.setLong(1, resourceId);
-                s.setLong(2, resourceVersionNumber);
-                ResultSet result = s.executeQuery();
-                // adding the resource to artifcat table and update the 
version numbers
-                resource.setPath(newPath);
-                if (resource.getAuthorUserName() == null) {
-                    resource.setAuthorUserName(userId);
-                }
-                resource.setLastUpdaterUserName(userId);
-                add(resource, conn);
-                AuthorizationUtil.setDefaultAuthorizations(realm, newPath, 
userId);
-                long newResourceID = getResourceID(newPath, conn);
-                resource.setId(newResourceID);
-                addResourceVersion(resource, conn);
-
-                // updating the version table
-                long newresourceVersion = 
getLatestVerisonNumber(newResourceID, conn);
-                ArrayList dependeyList = new ArrayList();
-                while (result.next()) {
-                    long daid = result.getLong("DAID");
-                    long dvn = result.getLong("DVN");
-                    PreparedStatement ps = getStatementForDependencyTable(conn,
-                            newResourceID,
-                            newresourceVersion,
-                            daid, dvn);
-                    dependeyList.add(ps);
-                }
-                for (int i = 0; i < dependeyList.size(); i++) {
-                    PreparedStatement preparedStatement = 
(PreparedStatement)dependeyList.get(i);
-                    preparedStatement.executeUpdate();
-                }
+                throw new RegistryException("Resource rename does not support 
for collections");
             } else {
                 // Then its just need to add the resource and no need to 
update any of the
                 // dependecy tables
@@ -681,14 +647,10 @@
             }
             resource.setPath(resourcePath);
             resource.setId(resourceID);
-            if (resource.isDirectory()) {
-                deleteDirectory(resource, conn);
-            } else {
-                markDeleted(resourcePath, conn);
-                deleteResource(resource, conn);
-                //prepareToDelete(resource.getId(), conn);
-                //resourceDAO.delete(resource.getPath(), conn);
-            }
+            markDeleted(resourcePath, conn);
+            deleteResource(resource, conn);
+            //prepareToDelete(resource.getId(), conn);
+            //resourceDAO.delete(resource.getPath(), conn);
         } catch (SQLException e) {
             throw new RegistryException(e.getMessage());
         }

Modified: 
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
==============================================================================
--- 
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
      (original)
+++ 
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
      Thu Jan 17 00:01:23 2008
@@ -388,15 +388,6 @@
 
     }
 
-    public void testCollectionRename() throws Exception{
-//        Resource r1 = new Resource();
-//        registry.put("/abc/dec/xyc1", r1);
-//        registry.put("/abc/dec/xyc2", r1);
-//        registry.rename("/abc/dec" ,"/dec/abc");
-//        Resource r2 = registry.get("/dec/abc");
-//        System.out.println(r2.getContent());
-    }
-
     public void testResourceRename() throws Exception {
         Resource r1 = new Resource();
         String conent1 = "Content1";

_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev

Reply via email to