exo-jcr SVN: r2586 - jcr/branches/1.12-SEC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2010-06-15 04:06:47 -0400 (Tue, 15 Jun 2010)
New Revision: 2586
Modified:
jcr/branches/1.12-SEC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
Log:
EXOJCR-764 : secure login
Modified: jcr/branches/1.12-SEC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
===================================================================
--- jcr/branches/1.12-SEC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-06-15 08:05:04 UTC (rev 2585)
+++ jcr/branches/1.12-SEC/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-06-15 08:06:47 UTC (rev 2586)
@@ -43,6 +43,9 @@
import java.io.IOException;
import java.io.InputStream;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -487,22 +490,50 @@
/**
* {@inheritDoc}
*/
- public Session login(Credentials credentials, String workspaceName) throws LoginException, NoSuchWorkspaceException,
+ public Session login(final Credentials credentials, String workspaceName) throws LoginException, NoSuchWorkspaceException,
RepositoryException
{
+
if (getState() == OFFLINE)
LOG.warn("Repository " + getName() + " is OFFLINE.");
ConversationState state;
- if (credentials != null)
- state = authenticationPolicy.authenticate(credentials);
- else
- state = authenticationPolicy.authenticate();
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ if (credentials != null)
+ return authenticationPolicy.authenticate(credentials);
+ else
+ return authenticationPolicy.authenticate();
+ }
+ };
+ try
+ {
+ state = (ConversationState)AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof LoginException)
+ {
+ throw (LoginException)cause;
+ }
+ else if (cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
return internalLogin(state, workspaceName);
+
}
/**
14 years, 3 months
exo-jcr SVN: r2585 - jcr/branches/1.12-SEC.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2010-06-15 04:05:04 -0400 (Tue, 15 Jun 2010)
New Revision: 2585
Modified:
jcr/branches/1.12-SEC/pom.xml
Log:
EXOJCR-764 : update to stable versions
Modified: jcr/branches/1.12-SEC/pom.xml
===================================================================
--- jcr/branches/1.12-SEC/pom.xml 2010-06-15 07:58:25 UTC (rev 2584)
+++ jcr/branches/1.12-SEC/pom.xml 2010-06-15 08:05:04 UTC (rev 2585)
@@ -42,9 +42,9 @@
<properties>
<exo.product.name>exo-jcr</exo.product.name>
<exo.product.specification>1.12</exo.product.specification>
- <org.exoplatform.kernel.version>2.2.2-GA-SNAPSHOT</org.exoplatform.kernel.version>
+ <org.exoplatform.kernel.version>2.2.2-GA</org.exoplatform.kernel.version>
<org.exoplatform.core.version>2.3-SEC-SNAPSHOT</org.exoplatform.core.version>
- <org.exoplatform.ws.version>2.1.2-GA-SNAPSHOT</org.exoplatform.ws.version>
+ <org.exoplatform.ws.version>2.1.2-GA</org.exoplatform.ws.version>
<org.exoplatform.doc-style.version>1</org.exoplatform.doc-style.version>
</properties>
14 years, 3 months
exo-jcr SVN: r2584 - in jcr/trunk/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/util/io and 3 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-06-15 03:58:25 -0400 (Tue, 15 Jun 2010)
New Revision: 2584
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedFileHelper.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java
Log:
EXOJCR-756: replace file operations on privileged file operations
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java 2010-06-15 07:36:55 UTC (rev 2583)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java 2010-06-15 07:58:25 UTC (rev 2584)
@@ -161,7 +161,7 @@
}
catch (RecordAlreadyExistsException e)
{
- if (tempFile != null && PrivilegedFileHelper.exists(tempFile) && !tempFile.delete())
+ if (tempFile != null && PrivilegedFileHelper.exists(tempFile) && !PrivilegedFileHelper.delete(tempFile))
{
LOG.warn("Can't delete CAS temp file. Added to file cleaner. "
+ PrivilegedFileHelper.getAbsolutePath(tempFile));
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedFileHelper.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedFileHelper.java 2010-06-15 07:36:55 UTC (rev 2583)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedFileHelper.java 2010-06-15 07:58:25 UTC (rev 2584)
@@ -351,6 +351,18 @@
return AccessController.doPrivileged(action);
}
+ public static boolean isDirectory(final File file)
+ {
+ PrivilegedAction<Boolean> action = new PrivilegedAction<Boolean>()
+ {
+ public Boolean run()
+ {
+ return file.isDirectory();
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+
public static boolean exists(final File file)
{
PrivilegedAction<Boolean> action = new PrivilegedAction<Boolean>()
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java 2010-06-15 07:36:55 UTC (rev 2583)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java 2010-06-15 07:58:25 UTC (rev 2584)
@@ -23,12 +23,8 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import java.io.ByteArrayInputStream;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
import java.sql.ResultSet;
-import java.sql.SQLException;
import javax.naming.InitialContext;
import javax.sql.DataSource;
@@ -53,48 +49,15 @@
@Override
protected void tearDown() throws Exception
{
-
connect.close();
super.tearDown();
}
public Connection getJNDIConnection() throws Exception
{
+ DataSource ds = (DataSource)new InitialContext().lookup("jdbcjcrtest");
+ connect = ds.getConnection();
- final DataSource ds = (DataSource)new InitialContext().lookup("jdbcjcrtest");
-
- PrivilegedExceptionAction<Connection> action = new PrivilegedExceptionAction<Connection>()
- {
- public Connection run() throws Exception
- {
- return ds.getConnection();
- }
- };
- try
- {
- connect = AccessController.doPrivileged(action);
- }
- catch (PrivilegedActionException pae)
- {
- Throwable cause = pae.getCause();
- if (cause instanceof IllegalArgumentException)
- {
- throw (IllegalArgumentException)cause;
- }
- else if (cause instanceof SQLException)
- {
- throw (SQLException)cause;
- }
- else if (cause instanceof RuntimeException)
- {
- throw (RuntimeException)cause;
- }
- else
- {
- throw new RuntimeException(cause);
- }
- }
-
return connect;
}
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2010-06-15 07:36:55 UTC (rev 2583)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2010-06-15 07:58:25 UTC (rev 2584)
@@ -626,7 +626,7 @@
long count = 0;
for (File sf : PrivilegedFileHelper.listFiles(dir))
{
- if (sf.isDirectory() && PrivilegedFileHelper.list(sf).length > 0)
+ if (PrivilegedFileHelper.isDirectory(sf) && PrivilegedFileHelper.list(sf).length > 0)
count += deleteRecursive(sf);
else if (PrivilegedFileHelper.delete(sf))
count += 1;
@@ -640,9 +640,9 @@
private long calcDirSize(File dir)
{
long size = 0;
- for (File sf : dir.listFiles())
+ for (File sf : PrivilegedFileHelper.listFiles(dir))
{
- if (sf.isDirectory())
+ if (PrivilegedFileHelper.isDirectory(sf))
size += calcDirSize(sf);
else
size += PrivilegedFileHelper.length(sf);
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java 2010-06-15 07:36:55 UTC (rev 2583)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java 2010-06-15 07:58:25 UTC (rev 2584)
@@ -175,7 +175,7 @@
PrivilegedFileHelper.delete(f);
}
else
- f.delete();
+ PrivilegedFileHelper.delete(f);;
}
}
14 years, 3 months
exo-jcr SVN: r2583 - in kernel/branches/2.2.x/exo.kernel.container/src: test/java/org/exoplatform/container/definition and 1 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-06-15 03:36:55 -0400 (Tue, 15 Jun 2010)
New Revision: 2583
Added:
kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-defs.xml
kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs.xml
kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs2.xml
Modified:
kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
Log:
EXOJCR-788: Inconsistency issue fixed
Modified: kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-06-14 15:27:24 UTC (rev 2582)
+++ kernel/branches/2.2.x/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-06-15 07:36:55 UTC (rev 2583)
@@ -442,7 +442,7 @@
{
result = definition.getDependencies();
}
- return result == null ? defaultDefinition.getDependencies() : result;
+ return result == null || result.isEmpty() ? defaultDefinition.getDependencies() : result;
}
/**
@@ -462,7 +462,7 @@
if (definition != null)
{
final Map<String, Object> settings = definition.getSettings();
- if (settings != null)
+ if (settings != null && !settings.isEmpty())
{
return settings.get(settingName);
}
@@ -547,7 +547,7 @@
throw new IllegalStateException("The PortalContainerConfig has already been initialized");
}
final Map<String, PortalContainerDefinition> tempDefinitions =
- new HashMap<String, PortalContainerDefinition>(definitions);
+ new LinkedHashMap<String, PortalContainerDefinition>(definitions);
for (PortalContainerDefinition def : lDefs)
{
String name = def.getName();
@@ -944,6 +944,7 @@
// Add the default portal container name
lPortalContainerNames.add(defaultDefinition.getName());
final Map<String, List<String>> mScopes = new HashMap<String, List<String>>();
+ boolean first = true;
for (Map.Entry<String, PortalContainerDefinition> entry : mDefinitions.entrySet())
{
PortalContainerDefinition definition = entry.getValue();
@@ -951,25 +952,30 @@
boolean hasChanged = false;
if (!name.equals(defaultDefinition.getName()))
{
+ lPortalContainerNames.add(name);
+ }
+ if (first)
+ {
+ first = false;
+ // Initialize the main fields thanks to the data found in the first portal container
if (defaultDefinition.getName() == DEFAULT_PORTAL_CONTAINER_NAME)
{
defaultDefinition.setName(name);
hasChanged = true;
}
- lPortalContainerNames.add(name);
+ if (defaultDefinition.getRestContextName() == DEFAULT_REST_CONTEXT_NAME
+ && definition.getRestContextName() != null && definition.getRestContextName().trim().length() > 0)
+ {
+ defaultDefinition.setRestContextName(definition.getRestContextName().trim());
+ hasChanged = true;
+ }
+ if (defaultDefinition.getRealmName() == DEFAULT_REALM_NAME && definition.getRealmName() != null
+ && definition.getRealmName().trim().length() > 0)
+ {
+ defaultDefinition.setRealmName(definition.getRealmName().trim());
+ hasChanged = true;
+ }
}
- if (defaultDefinition.getRestContextName() == DEFAULT_REST_CONTEXT_NAME
- && definition.getRestContextName() != null && definition.getRestContextName().trim().length() > 0)
- {
- defaultDefinition.setRestContextName(definition.getRestContextName().trim());
- hasChanged = true;
- }
- if (defaultDefinition.getRealmName() == DEFAULT_REALM_NAME && definition.getRealmName() != null
- && definition.getRealmName().trim().length() > 0)
- {
- defaultDefinition.setRealmName(definition.getRealmName().trim());
- hasChanged = true;
- }
registerDependencies(definition, mScopes);
if (hasChanged)
{
Modified: kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-06-14 15:27:24 UTC (rev 2582)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-06-15 07:36:55 UTC (rev 2583)
@@ -71,6 +71,14 @@
assertEquals("my-exo-domain", config.getDefaultRealmName());
assertTrue(config.hasDefinition());
+ rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-defs.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+
+ assertEquals("myPortal", config.getDefaultPortalContainer());
+ assertEquals("myRest", config.getDefaultRestContext());
+ assertEquals("my-exo-domain", config.getDefaultRealmName());
+ assertTrue(config.hasDefinition());
+
rootContainer =
createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml");
config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
@@ -87,20 +95,73 @@
assertEquals("myRest-pcdef", config.getDefaultRestContext());
assertEquals("my-exo-domain-pcdef", config.getDefaultRealmName());
assertTrue(config.hasDefinition());
+
+ rootContainer = createRootContainer("portal-container-config-with-no-default-values-but-with-portal-defs.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+
+ assertEquals("portal", config.getDefaultPortalContainer());
+ assertEquals("myRest", config.getDefaultRestContext());
+ assertEquals("my-exo-domain", config.getDefaultRealmName());
+ assertTrue(config.hasDefinition());
+
+ rootContainer = createRootContainer("portal-container-config-with-no-default-values-but-with-portal-defs2.xml");
+ config = (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+
+ assertEquals("myPortal-pcdef", config.getDefaultPortalContainer());
+ assertEquals("myRest-pcdef", config.getDefaultRestContext());
+ assertEquals("my-exo-domain-pcdef", config.getDefaultRealmName());
+ assertTrue(config.hasDefinition());
}
public void testDependencies()
{
- // Without dependencies
- RootContainer rootContainer =
- createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml");
+
+ // Empty
+ RootContainer rootContainer = createRootContainer("portal-container-config-with-no-default-values.xml");
PortalContainerConfig config =
(PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getDependencies(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
assertNull(config.getDependencies("foo"));
assertNull(config.getDependencies("myPortal"));
assertNull(config.getDependencies("myPortal-pcdef"));
List<String> names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
+ names = config.getPortalContainerNames("myPortal");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
+ names = config.getPortalContainerNames("myPortal-pcdef");
+ assertTrue(names != null && !names.isEmpty());
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("foo"));
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("myPortal"));
+ assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("myPortal-pcdef"));
+ assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("foo"));
+ assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("myPortal"));
+ assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("myPortal-pcdef"));
+ assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getRealmName("foo"));
+ assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getRealmName("myPortal"));
+ assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getRealmName("myPortal-pcdef"));
+ assertFalse(config.isPortalContainerName("foo"));
+ assertFalse(config.isPortalContainerName("myPortal"));
+ assertFalse(config.isPortalContainerName("myPortal-pcdef"));
+ assertTrue(config.isPortalContainerName(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
+ // Needed for backward compatibility
+ assertTrue(config.isScopeValid("foo", "foo"));
+ assertTrue(config.isScopeValid("myPortal", "foo"));
+ assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
+ assertFalse(config.hasDefinition());
+
+ // Without dependencies
+ rootContainer =
+ createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml");
+ config =
+ (PortalContainerConfig)rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
+ assertNull(config.getDependencies("foo"));
+ assertNull(config.getDependencies("myPortal"));
+ assertNull(config.getDependencies("myPortal-pcdef"));
+ names = config.getPortalContainerNames("foo");
+ assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal", names.get(0));
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && !names.isEmpty());
Added: kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-defs.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-defs.xml (rev 0)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-default-values-and-with-portal-defs.xml 2010-06-15 07:36:55 UTC (rev 2583)
@@ -0,0 +1,81 @@
+<?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>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <type>org.exoplatform.container.definition.PortalContainerConfig</type>
+ <init-params>
+ <!-- The name of the default portal container -->
+ <value-param>
+ <name>default.portal.container</name>
+ <value>myPortal</value>
+ </value-param>
+ <!-- The name of the default rest ServletContext -->
+ <value-param>
+ <name>default.rest.context</name>
+ <value>myRest</value>
+ </value-param>
+ <!-- The name of the default realm -->
+ <value-param>
+ <name>default.realm.name</name>
+ <value>my-exo-domain</value>
+ </value-param>
+ </init-params>
+ </component>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin>
+ <!-- The name of the plugin -->
+ <name>Add PortalContainer Definitions</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
+ <set-method>registerPlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionPlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
+ <init-params>
+ <object-param>
+ <name>portal</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal-pcdef</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest-pcdef</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain-pcdef</string>
+ </field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>portal</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest2</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain2</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
\ No newline at end of file
Added: kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs.xml (rev 0)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs.xml 2010-06-15 07:36:55 UTC (rev 2583)
@@ -0,0 +1,63 @@
+<?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>org.exoplatform.container.definition.PortalContainerConfig</type>
+ </component>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin>
+ <!-- The name of the plugin -->
+ <name>Add PortalContainer Definitions</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
+ <set-method>registerPlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionPlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
+ <init-params>
+ <object-param>
+ <name>portal1</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>portal</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain</string>
+ </field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>portal2</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal-pcdef</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest-pcdef</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain-pcdef</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
\ No newline at end of file
Added: kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs2.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs2.xml (rev 0)
+++ kernel/branches/2.2.x/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal-container-config-with-no-default-values-but-with-portal-defs2.xml 2010-06-15 07:36:55 UTC (rev 2583)
@@ -0,0 +1,63 @@
+<?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>org.exoplatform.container.definition.PortalContainerConfig</type>
+ </component>
+ <external-component-plugins>
+ <!-- The full qualified name of the PortalContainerConfig -->
+ <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
+ <component-plugin>
+ <!-- The name of the plugin -->
+ <name>Add PortalContainer Definitions</name>
+ <!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
+ <set-method>registerPlugin</set-method>
+ <!-- The full qualified name of the PortalContainerDefinitionPlugin -->
+ <type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
+ <init-params>
+ <object-param>
+ <name>portal1</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>myPortal-pcdef</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest-pcdef</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain-pcdef</string>
+ </field>
+ </object>
+ </object-param>
+ <object-param>
+ <name>portal2</name>
+ <object type="org.exoplatform.container.definition.PortalContainerDefinition">
+ <!-- The name of the portal container -->
+ <field name="name">
+ <string>portal</string>
+ </field>
+ <!-- The name of the context name of the rest web application -->
+ <field name="restContextName">
+ <string>myRest</string>
+ </field>
+ <!-- The name of the realm -->
+ <field name="realmName">
+ <string>my-exo-domain</string>
+ </field>
+ </object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
\ No newline at end of file
14 years, 3 months
exo-jcr SVN: r2582 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr: impl/core/query and 2 other directories.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-06-14 11:27:24 -0400 (Mon, 14 Jun 2010)
New Revision: 2582
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SpellChecker.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java
Log:
EXOJCR-787: make LuceneSpellChecker configurable
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java 2010-06-14 15:24:48 UTC (rev 2581)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java 2010-06-14 15:27:24 UTC (rev 2582)
@@ -83,6 +83,10 @@
public static final String PARAM_SPELLCHECKER_CLASS = "spellchecker-class";
+ public static final String PARAM_SPELLCHECKER_MORE_POPULAR = "spellchecker-more-popular";
+
+ public static final String PARAM_SPELLCHECKER_DISTANCE = "spellchecker-min-distance";
+
public static final String PARAM_SUPPORT_HIGHLIGHTING = "support-highlighting";
public static final String PARAM_SYNONYMPROVIDER_CLASS = "synonymprovider-class";
@@ -92,9 +96,9 @@
public static final String PARAM_USE_COMPOUNDFILE = "use-compoundfile";
public static final String PARAM_VOLATILE_IDLE_TIME = "volatile-idle-time";
-
+
public static final String PARAM_MAX_VOLATILE_SIZE = "max-volatile-size";
-
+
public static final String PARAM_MAX_VOLATILE_TIME = "max-volatile-time";
//since https://jira.jboss.org/jira/browse/EXOJCR-17
@@ -106,8 +110,8 @@
public static final String PARAM_CHANGES_FILTER_CLASS = "changesfilter-class";
public static final String PARAM_JBOSSCACHE_CONFIGURATION = "jbosscache-configuration";
-
+
public static final String PARAM_JBOSSCACHE_PUSHSTATE = "jbosscache-sscl-push.state.enabled";
-
+
public static final String PARAM_JBOSSCACHE_PUSHSTATE_TIMEOUT = "jbosscache-sscl-push.state.timeout";
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java 2010-06-14 15:24:48 UTC (rev 2581)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java 2010-06-14 15:27:24 UTC (rev 2582)
@@ -66,7 +66,6 @@
*/
private void setParam(String name, String value)
{
-
if (QueryHandlerParams.PARAM_AUTO_REPAIR.equals(name))
{
searchIndex.setAutoRepair(Boolean.parseBoolean(value));
@@ -179,5 +178,13 @@
{
searchIndex.setAnalyzer(value);
}
+ else if (QueryHandlerParams.PARAM_SPELLCHECKER_MORE_POPULAR.equals(name))
+ {
+ searchIndex.setSpellCheckerMorePopuar(Boolean.parseBoolean(value));
+ }
+ else if (QueryHandlerParams.PARAM_SPELLCHECKER_DISTANCE.equals(name))
+ {
+ searchIndex.setSpellCheckerMinDistance(StringNumberParser.parseNumber(value).floatValue());
+ }
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2010-06-14 15:24:48 UTC (rev 2581)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2010-06-14 15:27:24 UTC (rev 2582)
@@ -384,6 +384,16 @@
private SpellChecker spellChecker;
/**
+ * Return most popular results.
+ */
+ private boolean spellCheckerMorePopular = true;
+
+ /**
+ * Minimal distance between spell checked word and proposed word.
+ */
+ private float spellCheckerMinDistance = 0.55f;
+
+ /**
* The similarity in use for indexing and searching.
*/
private Similarity similarity = Similarity.getDefault();
@@ -1360,13 +1370,14 @@
*/
protected SpellChecker createSpellChecker()
{
+ // spell checker config
SpellChecker spCheck = null;
if (spellCheckerClass != null)
{
try
{
spCheck = spellCheckerClass.newInstance();
- spCheck.init(this);
+ spCheck.init(this, spellCheckerMinDistance, spellCheckerMorePopular);
}
catch (Exception e)
{
@@ -2390,6 +2401,24 @@
}
/**
+ * Set SpellChecker morePopular parameter.
+ * @param morePopular boolean
+ */
+ public void setSpellCheckerMorePopuar(boolean morePopular)
+ {
+ spellCheckerMorePopular = morePopular;
+ }
+
+ /**
+ * Set SpellChecker minimal word distance.
+ * @param minDistance float
+ */
+ public void setSpellCheckerMinDistance(float minDistance)
+ {
+ spellCheckerMinDistance = minDistance;
+ }
+
+ /**
* @return the class name of the spell checker implementation or
* <code>null</code> if none is set.
*/
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SpellChecker.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SpellChecker.java 2010-06-14 15:24:48 UTC (rev 2581)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SpellChecker.java 2010-06-14 15:27:24 UTC (rev 2582)
@@ -27,38 +27,43 @@
* <code>SpellChecker</code> defines an interface to run a spellchecker over a
* fulltext query statement.
*/
-public interface SpellChecker {
+public interface SpellChecker
+{
- /**
- * Initializes this spell checker with an abstract query tree.
- *
- * @param handler
- * the query handler that created this spell checker.
- * @throws IOException
- * if an error occurs while initializing the spell checker.
- */
- void init(QueryHandler handler) throws IOException;
+ /**
+ * Initializes this spell checker.
+ *
+ * @param handler
+ * the query handler that created this spell checker.
+ * @param minDistance
+ * minimal distance between word and proposed close word. Float value 0..1.
+ * @param morePopular
+ * return only the suggest words that are as frequent or more frequent than the searched word
+ * @throws IOException
+ * if an error occurs while initializing the spell checker.
+ */
+ void init(QueryHandler handler, float minDistance, boolean morePopular) throws IOException;
- /**
- * Runs the spell checker over the first spellcheck relation query node in
- * the abstract query tree and returns a suggestion in case this
- * spellchecker thinks the words are misspelled. If the spellchecker
- * determines that the words are spelled correctly <code>null</code> is
- * returned.
- *
- * @param aqt
- * the abstract query tree, which may contain a relation query
- * node with a spellcheck operation.
- * @return a suggestion or <code>null</code> if this spell checker
- * determines that the fulltext query statement is spelled
- * correctly.
- * @throws RepositoryException
- */
- String check(QueryRootNode aqt) throws IOException, RepositoryException;
+ /**
+ * Runs the spell checker over the first spellcheck relation query node in
+ * the abstract query tree and returns a suggestion in case this
+ * spellchecker thinks the words are misspelled. If the spellchecker
+ * determines that the words are spelled correctly <code>null</code> is
+ * returned.
+ *
+ * @param aqt
+ * the abstract query tree, which may contain a relation query
+ * node with a spellcheck operation.
+ * @return a suggestion or <code>null</code> if this spell checker
+ * determines that the fulltext query statement is spelled
+ * correctly.
+ * @throws RepositoryException
+ */
+ String check(QueryRootNode aqt) throws IOException, RepositoryException;
- /**
- * Closes this spell checker and allows it to free resources.
- */
- void close();
+ /**
+ * Closes this spell checker and allows it to free resources.
+ */
+ void close();
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java 2010-06-14 15:24:48 UTC (rev 2581)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java 2010-06-14 15:27:24 UTC (rev 2582)
@@ -143,18 +143,13 @@
}
/**
- * Initializes this spell checker.
- *
- * @param handler
- * the query handler that created this spell checker.
- * @throws IOException
- * if <code>handler</code> is not of type {@link SearchIndex}.
+ * {@inheritDoc}
*/
- public void init(QueryHandler handler) throws IOException
+ public void init(QueryHandler handler, float minDistance, boolean morePopular) throws IOException
{
if (handler instanceof SearchIndex)
{
- this.spellChecker = new InternalSpellChecker((SearchIndex)handler);
+ this.spellChecker = new InternalSpellChecker((SearchIndex)handler, minDistance, morePopular);
}
else
{
@@ -183,8 +178,7 @@
spellChecker.close();
}
- // ------------------------------< internal
- // >--------------------------------
+ // ------------------------------< internal >--------------------------------
/**
* Returns the fulltext statement of a spellcheck relation query node or
@@ -240,13 +234,19 @@
*/
private SpellChecker spellChecker;
+ private final boolean morePopular;
+
/**
* Creates a new internal spell checker.
*
* @param handler
* the associated query handler.
+ * @param minDistance
+ * minimal distance between word and proposed close word. Float value 0..1.
+ * @param morePopular
+ * return only the suggest words that are as frequent or more frequent than the searched word
*/
- InternalSpellChecker(SearchIndex handler) throws IOException
+ InternalSpellChecker(SearchIndex handler, float minDistance, boolean morePopular) throws IOException
{
this.handler = handler;
String path = handler.getContext().getIndexDirectory() + File.separatorChar + "spellchecker";
@@ -256,7 +256,8 @@
this.lastRefresh = System.currentTimeMillis();
}
this.spellChecker = new SpellChecker(spellIndexDirectory);
- this.spellChecker.setAccuracy(0.55f);
+ this.spellChecker.setAccuracy(minDistance);
+ this.morePopular = morePopular;
refreshSpellChecker();
}
@@ -291,7 +292,16 @@
sb.replace(t.startOffset(), t.endOffset(), suggestions[i]);
}
}
- return sb.toString();
+ // if suggestion is same as a statement return null
+ String result = sb.toString();
+ if (statement.equalsIgnoreCase(result))
+ {
+ return null;
+ }
+ else
+ {
+ return result;
+ }
}
else
{
@@ -389,7 +399,9 @@
String[] suggestion = new String[words.length];
for (int i = 0; i < words.length; i++)
{
- String[] similar = spellChecker.suggestSimilar(words[i], 5, reader, FieldNames.FULLTEXT, true);
+ String[] similar =
+ spellChecker.suggestSimilar(words[i], 5, reader, FieldNames.FULLTEXT, morePopular);
+
if (similar.length > 0)
{
suggestion[i] = similar[0];
@@ -479,6 +491,7 @@
}
};
new Thread(refresh, "SpellChecker Refresh").start();
+
lastRefresh = System.currentTimeMillis();
}
}
14 years, 3 months
exo-jcr SVN: r2581 - in jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr: impl/core/query and 2 other directories.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-06-14 11:24:48 -0400 (Mon, 14 Jun 2010)
New Revision: 2581
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SpellChecker.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java
Log:
EXOJCR-787: make LuceneSpellChecker configurable
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java 2010-06-14 14:35:10 UTC (rev 2580)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java 2010-06-14 15:24:48 UTC (rev 2581)
@@ -83,6 +83,10 @@
public static final String PARAM_SPELLCHECKER_CLASS = "spellchecker-class";
+ public static final String PARAM_SPELLCHECKER_MORE_POPULAR = "spellchecker-more-popular";
+
+ public static final String PARAM_SPELLCHECKER_DISTANCE = "spellchecker-min-distance";
+
public static final String PARAM_SUPPORT_HIGHLIGHTING = "support-highlighting";
public static final String PARAM_SYNONYMPROVIDER_CLASS = "synonymprovider-class";
@@ -92,9 +96,9 @@
public static final String PARAM_USE_COMPOUNDFILE = "use-compoundfile";
public static final String PARAM_VOLATILE_IDLE_TIME = "volatile-idle-time";
-
+
public static final String PARAM_MAX_VOLATILE_SIZE = "max-volatile-size";
-
+
public static final String PARAM_MAX_VOLATILE_TIME = "max-volatile-time";
//since https://jira.jboss.org/jira/browse/EXOJCR-17
@@ -106,8 +110,8 @@
public static final String PARAM_CHANGES_FILTER_CLASS = "changesfilter-class";
public static final String PARAM_JBOSSCACHE_CONFIGURATION = "jbosscache-configuration";
-
+
public static final String PARAM_JBOSSCACHE_PUSHSTATE = "jbosscache-sscl-push.state.enabled";
-
+
public static final String PARAM_JBOSSCACHE_PUSHSTATE_TIMEOUT = "jbosscache-sscl-push.state.timeout";
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java 2010-06-14 14:35:10 UTC (rev 2580)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchIndexConfigurationHelper.java 2010-06-14 15:24:48 UTC (rev 2581)
@@ -66,7 +66,6 @@
*/
private void setParam(String name, String value)
{
-
if (QueryHandlerParams.PARAM_AUTO_REPAIR.equals(name))
{
searchIndex.setAutoRepair(Boolean.parseBoolean(value));
@@ -179,5 +178,13 @@
{
searchIndex.setAnalyzer(value);
}
+ else if (QueryHandlerParams.PARAM_SPELLCHECKER_MORE_POPULAR.equals(name))
+ {
+ searchIndex.setSpellCheckerMorePopuar(Boolean.parseBoolean(value));
+ }
+ else if (QueryHandlerParams.PARAM_SPELLCHECKER_DISTANCE.equals(name))
+ {
+ searchIndex.setSpellCheckerMinDistance(StringNumberParser.parseNumber(value).floatValue());
+ }
}
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2010-06-14 14:35:10 UTC (rev 2580)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2010-06-14 15:24:48 UTC (rev 2581)
@@ -384,6 +384,16 @@
private SpellChecker spellChecker;
/**
+ * Return most popular results.
+ */
+ private boolean spellCheckerMorePopular = true;
+
+ /**
+ * Minimal distance between spell checked word and proposed word.
+ */
+ private float spellCheckerMinDistance = 0.55f;
+
+ /**
* The similarity in use for indexing and searching.
*/
private Similarity similarity = Similarity.getDefault();
@@ -1357,13 +1367,14 @@
*/
protected SpellChecker createSpellChecker()
{
+ // spell checker config
SpellChecker spCheck = null;
if (spellCheckerClass != null)
{
try
{
spCheck = spellCheckerClass.newInstance();
- spCheck.init(this);
+ spCheck.init(this, spellCheckerMinDistance, spellCheckerMorePopular);
}
catch (Exception e)
{
@@ -2385,6 +2396,24 @@
}
/**
+ * Set SpellChecker morePopular parameter.
+ * @param morePopular boolean
+ */
+ public void setSpellCheckerMorePopuar(boolean morePopular)
+ {
+ spellCheckerMorePopular = morePopular;
+ }
+
+ /**
+ * Set SpellChecker minimal word distance.
+ * @param minDistance float
+ */
+ public void setSpellCheckerMinDistance(float minDistance)
+ {
+ spellCheckerMinDistance = minDistance;
+ }
+
+ /**
* @return the class name of the spell checker implementation or
* <code>null</code> if none is set.
*/
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SpellChecker.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SpellChecker.java 2010-06-14 14:35:10 UTC (rev 2580)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SpellChecker.java 2010-06-14 15:24:48 UTC (rev 2581)
@@ -27,38 +27,43 @@
* <code>SpellChecker</code> defines an interface to run a spellchecker over a
* fulltext query statement.
*/
-public interface SpellChecker {
+public interface SpellChecker
+{
- /**
- * Initializes this spell checker with an abstract query tree.
- *
- * @param handler
- * the query handler that created this spell checker.
- * @throws IOException
- * if an error occurs while initializing the spell checker.
- */
- void init(QueryHandler handler) throws IOException;
+ /**
+ * Initializes this spell checker.
+ *
+ * @param handler
+ * the query handler that created this spell checker.
+ * @param minDistance
+ * minimal distance between word and proposed close word. Float value 0..1.
+ * @param morePopular
+ * return only the suggest words that are as frequent or more frequent than the searched word
+ * @throws IOException
+ * if an error occurs while initializing the spell checker.
+ */
+ void init(QueryHandler handler, float minDistance, boolean morePopular) throws IOException;
- /**
- * Runs the spell checker over the first spellcheck relation query node in
- * the abstract query tree and returns a suggestion in case this
- * spellchecker thinks the words are misspelled. If the spellchecker
- * determines that the words are spelled correctly <code>null</code> is
- * returned.
- *
- * @param aqt
- * the abstract query tree, which may contain a relation query
- * node with a spellcheck operation.
- * @return a suggestion or <code>null</code> if this spell checker
- * determines that the fulltext query statement is spelled
- * correctly.
- * @throws RepositoryException
- */
- String check(QueryRootNode aqt) throws IOException, RepositoryException;
+ /**
+ * Runs the spell checker over the first spellcheck relation query node in
+ * the abstract query tree and returns a suggestion in case this
+ * spellchecker thinks the words are misspelled. If the spellchecker
+ * determines that the words are spelled correctly <code>null</code> is
+ * returned.
+ *
+ * @param aqt
+ * the abstract query tree, which may contain a relation query
+ * node with a spellcheck operation.
+ * @return a suggestion or <code>null</code> if this spell checker
+ * determines that the fulltext query statement is spelled
+ * correctly.
+ * @throws RepositoryException
+ */
+ String check(QueryRootNode aqt) throws IOException, RepositoryException;
- /**
- * Closes this spell checker and allows it to free resources.
- */
- void close();
+ /**
+ * Closes this spell checker and allows it to free resources.
+ */
+ void close();
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java 2010-06-14 14:35:10 UTC (rev 2580)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java 2010-06-14 15:24:48 UTC (rev 2581)
@@ -143,18 +143,13 @@
}
/**
- * Initializes this spell checker.
- *
- * @param handler
- * the query handler that created this spell checker.
- * @throws IOException
- * if <code>handler</code> is not of type {@link SearchIndex}.
+ * {@inheritDoc}
*/
- public void init(QueryHandler handler) throws IOException
+ public void init(QueryHandler handler, float minDistance, boolean morePopular) throws IOException
{
if (handler instanceof SearchIndex)
{
- this.spellChecker = new InternalSpellChecker((SearchIndex)handler);
+ this.spellChecker = new InternalSpellChecker((SearchIndex)handler, minDistance, morePopular);
}
else
{
@@ -183,8 +178,7 @@
spellChecker.close();
}
- // ------------------------------< internal
- // >--------------------------------
+ // ------------------------------< internal >--------------------------------
/**
* Returns the fulltext statement of a spellcheck relation query node or
@@ -240,13 +234,19 @@
*/
private SpellChecker spellChecker;
+ private final boolean morePopular;
+
/**
* Creates a new internal spell checker.
*
* @param handler
* the associated query handler.
+ * @param minDistance
+ * minimal distance between word and proposed close word. Float value 0..1.
+ * @param morePopular
+ * return only the suggest words that are as frequent or more frequent than the searched word
*/
- InternalSpellChecker(SearchIndex handler) throws IOException
+ InternalSpellChecker(SearchIndex handler, float minDistance, boolean morePopular) throws IOException
{
this.handler = handler;
String path = handler.getContext().getIndexDirectory() + File.separatorChar + "spellchecker";
@@ -256,7 +256,8 @@
this.lastRefresh = System.currentTimeMillis();
}
this.spellChecker = new SpellChecker(spellIndexDirectory);
- this.spellChecker.setAccuracy(0.55f);
+ this.spellChecker.setAccuracy(minDistance);
+ this.morePopular = morePopular;
refreshSpellChecker();
}
@@ -291,7 +292,16 @@
sb.replace(t.startOffset(), t.endOffset(), suggestions[i]);
}
}
- return sb.toString();
+ // if suggestion is same as a statement return null
+ String result = sb.toString();
+ if (statement.equalsIgnoreCase(result))
+ {
+ return null;
+ }
+ else
+ {
+ return result;
+ }
}
else
{
@@ -389,7 +399,9 @@
String[] suggestion = new String[words.length];
for (int i = 0; i < words.length; i++)
{
- String[] similar = spellChecker.suggestSimilar(words[i], 5, reader, FieldNames.FULLTEXT, true);
+ String[] similar =
+ spellChecker.suggestSimilar(words[i], 5, reader, FieldNames.FULLTEXT, morePopular);
+
if (similar.length > 0)
{
suggestion[i] = similar[0];
@@ -479,6 +491,7 @@
}
};
new Thread(refresh, "SpellChecker Refresh").start();
+
lastRefresh = System.currentTimeMillis();
}
}
14 years, 3 months
exo-jcr SVN: r2580 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-06-14 10:35:10 -0400 (Mon, 14 Jun 2010)
New Revision: 2580
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/ControllerCacheLoader.java
Log:
EXOJCR-756
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/ControllerCacheLoader.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/ControllerCacheLoader.java 2010-06-14 13:49:38 UTC (rev 2579)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/ControllerCacheLoader.java 2010-06-14 14:35:10 UTC (rev 2580)
@@ -16,6 +16,7 @@
*/
package org.exoplatform.services.jcr.impl.core.lock.jbosscache;
+import org.exoplatform.services.jcr.impl.util.SecurityHelper;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.CacheStatus;
import org.jboss.cache.Fqn;
@@ -28,6 +29,7 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.security.PrivilegedExceptionAction;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -44,7 +46,7 @@
* Created by The eXo Platform SAS
* Author : Nicolas Filotto
* nicolas.filotto(a)exoplatform.com
- * 9 f�vr. 2010
+ * 9 f�vr. 2010
*/
@SuppressWarnings("unchecked")
public class ControllerCacheLoader implements CacheLoader
@@ -201,9 +203,16 @@
/**
* @see org.jboss.cache.loader.CacheLoader#put(org.jboss.cache.Fqn, java.lang.Object, java.lang.Object)
*/
- public Object put(Fqn name, Object key, Object value) throws Exception
+ public Object put(final Fqn name, final Object key, final Object value) throws Exception
{
- return cl.put(name, key, value);
+
+ return SecurityHelper.doPriviledgedIOExceptionAction(new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ return cl.put(name, key, value);
+ }
+ });
}
/**
14 years, 3 months
exo-jcr SVN: r2579 - in jcr/trunk/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/storage/value/fs and 6 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-06-14 09:49:38 -0400 (Mon, 14 Jun 2010)
New Revision: 2579
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/FileCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedFileHelper.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SpoolFile.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SwapFile.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportDocView.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java
Log:
EXOJCR-756: replace file operations on privileged file operations
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java 2010-06-14 12:20:45 UTC (rev 2578)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java 2010-06-14 13:49:38 UTC (rev 2579)
@@ -160,7 +160,7 @@
this.data = null;
this.spoolFile = sf;
- this.spoolChannel = new RandomAccessFile(sf, "rw").getChannel();
+ this.spoolChannel = PrivilegedFileHelper.randomAccessFile(sf, "rw").getChannel();
this.spooled = true;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java 2010-06-14 12:20:45 UTC (rev 2578)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java 2010-06-14 13:49:38 UTC (rev 2579)
@@ -57,18 +57,20 @@
@Override
public boolean delete()
{
- PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+
+ PrivilegedAction<Boolean> action = new PrivilegedAction<Boolean>()
{
- public Object run()
+ public Boolean run()
{
- boolean res = deleteFromSuper();
- if (res)
- deleteParent(new File(getParent()));
-
- return res;
+ return TreeFile.super.delete();
}
};
- return (Boolean)AccessController.doPrivileged(action);
+ boolean res = AccessController.doPrivileged(action);
+
+ if (res)
+ deleteParent(new File(getParent()));
+
+ return res;
}
protected boolean deleteParent(File fp)
@@ -98,8 +100,4 @@
return res;
}
- private boolean deleteFromSuper()
- {
- return super.delete();
- }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java 2010-06-14 12:20:45 UTC (rev 2578)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java 2010-06-14 13:49:38 UTC (rev 2579)
@@ -189,7 +189,7 @@
if (lockFileStream != null)
lockFileStream.close();
- if (!lockFile.delete())
+ if (!PrivilegedFileHelper.delete(lockFile))
{ // TODO don't use FileCleaner, delete should be enough
LOG.warn("Cannot delete lock file " + PrivilegedFileHelper.getAbsolutePath(lockFile)
+ ". Add to the FileCleaner");
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/FileCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/FileCleaner.java 2010-06-14 12:20:45 UTC (rev 2578)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/FileCleaner.java 2010-06-14 13:49:38 UTC (rev 2579)
@@ -126,7 +126,7 @@
{
if (PrivilegedFileHelper.exists(file))
{
- if (!file.delete())
+ if (!PrivilegedFileHelper.delete(file))
{
notRemovedFiles.add(file);
@@ -162,7 +162,7 @@
File file = null;
while ((file = files.poll()) != null)
{
- file.delete();
+ PrivilegedFileHelper.delete(file);
}
}
});
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedFileHelper.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedFileHelper.java 2010-06-14 12:20:45 UTC (rev 2578)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/PrivilegedFileHelper.java 2010-06-14 13:49:38 UTC (rev 2579)
@@ -24,6 +24,7 @@
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
+import java.io.RandomAccessFile;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
@@ -265,6 +266,42 @@
}
}
+ public static RandomAccessFile randomAccessFile(final File file, final String mode) throws IllegalArgumentException,
+ IOException
+ {
+ PrivilegedExceptionAction<RandomAccessFile> action = new PrivilegedExceptionAction<RandomAccessFile>()
+ {
+ public RandomAccessFile run() throws Exception
+ {
+ return new RandomAccessFile(file, mode);
+ }
+ };
+ try
+ {
+ return AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof IllegalArgumentException)
+ {
+ throw (IllegalArgumentException)cause;
+ }
+ else if (cause instanceof FileNotFoundException)
+ {
+ throw (FileNotFoundException)cause;
+ }
+ else if (cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
+ }
+
public static long length(final File file)
{
PrivilegedAction<Long> action = new PrivilegedAction<Long>()
@@ -373,4 +410,17 @@
};
return AccessController.doPrivileged(action);
}
+
+ public static File[] listFiles(final File file)
+ {
+ PrivilegedAction<File[]> action = new PrivilegedAction<File[]>()
+ {
+ public File[] run()
+ {
+ return file.listFiles();
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SpoolFile.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SpoolFile.java 2010-06-14 12:20:45 UTC (rev 2578)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SpoolFile.java 2010-06-14 13:49:38 UTC (rev 2579)
@@ -24,6 +24,8 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Map;
import java.util.WeakHashMap;
@@ -106,7 +108,15 @@
// make unusable
users.clear();
users = null;
- return super.delete();
+
+ PrivilegedAction<Boolean> action = new PrivilegedAction<Boolean>()
+ {
+ public Boolean run()
+ {
+ return SpoolFile.super.delete();
+ }
+ };
+ return AccessController.doPrivileged(action);
}
return false;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SwapFile.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SwapFile.java 2010-06-14 12:20:45 UTC (rev 2578)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SwapFile.java 2010-06-14 13:49:38 UTC (rev 2579)
@@ -20,6 +20,8 @@
import java.io.File;
import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
@@ -155,8 +157,18 @@
{
synchronized (inShare)
{
- if (super.delete())
+
+ PrivilegedAction<Boolean> action = new PrivilegedAction<Boolean>()
{
+ public Boolean run()
+ {
+ return SwapFile.super.delete();
+ }
+ };
+ boolean res = AccessController.doPrivileged(action);
+
+ if (res)
+ {
// remove from shared files list
inShare.remove(getAbsolutePath());
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportDocView.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportDocView.java 2010-06-14 12:20:45 UTC (rev 2578)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportDocView.java 2010-06-14 13:49:38 UTC (rev 2579)
@@ -30,7 +30,6 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Calendar;
@@ -354,9 +353,9 @@
{
Session newSession = repository.login(this.credentials /*
- * session.getCredentials
- * ()
- */);
+ * session.getCredentials
+ * ()
+ */);
newSession.setNamespacePrefix("newjcr", "http://www.jcp.org/jcr/1.0");
@@ -383,9 +382,9 @@
{
Session newSession = repository.login(this.credentials /*
- * session.getCredentials
- * ()
- */);
+ * session.getCredentials
+ * ()
+ */);
newSession.setNamespacePrefix("newjcr", "http://www.jcp.org/jcr/1.0");
Node testNode = newSession.getRootNode().addNode("jcr:testExportNamespaceRemaping");
@@ -402,7 +401,7 @@
// session.exportDocumentView(testNode.getPath(), bos, false, false);
SAXTransformerFactory saxFact = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
- TransformerHandler handler = saxFact.newTransformerHandler();
+ final TransformerHandler handler = saxFact.newTransformerHandler();
handler.setResult(new StreamResult(bos));
newSession.exportDocumentView(testNode.getPath(), handler, false, false);
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java 2010-06-14 12:20:45 UTC (rev 2578)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java 2010-06-14 13:49:38 UTC (rev 2579)
@@ -21,11 +21,14 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
-import org.exoplatform.services.jcr.impl.storage.jdbc.init.StorageDBInitializer;
import java.io.ByteArrayInputStream;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
import java.sql.ResultSet;
+import java.sql.SQLException;
import javax.naming.InitialContext;
import javax.sql.DataSource;
@@ -47,6 +50,7 @@
private Connection connect = null;
+ @Override
protected void tearDown() throws Exception
{
@@ -57,8 +61,40 @@
public Connection getJNDIConnection() throws Exception
{
- DataSource ds = (DataSource)new InitialContext().lookup("jdbcjcrtest");
- connect = ds.getConnection();
+ final DataSource ds = (DataSource)new InitialContext().lookup("jdbcjcrtest");
+
+ PrivilegedExceptionAction<Connection> action = new PrivilegedExceptionAction<Connection>()
+ {
+ public Connection run() throws Exception
+ {
+ return ds.getConnection();
+ }
+ };
+ try
+ {
+ connect = AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof IllegalArgumentException)
+ {
+ throw (IllegalArgumentException)cause;
+ }
+ else if (cause instanceof SQLException)
+ {
+ throw (SQLException)cause;
+ }
+ else if (cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
+
return connect;
}
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2010-06-14 12:20:45 UTC (rev 2578)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2010-06-14 13:49:38 UTC (rev 2579)
@@ -624,7 +624,7 @@
private long deleteRecursive(File dir)
{
long count = 0;
- for (File sf : dir.listFiles())
+ for (File sf : PrivilegedFileHelper.listFiles(dir))
{
if (sf.isDirectory() && PrivilegedFileHelper.list(sf).length > 0)
count += deleteRecursive(sf);
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java 2010-06-14 12:20:45 UTC (rev 2578)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/storage/fs/TestFSReadWrite.java 2010-06-14 13:49:38 UTC (rev 2579)
@@ -125,7 +125,7 @@
{
deleteDir(testRoot);
// deleteFiles(files);
- testRoot.delete();
+ PrivilegedFileHelper.delete(testRoot);
log.info("Tear down of " + getName() + ",\t" + (System.currentTimeMillis() - time));
}
@@ -136,7 +136,7 @@
{
for (File f : filesList)
{
- f.delete();
+ PrivilegedFileHelper.delete(f);
deleteFileParent(new File(f.getParent()));
}
}
@@ -150,7 +150,7 @@
if (ls.length <= 0)
{
// log.info("del " + fp.getAbsolutePath());
- fp.delete();
+ PrivilegedFileHelper.delete(fp);
deleteFileParent(new File(fp.getParent()));
}
}
@@ -172,7 +172,7 @@
if (f.isDirectory())
{
deleteDir(f);
- f.delete();
+ PrivilegedFileHelper.delete(f);
}
else
f.delete();
14 years, 3 months
exo-jcr SVN: r2578 - in jcr/trunk/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/dataflow/serialization and 15 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-06-14 08:20:45 -0400 (Mon, 14 Jun 2010)
New Revision: 2578
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/SerializationSpoolFile.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileValueStorage.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/DeleteValues.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportImport.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportSysView.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestSystemViewImport.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestUpdate.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceManagement.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestFileBasedNamespaceMappings.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCleanableFileStreamValueData.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationLogTestLoad.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestEOFException.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileValueIO.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/TestValueFileIOHelper.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/tools/tree/generator/RandomValueNodeGenerator.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueData.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestValueImpl.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestConcurrentItems.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestExportBigFiles.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java
Log:
EXOJCR-756: replace file operations on privileged file operations
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -91,7 +91,7 @@
try
{
sch.close();
- sf.delete();
+ PrivilegedFileHelper.delete(sf);
}
catch (Exception e1)
{
@@ -142,7 +142,7 @@
try
{
sfout.close();
- sf.delete();
+ PrivilegedFileHelper.delete(sf);
}
catch (Exception e1)
{
@@ -297,7 +297,7 @@
try
{
chch.close();
- chf.delete();
+ PrivilegedFileHelper.delete(chf);
}
catch (Exception e1)
{
@@ -382,7 +382,7 @@
try
{
chch.close();
- chf.delete();
+ PrivilegedFileHelper.delete(chf);
}
catch (Exception e1)
{
@@ -425,7 +425,7 @@
spoolChannel.close();
// delete file
- if (!spoolFile.delete())
+ if (!PrivilegedFileHelper.delete(spoolFile))
{
if (fileCleaner != null)
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -697,7 +697,7 @@
if (deleteSpoolFile && PrivilegedFileHelper.exists(spoolFile))
{
- if (!spoolFile.delete())
+ if (!PrivilegedFileHelper.delete(spoolFile))
{
if (fileCleaner != null)
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/SerializationSpoolFile.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/SerializationSpoolFile.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/SerializationSpoolFile.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -22,6 +22,8 @@
import java.io.File;
import java.io.FileNotFoundException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
/**
* Created by The eXo Platform SAS. <br/>
@@ -80,7 +82,15 @@
{
if (!inUse())
{
- boolean result = super.delete();
+ PrivilegedAction<Boolean> action = new PrivilegedAction<Boolean>()
+ {
+ public Boolean run()
+ {
+ return SerializationSpoolFile.super.delete();
+ }
+ };
+ boolean result = AccessController.doPrivileged(action);
+
if (result)
{
holder.remove(id);
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileValueStorage.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileValueStorage.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileValueStorage.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -122,7 +122,7 @@
{
// care about storage temp dir cleanup
for (File tmpf : tempDir.listFiles())
- if (!tmpf.delete())
+ if (!PrivilegedFileHelper.delete(tmpf))
log.warn("Storage temporary directory contains un-deletable file "
+ PrivilegedFileHelper.getAbsolutePath(tmpf)
+ ". It's recommended to leave this directory for JCR External Values Storage private use.");
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -82,7 +82,7 @@
String[] ls = PrivilegedFileHelper.list(fp);;
if (ls != null && ls.length <= 0)
{
- if (res = fp.delete())
+ if (res = PrivilegedFileHelper.delete(fp))
{
res = deleteParent(new File(fp.getParent()));
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -211,7 +211,7 @@
try
{
// delete temp file - it's new file add
- tempFile.delete(); // should be ok without file cleaner
+ PrivilegedFileHelper.delete(tempFile); // should be ok without file cleaner
}
finally
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/DeleteValues.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/DeleteValues.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/DeleteValues.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -20,6 +20,7 @@
import org.exoplatform.services.jcr.impl.storage.value.ValueDataResourceHolder;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
import java.io.IOException;
@@ -100,7 +101,7 @@
{
for (File f : files)
{
- if (!f.delete())
+ if (!PrivilegedFileHelper.delete(f))
// TODO possible place of error: FileNotFoundException when we delete/update existing
// Value and then add/update again.
// After the time the Cleaner will delete the file which is mapped to the Value.
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportImport.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportImport.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportImport.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -22,7 +22,6 @@
import org.xml.sax.SAXException;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Calendar;
@@ -102,7 +101,7 @@
}
}
- destFile.delete();
+ PrivilegedFileHelper.delete(destFile);
}
public void testExportImportCustomNodeType() throws Exception
@@ -181,7 +180,7 @@
}
}
- destFile.delete();
+ PrivilegedFileHelper.delete(destFile);
}
public void testMixinExportImportDocumentViewContentHandler() throws Exception
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportSysView.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportSysView.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/exporting/TestExportSysView.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -28,7 +28,6 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Calendar;
@@ -237,7 +236,7 @@
testNode.unlock();
testNode.remove();
session.save();
- assertTrue(destFile.delete());
+ assertTrue(PrivilegedFileHelper.delete(destFile));
}
public void testMultyValueExportCh() throws ItemExistsException, PathNotFoundException, VersionException,
@@ -297,7 +296,7 @@
}
}
}
- destFile.delete();
+ PrivilegedFileHelper.delete(destFile);
}
public void testMultyValueExportStream() throws ItemExistsException, PathNotFoundException, VersionException,
@@ -351,7 +350,7 @@
}
}
}
- destFile.delete();
+ PrivilegedFileHelper.delete(destFile);
}
public void testMultyValueExportStreamSkipBinary() throws ItemExistsException, PathNotFoundException,
@@ -403,7 +402,7 @@
}
}
}
- destFile.delete();
+ PrivilegedFileHelper.delete(destFile);
}
public void testWithContentHandler() throws RepositoryException, SAXException
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestSystemViewImport.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestSystemViewImport.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/importing/TestSystemViewImport.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -31,8 +31,6 @@
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -622,7 +620,7 @@
if (xmlContent != null)
{
- xmlContent.delete();
+ PrivilegedFileHelper.delete(xmlContent);
}
super.tearDown();
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestUpdate.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestUpdate.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/writing/TestUpdate.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -22,7 +22,6 @@
import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.File;
-import java.io.FileInputStream;
import java.io.InputStream;
import javax.jcr.Node;
@@ -73,7 +72,7 @@
{
log.error(e);
pds.close();
- propData.delete();
+ PrivilegedFileHelper.delete(propData);
ws1session.refresh(false);
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceManagement.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceManagement.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceManagement.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -161,7 +161,7 @@
}
finally
{
- file.delete();
+ PrivilegedFileHelper.delete(file);
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestFileBasedNamespaceMappings.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestFileBasedNamespaceMappings.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/query/lucene/TestFileBasedNamespaceMappings.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -21,8 +21,9 @@
import junit.framework.TestCase;
+import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
+
import java.io.File;
-import java.io.FileOutputStream;
import java.util.Properties;
/**
@@ -79,7 +80,7 @@
@Override
protected void tearDown() throws Exception
{
- test_mapp.delete();
+ PrivilegedFileHelper.delete(test_mapp);
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCleanableFileStreamValueData.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCleanableFileStreamValueData.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCleanableFileStreamValueData.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -105,7 +105,7 @@
if (PrivilegedFileHelper.exists(testFile))
{
- testFile.delete();
+ PrivilegedFileHelper.delete(testFile);
}
TestSwapFile.cleanShare();
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationLogTestLoad.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationLogTestLoad.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationLogTestLoad.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -24,7 +24,6 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.util.Calendar;
import java.util.List;
@@ -57,7 +56,7 @@
fis.close();
- file.delete();
+ PrivilegedFileHelper.delete(file);
List<TransactionChangesLog> logs = pl.pushChanges();
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -20,14 +20,11 @@
import org.exoplatform.services.jcr.impl.dataflow.AbstractPersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.FilePersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData;
import org.exoplatform.services.jcr.impl.util.io.PrivilegedFileHelper;
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -103,7 +100,7 @@
jcrread += t3;
jcrin.close();
- jcrfile.delete();
+ PrivilegedFileHelper.delete(jcrfile);
}
@@ -138,7 +135,7 @@
javaRead += t4;
jin.close();
- jfile.delete();
+ PrivilegedFileHelper.delete(jfile);
}
System.out.println(" JCR s- " + (jcrwrite / iterations));
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/MultipleDeserializationTestLoad.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -29,8 +29,6 @@
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
@@ -158,7 +156,7 @@
jcrread += t3;
jcrin.close();
}
- jcrfile.delete();
+ PrivilegedFileHelper.delete(jcrfile);
System.out.println(" JCR first des - " + (jcrfread));
System.out.println(" JCR des- " + (jcrread / iterations));
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestEOFException.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestEOFException.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/TestEOFException.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -24,8 +24,6 @@
import java.io.EOFException;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Random;
@@ -66,7 +64,7 @@
or.close();
}
- test.delete();
+ PrivilegedFileHelper.delete(test);
}
public void testReadBoolean() throws Exception
@@ -95,7 +93,7 @@
or.close();
}
- test.delete();
+ PrivilegedFileHelper.delete(test);
}
public void testReadInt() throws Exception
@@ -125,7 +123,7 @@
or.close();
}
- test.delete();
+ PrivilegedFileHelper.delete(test);
}
public void testReadLong() throws Exception
@@ -155,7 +153,7 @@
or.close();
}
- test.delete();
+ PrivilegedFileHelper.delete(test);
}
protected byte[] createBLOBTempData(int size) throws IOException
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -628,12 +628,12 @@
{
if (sf.isDirectory() && PrivilegedFileHelper.list(sf).length > 0)
count += deleteRecursive(sf);
- else if (sf.delete())
+ else if (PrivilegedFileHelper.delete(sf))
count += 1;
else
LOG.warn("Can't delete file " + PrivilegedFileHelper.getAbsolutePath(sf));
}
- count += dir.delete() ? 1 : 0;
+ count += PrivilegedFileHelper.delete(dir) ? 1 : 0;
return count;
}
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -74,7 +74,7 @@
File file = new File(rootDir, "testReadFromIOChannel0");
PrivilegedFileHelper.deleteOnExit(file);
if (PrivilegedFileHelper.exists(file))
- file.delete();
+ PrivilegedFileHelper.delete(file);
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
out.close();
@@ -83,7 +83,7 @@
file = new File(rootDir, "testReadFromIOChannel1");
if (PrivilegedFileHelper.exists(file))
- file.delete();
+ PrivilegedFileHelper.delete(file);
out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
out.close();
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileValueIO.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileValueIO.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileValueIO.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -87,7 +87,7 @@
byte[] buf = "0123456789".getBytes();
File file = new File("target/testReadByteArrayValueData");
if (PrivilegedFileHelper.exists(file))
- file.delete();
+ PrivilegedFileHelper.delete(file);
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
out.close();
@@ -109,7 +109,7 @@
byte[] buf = "0123456789".getBytes();
File file = new File("target/testReadFileValueData");
if (PrivilegedFileHelper.exists(file))
- file.delete();
+ PrivilegedFileHelper.delete(file);
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
out.close();
@@ -138,7 +138,7 @@
byte[] buf = "0123456789".getBytes();
File file = new File("target/testWriteFileValueData");
if (PrivilegedFileHelper.exists(file))
- file.delete();
+ PrivilegedFileHelper.delete(file);
TransientValueData vd = new TransientValueData(0, buf, null, null, null, 1024, null, false);
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/TestValueFileIOHelper.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/TestValueFileIOHelper.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/TestValueFileIOHelper.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -132,7 +132,7 @@
@Override
public void tearDown() throws Exception
{
- dest.delete();
+ PrivilegedFileHelper.delete(dest);
super.tearDown();
}
@@ -173,7 +173,7 @@
System.out.println("\t=== IO time " + (System.currentTimeMillis() - start));
// clean and recreate file
- dest.delete();
+ PrivilegedFileHelper.delete(dest);
dest = PrivilegedFileHelper.createTempFile("vdftest", "", testDir);
// copy via NIO
@@ -256,7 +256,7 @@
System.out.println("\t=== IO time " + (System.currentTimeMillis() - start));
// clean and recreate file
- dest.delete();
+ PrivilegedFileHelper.delete(dest);
dest = PrivilegedFileHelper.createTempFile("vdftest", "", testDir);
// copy via NIO
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/tools/tree/generator/RandomValueNodeGenerator.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/tools/tree/generator/RandomValueNodeGenerator.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/tools/tree/generator/RandomValueNodeGenerator.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -100,7 +100,7 @@
val.getStream();// to spool data;
inputStream.close();
if (file != null)
- file.delete();
+ PrivilegedFileHelper.delete(file);
break;
case PropertyType.BOOLEAN :
val = valueFactory.createValue(random.nextBoolean());
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -60,7 +60,7 @@
byte[] buf = "0123456789".getBytes();
File file = new File("target/testCreateFileStreamValueData");
if (PrivilegedFileHelper.exists(file))
- file.delete();
+ PrivilegedFileHelper.delete(file);
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
out.close();
@@ -113,7 +113,7 @@
.getBytes();
File file = new File("target/testConcurrentFileStreamValueDataReading");
if (PrivilegedFileHelper.exists(file))
- file.delete();
+ PrivilegedFileHelper.delete(file);
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
// approx. 10Kb file
for (int i = 0; i < 100; i++)
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueData.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueData.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestTransientValueData.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -71,7 +71,7 @@
byte[] buf = "0123456789".getBytes();
File file = new File("target/testCreateFileStreamTransientValueData");
if (PrivilegedFileHelper.exists(file))
- file.delete();
+ PrivilegedFileHelper.delete(file);
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
out.close();
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestValueImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestValueImpl.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestValueImpl.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -55,7 +55,7 @@
byte[] buf = "012345678901234567890123456789".getBytes();
File file = new File("target/testNewBinaryValue");
if (PrivilegedFileHelper.exists(file))
- file.delete();
+ PrivilegedFileHelper.delete(file);
FileOutputStream out = PrivilegedFileHelper.fileOutputStream(file);
out.write(buf);
out.close();
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestConcurrentItems.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestConcurrentItems.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestConcurrentItems.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -113,7 +113,7 @@
try
{
if (testFile != null)
- testFile.delete();
+ PrivilegedFileHelper.delete(testFile);
}
catch (Throwable e)
{
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestExportBigFiles.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestExportBigFiles.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/load/blob/TestExportBigFiles.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -101,7 +101,7 @@
n1.remove();
session.save();
PrivilegedFileHelper.deleteOnExit(file);
- file.delete();
+ PrivilegedFileHelper.delete(file);
}
@@ -165,7 +165,7 @@
n1.remove();
session.save();
PrivilegedFileHelper.deleteOnExit(file);
- file.delete();
+ PrivilegedFileHelper.delete(file);
}
public void testIEPdfFiles() throws Exception
@@ -225,7 +225,7 @@
n1.remove();
session.save();
PrivilegedFileHelper.deleteOnExit(file);
- file.delete();
+ PrivilegedFileHelper.delete(file);
}
public void testRandomSizeExportImportSysView() throws Exception
@@ -297,7 +297,7 @@
n1.remove();
session.save();
PrivilegedFileHelper.deleteOnExit(file);
- file.delete();
+ PrivilegedFileHelper.delete(file);
}
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java 2010-06-14 12:17:27 UTC (rev 2577)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java 2010-06-14 12:20:45 UTC (rev 2578)
@@ -112,6 +112,6 @@
}
assertTrue(PrivilegedFileHelper.exists(vd2.getFile()));
- f.delete();
+ PrivilegedFileHelper.delete(f);
}
}
14 years, 3 months
exo-jcr SVN: r2577 - in jcr/trunk/exo.jcr.component.core: src/test/java/org/exoplatform/services/jcr and 1 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-06-14 08:17:27 -0400 (Mon, 14 Jun 2010)
New Revision: 2577
Modified:
jcr/trunk/exo.jcr.component.core/pom.xml
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java
jcr/trunk/exo.jcr.component.core/src/test/resources/test.policy
Log:
EXOJCR-756 BaseStandaloneTest now uses /target/test-classes/test.policy instead of src/test/resources/test.policy
Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml 2010-06-14 12:06:33 UTC (rev 2576)
+++ jcr/trunk/exo.jcr.component.core/pom.xml 2010-06-14 12:17:27 UTC (rev 2577)
@@ -468,7 +468,7 @@
<goal>run</goal>
</goals>
</execution>
- <!-- execution>
+ <execution>
<id>prepare-test-policy</id>
<phase>process-test-resources</phase>
<configuration>
@@ -489,7 +489,7 @@
<goals>
<goal>run</goal>
</goals>
- </execution -->
+ </execution>
</executions>
<dependencies>
<dependency>
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java 2010-06-14 12:06:33 UTC (rev 2576)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java 2010-06-14 12:17:27 UTC (rev 2577)
@@ -164,7 +164,7 @@
fileCleaner = wfcleaner.getFileCleaner();
holder = new ReaderSpoolFileHolder();
- URL url = Thread.currentThread().getContextClassLoader().getResource("test.policy");
+ URL url = Thread.currentThread().getContextClassLoader().getResource("./test.policy");
Policy.setPolicy(new PolicyFile(url));
System.setSecurityManager(new SecurityManager());
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/test.policy
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/test.policy 2010-06-14 12:06:33 UTC (rev 2576)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/test.policy 2010-06-14 12:17:27 UTC (rev 2577)
@@ -1,14 +1,14 @@
-grant codeBase "@MAVEN_REPO@/-"{
+grant codeBase "file:@MAVEN_REPO@/-"{
permission java.security.AllPermission;
};
-grant codeBase "@MAIN_CLASSES@/-"{
+grant codeBase "file:@MAIN_CLASSES@/-"{
permission java.security.AllPermission;
};
-grant codeBase "@TEST_CLASSES@/-"{
+grant codeBase "file:@TEST_CLASSES@/-"{
permission java.lang.RuntimePermission "setSecurityManager";
permission java.lang.RuntimePermission "getJCRSystemSession";
permission java.lang.RuntimePermission "manageRepository";
14 years, 3 months