[exo-jcr-commits] exo-jcr SVN: r2660 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc: optimisation/db and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jun 18 07:04:40 EDT 2010


Author: nzamosenchuk
Date: 2010-06-18 07:04:39 -0400 (Fri, 18 Jun 2010)
New Revision: 2660

Modified:
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java
Log:
EXOJCR-758: HSSQL JDBC connection updated

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java	2010-06-18 09:26:59 UTC (rev 2659)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java	2010-06-18 11:04:39 UTC (rev 2660)
@@ -16,11 +16,19 @@
  */
 package org.exoplatform.services.jcr.impl.storage.jdbc.db;
 
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.impl.util.SecurityHelper;
 import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
 import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
 
 import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedExceptionAction;
 import java.sql.Connection;
+import java.sql.ResultSet;
 import java.sql.SQLException;
 
 /**
@@ -34,6 +42,253 @@
 public class HSQLDBMultiDbJDBCConnection extends MultiDbJDBCConnection
 {
 
+   @Override
+   protected int addNodeRecord(final NodeData data) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.addNodeRecord(data);
+         }
+      });
+   }
+
+   @Override
+   protected int addPropertyRecord(final PropertyData data) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.addPropertyRecord(data);
+         }
+      });
+   }
+
+   @Override
+   protected int addReference(final PropertyData data) throws SQLException, IOException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.addReference(data);
+         }
+      });
+   }
+
+   @Override
+   protected int addValueData(final String cid, final int orderNumber, final InputStream stream,
+      final int streamLength, final String storageDesc) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.addValueData(cid, orderNumber, stream, streamLength, storageDesc);
+
+         }
+      });
+   }
+
+   @Override
+   protected int deleteItemByIdentifier(final String identifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.deleteItemByIdentifier(identifier);
+         }
+      });
+   }
+
+   @Override
+   protected int deleteReference(final String propertyIdentifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.deleteReference(propertyIdentifier);
+
+         }
+      });
+   }
+
+   @Override
+   protected int deleteValueData(final String cid) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.deleteValueData(cid);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findChildNodesByParentIdentifier(final String parentIdentifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findChildNodesByParentIdentifier(parentIdentifier);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findChildNodesCountByParentIdentifier(final String parentIdentifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findChildNodesCountByParentIdentifier(parentIdentifier);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findChildPropertiesByParentIdentifier(final String parentIdentifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findChildPropertiesByParentIdentifier(parentIdentifier);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findItemByIdentifier(final String identifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findItemByIdentifier(identifier);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findItemByName(final String parentId, final String name, final int index) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findItemByName(parentId, name, index);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findPropertyByName(final String parentId, final String name) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findPropertyByName(parentId, name);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findReferences(final String nodeIdentifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findReferences(nodeIdentifier);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findValueByPropertyIdOrderNumber(final String cid, final int orderNumb) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findValueByPropertyIdOrderNumber(cid, orderNumb);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findValuesByPropertyId(final String cid) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findValuesByPropertyId(cid);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findValuesStorageDescriptorsByPropertyId(final String cid) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findValuesStorageDescriptorsByPropertyId(cid);
+
+         }
+      });
+   }
+
+   @Override
+   protected int renameNode(final NodeData data) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.renameNode(data);
+
+         }
+      });
+   }
+
+   @Override
+   protected int updateNodeByIdentifier(final int version, final int index, final int orderNumb, final String identifier)
+      throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.updateNodeByIdentifier(version, index, orderNumb, identifier);
+         }
+      });
+   }
+
+   @Override
+   protected int updatePropertyByIdentifier(final int version, final int type, final String identifier)
+      throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.updatePropertyByIdentifier(version, type, identifier);
+         }
+      });
+   }
+
    /**
       * HSQLDB Multidatabase JDBC Connection constructor.
       * 

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java	2010-06-18 09:26:59 UTC (rev 2659)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java	2010-06-18 11:04:39 UTC (rev 2660)
@@ -17,12 +17,19 @@
 package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
 
 import org.exoplatform.services.jcr.datamodel.IllegalNameException;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
 import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.impl.util.SecurityHelper;
 import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
 import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
 
 import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.PrivilegedExceptionAction;
 import java.sql.Connection;
+import java.sql.ResultSet;
 import java.sql.SQLException;
 
 import javax.jcr.InvalidItemStateException;
@@ -38,6 +45,297 @@
 public class HSQLDBMultiDbJDBCConnection extends MultiDbJDBCConnection
 {
 
+   @Override
+   protected int addNodeRecord(final NodeData data) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.addNodeRecord(data);
+         }
+      });
+   }
+
+   @Override
+   protected int addPropertyRecord(final PropertyData data) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.addPropertyRecord(data);
+         }
+      });
+   }
+
+   @Override
+   protected int addReference(final PropertyData data) throws SQLException, IOException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.addReference(data);
+         }
+      });
+   }
+
+   @Override
+   protected int addValueData(final String cid, final int orderNumber, final InputStream stream,
+      final int streamLength, final String storageDesc) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.addValueData(cid, orderNumber, stream, streamLength, storageDesc);
+         }
+      });
+   }
+
+   @Override
+   protected int deleteItemByIdentifier(final String identifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.deleteItemByIdentifier(identifier);
+         }
+      });
+   }
+
+   @Override
+   protected int deleteReference(final String propertyIdentifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.deleteReference(propertyIdentifier);
+         }
+      });
+   }
+
+   @Override
+   protected int deleteValueData(final String cid) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.deleteValueData(cid);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findChildNodesByParentIdentifier(final String parentIdentifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findChildNodesByParentIdentifier(parentIdentifier);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findChildNodesByParentIdentifierCQ(final String parentIdentifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findChildNodesByParentIdentifierCQ(parentIdentifier);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findChildNodesCountByParentIdentifier(final String parentIdentifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findChildNodesCountByParentIdentifier(parentIdentifier);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findChildPropertiesByParentIdentifier(final String parentIdentifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findChildPropertiesByParentIdentifier(parentIdentifier);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findChildPropertiesByParentIdentifierCQ(final String parentIdentifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findChildPropertiesByParentIdentifierCQ(parentIdentifier);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findItemByIdentifier(final String identifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findItemByIdentifier(identifier);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findItemByName(final String parentId, final String name, final int index) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findItemByName(parentId, name, index);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findItemQPathByIdentifierCQ(final String identifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findItemQPathByIdentifierCQ(identifier);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findNodeMainPropertiesByParentIdentifierCQ(final String parentIdentifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findNodeMainPropertiesByParentIdentifierCQ(parentIdentifier);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findPropertyByName(final String parentId, final String name) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findPropertyByName(parentId, name);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findReferences(final String nodeIdentifier) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findReferences(nodeIdentifier);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findValueByPropertyIdOrderNumber(final String cid, final int orderNumb) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findValueByPropertyIdOrderNumber(cid, orderNumb);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findValuesByPropertyId(final String cid) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findValuesByPropertyId(cid);
+         }
+      });
+   }
+
+   @Override
+   protected ResultSet findValuesStorageDescriptorsByPropertyId(final String cid) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
+      {
+         public ResultSet run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.findValuesStorageDescriptorsByPropertyId(cid);
+         }
+      });
+   }
+
+   @Override
+   protected int renameNode(final NodeData data) throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.renameNode(data);
+         }
+      });
+   }
+
+   @Override
+   protected int updateNodeByIdentifier(final int version, final int index, final int orderNumb, final String identifier)
+      throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.updateNodeByIdentifier(version, index, orderNumb, identifier);
+         }
+      });
+   }
+
+   @Override
+   protected int updatePropertyByIdentifier(final int version, final int type, final String identifier)
+      throws SQLException
+   {
+      return SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
+      {
+         public Integer run() throws Exception
+         {
+            return HSQLDBMultiDbJDBCConnection.super.updatePropertyByIdentifier(version, type, identifier);
+         }
+      });
+   }
+
    /**
       * HSQLDB Multidatabase JDBC Connection constructor.
       * 
@@ -88,7 +386,7 @@
       FIND_PROPERTIES_BY_PARENTID_CQ =
          "select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED,"
             + " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
-            + " where I.PARENT_ID=? and I.I_CLASS=2 order by I.NAME";      
+            + " where I.PARENT_ID=? and I.I_CLASS=2 order by I.NAME";
    }
 
    /**
@@ -98,5 +396,5 @@
    protected QPath traverseQPath(String cpid) throws SQLException, InvalidItemStateException, IllegalNameException
    {
       return traverseQPathSQ(cpid);
-   }   
+   }
 }



More information about the exo-jcr-commits mailing list