exo-jcr SVN: r1638 - in jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster: load and 1 other directory.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2010-02-03 04:11:25 -0500 (Wed, 03 Feb 2010)
New Revision: 1638
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AvgResponceTimeTest.java
Log:
EXOJCR-413 : test responce time
Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AvgResponceTimeTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AvgResponceTimeTest.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AvgResponceTimeTest.java 2010-02-03 09:11:25 UTC (rev 1638)
@@ -0,0 +1,350 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.cluster.load;
+
+import junit.framework.TestCase;
+
+import org.exoplatform.common.http.client.HTTPResponse;
+import org.exoplatform.services.jcr.cluster.JCRWebdavConnection;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.Timer;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
+ * @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
+ *
+ */
+public class AvgResponceTimeTest extends TestCase
+{
+ /**
+ * WebDav realm
+ */
+ private String WEBDAV_REALM = "eXo REST services";
+
+ /**
+ * WebDav path
+ */
+ private String WEBDAV_DEFAULT_PATH = "/rest/jcr/repository/production/";
+
+ /**
+ * 10 sec default sampling time.
+ */
+ private static final int SAMPLING_TIME = 14000;
+
+ /**
+ * 2min default time of work of one iteration.
+ */
+ private static final int ITERATION_TIME = 60 * 1000;
+
+ /**
+ * How much thread will be added on the next iteration.
+ */
+ private static final int ITERATION_GROWING_POLL = 5;
+
+ /**
+ * Number between 0 and 100 show % how many read operations.
+ */
+ private static final int READ_VALUE = 90;
+
+ private static final Random random = new Random();
+
+ private volatile static long l1FolderCount = 0;
+
+ private static long lastCleanTime;
+
+ /**
+ * Statistic dumper task
+ */
+ private static final Timer STAT_TIMER = new Timer(true);
+
+ public void testResponce() throws Exception
+ {
+ final List<NodeInfo> nodesPath = new ArrayList<NodeInfo>();
+ //start from 1 thread
+ int threadCount = 0;
+ lastCleanTime = System.currentTimeMillis();
+
+ while (true)
+ {
+
+ final List<WorkerResult> responceResults = Collections.synchronizedList(new ArrayList<WorkerResult>());
+ threadCount += ITERATION_GROWING_POLL;
+ ExecutorService tp = Executors.newFixedThreadPool(threadCount);
+ WorkerThread[] workedThread = new WorkerThread[threadCount];
+ for (int i = 0; i < threadCount; i++)
+ {
+ workedThread[i] = new WorkerThread(nodesPath, responceResults);
+ tp.execute(workedThread[i]);
+
+ }
+ responceResults.clear();
+ System.out.println("Thread started " + threadCount);
+ Thread.sleep(ITERATION_TIME);
+
+ for (int i = 0; i < workedThread.length; i++)
+ {
+ workedThread[i].setShoudRun(false);
+ }
+ tp.shutdown();
+ //wait 10 minutes
+ tp.awaitTermination(60 * 10, TimeUnit.SECONDS);
+ dumpResults(responceResults);
+ responceResults.clear();
+
+ }
+ }
+
+ public static void dumpResults(List<WorkerResult> responceResults)
+ {
+ long sum_read = 0;
+ long sum_write = 0;
+ long read = 0;
+ long write = 0;
+ for (WorkerResult workerResult : responceResults)
+ {
+
+ if (workerResult.isRead)
+ {
+ read++;
+ sum_read += workerResult.responceTime;
+ }
+ else
+ {
+ write++;
+ sum_write += workerResult.responceTime;
+ }
+ }
+ if ((read + write) > 0)
+ {
+ System.out.println("Read=" + read + " Write=" + write + " value " + (read * 100 / (read + write))
+ + " Avg read resp=" + (read > 0 ? (sum_read / read) : 0) + " Avg write resp="
+ + (write > 0 ? (sum_write / write) : 0));
+ //System.out.println(responceResults);
+ }
+ responceResults.clear();
+ }
+
+ private class NodeInfo
+ {
+ private final String path;
+
+ private final long created;
+
+ /**
+ * @param path
+ * @param created
+ */
+ public NodeInfo(String path, long created)
+ {
+ super();
+ this.path = path;
+ this.created = created;
+ }
+
+ }
+
+ private class WorkerResult
+ {
+ private final boolean isRead;
+
+ private final long responceTime;
+
+ /**
+ * @param isRead
+ * @param responceTime
+ */
+ public WorkerResult(boolean isRead, long responceTime)
+ {
+ super();
+ this.isRead = isRead;
+ this.responceTime = responceTime;
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ return "WorkerResult [isRead=" + isRead + ", responceTime=" + responceTime + "]";
+ }
+
+ }
+
+ private class WorkerThread implements Runnable
+ {
+
+ private final List<WorkerResult> responceResults;
+
+ private final List<NodeInfo> nodesPath;
+
+ private String l1FolderName;
+
+ private long l2FolderCount;
+
+ private boolean shoudRun;
+
+ /**
+ * @param nodesPath
+ * @param resultsList
+ */
+ public WorkerThread(List<NodeInfo> nodesPath, List<WorkerResult> responceResults)
+ {
+ this.nodesPath = nodesPath;
+ this.responceResults = responceResults;
+ this.shoudRun = true;
+ }
+
+ /**
+ * @see java.lang.Runnable#run()
+ */
+ public void run()
+ {
+
+ while (shoudRun)
+ {
+ if (random.nextInt(100) > READ_VALUE)
+ {
+
+ doWrite();
+ }
+ else
+ {
+ doRead();
+ }
+ }
+
+ }
+
+ /**
+ * @return the shoudRun
+ */
+ protected boolean isShoudRun()
+ {
+ return shoudRun;
+ }
+
+ /**
+ * @param shoudRun the shoudRun to set
+ */
+ protected void setShoudRun(boolean shoudRun)
+ {
+ this.shoudRun = shoudRun;
+ }
+
+ private JCRWebdavConnection getNewConnection()
+ {
+ return new JCRWebdavConnection("192.168.0.129", 80, "root", "exo", WEBDAV_REALM, WEBDAV_DEFAULT_PATH);
+ }
+
+ /**
+ * Make write operation.
+ */
+ private void doWrite()
+ {
+ long start = 0;
+ JCRWebdavConnection connection = null;
+ try
+ {
+ connection = getNewConnection();
+
+ if (l1FolderName == null || l2FolderCount == 100)
+ {
+ l1FolderName = "folder" + (l1FolderCount++);
+ start = System.currentTimeMillis();
+ connection.addDir(l1FolderName);
+ l2FolderCount = 0;
+ responceResults.add(new WorkerResult(false, System.currentTimeMillis() - start));
+ }
+ String path = l1FolderName + "/" + "node" + l2FolderCount++;
+ start = System.currentTimeMillis();
+ HTTPResponse response = connection.addNode(path, ("__the_data_in_nt+file__" + l2FolderCount).getBytes());
+
+ if (response.getStatusCode() != 201)
+ {
+ System.out.println(Thread.currentThread().getName() + " : Can not add (response code "
+ + response.getStatusCode() + new String(response.getData()) + " ) node with path : " + path);
+ }
+ responceResults.add(new WorkerResult(false, System.currentTimeMillis() - start));
+ nodesPath.add(new NodeInfo(path, System.currentTimeMillis()));
+ }
+ catch (Exception e)
+ {
+ System.out.println(e.getLocalizedMessage());
+ }
+ finally
+ {
+ if (connection != null)
+ {
+ connection.stop();
+ }
+ }
+
+ }
+
+ /**
+ * Make
+ */
+ private void doRead()
+ {
+ if (nodesPath.size() > 0)
+ {
+
+ String readNodePath = null;
+ while (readNodePath == null)
+ {
+ NodeInfo nodeInfo = nodesPath.get(random.nextInt(nodesPath.size()));
+ // if ((System.currentTimeMillis() - nodeInfo.created) > 30000)
+ // {
+ readNodePath = nodeInfo.path;
+ // }
+
+ }
+ long start = System.currentTimeMillis();
+ JCRWebdavConnection conn = getNewConnection();
+ try
+ {
+ HTTPResponse response = conn.getNode(readNodePath);
+ if (response.getStatusCode() != 200)
+ {
+ System.out.println("Can not get (response code " + response.getStatusCode()
+ + new String(response.getData()) + " ) node with path : " + readNodePath);
+ }
+
+ }
+ catch (Exception e)
+ {
+ System.out.println(e.getLocalizedMessage());
+ }
+ finally
+ {
+ conn.stop();
+ }
+ responceResults.add(new WorkerResult(true, System.currentTimeMillis() - start));
+ }
+ }
+ }
+}
Property changes on: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/cluster/load/AvgResponceTimeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 7 months
exo-jcr SVN: r1637 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-02-02 11:16:52 -0500 (Tue, 02 Feb 2010)
New Revision: 1637
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java
Log:
EXOJCR-451 : The problem with NullPointerException on serialization of PlainChangesLogImpl was fixed.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java 2010-02-02 16:15:48 UTC (rev 1636)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java 2010-02-02 16:16:52 UTC (rev 1637)
@@ -36,6 +36,9 @@
*/
public class PlainChangesLogImpl implements Externalizable, PlainChangesLog
{
+ private static final int NULL_VALUE = -1;
+
+ private static final int NOT_NULL_VALUE = 1;
private static final long serialVersionUID = 5624550860372364084L;
@@ -224,9 +227,17 @@
out.writeObject(items.get(i));
}
- buff = pairId.getBytes(Constants.DEFAULT_ENCODING);
- out.writeInt(buff.length);
- out.write(buff);
+ if (pairId != null)
+ {
+ out.writeInt(NOT_NULL_VALUE);
+ buff = pairId.getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buff.length);
+ out.write(buff);
+ }
+ else
+ {
+ out.writeInt(NULL_VALUE);
+ }
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
@@ -243,9 +254,12 @@
add((ItemState)in.readObject());
}
- buf = new byte[in.readInt()];
- in.readFully(buf);
- pairId = new String(buf, Constants.DEFAULT_ENCODING);
+ if (in.readInt() == NOT_NULL_VALUE)
+ {
+ buf = new byte[in.readInt()];
+ in.readFully(buf);
+ pairId = new String(buf, Constants.DEFAULT_ENCODING);
+ }
}
// ------------------ [ END ] ------------------
}
14 years, 7 months
exo-jcr SVN: r1636 - jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-02-02 11:15:48 -0500 (Tue, 02 Feb 2010)
New Revision: 1636
Modified:
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.sybase.sql
Log:
EXOJCR-403: remove comments
Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.sybase.sql
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.sybase.sql 2010-02-02 14:04:13 UTC (rev 1635)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.sybase.sql 2010-02-02 16:15:48 UTC (rev 1636)
@@ -1,43 +1,3 @@
-/* --Before database will be created we have to create 'disk' with enough amount of free space
-use master
-go
-
-disk init name = 'EXOJCR',
-physname = '/opt/Sybase/ASELE/data/exojcr',
-size = '400M',
-cntrltype = 0
-go
-
-sp_deviceattr 'EXOJCR', dsync, true
-go
-
--- Creating database 'portal', 'jcr', 'jcr2'
-use master
-go
-
-create database portal on EXOJCR
-go
-create database jcr on EXOJCR
-go
-create database jcr2 on EXOJCR
-go
-
--- Enable indexes in database turning on 'select into' option
-use master
-go
-sp_dboption portal, 'select into', true
-go
-sp_dboption jcr, 'select into', true
-go
-sp_dboption jcr2, 'select into', true
-go
-
--- NOTE: User creating tables we must have a DBO rights for the target database
--- NOTE: Index maximum length is 600 bytes
--- NOTE: VARBINARY storage size is the actual size of the data values entered, not the column length.
--- NOTE: set number of user connection according your pool configuration: sp_configure "number of user connection", 200
-*/
-
CREATE TABLE JCR_SCONTAINER(
VERSION VARCHAR(96) NOT NULL,
CONSTRAINT JCR_PK_MCONTAINER PRIMARY KEY(VERSION)
14 years, 7 months
exo-jcr SVN: r1635 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-02-02 09:04:13 -0500 (Tue, 02 Feb 2010)
New Revision: 1635
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java
Log:
EXOJCR-449 : The implementation methods getAllChildNodeDefinitions and getAllPropertyDefinitions in NodeTypeDataManagerImpl was changed.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java 2010-02-02 10:02:57 UTC (rev 1634)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java 2010-02-02 14:04:13 UTC (rev 1635)
@@ -176,27 +176,44 @@
public NodeDefinitionData[] getAllChildNodeDefinitions(final InternalQName... nodeTypeNames)
{
- final Collection<NodeDefinitionData> defs = new HashSet<NodeDefinitionData>();
+ final Collection<NodeDefinitionData> defsAny = new ArrayList<NodeDefinitionData>();
+ final HashMap<InternalQName, NodeDefinitionData> defs = new HashMap<InternalQName, NodeDefinitionData>();
for (final InternalQName ntname : nodeTypeNames)
{
- for (final NodeDefinitionData cnd : this.nodeTypeRepository.getNodeType(ntname)
- .getDeclaredChildNodeDefinitions())
- {
- defs.add(cnd);
- }
-
for (final InternalQName suname : this.nodeTypeRepository.getSupertypes(ntname))
{
for (final NodeDefinitionData cnd : this.nodeTypeRepository.getNodeType(suname)
.getDeclaredChildNodeDefinitions())
{
- defs.add(cnd);
+ if (cnd.getName().equals(Constants.JCR_ANY_NAME))
+ {
+ defsAny.add(cnd);
+ }
+ else
+ {
+ defs.put(cnd.getName(), cnd);
+ }
}
}
+
+ for (final NodeDefinitionData cnd : this.nodeTypeRepository.getNodeType(ntname)
+ .getDeclaredChildNodeDefinitions())
+ {
+ if (cnd.getName().equals(Constants.JCR_ANY_NAME))
+ {
+ defsAny.add(cnd);
+ }
+ else
+ {
+ defs.put(cnd.getName(), cnd);
+ }
+ }
}
+
+ defsAny.addAll(defs.values());
- return defs.toArray(new NodeDefinitionData[defs.size()]);
+ return defsAny.toArray(new NodeDefinitionData[defsAny.size()]);
}
/**
@@ -224,48 +241,9 @@
public PropertyDefinitionData[] getAllPropertyDefinitions(final InternalQName... nodeTypeNames)
{
- class Key
- {
- private InternalQName name;
-
- private boolean isMulti;
-
- public Key(InternalQName name, boolean isMulti)
- {
- this.name = name;
- this.isMulti = isMulti;
- }
-
- /**
- * {@inheritDoc}
- */
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + (isMulti ? 1231 : 1237);
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean equals(Object obj)
- {
- if (!(obj instanceof Key))
- {
- return false;
- }
-
- Key k = (Key) obj;
-
- return name.equals(k.name) && isMulti == k.isMulti;
- }
- }
+ final Collection<PropertyDefinitionData> defsAny = new ArrayList<PropertyDefinitionData>();
+ final HashMap<InternalQName, PropertyDefinitionData> defs = new HashMap<InternalQName, PropertyDefinitionData>();
- final HashMap<Key, PropertyDefinitionData> defs = new HashMap<Key, PropertyDefinitionData>();
-
for (final InternalQName ntname : nodeTypeNames)
{
@@ -274,19 +252,34 @@
for (final PropertyDefinitionData pd : this.nodeTypeRepository.getNodeType(suname)
.getDeclaredPropertyDefinitions())
{
-
- defs.put(new Key(pd.getName(), pd.isMultiple()), pd);
+ if (pd.getName().equals(Constants.JCR_ANY_NAME))
+ {
+ defsAny.add(pd);
+ }
+ else
+ {
+ defs.put(pd.getName(), pd);
+ }
}
}
for (final PropertyDefinitionData pd : this.nodeTypeRepository.getNodeType(ntname)
.getDeclaredPropertyDefinitions())
{
- defs.put(new Key(pd.getName(), pd.isMultiple()), pd);
+ if (pd.getName().equals(Constants.JCR_ANY_NAME))
+ {
+ defsAny.add(pd);
+ }
+ else
+ {
+ defs.put(pd.getName(), pd);
+ }
}
}
- return defs.values().toArray(new PropertyDefinitionData[defs.size()]);
+ defsAny.addAll(defs.values());
+
+ return defsAny.toArray(new PropertyDefinitionData[defsAny.size()]);
}
/**
14 years, 7 months
exo-jcr SVN: r1634 - in jcr/trunk/exo.jcr.component.core/src: test/resources/conf/standalone/cluster and 1 other directory.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-02-02 05:02:57 -0500 (Tue, 02 Feb 2010)
New Revision: 1634
Modified:
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/test-jbosscache-data.xml
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-jbosscache-data.xml
Log:
EXOJCR-434: MaxNodes extended upto 1M
Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/test-jbosscache-data.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/test-jbosscache-data.xml 2010-02-02 09:50:16 UTC (rev 1633)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/conf/portal/test-jbosscache-data.xml 2010-02-02 10:02:57 UTC (rev 1634)
@@ -15,7 +15,7 @@
<default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm"
actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ParentNodeEvictionActionPolicy"
eventQueueSize="1000000">
- <property name="maxNodes" value="10000" />
+ <property name="maxNodes" value="1000000" />
<property name="timeToLive" value="120000" />
</default>
</eviction>
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-jbosscache-data.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-jbosscache-data.xml 2010-02-02 09:50:16 UTC (rev 1633)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-jbosscache-data.xml 2010-02-02 10:02:57 UTC (rev 1634)
@@ -15,7 +15,7 @@
<default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm"
actionPolicyClass="org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.ParentNodeEvictionActionPolicy"
eventQueueSize="1000000">
- <property name="maxNodes" value="10000" />
+ <property name="maxNodes" value="1000000" />
<property name="timeToLive" value="120000" />
</default>
</eviction>
14 years, 7 months
exo-jcr SVN: r1633 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-02-02 04:50:16 -0500 (Tue, 02 Feb 2010)
New Revision: 1633
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
Log:
EXOJCR-465: tm.setTransactionTimeout has to be called before tm.begin, a TL has been added to remind the application that a Transaction Timeout has already been set
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java 2010-02-02 08:18:34 UTC (rev 1632)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java 2010-02-02 09:50:16 UTC (rev 1633)
@@ -19,6 +19,8 @@
package org.exoplatform.services.transaction.jbosscache;
import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import org.exoplatform.services.transaction.ExoResource;
import org.exoplatform.services.transaction.TransactionService;
import org.jboss.cache.transaction.TransactionManagerLookup;
@@ -41,8 +43,12 @@
*/
public class GenericTransactionService implements TransactionService
{
-
/**
+ * The logger
+ */
+ private static final Log LOG = ExoLogger.getLogger(GenericTransactionService.class);
+
+ /**
* The default value of a transaction timeout in seconds
*/
private static final int DEFAULT_TIME_OUT = 60;
@@ -230,6 +236,11 @@
* The default timeout of the {@link Transaction}
*/
private final int defaultTimeout;
+
+ /**
+ * This is used to know if a timeout has already been set for the next transaction
+ */
+ private final ThreadLocal<Boolean> timeoutHasBeenSet = new ThreadLocal<Boolean>();
public TransactionManagerTxTimeoutAware(TransactionManager tm, int defaultTimeout)
{
@@ -242,9 +253,25 @@
*/
public void begin() throws NotSupportedException, SystemException
{
+ if (timeoutHasBeenSet.get() != null)
+ {
+ // clean the ThreadLocal
+ timeoutHasBeenSet.set(null);
+ }
+ else
+ {
+ try
+ {
+ // Set the default transaction timeout
+ tm.setTransactionTimeout(defaultTimeout);
+ }
+ catch (Exception e)
+ {
+ LOG.warn("Cannot set the transaction timeout", e);
+ }
+ }
+ // Start the transaction
tm.begin();
- // Set the default transaction timeout
- tm.setTransactionTimeout(defaultTimeout);
}
/**
@@ -302,6 +329,7 @@
public void setTransactionTimeout(int timeout) throws SystemException
{
tm.setTransactionTimeout(timeout);
+ timeoutHasBeenSet.set(true);
}
/**
14 years, 7 months
exo-jcr SVN: r1632 - in jcr/trunk/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/usecases/nodetypes and 1 other directory.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-02-02 03:18:34 -0500 (Tue, 02 Feb 2010)
New Revision: 1632
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/InmemoryNodeTypeRepository.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/nodetypes/TestGettingExoScriptProperty.java
Log:
EXOJCR-449 : The problem with overdetermination properties in node type was fixed.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/InmemoryNodeTypeRepository.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/InmemoryNodeTypeRepository.java 2010-02-01 18:23:22 UTC (rev 1631)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/InmemoryNodeTypeRepository.java 2010-02-02 08:18:34 UTC (rev 1632)
@@ -80,7 +80,7 @@
{
hierarchy.addNodeType(nodeType, volatileNodeTypes);
- defsHolder.putDefinitions(nodeType.getName(), nodeType);
+
// put supers
final Set<InternalQName> supers = hierarchy.getSupertypes(nodeType.getName(), volatileNodeTypes);
@@ -89,6 +89,9 @@
defsHolder.putDefinitions(nodeType.getName(), hierarchy.getNodeType(superName, volatileNodeTypes));
}
haveTypes = true;
+
+ // put prop def
+ defsHolder.putDefinitions(nodeType.getName(), nodeType);
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java 2010-02-01 18:23:22 UTC (rev 1631)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java 2010-02-02 08:18:34 UTC (rev 1632)
@@ -224,27 +224,69 @@
public PropertyDefinitionData[] getAllPropertyDefinitions(final InternalQName... nodeTypeNames)
{
- final Collection<PropertyDefinitionData> defs = new HashSet<PropertyDefinitionData>();
+ class Key
+ {
+ private InternalQName name;
- for (final InternalQName ntname : nodeTypeNames)
- {
- for (final PropertyDefinitionData pd : this.nodeTypeRepository.getNodeType(ntname)
- .getDeclaredPropertyDefinitions())
+ private boolean isMulti;
+
+ public Key(InternalQName name, boolean isMulti)
{
- defs.add(pd);
+ this.name = name;
+ this.isMulti = isMulti;
}
+ /**
+ * {@inheritDoc}
+ */
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + (isMulti ? 1231 : 1237);
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof Key))
+ {
+ return false;
+ }
+
+ Key k = (Key) obj;
+
+ return name.equals(k.name) && isMulti == k.isMulti;
+ }
+ }
+
+ final HashMap<Key, PropertyDefinitionData> defs = new HashMap<Key, PropertyDefinitionData>();
+
+ for (final InternalQName ntname : nodeTypeNames)
+ {
+
for (final InternalQName suname : this.nodeTypeRepository.getSupertypes(ntname))
{
for (final PropertyDefinitionData pd : this.nodeTypeRepository.getNodeType(suname)
- .getDeclaredPropertyDefinitions())
+ .getDeclaredPropertyDefinitions())
{
- defs.add(pd);
+
+ defs.put(new Key(pd.getName(), pd.isMultiple()), pd);
}
}
+
+ for (final PropertyDefinitionData pd : this.nodeTypeRepository.getNodeType(ntname)
+ .getDeclaredPropertyDefinitions())
+ {
+ defs.put(new Key(pd.getName(), pd.isMultiple()), pd);
+ }
}
-
- return defs.toArray(new PropertyDefinitionData[defs.size()]);
+
+ return defs.values().toArray(new PropertyDefinitionData[defs.size()]);
}
/**
@@ -360,6 +402,7 @@
PropertyDefinitionDatas propertyDefinitions =
this.nodeTypeRepository.getPropertyDefinitions(propertyName, nodeTypeNames);
+
// Try super
if (propertyDefinitions == null)
{
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/nodetypes/TestGettingExoScriptProperty.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/nodetypes/TestGettingExoScriptProperty.java 2010-02-01 18:23:22 UTC (rev 1631)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/nodetypes/TestGettingExoScriptProperty.java 2010-02-02 08:18:34 UTC (rev 1632)
@@ -20,11 +20,14 @@
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import javax.jcr.Value;
import javax.jcr.nodetype.NodeType;
import javax.jcr.nodetype.NodeTypeIterator;
import javax.jcr.nodetype.NodeTypeManager;
import javax.jcr.nodetype.PropertyDefinition;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.api.nodetype.NodeTypeUtil;
import org.exoplatform.services.jcr.usecases.BaseUsecasesTest;
/**
@@ -38,177 +41,35 @@
public class TestGettingExoScriptProperty
extends BaseUsecasesTest
{
-
- public static final int ANY_PROPERTY_TYPE = -1;
-
- public void testLoadPropertyDef() throws Exception
+ public void testLoadProperyDef3() throws Exception
{
- PropertyDefinition propDef = locatePropertyDef(session, ANY_PROPERTY_TYPE, false, true, false, false);
-
- System.out.println("\n\n" +propDef.getName() + "\n\n");
-
- assertEquals(true, propDef.isProtected());
-
- if (propDef.getName().equals("exo:script")) {
- assertEquals(false, propDef.isProtected());
- }
- }
-
- public void testExoScriptProperty() throws Exception
- {
- Node rootNode = session.getRootNode();
-
- Node action = rootNode.addNode("123", "exo:scriptAction");
-
- action.setProperty( "exo:name", "exo_name__value");
- action.setProperty( "exo:lifecyclePhase", "add");
- action.setProperty( "exo:roles", new String[] {"*"});
-
- action.setProperty( "exo:script", "exo_script__value");
- session.save();
-
- PropertyDefinition[] propsDef = action.getPrimaryNodeType().getDeclaredPropertyDefinitions();
-
- for (PropertyDefinition pDef : propsDef)
- {
- if (pDef.getName().equals("exo:script")) {
-
- assertEquals(pDef.isProtected(), false);
- return;
- }
- }
-
- fail("The property definition is not found.");
- }
-
- public void testGetPropDefFromNTM() throws Exception
- {
NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
+
+ NodeType nt = manager.getNodeType("exo:addMetadataAction");
+
+ PropertyDefinition propDef = null;
+ PropertyDefinition[] propsDef = nt.getPropertyDefinitions();
- NodeType nt = manager.getNodeType("exo:scriptAction");
-
- PropertyDefinition[] propsDef = nt.getDeclaredPropertyDefinitions();
-
+ assertEquals(8, propsDef.length);
+
for (PropertyDefinition pDef : propsDef)
{
- if (pDef.getName().equals("exo:script")) {
- assertEquals(pDef.isProtected(), false);
- return;
+ if (pDef.getName().equals("exo:script"))
+ {
+ propDef = pDef;
}
}
-
- fail("The property definition is not found.");
-
- }
- public static PropertyDefinition locatePropertyDef(Session session, int propertyType, boolean multiple,
- boolean isProtected, boolean constraints, boolean residual) throws RepositoryException
- {
-
- NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
- NodeTypeIterator types = manager.getAllNodeTypes();
-
- while (types.hasNext())
+ // will never happen since at least jcr:primaryType of nt:base accomplish the request
+ if (propDef == null)
{
- NodeType type = types.nextNodeType();
- PropertyDefinition propDefs[] = type.getDeclaredPropertyDefinitions();
- for (int i = 0; i < propDefs.length; i++)
- {
- PropertyDefinition propDef = propDefs[i];
-
- System.out.println("\n\n " + propDef.getName());
+ throw new NotExecutableException("No protected property def found.");
+ }
- if (propertyType != ANY_PROPERTY_TYPE && propDef.getRequiredType() != propertyType)
- {
- continue;
- }
+ NodeType nodeType = propDef.getDeclaringNodeType();
+ Value value = NodeTypeUtil.getValueOfType(session, propDef.getRequiredType());
- if (propertyType == ANY_PROPERTY_TYPE && propDef.getRequiredType() == PropertyType.UNDEFINED)
- {
- continue;
- }
-
- if (multiple && !propDef.isMultiple())
- {
- continue;
- }
- if (!multiple && propDef.isMultiple())
- {
- continue;
- }
-
- System.out.println("isProtected && !propDef.isProtected() ==" + (isProtected && !propDef.isProtected()));
- if (isProtected && !propDef.isProtected())
- {
- continue;
- }
- if (!isProtected && propDef.isProtected())
- {
- continue;
- }
-
- String vc[] = propDef.getValueConstraints();
- if (!constraints && vc != null && vc.length > 0)
- {
- continue;
- }
- if (constraints)
- {
- // property def with constraints requested
- if (vc == null || vc.length == 0)
- {
- // property def has no constraints
- continue;
- }
- }
-
- if (!residual && propDef.getName().equals("*"))
- {
- continue;
- }
-
- if (residual && !propDef.getName().equals("*"))
- {
- continue;
- }
-
- // also skip property residual property definition if there
- // is another residual definition
- if (residual)
- {
- // check if there is another residual property def
- if (getNumResidualPropDefs(type) > 1)
- {
- continue;
- }
- }
-
- if (!residual)
- {
- // if not looking for a residual property def then there
- // must not be any residual definition at all on the node
- // type
- if (getNumResidualPropDefs(type) > 0)
- {
- continue;
- }
- }
-
- return propDef;
- }
- }
- return null;
+ assertFalse("canSetProperty(String propertyName, Value value) must "
+ + "return false if the property is protected.", nodeType.canSetProperty(propDef.getName(), value));
}
-
- private static int getNumResidualPropDefs(NodeType type) {
- PropertyDefinition[] pDefs = type.getPropertyDefinitions();
- int residuals = 0;
- for (int j = 0; j < pDefs.length; j++) {
- PropertyDefinition pDef = pDefs[j];
- if (pDef.getName().equals("*")) {
- residuals++;
- }
- }
- return residuals;
- }
}
14 years, 7 months
exo-jcr SVN: r1631 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-02-01 13:23:22 -0500 (Mon, 01 Feb 2010)
New Revision: 1631
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
Log:
EXOJCR-465: A decorator has been created to be able to set the default transaction timeout at transaction creation (i.e. tm.begin())
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java 2010-02-01 17:45:38 UTC (rev 1630)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java 2010-02-01 18:23:22 UTC (rev 1631)
@@ -19,12 +19,14 @@
package org.exoplatform.services.transaction.jbosscache;
import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
import org.exoplatform.services.transaction.ExoResource;
import org.exoplatform.services.transaction.TransactionService;
import org.jboss.cache.transaction.TransactionManagerLookup;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
@@ -39,35 +41,31 @@
*/
public class GenericTransactionService implements TransactionService
{
+
/**
- * The logger
+ * The default value of a transaction timeout in seconds
*/
- private final Log log = ExoLogger.getLogger(GenericTransactionService.class);
-
+ private static final int DEFAULT_TIME_OUT = 60;
+
/**
- * The default timeout value of a transaction set to 20s
- */
- private static final int DEFAULT_TIME_OUT = 20;
-
- /**
* TransactionManagerLookup.
*/
protected final TransactionManagerLookup tmLookup;
-
+
/**
* The default timeout
*/
protected final int defaultTimeout;
-
+
/**
* Indicates if the timeout has to be enforced
*/
protected final boolean forceTimeout;
-
+
/**
* The current Transaction Manager
*/
- private volatile TransactionManager tm;
+ private volatile TransactionManager tm;
/**
* JBossTransactionManagerLookup constructor.
@@ -78,7 +76,7 @@
{
this(tmLookup, null);
}
-
+
public GenericTransactionService(TransactionManagerLookup tmLookup, InitParams params)
{
this.tmLookup = tmLookup;
@@ -99,7 +97,7 @@
*/
public Xid createXid()
{
- throw new UnsupportedOperationException("Method createXid() not supported");
+ throw new UnsupportedOperationException("Method createXid() not supported");
}
/**
@@ -128,7 +126,7 @@
Transaction tx = tm.getTransaction();
if (tx != null)
{
- tx.enlistResource(exores.getXAResource());
+ tx.enlistResource(exores.getXAResource());
}
else
{
@@ -169,14 +167,7 @@
// Only set the timeout when a timeout has been given into the
// configuration otherwise we assume that the value will be
// set at the AS level
- try
- {
- tm.setTransactionTimeout(defaultTimeout);
- }
- catch (Exception e)
- {
- log.warn("Cannot set the transaction timeout", e);
- }
+ tm = new TransactionManagerTxTimeoutAware(tm, defaultTimeout);
}
this.tm = tm;
}
@@ -201,20 +192,124 @@
TransactionManager tm = getTransactionManager();
tm.setTransactionTimeout(seconds);
}
-
+
/**
* Allows to execute an action when we try to enlist a resource when there is no active
* transaction
*/
- protected void enlistResourceOnTxMissing(TransactionManager tm, ExoResource exores) throws RollbackException, SystemException
+ protected void enlistResourceOnTxMissing(TransactionManager tm, ExoResource exores) throws RollbackException,
+ SystemException
{
}
-
+
/**
* Allows to execute an action when we try to delist a resource when there is no active
* transaction
*/
- protected void delistResourceOnTxMissing(TransactionManager tm, ExoResource exores) throws RollbackException, SystemException
+ protected void delistResourceOnTxMissing(TransactionManager tm, ExoResource exores) throws RollbackException,
+ SystemException
{
}
+
+ /**
+ * This class is used to enforce the {@link Transaction} timeout when a new transaction is created through the nested {@link TransactionManager}
+ *
+ * Created by The eXo Platform SAS
+ * Author : Nicolas Filotto
+ * nicolas.filotto(a)exoplatform.com
+ * 1 f�vr. 2010
+ */
+ private static class TransactionManagerTxTimeoutAware implements TransactionManager
+ {
+ /**
+ * The nested {@link TransactionManager}
+ */
+ private final TransactionManager tm;
+
+ /**
+ * The default timeout of the {@link Transaction}
+ */
+ private final int defaultTimeout;
+
+ public TransactionManagerTxTimeoutAware(TransactionManager tm, int defaultTimeout)
+ {
+ this.tm = tm;
+ this.defaultTimeout = defaultTimeout;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void begin() throws NotSupportedException, SystemException
+ {
+ tm.begin();
+ // Set the default transaction timeout
+ tm.setTransactionTimeout(defaultTimeout);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
+ SecurityException, IllegalStateException, SystemException
+ {
+ tm.commit();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getStatus() throws SystemException
+ {
+ return tm.getStatus();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Transaction getTransaction() throws SystemException
+ {
+ return tm.getTransaction();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void resume(Transaction tx) throws InvalidTransactionException, IllegalStateException, SystemException
+ {
+ tm.resume(tx);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rollback() throws IllegalStateException, SecurityException, SystemException
+ {
+ tm.rollback();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setRollbackOnly() throws IllegalStateException, SystemException
+ {
+ tm.setRollbackOnly();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setTransactionTimeout(int timeout) throws SystemException
+ {
+ tm.setTransactionTimeout(timeout);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Transaction suspend() throws SystemException
+ {
+ return tm.suspend();
+ }
+ }
}
14 years, 7 months
exo-jcr SVN: r1630 - jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-02-01 12:45:38 -0500 (Mon, 01 Feb 2010)
New Revision: 1630
Modified:
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.db2.sql
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.db2v8.sql
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.db2.sql
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.db2v8.sql
Log:
EXOJCR-455 DB2 dialects support BLOBs upto 2G
Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.db2.sql
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.db2.sql 2010-02-01 12:22:56 UTC (rev 1629)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.db2.sql 2010-02-01 17:45:38 UTC (rev 1630)
@@ -20,7 +20,7 @@
CREATE UNIQUE INDEX JCR_IDX_MITEM_PARENT_ID ON JCR_MITEM(I_CLASS, PARENT_ID, ID, VERSION DESC);
CREATE TABLE JCR_MVALUE(
ID BIGINT generated by default as identity (START WITH 2, INCREMENT BY 1) NOT NULL,
- DATA BLOB,
+ DATA BLOB(2G) NOT LOGGED COMPACT,
ORDER_NUM INTEGER NOT NULL,
PROPERTY_ID VARCHAR(96) NOT NULL,
STORAGE_DESC VARCHAR(512),
Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.db2v8.sql
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.db2v8.sql 2010-02-01 12:22:56 UTC (rev 1629)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-mjdbc.db2v8.sql 2010-02-01 17:45:38 UTC (rev 1630)
@@ -20,7 +20,7 @@
CREATE UNIQUE INDEX JCR_IDX_MITEM_PID ON JCR_MITEM(I_CLASS, PARENT_ID, ID, VERSION DESC);
CREATE TABLE JCR_MVALUE(
ID BIGINT generated by default as identity (START WITH 2, INCREMENT BY 1) NOT NULL,
- DATA BLOB,
+ DATA BLOB(2G) NOT LOGGED COMPACT,
ORDER_NUM INTEGER NOT NULL,
PROPERTY_ID VARCHAR(96) NOT NULL,
STORAGE_DESC VARCHAR(512),
Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.db2.sql
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.db2.sql 2010-02-01 12:22:56 UTC (rev 1629)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.db2.sql 2010-02-01 17:45:38 UTC (rev 1630)
@@ -22,7 +22,7 @@
CREATE INDEX JCR_IDX_SITEM_PARENT_FK ON JCR_SITEM(PARENT_ID);
CREATE TABLE JCR_SVALUE(
ID BIGINT generated by default as identity (START WITH 2, INCREMENT BY 1) NOT NULL,
- DATA BLOB,
+ DATA BLOB(2G) NOT LOGGED COMPACT,
ORDER_NUM INTEGER NOT NULL,
PROPERTY_ID VARCHAR(96) NOT NULL,
STORAGE_DESC VARCHAR(512),
Modified: jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.db2v8.sql
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.db2v8.sql 2010-02-01 12:22:56 UTC (rev 1629)
+++ jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/jcr-sjdbc.db2v8.sql 2010-02-01 17:45:38 UTC (rev 1630)
@@ -22,7 +22,7 @@
CREATE INDEX JCR_IDX_SITEM_PFK ON JCR_SITEM(PARENT_ID);
CREATE TABLE JCR_SVALUE(
ID BIGINT generated by default as identity (START WITH 2, INCREMENT BY 1) NOT NULL,
- DATA BLOB,
+ DATA BLOB(2G) NOT LOGGED COMPACT,
ORDER_NUM INTEGER NOT NULL,
PROPERTY_ID VARCHAR(96) NOT NULL,
STORAGE_DESC VARCHAR(512),
14 years, 7 months
exo-jcr SVN: r1629 - in ws/trunk/exo.ws.rest.core/src: main/java/org/exoplatform/services/rest/impl and 3 other directories.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2010-02-01 07:22:56 -0500 (Mon, 01 Feb 2010)
New Revision: 1629
Added:
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ExceptionsTest.java
Removed:
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodExceptionTest.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/WebApplicationExceptionTest.java
Modified:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/ExtHttpHeaders.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java
ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/JsonEntityTest.java
Log:
EXOJCR-458 :
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/ExtHttpHeaders.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/ExtHttpHeaders.java 2010-02-01 11:15:06 UTC (rev 1628)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/ExtHttpHeaders.java 2010-02-01 12:22:56 UTC (rev 1629)
@@ -120,6 +120,13 @@
* Headers for Distributed Authoring</a> section 9 for more information.
*/
public static final String IF = "If";
+
+ /**
+ * This header indicates that body is provided via JAXR framework.
+ * Value of header MAY contain additional information about the nature
+ * of body's content, for example: 'Error-Message'.
+ */
+ public static final String JAXRS_BODY_PROVIDED = "JAXRS-Body-Provided";
/**
* WebDav "Timeout" header. See <a href='http://www.ietf.org/rfc/rfc2518.txt'>
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java 2010-02-01 11:15:06 UTC (rev 1628)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java 2010-02-01 12:22:56 UTC (rev 1629)
@@ -30,6 +30,7 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
+import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.ext.ExceptionMapper;
import org.exoplatform.container.component.ComponentPlugin;
@@ -38,6 +39,7 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.exoplatform.services.rest.ApplicationContext;
+import org.exoplatform.services.rest.ExtHttpHeaders;
import org.exoplatform.services.rest.FilterDescriptor;
import org.exoplatform.services.rest.GenericContainerRequest;
import org.exoplatform.services.rest.GenericContainerResponse;
@@ -73,12 +75,12 @@
* See {@link RequestDispatcher}.
*/
private final RequestDispatcher dispatcher;
-
+
public static final String getProperty(String name)
{
return properties.get(name);
}
-
+
public static final void setProperty(String name, String value)
{
if (value == null)
@@ -132,6 +134,14 @@
{
dispatcher.dispatch(request, response);
+ if (response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED) == null)
+ {
+ String jaxrsHeader = getJaxrsHeader(response.getStatus());
+ if (jaxrsHeader != null)
+ {
+ response.getHttpHeaders().putSingle(ExtHttpHeaders.JAXRS_BODY_PROVIDED, jaxrsHeader);
+ }
+ }
}
catch (Exception e)
@@ -142,65 +152,50 @@
Response errorResponse = ((WebApplicationException)e).getResponse();
ExceptionMapper excmap = ProviderBinder.getInstance().getExceptionMapper(WebApplicationException.class);
+ int errorStatus = errorResponse.getStatus();
// should be some of 4xx status
- if (errorResponse.getStatus() < 500)
+ if (errorStatus < 500)
{
+ // Warn about error in debug mode only.
if (LOG.isDebugEnabled() && e.getCause() != null)
{
LOG.warn("WebApplication exception occurs.", e.getCause());
}
- if (errorResponse.getEntity() == null)
+ }
+ else
+ {
+ if (e.getCause() != null)
{
- if (excmap != null)
+ LOG.warn("WebApplication exception occurs.", e.getCause());
+ }
+ }
+ // -----
+ if (errorResponse.getEntity() == null)
+ {
+ if (excmap != null)
+ {
+ errorResponse = excmap.toResponse(e);
+ }
+ else
+ {
+ if (e.getMessage() != null)
{
- errorResponse = excmap.toResponse(e);
+ errorResponse = createErrorResponse(errorStatus, e.getMessage());
}
}
-
- if (e.getMessage() != null)
- errorResponse =
- Response.status(errorResponse.getStatus()).entity(new String(e.getMessage())).type(
- MediaType.TEXT_PLAIN).header("JAXRS-Message-Provided", "true").build();
-
- response.setResponse(errorResponse);
}
else
{
-
- if (errorResponse.getEntity() == null)
+ if (errorResponse.getMetadata().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED) == null)
{
- if (excmap != null)
+ String jaxrsHeader = getJaxrsHeader(errorStatus);
+ if (jaxrsHeader != null)
{
- if (LOG.isDebugEnabled() && e.getCause() != null)
- {
- // Hide error message if exception mapper exists.
- LOG.warn("WebApplication exception occurs.", e.getCause());
- }
-
- errorResponse = excmap.toResponse(e);
+ errorResponse.getMetadata().putSingle(ExtHttpHeaders.JAXRS_BODY_PROVIDED, jaxrsHeader);
}
- else
- {
- if (e.getCause() != null)
- {
- LOG.warn("WebApplication exception occurs.", e.getCause());
- }
-
- // print stack trace & adding ex message into body
- if (LOG.isDebugEnabled())
- {
- e.printStackTrace();
- }
- if (e.getMessage() != null)
- errorResponse =
- Response.status(errorResponse.getStatus()).entity(new String(e.getMessage())).type(
- MediaType.TEXT_PLAIN).header("JAXRS-Message-Provided", "true").build();
- else
- errorResponse = Response.status(errorResponse.getStatus()).header("JAXRS-Message-Provided", "false").build();
- }
}
- response.setResponse(errorResponse);
}
+ response.setResponse(errorResponse);
}
else if (e instanceof InternalException)
{
@@ -251,6 +246,41 @@
}
}
+ /**
+ * Create error response with specified status and body message.
+ *
+ * @param status response status
+ * @param message response message
+ * @return response
+ */
+ private Response createErrorResponse(int status, String message)
+ {
+
+ ResponseBuilder responseBuilder = Response.status(status);
+ responseBuilder.entity(message).type(MediaType.TEXT_PLAIN);
+ String jaxrsHeader = getJaxrsHeader(status);
+ if (jaxrsHeader != null)
+ responseBuilder.header(ExtHttpHeaders.JAXRS_BODY_PROVIDED, jaxrsHeader);
+
+ return responseBuilder.build();
+ }
+
+ /**
+ * Get JAXR header for response status.
+ *
+ * @param status response status
+ * @return JAXRS header or null.
+ */
+ private String getJaxrsHeader(int status)
+ {
+ if (status >= 400)
+ {
+ return "Error-Message";
+ }
+ // Add required behavior here.
+ return null;
+ }
+
//
/**
Copied: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ExceptionsTest.java (from rev 1626, ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/WebApplicationExceptionTest.java)
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ExceptionsTest.java (rev 0)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ExceptionsTest.java 2010-02-01 12:22:56 UTC (rev 1629)
@@ -0,0 +1,155 @@
+/*
+ * 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.
+ */
+package org.exoplatform.services.rest.impl;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+
+import org.exoplatform.services.rest.AbstractResourceTest;
+import org.exoplatform.services.rest.ExtHttpHeaders;
+import org.exoplatform.services.rest.impl.ContainerResponse;
+import org.exoplatform.services.rest.impl.UnhandledException;
+import org.exoplatform.services.rest.tools.ByteArrayContainerResponseWriter;
+
+/**
+ * Created by The eXo Platform SAS. <br/>
+ * Date: 24 Dec 2009
+ *
+ * @author <a href="mailto:max.shaposhnik@exoplatform.com">Max Shaposhnik</a>
+ * @version $Id: WebApplicationExceptionTest.java
+ */
+public class ExceptionsTest extends AbstractResourceTest
+{
+
+ @Path("a")
+ public static class Resource1
+ {
+
+ @GET
+ @Path("0")
+ public void m0() throws WebApplicationException
+ {
+ Exception e = new Exception(errorMessage);
+ throw new WebApplicationException(e, 500);
+ }
+
+ @GET
+ @Path("1")
+ public void m1() throws WebApplicationException
+ {
+ Response response = Response.status(500).entity(errorMessage).type("text/plain").build();
+ throw new WebApplicationException(new Exception(), response);
+ }
+
+ @GET
+ @Path("2")
+ public Response m2() throws WebApplicationException
+ {
+ throw new WebApplicationException(500);
+ }
+
+ @GET
+ @Path("3")
+ public void m3() throws Exception
+ {
+ throw new RuntimeException("Runtime exception");
+ }
+
+ @GET
+ @Path("4")
+ public Response m4() throws Exception
+ {
+ return Response.status(500).entity(errorMessage).type("text/plain").build();
+ }
+
+ }
+
+ private static String errorMessage = "test-error-message";
+
+ private Resource1 resource;
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ resource = new Resource1();
+ registry(resource);
+ }
+
+ public void tearDown() throws Exception
+ {
+ unregistry(resource);
+ super.tearDown();
+ }
+
+ public void testErrorResponse() throws Exception
+ {
+ ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
+ ContainerResponse response = service("GET", "/a/4", "", null, null, writer);
+ assertEquals(500, response.getStatus());
+ String entity = new String(writer.getBody());
+ assertEquals(errorMessage, entity);
+ assertNotNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
+ }
+
+ public void testUncheckedException() throws Exception
+ {
+ ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
+ try
+ {
+ service("GET", "/a/3", "", null, null, writer);
+ fail("UnhandledException should be throw by RequstHandlerImpl");
+ }
+ catch (UnhandledException e)
+ {
+ // OK
+ }
+ }
+
+ public void testWebApplicationExceptionWithCause() throws Exception
+ {
+ ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
+ ContainerResponse response = service("GET", "/a/0", "", null, null, writer);
+ assertEquals(500, response.getStatus());
+ String entity = new String(writer.getBody());
+ assertEquals(new Exception(errorMessage).toString(), entity);
+ assertNotNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
+ }
+
+ public void testWebApplicationExceptionWithoutCause() throws Exception
+ {
+ ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
+ ContainerResponse response = service("GET", "/a/2", "", null, null, writer);
+ assertEquals(500, response.getStatus());
+ assertNull(response.getEntity());
+ assertNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
+ }
+
+ public void testWebApplicationExceptionWithResponse() throws Exception
+ {
+ ByteArrayContainerResponseWriter writer = new ByteArrayContainerResponseWriter();
+ ContainerResponse response = service("GET", "/a/1", "", null, null, writer);
+ assertEquals(500, response.getStatus());
+ String entity = new String(writer.getBody());
+ assertEquals(errorMessage, entity);
+ assertNotNull(response.getHttpHeaders().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED));
+ }
+
+}
Property changes on: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/ExceptionsTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Deleted: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodExceptionTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodExceptionTest.java 2010-02-01 11:15:06 UTC (rev 1628)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/MethodExceptionTest.java 2010-02-01 12:22:56 UTC (rev 1629)
@@ -1,101 +0,0 @@
-/*
- * 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.
- */
-package org.exoplatform.services.rest.impl.method;
-
-import org.exoplatform.services.rest.AbstractResourceTest;
-import org.exoplatform.services.rest.impl.UnhandledException;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-
-/**
- * Created by The eXo Platform SAS. <br/>
- * Date: 21 Jan 2009
- *
- * @author <a href="mailto:dmitry.kataev@exoplatform.com.ua">Dmytro Katayev</a>
- * @version $Id: MethodExceptionTest.java
- */
-public class MethodExceptionTest extends AbstractResourceTest
-{
-
- @SuppressWarnings("serial")
- public static class UncheckedException extends Exception
- {
-
- public UncheckedException()
- {
- super();
- }
-
- public UncheckedException(String msg)
- {
- super(msg);
- }
-
- }
-
- @Path("/a")
- public static class Resource1
- {
-
- @GET
- @Path("/0")
- public void m0() throws WebApplicationException
- {
- throw new WebApplicationException();
- }
-
- @GET
- @Path("/1")
- public Response m1() throws WebApplicationException
- {
- return new WebApplicationException().getResponse();
- }
-
- @GET
- @Path("/2")
- public void m2() throws Exception
- {
- throw new UncheckedException("Unchecked exception");
- }
-
- }
-
- public void testExceptionProcessing() throws Exception
- {
- Resource1 resource = new Resource1();
- registry(resource);
-
- assertEquals(500, service("GET", "/a/0", "", null, null).getStatus());
- assertEquals(500, service("GET", "/a/1", "", null, null).getStatus());
- try
- {
- assertEquals(500, service("GET", "/a/2", "", null, null).getStatus());
- fail();
- }
- catch (UnhandledException e)
- {
- }
- unregistry(resource);
- }
-
- //
-}
Deleted: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/WebApplicationExceptionTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/WebApplicationExceptionTest.java 2010-02-01 11:15:06 UTC (rev 1628)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/method/WebApplicationExceptionTest.java 2010-02-01 12:22:56 UTC (rev 1629)
@@ -1,81 +0,0 @@
-/*
- * 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.
- */
-package org.exoplatform.services.rest.impl.method;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-
-import org.exoplatform.services.rest.AbstractResourceTest;
-import org.exoplatform.services.rest.impl.method.MethodExceptionTest.UncheckedException;
-
-/**
- * Created by The eXo Platform SAS. <br/>
- * Date: 24 Dec 2009
- *
- * @author <a href="mailto:max.shaposhnik@exoplatform.com">Max Shaposhnik</a>
- * @version $Id: WebApplicationExceptionTest.java
- */
-public class WebApplicationExceptionTest extends AbstractResourceTest
-{
-
- @Path("/a")
- public static class Resource1
- {
-
- @GET
- @Path("/0")
- public void m0() throws WebApplicationException
- {
- Exception e = new Exception("testmsg");
- throw new WebApplicationException(e, 500);
- }
-
- @GET
- @Path("/1")
- public Response m1() throws WebApplicationException
- {
- throw new WebApplicationException(500);
- }
-
- @GET
- @Path("/2")
- public void m2() throws Exception
- {
- throw new UncheckedException("Unchecked exception");
- }
-
- }
-
- public void testExceptionMessage() throws Exception
- {
- Resource1 resource = new Resource1();
- registry(resource);
-
- assertEquals(500, service("GET", "/a/0", "", null, null).getStatus());
- String entity = (String)service("GET", "/a/0", "", null, null).getEntity();
- assertTrue(entity.indexOf("testmsg") > 0);
-
- assertEquals(500, service("GET", "/a/1", "", null, null).getStatus());
- assertEquals(null, service("GET", "/a/1", "", null, null).getEntity());
- unregistry(resource);
- }
-
-}
Modified: ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/JsonEntityTest.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/JsonEntityTest.java 2010-02-01 11:15:06 UTC (rev 1628)
+++ ws/trunk/exo.ws.rest.core/src/test/java/org/exoplatform/services/rest/impl/provider/JsonEntityTest.java 2010-02-01 12:22:56 UTC (rev 1629)
@@ -125,7 +125,7 @@
assertEquals("Hamlet\n", book.getTitle());
assertEquals("William Shakespeare\n", book.getAuthor());
assertFalse(book.isSendByPost());
- writer = new ByteArrayContainerResponseWriter();
+// writer = new ByteArrayContainerResponseWriter();
unregistry(r2);
}
14 years, 7 months