exo-jcr SVN: r1092 - jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-12-16 06:27:46 -0500 (Wed, 16 Dec 2009)
New Revision: 1092
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
Log:
EXOJCR-300: create Transient copy from EditableValue
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2009-12-16 11:26:17 UTC (rev 1091)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2009-12-16 11:27:46 UTC (rev 1092)
@@ -390,7 +390,7 @@
{
QPath qpath = QPath.makeChildPath(parentNode.getInternalPath(), propertyName);
-
+
int state;
String identifier;
@@ -438,7 +438,7 @@
state = ItemState.UPDATED;
}
}
-
+
if (defs == null || defs.getAnyDefinition() == null)
throw new RepositoryException("Property definition '" + propertyName.getAsString() + "' is not found.");
@@ -558,14 +558,14 @@
throw new ConstraintViolationException("Can not remove (by setting null value) mandatory property "
+ locationFactory.createJCRPath(qpath).getAsString(false));
}
-
+
TransientPropertyData newData =
new TransientPropertyData(qpath, identifier, version, propType, parentNode.getInternalIdentifier(),
multiValue);
// launch event: pre-remove
session.getActionHandler().preRemoveItem(prevProp);
-
+
dataManager.delete(newData);
prop = prevProp;
}
@@ -856,14 +856,9 @@
return new TransientValueData(value.getString());
case PropertyType.BINARY :
ValueData vd;
- if (value instanceof BaseValue)
+ if (value instanceof BaseValue || value instanceof ExtendedValue)
{
- // if the value is normaly created in JCR API
- vd = ((BaseValue)value).getInternalData();
- }
- else if (value instanceof ExtendedValue)
- {
- // if te value comes from outside the JCR API scope, e.g. RMI invocation
+ // create Transient copy
vd = ((BaseValue)getSession().getValueFactory().createValue(value.getStream())).getInternalData();
}
else
@@ -925,7 +920,7 @@
try
{
if (type != PropertyType.BINARY)
- {
+ {
strVal = ValueDataConvertor.readString(value);
}
else
16 years, 7 months
exo-jcr SVN: r1091 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: dataflow/persistent and 1 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-12-16 06:26:17 -0500 (Wed, 16 Dec 2009)
New Revision: 1091
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractPersistedValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java
Log:
EXOJCR-274: ValueData streaming into VS updated
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractPersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractPersistedValueData.java 2009-12-16 11:24:18 UTC (rev 1090)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractPersistedValueData.java 2009-12-16 11:26:17 UTC (rev 1091)
@@ -61,7 +61,7 @@
return false;
}
-
+
/**
* Create transient copy of persisted data.
*
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java 2009-12-16 11:24:18 UTC (rev 1090)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java 2009-12-16 11:26:17 UTC (rev 1091)
@@ -153,6 +153,12 @@
this.stream = null;
}
+
+ /**
+ * Return status of persisted state.
+ *
+ * @return boolean, true if the ValueData was persisted to a storage, false otherwise.
+ */
public boolean isPersisted()
{
return file != null;
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java 2009-12-16 11:24:18 UTC (rev 1090)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java 2009-12-16 11:26:17 UTC (rev 1091)
@@ -175,14 +175,17 @@
// make sure parent dir exists
vcasFile.getParentFile().mkdirs();
- if (!tempFile.renameTo(vcasFile)) // rename propetynamed file to hashnamed one
+ // rename propetynamed file to hashnamed one
+ if (!tempFile.renameTo(vcasFile))
+ {
throw new VCASException("File " + tempFile.getAbsolutePath() + " can't be renamed to VCAS-named "
+ vcasFile.getAbsolutePath());
+ }
} // else - CASed Value already exists
- // set persisted file
- if (!value.isByteArray())
+ if (!value.isByteArray() && value instanceof StreamPersistedValueData)
{
+ // set persisted file
((StreamPersistedValueData)value).setPersistedFile(vcasFile);
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java 2009-12-16 11:24:18 UTC (rev 1090)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java 2009-12-16 11:26:17 UTC (rev 1091)
@@ -132,43 +132,51 @@
else
{
// stream Value
- StreamPersistedValueData streamed = (StreamPersistedValueData)value;
- if (streamed.isPersisted())
+
+ if (value instanceof StreamPersistedValueData)
{
- // already persisted in another Value, copy it to this Value
- // TODO should not occurs!
- LOG.warn("File based persisted ValueData on save: " + streamed.getFile().getAbsolutePath() + " -> "
- + file.getAbsoluteFile());
- copyClose(streamed.getAsStream(), new FileOutputStream(file));
- }
- else
- {
- File tempFile;
- if ((tempFile = streamed.getTempFile()) != null)
+ StreamPersistedValueData streamed = (StreamPersistedValueData)value;
+
+ if (streamed.isPersisted())
{
- // it's spooled Value, try move its file to VS
- if (!tempFile.renameTo(file))
+ // already persisted in another Value, copy it to this Value
+ copyClose(streamed.getAsStream(), new FileOutputStream(file));
+ }
+ else
+ {
+ // the Value not yet persisted, i.e. or in client stream or spooled to a temp file
+ File tempFile;
+ if ((tempFile = streamed.getTempFile()) != null)
{
- // not succeeded - copy bytes
- if (LOG.isDebugEnabled())
+ // it's spooled Value, try move its file to VS
+ if (!tempFile.renameTo(file))
{
- LOG
- .debug("Value spool file move (rename) to Values Storage is not succeeded. Trying bytes copy. Spool file: "
- + tempFile.getAbsolutePath() + ". Destination: " + file.getAbsolutePath());
+ // not succeeded - copy bytes, temp file will be deleted by transient ValueData
+ if (LOG.isDebugEnabled())
+ {
+ LOG
+ .debug("Value spool file move (rename) to Values Storage is not succeeded. Trying bytes copy. Spool file: "
+ + tempFile.getAbsolutePath() + ". Destination: " + file.getAbsolutePath());
+ }
+
+ copyClose(new FileInputStream(tempFile), new FileOutputStream(file));
}
+ }
+ else
+ {
+ // not spooled, use client InputStream
+ copyClose(streamed.getStream(), new FileOutputStream(file));
+ }
- copyClose(new FileInputStream(tempFile), new FileOutputStream(file));
- }
+ // link this Value to file in VS
+ streamed.setPersistedFile(file);
}
- else
- {
- // not spooled, use InputStream
- copyClose(streamed.getStream(), new FileOutputStream(file));
- }
-
- // map this transient Value to file in VS
- streamed.setPersistedFile(file);
}
+ else
+ {
+ // copy from Value stream to the file, e.g. from FilePersistedValueData to this Value
+ copyClose(value.getAsStream(), new FileOutputStream(file));
+ }
}
}
@@ -192,21 +200,27 @@
else
{
InputStream in;
- StreamPersistedValueData streamed = (StreamPersistedValueData)value;
- if (streamed.isPersisted())
+ if (value instanceof StreamPersistedValueData)
{
- // already persisted in another Value, copy it to this Value
- // TODO should not occurs!
- LOG.warn("File based persisted ValueData on save: " + streamed.getFile().getAbsolutePath() + " -> CAS");
- in = streamed.getAsStream();
+
+ StreamPersistedValueData streamed = (StreamPersistedValueData)value;
+ if (streamed.isPersisted())
+ {
+ // already persisted in another Value, copy it to this Value
+ in = streamed.getAsStream();
+ }
+ else
+ {
+ in = streamed.getStream();
+ if (in == null)
+ {
+ in = new FileInputStream(streamed.getTempFile());
+ }
+ }
}
else
{
- in = streamed.getStream();
- if (in == null)
- {
- in = new FileInputStream(streamed.getTempFile());
- }
+ in = value.getAsStream();
}
try
16 years, 7 months
exo-jcr SVN: r1090 - core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl.
by do-not-reply@jboss.org
Author: vparfonov
Date: 2009-12-16 06:24:18 -0500 (Wed, 16 Dec 2009)
New Revision: 1090
Modified:
core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/XMLDocumentReader.java
Log:
EXOJCR-323 : Add "application/xml" and "application/x-google-gadget" mimetype to XMLDocumentReader
Modified: core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/XMLDocumentReader.java
===================================================================
--- core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/XMLDocumentReader.java 2009-12-16 10:29:59 UTC (rev 1089)
+++ core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/XMLDocumentReader.java 2009-12-16 11:24:18 UTC (rev 1090)
@@ -38,13 +38,13 @@
{
/**
- * Get the text/xml mime type.
+ * Get the text/xml, application/xml, application/x-google-gadget mime types.
*
- * @return The string with text/xml mime type.
+ * @return The string with text/xml, application/xml, application/x-google-gadget mime type.
*/
public String[] getMimeTypes()
{
- return new String[]{"text/xml"};
+ return new String[]{"text/xml", "application/xml", "application/x-google-gadget"};
}
/**
16 years, 7 months
exo-jcr SVN: r1089 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2009-12-16 05:29:59 -0500 (Wed, 16 Dec 2009)
New Revision: 1089
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionContextHolder.java
Removed:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCStorageConnectionFactory.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Log:
EXOJCR-321: Prevent useless database access for the methods add(NodeData) and add(PropertyData)
Just before the put I add the id into a context and in the CacheLoader, I check if the id that I need to retrieve from the database is new if it is new, I return null otherwise it accesses to the database
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-12-16 09:33:10 UTC (rev 1088)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-12-16 10:29:59 UTC (rev 1089)
@@ -197,14 +197,11 @@
}
}
+ // Define the item id as a new id to prevent useless data access
+ JBossCacheStorageConnectionContextHolder.addNewItemsId(dataContainer, data.getIdentifier());
// add in NODES
- value =
- cache.put(Fqn.fromRelativeFqn(Fqn.fromElements(JBossCacheStorage.NODES), makeNodeFqn(data.getIdentifier())),
- ITEM_DATA, data);
- if (value != null)
- {
- throw new ItemExistsException("Node already exists " + data.getQPath().getAsString());
- }
+ cache.put(Fqn.fromRelativeFqn(Fqn.fromElements(JBossCacheStorage.NODES), makeNodeFqn(data.getIdentifier())),
+ ITEM_DATA, data);
}
/**
@@ -232,16 +229,12 @@
throw new ItemExistsException("Property already exists " + data.getQPath().getAsString());
}
+ // Define the item id as a new id to prevent useless data access
+ JBossCacheStorageConnectionContextHolder.addNewItemsId(dataContainer, data.getIdentifier());
// add in PROPERTIES
- value =
- cache.put(Fqn.fromRelativeFqn(Fqn.fromElements(JBossCacheStorage.PROPS), makePropFqn(data.getIdentifier())),
- ITEM_DATA, data);
+ cache.put(Fqn.fromRelativeFqn(Fqn.fromElements(JBossCacheStorage.PROPS), makePropFqn(data.getIdentifier())),
+ ITEM_DATA, data);
- if (value != null)
- {
- throw new ItemExistsException("Property already exists " + data.getQPath().getAsString());
- }
-
// REFERENCEs hadnling
if (data.getType() == PropertyType.REFERENCE)
{
@@ -1044,7 +1037,7 @@
*/
public void close() throws IllegalStateException, RepositoryException
{
- JDBCStorageConnectionFactory.close(dataContainer);
+ JBossCacheStorageConnectionContextHolder.close(dataContainer);
}
/**
Copied: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionContextHolder.java (from rev 1083, jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCStorageConnectionFactory.java)
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionContextHolder.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionContextHolder.java 2009-12-16 10:29:59 UTC (rev 1089)
@@ -0,0 +1,222 @@
+/*
+ * 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 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * This class is used to holds the full context during the live time of
+ * the {@link JBossCacheStorageConnection}. We keep one
+ * {@link JDBCStorageConnection} per JDBCStorageConnection into a
+ * {@link ThreadLocal}
+ *
+ * @author nicolasfilotto
+ *
+ */
+public class JBossCacheStorageConnectionContextHolder
+{
+
+ /**
+ * The {@link ThreadLocal} in which we store all the current contexts
+ */
+ private static final ThreadLocal<Map<WorkspaceDataContainer, JBossCacheStorageConnectionContext>> CONTEXTS =
+ new ThreadLocal<Map<WorkspaceDataContainer, JBossCacheStorageConnectionContext>>();
+
+ /**
+ * Indicates if we are in a debug mode
+ */
+ public static AtomicBoolean DEBUG = new AtomicBoolean(false);
+
+ /**
+ * The total amount of connections. Used for debugging purpose only.
+ */
+ public static AtomicInteger TOTAL_CONNECTION = new AtomicInteger(0);
+
+ /**
+ * Indicates if we display the stack trace into the output stream. Used for
+ * debugging purpose only.
+ */
+ public static AtomicBoolean SHOW_TRACE = new AtomicBoolean(false);
+
+ /**
+ * Gives the current opened connection for the related
+ * {@link WorkspaceDataContainer} if it exists, returns a new one otherwise
+ *
+ * @param dataContainer
+ * the data container for which we want a connection
+ * @return an opened connection
+ * @throws RepositoryException
+ * if an error occurs
+ */
+ static JDBCStorageConnection getConnection(WorkspaceDataContainer dataContainer) throws RepositoryException
+ {
+ if (DEBUG.get())
+ {
+ if (SHOW_TRACE.get())
+ {
+ (new Exception()).printStackTrace();
+ }
+ TOTAL_CONNECTION.incrementAndGet();
+ }
+ final JBossCacheStorageConnectionContext context = getContext(dataContainer);
+ return context.getConnection();
+ }
+
+ /**
+ * Close the context related to the given {@link WorkspaceDataContainer}
+ *
+ * @param dataContainer
+ * the data container for which we want to close the context
+ * @throws IllegalStateException
+ * if connection is already closed
+ * @throws RepositoryException
+ * if some exception occured
+ */
+ static void close(WorkspaceDataContainer dataContainer) throws IllegalStateException, RepositoryException
+ {
+ final Map<WorkspaceDataContainer, JBossCacheStorageConnectionContext> contexts = CONTEXTS.get();
+ if (contexts == null)
+ {
+ return;
+ }
+ final JBossCacheStorageConnectionContext context = contexts.remove(dataContainer);
+ if (context == null)
+ {
+ return;
+ }
+ context.close();
+ }
+
+ /**
+ * Defines an item id has a new id. It is used to prevent the CacheLoader to access
+ * the database in order to know if the item already exists
+ * @param dataContainer
+ * the data container for which we want to define a new item id
+ * @param id the id of the new item
+ */
+ static void addNewItemsId(WorkspaceDataContainer dataContainer, String id)
+ {
+ final JBossCacheStorageConnectionContext context = getContext(dataContainer);
+ context.addNewItemsId(id);
+ }
+
+ /**
+ * Checks if a given id is an id of a new item
+ * @param dataContainer
+ * the data container for which we want to check the item id
+ * @param id the item id
+ * @return <code>true</code> id the id is known as a new item id, <code>false</code>
+ * otherwise
+ */
+ static boolean isNewItem(WorkspaceDataContainer dataContainer, String id)
+ {
+ final JBossCacheStorageConnectionContext context = getContext(dataContainer);
+ return context.isNewItem(id);
+ }
+
+ /**
+ * Gives the current context for the related data container
+ */
+ private static JBossCacheStorageConnectionContext getContext(WorkspaceDataContainer dataContainer)
+ {
+ Map<WorkspaceDataContainer, JBossCacheStorageConnectionContext> contexts = CONTEXTS.get();
+ if (contexts == null)
+ {
+ contexts = new HashMap<WorkspaceDataContainer, JBossCacheStorageConnectionContext>();
+ CONTEXTS.set(contexts);
+ }
+ JBossCacheStorageConnectionContext context = contexts.get(dataContainer);
+ if (context == null)
+ {
+ context = new JBossCacheStorageConnectionContext(dataContainer);
+ contexts.put(dataContainer, context);
+ }
+ return context;
+ }
+
+ /**
+ * The full context of a {@link JBossCacheStorageConnection}
+ */
+ private static class JBossCacheStorageConnectionContext
+ {
+ /**
+ * The current connection
+ */
+ private JDBCStorageConnection connection;
+
+ /**
+ * The list of all the ids of the new items
+ */
+ private Set<String> newItemsId;
+
+ /**
+ * The related data container
+ */
+ private final WorkspaceDataContainer dataContainer;
+
+ public JBossCacheStorageConnectionContext(WorkspaceDataContainer dataContainer)
+ {
+ this.dataContainer = dataContainer;
+ }
+
+ public JDBCStorageConnection getConnection() throws RepositoryException
+ {
+ if (connection == null || !connection.isOpened())
+ {
+ connection = (JDBCStorageConnection)dataContainer.openConnection();
+ }
+ return connection;
+ }
+
+ public boolean isNewItem(String id)
+ {
+ return newItemsId != null && newItemsId.contains(id);
+ }
+
+ public void addNewItemsId(String id)
+ {
+ if (newItemsId == null)
+ {
+ this.newItemsId = new HashSet<String>();
+ }
+ newItemsId.add(id);
+ }
+
+ public void close() throws IllegalStateException, RepositoryException
+ {
+ if (connection == null || !connection.isOpened())
+ {
+ return;
+ }
+ connection.close();
+ connection = null;
+ }
+ }
+}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-12-16 09:33:10 UTC (rev 1088)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-12-16 10:29:59 UTC (rev 1089)
@@ -163,7 +163,7 @@
LOG.debug("Modifications list size = " + modifications.size());
}
- JDBCStorageConnection conn = JDBCStorageConnectionFactory.get(dataContainer);
+ JDBCStorageConnection conn = JBossCacheStorageConnectionContextHolder.getConnection(dataContainer);
try
{
@@ -319,8 +319,12 @@
// /$NODES/<NODE_ID>
if (name.size() == 2)
{
- JDBCStorageConnection conn = JDBCStorageConnectionFactory.get(dataContainer);
String nodeId = name.getLastElementAsString();
+ if (JBossCacheStorageConnectionContextHolder.isNewItem(dataContainer, nodeId))
+ {
+ return null;
+ }
+ JDBCStorageConnection conn = JBossCacheStorageConnectionContextHolder.getConnection(dataContainer);
NodeData nodeData = (NodeData) conn.getItemData(nodeId);
if (nodeData != null)
{
@@ -346,7 +350,7 @@
// /$NODES/<NODE_ID>/<SUB_NODE_NAME>
else if (name.size() == 3)
{
- JDBCStorageConnection conn = JDBCStorageConnectionFactory.get(dataContainer);
+ JDBCStorageConnection conn = JBossCacheStorageConnectionContextHolder.getConnection(dataContainer);
QPathEntry childNodeName = QPathEntry.parse(name.getLastElementAsString());
String parentId = (String) name.get(1);
@@ -373,8 +377,12 @@
{
if (name.size() == 2)
{
- JDBCStorageConnection conn = JDBCStorageConnectionFactory.get(dataContainer);
String propertyId = name.getLastElementAsString();
+ if (JBossCacheStorageConnectionContextHolder.isNewItem(dataContainer, propertyId))
+ {
+ return null;
+ }
+ JDBCStorageConnection conn = JBossCacheStorageConnectionContextHolder.getConnection(dataContainer);
PropertyData propertyData = (PropertyData) conn.getItemData(propertyId);
if (propertyData != null)
{
@@ -397,7 +405,7 @@
// get reference
if (name.size() == 3)
{
- JDBCStorageConnection conn = JDBCStorageConnectionFactory.get(dataContainer);
+ JDBCStorageConnection conn = JBossCacheStorageConnectionContextHolder.getConnection(dataContainer);
// do we have such property reference
String nodeID = String.valueOf(name.get(1));
String propID = String.valueOf(name.get(2));
@@ -413,7 +421,7 @@
}
else if (name.size() == 2)
{
- JDBCStorageConnection conn = JDBCStorageConnectionFactory.get(dataContainer);
+ JDBCStorageConnection conn = JBossCacheStorageConnectionContextHolder.getConnection(dataContainer);
// do we have node with any reference
String nodeID = name.getLastElementAsString();
if (conn.getReferenceIdentifiers(nodeID).size() > 0)
@@ -476,7 +484,7 @@
// /$NODES/<NODE_ID>
if (name.size() == 2)
{
- JDBCStorageConnection conn = JDBCStorageConnectionFactory.get(dataContainer);
+ JDBCStorageConnection conn = JBossCacheStorageConnectionContextHolder.getConnection(dataContainer);
String nodeId = name.getLastElementAsString();
String nodeName = conn.getNodeName(nodeId);
@@ -492,7 +500,7 @@
// /$NODES/<NODE_ID>/<SUB_NODE_NAME>
else if (name.size() == 3)
{
- JDBCStorageConnection conn = JDBCStorageConnectionFactory.get(dataContainer);
+ JDBCStorageConnection conn = JBossCacheStorageConnectionContextHolder.getConnection(dataContainer);
QPathEntry childNodeName = QPathEntry.parse(name.getLastElementAsString());
String parentId = (String) name.get(1);
@@ -518,7 +526,7 @@
{
if (name.size() == 2)
{
- JDBCStorageConnection conn = JDBCStorageConnectionFactory.get(dataContainer);
+ JDBCStorageConnection conn = JBossCacheStorageConnectionContextHolder.getConnection(dataContainer);
String propertyId = name.getLastElementAsString();
String propertyName = conn.getPropertyName(propertyId);
@@ -542,14 +550,14 @@
// /$REFS/<NODE_ID>
if (name.size() == 2)
{
- JDBCStorageConnection conn = JDBCStorageConnectionFactory.get(dataContainer);
+ JDBCStorageConnection conn = JBossCacheStorageConnectionContextHolder.getConnection(dataContainer);
String nodeId = name.getLastElementAsString();
exists = conn.getReferenceIdentifiers(nodeId).size() > 0;
}
// /$REFS/<NODE_ID>/<REF_PROP_ID>
else if (name.size() == 3)
{
- JDBCStorageConnection conn = JDBCStorageConnectionFactory.get(dataContainer);
+ JDBCStorageConnection conn = JBossCacheStorageConnectionContextHolder.getConnection(dataContainer);
String refPropertyId = name.getLastElementAsString();
String nodeId = (String) name.get(1);
@@ -605,12 +613,12 @@
String nodeId = (String) name.get(1);
if (name.get(0).equals(JBossCacheStorage.NODES))
{
- JDBCStorageConnection conn = JDBCStorageConnectionFactory.get(dataContainer);
+ JDBCStorageConnection conn = JBossCacheStorageConnectionContextHolder.getConnection(dataContainer);
return conn.getChildNodeNames(nodeId);
}
else if (name.get(0).equals(JBossCacheStorage.REFS))
{
- JDBCStorageConnection conn = JDBCStorageConnectionFactory.get(dataContainer);
+ JDBCStorageConnection conn = JBossCacheStorageConnectionContextHolder.getConnection(dataContainer);
List<String> references = conn.getReferenceIdentifiers(nodeId);
Set<String> result = new LinkedHashSet<String>();
result.addAll(references);
@@ -689,7 +697,7 @@
*/
public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
{
- final JDBCStorageConnection conn = JDBCStorageConnectionFactory.get(dataContainer);
+ final JDBCStorageConnection conn = JBossCacheStorageConnectionContextHolder.getConnection(dataContainer);
apply(modifications, conn);
conn.commit();
Deleted: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCStorageConnectionFactory.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCStorageConnectionFactory.java 2009-12-16 09:33:10 UTC (rev 1088)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCStorageConnectionFactory.java 2009-12-16 10:29:59 UTC (rev 1089)
@@ -1,127 +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 3 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.storage.jbosscache;
-
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
-import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jcr.RepositoryException;
-
-/**
- * This class is used to holds the JDBC connection open during the live time of
- * the {@link JBossCacheStorageConnection}. We keep one
- * {@link JDBCStorageConnection} per JDBCStorageConnection into a
- * {@link ThreadLocal}
- *
- * @author nicolasfilotto
- *
- */
-public class JDBCStorageConnectionFactory
-{
-
- /**
- * The {@link ThreadLocal} in which we store all the current opened
- * connections
- */
- private static final ThreadLocal<Map<WorkspaceDataContainer, JDBCStorageConnection>> CONNECTIONS =
- new ThreadLocal<Map<WorkspaceDataContainer, JDBCStorageConnection>>();
-
- /**
- * Indicates if we are in a debug mode
- */
- public static AtomicBoolean DEBUG = new AtomicBoolean(false);
-
- /**
- * The total amount of connections. Used for debugging purpose only.
- */
- public static AtomicInteger TOTAL_CONNECTION = new AtomicInteger(0);
-
- /**
- * Indicates if we display the stack trace into the output stream. Used for
- * debugging purpose only.
- */
- public static AtomicBoolean SHOW_TRACE = new AtomicBoolean(false);
-
- /**
- * Gives the current opened connection for the related
- * {@link WorkspaceDataContainer} if it exists, returns a new one otherwise
- *
- * @param dataContainer
- * the data container for which we want a connection
- * @return an opened connection
- * @throws RepositoryException
- * if an error occurs
- */
- static JDBCStorageConnection get(WorkspaceDataContainer dataContainer) throws RepositoryException
- {
- if (DEBUG.get())
- {
- if (SHOW_TRACE.get())
- {
- (new Exception()).printStackTrace();
- }
- TOTAL_CONNECTION.incrementAndGet();
- }
- Map<WorkspaceDataContainer, JDBCStorageConnection> connections = CONNECTIONS.get();
- if (connections == null)
- {
- connections = new HashMap<WorkspaceDataContainer, JDBCStorageConnection>();
- CONNECTIONS.set(connections);
- }
- JDBCStorageConnection connection = connections.get(dataContainer);
- if (connection == null || !connection.isOpened())
- {
- connection = (JDBCStorageConnection)dataContainer.openConnection();
- connections.put(dataContainer, connection);
- }
- return connection;
- }
-
- /**
- * Close the current opened connection related to the given
- * {@link WorkspaceDataContainer}
- *
- * @param dataContainer
- * the data container for which we want to close the connection
- * @throws IllegalStateException
- * if connection is already closed
- * @throws RepositoryException
- * if some exception occured
- */
- static void close(WorkspaceDataContainer dataContainer) throws IllegalStateException, RepositoryException
- {
- Map<WorkspaceDataContainer, JDBCStorageConnection> connections = CONNECTIONS.get();
- if (connections == null)
- {
- return;
- }
- JDBCStorageConnection connection = connections.remove(dataContainer);
- if (connection == null || !connection.isOpened())
- {
- return;
- }
- connection.close();
- connection = null;
- }
-}
16 years, 7 months
exo-jcr SVN: r1088 - jcr/branches/1.12.0-JBC.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-12-16 04:33:10 -0500 (Wed, 16 Dec 2009)
New Revision: 1088
Modified:
jcr/branches/1.12.0-JBC/pom.xml
Log:
EXOJCR-320 : Upgrade version of common-pool to 1.5.4
Modified: jcr/branches/1.12.0-JBC/pom.xml
===================================================================
--- jcr/branches/1.12.0-JBC/pom.xml 2009-12-16 09:32:36 UTC (rev 1087)
+++ jcr/branches/1.12.0-JBC/pom.xml 2009-12-16 09:33:10 UTC (rev 1088)
@@ -287,10 +287,22 @@
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
- <version>1.2.2</version>
- </dependency>
+ <version>1.2.2</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-pool</groupId>
+ <artifactId>commons-pool</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
+ <groupId>commons-pool</groupId>
+ <artifactId>commons-pool</artifactId>
+ <version>1.5.4</version>
+ </dependency>
+
+ <dependency>
<groupId>jotm</groupId>
<artifactId>jotm</artifactId>
<version>2.0.10</version>
@@ -398,6 +410,11 @@
<artifactId>jbosscache-core</artifactId>
<version>3.2.0.GA</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.cache</groupId>
+ <artifactId>jbosscache-searchable</artifactId>
+ <version>1.0.0.GA</version>
+ </dependency>
</dependencies>
</dependencyManagement>
16 years, 7 months
exo-jcr SVN: r1087 - jcr/branches/1.12.0-JBC/component/core.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-12-16 04:32:36 -0500 (Wed, 16 Dec 2009)
New Revision: 1087
Modified:
jcr/branches/1.12.0-JBC/component/core/pom.xml
Log:
EXOJCR-320 : Upgrade version of common-pool to 1.5.4
Modified: jcr/branches/1.12.0-JBC/component/core/pom.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/pom.xml 2009-12-16 09:18:06 UTC (rev 1086)
+++ jcr/branches/1.12.0-JBC/component/core/pom.xml 2009-12-16 09:32:36 UTC (rev 1087)
@@ -125,6 +125,11 @@
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-pool</groupId>
+ <artifactId>commons-pool</artifactId>
+ </dependency>
+
<!-- JOTM comes from exo.kernel.component.common -->
16 years, 7 months
exo-jcr SVN: r1086 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/dataflow and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-12-16 04:18:06 -0500 (Wed, 16 Dec 2009)
New Revision: 1086
Added:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/TestExternalizabeItemData.java
Removed:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/TestExternalizabeTransientItemData.java
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedPropertyData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientItemData.java
Log:
EXOJCR-300: Externalize test fix
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java 2009-12-16 09:05:19 UTC (rev 1085)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java 2009-12-16 09:18:06 UTC (rev 1086)
@@ -18,10 +18,18 @@
*/
package org.exoplatform.services.jcr.dataflow.persistent;
+import org.exoplatform.services.jcr.access.AccessControlList;
+import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
import javax.jcr.RepositoryException;
/**
@@ -33,17 +41,21 @@
* @version $Id$
*/
-public abstract class PersistedItemData implements ItemData
+public abstract class PersistedItemData implements ItemData, Externalizable
{
- protected final String id;
+ protected String id;
- protected final QPath qpath;
+ protected QPath qpath;
- protected final String parentId;
+ protected String parentId;
- protected final int version;
+ protected int version;
+ private int NOT_NULL_VALUE = 1;
+
+ private int NULL_VALUE = -1;
+
public PersistedItemData(String id, QPath qpath, String parentId, int version)
{
this.id = id;
@@ -83,7 +95,7 @@
{
return parentId;
}
-
+
/**
* Creates transient copy of this persistent ItemData.
*
@@ -110,4 +122,78 @@
return false;
}
+
+ // ----------------- Externalizable
+ public PersistedItemData()
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ byte[] buf;
+
+ try
+ {
+ buf = new byte[in.readInt()];
+ in.readFully(buf);
+ String sQPath = new String(buf, Constants.DEFAULT_ENCODING);
+ qpath = QPath.parse(sQPath);
+ }
+ catch (final IllegalPathException e)
+ {
+ throw new IOException("Deserialization error. " + e)
+ {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Throwable getCause()
+ {
+ return e;
+ }
+ };
+ }
+
+ buf = new byte[in.readInt()];
+ in.readFully(buf);
+ id = new String(buf);
+
+ int isNull = in.readInt();
+ if (isNull == NOT_NULL_VALUE)
+ {
+ buf = new byte[in.readInt()];
+ in.readFully(buf);
+ parentId = new String(buf);
+ }
+
+ version = in.readInt();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ byte[] buf = qpath.getAsString().getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buf.length);
+ out.write(buf);
+
+ out.writeInt(id.getBytes().length);
+ out.write(id.getBytes());
+
+ if (parentId != null)
+ {
+ out.writeInt(NOT_NULL_VALUE);
+ out.writeInt(parentId.getBytes().length);
+ out.write(parentId.getBytes());
+ }
+ else
+ out.writeInt(NULL_VALUE);
+
+ out.writeInt(version);
+ }
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java 2009-12-16 09:05:19 UTC (rev 1085)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java 2009-12-16 09:18:06 UTC (rev 1086)
@@ -20,12 +20,19 @@
import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.dataflow.ItemDataVisitor;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
import javax.jcr.RepositoryException;
/**
@@ -37,14 +44,14 @@
* @version $Id$
*/
-public class PersistedNodeData extends PersistedItemData implements NodeData
+public class PersistedNodeData extends PersistedItemData implements NodeData, Externalizable
{
- protected final int orderNumber;
+ protected int orderNumber;
- protected final InternalQName primaryTypeName;
+ protected InternalQName primaryTypeName;
- protected final InternalQName[] mixinTypeNames;
+ protected InternalQName[] mixinTypeNames;
protected AccessControlList acl;
@@ -112,12 +119,114 @@
@Override
public TransientItemData createTransientCopy()
{
-// TransientNodeData dataCopy =
-// new TransientNodeData(getQPath(), getIdentifier(), getPersistedVersion(), getPrimaryTypeName(),
-// getMixinTypeNames(), getOrderNumber(), getParentIdentifier() != null ? getParentIdentifier() : null,
-// getACL());
-//
-// return dataCopy;
+ // TransientNodeData dataCopy =
+ // new TransientNodeData(getQPath(), getIdentifier(), getPersistedVersion(), getPrimaryTypeName(),
+ // getMixinTypeNames(), getOrderNumber(), getParentIdentifier() != null ? getParentIdentifier() : null,
+ // getACL());
+ //
+ // return dataCopy;
throw new IllegalStateException("createTransientCopy deprecated");
}
+
+ // ----------------- Externalizable
+ public PersistedNodeData()
+ {
+ super();
+ acl = new AccessControlList();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ super.writeExternal(out);
+
+ out.writeInt(orderNumber);
+
+ // primary type
+ byte[] ptbuf = primaryTypeName.getAsString().getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(ptbuf.length);
+ out.write(ptbuf);
+
+ // mixins
+ out.writeInt(mixinTypeNames.length);
+ for (int i = 0; i < mixinTypeNames.length; i++)
+ {
+ byte[] buf = mixinTypeNames[i].getAsString().getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buf.length);
+ out.write(buf);
+ }
+
+ acl.writeExternal(out);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ super.readExternal(in);
+
+ orderNumber = in.readInt();
+
+ // primary type
+ byte[] buf;
+ try
+ {
+ buf = new byte[in.readInt()];
+ in.readFully(buf);
+ primaryTypeName = InternalQName.parse(new String(buf, Constants.DEFAULT_ENCODING));
+ }
+ catch (final IllegalNameException e)
+ {
+ throw new IOException(e.getMessage())
+ {
+ private static final long serialVersionUID = 3489809179234435267L;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Throwable getCause()
+ {
+ return e;
+ }
+ };
+ }
+
+ // mixins
+ int count = in.readInt();
+ mixinTypeNames = new InternalQName[count];
+ for (int i = 0; i < count; i++)
+ {
+ try
+ {
+ buf = new byte[in.readInt()];
+ in.readFully(buf);
+ mixinTypeNames[i] = InternalQName.parse(new String(buf, Constants.DEFAULT_ENCODING));
+ }
+ catch (final IllegalNameException e)
+ {
+ throw new IOException(e.getMessage())
+ {
+ private static final long serialVersionUID = 3489809179234435268L; // eclipse
+
+ // gen
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Throwable getCause()
+ {
+ return e;
+ }
+ };
+ }
+ }
+
+ // acl
+ acl.readExternal(in);
+ }
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedPropertyData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedPropertyData.java 2009-12-16 09:05:19 UTC (rev 1085)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedPropertyData.java 2009-12-16 09:18:06 UTC (rev 1086)
@@ -26,6 +26,10 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.List;
@@ -40,15 +44,17 @@
* @version $Id$
*/
-public class PersistedPropertyData extends PersistedItemData implements PropertyData
+public class PersistedPropertyData extends PersistedItemData implements PropertyData, Externalizable
{
protected List<ValueData> values;
- protected final int type;
+ protected int type;
- protected final boolean multiValued;
+ protected boolean multiValued;
+ protected final static int NULL_VALUES = -1;
+
public PersistedPropertyData(String id, QPath qpath, String parentId, int version, int type, boolean multiValued,
List<ValueData> values)
{
@@ -105,18 +111,67 @@
@Deprecated
public TransientItemData createTransientCopy() throws RepositoryException
{
-// List<ValueData> copyValues = new ArrayList<ValueData>();
-// for (ValueData vdata : getValues())
-// {
-// copyValues.add(((PersistedValueData)vdata).createTransientCopy());
-// }
-//
-// TransientPropertyData dataCopy =
-// new TransientPropertyData(getQPath(), getIdentifier(), getPersistedVersion(), getType(),
-// getParentIdentifier(), isMultiValued(), copyValues);
-//
-// return dataCopy;
-
+ // List<ValueData> copyValues = new ArrayList<ValueData>();
+ // for (ValueData vdata : getValues())
+ // {
+ // copyValues.add(((PersistedValueData)vdata).createTransientCopy());
+ // }
+ //
+ // TransientPropertyData dataCopy =
+ // new TransientPropertyData(getQPath(), getIdentifier(), getPersistedVersion(), getType(),
+ // getParentIdentifier(), isMultiValued(), copyValues);
+ //
+ // return dataCopy;
+
throw new IllegalStateException("createTransientCopy deprecated");
}
+
+ // ----------------- Externalizable
+ public PersistedPropertyData()
+ {
+ super();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ super.writeExternal(out);
+
+ out.writeInt(type);
+ out.writeBoolean(multiValued);
+
+ if (values != null)
+ {
+ int listSize = values.size();
+ out.writeInt(listSize);
+ for (int i = 0; i < listSize; i++)
+ out.writeObject(values.get(i));
+ }
+ else
+ {
+ out.writeInt(NULL_VALUES);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ super.readExternal(in);
+
+ type = in.readInt();
+
+ multiValued = in.readBoolean();
+
+ int listSize = in.readInt();
+ if (listSize != NULL_VALUES)
+ {
+ values = new ArrayList<ValueData>();
+ for (int i = 0; i < listSize; i++)
+ values.add((ValueData)in.readObject());
+ }
+ }
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientItemData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientItemData.java 2009-12-16 09:05:19 UTC (rev 1085)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientItemData.java 2009-12-16 09:18:06 UTC (rev 1086)
@@ -155,6 +155,9 @@
this.persistedVersion++;
}
+ /**
+ * {@inheritDoc}
+ */
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
byte[] buf;
@@ -197,6 +200,9 @@
persistedVersion = in.readInt();
}
+ /**
+ * {@inheritDoc}
+ */
public void writeExternal(ObjectOutput out) throws IOException
{
byte[] buf = qpath.getAsString().getBytes(Constants.DEFAULT_ENCODING);
Added: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/TestExternalizabeItemData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/TestExternalizabeItemData.java (rev 0)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/TestExternalizabeItemData.java 2009-12-16 09:18:06 UTC (rev 1086)
@@ -0,0 +1,80 @@
+/*
+ * 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.jcr.impl.dataflow;
+
+import org.exoplatform.services.jcr.JcrImplBaseTest;
+import org.exoplatform.services.jcr.dataflow.persistent.PersistedItemData;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.impl.core.NodeImpl;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 21.01.2009
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public class TestExternalizabeItemData extends JcrImplBaseTest
+{
+
+ public void testPersistedItemData() throws Exception
+ {
+ ItemData idSrc = ((NodeImpl)root).getData();
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(os);
+
+ assertTrue(idSrc instanceof PersistedItemData);
+
+ oos.writeObject(idSrc);
+
+ ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
+ ObjectInputStream ois = new ObjectInputStream(is);
+
+ ItemData idDest = (ItemData)ois.readObject();
+
+ assertNotNull(idDest);
+ }
+
+ public void testTransientItemData() throws Exception
+ {
+ ItemData idSrc = ((NodeImpl)root.addNode("test")).getData();
+
+ assertTrue(idSrc instanceof TransientItemData);
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(os);
+
+ oos.writeObject(idSrc);
+
+ ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
+ ObjectInputStream ois = new ObjectInputStream(is);
+
+ ItemData idDest = (ItemData)ois.readObject();
+
+ assertNotNull(idDest);
+ }
+
+}
Property changes on: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/TestExternalizabeItemData.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Deleted: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/TestExternalizabeTransientItemData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/TestExternalizabeTransientItemData.java 2009-12-16 09:05:19 UTC (rev 1085)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/TestExternalizabeTransientItemData.java 2009-12-16 09:18:06 UTC (rev 1086)
@@ -1,58 +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.jcr.impl.dataflow;
-
-import org.exoplatform.services.jcr.JcrImplBaseTest;
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.impl.core.NodeImpl;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 21.01.2009
- *
- * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
- * @version $Id: TestExternalizabeTransientItemData.java 111 2008-11-11 11:11:11Z rainf0x $
- */
-public class TestExternalizabeTransientItemData extends JcrImplBaseTest
-{
-
- public void testRootNode() throws Exception
- {
- ItemData idSrc = ((NodeImpl)root).getData();
-
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(os);
-
- oos.writeObject(idSrc);
-
- ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(is);
-
- ItemData idDest = (ItemData)ois.readObject();
-
- assertNotNull(idDest);
- }
-
-}
16 years, 7 months
exo-jcr SVN: r1085 - jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-12-16 04:05:19 -0500 (Wed, 16 Dec 2009)
New Revision: 1085
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java
Log:
EXOJCR-274: fix CAS tests
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2009-12-16 08:38:07 UTC (rev 1084)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2009-12-16 09:05:19 UTC (rev 1085)
@@ -346,7 +346,7 @@
{
File f = createBLOBTempFile(300);
addedSize += f.length();
- fch.write(propertyId, new StreamPersistedValueData(i, new FileInputStream(testFile)));
+ fch.write(propertyId, new StreamPersistedValueData(i, new FileInputStream(f)));
}
fch.commit();
@@ -515,7 +515,7 @@
File f = createBLOBTempFile(450);
addedSize += (m1fileSize = f.length());
- StreamPersistedValueData v = new StreamPersistedValueData(i, new FileInputStream(testFile));
+ StreamPersistedValueData v = new StreamPersistedValueData(i, new FileInputStream(f));
if (i == 1)
sharedValue = v;
@@ -546,7 +546,7 @@
m2filesCount++;
File f = createBLOBTempFile(350);
addedSize += (m2fileSize = f.length()); // add size
- v = new StreamPersistedValueData(i, new FileInputStream(testFile));
+ v = new StreamPersistedValueData(i, new FileInputStream(f));
}
fch.write(property2MultivaluedId, v);
}
16 years, 7 months
exo-jcr SVN: r1084 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl: value and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-12-16 03:38:07 -0500 (Wed, 16 Dec 2009)
New Revision: 1084
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java
Log:
EXOJCR-300: test fix
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java 2009-12-16 00:07:22 UTC (rev 1083)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java 2009-12-16 08:38:07 UTC (rev 1084)
@@ -110,10 +110,10 @@
try
{
v1.getAsByteArray();
- fail("IllegalStateException should have been thrown");
}
catch (IllegalStateException e)
{
+ fail("IllegalStateException should not have been thrown");
}
channel.delete("testReadFromIOChannel");
channel.commit();
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java 2009-12-16 00:07:22 UTC (rev 1083)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java 2009-12-16 08:38:07 UTC (rev 1084)
@@ -71,10 +71,10 @@
try
{
vd.getAsByteArray();
- fail("IllegalStateException should have been thrown!");
}
catch (IllegalStateException e)
{
+ fail("IllegalStateException should not have been thrown!");
}
assertTrue(vd.getAsStream() instanceof FileInputStream);
}
16 years, 7 months
exo-jcr SVN: r1083 - in kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container: jmx and 1 other directory.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2009-12-15 19:07:22 -0500 (Tue, 15 Dec 2009)
New Revision: 1083
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/ExoModelMBean.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/ManageableContainer.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/ManagementContextImpl.java
Log:
actually, scope properly the various mbeans for portal container as with several portal containers, only one is visible at random
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java 2009-12-15 22:45:01 UTC (rev 1082)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/ExoContainer.java 2009-12-16 00:07:22 UTC (rev 1083)
@@ -94,7 +94,7 @@
public ExoContainer(MBeanServer mbeanServer)
{
- super(new ManagementContextImpl(mbeanServer, new HashMap<String, String>()));
+ super(new ManagementContextImpl(mbeanServer));
context = new ExoContainerContext(this);
context.setName(this.getClass().getName());
registerComponentInstance(context);
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/ExoModelMBean.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/ExoModelMBean.java 2009-12-15 22:45:01 UTC (rev 1082)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/ExoModelMBean.java 2009-12-16 00:07:22 UTC (rev 1083)
@@ -24,7 +24,7 @@
import org.exoplatform.management.ManagementContext;
import org.exoplatform.management.jmx.annotations.NamingContext;
-import java.util.HashMap;
+import java.util.Collections;
import java.util.Map;
import javax.management.InstanceNotFoundException;
@@ -116,17 +116,20 @@
PropertiesInfo info = PropertiesInfo.resolve(mr.getClass(), NamingContext.class);
//
- Map<String, String> scopingProperties = new HashMap<String, String>();
- if (info != null)
+ Map<String, String> scopingProperties = info != null ? info.resolve(mr) : Collections.<String, String>emptyMap();
+
+ //
+ if (mr instanceof ManageableContainer)
{
- for (PropertyInfo property : info.getProperties())
- {
- scopingProperties.put(property.getKey(), property.resolveValue(mr));
- }
+ context = ((ManageableContainer)mr).managementContext;
}
+ else
+ {
+ context = new ManagementContextImpl(parentContext);
+ }
//
- context = new ManagementContextImpl(parentContext, scopingProperties);
+ context.scopingProperties = scopingProperties;
//
if (mr instanceof ManagementAware)
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/ManageableContainer.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/ManageableContainer.java 2009-12-15 22:45:01 UTC (rev 1082)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/ManageableContainer.java 2009-12-16 00:07:22 UTC (rev 1083)
@@ -122,7 +122,7 @@
ManagementContextImpl parentManagementContext = ((ManageableContainer)parent).managementContext;
if (parentManagementContext != null)
{
- managementContext = new ManagementContextImpl(parentManagementContext, new HashMap<String, String>());
+ managementContext = new ManagementContextImpl(parentManagementContext);
managementContext.container = this;
}
}
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/ManagementContextImpl.java
===================================================================
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/ManagementContextImpl.java 2009-12-15 22:45:01 UTC (rev 1082)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/jmx/ManagementContextImpl.java 2009-12-16 00:07:22 UTC (rev 1083)
@@ -25,6 +25,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
@@ -46,7 +47,7 @@
{
/** . */
- private Map<String, String> scopingProperties;
+ Map<String, String> scopingProperties;
/** The registrations done by this mbean. */
private final Map<Object, ObjectName> registrations;
@@ -62,10 +63,10 @@
public ManagementContextImpl()
{
- this(MBeanServerFactory.createMBeanServer(), new HashMap<String, String>());
+ this(MBeanServerFactory.createMBeanServer());
}
- public ManagementContextImpl(MBeanServer server, Map<String, String> scopingProperties)
+ public ManagementContextImpl(MBeanServer server)
{
if (server == null)
{
@@ -73,11 +74,16 @@
}
this.registrations = new HashMap<Object, ObjectName>();
this.parent = null;
- this.scopingProperties = scopingProperties;
+
+ // This is the root container that never have scoping properties
+ // Also without that we would have an NPE when the portal container are registered
+ // as the scoping properties would not exist since the root container would not be yet
+
+ this.scopingProperties = Collections.emptyMap();
this.server = server;
}
- public ManagementContextImpl(ManagementContextImpl parent, Map<String, String> scopingProperties)
+ public ManagementContextImpl(ManagementContextImpl parent)
{
if (parent == null)
{
@@ -85,7 +91,7 @@
}
this.registrations = new HashMap<Object, ObjectName>();
this.parent = parent;
- this.scopingProperties = scopingProperties;
+ this.scopingProperties = null;
this.server = parent.server;
}
@@ -216,7 +222,10 @@
}
for (ManagementContextImpl current = this; current != null; current = current.parent)
{
- props.putAll(current.scopingProperties);
+ if (current.scopingProperties != null)
+ {
+ props.putAll(current.scopingProperties);
+ }
}
on = JMX.createObjectName(on.getDomain(), props);
attemptToRegister(on, mbean);
16 years, 7 months