exo-jcr SVN: r2536 - jcr/tags/1.12.2-GA/exo.jcr.connectors.localadapter/src/main/rar/META-INF.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-06-10 05:48:10 -0400 (Thu, 10 Jun 2010)
New Revision: 2536
Modified:
jcr/tags/1.12.2-GA/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml
Log:
EXOJCR-753 version updated
Modified: jcr/tags/1.12.2-GA/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml
===================================================================
--- jcr/tags/1.12.2-GA/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml 2010-06-10 09:33:54 UTC (rev 2535)
+++ jcr/tags/1.12.2-GA/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml 2010-06-10 09:48:10 UTC (rev 2536)
@@ -25,7 +25,7 @@
<display-name>JCR repository</display-name>
<vendor-name>exoplatform</vendor-name>
<eis-type />
- <resourceadapter-version>1.12.2-GA-SNAPSHOT</resourceadapter-version>
+ <resourceadapter-version>1.12.2-GA</resourceadapter-version>
<license>
<license-required>false</license-required>
</license>
14 years
exo-jcr SVN: r2535 - in kernel/trunk/exo.kernel.container/src: test/java/org/exoplatform/container/configuration and 1 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-06-10 05:33:54 -0400 (Thu, 10 Jun 2010)
New Revision: 2535
Added:
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/config-manager-configuration-a.xml
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/config-manager-configuration-b.xml
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/config-manager-configuration-c.xml
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationManagerImpl.java
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/configuration/TestConfigurationManagerImpl.java
Log:
EXOJCR-745: Allow cascading imports in configuration files
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationManagerImpl.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationManagerImpl.java 2010-06-10 09:25:00 UTC (rev 2534)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationManagerImpl.java 2010-06-10 09:33:54 UTC (rev 2535)
@@ -167,32 +167,11 @@
configurations_ = conf;
else
configurations_.mergeConfiguration(conf);
- List urls = conf.getImports();
- if (urls != null)
- {
- for (int i = 0; i < urls.size(); i++)
- {
- String uri = (String)urls.get(i);
- URL urlObject = getURL(uri);
- if (urlObject != null)
- {
- if (LOG_DEBUG)
- log.info("\timport " + urlObject);
- // Set the URL of imported file
- currentURL.set(urlObject);
- conf = unmarshaller.unmarshall(urlObject);
- configurations_.mergeConfiguration(conf);
- }
- else
- {
- log.warn("Couldn't process the URL for " + uri + " configuration file ignored ");
- }
- }
- }
+ importConf(unmarshaller, conf);
}
catch (Exception ex)
{
- log.error("Cannot process the configuration " + url, ex);
+ log.error("Cannot process the configuration " + currentURL.get(), ex);
}
finally
{
@@ -200,6 +179,58 @@
}
}
+ /**
+ * Recursively import the configuration files
+ *
+ * @param unmarshaller the unmarshaller used to unmarshall the configuration file to import
+ * @param conf the configuration in which we get the list of files to import
+ * @throws Exception if an exception occurs while loading the files to import
+ */
+ private void importConf(ConfigurationUnmarshaller unmarshaller, Configuration conf) throws Exception
+ {
+ importConf(unmarshaller, conf, 1);
+ }
+
+ /**
+ * Recursively import the configuration files
+ *
+ * @param unmarshaller the unmarshaller used to unmarshall the configuration file to import
+ * @param conf the configuration in which we get the list of files to import
+ * @param depth used to log properly the URL of the file to import
+ * @throws Exception if an exception occurs while loading the files to import
+ */
+ private void importConf(ConfigurationUnmarshaller unmarshaller, Configuration conf, int depth) throws Exception
+ {
+ List urls = conf.getImports();
+ if (urls != null)
+ {
+ StringBuilder prefix = new StringBuilder(depth);
+ for (int i = 0; i < depth; i++)
+ {
+ prefix.append('\t');
+ }
+ for (int i = 0; i < urls.size(); i++)
+ {
+ String uri = (String)urls.get(i);
+ URL urlObject = getURL(uri);
+ if (urlObject != null)
+ {
+ if (LOG_DEBUG)
+ log.info(prefix + "import " + urlObject);
+ // Set the URL of imported file
+ currentURL.set(urlObject);
+ conf = unmarshaller.unmarshall(urlObject);
+ configurations_.mergeConfiguration(conf);
+ importConf(unmarshaller, conf, depth + 1);
+ }
+ else
+ {
+ log.warn("Couldn't process the URL for " + uri + " configuration file ignored ");
+ }
+ }
+ }
+ }
+
public void processRemoveConfiguration()
{
if (configurations_ == null)
Modified: kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/configuration/TestConfigurationManagerImpl.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/configuration/TestConfigurationManagerImpl.java 2010-06-10 09:25:00 UTC (rev 2534)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/configuration/TestConfigurationManagerImpl.java 2010-06-10 09:33:54 UTC (rev 2535)
@@ -18,6 +18,8 @@
import junit.framework.TestCase;
+import org.exoplatform.container.xml.Configuration;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -199,6 +201,39 @@
checkURL(url, true);
}
+ public void testImport() throws Exception
+ {
+ // no import
+ ConfigurationManager cm = new ConfigurationManagerImpl();
+ cm.addConfiguration("classpath:/org/exoplatform/container/configuration/config-manager-configuration-a.xml");
+ Configuration conf = cm.getConfiguration();
+ assertNotNull(conf.getComponent("A"));
+ assertTrue(conf.getComponent("A").getDocumentURL().getFile().endsWith("config-manager-configuration-a.xml"));
+ assertNull(conf.getComponent("B"));
+ assertNull(conf.getComponent("C"));
+
+ // b import a
+ cm = new ConfigurationManagerImpl();
+ cm.addConfiguration("classpath:/org/exoplatform/container/configuration/config-manager-configuration-b.xml");
+ conf = cm.getConfiguration();
+ assertNotNull(conf.getComponent("A"));
+ assertTrue(conf.getComponent("A").getDocumentURL().getFile().endsWith("config-manager-configuration-a.xml"));
+ assertNotNull(conf.getComponent("B"));
+ assertTrue(conf.getComponent("B").getDocumentURL().getFile().endsWith("config-manager-configuration-b.xml"));
+ assertNull(conf.getComponent("C"));
+
+ // c import b and b import a
+ cm = new ConfigurationManagerImpl();
+ cm.addConfiguration("classpath:/org/exoplatform/container/configuration/config-manager-configuration-c.xml");
+ conf = cm.getConfiguration();
+ assertNotNull(conf.getComponent("A"));
+ assertTrue(conf.getComponent("A").getDocumentURL().getFile().endsWith("config-manager-configuration-a.xml"));
+ assertNotNull(conf.getComponent("B"));
+ assertTrue(conf.getComponent("B").getDocumentURL().getFile().endsWith("config-manager-configuration-b.xml"));
+ assertNotNull(conf.getComponent("C"));
+ assertTrue(conf.getComponent("C").getDocumentURL().getFile().endsWith("config-manager-configuration-c.xml"));
+ }
+
private void checkURL(URL url) throws Exception
{
checkURL(url, false);
Added: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/config-manager-configuration-a.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/config-manager-configuration-a.xml (rev 0)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/config-manager-configuration-a.xml 2010-06-10 09:33:54 UTC (rev 2535)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+
+ <component>
+ <type>A</type>
+ </component>
+
+</configuration>
\ No newline at end of file
Added: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/config-manager-configuration-b.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/config-manager-configuration-b.xml (rev 0)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/config-manager-configuration-b.xml 2010-06-10 09:33:54 UTC (rev 2535)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+
+ <component>
+ <type>B</type>
+ </component>
+
+ <import>classpath:/org/exoplatform/container/configuration/config-manager-configuration-a.xml</import>
+</configuration>
\ No newline at end of file
Added: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/config-manager-configuration-c.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/config-manager-configuration-c.xml (rev 0)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/configuration/config-manager-configuration-c.xml 2010-06-10 09:33:54 UTC (rev 2535)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
+
+ <component>
+ <type>C</type>
+ </component>
+
+ <import>classpath:/org/exoplatform/container/configuration/config-manager-configuration-b.xml</import>
+</configuration>
\ No newline at end of file
14 years
exo-jcr SVN: r2534 - jcr/trunk/exo.jcr.connectors.localadapter/src/main/rar/META-INF.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-06-10 05:25:00 -0400 (Thu, 10 Jun 2010)
New Revision: 2534
Modified:
jcr/trunk/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml
Log:
EXOJCR-751 fix of ra.xml version
Modified: jcr/trunk/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml
===================================================================
--- jcr/trunk/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml 2010-06-10 09:11:39 UTC (rev 2533)
+++ jcr/trunk/exo.jcr.connectors.localadapter/src/main/rar/META-INF/ra.xml 2010-06-10 09:25:00 UTC (rev 2534)
@@ -25,7 +25,7 @@
<display-name>JCR repository</display-name>
<vendor-name>exoplatform</vendor-name>
<eis-type />
- <resourceadapter-version>1.12.2-GA-SNAPSHOT</resourceadapter-version>
+ <resourceadapter-version>1.12.2-GA</resourceadapter-version>
<license>
<license-required>false</license-required>
</license>
14 years
exo-jcr SVN: r2533 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr: core/security and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-06-10 05:11:39 -0400 (Thu, 10 Jun 2010)
New Revision: 2533
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/security/
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/security/JCRRuntimePermissions.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
Log:
EXOJCR-756: add JCRRuntimePermissions class
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/security/JCRRuntimePermissions.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/security/JCRRuntimePermissions.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/security/JCRRuntimePermissions.java 2010-06-10 09:11:39 UTC (rev 2533)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.core.security;
+
+/**
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
+ * @version $Id: JCRRuntimePermissions.java 111 2010-11-11 11:11:11Z tolusha $
+ */
+public class JCRRuntimePermissions
+{
+
+ public static final RuntimePermission GET_SYSTEM_SESSION_PERMISSION = new RuntimePermission("getJCRSystemSession");
+
+ public static final RuntimePermission MANAGE_REPOSITORY_PERMISSION = new RuntimePermission("manageRepository");
+
+}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-06-10 09:01:19 UTC (rev 2532)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-06-10 09:11:39 UTC (rev 2533)
@@ -27,6 +27,7 @@
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.core.WorkspaceContainerFacade;
import org.exoplatform.services.jcr.core.nodetype.ExtendedNodeTypeManager;
+import org.exoplatform.services.jcr.core.security.JCRRuntimePermissions;
import org.exoplatform.services.jcr.dataflow.PersistentDataManager;
import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener;
import org.exoplatform.services.jcr.datamodel.NodeData;
@@ -67,10 +68,6 @@
public class RepositoryImpl implements ManageableRepository
{
- private static final RuntimePermission GET_SYSTEM_SESSION_PERMISSION = new RuntimePermission("getJCRSystemSession");
-
- private static final RuntimePermission MANAGE_REPOSITORY_PERMISSION = new RuntimePermission("manageRepository");
-
/**
* Repository descriptors.
*/
@@ -164,7 +161,7 @@
SecurityManager security = System.getSecurityManager();
if (security != null)
{
- security.checkPermission(MANAGE_REPOSITORY_PERMISSION);
+ security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
}
PersistentDataManager pmanager =
@@ -201,7 +198,7 @@
SecurityManager security = System.getSecurityManager();
if (security != null)
{
- security.checkPermission(MANAGE_REPOSITORY_PERMISSION);
+ security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
}
if (isWorkspaceInitialized(wsConfig.getName()))
@@ -252,7 +249,7 @@
SecurityManager security = System.getSecurityManager();
if (security != null)
{
- security.checkPermission(MANAGE_REPOSITORY_PERMISSION);
+ security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
}
if (isWorkspaceInitialized(workspaceName))
@@ -283,7 +280,7 @@
SecurityManager security = System.getSecurityManager();
if (security != null)
{
- security.checkPermission(MANAGE_REPOSITORY_PERMISSION);
+ security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
}
return config;
@@ -362,7 +359,7 @@
SecurityManager security = System.getSecurityManager();
if (security != null)
{
- security.checkPermission(GET_SYSTEM_SESSION_PERMISSION);
+ security.checkPermission(JCRRuntimePermissions.GET_SYSTEM_SESSION_PERMISSION);
}
if (getState() == OFFLINE)
@@ -458,7 +455,7 @@
SecurityManager security = System.getSecurityManager();
if (security != null)
{
- security.checkPermission(MANAGE_REPOSITORY_PERMISSION);
+ security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
}
WorkspaceContainer workspaceContainer = null;
@@ -609,7 +606,7 @@
SecurityManager security = System.getSecurityManager();
if (security != null)
{
- security.checkPermission(MANAGE_REPOSITORY_PERMISSION);
+ security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
}
switch (state)
14 years
exo-jcr SVN: r2532 - jcr/trunk/exo.jcr.component.core.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-06-10 05:01:19 -0400 (Thu, 10 Jun 2010)
New Revision: 2532
Modified:
jcr/trunk/exo.jcr.component.core/pom.xml
Log:
EXOJCR-764 : ${env.MAVEN_OPTS} from argline removed.
Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml 2010-06-10 08:59:32 UTC (rev 2531)
+++ jcr/trunk/exo.jcr.component.core/pom.xml 2010-06-10 09:01:19 UTC (rev 2532)
@@ -374,7 +374,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>${env.MAVEN_OPTS} -Djava.security.manager -Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
+ <argLine>-Djava.security.manager -Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
<systemProperties>
<property>
<name>jcr.test.configuration.file</name>
14 years
exo-jcr SVN: r2531 - jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-06-10 04:59:32 -0400 (Thu, 10 Jun 2010)
New Revision: 2531
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
Log:
EXOJCR-392: Implemented - check all items in cache is it descendant of reordered node.
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-06-10 08:58:20 UTC (rev 2530)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-06-10 08:59:32 UTC (rev 2531)
@@ -25,6 +25,7 @@
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
+import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
@@ -902,15 +903,9 @@
.getIdentifier());
// remove from CHILD_NODES as parent
- Fqn<String> parentFqn = makeChildListFqn(childNodes, item.getIdentifier());
- Node<Serializable, Object> parent = cache.getNode(parentFqn);
- if (parent != null && parent.isLeaf())
- {
- cache.removeNode(parentFqn);
- }
+ cache.removeNode(makeChildListFqn(childNodes, item.getIdentifier()));
// remove from CHILD_NODES_LIST as parent
-
cache.removeNode(makeChildListFqn(childNodesList, item.getIdentifier()));
// remove from CHILD_PROPS as parent
@@ -1014,11 +1009,87 @@
int prevNodeIndex = prevNode.getQPath().getEntries()[prevNode.getQPath().getEntries().length - 1].getIndex();
if (nodeIndex != prevNodeIndex)
{
- updateTreePath(node.getIdentifier(), node.getQPath(), null); // don't change ACL, it's same parent
+ // its a samename reordering
+ updateTreePath(prevNode.getQPath(), node.getQPath(), null); // don't change ACL, it's same parent
}
}
/**
+ * Check all items in cache - is it descendant of prevRootPath, and update path according newRootPath.
+ *
+ * @param prevRootPath
+ * @param newRootPath
+ * @param acl
+ */
+ protected void updateTreePath(final QPath prevRootPath, final QPath newRootPath, final AccessControlList acl)
+ {
+ boolean inheritACL = acl != null;
+
+ // check all ITEMS in cache
+ Node<Serializable, Object> items = cache.getNode(itemsRoot);
+ Set<Object> childrenNames = items.getChildrenNames();
+ Iterator<Object> namesIt = childrenNames.iterator();
+
+ while (namesIt.hasNext())
+ {
+ String id = (String)namesIt.next();
+ ItemData data = (ItemData)cache.get(makeItemFqn(id), ITEM_DATA);
+
+ // check is this descendant of prevRootPath
+ QPath nodeQPath = data.getQPath();
+ if (nodeQPath.isDescendantOf(prevRootPath))
+ {
+
+ //make relative path
+ QPathEntry[] relativePath = null;
+ try
+ {
+ relativePath = nodeQPath.getRelPath(nodeQPath.getDepth() - prevRootPath.getDepth());
+ }
+ catch (IllegalPathException e)
+ {
+ // Do nothing. Never happens.
+ }
+
+ // make new path - no matter node or property
+ QPath newPath = QPath.makeChildPath(newRootPath, relativePath);
+
+ if (data.isNode())
+ {
+ // update node
+
+ NodeData prevNode = (NodeData)data;
+
+ TransientNodeData newNode =
+ new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(), prevNode
+ .getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
+ .getParentIdentifier(), inheritACL ? acl : prevNode.getACL()); // TODO check ACL
+ // update this node
+ cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
+ }
+ else
+ {
+ //update property
+
+ PropertyData prevProp = (PropertyData)data;
+
+ if (inheritACL
+ && (prevProp.getQPath().getName().equals(Constants.EXO_PERMISSIONS) || prevProp.getQPath().getName()
+ .equals(Constants.EXO_OWNER)))
+ {
+ inheritACL = false;
+ }
+
+ TransientPropertyData newProp =
+ new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(), prevProp
+ .getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
+ cache.put(makeItemFqn(newProp.getIdentifier()), ITEM_DATA, newProp);
+ }
+ }
+ }
+ }
+
+ /**
* Update Nodes tree with new path.
*
* @param parentId String - root node id of JCR subtree.
14 years
exo-jcr SVN: r2530 - in jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr: impl/core and 1 other directory.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-06-10 04:58:20 -0400 (Thu, 10 Jun 2010)
New Revision: 2530
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPathEntry.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
Log:
EXOJCR-766: QPathEntry - equals() method added
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java 2010-06-10 08:41:16 UTC (rev 2529)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java 2010-06-10 08:58:20 UTC (rev 2530)
@@ -176,7 +176,7 @@
for (int i = 0; i < ancestorNames.length; i++)
{
- if (!ancestorNames[i].equals(names[i]))
+ if (!names[i].equals(ancestorNames[i]))
return false;
}
return true;
@@ -239,7 +239,7 @@
}
/**
- * @return last name of this path
+ * @return last QPathEntry of this path
*/
public InternalQName getName()
{
@@ -247,7 +247,7 @@
}
/**
- * @return index
+ * @return index of last QPathEntry of this paths
*/
public int getIndex()
{
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPathEntry.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPathEntry.java 2010-06-10 08:41:16 UTC (rev 2529)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPathEntry.java 2010-06-10 08:58:20 UTC (rev 2530)
@@ -158,4 +158,18 @@
return getAsString(true);
}
+ @Override
+ public boolean equals(Object o)
+ {
+ boolean result = super.equals(o);
+
+ if (result == true && (o instanceof QPathEntry))
+ {
+ return result && (index == ((QPathEntry)o).getIndex());
+ }
+ else
+ {
+ return result;
+ }
+ }
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-06-10 08:41:16 UTC (rev 2529)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-06-10 08:58:20 UTC (rev 2530)
@@ -2393,18 +2393,14 @@
NodeData nodeData = siblings.get(i);
if (srcInd == -1)
{
- if (nodeData.getQPath().getName().equals(srcPath.getName())
- && (nodeData.getQPath().getIndex() == srcPath.getIndex() || srcPath.getIndex() == 0
- && nodeData.getQPath().getIndex() == 1))
+ if (nodeData.getQPath().getName().equals(srcPath.getName()))
{
srcInd = i;
}
}
if (destPath != null && destInd == -1)
{
- if (nodeData.getQPath().getName().equals(destPath.getName())
- && (nodeData.getQPath().getIndex() == destPath.getIndex() || destPath.getIndex() == 0
- && nodeData.getQPath().getIndex() == 1))
+ if (nodeData.getQPath().getName().equals(destPath.getName()))
{
destInd = i;
if (srcInd != -1)
@@ -2466,7 +2462,7 @@
NodeData sdata = siblings.get(j);
// calculating same name index
- if (sdata.getQPath().getName().equals(srcPath.getName()))
+ if (sdata.getQPath().getName().getAsString().equals(srcPath.getName().getAsString()))
++sameNameIndex;
// skeep unchanged
@@ -2475,7 +2471,8 @@
NodeData newData = sdata;
// change same name index
- if (sdata.getQPath().getName().equals(srcPath.getName()) && sdata.getQPath().getIndex() != sameNameIndex)
+ if (sdata.getQPath().getName().getAsString().equals(srcPath.getName().getAsString())
+ && sdata.getQPath().getIndex() != sameNameIndex)
{
// update with new index
QPath siblingPath =
14 years
exo-jcr SVN: r2529 - in jcr/trunk/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/impl/core/security and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-06-10 04:41:16 -0400 (Thu, 10 Jun 2010)
New Revision: 2529
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/TestSecurityRepositoryManagment.java
Removed:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/TestGetSystemSession.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
Log:
EXOJCR-778: Protect the main methods of a repository since they are critical: addItemPersistenceListener, configWorkspace, createWorkspace, internalRemoveWorkspace, setState, getConfiguration.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-06-09 14:10:00 UTC (rev 2528)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-06-10 08:41:16 UTC (rev 2529)
@@ -69,6 +69,8 @@
private static final RuntimePermission GET_SYSTEM_SESSION_PERMISSION = new RuntimePermission("getJCRSystemSession");
+ private static final RuntimePermission MANAGE_REPOSITORY_PERMISSION = new RuntimePermission("manageRepository");
+
/**
* Repository descriptors.
*/
@@ -158,6 +160,13 @@
*/
public void addItemPersistenceListener(String workspaceName, ItemsPersistenceListener listener)
{
+ // Need privileges to manage repository.
+ SecurityManager security = System.getSecurityManager();
+ if (security != null)
+ {
+ security.checkPermission(MANAGE_REPOSITORY_PERMISSION);
+ }
+
PersistentDataManager pmanager =
(PersistentDataManager)repositoryContainer.getWorkspaceContainer(workspaceName).getComponentInstanceOfType(
PersistentDataManager.class);
@@ -188,6 +197,13 @@
*/
public void configWorkspace(WorkspaceEntry wsConfig) throws RepositoryConfigurationException, RepositoryException
{
+ // Need privileges to manage repository.
+ SecurityManager security = System.getSecurityManager();
+ if (security != null)
+ {
+ security.checkPermission(MANAGE_REPOSITORY_PERMISSION);
+ }
+
if (isWorkspaceInitialized(wsConfig.getName()))
{
throw new RepositoryConfigurationException("Workspace '" + wsConfig.getName()
@@ -232,6 +248,12 @@
*/
public synchronized void createWorkspace(String workspaceName) throws RepositoryException
{
+ // Need privileges to manage repository.
+ SecurityManager security = System.getSecurityManager();
+ if (security != null)
+ {
+ security.checkPermission(MANAGE_REPOSITORY_PERMISSION);
+ }
if (isWorkspaceInitialized(workspaceName))
{
@@ -257,6 +279,13 @@
*/
public RepositoryEntry getConfiguration()
{
+ // Need privileges to manage repository.
+ SecurityManager security = System.getSecurityManager();
+ if (security != null)
+ {
+ security.checkPermission(MANAGE_REPOSITORY_PERMISSION);
+ }
+
return config;
}
@@ -425,6 +454,13 @@
*/
public void internalRemoveWorkspace(String workspaceName) throws RepositoryException
{
+ // Need privileges to manage repository.
+ SecurityManager security = System.getSecurityManager();
+ if (security != null)
+ {
+ security.checkPermission(MANAGE_REPOSITORY_PERMISSION);
+ }
+
WorkspaceContainer workspaceContainer = null;
if (isWorkspaceInitialized(workspaceName))
{
@@ -569,6 +605,13 @@
*/
public void setState(int state)
{
+ // Need privileges to manage repository.
+ SecurityManager security = System.getSecurityManager();
+ if (security != null)
+ {
+ security.checkPermission(MANAGE_REPOSITORY_PERMISSION);
+ }
+
switch (state)
{
case ONLINE :
Deleted: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/TestGetSystemSession.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/TestGetSystemSession.java 2010-06-09 14:10:00 UTC (rev 2528)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/TestGetSystemSession.java 2010-06-10 08:41:16 UTC (rev 2529)
@@ -1,83 +0,0 @@
-/**
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.services.jcr.impl.core.security;
-
-import java.security.AccessControlException;
-import java.security.PrivilegedExceptionAction;
-
-/**
- * @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
- * @version $Id$
- */
-public class TestGetSystemSession extends BaseSecurityTest
-{
- public void testGetSystemSessionSuccess()
- {
- PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
- {
- public Object run() throws Exception
- {
- repository.getSystemSession();
- return null;
- }
-
- };
- try
- {
- doPrivilegedActionStaticPermissions(action);
- }
- catch (AccessControlException ace)
- {
- fail("Must be able get system session. We are under static permissions");
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail();
- }
- }
-
- public void testGetSystemSessionFail()
- {
- PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
- {
- public Object run() throws Exception
- {
- repository.getSystemSession();
- return null;
- }
-
- };
- try
- {
- doPrivilegedAction(action);
- fail("Must not be able get system session.");
- }
- catch (AccessControlException ace)
- {
- // OK
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail();
- }
- }
-}
Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/TestSecurityRepositoryManagment.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/TestSecurityRepositoryManagment.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/TestSecurityRepositoryManagment.java 2010-06-10 08:41:16 UTC (rev 2529)
@@ -0,0 +1,431 @@
+/**
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.jcr.impl.core.security;
+
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.core.ManageableRepository;
+import org.exoplatform.services.jcr.impl.dataflow.serialization.TesterItemsPersistenceListener;
+
+import java.security.AccessControlException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
+ * @version $Id: TestGetSystemSession.java 2521 2010-06-09 11:50:54Z nzamosenchuk $
+ */
+public class TestSecurityRepositoryManagment extends BaseSecurityTest
+{
+ private static String testWorkspaceName = "testWorkspace";
+
+ public void testGetSystemSessionSuccess()
+ {
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ repository.getSystemSession();
+ return null;
+ }
+
+ };
+ try
+ {
+ doPrivilegedActionStaticPermissions(action);
+ }
+ catch (AccessControlException ace)
+ {
+ fail("Must be able get system session. We are under static permissions");
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testGetSystemSessionFail()
+ {
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ repository.getSystemSession();
+ return null;
+ }
+
+ };
+ try
+ {
+ doPrivilegedAction(action);
+ fail("Must not be able get system session.");
+ }
+ catch (AccessControlException ace)
+ {
+ // OK
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testAddItemPersistenceListenerSuccess()
+ {
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ repository.addItemPersistenceListener(workspace.getName(), new TesterItemsPersistenceListener(session));
+ return null;
+ }
+
+ };
+ try
+ {
+ doPrivilegedActionStaticPermissions(action);
+ }
+ catch (AccessControlException ace)
+ {
+ fail("Must be able add listener. We are under static permissions");
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testAddItemPersistenceListenerFail()
+ {
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ repository.addItemPersistenceListener(workspace.getName(), new TesterItemsPersistenceListener(session));
+ return null;
+ }
+
+ };
+ try
+ {
+ doPrivilegedAction(action);
+ fail("Must not be able add listener.");
+ }
+ catch (AccessControlException ace)
+ {
+ // OK
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testConfigWorkspaceSuccess()
+ {
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ WorkspaceEntry defConfig =
+ (WorkspaceEntry)session.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
+
+ WorkspaceEntry wsConfig = new WorkspaceEntry();
+ wsConfig.setName(testWorkspaceName);
+
+ wsConfig.setAccessManager(defConfig.getAccessManager());
+ wsConfig.setCache(defConfig.getCache());
+ wsConfig.setContainer(defConfig.getContainer());
+ wsConfig.setLockManager(defConfig.getLockManager());
+
+ repository.configWorkspace(wsConfig);
+ return null;
+ }
+
+ };
+ try
+ {
+ doPrivilegedActionStaticPermissions(action);
+ }
+ catch (AccessControlException ace)
+ {
+ fail("Must be able config workspace. We are under static permissions");
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testConfigWorkspaceFail()
+ {
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ WorkspaceEntry defConfig =
+ (WorkspaceEntry)session.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
+
+ WorkspaceEntry wsConfig = new WorkspaceEntry();
+ wsConfig.setName(testWorkspaceName);
+
+ wsConfig.setAccessManager(defConfig.getAccessManager());
+ wsConfig.setCache(defConfig.getCache());
+ wsConfig.setContainer(defConfig.getContainer());
+ wsConfig.setLockManager(defConfig.getLockManager());
+
+ repository.configWorkspace(wsConfig);
+ return null;
+ }
+
+ };
+ try
+ {
+ doPrivilegedAction(action);
+ fail("Must not be able config workspace.");
+ }
+ catch (AccessControlException ace)
+ {
+ // OK
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testCreateWorkspaceSuccess()
+ {
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ repository.createWorkspace(testWorkspaceName);
+ return null;
+ }
+
+ };
+ try
+ {
+ doPrivilegedActionStaticPermissions(action);
+ }
+ catch (AccessControlException ace)
+ {
+ fail("Must be able create workspace. We are under static permissions");
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testCreateWorkspaceFail()
+ {
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ repository.createWorkspace(testWorkspaceName);
+ return null;
+ }
+
+ };
+ try
+ {
+ doPrivilegedAction(action);
+ fail("Must not be able create workspace.");
+ }
+ catch (AccessControlException ace)
+ {
+ // OK
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testInternalRemoveWorkspaceSuccess()
+ {
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ repository.internalRemoveWorkspace(testWorkspaceName);
+ return null;
+ }
+
+ };
+ try
+ {
+ doPrivilegedActionStaticPermissions(action);
+ }
+ catch (AccessControlException ace)
+ {
+ fail("Must be able remove workspace. We are under static permissions");
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testInternalRemoveWorkspaceFail()
+ {
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ repository.internalRemoveWorkspace(testWorkspaceName);
+ return null;
+ }
+
+ };
+ try
+ {
+ doPrivilegedAction(action);
+ fail("Must not be able remove workspace.");
+ }
+ catch (AccessControlException ace)
+ {
+ // OK
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testSetStateeSuccess()
+ {
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ repository.setState(ManageableRepository.OFFLINE);
+ repository.setState(ManageableRepository.ONLINE);
+ return null;
+ }
+
+ };
+ try
+ {
+ doPrivilegedActionStaticPermissions(action);
+ }
+ catch (AccessControlException ace)
+ {
+ fail("Must be able set state. We are under static permissions");
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testSetStateFail()
+ {
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ repository.setState(ManageableRepository.OFFLINE);
+ repository.setState(ManageableRepository.ONLINE);
+ return null;
+ }
+
+ };
+ try
+ {
+ doPrivilegedAction(action);
+ fail("Must not be able set state.");
+ }
+ catch (AccessControlException ace)
+ {
+ // OK
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testGetConfigurationSuccess()
+ {
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ repository.getConfiguration();
+ return null;
+ }
+
+ };
+ try
+ {
+ doPrivilegedActionStaticPermissions(action);
+ }
+ catch (AccessControlException ace)
+ {
+ fail("Must be able get configuration. We are under static permissions");
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ public void testGetConfigurationFail()
+ {
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ repository.getConfiguration();
+ return null;
+ }
+
+ };
+ try
+ {
+ doPrivilegedAction(action);
+ fail("Must not be able get configuration.");
+ }
+ catch (AccessControlException ace)
+ {
+ // OK
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail();
+ }
+ }
+}
14 years
exo-jcr SVN: r2528 - core/trunk/exo.core.component.security.core/src/main/java/org/exoplatform/services/security.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-06-09 10:10:00 -0400 (Wed, 09 Jun 2010)
New Revision: 2528
Modified:
core/trunk/exo.core.component.security.core/src/main/java/org/exoplatform/services/security/Identity.java
Log:
EXOJCR-770 : Fix "SecureSet" subclass.
Modified: core/trunk/exo.core.component.security.core/src/main/java/org/exoplatform/services/security/Identity.java
===================================================================
--- core/trunk/exo.core.component.security.core/src/main/java/org/exoplatform/services/security/Identity.java 2010-06-09 13:48:33 UTC (rev 2527)
+++ core/trunk/exo.core.component.security.core/src/main/java/org/exoplatform/services/security/Identity.java 2010-06-09 14:10:00 UTC (rev 2528)
@@ -151,6 +151,7 @@
/**
* @deprecated for back compatibility.
*/
+ @Deprecated
public void setMemberships(Collection<MembershipEntry> memberships)
{
this.memberships = new SecureSet<MembershipEntry>(memberships);
@@ -242,6 +243,7 @@
throw new NullPointerException();
}
checkPermission();
+ set.addAll(elements);
return elements.size() > 0;
}
@@ -261,11 +263,13 @@
return set.containsAll(coll);
}
+ @Override
public boolean equals(Object o)
{
return o == this || set.equals(o);
}
+ @Override
public int hashCode()
{
return set.hashCode();
@@ -341,6 +345,7 @@
return set.toArray(a);
}
+ @Override
public String toString()
{
return set.toString();
14 years
exo-jcr SVN: r2527 - in jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: storage/jdbc and 7 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-06-09 09:48:33 -0400 (Wed, 09 Jun 2010)
New Revision: 2527
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/update/StorageUpdateManager.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
Log:
EXOJCR-754: close Statements & ResultSets
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-06-09 13:47:50 UTC (rev 2526)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-06-09 13:48:33 UTC (rev 2527)
@@ -34,6 +34,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -226,25 +227,52 @@
try
{
Connection con = openConnection();
- if (isDbInitialized(con))
+ ResultSet res = null;
+ PreparedStatement ps = null;
+ try
{
- // check that data exists
- PreparedStatement ps = con.prepareStatement("SELECT COUNT(*) FROM " + configTableName + " WHERE NAME=?");
- try
+ if (isDbInitialized(con))
{
+ // check that data exists
+ ps = con.prepareStatement("SELECT COUNT(*) FROM " + configTableName + " WHERE NAME=?");
+
ps.setString(1, CONFIGNAME);
- ResultSet res = ps.executeQuery();
+ res = ps.executeQuery();
if (res.next())
{
return res.getInt(1) > 0;
}
}
- finally
+ return false;
+ }
+ finally
+ {
+ if (res != null)
{
- con.close();
+ try
+ {
+ res.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
+
+ if (ps != null)
+ {
+ try
+ {
+ ps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
+ con.close();
}
- return false;
}
catch (final SQLException e)
{
@@ -264,14 +292,16 @@
try
{
Connection con = openConnection();
+ ResultSet res = null;
+ PreparedStatement ps = null;
try
{
if (isDbInitialized(con))
{
- PreparedStatement ps = con.prepareStatement("SELECT * FROM " + configTableName + " WHERE NAME=?");
+ ps = con.prepareStatement("SELECT * FROM " + configTableName + " WHERE NAME=?");
ps.setString(1, CONFIGNAME);
- ResultSet res = ps.executeQuery();
+ res = ps.executeQuery();
if (res.next())
{
@@ -281,7 +311,6 @@
else
throw new ConfigurationNotFoundException("No configuration data is found in database. Source name "
+ sourceName);
-
}
else
throw new ConfigurationNotInitializedException(
@@ -290,6 +319,30 @@
}
finally
{
+ if (res != null)
+ {
+ try
+ {
+ res.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (ps != null)
+ {
+ try
+ {
+ ps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
con.close();
}
}
@@ -316,6 +369,7 @@
try
{
Connection con = openConnection();
+ PreparedStatement ps = null;
try
{
@@ -324,7 +378,9 @@
if (!isDbInitialized(con))
{
// init db
- con.createStatement().executeUpdate(sql = initSQL);
+ Statement st = con.createStatement();
+ st.executeUpdate(sql = initSQL);
+ st.close();
con.commit();
con.close();
@@ -336,9 +392,6 @@
if (isDbInitialized(con))
{
-
- PreparedStatement ps = null;
-
ConfigDataHolder config = new ConfigDataHolder(confData);
if (hasConfig())
@@ -372,6 +425,18 @@
}
finally
{
+ if (ps != null)
+ {
+ try
+ {
+ ps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
con.close();
}
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-06-09 13:47:50 UTC (rev 2526)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-06-09 13:48:33 UTC (rev 2527)
@@ -330,6 +330,8 @@
checkIfOpened();
try
{
+ closeStatements();
+
if (!this.readOnly)
{
dbConnection.rollback();
@@ -386,156 +388,163 @@
*
* @throws SQLException
*/
- protected void closeStatements() throws SQLException
+ protected void closeStatements()
{
- if (findItemById != null)
+ try
{
- findItemById.close();
- }
+ if (findItemById != null)
+ {
+ findItemById.close();
+ }
- if (findItemByPath != null)
- {
- findItemByPath.close();
- }
+ if (findItemByPath != null)
+ {
+ findItemByPath.close();
+ }
- if (findItemByName != null)
- {
- findItemByName.close();
- }
+ if (findItemByName != null)
+ {
+ findItemByName.close();
+ }
- if (findChildPropertyByPath != null)
- {
- findChildPropertyByPath.close();
- }
+ if (findChildPropertyByPath != null)
+ {
+ findChildPropertyByPath.close();
+ }
- if (findPropertyByName != null)
- {
- findPropertyByName.close();
- }
+ if (findPropertyByName != null)
+ {
+ findPropertyByName.close();
+ }
- if (findDescendantNodes != null)
- {
- findDescendantNodes.close();
- }
+ if (findDescendantNodes != null)
+ {
+ findDescendantNodes.close();
+ }
- if (findDescendantProperties != null)
- {
- findDescendantProperties.close();
- }
+ if (findDescendantProperties != null)
+ {
+ findDescendantProperties.close();
+ }
- if (findReferences != null)
- {
- findReferences.close();
- }
+ if (findReferences != null)
+ {
+ findReferences.close();
+ }
- if (findValuesByPropertyId != null)
- {
- findValuesByPropertyId.close();
- }
+ if (findValuesByPropertyId != null)
+ {
+ findValuesByPropertyId.close();
+ }
- if (findValuesStorageDescriptorsByPropertyId != null)
- {
- findValuesStorageDescriptorsByPropertyId.close();
- }
+ if (findValuesStorageDescriptorsByPropertyId != null)
+ {
+ findValuesStorageDescriptorsByPropertyId.close();
+ }
- if (findValuesDataByPropertyId != null)
- {
- findValuesDataByPropertyId.close();
- }
+ if (findValuesDataByPropertyId != null)
+ {
+ findValuesDataByPropertyId.close();
+ }
- if (findValueByPropertyIdOrderNumber != null)
- {
- findValueByPropertyIdOrderNumber.close();
- }
+ if (findValueByPropertyIdOrderNumber != null)
+ {
+ findValueByPropertyIdOrderNumber.close();
+ }
- if (findNodesByParentId != null)
- {
- findNodesByParentId.close();
- }
+ if (findNodesByParentId != null)
+ {
+ findNodesByParentId.close();
+ }
- if (findNodesCountByParentId != null)
- {
- findNodesCountByParentId.close();
- }
+ if (findNodesCountByParentId != null)
+ {
+ findNodesCountByParentId.close();
+ }
- if (findPropertiesByParentId != null)
- {
- findPropertiesByParentId.close();
- }
+ if (findPropertiesByParentId != null)
+ {
+ findPropertiesByParentId.close();
+ }
- if (insertItem != null)
- {
- insertItem.close();
- }
+ if (insertItem != null)
+ {
+ insertItem.close();
+ }
- if (insertNode != null)
- {
- insertNode.close();
- }
+ if (insertNode != null)
+ {
+ insertNode.close();
+ }
- if (insertProperty != null)
- {
- insertProperty.close();
- }
+ if (insertProperty != null)
+ {
+ insertProperty.close();
+ }
- if (insertReference != null)
- {
- insertReference.close();
- }
+ if (insertReference != null)
+ {
+ insertReference.close();
+ }
- if (insertValue != null)
- {
- insertValue.close();
- }
+ if (insertValue != null)
+ {
+ insertValue.close();
+ }
- if (updateItem != null)
- {
- updateItem.close();
- }
+ if (updateItem != null)
+ {
+ updateItem.close();
+ }
- if (updateItemPath != null)
- {
- updateItemPath.close();
- }
+ if (updateItemPath != null)
+ {
+ updateItemPath.close();
+ }
- if (updateNode != null)
- {
- updateNode.close();
- }
+ if (updateNode != null)
+ {
+ updateNode.close();
+ }
- if (updateProperty != null)
- {
- updateProperty.close();
- }
+ if (updateProperty != null)
+ {
+ updateProperty.close();
+ }
- if (deleteItem != null)
- {
- deleteItem.close();
- }
+ if (deleteItem != null)
+ {
+ deleteItem.close();
+ }
- if (deleteNode != null)
- {
- deleteNode.close();
- }
+ if (deleteNode != null)
+ {
+ deleteNode.close();
+ }
- if (deleteProperty != null)
- {
- deleteProperty.close();
- }
+ if (deleteProperty != null)
+ {
+ deleteProperty.close();
+ }
- if (deleteReference != null)
- {
- deleteReference.close();
- }
+ if (deleteReference != null)
+ {
+ deleteReference.close();
+ }
- if (deleteValue != null)
- {
- deleteValue.close();
+ if (deleteValue != null)
+ {
+ deleteValue.close();
+ }
+
+ if (renameNode != null)
+ {
+ renameNode.close();
+ }
}
-
- if (renameNode != null)
+ catch (SQLException e)
{
- renameNode.close();
+ LOG.error("Can't close the statement: " + e);
}
}
@@ -547,6 +556,8 @@
checkIfOpened();
try
{
+ closeStatements();
+
if (!this.readOnly)
{
dbConnection.commit();
@@ -877,13 +888,27 @@
try
{
ResultSet node = findChildNodesByParentIdentifier(getInternalId(parent.getIdentifier()));
- List<NodeData> childrens = new ArrayList<NodeData>();
- while (node.next())
+ try
{
- childrens.add((NodeData)itemData(parent.getQPath(), node, I_CLASS_NODE, parent.getACL()));
+ List<NodeData> childrens = new ArrayList<NodeData>();
+ while (node.next())
+ {
+ childrens.add((NodeData)itemData(parent.getQPath(), node, I_CLASS_NODE, parent.getACL()));
+ }
+
+ return childrens;
}
-
- return childrens;
+ finally
+ {
+ try
+ {
+ node.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException e)
{
@@ -904,13 +929,28 @@
try
{
ResultSet count = findChildNodesCountByParentIdentifier(getInternalId(parent.getIdentifier()));
- if (count.next())
+ try
{
- return count.getInt(1);
+ if (count.next())
+ {
+ return count.getInt(1);
+ }
+ else
+ {
+ throw new RepositoryException("FATAL No resulton childNodes count for "
+ + parent.getQPath().getAsString());
+ }
}
- else
+ finally
{
- throw new RepositoryException("FATAL No resulton childNodes count for " + parent.getQPath().getAsString());
+ try
+ {
+ count.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
catch (SQLException e)
@@ -928,11 +968,25 @@
try
{
ResultSet prop = findChildPropertiesByParentIdentifier(getInternalId(parent.getIdentifier()));
- List<PropertyData> children = new ArrayList<PropertyData>();
- while (prop.next())
- children.add((PropertyData)itemData(parent.getQPath(), prop, I_CLASS_PROPERTY, null));
+ try
+ {
+ List<PropertyData> children = new ArrayList<PropertyData>();
+ while (prop.next())
+ children.add((PropertyData)itemData(parent.getQPath(), prop, I_CLASS_PROPERTY, null));
- return children;
+ return children;
+ }
+ finally
+ {
+ try
+ {
+ prop.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException e)
{
@@ -953,11 +1007,25 @@
try
{
ResultSet prop = findChildPropertiesByParentIdentifier(getInternalId(parent.getIdentifier()));
- List<PropertyData> children = new ArrayList<PropertyData>();
- while (prop.next())
- children.add(propertyData(parent.getQPath(), prop));
+ try
+ {
+ List<PropertyData> children = new ArrayList<PropertyData>();
+ while (prop.next())
+ children.add(propertyData(parent.getQPath(), prop));
- return children;
+ return children;
+ }
+ finally
+ {
+ try
+ {
+ prop.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException e)
{
@@ -998,12 +1066,26 @@
try
{
ResultSet refProps = findReferences(getInternalId(nodeIdentifier));
- List<PropertyData> references = new ArrayList<PropertyData>();
- while (refProps.next())
+ try
{
- references.add((PropertyData)itemData(null, refProps, I_CLASS_PROPERTY, null));
+ List<PropertyData> references = new ArrayList<PropertyData>();
+ while (refProps.next())
+ {
+ references.add((PropertyData)itemData(null, refProps, I_CLASS_PROPERTY, null));
+ }
+ return references;
}
- return references;
+ finally
+ {
+ try
+ {
+ refProps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException e)
{
@@ -1038,13 +1120,20 @@
return valueRecord.wasNull() ? readValueData(cid, orderNumb, persistedVersion, valueRecord
.getBinaryStream(COLUMN_VDATA)) : readValueData(propertyId, orderNumb, storageId);
}
+
+ return null;
}
finally
{
- valueRecord.close();
+ try
+ {
+ valueRecord.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
-
- return null;
}
catch (SQLException e)
{
@@ -1072,15 +1161,28 @@
protected ItemData getItemByIdentifier(String cid) throws RepositoryException, IllegalStateException
{
checkIfOpened();
- ResultSet item = null;
try
{
- item = findItemByIdentifier(cid);
- if (item.next())
+ ResultSet item = findItemByIdentifier(cid);
+ try
{
- return itemData(null, item, item.getInt(COLUMN_CLASS), null);
+ if (item.next())
+ {
+ return itemData(null, item, item.getInt(COLUMN_CLASS), null);
+ }
+ return null;
}
- return null;
+ finally
+ {
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException e)
{
@@ -1090,18 +1192,6 @@
{
throw new RepositoryException("getItemData() error", e);
}
- finally
- {
- try
- {
- if (item != null)
- item.close();
- }
- catch (SQLException e)
- {
- LOG.error("getItemData() Error close resultset " + e.getMessage());
- }
- }
}
/**
@@ -1123,13 +1213,26 @@
IllegalStateException
{
checkIfOpened();
- ResultSet item = null;
try
{
- item = findItemByName(parentId, name.getAsString(), name.getIndex());
- if (item.next())
- return itemData(parent.getQPath(), item, item.getInt(COLUMN_CLASS), parent.getACL());
- return null;
+ ResultSet item = findItemByName(parentId, name.getAsString(), name.getIndex());
+ try
+ {
+ if (item.next())
+ return itemData(parent.getQPath(), item, item.getInt(COLUMN_CLASS), parent.getACL());
+ return null;
+ }
+ finally
+ {
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (SQLException e)
{
@@ -1139,18 +1242,6 @@
{
throw new RepositoryException(e);
}
- finally
- {
- try
- {
- if (item != null)
- item.close();
- }
- catch (SQLException e)
- {
- LOG.error("getItemData() Error close resultset " + e.getMessage());
- }
- }
}
/**
@@ -1183,10 +1274,9 @@
String caid = cpid; // container ancestor id
do
{
- ResultSet parent = null;
+ ResultSet parent = findItemByIdentifier(caid);
try
{
- parent = findItemByIdentifier(caid);
if (!parent.next())
throw new InvalidItemStateException("Parent not found, uuid: " + getIdentifier(caid));
@@ -1197,7 +1287,14 @@
}
finally
{
- parent.close();
+ try
+ {
+ parent.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
while (!caid.equals(Constants.ROOT_PARENT_UUID));
@@ -1296,7 +1393,14 @@
}
finally
{
- pidrs.close();
+ try
+ {
+ pidrs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
@@ -1426,6 +1530,7 @@
{
List<QPathEntry> qrpath = new ArrayList<QPathEntry>(); // reverted path
PreparedStatement cstmt = null;
+ ResultSet parent = null;
try
{
cstmt =
@@ -1433,7 +1538,7 @@
.prepareStatement("select * from get_qpath(?) AS (id varchar, name varchar, parent_id varchar, i_index int)");
cstmt.setString(1, cpid);
// cstmt.setString(2, caid);
- ResultSet parent = cstmt.executeQuery();
+ parent = cstmt.executeQuery();
while (parent.next())
{
@@ -1445,9 +1550,22 @@
// parent = findItemByIdentifier(caid);
if (qrpath.size() <= 0)
throw new InvalidItemStateException("Parent not found, uuid: " + getIdentifier(cpid));
+
}
finally
{
+ if (parent != null)
+ {
+ try
+ {
+ parent.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
if (cstmt != null)
cstmt.close();
}
@@ -1706,7 +1824,14 @@
}
finally
{
- mtrs.close();
+ try
+ {
+ mtrs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
@@ -1745,7 +1870,14 @@
}
finally
{
- exoPerm.close();
+ try
+ {
+ exoPerm.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
@@ -1772,7 +1904,14 @@
}
finally
{
- exoOwner.close();
+ try
+ {
+ exoOwner.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
@@ -1833,10 +1972,10 @@
}
}
+ // PRIMARY
+ ResultSet ptProp = findPropertyByName(cid, Constants.JCR_PRIMARYTYPE.getAsString());
try
{
- // PRIMARY
- ResultSet ptProp = findPropertyByName(cid, Constants.JCR_PRIMARYTYPE.getAsString());
if (!ptProp.next())
throw new PrimaryTypeNotFoundException("FATAL ERROR primary type record not found. Node "
@@ -1914,6 +2053,17 @@
throw new RepositoryException("FATAL ERROR Node " + getIdentifier(cid) + " " + qpath.getAsString()
+ " has wrong formed ACL. ", e);
}
+ finally
+ {
+ try
+ {
+ ptProp.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
catch (IllegalNameException e)
{
@@ -2020,7 +2170,14 @@
}
finally
{
- valueRecords.close();
+ try
+ {
+ valueRecords.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
@@ -2062,7 +2219,14 @@
}
finally
{
- valueRecords.close();
+ try
+ {
+ valueRecords.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
return data;
@@ -2119,8 +2283,6 @@
throws SQLException, IOException
{
- ResultSet valueResultSet = null;
-
byte[] buffer = new byte[0];
byte[] spoolBuffer = new byte[ValueFileIOHelper.IOBUFFER_SIZE];
int read;
@@ -2170,8 +2332,6 @@
}
finally
{
- if (valueResultSet != null)
- valueResultSet.close();
if (out != null)
{
out.close();
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java 2010-06-09 13:47:50 UTC (rev 2526)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLMultiDbJDBCConnection.java 2010-06-09 13:48:33 UTC (rev 2527)
@@ -85,7 +85,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addNodeRecord(data);
@@ -108,7 +115,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addPropertyRecord(data);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java 2010-06-09 13:47:50 UTC (rev 2526)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLSingleDbJDBCConnection.java 2010-06-09 13:48:33 UTC (rev 2527)
@@ -85,7 +85,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addNodeRecord(data);
@@ -108,7 +115,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addPropertyRecord(data);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java 2010-06-09 13:47:50 UTC (rev 2526)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java 2010-06-09 13:48:33 UTC (rev 2527)
@@ -22,6 +22,7 @@
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
/**
* Created by The eXo Platform SAS
@@ -68,14 +69,16 @@
protected boolean isSequenceExists(Connection conn, String sequenceName) throws SQLException
{
String seqName = sequenceName.toUpperCase().toLowerCase();
+ ResultSet srs = null;
+ Statement st = null;
try
{
- ResultSet srs = conn.createStatement().executeQuery("SELECT NEXT VALUE FOR " + seqName);
+ st = conn.createStatement();
+ srs = st.executeQuery("SELECT NEXT VALUE FOR " + seqName);
if (srs.next())
{
return true;
}
- srs.close();
return false;
}
catch (final SQLException e)
@@ -85,7 +88,6 @@
return false;
throw new SQLException(e.getMessage())
{
-
/**
* {@inheritDoc}
*/
@@ -96,6 +98,32 @@
}
};
}
+ finally
+ {
+ if (srs != null)
+ {
+ try
+ {
+ srs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+ }
}
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java 2010-06-09 13:47:50 UTC (rev 2526)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java 2010-06-09 13:48:33 UTC (rev 2527)
@@ -22,6 +22,7 @@
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
/**
* Created by The eXo Platform SAS
@@ -46,14 +47,16 @@
@Override
protected boolean isSequenceExists(Connection conn, String sequenceName) throws SQLException
{
+ ResultSet srs = null;
+ Statement st = null;
try
{
- ResultSet srs = conn.createStatement().executeQuery("SELECT " + sequenceName + ".nextval FROM DUAL");
+ st = conn.createStatement();
+ srs = st.executeQuery("SELECT " + sequenceName + ".nextval FROM DUAL");
if (srs.next())
{
return true;
}
- srs.close();
return false;
}
catch (SQLException e)
@@ -63,25 +66,86 @@
return false;
throw e;
}
+ finally
+ {
+ if (srs != null)
+ {
+ try
+ {
+ srs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+ }
}
@Override
protected boolean isTriggerExists(Connection conn, String triggerName) throws SQLException
{
String sql = "SELECT COUNT(trigger_name) FROM all_triggers WHERE trigger_name = '" + triggerName + "'";
- ResultSet r = conn.createStatement().executeQuery(sql);
- if (r.next())
- return r.getInt(1) > 0;
- else
- return false;
+ Statement st = null;
+ ResultSet r = null;
+ try
+ {
+ st = conn.createStatement();
+ r = st.executeQuery(sql);
+
+ if (r.next())
+ return r.getInt(1) > 0;
+ else
+ return false;
+ }
+ finally
+ {
+ if (r != null)
+ {
+ try
+ {
+ r.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+ }
}
@Override
protected boolean isTableExists(Connection conn, String tableName) throws SQLException
{
+ Statement st = null;
try
{
- conn.createStatement().executeUpdate("SELECT 1 FROM " + tableName);
+ st = conn.createStatement();
+ st.executeUpdate("SELECT 1 FROM " + tableName);
return true;
}
catch (SQLException e)
@@ -91,6 +155,20 @@
return false;
throw e;
}
+ finally
+ {
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+ }
}
@Override
@@ -98,10 +176,44 @@
{
// use of oracle system view
String sql = "SELECT COUNT(index_name) FROM all_indexes WHERE index_name='" + indexName + "'";
- ResultSet r = conn.createStatement().executeQuery(sql);
- if (r.next())
- return r.getInt(1) > 0;
- else
- return false;
+ Statement st = null;
+ ResultSet r = null;
+ try
+ {
+ st = conn.createStatement();
+ r = st.executeQuery(sql);
+
+ if (r.next())
+ return r.getInt(1) > 0;
+ else
+ return false;
+ }
+ finally
+ {
+ if (r != null)
+ {
+ try
+ {
+ r.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
+ }
}
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2010-06-09 13:47:50 UTC (rev 2526)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2010-06-09 13:48:33 UTC (rev 2527)
@@ -248,7 +248,7 @@
}
catch (SQLException e)
{
- LOG.error(e.getMessage(), e);
+ LOG.error("Can't close the ResultSet: " + e);
}
}
}
@@ -348,7 +348,7 @@
}
catch (SQLException e)
{
- LOG.error(e.getMessage(), e);
+ LOG.error("Can't close the ResultSet: " + e);
}
}
}
@@ -409,20 +409,34 @@
int cversion, int cnordernumb, AccessControlList parentACL) throws RepositoryException, SQLException
{
ResultSet ptProp = findNodeMainPropertiesByParentIdentifierCQ(cid);
- Map<String, SortedSet<TempPropertyData>> properties = new HashMap<String, SortedSet<TempPropertyData>>();
- while (ptProp.next())
+ try
{
- String key = ptProp.getString(COLUMN_NAME);
- SortedSet<TempPropertyData> values = properties.get(key);
- if (values == null)
+ Map<String, SortedSet<TempPropertyData>> properties = new HashMap<String, SortedSet<TempPropertyData>>();
+ while (ptProp.next())
{
- values = new TreeSet<TempPropertyData>();
- properties.put(key, values);
+ String key = ptProp.getString(COLUMN_NAME);
+ SortedSet<TempPropertyData> values = properties.get(key);
+ if (values == null)
+ {
+ values = new TreeSet<TempPropertyData>();
+ properties.put(key, values);
+ }
+ values.add(new TempPropertyData(ptProp));
}
- values.add(new TempPropertyData(ptProp));
+
+ return loadNodeRecord(parentPath, cname, cid, cpid, cindex, cversion, cnordernumb, properties, parentACL);
}
-
- return loadNodeRecord(parentPath, cname, cid, cpid, cindex, cversion, cnordernumb, properties, parentACL);
+ finally
+ {
+ try
+ {
+ ptProp.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
/**
@@ -644,8 +658,19 @@
}
finally
{
- result.close();
+ if (result != null)
+ {
+ try
+ {
+ result.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
}
+
if (caid.equals(Constants.ROOT_PARENT_UUID) || (id = getIdentifier(caid)).equals(Constants.ROOT_UUID))
{
if (id.equals(Constants.ROOT_UUID))
@@ -670,28 +695,35 @@
* {@inheritDoc}
*/
@Override
- protected void closeStatements() throws SQLException
+ protected void closeStatements()
{
super.closeStatements();
- if (findNodesByParentIdCQ != null)
+ try
{
- findNodesByParentIdCQ.close();
- }
+ if (findNodesByParentIdCQ != null)
+ {
+ findNodesByParentIdCQ.close();
+ }
- if (findPropertiesByParentIdCQ != null)
- {
- findPropertiesByParentIdCQ.close();
- }
+ if (findPropertiesByParentIdCQ != null)
+ {
+ findPropertiesByParentIdCQ.close();
+ }
- if (findNodeMainPropertiesByParentIdentifierCQ != null)
- {
- findNodeMainPropertiesByParentIdentifierCQ.close();
+ if (findNodeMainPropertiesByParentIdentifierCQ != null)
+ {
+ findNodeMainPropertiesByParentIdentifierCQ.close();
+ }
+
+ if (findItemQPathByIdentifierCQ != null)
+ {
+ findItemQPathByIdentifierCQ.close();
+ }
}
-
- if (findItemQPathByIdentifierCQ != null)
+ catch (SQLException e)
{
- findItemQPathByIdentifierCQ.close();
+ LOG.error("Can't close the Statement: " + e);
}
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java 2010-06-09 13:47:50 UTC (rev 2526)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLMultiDbJDBCConnection.java 2010-06-09 13:48:33 UTC (rev 2527)
@@ -85,7 +85,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addNodeRecord(data);
@@ -108,7 +115,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addPropertyRecord(data);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java 2010-06-09 13:47:50 UTC (rev 2526)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLSingleDbJDBCConnection.java 2010-06-09 13:48:33 UTC (rev 2527)
@@ -85,7 +85,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addNodeRecord(data);
@@ -108,7 +115,14 @@
}
finally
{
- item.close();
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
}
}
return super.addPropertyRecord(data);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/update/StorageUpdateManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/update/StorageUpdateManager.java 2010-06-09 13:47:50 UTC (rev 2526)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/update/StorageUpdateManager.java 2010-06-09 13:48:33 UTC (rev 2527)
@@ -30,6 +30,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
@@ -199,6 +200,7 @@
PreparedStatement insertVersion = connection.prepareStatement(SQL_UPDATE_VERSION);
insertVersion.setString(1, REQUIRED_STORAGE_VERSION);
insertVersion.executeUpdate();
+ insertVersion.close();
connection.commit();
}
@@ -368,9 +370,11 @@
private String currentVersion() throws SQLException
{
ResultSet version = null;
+ Statement st = null;
try
{
- version = connection.createStatement().executeQuery(SQL_SELECT_VERSION);
+ st = connection.createStatement();
+ version = st.executeQuery(SQL_SELECT_VERSION);
if (version.next())
return version.getString("VERSION");
}
@@ -381,12 +385,34 @@
finally
{
if (version != null)
- version.close();
+ {
+ try
+ {
+ version.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the Statement: " + e);
+ }
+ }
}
PreparedStatement insertVersion = connection.prepareStatement(SQL_INSERT_VERSION);
insertVersion.setString(1, REQUIRED_STORAGE_VERSION);
insertVersion.executeUpdate();
+ insertVersion.close();
return REQUIRED_STORAGE_VERSION;
}
@@ -402,9 +428,11 @@
ResultSet refs = null;
PreparedStatement update = null;
+ Statement st = null;
try
{
- refs = conn.createStatement().executeQuery(SQL_SELECT_JCRUUID);
+ st = conn.createStatement();
+ refs = st.executeQuery(SQL_SELECT_JCRUUID);
update = conn.prepareStatement(SQL_UPDATE_JCRUUID);
while (refs.next())
{
@@ -453,9 +481,40 @@
finally
{
if (refs != null)
- refs.close();
+ {
+ try
+ {
+ refs.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the ResultSet: " + e);
+ }
+ }
+
if (update != null)
- update.close();
+ {
+ try
+ {
+ update.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the Statement: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the Statement: " + e);
+ }
+ }
}
}
@@ -467,10 +526,12 @@
ResultSet refs = null;
PreparedStatement update = null;
+ Statement st = null;
try
{
String sql = SQL_SELECT_FROZENJCRUUID.replaceAll(FROZENJCRUUID, searchCriteria);
- refs = conn.createStatement().executeQuery(SQL_SELECT_FROZENJCRUUID);
+ st = conn.createStatement();
+ refs = st.executeQuery(SQL_SELECT_FROZENJCRUUID);
while (refs.next())
{
try
@@ -502,9 +563,40 @@
finally
{
if (refs != null)
- refs.close();
+ {
+ try
+ {
+ refs.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the ResultSet: " + e);
+ }
+ }
+
if (update != null)
- update.close();
+ {
+ try
+ {
+ update.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the Statement: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the Statement: " + e);
+ }
+ }
}
}
@@ -518,9 +610,11 @@
ResultSet refs = null;
PreparedStatement update = null;
+ Statement st = null;
try
{
- refs = conn.createStatement().executeQuery(SQL_SELECT_REFERENCES);
+ st = conn.createStatement();
+ refs = st.executeQuery(SQL_SELECT_REFERENCES);
update = conn.prepareStatement(SQL_INSERT_REFERENCES);
while (refs.next())
{
@@ -562,9 +656,40 @@
finally
{
if (refs != null)
- refs.close();
+ {
+ try
+ {
+ refs.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the ResultSet: " + e);
+ }
+ }
+
if (update != null)
- update.close();
+ {
+ try
+ {
+ update.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the Statement: " + e);
+ }
+ }
+
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ log.error("Can't close the Statement: " + e);
+ }
+ }
}
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java 2010-06-09 13:47:50 UTC (rev 2526)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java 2010-06-09 13:48:33 UTC (rev 2527)
@@ -29,6 +29,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -142,6 +143,7 @@
{
dataSource = (DataSource)new InitialContext().lookup(sn);
Connection conn = null;
+ Statement st = null;
try
{
conn = dataSource.getConnection();
@@ -204,15 +206,15 @@
// check if table already exists
if (!trs.next())
{
+ st = conn.createStatement();
+
// create table
- conn.createStatement().executeUpdate(
- "CREATE TABLE " + tableName
- + " (PROPERTY_ID VARCHAR(96) NOT NULL, ORDER_NUM INTEGER NOT NULL, CAS_ID VARCHAR(512) NOT NULL, "
- + "CONSTRAINT " + sqlConstraintPK + " PRIMARY KEY(PROPERTY_ID, ORDER_NUM))");
+ st.executeUpdate("CREATE TABLE " + tableName
+ + " (PROPERTY_ID VARCHAR(96) NOT NULL, ORDER_NUM INTEGER NOT NULL, CAS_ID VARCHAR(512) NOT NULL, "
+ + "CONSTRAINT " + sqlConstraintPK + " PRIMARY KEY(PROPERTY_ID, ORDER_NUM))");
// create index on hash (CAS_ID)
- conn.createStatement().executeUpdate(
- "CREATE INDEX " + sqlVCASIDX + " ON " + tableName + "(CAS_ID, PROPERTY_ID, ORDER_NUM)");
+ st.executeUpdate("CREATE INDEX " + sqlVCASIDX + " ON " + tableName + "(CAS_ID, PROPERTY_ID, ORDER_NUM)");
if (LOG.isDebugEnabled())
{
@@ -230,6 +232,18 @@
}
finally
{
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
if (conn != null)
{
try
@@ -403,12 +417,14 @@
try
{
Connection con = dataSource.getConnection();
+ ResultSet rs = null;
+ PreparedStatement ps = null;
try
{
- PreparedStatement ps = con.prepareStatement(sqlSelectRecord);
+ ps = con.prepareStatement(sqlSelectRecord);
ps.setString(1, propertyId);
ps.setInt(2, orderNum);
- ResultSet rs = ps.executeQuery();
+ rs = ps.executeQuery();
if (rs.next())
{
@@ -422,6 +438,30 @@
}
finally
{
+ if (rs != null)
+ {
+ try
+ {
+ rs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (ps != null)
+ {
+ try
+ {
+ ps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
con.close();
}
}
@@ -439,16 +479,17 @@
try
{
Connection con = dataSource.getConnection();
+ PreparedStatement ps = null;
+ ResultSet rs = null;
try
{
List<String> ids = new ArrayList<String>();
- PreparedStatement ps;
if (ownOnly)
{
ps = con.prepareStatement(sqlSelectOwnRecords);
ps.setString(1, propertyId);
- ResultSet rs = ps.executeQuery();
+ rs = ps.executeQuery();
if (rs.next())
{
do
@@ -470,7 +511,7 @@
// TODO unused externaly feature (except tests)
ps = con.prepareStatement(sqlSelectRecords);
ps.setString(1, propertyId);
- ResultSet rs = ps.executeQuery();
+ rs = ps.executeQuery();
if (rs.next())
{
do
@@ -488,6 +529,30 @@
}
finally
{
+ if (rs != null)
+ {
+ try
+ {
+ rs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+
+ if (ps != null)
+ {
+ try
+ {
+ ps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
con.close();
}
}
@@ -505,14 +570,27 @@
try
{
Connection con = dataSource.getConnection();
+ PreparedStatement ps = null;
try
{
- PreparedStatement ps = con.prepareStatement(sqlSelectSharingProps);
+ ps = con.prepareStatement(sqlSelectSharingProps);
ps.setString(1, propertyId);
return ps.executeQuery().next();
}
finally
{
+ if (ps != null)
+ {
+ try
+ {
+ ps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
con.close();
}
}
@@ -521,5 +599,4 @@
throw new VCASException("VCAS HAS SHARED IDs database error: " + e, e);
}
}
-
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2010-06-09 13:47:50 UTC (rev 2526)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2010-06-09 13:48:33 UTC (rev 2527)
@@ -28,6 +28,7 @@
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -324,8 +325,10 @@
}
String sql = null;
+ Statement st = null;
try
{
+ st = connection.createStatement();
connection.setAutoCommit(false);
for (String scr : scripts)
@@ -341,7 +344,7 @@
LOG.debug("Execute script: \n[" + sql + "]");
}
- connection.createStatement().executeUpdate(sql);
+ st.executeUpdate(sql);
}
}
@@ -377,6 +380,18 @@
}
finally
{
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
try
{
connection.close();
14 years