exo-jcr SVN: r1957 - parent/tags.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-02-26 11:21:29 -0500 (Fri, 26 Feb 2010)
New Revision: 1957
Added:
parent/tags/5/
Log:
[maven-scm] copy for tag 5
Copied: parent/tags/5 (from rev 1956, parent/trunk)
14 years, 2 months
exo-jcr SVN: r1955 - in jcr/trunk/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core/query/lucene and 1 other directories.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2010-02-26 03:32:46 -0500 (Fri, 26 Feb 2010)
New Revision: 1955
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexUpdateMonitor.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DefaultIndexUpdateMonitor.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexUpdateMonitor.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestIndexUpdateMonitor.java
Log:
EXOJCR-540 : Changed logic of system workspace handling in
JBossCacheIndexUpdateMonitor class in a same way as it did in
JBossCacheIndexInfos class
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java 2010-02-25 20:36:58 UTC (rev 1954)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java 2010-02-26 08:32:46 UTC (rev 1955)
@@ -90,7 +90,8 @@
// try to get pushState parameters, since they are set programmatically only
Boolean pushState = config.getParameterBoolean(QueryHandlerParams.PARAM_JBOSSCACHE_PUSHSTATE, false);
- Integer pushStateTimeOut = config.getParameterInteger(QueryHandlerParams.PARAM_JBOSSCACHE_PUSHSTATE_TIMEOUT, 10000);
+ Integer pushStateTimeOut =
+ config.getParameterInteger(QueryHandlerParams.PARAM_JBOSSCACHE_PUSHSTATE_TIMEOUT, 10000);
singletonStoreProperties.setProperty("pushStateWhenCoordinator", pushState.toString());
singletonStoreProperties.setProperty("pushStateWhenCoordinatorTimeout", pushStateTimeOut.toString());
@@ -126,13 +127,13 @@
if (!parentHandler.isInitialized())
{
parentHandler.setIndexInfos(new JBossCacheIndexInfos(cache, true, modeHandler));
- parentHandler.setIndexUpdateMonitor(new JBossCacheIndexUpdateMonitor(cache, modeHandler));
+ parentHandler.setIndexUpdateMonitor(new JBossCacheIndexUpdateMonitor(cache, true, modeHandler));
parentHandler.init();
}
if (!handler.isInitialized())
{
handler.setIndexInfos(new JBossCacheIndexInfos(cache, false, modeHandler));
- handler.setIndexUpdateMonitor(new JBossCacheIndexUpdateMonitor(cache, modeHandler));
+ handler.setIndexUpdateMonitor(new JBossCacheIndexUpdateMonitor(cache, false, modeHandler));
handler.init();
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexUpdateMonitor.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexUpdateMonitor.java 2010-02-25 20:36:58 UTC (rev 1954)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexUpdateMonitor.java 2010-02-26 08:32:46 UTC (rev 1955)
@@ -21,17 +21,15 @@
import org.exoplatform.services.jcr.impl.core.query.IndexerIoMode;
import org.exoplatform.services.jcr.impl.core.query.IndexerIoModeHandler;
import org.exoplatform.services.jcr.impl.core.query.IndexerIoModeListener;
+import org.exoplatform.services.jcr.impl.core.query.lucene.IndexInfos;
import org.exoplatform.services.jcr.impl.core.query.lucene.IndexUpdateMonitor;
import org.exoplatform.services.jcr.impl.core.query.lucene.IndexUpdateMonitorListener;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
-import org.jboss.cache.lock.LockManager;
-import org.jboss.cache.lock.LockType;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeModified;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
@@ -56,8 +54,10 @@
private final Cache<Serializable, Object> cache;
- private final static Fqn PARAMETER_ROOT = Fqn.fromString("INDEX_UPDATE_MONITOR");
+ private static final String INDEX_PARAMETERS = "$index_parameters".intern();
+ private static final String SYSINDEX_PARAMETERS = "$sysindex_parameters".intern();
+
private final static String PARAMETER_NAME = "index-update-in-progress";
public final IndexerIoModeHandler modeHandler;
@@ -68,25 +68,34 @@
private final List<IndexUpdateMonitorListener> listeners;
/**
+ * This FQN points to cache node, where list of indexes for this {@link IndexInfos} instance is stored.
+ */
+ private final Fqn parametersFqn;
+
+ /**
* @param cache instance of JbossCache that is used to deliver index names
*/
- public JBossCacheIndexUpdateMonitor(Cache<Serializable, Object> cache, IndexerIoModeHandler modeHandler)
+ public JBossCacheIndexUpdateMonitor(Cache<Serializable, Object> cache, boolean system,
+ IndexerIoModeHandler modeHandler)
{
this.cache = cache;
this.modeHandler = modeHandler;
this.listeners = new CopyOnWriteArrayList<IndexUpdateMonitorListener>();
+ // store parsed FQN to avoid it's parsing each time cache event is generated
+ this.parametersFqn = Fqn.fromString(system ? INDEX_PARAMETERS : SYSINDEX_PARAMETERS);
+
modeHandler.addIndexerIoModeListener(this);
Node<Serializable, Object> cacheRoot = cache.getRoot();
// prepare cache structures
- if (!cacheRoot.hasChild(PARAMETER_ROOT))
+ if (!cacheRoot.hasChild(parametersFqn))
{
cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- cacheRoot.addChild(PARAMETER_ROOT).setResident(true);
+ cacheRoot.addChild(parametersFqn).setResident(true);
}
else
{
- cache.getNode(PARAMETER_ROOT).setResident(true);
+ cache.getNode(parametersFqn).setResident(true);
}
if (IndexerIoMode.READ_WRITE == modeHandler.getMode())
@@ -98,6 +107,7 @@
// Currently READ_ONLY is set, so new lists should be fired to multiIndex.
cache.addCacheListener(this);
}
+
}
/**
@@ -124,44 +134,12 @@
*/
public boolean getUpdateInProgress()
{
- Object value = cache.get(PARAMETER_ROOT, PARAMETER_NAME);
+
+ Object value = cache.get(parametersFqn, PARAMETER_NAME);
return value != null ? (Boolean)value : false;
}
/**
- * Returns true if the node is locked (either for reading or writing) by anyone, and false otherwise.
- * @param name
- * @return
- */
- public boolean isLocked(String name)
- {
- LockManager lm = ((CacheSPI<Serializable, Object>)cache).getComponentRegistry().getComponent(LockManager.class);
- return lm.isLocked(Fqn.fromRelativeFqn(PARAMETER_ROOT, Fqn.fromString(name)));
- }
-
- /**
- * Acquires a lock of type lockType, for a given owner
- * @param name
- * @param lockType
- * @return
- * @throws InterruptedException
- */
- public boolean lock(String name, LockType lockType)
- {
-
- LockManager lm = ((CacheSPI<Serializable, Object>)cache).getComponentRegistry().getComponent(LockManager.class);
- try
- {
- return lm.lock(Fqn.fromRelativeFqn(PARAMETER_ROOT, Fqn.fromString(name)), lockType, Integer.MAX_VALUE);
- }
- catch (InterruptedException e)
- {
- log.warn("An error occurs while tryning to lock the node " + name, e);
- }
- return false;
- }
-
- /**
* @see org.exoplatform.services.jcr.impl.core.query.lucene.IndexUpdateMonitor#setUpdateInProgress(boolean)
*/
public void setUpdateInProgress(boolean updateInProgress)
@@ -172,7 +150,7 @@
}
try
{
- cache.put(PARAMETER_ROOT, PARAMETER_NAME, new Boolean(updateInProgress));
+ cache.put(parametersFqn, PARAMETER_NAME, new Boolean(updateInProgress));
for (IndexUpdateMonitorListener listener : listeners)
{
listener.onUpdateInProgressChange(updateInProgress);
@@ -186,17 +164,6 @@
}
/**
- * Releases the lock passed in
- * @param name
- */
- public void unlock(String name)
- {
- LockManager lm = ((CacheSPI<Serializable, Object>)cache).getComponentRegistry().getComponent(LockManager.class);
- lm.unlock(Fqn.fromRelativeFqn(PARAMETER_ROOT, Fqn.fromString(name)), cache.getInvocationContext()
- .getGlobalTransaction());
- }
-
- /**
* @see org.exoplatform.services.jcr.impl.core.query.lucene.IndexUpdateMonitor#addIndexUpdateMonitorListener(org.exoplatform.services.jcr.impl.core.query.lucene.IndexUpdateMonitorListener)
*/
public void addIndexUpdateMonitorListener(IndexUpdateMonitorListener listener)
@@ -212,7 +179,7 @@
@NodeModified
public void cacheNodeModified(NodeModifiedEvent event)
{
- if (!event.isPre() && event.getFqn().equals(PARAMETER_ROOT))
+ if (!event.isPre() && event.getFqn().equals(parametersFqn))
{
Object value = null;
Map<?, ?> data = event.getData();
@@ -227,7 +194,7 @@
if (value == null)
{
log.warn("The data cannot be found, we will try to get it from the cache");
- value = cache.get(PARAMETER_ROOT, PARAMETER_NAME);
+ value = cache.get(parametersFqn, PARAMETER_NAME);
}
boolean updateInProgress = value != null ? (Boolean)value : false;
for (IndexUpdateMonitorListener listener : listeners)
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DefaultIndexUpdateMonitor.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DefaultIndexUpdateMonitor.java 2010-02-25 20:36:58 UTC (rev 1954)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DefaultIndexUpdateMonitor.java 2010-02-26 08:32:46 UTC (rev 1955)
@@ -18,8 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import org.jboss.cache.lock.LockType;
-
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -32,12 +30,12 @@
public class DefaultIndexUpdateMonitor implements IndexUpdateMonitor
{
private final AtomicBoolean updateInProgress;
-
+
/**
* The list of all the listeners
*/
private final List<IndexUpdateMonitorListener> listeners;
-
+
/**
* @param semaphore
*/
@@ -67,33 +65,10 @@
for (IndexUpdateMonitorListener listener : listeners)
{
listener.onUpdateInProgressChange(updateInProgress);
- }
+ }
}
/**
- * @see org.exoplatform.services.jcr.impl.core.query.lucene.IndexUpdateMonitor#unlock(java.lang.String)
- */
- public void unlock(String name)
- {
- }
-
- /**
- * @see org.exoplatform.services.jcr.impl.core.query.lucene.IndexUpdateMonitor#lock(java.lang.String, org.jboss.cache.lock.LockType)
- */
- public boolean lock(String name, LockType lockType)
- {
- return false;
- }
-
- /**
- * @see org.exoplatform.services.jcr.impl.core.query.lucene.IndexUpdateMonitor#isLocked(java.lang.String)
- */
- public boolean isLocked(String name)
- {
- return false;
- }
-
- /**
* @see org.exoplatform.services.jcr.impl.core.query.lucene.IndexUpdateMonitor#addIndexUpdateMonitorListener(org.exoplatform.services.jcr.impl.core.query.lucene.IndexUpdateMonitorListener)
*/
public void addIndexUpdateMonitorListener(IndexUpdateMonitorListener listener)
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexUpdateMonitor.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexUpdateMonitor.java 2010-02-25 20:36:58 UTC (rev 1954)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexUpdateMonitor.java 2010-02-26 08:32:46 UTC (rev 1955)
@@ -18,7 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import org.jboss.cache.lock.LockType;
/**
* @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
@@ -42,27 +41,5 @@
* @param listener the listener to add
*/
void addIndexUpdateMonitorListener(IndexUpdateMonitorListener listener);
-
- /**
- * Returns true if the node is locked (either for reading or writing) by anyone, and false otherwise.
- * @param name
- * @return
- */
- public boolean isLocked(String name);
- /**
- * Acquires a lock of type lockType, for a given owner
- * @param name
- * @param lockType
- * @return
- * @throws InterruptedException
- */
- public boolean lock(String name, LockType lockType);
-
- /**
- * Releases the lock passed in
- * @param name
- */
- public void unlock(String name);
-
}
\ No newline at end of file
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestIndexUpdateMonitor.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestIndexUpdateMonitor.java 2010-02-25 20:36:58 UTC (rev 1954)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestIndexUpdateMonitor.java 2010-02-26 08:32:46 UTC (rev 1955)
@@ -29,10 +29,8 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.lock.LockType;
import java.io.Serializable;
-import java.util.concurrent.atomic.AtomicBoolean;
/**
* @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
@@ -59,7 +57,8 @@
// TODO Auto-generated method stub
super.setUp();
cache = createCache();
- indexUpdateMonitor = new JBossCacheIndexUpdateMonitor(cache, new IndexerIoModeHandler(IndexerIoMode.READ_WRITE));
+ indexUpdateMonitor =
+ new JBossCacheIndexUpdateMonitor(cache, false, new IndexerIoModeHandler(IndexerIoMode.READ_WRITE));
}
/**
@@ -92,177 +91,6 @@
}
- public void testLock() throws Exception
- {
- String lockName = "testLock";
- assertFalse(indexUpdateMonitor.isLocked(lockName));
- assertTrue(indexUpdateMonitor.lock(lockName, LockType.WRITE));
- assertTrue(indexUpdateMonitor.isLocked(lockName));
- LockChecker checker = new LockChecker(indexUpdateMonitor, lockName);
- Thread lockThread = new Thread(checker);
- assertFalse(checker.isWaiting());
- lockThread.start();
- assertTrue(checker.isWaiting());
- indexUpdateMonitor.unlock(lockName);
- assertFalse(checker.isWaiting());
-
- }
-
- public void _testMultiThread() throws Exception
- {
- AtomicBoolean atomicBoolean = new AtomicBoolean();
- ThreadGroup chengers = new ThreadGroup("Changers");
- ThreadGroup checkers = new ThreadGroup("Checkers");
- Thread[] changersArray = new Thread[10];
- Thread[] checkerArray = new Thread[10];
-
- for (int i = 0; i < changersArray.length; i++)
- {
- changersArray[i] = new Thread(chengers, new UpdateMonitorChanger(atomicBoolean));
- changersArray[i].start();
- }
-
- for (int i = 0; i < checkerArray.length; i++)
- {
- checkerArray[i] = new Thread(checkers, new UpdateMonitorChecker(atomicBoolean));
- checkerArray[i].start();
- }
-
- // Thread changer = new Thread(new UpdateMonitorChanger(atomicBoolean));
- // changer.start();
- // Thread checker = new Thread(new UpdateMonitorChecker(atomicBoolean));
- // checker.start();
-
- Thread.sleep(4 * 60 * 1000);
- chengers.destroy();
- checkers.destroy();
- }
-
- private class LockChecker implements Runnable
- {
- private final String lockName;
-
- private boolean waiting = false;
-
- /**
- * @return the waiting
- */
- protected boolean isWaiting()
- {
- return waiting;
- }
-
- /**
- * @param indexUpdateMonitor
- */
- public LockChecker(IndexUpdateMonitor indexUpdateMonitor, String lockName)
- {
- super();
- this.indexUpdateMonitor = indexUpdateMonitor;
- this.lockName = lockName;
- }
-
- private final IndexUpdateMonitor indexUpdateMonitor;
-
- /**
- * @see java.lang.Runnable#run()
- */
- public void run()
- {
- waiting = true;
- assertTrue(indexUpdateMonitor.lock(lockName, LockType.WRITE));
- waiting = false;
- }
- }
-
- private class UpdateMonitorChanger implements Runnable
- {
- private AtomicBoolean atomicBoolean;
-
- /**
- * @param atomicBoolean
- */
- public UpdateMonitorChanger(AtomicBoolean atomicBoolean)
- {
- super();
- this.atomicBoolean = atomicBoolean;
- }
-
- /**
- * @see java.lang.Runnable#run()
- */
- public void run()
- {
- while (!Thread.currentThread().isInterrupted())
- {
-
- synchronized (atomicBoolean)
- {
- assertEquals(atomicBoolean.get(), indexUpdateMonitor.getUpdateInProgress());
- boolean oldValue = atomicBoolean.get();
-
- indexUpdateMonitor.setUpdateInProgress(!oldValue);
-
- if (!atomicBoolean.compareAndSet(oldValue, !oldValue))
- {
- log.warn("Fail to change monitor");
- }
- }
- }
-
- }
- }
-
- private class UpdateMonitorChecker implements Runnable
- {
-
- /**
- * @param atomicBoolean
- */
- public UpdateMonitorChecker(AtomicBoolean atomicBoolean)
- {
- super();
- this.atomicBoolean = atomicBoolean;
- }
-
- private final AtomicBoolean atomicBoolean;
-
- /**
- * @see java.lang.Runnable#run()
- */
- public void run()
- {
-
- while (!Thread.currentThread().isInterrupted())
- {
-
- synchronized (atomicBoolean)
- {
- //assertEquals(atomicBoolean.get(), indexUpdateMonitor.getUpdateInProgress());
- if (atomicBoolean.get() == indexUpdateMonitor.getUpdateInProgress())
- {
- System.out.println("check ok");
- }
- else
- {
- System.out.println("check fail");
- }
-
- }
-
- try
- {
- Thread.sleep(100);
- }
- catch (InterruptedException e)
- {
- return;
- }
- }
-
- }
- }
-
private Cache<Serializable, Object> createCache()
{
String jbcConfig = "conf/cluster/test-jbosscache-indexer-config-exoloader_db1_ws.xml";
14 years, 2 months
exo-jcr SVN: r1954 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-02-25 15:36:58 -0500 (Thu, 25 Feb 2010)
New Revision: 1954
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
Log:
EXOJCR-519: I reverted the changes on the order by clause since it doesn't seem to have any performances effects.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-02-25 19:28:16 UTC (rev 1953)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-02-25 20:36:58 UTC (rev 1954)
@@ -206,7 +206,7 @@
"select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
+ " from JCR_MITEM I, JCR_MITEM P, JCR_MVALUE V"
+ " where I.PARENT_ID=? and I.I_CLASS=1 and (P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
- + " order by I.N_ORDER_NUM, I.ID, P.ID";
+ + " order by I.N_ORDER_NUM, I.ID, PROP_NAME DESC, V.ORDER_NUM";
FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
"select I.NAME, V.DATA"
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-02-25 19:28:16 UTC (rev 1953)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-02-25 20:36:58 UTC (rev 1954)
@@ -214,7 +214,7 @@
"select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
+ " from JCR_SITEM I, JCR_SITEM P, JCR_SVALUE V"
+ " where I.CONTAINER_NAME=? and I.PARENT_ID=? and I.I_CLASS=1 and (P.CONTAINER_NAME=? and P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
- + " order by I.N_ORDER_NUM, I.ID, P.ID";
+ + " order by I.N_ORDER_NUM, I.ID, PROP_NAME DESC, V.ORDER_NUM";
FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
"select I.NAME, V.DATA"
14 years, 2 months
exo-jcr SVN: r1953 - kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-02-25 14:28:16 -0500 (Thu, 25 Feb 2010)
New Revision: 1953
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationUnmarshaller.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/NoKernelNamespaceSAXFilter.java
Log:
EXOJCR-547: Log level reduced to Trace
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationUnmarshaller.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationUnmarshaller.java 2010-02-25 18:18:49 UTC (rev 1952)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/ConfigurationUnmarshaller.java 2010-02-25 19:28:16 UTC (rev 1953)
@@ -26,9 +26,7 @@
import org.jibx.runtime.IBindingFactory;
import org.jibx.runtime.IUnmarshallingContext;
import org.w3c.dom.Document;
-import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -41,7 +39,6 @@
import java.util.Collections;
import java.util.Set;
-import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
@@ -53,10 +50,6 @@
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.validation.Validator;
/**
* Unmarshall a configuration.
@@ -91,7 +84,8 @@
{
if (exception.getMessage().equals("cvc-elt.1: Cannot find the declaration of element 'configuration'."))
{
- log.info("The document "
+ log
+ .info("The document "
+ url
+ " does not contain a schema declaration, it should have an "
+ "XML declaration similar to\n"
@@ -103,7 +97,7 @@
else
{
log.error("In document " + url + " at (" + exception.getLineNumber() + "," + exception.getColumnNumber()
- + ") :" + exception.getMessage());
+ + ") :" + exception.getMessage());
}
valid = false;
}
@@ -141,11 +135,9 @@
public boolean isValid(URL url) throws NullPointerException, IOException
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- String[] schemas = {
- Namespaces.KERNEL_1_0_URI,
- Namespaces.KERNEL_1_1_URI
- };
- factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
+ String[] schemas = {Namespaces.KERNEL_1_0_URI, Namespaces.KERNEL_1_1_URI};
+ factory
+ .setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", schemas);
factory.setNamespaceAware(true);
factory.setValidating(true);
@@ -175,11 +167,11 @@
{
if (PropertyManager.isDevelopping())
{
- boolean valid = isValid(url);
- if (!valid)
- {
- log.info("The configuration file " + url + " was not found valid according to its XSD");
- }
+ boolean valid = isValid(url);
+ if (!valid)
+ {
+ log.info("The configuration file " + url + " was not found valid according to its XSD");
+ }
}
//
@@ -188,9 +180,12 @@
{
// With Java 6, it's safer to precise the builder factory class name as it may result:
// java.lang.AbstractMethodError: org.apache.xerces.dom.DeferredDocumentImpl.getXmlStandalone()Z
- // at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.setDocumentInfo(Unknown Source)
+ // at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.setDocumentInfo(Unknown Source)
Method dbfniMethod = DocumentBuilderFactory.class.getMethod("newInstance", String.class, ClassLoader.class);
- factory = (DocumentBuilderFactory)dbfniMethod.invoke(null, "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl", Thread.currentThread().getContextClassLoader());
+ factory =
+ (DocumentBuilderFactory)dbfniMethod.invoke(null,
+ "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl", Thread.currentThread()
+ .getContextClassLoader());
}
catch (InvocationTargetException e)
{
@@ -246,7 +241,8 @@
String document = buffer.toString();
// Debug
- log.debug("About to parse configuration file " + document);
+ if (log.isTraceEnabled())
+ log.trace("About to parse configuration file " + document);
//
IBindingFactory bfact = BindingDirectory.getFactory(Configuration.class);
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/NoKernelNamespaceSAXFilter.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/NoKernelNamespaceSAXFilter.java 2010-02-25 18:18:49 UTC (rev 1952)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/configuration/NoKernelNamespaceSAXFilter.java 2010-02-25 19:28:16 UTC (rev 1953)
@@ -18,6 +18,9 @@
*/
package org.exoplatform.container.configuration;
+import static org.exoplatform.container.configuration.Namespaces.KERNEL_1_0_URI;
+import static org.exoplatform.container.configuration.Namespaces.KERNEL_1_1_URI;
+
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.xml.sax.Attributes;
@@ -29,7 +32,6 @@
import java.util.HashSet;
import java.util.Set;
-import static org.exoplatform.container.configuration.Namespaces.*;
/**
* Removes kernel namespace declaration from the document to not confuse the jibx thing.
@@ -79,12 +81,14 @@
if (KERNEL_1_0_URI.equals(uri) || KERNEL_1_1_URI.equals(uri) || XSI_URI.equals(uri))
{
blackListedPrefixes.add(prefix);
- log.debug("Black listing prefix " + prefix + " with uri " + uri);
+ if (log.isTraceEnabled())
+ log.trace("Black listing prefix " + prefix + " with uri " + uri);
}
else
{
contentHandler.startPrefixMapping(prefix, uri);
- log.debug("Start prefix mapping " + prefix + " with uri " + uri);
+ if (log.isTraceEnabled())
+ log.trace("Start prefix mapping " + prefix + " with uri " + uri);
}
}
@@ -92,31 +96,34 @@
{
if (!blackListedPrefixes.remove(prefix))
{
- log.debug("Ending prefix mapping " + prefix);
+ if (log.isTraceEnabled())
+ log.trace("Ending prefix mapping " + prefix);
contentHandler.endPrefixMapping(prefix);
}
else
{
- log.debug("Removed prefix mapping " + prefix + " from black list ");
+ if (log.isTraceEnabled())
+ log.trace("Removed prefix mapping " + prefix + " from black list ");
}
}
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException
{
- Set<String> profiles = null;
AttributesImpl noNSAtts = new AttributesImpl();
- for (int i = 0;i < atts.getLength();i++)
+ for (int i = 0; i < atts.getLength(); i++)
{
String attQName = atts.getQName(i);
if ((attQName.equals("xmlns")) && blackListedPrefixes.contains(""))
{
// Skip
- log.debug("Skipping black listed xmlns attribute");
+ if (log.isTraceEnabled())
+ log.trace("Skipping black listed xmlns attribute");
}
else if (attQName.startsWith("xmlns:") && blackListedPrefixes.contains(attQName.substring(6)))
{
// Skip
- log.debug("Skipping black listed " + attQName + " attribute");
+ if (log.isTraceEnabled())
+ log.trace("Skipping black listed " + attQName + " attribute");
}
else
{
@@ -129,12 +136,14 @@
if (XSI_URI.equals(attURI))
{
// Skip
- log.debug("Skipping XSI " + attQName + " attribute");
+ if (log.isTraceEnabled())
+ log.trace("Skipping XSI " + attQName + " attribute");
continue;
}
else if (KERNEL_1_0_URI.equals(attURI) || KERNEL_1_1_URI.equals(attURI))
{
- log.debug("Requalifying prefixed attribute " + attQName + " attribute to " + localName);
+ if (log.isTraceEnabled())
+ log.trace("Requalifying prefixed attribute " + attQName + " attribute to " + localName);
attURI = null;
attQName = localName;
}
@@ -147,7 +156,8 @@
//
if (KERNEL_1_0_URI.equals(uri) || KERNEL_1_1_URI.equals(uri))
{
- log.debug("Requalifying active profile " + qName + " start element to " + localName);
+ if (log.isTraceEnabled())
+ log.trace("Requalifying active profile " + qName + " start element to " + localName);
qName = localName;
uri = null;
}
@@ -160,13 +170,15 @@
{
if (KERNEL_1_0_URI.equals(uri) || KERNEL_1_1_URI.equals(uri))
{
- log.debug("Requalifying " + qName + " end element");
+ if (log.isTraceEnabled())
+ log.trace("Requalifying " + qName + " end element");
qName = localName;
uri = null;
}
//
- log.debug("Propagatting " + qName + " end element");
+ if (log.isTraceEnabled())
+ log.trace("Propagatting " + qName + " end element");
contentHandler.endElement(uri, localName, qName);
}
14 years, 2 months
exo-jcr SVN: r1952 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-02-25 13:18:49 -0500 (Thu, 25 Feb 2010)
New Revision: 1952
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
Log:
EXOJCR-519: During heavy load the explain plan change and the database does a full scan due to the sub-select and use a temporary table due to the sort by ORDER_NUM, both have been removed.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-02-25 12:04:15 UTC (rev 1951)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-02-25 18:18:49 UTC (rev 1952)
@@ -204,10 +204,10 @@
FIND_NODES_BY_PARENTID_CQ =
"select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
- + " from (select * from JCR_MITEM where PARENT_ID=? and I_CLASS=1) I, JCR_MITEM P, JCR_MVALUE V"
- + " where (P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
- + " order by I.N_ORDER_NUM, I.ID, PROP_NAME DESC, V.ORDER_NUM";
-
+ + " from JCR_MITEM I, JCR_MITEM P, JCR_MVALUE V"
+ + " where I.PARENT_ID=? and I.I_CLASS=1 and (P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
+ + " order by I.N_ORDER_NUM, I.ID, P.ID";
+
FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
"select I.NAME, V.DATA"
+ " from JCR_MITEM I, JCR_MVALUE V"
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-02-25 12:04:15 UTC (rev 1951)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-02-25 18:18:49 UTC (rev 1952)
@@ -212,9 +212,9 @@
FIND_NODES_BY_PARENTID_CQ =
"select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
- + " from (select * from JCR_SITEM where CONTAINER_NAME=? and PARENT_ID=? AND I_CLASS=1) I, JCR_SITEM P, JCR_SVALUE V"
- + " where (P.CONTAINER_NAME=? and P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
- + " order by I.N_ORDER_NUM, I.ID, PROP_NAME DESC, V.ORDER_NUM";
+ + " from JCR_SITEM I, JCR_SITEM P, JCR_SVALUE V"
+ + " where I.CONTAINER_NAME=? and I.PARENT_ID=? and I.I_CLASS=1 and (P.CONTAINER_NAME=? and P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
+ + " order by I.N_ORDER_NUM, I.ID, P.ID";
FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
"select I.NAME, V.DATA"
14 years, 2 months
exo-jcr SVN: r1951 - in kernel/trunk/exo.kernel.container/src: main/java/org/exoplatform/container/util and 3 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-02-25 07:04:15 -0500 (Thu, 25 Feb 2010)
New Revision: 1951
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal/myPortal-pcdef/settings.properties
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings.properties
Log:
EXOJCR-528: Allow to use ${name}, ${rest} and ${realm} in the external properties file
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-02-24 15:39:10 UTC (rev 1950)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/definition/PortalContainerConfig.java 2010-02-25 12:04:15 UTC (rev 1951)
@@ -481,21 +481,36 @@
String path = def.getExternalSettingsPath();
if (path != null && (path = path.trim()).length() > 0)
{
- final Map<String, String> props = loadExternalSettings(path, def.getName());
+ final Map<String, String> props = loadExternalSettings(path, def);
if (props != null && !props.isEmpty())
{
mergeSettings(settings, props);
}
}
- // We then add the portal container name
+ // We then add the main settings
+ settings.putAll(getMainSettings(def));
+ // We re-inject the settings and we make sure it is thread safe
+ def.setSettings(Collections.unmodifiableMap(settings));
+ }
+
+ /**
+ * This method gives the main settings such as the portal container name, the rest context name
+ * and the realm name into a {@link Map}
+ * @param def the {@link PortalContainerDefinition} from which we extract the value of the main
+ * settings, if a main setting is null, we use the default value.
+ * @return A {@link Map} of settings including the main settings
+ */
+ private Map<String, String> getMainSettings(PortalContainerDefinition def)
+ {
+ final Map<String, String> settings = new HashMap<String, String>(3);
+ // We add the portal container name
settings.put(PORTAL_CONTAINER_SETTING_NAME, def.getName());
// We add the rest context name
settings.put(REST_CONTEXT_SETTING_NAME, def.getRestContextName() == null ? defaultRestContextName : def
.getRestContextName());
// We add the realm name
settings.put(REALM_SETTING_NAME, def.getRealmName() == null ? defaultRealmName : def.getRealmName());
- // We re-inject the settings and we make sure it is thread safe
- def.setSettings(Collections.unmodifiableMap(settings));
+ return settings;
}
/**
@@ -515,10 +530,10 @@
* by the {@link ConfigurationManager}</li>
* </ol>
* @param path the path of the external settings to load
- * @param portalContainerName the name of the related portal container
+ * @param def the {@link PortalContainerDefinition} for which we load the external settings
* @return A {@link Map} of settings if the file could be loaded, <code>null</code> otherwise
*/
- private Map<String, String> loadExternalSettings(String path, String portalContainerName)
+ private Map<String, String> loadExternalSettings(String path, PortalContainerDefinition def)
{
try
{
@@ -526,7 +541,7 @@
if (path.indexOf(':') == -1)
{
// We first check if the file is not in eXo configuration directory
- String fullPath = serverInfo.getExoConfigurationDirectory() + "/portal/" + portalContainerName + "/" + path;
+ String fullPath = serverInfo.getExoConfigurationDirectory() + "/portal/" + def.getName() + "/" + path;
File file = new File(fullPath);
if (file.exists())
{
@@ -540,7 +555,7 @@
url = cm.getURL(path);
}
// We load the properties from the url found
- return ContainerUtil.loadProperties(url);
+ return ContainerUtil.loadProperties(url, getMainSettings(def));
}
catch (Exception e)
{
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java 2010-02-24 15:39:10 UTC (rev 1950)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java 2010-02-25 12:04:15 UTC (rev 1951)
@@ -208,6 +208,17 @@
*/
public static Map<String, String> loadProperties(URL url)
{
+ return loadProperties(url, null);
+ }
+
+ /**
+ * Loads the properties file corresponding to the given url
+ * @param url the url of the properties file
+ * @param initEnv the initial environment that is composed of a set of initial variables
+ * @return a {@link Map} of properties
+ */
+ public static Map<String, String> loadProperties(URL url, Map<String, String> initEnv)
+ {
LinkedHashMap<String, String> props = null;
String path = null;
InputStream in = null;
@@ -243,7 +254,12 @@
if (props != null)
{
// Those properties are used for variables resolution
- final LinkedHashMap<String, String> currentProps = new LinkedHashMap<String,String>();
+ final Map<String, String> currentProps = new HashMap<String,String>();
+ if (initEnv != null && !initEnv.isEmpty())
+ {
+ // There are a set of initial variables to load into the environment
+ currentProps.putAll(initEnv);
+ }
for (Map.Entry<String, String> entry : props.entrySet())
{
String propertyName = entry.getKey();
Modified: kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-02-24 15:39:10 UTC (rev 1950)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-02-25 12:04:15 UTC (rev 1951)
@@ -278,7 +278,7 @@
assertEquals("20", config.getSetting("myPortal-pcdef", "long"));
assertEquals("20", config.getSetting("myPortal-pcdef", "double"));
assertEquals("false", config.getSetting("myPortal-pcdef", "boolean"));
- assertEquals("value-new value", config.getSetting("myPortal-pcdef", "complex-value"));
+ assertEquals("myPortal-pcdef-myRest-pcdef-my-exo-domain-pcdef-value-new value", config.getSetting("myPortal-pcdef", "complex-value"));
assertNull(config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
assertNull(config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
@@ -311,7 +311,7 @@
assertEquals("22", config.getSetting("myPortal-pcdef", "long"));
assertEquals("22", config.getSetting("myPortal-pcdef", "double"));
assertEquals("true", config.getSetting("myPortal-pcdef", "boolean"));
- assertEquals("value 2-new value 2", config.getSetting("myPortal-pcdef", "complex-value"));
+ assertEquals("myPortal-pcdef-myRest-pcdef-my-exo-domain-pcdef-value 2-new value 2", config.getSetting("myPortal-pcdef", "complex-value"));
assertNull(config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
assertNull(config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal/myPortal-pcdef/settings.properties
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal/myPortal-pcdef/settings.properties 2010-02-24 15:39:10 UTC (rev 1950)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal/myPortal-pcdef/settings.properties 2010-02-25 12:04:15 UTC (rev 1951)
@@ -4,4 +4,4 @@
long=22
double=22
boolean=true
-complex-value=${foo2}-${string}
\ No newline at end of file
+complex-value=${name}-${rest}-${realm}-${foo2}-${string}
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings.properties
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings.properties 2010-02-24 15:39:10 UTC (rev 1950)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings.properties 2010-02-25 12:04:15 UTC (rev 1951)
@@ -4,4 +4,4 @@
long=20
double=20
boolean=false
-complex-value=${foo2}-${string}
\ No newline at end of file
+complex-value=${name}-${rest}-${realm}-${foo2}-${string}
\ No newline at end of file
14 years, 2 months
exo-jcr SVN: r1950 - jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-02-24 10:39:10 -0500 (Wed, 24 Feb 2010)
New Revision: 1950
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MkColCommand.java
Log:
EXOJCR-220 status message and log.error() added
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2010-02-24 10:56:38 UTC (rev 1949)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2010-02-24 15:39:10 UTC (rev 1950)
@@ -201,6 +201,7 @@
}
catch (RepositoryException exc)
{
+ log.error(exc.getMessage(), exc);
return Response.serverError().entity(exc.getMessage()).build();
}
catch (Exception exc)
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MkColCommand.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MkColCommand.java 2010-02-24 10:56:38 UTC (rev 1949)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/MkColCommand.java 2010-02-24 15:39:10 UTC (rev 1950)
@@ -113,6 +113,7 @@
}
catch (RepositoryException exc)
{
+ log.error(exc.getMessage(), exc);
return Response.serverError().entity(exc.getMessage()).build();
}
14 years, 2 months
exo-jcr SVN: r1949 - in kernel/trunk/exo.kernel.container/src: main/java/org/exoplatform/container/xml and 5 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-02-24 05:56:38 -0500 (Wed, 24 Feb 2010)
New Revision: 1949
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Deserializer.java
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPropertyManagerConfigurator.java
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal/myPortal-pcdef/settings.properties
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings.properties
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/property-configurator.properties
kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/property-configurator.xml
Log:
EXOJCR-543: It was not possible anymore to create a variable thanks to another variables.
UnitTests have been added and bug has been fixed
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java 2010-02-24 10:56:15 UTC (rev 1948)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/util/ContainerUtil.java 2010-02-24 10:56:38 UTC (rev 1949)
@@ -242,12 +242,15 @@
}
if (props != null)
{
+ // Those properties are used for variables resolution
+ final LinkedHashMap<String, String> currentProps = new LinkedHashMap<String,String>();
for (Map.Entry<String, String> entry : props.entrySet())
{
String propertyName = entry.getKey();
String propertyValue = entry.getValue();
- propertyValue = Deserializer.resolveString(propertyValue);
+ propertyValue = Deserializer.resolveVariables(propertyValue, currentProps);
props.put(propertyName, propertyValue);
+ currentProps.put(propertyName, propertyValue);
}
}
}
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Deserializer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Deserializer.java 2010-02-24 10:56:15 UTC (rev 1948)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Deserializer.java 2010-02-24 10:56:38 UTC (rev 1949)
@@ -23,6 +23,8 @@
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.RootContainer;
+import java.util.Map;
+
/**
* A deserializer used by JIBX that resolve system properties to allow runtime configuration.
*
@@ -182,6 +184,18 @@
*/
public static String resolveVariables(String input)
{
+ return resolveVariables(input, null);
+ }
+
+ /**
+ * Resolve the variables of type ${my.var} for the current context which is composed
+ * of the system properties, the portal container properties and the given properties
+ * @param input the input value
+ * @param props a set of properties to add for the variable resolution
+ * @return the resolve value
+ */
+ public static String resolveVariables(String input, Map<String, String> props)
+ {
final int NORMAL = 0;
final int SEEN_DOLLAR = 1;
final int IN_BRACKET = 2;
@@ -241,7 +255,17 @@
}
else
{
- value = System.getProperty(key);
+ if (props != null)
+ {
+ // Some properties have been given thus we need to check inside first
+ value = props.get(key);
+ }
+ if (value == null)
+ {
+ // No value could be found so far, thus we try to get it from the
+ // system properties
+ value = System.getProperty(key);
+ }
}
if (value != null)
{
Modified: kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPropertyManagerConfigurator.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPropertyManagerConfigurator.java 2010-02-24 10:56:15 UTC (rev 1948)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPropertyManagerConfigurator.java 2010-02-24 10:56:38 UTC (rev 1949)
@@ -19,6 +19,7 @@
package org.exoplatform.container;
import junit.framework.TestCase;
+
import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.commons.utils.Tools;
import org.exoplatform.container.configuration.ConfigurationManagerImpl;
@@ -111,6 +112,7 @@
assertEquals("property_value_1", additions.get("property_1"));
assertEquals("property_value_2", additions.get("property_2"));
assertEquals("${property_3}", additions.get("property_3"));
+ assertEquals("property_value_1-property_value_2", additions.get("property_4"));
}
public void testFromPropertiesByParam() throws Exception
@@ -129,6 +131,7 @@
assertEquals("property_value_1", additions.get("property_1"));
assertEquals("property_value_2", additions.get("property_2"));
assertEquals("${property_3}", additions.get("property_3"));
+ assertEquals("property_value_1-property_value_2", additions.get("property_4"));
}
public void testFromProperties() throws Exception
@@ -146,6 +149,7 @@
assertEquals("property_value_1", additions.get("property_1"));
assertEquals("property_value_2", additions.get("property_2"));
assertEquals("${property_3}", additions.get("property_3"));
+ assertEquals("property_value_1-property_value_2", additions.get("property_4"));
}
public void testFromXML() throws Exception
@@ -163,5 +167,6 @@
assertEquals("property_value_1", additions.get("property_1"));
assertEquals("property_value_2", additions.get("property_2"));
assertEquals("${property_3}", additions.get("property_3"));
+ assertEquals("property_value_1-property_value_2", additions.get("property_4"));
}
}
Modified: kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-02-24 10:56:15 UTC (rev 1948)
+++ kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/definition/TestPortalContainerConfig.java 2010-02-24 10:56:38 UTC (rev 1949)
@@ -278,6 +278,7 @@
assertEquals("20", config.getSetting("myPortal-pcdef", "long"));
assertEquals("20", config.getSetting("myPortal-pcdef", "double"));
assertEquals("false", config.getSetting("myPortal-pcdef", "boolean"));
+ assertEquals("value-new value", config.getSetting("myPortal-pcdef", "complex-value"));
assertNull(config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
assertNull(config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
@@ -310,6 +311,7 @@
assertEquals("22", config.getSetting("myPortal-pcdef", "long"));
assertEquals("22", config.getSetting("myPortal-pcdef", "double"));
assertEquals("true", config.getSetting("myPortal-pcdef", "boolean"));
+ assertEquals("value 2-new value 2", config.getSetting("myPortal-pcdef", "complex-value"));
assertNull(config.getSetting("foo", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
assertNull(config.getSetting("myPortal", PortalContainerConfig.PORTAL_CONTAINER_SETTING_NAME));
assertEquals("myPortal-pcdef", config.getSetting("myPortal-pcdef",
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal/myPortal-pcdef/settings.properties
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal/myPortal-pcdef/settings.properties 2010-02-24 10:56:15 UTC (rev 1948)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/portal/myPortal-pcdef/settings.properties 2010-02-24 10:56:38 UTC (rev 1949)
@@ -3,4 +3,5 @@
int=22
long=22
double=22
-boolean=true
\ No newline at end of file
+boolean=true
+complex-value=${foo2}-${string}
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings.properties
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings.properties 2010-02-24 10:56:15 UTC (rev 1948)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/definition/settings.properties 2010-02-24 10:56:38 UTC (rev 1949)
@@ -3,4 +3,5 @@
int=20
long=20
double=20
-boolean=false
\ No newline at end of file
+boolean=false
+complex-value=${foo2}-${string}
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/property-configurator.properties
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/property-configurator.properties 2010-02-24 10:56:15 UTC (rev 1948)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/property-configurator.properties 2010-02-24 10:56:38 UTC (rev 1949)
@@ -1,3 +1,4 @@
property_1=property_value_1
property_2=${property_2}
-property_3=${property_3}
\ No newline at end of file
+property_3=${property_3}
+property_4=${property_1}-${property_2}
\ No newline at end of file
Modified: kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/property-configurator.xml
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/property-configurator.xml 2010-02-24 10:56:15 UTC (rev 1948)
+++ kernel/trunk/exo.kernel.container/src/test/resources/org/exoplatform/container/property-configurator.xml 2010-02-24 10:56:38 UTC (rev 1949)
@@ -4,4 +4,5 @@
<entry key="property_1">property_value_1</entry>
<entry key="property_2">${property_2}</entry>
<entry key="property_3">${property_3}</entry>
+<entry key="property_4">${property_1}-${property_2}</entry>
</properties>
\ No newline at end of file
14 years, 2 months