Author: sergiykarpenko
Date: 2009-12-25 10:55:34 -0500 (Fri, 25 Dec 2009)
New Revision: 1194
Added:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/SQLExceptionHandler.java
Removed:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCStorageConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCWorkspaceDataContainer.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewSQLExceptionHandler.java
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.mysql.xml
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.mysql.xml
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-302: rename classes
Added:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
(rev 0)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2009-12-25
15:55:34 UTC (rev 1194)
@@ -0,0 +1,2532 @@
+/*
+ * 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.storage.jdbc.optimisation;
+
+import org.exoplatform.services.jcr.access.AccessControlEntry;
+import org.exoplatform.services.jcr.access.AccessControlList;
+import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.dataflow.persistent.PersistedNodeData;
+import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
+import org.exoplatform.services.jcr.datamodel.IllegalACLException;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.datamodel.ValueData;
+import org.exoplatform.services.jcr.impl.Constants;
+import
org.exoplatform.services.jcr.impl.dataflow.persistent.ByteArrayPersistedValueData;
+import
org.exoplatform.services.jcr.impl.dataflow.persistent.CleanableFilePersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData;
+import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.storage.jdbc.PrimaryTypeNotFoundException;
+import org.exoplatform.services.jcr.impl.storage.value.ValueStorageNotFoundException;
+import org.exoplatform.services.jcr.impl.storage.value.fs.operations.ValueFileIOHelper;
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.SwapFile;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.jcr.storage.value.ValueIOChannel;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady
Azarenkov</a>
+ * @version $Id: JDBCStorageConnection.java 34801 2009-07-31 15:44:50Z dkatayev $
+ */
+abstract public class CQJDBCStorageConnection extends DBConstants implements
WorkspaceStorageConnection
+{
+
+ /**
+ * Connection logger.
+ */
+ protected static final Log LOG =
ExoLogger.getLogger("jcr.JDBCStorageConnection");
+
+ /**
+ * NODE type.
+ */
+ public static final int I_CLASS_NODE = 1;
+
+ /**
+ * PROPERTY type.
+ */
+ public static final int I_CLASS_PROPERTY = 2;
+
+ protected final ValueStoragePluginProvider valueStorageProvider;
+
+ protected final int maxBufferSize;
+
+ protected final File swapDirectory;
+
+ protected final FileCleaner swapCleaner;
+
+ protected final Connection dbConnection;
+
+ protected final String containerName;
+
+ protected final SQLExceptionHandler exceptionHandler;
+
+ protected final List<ValueIOChannel> valueChanges;
+
+ /**
+ * Read-only flag, if true the connection is marked as READ-ONLY.
+ */
+ protected final boolean readOnly;
+
+ /**
+ * JDBCStorageConnection constructor.
+ *
+ * @param dbConnection
+ * JDBC connection
+ * @param containerName
+ * Workspace conatiner name
+ * @param valueStorageProvider
+ * External Value Storage provider
+ * @param maxBufferSize
+ * maximum buffer size (config)
+ * @param swapDirectory
+ * swap directory (config)
+ * @param swapCleaner
+ * swap cleaner (FileCleaner)
+ * @throws SQLException
+ * database error
+ */
+ protected CQJDBCStorageConnection(Connection dbConnection, boolean readOnly, String
containerName,
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ throws SQLException
+ {
+
+ this.valueStorageProvider = valueStorageProvider;
+
+ this.maxBufferSize = maxBufferSize;
+ this.swapDirectory = swapDirectory;
+ this.swapCleaner = swapCleaner;
+ this.containerName = containerName;
+
+ this.dbConnection = dbConnection;
+ this.readOnly = readOnly;
+
+ // Fix for Sybase jConnect JDBC driver bug.
+ // Which throws SQLException(JZ016: The AutoCommit option is already set to
+ // false)
+ // if conn.setAutoCommit(false) called twise or more times with value
+ // 'false'.
+ if (dbConnection.getAutoCommit())
+ {
+ dbConnection.setAutoCommit(false);
+ }
+
+ prepareQueries();
+ this.exceptionHandler = new SQLExceptionHandler(containerName, this);
+
+ this.valueChanges = new ArrayList<ValueIOChannel>();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ return true;
+
+ if (obj instanceof JDBCStorageConnection)
+ {
+ JDBCStorageConnection another = (JDBCStorageConnection)obj;
+ return getJdbcConnection() == another.getJdbcConnection();
+ }
+
+ return false;
+ }
+
+ /**
+ * Return JDBC connection obtained from initialized data source. NOTE: Helper can
obtain one new
+ * connection per each call of the method or return one obtained once.
+ */
+ public Connection getJdbcConnection()
+ {
+ return dbConnection;
+ }
+
+ /**
+ * Prepared queries at start time.
+ *
+ * @throws SQLException
+ * database error
+ */
+ abstract protected void prepareQueries() throws SQLException;
+
+ /**
+ * Used in Single Db Connection classes for Identifier related queries.
+ *
+ * @param identifier
+ * Item id
+ * @return String with container internal id
+ */
+ protected abstract String getInternalId(String identifier);
+
+ /**
+ * Used in loadXYZRecord methods for extract real Identifier from container value.
+ *
+ * @param internalId
+ * @return
+ */
+ protected abstract String getIdentifier(String internalId);
+
+ // ---------------- WorkspaceStorageConnection -------------
+
+ /**
+ * @throws IllegalStateException
+ * if connection is closed.
+ */
+ protected void checkIfOpened() throws IllegalStateException
+ {
+ if (!isOpened())
+ throw new IllegalStateException("Connection is closed");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isOpened()
+ {
+ try
+ {
+ return !dbConnection.isClosed();
+ }
+ catch (SQLException e)
+ {
+ LOG.error(e);
+ return false;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final void rollback() throws IllegalStateException, RepositoryException
+ {
+ checkIfOpened();
+ try
+ {
+ dbConnection.rollback();
+ dbConnection.close();
+
+ // rollback from the end
+ for (int p = valueChanges.size() - 1; p >= 0; p--)
+ valueChanges.get(p).rollback();
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ finally
+ {
+ valueChanges.clear();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final void close() throws IllegalStateException, RepositoryException
+ {
+ checkIfOpened();
+ try
+ {
+ // If READ-ONLY status back it to READ-WRITE (we assume it was original state)
+ if (readOnly)
+ dbConnection.setReadOnly(true);
+
+ dbConnection.close();
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final void commit() throws IllegalStateException, RepositoryException
+ {
+ checkIfOpened();
+ try
+ {
+ dbConnection.commit();
+ dbConnection.close();
+
+ try
+ {
+ for (ValueIOChannel vo : valueChanges)
+ vo.commit();
+
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ finally
+ {
+ valueChanges.clear();
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void add(NodeData data) throws RepositoryException,
UnsupportedOperationException, InvalidItemStateException,
+ IllegalStateException
+ {
+ checkIfOpened();
+ try
+ {
+ addNodeRecord(data);
+ if (LOG.isDebugEnabled())
+ LOG.debug("Node added " + data.getQPath().getAsString() + ",
" + data.getIdentifier() + ", "
+ + data.getPrimaryTypeName().getAsString());
+
+ }
+ catch (SQLException e)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.error("Node add. Database error: " + e);
+
+ exceptionHandler.handleAddException(e, data);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void add(PropertyData data) throws RepositoryException,
UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ checkIfOpened();
+
+ try
+ {
+ addPropertyRecord(data);
+
+ if (data.getType() == PropertyType.REFERENCE)
+ {
+ try
+ {
+ addReference(data);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException("Can't read REFERENCE property
(" + data.getQPath() + " "
+ + data.getIdentifier() + ") value: " + e.getMessage(), e);
+ }
+ }
+
+ addValues(getInternalId(data.getIdentifier()), data);
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("Property added " + data.getQPath().getAsString() +
", " + data.getIdentifier()
+ + (data.getValues() != null ? ", values count: " +
data.getValues().size() : ", NULL data"));
+
+ }
+ catch (IOException e)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.error("Property add. IO error: " + e, e);
+ throw new RepositoryException("Error of Property Value add " + e, e);
+ }
+ catch (SQLException e)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.error("Property add. Database error: " + e, e);
+ exceptionHandler.handleAddException(e, data);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rename(NodeData data) throws RepositoryException,
UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+
+ checkIfOpened();
+ try
+ {
+ if (renameNode(data) <= 0)
+ throw new JCRInvalidItemStateException("(rename) Node not found " +
data.getQPath().getAsString() + " "
+ + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
+ ItemState.RENAMED);
+ }
+ catch (SQLException e)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.error("Property add. Database error: " + e, e);
+ exceptionHandler.handleAddException(e, data);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void delete(NodeData data) throws RepositoryException,
UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ checkIfOpened();
+
+ final String cid = getInternalId(data.getIdentifier());
+
+ try
+ {
+ int nc = deleteItemByIdentifier(cid);
+ if (nc <= 0)
+ throw new JCRInvalidItemStateException("(delete) Node not found " +
data.getQPath().getAsString() + " "
+ + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
+ ItemState.DELETED);
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("Node deleted " + data.getQPath().getAsString() + ",
" + data.getIdentifier() + ", "
+ + ((NodeData)data).getPrimaryTypeName().getAsString());
+
+ }
+ catch (SQLException e)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.error("Node remove. Database error: " + e, e);
+ exceptionHandler.handleDeleteException(e, data);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void delete(PropertyData data) throws RepositoryException,
UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ checkIfOpened();
+
+ final String cid = getInternalId(data.getIdentifier());
+
+ try
+ {
+ deleteValues(cid, data, false);
+
+ // delete references
+ deleteReference(cid);
+
+ // delete item
+ int nc = deleteItemByIdentifier(cid);
+ if (nc <= 0)
+ throw new JCRInvalidItemStateException("(delete) Property not found
" + data.getQPath().getAsString() + " "
+ + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
+ ItemState.DELETED);
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("Property deleted "
+ + data.getQPath().getAsString()
+ + ", "
+ + data.getIdentifier()
+ + (((PropertyData)data).getValues() != null ? ", values count:
"
+ + ((PropertyData)data).getValues().size() : ", NULL data"));
+
+ }
+ catch (IOException e)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.error("Property remove. IO error: " + e, e);
+ throw new RepositoryException("Error of Property Value delete " + e,
e);
+ }
+ catch (SQLException e)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.error("Property remove. Database error: " + e, e);
+ exceptionHandler.handleDeleteException(e, data);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update(NodeData data) throws RepositoryException,
UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ checkIfOpened();
+ try
+ {
+ String cid = getInternalId(data.getIdentifier());
+ // order numb update
+ if (updateNodeByIdentifier(data.getPersistedVersion(),
data.getQPath().getIndex(), data.getOrderNumber(), cid) <= 0)
+ throw new JCRInvalidItemStateException("(update) Node not found " +
data.getQPath().getAsString() + " "
+ + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
+ ItemState.UPDATED);
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("Node updated " + data.getQPath().getAsString() + ",
" + data.getIdentifier() + ", "
+ + data.getPrimaryTypeName().getAsString());
+
+ }
+ catch (SQLException e)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.error("Node update. Database error: " + e, e);
+ exceptionHandler.handleUpdateException(e, data);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update(PropertyData data) throws RepositoryException,
UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ checkIfOpened();
+
+ try
+ {
+ String cid = getInternalId(data.getIdentifier());
+
+ // update type
+ if (updatePropertyByIdentifier(data.getPersistedVersion(), data.getType(), cid)
<= 0)
+ throw new JCRInvalidItemStateException("(update) Property not found
" + data.getQPath().getAsString() + " "
+ + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
+ ItemState.UPDATED);
+
+ // update reference
+ try
+ {
+ deleteReference(cid);
+
+ if (data.getType() == PropertyType.REFERENCE)
+ {
+ addReference(data);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException("Can't update REFERENCE property
(" + data.getQPath() + " "
+ + data.getIdentifier() + ") value: " + e.getMessage(), e);
+ }
+
+ // do Values update: delete all and add all
+ deleteValues(cid, data, true);
+ addValues(cid, data);
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("Property updated " + data.getQPath().getAsString() +
", " + data.getIdentifier()
+ + (data.getValues() != null ? ", values count: " +
data.getValues().size() : ", NULL data"));
+
+ }
+ catch (IOException e)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.error("Property update. IO error: " + e, e);
+ throw new RepositoryException("Error of Property Value update " + e,
e);
+ }
+ catch (SQLException e)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.error("Property update. Database error: " + e, e);
+ exceptionHandler.handleUpdateException(e, data);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<NodeData> getChildNodesData(NodeData parent) throws
RepositoryException, IllegalStateException
+ {
+ checkIfOpened();
+ try
+ {
+ // ResultSet node =
findChildNodesByParentIdentifier(getInternalId(parent.getIdentifier()));
+ // List<NodeData> childrens = new ArrayList<NodeData>();
+ // while (node.next())
+ // childrens.add((NodeData)itemData(parent.getQPath(), node,
I_CLASS_NODE, parent.getACL()));
+ //
+ // return childrens;
+ ResultSet resultSet =
findChildNodesByParentIdentifierNew(getInternalId(parent.getIdentifier()));
+ if (resultSet.next())
+ {
+ Map<String, TempNodeData> tempNodes = loadNodesData(resultSet);
+
+ List<NodeData> childrens = new
ArrayList<NodeData>(tempNodes.size());
+ QPath parentQPath = parent.getQPath();
+ AccessControlList parentACL = parent.getACL();
+ for (TempNodeData data : tempNodes.values())
+ {
+ NodeData nodeData = loadNodeFromTemporaryNodeData(data, parentQPath,
parentACL);
+ childrens.add(nodeData);
+ }
+ return childrens;
+ }
+ else
+ {
+ return new ArrayList<NodeData>();
+ }
+
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ protected Map<String, TempNodeData> loadNodesData(ResultSet resultSet) throws
RepositoryException, IOException,
+ SQLException
+ {
+
+ Map<String, TempNodeData> nodesData = new LinkedHashMap<String,
TempNodeData>();
+ do
+ {
+ int itemClass = resultSet.getInt(COLUMN_CLASS);
+ if (itemClass == I_CLASS_NODE)
+ {
+ TempNodeData data = new TempNodeData(resultSet);
+ nodesData.put(data.cid, data);
+ }
+ else
+ {
+ String cpid = resultSet.getString(COLUMN_PARENTID);
+ TempNodeData data = nodesData.get(cpid);
+ if (data.properties == null)
+ {
+ data.properties = new HashMap<String, List<byte[]>>();
+ }
+ Map<String, List<byte[]>> properties = data.properties;
+ String key = resultSet.getString(COLUMN_NAME);
+ List<byte[]> values = properties.get(key);
+ if (values == null)
+ {
+ values = new ArrayList<byte[]>();
+ properties.put(key, values);
+ }
+ values.add(resultSet.getBytes(COLUMN_VDATA));
+ }
+ }
+ while (resultSet.next());
+
+ return nodesData;
+
+ }
+
+ private static class TempNodeData
+ {
+ String cid;
+
+ String cname;
+
+ int cversion;
+
+ String cpid;
+
+ int cindex;
+
+ int cnordernumb;
+
+ Map<String, List<byte[]>> properties = new HashMap<String,
List<byte[]>>();
+
+ public TempNodeData(ResultSet item) throws SQLException
+ {
+ cid = item.getString(COLUMN_ID);
+ cname = item.getString(COLUMN_NAME);
+ cversion = item.getInt(COLUMN_VERSION);
+
+ cpid = item.getString(COLUMN_PARENTID);
+
+ cindex = item.getInt(COLUMN_INDEX);
+ cnordernumb = item.getInt(COLUMN_NORDERNUM);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getChildNodesCount(NodeData parent) throws RepositoryException
+ {
+ checkIfOpened();
+ try
+ {
+ ResultSet count =
findChildNodesCountByParentIdentifier(getInternalId(parent.getIdentifier()));
+ if (count.next())
+ {
+ return count.getInt(1);
+ }
+ else
+ {
+ throw new RepositoryException("FATAL No resulton childNodes count for
" + parent.getQPath().getAsString());
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<PropertyData> getChildPropertiesData(NodeData parent) throws
RepositoryException, IllegalStateException
+ {
+ checkIfOpened();
+ try
+ {
+
+ ResultSet resultSet =
getChildPropertiesByParentIdentifier(getInternalId(parent.getIdentifier()));
+ List<PropertyData> children = new ArrayList<PropertyData>();
+ if (resultSet.next())
+ {
+ while (!resultSet.isAfterLast())
+ children.add(loadPropertyRecord(resultSet, parent.getQPath()));
+ }
+
+ return children;
+
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * TODO left as current
+ */
+ public List<PropertyData> listChildPropertiesData(NodeData parent) throws
RepositoryException, IllegalStateException
+ {
+ checkIfOpened();
+ try
+ {
+ ResultSet prop =
findChildPropertiesByParentIdentifier(getInternalId(parent.getIdentifier()));
+ List<PropertyData> children = new ArrayList<PropertyData>();
+ while (prop.next())
+ children.add(propertyData(parent.getQPath(), prop));
+
+ return children;
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData getItemData(String identifier) throws RepositoryException,
IllegalStateException
+ {
+ return getItemByIdentifier(getInternalId(identifier));
+ }
+
+ public ItemData getItemData(NodeData parentData, QPathEntry name) throws
RepositoryException, IllegalStateException
+ {
+
+ if (parentData != null)
+ {
+ return getItemByName(parentData, getInternalId(parentData.getIdentifier()),
name);
+ }
+
+ // it's a root node
+ return getItemByName(null, null, name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<PropertyData> getReferencesData(String nodeIdentifier) throws
RepositoryException, IllegalStateException
+ {
+ checkIfOpened();
+ try
+ {
+ ResultSet refProps = findReferences(getInternalId(nodeIdentifier));
+ List<PropertyData> references = new ArrayList<PropertyData>();
+ while (refProps.next())
+ {
+ references.add((PropertyData)itemData(null, refProps, I_CLASS_PROPERTY,
null));
+ }
+
+ // ResultSet resultSet =
findReferenceProperties(getInternalId(nodeIdentifier));
+ // List<PropertyData> references = new
ArrayList<PropertyData>(); //
+ // if (resultSet.next())
+ // {
+ // while (!resultSet.isAfterLast())
+ // references.add(loadPropertyRecord(resultSet, null));
+ // }
+
+ return references;
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ // ------------------ Private methods ---------------
+
+ /**
+ * Get Item By Identifier.
+ *
+ * @param cid
+ * Item id (container internal)
+ * @return ItemData
+ * @throws RepositoryException
+ * Repository error
+ * @throws IllegalStateException
+ * if connection is closed
+ */
+ protected ItemData getItemByIdentifier(String cid) throws RepositoryException,
IllegalStateException
+ {
+ checkIfOpened();
+ ResultSet resultSet = null;
+ try
+ {
+ resultSet = findItemByIdentifierNew(cid);
+ if (resultSet.next())
+ {
+ int itemType = resultSet.getInt(COLUMN_CLASS);
+ if (itemType == I_CLASS_NODE)
+ {
+ Map<String, TempNodeData> node = loadNodesData(resultSet);
+ return loadNodeFromTemporaryNodeData(node.get(cid), null, null);
+ //return loadNodeRecord(resultSet, null, null);
+ }
+ else
+ {
+ return loadPropertyRecord(resultSet, null);
+ }
+
+ }
+ return null;
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException("getItemData() error", e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException("getItemData() error", e);
+ }
+ finally
+ {
+ try
+ {
+ if (resultSet != null)
+ resultSet.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("getItemData() Error close resultset " +
e.getMessage());
+ }
+ }
+
+ }
+
+ /**
+ * Gets an item data from database.
+ *
+ * @param parentPath
+ * - parent QPath
+ * @param parentId
+ * - parent container internal id (depends on Multi/Single DB)
+ * @param name
+ * - item name
+ * @return - ItemData instance
+ * @throws RepositoryException
+ * Repository error
+ * @throws IllegalStateException
+ * if connection is closed
+ */
+ protected ItemData getItemByName(NodeData parent, String parentId, QPathEntry name)
throws RepositoryException,
+ IllegalStateException
+ {
+ checkIfOpened();
+ ResultSet resultSet = null;
+ try
+ {
+ resultSet = findItemByNameNew(parentId, name.getAsString(), name.getIndex());
+ if (resultSet.next())
+ {
+ // return itemData(parent.getQPath(), item, item.getInt(COLUMN_CLASS),
parent.getACL());
+ int itemType = resultSet.getInt(COLUMN_CLASS);
+ if (itemType == I_CLASS_NODE)
+ {
+ // Remember first node id. If node is not first in result set - it's a
bug.
+ String firstNodeId = resultSet.getString(COLUMN_ID);
+
+ // There may be two or more nodes, so load temp NodeDatas and return first
one.
+ Map<String, TempNodeData> tempNodes = loadNodesData(resultSet);
+
+ QPath parentQPath = parent.getQPath();
+ AccessControlList parentACL = parent.getACL();
+
+ NodeData nodeData =
loadNodeFromTemporaryNodeData(tempNodes.get(firstNodeId), parentQPath, parentACL);
+ tempNodes.clear();
+ return nodeData;
+
+ //return loadNodeRecord(resultSet, parent.getQPath(), parent.getACL());
+ }
+ else
+ {
+ return loadPropertyRecord(resultSet, parent.getQPath());
+ }
+ }
+
+ return null;
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ finally
+ {
+ try
+ {
+ if (resultSet != null)
+ resultSet.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("getItemData() Error close resultset " +
e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Build Item path by id.
+ *
+ * @param cpid
+ * - Item id (container id)
+ * @return Item QPath
+ * @throws SQLException
+ * - if database error occurs
+ * @throws InvalidItemStateException
+ * - if parent not found
+ * @throws IllegalNameException
+ * - if name on the path is wrong
+ */
+ private QPath traverseQPath(String cpid) throws SQLException,
InvalidItemStateException, IllegalNameException
+ {
+ // get item by Identifier usecase
+ List<QPathEntry> qrpath = new ArrayList<QPathEntry>(); // reverted
path
+ String caid = cpid; // container ancestor id
+ do
+ {
+ ResultSet parent = null;
+ try
+ {
+ parent = findItemByIdentifier(caid);
+ if (!parent.next())
+ throw new InvalidItemStateException("Parent not found, uuid: " +
getIdentifier(caid));
+
+ QPathEntry qpe =
+ new QPathEntry(InternalQName.parse(parent.getString(COLUMN_NAME)),
parent.getInt(COLUMN_INDEX));
+ qrpath.add(qpe);
+ caid = parent.getString(COLUMN_PARENTID);
+ }
+ finally
+ {
+ parent.close();
+ }
+ }
+ while (!caid.equals(Constants.ROOT_PARENT_UUID));
+
+ QPathEntry[] qentries = new QPathEntry[qrpath.size()];
+ int qi = 0;
+ for (int i = qrpath.size() - 1; i >= 0; i--)
+ {
+ qentries[qi++] = qrpath.get(i);
+ }
+ return new QPath(qentries);
+ }
+
+ /**
+ * ItemLocationInfo.
+ *
+ */
+ class ItemLocationInfo
+ {
+ /**
+ * Item qpath
+ */
+ final QPath qpath;
+
+ /**
+ * All ancestors of the item with qpath
+ */
+ final List<String> ancestors;
+
+ /**
+ * Item id.
+ */
+ final String itemId;
+
+ /**
+ * ItemLocationInfo constructor.
+ *
+ * @param qpath
+ * Item path
+ * @param ancestors
+ * ancesstors id list
+ * @param itemId
+ * Item id
+ */
+ ItemLocationInfo(QPath qpath, List<String> ancestors, String itemId)
+ {
+ this.qpath = qpath;
+ this.ancestors = ancestors;
+ this.itemId = itemId;
+ }
+ }
+
+ /**
+ * Find ancestor permissions by cpid. Will search till find the permissions or meet a
root node.
+ *
+ * @param cpid
+ * - initial parent node id
+ * @return Collection<String>
+ * @throws SQLException
+ * if database error
+ * @throws IllegalACLException
+ * if wrong ACL
+ * @throws IllegalNameException
+ * if wrong QName
+ * @throws RepositoryException
+ * if Repository error
+ */
+ private List<AccessControlEntry> traverseACLPermissions(String cpid) throws
SQLException, IllegalACLException,
+ IllegalNameException, RepositoryException
+ {
+ String caid = cpid;
+ while (!caid.equals(Constants.ROOT_PARENT_UUID))
+ {
+ MixinInfo naMixins = readMixins(caid);
+ if (naMixins.hasPrivilegeable())
+ return readACLPermisions(caid);
+
+ if (naMixins.parentId == null)
+ caid = findParentId(caid);
+ else
+ caid = naMixins.parentId;
+ }
+
+ throw new IllegalACLException("Can not find permissions for a node with id
" + getIdentifier(cpid));
+ }
+
+ protected String findParentId(String cid) throws SQLException, RepositoryException
+ {
+ ResultSet pidrs = findItemByIdentifier(cid);
+ try
+ {
+ if (pidrs.next())
+ return pidrs.getString(COLUMN_PARENTID);
+ else
+ throw new RepositoryException("Item not found id: " +
getIdentifier(cid));
+ }
+ finally
+ {
+ pidrs.close();
+ }
+ }
+
+ /**
+ * Find ancestor owner by cpid. Will search till find the owner or meet a root node.
+ *
+ * @param cpid
+ * - initial parent node id
+ * @return owner name
+ * @throws SQLException
+ * if database error
+ * @throws IllegalACLException
+ * if wrong ACL
+ * @throws IllegalNameException
+ * if wrong QName
+ * @throws RepositoryException
+ * if Repository error
+ */
+ private String traverseACLOwner(String cpid) throws SQLException, IllegalACLException,
IllegalNameException,
+ RepositoryException
+ {
+ String caid = cpid;
+
+ while (!caid.equals(Constants.ROOT_PARENT_UUID))
+ {
+ MixinInfo naMixins = readMixins(caid);
+ if (naMixins.hasOwneable())
+ return readACLOwner(caid);
+
+ if (naMixins.parentId == null)
+ caid = findParentId(caid);
+ else
+ caid = naMixins.parentId;
+ }
+
+ throw new IllegalACLException("Can not find owner for a node with id " +
getIdentifier(cpid));
+ }
+
+ /**
+ * Find ancestor ACL by cpid. Will search till find the ACL or meet a root node.
+ *
+ * @param cpid
+ * - initial parent node id
+ * @return owner name
+ * @throws SQLException
+ * if database error
+ * @throws IllegalACLException
+ * if wrong ACL
+ * @throws IllegalNameException
+ * if wrong QName
+ * @throws RepositoryException
+ * if Repository error
+ */
+ private AccessControlList traverseACL(String cpid) throws SQLException,
IllegalACLException, IllegalNameException,
+ RepositoryException
+ {
+ String naOwner = null;
+ List<AccessControlEntry> naPermissions = null;
+
+ String caid = cpid;
+
+ while (!caid.equals(Constants.ROOT_PARENT_UUID))
+ {
+ MixinInfo naMixins = readMixins(caid);
+ if (naOwner == null && naMixins.hasOwneable())
+ {
+ naOwner = readACLOwner(caid);
+ if (naPermissions != null)
+ break;
+ }
+ if (naPermissions == null && naMixins.hasPrivilegeable())
+ {
+ naPermissions = readACLPermisions(caid);
+ if (naOwner != null)
+ break;
+ }
+
+ if (naMixins.parentId == null)
+ caid = findParentId(caid);
+ else
+ caid = naMixins.parentId;
+ }
+
+ if (naOwner != null && naPermissions != null)
+ {
+ // got all
+ return new AccessControlList(naOwner, naPermissions);
+ }
+ else if (naOwner == null && naPermissions == null)
+ {
+ // Default values (i.e. ACL is disabled in repository)
+ return new AccessControlList();
+ }
+ else
+ throw new IllegalACLException("ACL is not found for node with id " +
getIdentifier(cpid)
+ + " or for its ancestors. But repository is ACL enabled.");
+ }
+
+ /**
+ * [PN] Experimental. Use SP for traversing Qpath on the database server side. Hm, I
haven't a
+ * good result for that yet. Few seconds only for TCK execution. PGSQL SP: CREATE OR
REPLACE
+ * FUNCTION get_qpath(parentId VARCHAR) RETURNS SETOF record AS $$ DECLARE cur_item
RECORD; cur_id
+ * varchar; BEGIN cur_id := parentId; WHILE NOT cur_id = ' ' LOOP SELECT id,
name, parent_id,
+ * i_index INTO cur_item FROM JCR_SITEM WHERE ID=cur_id; IF NOT found THEN RETURN; END
IF; RETURN
+ * NEXT cur_item; cur_id := cur_item.parent_id; END LOOP; RETURN; END; $$ LANGUAGE
plpgsql;
+ *
+ * @param cpid
+ * @return
+ * @throws SQLException
+ * if database error
+ * @throws InvalidItemStateException
+ * if Item state is obsolete
+ * @throws IllegalNameException
+ * if invalid QName
+ */
+ private QPath traverseQPath_SP_PGSQL(String cpid) throws SQLException,
InvalidItemStateException,
+ IllegalNameException
+ {
+ // get item by Identifier usecase:
+ // find parent path in db by cpid
+ if (cpid == null)
+ {
+ // root node
+ return null; // Constants.ROOT_PATH
+ }
+ else
+ {
+ List<QPathEntry> qrpath = new ArrayList<QPathEntry>(); // reverted
path
+ PreparedStatement cstmt = null;
+ try
+ {
+ cstmt =
+ dbConnection
+ .prepareStatement("select * from get_qpath(?) AS (id varchar, name
varchar, parent_id varchar, i_index int)");
+ cstmt.setString(1, cpid);
+ // cstmt.setString(2, caid);
+ ResultSet parent = cstmt.executeQuery();
+
+ while (parent.next())
+ {
+ QPathEntry qpe =
+ new QPathEntry(InternalQName.parse(parent.getString(COLUMN_NAME)),
parent.getInt(COLUMN_INDEX));
+ qrpath.add(qpe);
+ }
+
+ // parent = findItemByIdentifier(caid);
+ if (qrpath.size() <= 0)
+ throw new InvalidItemStateException("Parent not found, uuid: " +
getIdentifier(cpid));
+ }
+ finally
+ {
+ if (cstmt != null)
+ cstmt.close();
+ }
+
+ QPathEntry[] qentries = new QPathEntry[qrpath.size()];
+ int qi = 0;
+ for (int i = qrpath.size() - 1; i >= 0; i--)
+ {
+ qentries[qi++] = qrpath.get(i);
+ }
+ return new QPath(qentries);
+ }
+ }
+
+ /**
+ * Build ItemData.
+ *
+ * @param parentPath
+ * - parent path
+ * @param item
+ * database - ResultSet with Item record(s)
+ * @param itemClass
+ * - Item type (Node or Property)
+ * @param parentACL
+ * - parent ACL
+ * @return ItemData instance
+ * @throws RepositoryException
+ * Repository error
+ * @throws SQLException
+ * database error
+ * @throws IOException
+ * I/O error
+ */
+ private ItemData itemData(QPath parentPath, ResultSet item, int itemClass,
AccessControlList parentACL)
+ throws RepositoryException, SQLException, IOException
+ {
+ String cid = item.getString(COLUMN_ID);
+ String cname = item.getString(COLUMN_NAME);
+ int cversion = item.getInt(COLUMN_VERSION);
+
+ String cpid = item.getString(COLUMN_PARENTID);
+ // if parent ID is empty string - it's a root node
+ // cpid = cpid.equals(Constants.ROOT_PARENT_UUID) ? null : cpid;
+
+ try
+ {
+ if (itemClass == I_CLASS_NODE)
+ {
+ int cindex = item.getInt(COLUMN_INDEX);
+ int cnordernumb = item.getInt(COLUMN_NORDERNUM);
+ return loadNodeRecord(parentPath, cname, cid, cpid, cindex, cversion,
cnordernumb, parentACL);
+ }
+
+ int cptype = item.getInt(COLUMN_PTYPE);
+ boolean cpmultivalued = item.getBoolean(COLUMN_PMULTIVALUED);
+ return loadPropertyRecord(parentPath, cname, cid, cpid, cversion, cptype,
cpmultivalued);
+ }
+ catch (InvalidItemStateException e)
+ {
+ throw new InvalidItemStateException("FATAL: Can't build item path for
name " + cname + " id: "
+ + getIdentifier(cid) + ". " + e);
+ }
+ }
+
+ /**
+ * Read property data without value data. For listChildPropertiesData(NodeData).
+ *
+ * @param parentPath
+ * - parent path
+ * @param item
+ * database - ResultSet with Item record(s)
+ * @return PropertyData instance
+ * @throws RepositoryException
+ * Repository error
+ * @throws SQLException
+ * database error
+ * @throws IOException
+ * I/O error
+ */
+ private PropertyData propertyData(QPath parentPath, ResultSet item) throws
RepositoryException, SQLException,
+ IOException
+ {
+ String cid = item.getString(COLUMN_ID);
+ String cname = item.getString(COLUMN_NAME);
+ int cversion = item.getInt(COLUMN_VERSION);
+ String cpid = item.getString(COLUMN_PARENTID);
+ int cptype = item.getInt(COLUMN_PTYPE);
+ boolean cpmultivalued = item.getBoolean(COLUMN_PMULTIVALUED);
+
+ try
+ {
+ InternalQName qname = InternalQName.parse(cname);
+
+ QPath qpath = QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) :
parentPath, qname);
+
+ PersistedPropertyData pdata =
+ new PersistedPropertyData(getIdentifier(cid), qpath, getIdentifier(cpid),
cversion, cptype, cpmultivalued,
+ new ArrayList<ValueData>());
+
+ return pdata;
+ }
+ catch (InvalidItemStateException e)
+ {
+ throw new InvalidItemStateException("FATAL: Can't build property path
for name " + cname + " id: "
+ + getIdentifier(cid) + ". " + e);
+ }
+ catch (IllegalNameException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * Mixin types description (internal use).
+ *
+ */
+ class MixinInfo
+ {
+
+ /**
+ * OWNEABLE constant.
+ */
+ static final int OWNEABLE = 0x0001; // bits 0001
+
+ /**
+ * PRIVILEGEABLE constant.
+ */
+ static final int PRIVILEGEABLE = 0x0002; // bits 0010
+
+ /**
+ * OWNEABLE_PRIVILEGEABLE constant.
+ */
+ static final int OWNEABLE_PRIVILEGEABLE = OWNEABLE | PRIVILEGEABLE; // bits 0011
+
+ /**
+ * Mixin types.
+ */
+ final List<InternalQName> mixinTypes;
+
+ /**
+ * oexo:owneable flag.
+ */
+ final boolean owneable;
+
+ /**
+ * exo:privilegeable flag.
+ */
+ final boolean privilegeable;
+
+ /**
+ * Parent Id.
+ */
+ final String parentId = null;
+
+ /**
+ * MixinInfo constructor.
+ *
+ * @param mixinTypes
+ * mixin types
+ * @param owneable
+ * exo:owneable flag
+ * @param privilegeable
+ * exo:privilegeable flag
+ */
+ MixinInfo(List<InternalQName> mixinTypes, boolean owneable, boolean
privilegeable)
+ {
+ this.mixinTypes = mixinTypes;
+ this.owneable = owneable;
+ this.privilegeable = privilegeable;
+ }
+
+ /**
+ * Return Mixin names array.
+ *
+ * @return InternalQName[] Mixin names array
+ */
+ InternalQName[] mixinNames()
+ {
+ if (mixinTypes != null)
+ {
+ InternalQName[] mns = new InternalQName[mixinTypes.size()];
+ mixinTypes.toArray(mns);
+ return mns;
+ }
+ else
+ return new InternalQName[0];
+ }
+
+ /**
+ * Tell is exo:privilegeable.
+ *
+ * @return boolean
+ */
+ boolean hasPrivilegeable()
+ {
+ return privilegeable;
+ }
+
+ /**
+ * Tell is exo:owneable.
+ *
+ * @return boolean
+ */
+ boolean hasOwneable()
+ {
+ return owneable;
+ }
+ }
+
+ /**
+ * Read mixins from database.
+ *
+ * @param cid
+ * - Item id (internal)
+ * @return MixinInfo
+ * @throws SQLException
+ * database error
+ * @throws IllegalNameException
+ * if nodetype name in mixin record is wrong
+ */
+ protected MixinInfo readMixins(String cid) throws SQLException, IllegalNameException
+ {
+ ResultSet mtrs = findPropertyByName(cid, Constants.JCR_MIXINTYPES.getAsString());
+
+ try
+ {
+ List<InternalQName> mts = null;
+ boolean owneable = false;
+ boolean privilegeable = false;
+ if (mtrs.next())
+ {
+ mts = new ArrayList<InternalQName>();
+ do
+ {
+ byte[] mxnb = mtrs.getBytes(COLUMN_VDATA);
+ if (mxnb != null)
+ {
+ InternalQName mxn = InternalQName.parse(new String(mxnb));
+ mts.add(mxn);
+
+ if (!privilegeable && Constants.EXO_PRIVILEGEABLE.equals(mxn))
+ privilegeable = true;
+ else if (!owneable && Constants.EXO_OWNEABLE.equals(mxn))
+ owneable = true;
+ } // else, if SQL NULL - skip it
+ }
+ while (mtrs.next());
+ }
+
+ return new MixinInfo(mts, owneable, privilegeable);
+ }
+ finally
+ {
+ mtrs.close();
+ }
+ }
+
+ /**
+ * Return permission values or throw an exception. We assume the node is
mix:privilegeable.
+ *
+ * @param cid
+ * Node id
+ * @return list of ACL entries
+ * @throws SQLException
+ * database error
+ * @throws IllegalACLException
+ * if property exo:permissions is not found for node
+ */
+ protected List<AccessControlEntry> readACLPermisions(String cid) throws
SQLException, IllegalACLException
+ {
+ List<AccessControlEntry> naPermissions = new
ArrayList<AccessControlEntry>();
+ ResultSet exoPerm = findPropertyByName(cid,
Constants.EXO_PERMISSIONS.getAsString());
+ try
+ {
+ if (exoPerm.next())
+ {
+ do
+ {
+ StringTokenizer parser =
+ new StringTokenizer(new String(exoPerm.getBytes(COLUMN_VDATA)),
AccessControlEntry.DELIMITER);
+ naPermissions.add(new AccessControlEntry(parser.nextToken(),
parser.nextToken()));
+ }
+ while (exoPerm.next());
+
+ return naPermissions;
+ }
+ else
+ throw new IllegalACLException("Property exo:permissions is not found for
node with id: "
+ + getIdentifier(cid));
+ }
+ finally
+ {
+ exoPerm.close();
+ }
+ }
+
+ /**
+ * Return owner value or throw an exception. We assume the node is mix:owneable.
+ *
+ * @param cid
+ * Node id
+ * @return ACL owner
+ * @throws SQLException
+ * database error
+ * @throws IllegalACLException
+ * Property exo:owner is not found for node
+ */
+ protected String readACLOwner(String cid) throws SQLException, IllegalACLException
+ {
+ ResultSet exoOwner = findPropertyByName(cid, Constants.EXO_OWNER.getAsString());
+ try
+ {
+ if (exoOwner.next())
+ return new String(exoOwner.getBytes(COLUMN_VDATA));
+ else
+ throw new IllegalACLException("Property exo:owner is not found for node
with id: " + getIdentifier(cid));
+ }
+ finally
+ {
+ exoOwner.close();
+ }
+ }
+
+ /**
+ * Load NodeData record.
+ *
+ * @param parentPath
+ * parent path
+ * @param cname
+ * Node name
+ * @param cid
+ * Node id
+ * @param cpid
+ * Node parent id
+ * @param cindex
+ * Node index
+ * @param cversion
+ * Node persistent version
+ * @param cnordernumb
+ * Node order number
+ * @param parentACL
+ * Node parent ACL
+ * @return PersistedNodeData
+ * @throws RepositoryException
+ * Repository error
+ * @throws SQLException
+ * database error
+ */
+ protected PersistedNodeData loadNodeRecord(QPath parentPath, String cname, String cid,
String cpid, int cindex,
+ int cversion, int cnordernumb, AccessControlList parentACL) throws
RepositoryException, SQLException
+ {
+
+ try
+ {
+ InternalQName qname = InternalQName.parse(cname);
+
+ QPath qpath;
+ String parentCid;
+ if (parentPath != null)
+ {
+ // get by parent and name
+ qpath = QPath.makeChildPath(parentPath, qname, cindex);
+ parentCid = cpid;
+ }
+ else
+ {
+ // get by id
+ if (cpid.equals(Constants.ROOT_PARENT_UUID))
+ {
+ // root node
+ qpath = Constants.ROOT_PATH;
+ parentCid = null;
+ }
+ else
+ {
+ qpath = QPath.makeChildPath(traverseQPath(cpid), qname, cindex);
+ parentCid = cpid;
+ }
+ }
+
+ try
+ {
+ // PRIMARY
+ ResultSet ptProp = findPropertyByName(cid,
Constants.JCR_PRIMARYTYPE.getAsString());
+
+ if (!ptProp.next())
+ throw new PrimaryTypeNotFoundException("FATAL ERROR primary type
record not found. Node "
+ + qpath.getAsString() + ", id " + cid + ", container
" + this.containerName, null);
+
+ byte[] data = ptProp.getBytes(COLUMN_VDATA);
+ InternalQName ptName = InternalQName.parse(new String((data != null ? data :
new byte[]{})));
+
+ // MIXIN
+ MixinInfo mixins = readMixins(cid);
+
+ // ACL
+ AccessControlList acl; // NO DEFAULT values!
+
+ if (mixins.hasOwneable())
+ {
+ // has own owner
+ if (mixins.hasPrivilegeable())
+ {
+ // and permissions
+ acl = new AccessControlList(readACLOwner(cid),
readACLPermisions(cid));
+ }
+ else if (parentACL != null)
+ {
+ // use permissions from existed parent
+ acl =
+ new AccessControlList(readACLOwner(cid), parentACL.hasPermissions()
? parentACL
+ .getPermissionEntries() : null);
+ }
+ else
+ {
+ // have to search nearest ancestor permissions in ACL manager
+ // acl = new AccessControlList(readACLOwner(cid),
traverseACLPermissions(cpid));
+ acl = new AccessControlList(readACLOwner(cid), null);
+ }
+ }
+ else if (mixins.hasPrivilegeable())
+ {
+ // has own permissions
+ if (mixins.hasOwneable())
+ {
+ // and owner
+ acl = new AccessControlList(readACLOwner(cid),
readACLPermisions(cid));
+ }
+ else if (parentACL != null)
+ {
+ // use owner from existed parent
+ acl = new AccessControlList(parentACL.getOwner(),
readACLPermisions(cid));
+ }
+ else
+ {
+ // have to search nearest ancestor owner in ACL manager
+ // acl = new AccessControlList(traverseACLOwner(cpid),
readACLPermisions(cid));
+ acl = new AccessControlList(null, readACLPermisions(cid));
+ }
+ }
+ else
+ {
+ if (parentACL != null)
+ // construct ACL from existed parent ACL
+ acl =
+ new AccessControlList(parentACL.getOwner(),
parentACL.hasPermissions() ? parentACL
+ .getPermissionEntries() : null);
+ else
+ // have to search nearest ancestor owner and permissions in ACL
manager
+ // acl = traverseACL(cpid);
+ acl = null;
+ }
+
+ return new PersistedNodeData(getIdentifier(cid), qpath,
getIdentifier(parentCid), cversion, cnordernumb,
+ ptName, mixins.mixinNames(), acl);
+ }
+ catch (IllegalACLException e)
+ {
+ throw new RepositoryException("FATAL ERROR Node " +
getIdentifier(cid) + " " + qpath.getAsString()
+ + " has wrong formed ACL. ", e);
+ }
+ }
+ catch (IllegalNameException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * Load PropertyData record.
+ *
+ * @param parentPath
+ * parent path
+ * @param cname
+ * Property name
+ * @param cid
+ * Property id
+ * @param cpid
+ * Property parent id
+ * @param cversion
+ * Property persistent verison
+ * @param cptype
+ * Property type
+ * @param cpmultivalued
+ * Property multivalued status
+ * @return PersistedPropertyData
+ * @throws RepositoryException
+ * Repository error
+ * @throws SQLException
+ * database error
+ * @throws IOException
+ * I/O error
+ */
+ protected PersistedPropertyData loadPropertyRecord(QPath parentPath, String cname,
String cid, String cpid,
+ int cversion, int cptype, boolean cpmultivalued) throws RepositoryException,
SQLException, IOException
+ {
+
+ // NOTE: cpid never should be null or root parent (' ')
+
+ try
+ {
+ QPath qpath =
+ QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) : parentPath,
InternalQName.parse(cname));
+
+ String identifier = getIdentifier(cid);
+ List<ValueData> values = readValues(cid, identifier, cversion);
+ PersistedPropertyData pdata =
+ new PersistedPropertyData(identifier, qpath, getIdentifier(cpid), cversion,
cptype, cpmultivalued, values);
+
+ return pdata;
+ }
+ catch (IllegalNameException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ protected PersistedNodeData loadNodeRecord(ResultSet item, QPath parentPath,
AccessControlList pACL)
+ throws RepositoryException, SQLException, IOException
+ {
+
+ String cid = item.getString(COLUMN_ID);
+ String cname = item.getString(COLUMN_NAME);
+ int cversion = item.getInt(COLUMN_VERSION);
+ String cpid = item.getString(COLUMN_PARENTID);
+ int cindex = item.getInt(COLUMN_INDEX);
+ int cnordernumb = item.getInt(COLUMN_NORDERNUM);
+ AccessControlList parentACL = pACL;
+
+ try
+ {
+ InternalQName qname = InternalQName.parse(cname);
+
+ // TODO can't avoid QPath traverse
+ QPath qpath;
+ String parentCid;
+ if (parentPath != null)
+ {
+ // get by parent and name
+ qpath = QPath.makeChildPath(parentPath, qname, cindex);
+ parentCid = cpid;
+ }
+ else
+ {
+ // get by id
+ if (cpid.equals(Constants.ROOT_PARENT_UUID))
+ {
+ // root node
+ qpath = Constants.ROOT_PATH;
+ parentCid = null;
+ }
+ else
+ {
+ qpath = QPath.makeChildPath(traverseQPath(cpid), qname, cindex);
+ parentCid = cpid;
+ }
+ }
+
+ // preload properties
+
+ Map<String, List<byte[]>> properties = new LinkedHashMap<String,
List<byte[]>>();
+
+ // PRIMARY
+ if (!item.next() ||
!item.getString(COLUMN_NAME).equals(Constants.JCR_PRIMARYTYPE.getAsString()))
+ {
+ throw new SQLException("Node finded but primaryType property not "
+ cid);
+ }
+
+ byte[] data = item.getBytes(COLUMN_VDATA);
+ InternalQName ptName = InternalQName.parse(new String((data != null ? data : new
byte[]{})));
+
+ // // PRIMARY
+ // ResultSet ptProp = findPropertyByName(cid,
Constants.JCR_PRIMARYTYPE.getAsString());
+ //
+ // if (!ptProp.next())
+ // throw new PrimaryTypeNotFoundException("FATAL ERROR
primary type record not found. Node "
+ // + qpath.getAsString() + ", id " + cid + ",
container " + this.containerName, null);
+ //
+ // byte[] data = ptProp.getBytes(COLUMN_VDATA);
+ // InternalQName ptName = InternalQName.parse(new String((data !=
null ? data : new byte[]{})));
+
+ // MIXIN
+ MixinInfo mixins = null;
+ List<InternalQName> mts = null;
+ boolean owneable = false;
+ boolean privilegeable = false;
+ while (item.next() &&
item.getString(COLUMN_NAME).equals(Constants.JCR_MIXINTYPES.getAsString()))
+ {
+ mts = new ArrayList<InternalQName>();
+ byte[] mxnb = item.getBytes(COLUMN_VDATA);
+ if (mxnb != null)
+ {
+ InternalQName mxn = InternalQName.parse(new String(mxnb));
+ mts.add(mxn);
+
+ if (!privilegeable && Constants.EXO_PRIVILEGEABLE.equals(mxn))
+ privilegeable = true;
+ else if (!owneable && Constants.EXO_OWNEABLE.equals(mxn))
+ owneable = true;
+ } // else, if SQL NULL - skip it
+
+ }
+
+ mixins = new MixinInfo(mts, owneable, privilegeable);
+
+ try
+ {
+ // ACL
+ AccessControlList acl; // NO DEFAULT values!
+
+ if (mixins.hasOwneable())
+ {
+ // has own owner
+ if (mixins.hasPrivilegeable())
+ {
+ // and permissions
+ acl = new AccessControlList(readACLOwner(cid),
readACLPermisions(cid));
+ }
+ else if (parentACL != null)
+ {
+ // use permissions from existed parent
+ acl =
+ new AccessControlList(readACLOwner(cid), parentACL.hasPermissions()
? parentACL
+ .getPermissionEntries() : null);
+ }
+ else
+ {
+ // have to search nearest ancestor permissions in ACL manager
+ // acl = new AccessControlList(readACLOwner(cid),
traverseACLPermissions(cpid));
+ acl = new AccessControlList(readACLOwner(cid), null);
+ }
+ }
+ else if (mixins.hasPrivilegeable())
+ {
+ // has own permissions
+ if (mixins.hasOwneable())
+ {
+ // and owner
+ acl = new AccessControlList(readACLOwner(cid),
readACLPermisions(cid));
+ }
+ else if (parentACL != null)
+ {
+ // use owner from existed parent
+ acl = new AccessControlList(parentACL.getOwner(),
readACLPermisions(cid));
+ }
+ else
+ {
+ // have to search nearest ancestor owner in ACL manager
+ // acl = new AccessControlList(traverseACLOwner(cpid),
readACLPermisions(cid));
+ acl = new AccessControlList(null, readACLPermisions(cid));
+ }
+ }
+ else
+ {
+ if (parentACL != null)
+ // construct ACL from existed parent ACL
+ acl =
+ new AccessControlList(parentACL.getOwner(),
parentACL.hasPermissions() ? parentACL
+ .getPermissionEntries() : null);
+ else
+ // have to search nearest ancestor owner and permissions in ACL
manager
+ // acl = traverseACL(cpid);
+ acl = null;
+ }
+
+ return new PersistedNodeData(getIdentifier(cid), qpath,
getIdentifier(parentCid), cversion, cnordernumb,
+ ptName, mixins.mixinNames(), acl);
+
+ }
+ catch (IllegalACLException e)
+ {
+ throw new RepositoryException("FATAL ERROR Node " +
getIdentifier(cid) + " " + qpath.getAsString()
+ + " has wrong formed ACL. ", e);
+ }
+ }
+ catch (IllegalNameException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ protected PersistedNodeData loadNodeFromTemporaryNodeData(TempNodeData buf, QPath
parentPath, AccessControlList pACL)
+ throws RepositoryException, SQLException, IOException
+ {
+
+ String cid = buf.cid;
+ String cname = buf.cname;
+ int cversion = buf.cversion;
+ String cpid = buf.cpid;
+ int cindex = buf.cindex;
+ int cnordernumb = buf.cnordernumb;
+ AccessControlList parentACL = pACL;
+
+ try
+ {
+ InternalQName qname = InternalQName.parse(cname);
+
+ // TODO can't avoid QPath traverse
+ QPath qpath;
+ String parentCid;
+ if (parentPath != null)
+ {
+ // get by parent and name
+ qpath = QPath.makeChildPath(parentPath, qname, cindex);
+ parentCid = cpid;
+ }
+ else
+ {
+ // get by id
+ if (cpid.equals(Constants.ROOT_PARENT_UUID))
+ {
+ // root node
+ qpath = Constants.ROOT_PATH;
+ parentCid = null;
+ }
+ else
+ {
+ qpath = QPath.makeChildPath(traverseQPath(cpid), qname, cindex);
+ parentCid = cpid;
+ }
+ }
+
+ // PRIMARY
+
+ List<byte[]> primaryType =
buf.properties.get(Constants.JCR_PRIMARYTYPE.getAsString());
+ if (primaryType == null || primaryType.size() == 0)
+ {
+ throw new SQLException("Node finded but primaryType property not "
+ cid);
+ }
+
+ byte[] data = primaryType.get(0);
+ InternalQName ptName = InternalQName.parse(new String((data != null ? data : new
byte[]{})));
+
+ // MIXIN
+ MixinInfo mixins = null;
+ List<InternalQName> mts = null;
+ boolean owneable = false;
+ boolean privilegeable = false;
+ List<byte[]> mixinTypes =
buf.properties.get(Constants.JCR_MIXINTYPES.getAsString());
+ if (mixinTypes != null)
+ {
+ mts = new ArrayList<InternalQName>();
+ for (byte[] mxnb : mixinTypes)
+ {
+ InternalQName mxn = InternalQName.parse(new String(mxnb));
+ mts.add(mxn);
+
+ if (!privilegeable && Constants.EXO_PRIVILEGEABLE.equals(mxn))
+ privilegeable = true;
+ else if (!owneable && Constants.EXO_OWNEABLE.equals(mxn))
+ owneable = true;
+ }
+ }
+
+ mixins = new MixinInfo(mts, owneable, privilegeable);
+
+ try
+ {
+ // ACL
+ AccessControlList acl; // NO DEFAULT values!
+
+ if (mixins.hasOwneable())
+ {
+ // has own owner
+ if (mixins.hasPrivilegeable())
+ {
+ // and permissions
+ acl = new AccessControlList(readACLOwner(cid),
readACLPermisions(cid));
+ }
+ else if (parentACL != null)
+ {
+ // use permissions from existed parent
+ acl =
+ new AccessControlList(readACLOwner(cid), parentACL.hasPermissions()
? parentACL
+ .getPermissionEntries() : null);
+ }
+ else
+ {
+ // have to search nearest ancestor permissions in ACL manager
+ // acl = new AccessControlList(readACLOwner(cid),
traverseACLPermissions(cpid));
+ acl = new AccessControlList(readACLOwner(cid), null);
+ }
+ }
+ else if (mixins.hasPrivilegeable())
+ {
+ // has own permissions
+ if (mixins.hasOwneable())
+ {
+ // and owner
+ acl = new AccessControlList(readACLOwner(cid),
readACLPermisions(cid));
+ }
+ else if (parentACL != null)
+ {
+ // use owner from existed parent
+ acl = new AccessControlList(parentACL.getOwner(),
readACLPermisions(cid));
+ }
+ else
+ {
+ // have to search nearest ancestor owner in ACL manager
+ // acl = new AccessControlList(traverseACLOwner(cpid),
readACLPermisions(cid));
+ acl = new AccessControlList(null, readACLPermisions(cid));
+ }
+ }
+ else
+ {
+ if (parentACL != null)
+ // construct ACL from existed parent ACL
+ acl =
+ new AccessControlList(parentACL.getOwner(),
parentACL.hasPermissions() ? parentACL
+ .getPermissionEntries() : null);
+ else
+ // have to search nearest ancestor owner and permissions in ACL
manager
+ // acl = traverseACL(cpid);
+ acl = null;
+ }
+
+ return new PersistedNodeData(getIdentifier(cid), qpath,
getIdentifier(parentCid), cversion, cnordernumb,
+ ptName, mixins.mixinNames(), acl);
+
+ }
+ catch (IllegalACLException e)
+ {
+ throw new RepositoryException("FATAL ERROR Node " +
getIdentifier(cid) + " " + qpath.getAsString()
+ + " has wrong formed ACL. ", e);
+ }
+ }
+ catch (IllegalNameException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ protected PersistedPropertyData loadPropertyRecord(ResultSet item, QPath parentPath)
throws RepositoryException,
+ SQLException, IOException
+ {
+ String cid = item.getString(COLUMN_ID);
+ String cname = item.getString(COLUMN_NAME);
+ int cversion = item.getInt(COLUMN_VERSION);
+
+ String cpid = item.getString(COLUMN_PARENTID);
+ // if parent ID is empty string - it's a root node
+ // cpid = cpid.equals(Constants.ROOT_PARENT_UUID) ? null : cpid;
+
+ try
+ {
+ int cptype = item.getInt(COLUMN_PTYPE);
+ boolean cpmultivalued = item.getBoolean(COLUMN_PMULTIVALUED);
+ try
+ {
+ QPath qpath =
+ QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) : parentPath,
InternalQName.parse(cname));
+
+ List<ValueData> data = new ArrayList<ValueData>();
+
+ String identifier = getIdentifier(cid);
+
+ do
+ {
+ final int orderNum = item.getInt(COLUMN_VORDERNUM);
+ final String storageId = item.getString(COLUMN_VSTORAGE_DESC);
+ ValueData vdata =
+ item.wasNull() ? readValueData(cid, orderNum, cversion,
item.getBinaryStream(COLUMN_VDATA))
+ : readValueData(identifier, orderNum, storageId);
+ data.add(vdata);
+ }
+ while (item.next() && item.getString(COLUMN_ID) == cid);
+
+ PersistedPropertyData pdata =
+ new PersistedPropertyData(identifier, qpath, getIdentifier(cpid),
cversion, cptype, cpmultivalued, data);
+
+ return pdata;
+ }
+ catch (IllegalNameException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+ catch (InvalidItemStateException e)
+ {
+ throw new InvalidItemStateException("FATAL: Can't build item path for
name " + cname + " id: "
+ + getIdentifier(cid) + ". " + e);
+ }
+ }
+
+ /**
+ * Delete Property Values.
+ *
+ * @param cid
+ * Property id
+ * @param pdata
+ * PropertyData
+ * @param update
+ * boolean true if it's delete-add sequence (update operation)
+ * @throws IOException
+ * i/O error
+ * @throws SQLException
+ * if database error occurs
+ * @throws ValueStorageNotFoundException
+ * if no such storage found with Value storageId
+ */
+ private void deleteValues(String cid, PropertyData pdata, boolean update) throws
IOException, SQLException,
+ ValueStorageNotFoundException
+ {
+
+ final ResultSet valueRecords = findValuesStorageDescriptorsByPropertyId(cid);
+ try
+ {
+ if (valueRecords.next())
+ {
+ // delete all Values in database
+ deleteValueData(cid);
+
+ do
+ {
+ final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
+ if (!valueRecords.wasNull())
+ {
+ final ValueIOChannel channel =
valueStorageProvider.getChannel(storageId);
+ try
+ {
+ channel.delete(pdata.getIdentifier());
+ valueChanges.add(channel);
+ }
+ finally
+ {
+ channel.close();
+ }
+ }
+ }
+ while (valueRecords.next());
+ }
+ }
+ finally
+ {
+ valueRecords.close();
+ }
+ }
+
+ /**
+ * Read Property Values.
+ *
+ * @param identifier
+ * property identifier
+ * @param cid
+ * Property id
+ * @param pdata
+ * PropertyData
+ * @return list of ValueData
+ * @throws IOException
+ * i/O error
+ * @throws SQLException
+ * if database errro occurs
+ * @throws ValueStorageNotFoundException
+ * if no such storage found with Value storageId
+ */
+ private List<ValueData> readValues(String cid, String identifier, int cversion)
throws IOException, SQLException,
+ ValueStorageNotFoundException
+ {
+
+ List<ValueData> data = new ArrayList<ValueData>();
+
+ final ResultSet valueRecords = findValuesByPropertyId(cid);
+ try
+ {
+ while (valueRecords.next())
+ {
+ final int orderNum = valueRecords.getInt(COLUMN_VORDERNUM);
+ final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
+ ValueData vdata =
+ valueRecords.wasNull() ? readValueData(cid, orderNum, cversion,
valueRecords
+ .getBinaryStream(COLUMN_VDATA)) : readValueData(identifier, orderNum,
storageId);
+ data.add(vdata);
+ }
+ }
+ finally
+ {
+ valueRecords.close();
+ }
+
+ return data;
+ }
+
+ /**
+ * Read ValueData from External Storage.
+ *
+ * @param pdata
+ * PropertyData
+ * @param orderNumber
+ * Value order number
+ * @param storageId
+ * external Value storage id
+ * @return ValueData
+ * @throws SQLException
+ * database error
+ * @throws IOException
+ * I/O error
+ * @throws ValueStorageNotFoundException
+ * if no such storage found with Value storageId
+ */
+ protected ValueData readValueData(String identifier, int orderNumber, String
storageId) throws SQLException,
+ IOException, ValueStorageNotFoundException
+ {
+ ValueIOChannel channel = valueStorageProvider.getChannel(storageId);
+ try
+ {
+ return channel.read(identifier, orderNumber, maxBufferSize);
+ }
+ finally
+ {
+ channel.close();
+ }
+ }
+
+ /**
+ * Read ValueData from database.
+ *
+ * @param cid
+ * Property id
+ * @param orderNumber
+ * Value order number
+ * @param version
+ * persistent version (used for BLOB swapping)
+ * @param content
+ * @return ValueData
+ * @throws SQLException
+ * database error
+ * @throws IOException
+ * I/O error (swap)
+ */
+ protected ValueData readValueData(String cid, int orderNumber, int version, final
InputStream content)
+ throws SQLException, IOException
+ {
+
+ ResultSet valueResultSet = null;
+
+ byte[] buffer = new byte[0];
+ byte[] spoolBuffer = new byte[ValueFileIOHelper.IOBUFFER_SIZE];
+ int read;
+ int len = 0;
+ OutputStream out = null;
+
+ SwapFile swapFile = null;
+ try
+ {
+ // stream from database
+ if (content != null)
+ while ((read = content.read(spoolBuffer)) >= 0)
+ {
+ if (out != null)
+ {
+ // spool to temp file
+ out.write(spoolBuffer, 0, read);
+ len += read;
+ }
+ else if (len + read > maxBufferSize)
+ {
+ // threshold for keeping data in memory exceeded;
+ // create temp file and spool buffer contents
+ swapFile = SwapFile.get(swapDirectory, cid + orderNumber +
"." + version);
+ if (swapFile.isSpooled())
+ {
+ // break, value already spooled
+ buffer = null;
+ break;
+ }
+ out = new FileOutputStream(swapFile);
+ out.write(buffer, 0, len);
+ out.write(spoolBuffer, 0, read);
+ buffer = null;
+ len += read;
+ }
+ else
+ {
+ // reallocate new buffer and spool old buffer contents
+ byte[] newBuffer = new byte[len + read];
+ System.arraycopy(buffer, 0, newBuffer, 0, len);
+ System.arraycopy(spoolBuffer, 0, newBuffer, len, read);
+ buffer = newBuffer;
+ len += read;
+ }
+ }
+ }
+ finally
+ {
+ if (valueResultSet != null)
+ valueResultSet.close();
+ if (out != null)
+ {
+ out.close();
+ swapFile.spoolDone();
+ }
+ }
+
+ if (buffer == null)
+ return new CleanableFilePersistedValueData(orderNumber, swapFile, swapCleaner);
+
+ return new ByteArrayPersistedValueData(orderNumber, buffer);
+ }
+
+ /**
+ * Writes value data to swap file.
+ *
+ * @param cid
+ * Property id
+ * @param orderNumber
+ * Value order number
+ * @param version
+ * persistent version (used for BLOB swapping)
+ * @param content
+ * @return ValueData
+ * @throws SQLException
+ * database error
+ * @throws IOException
+ * I/O error (swap)
+ */
+ protected SwapFile swapValueData(String cid, int orderNumber, int version, final
InputStream content)
+ throws SQLException, IOException
+ {
+
+ byte[] spoolBuffer = new byte[ValueFileIOHelper.IOBUFFER_SIZE];
+ int read;
+ int len = 0;
+
+ SwapFile swapFile = SwapFile.get(swapDirectory, cid + orderNumber + "." +
version);
+ OutputStream out = new FileOutputStream(swapFile);;
+
+ if (swapFile.isSpooled())
+ {
+ return swapFile;
+ }
+
+ try
+ {
+ if (content != null)
+ while ((read = content.read(spoolBuffer)) >= 0)
+ {
+ // spool to temp file
+ out.write(spoolBuffer, 0, read);
+ len += read;
+ }
+ }
+ finally
+ {
+ out.close();
+ swapFile.spoolDone();
+ }
+
+ return swapFile;
+ }
+
+ /**
+ * Add Values to Property record.
+ *
+ * @param data
+ * PropertyData
+ * @throws SQLException
+ * database error
+ * @throws IOException
+ * I/O error
+ * @thorws RepositoryException if Value data large of JDBC accepted
(Integer.MAX_VALUE)
+ */
+ protected void addValues(String cid, PropertyData data) throws IOException,
SQLException, RepositoryException
+ {
+ List<ValueData> vdata = data.getValues();
+
+ for (int i = 0; i < vdata.size(); i++)
+ {
+ ValueData vd = vdata.get(i);
+ ValueIOChannel channel = valueStorageProvider.getApplicableChannel(data, i);
+ InputStream stream;
+ int streamLength;
+ String storageId;
+ if (channel == null)
+ {
+ // prepare write of Value in database
+ if (vd.isByteArray())
+ {
+ byte[] dataBytes = vd.getAsByteArray();
+ stream = new ByteArrayInputStream(dataBytes);
+ streamLength = dataBytes.length;
+ }
+ else
+ {
+ // it's StreamPersistedValueData
+ StreamPersistedValueData streamData = (StreamPersistedValueData)vd;
+ stream = streamData.getStream();
+
+ // TODO spool on JDBC driver read - multiplexing the data to two stores,
database and spool file, with one read.
+ SwapFile swapFile = swapValueData(cid, i, data.getPersistedVersion(),
stream);
+
+ long vlen = swapFile.length();
+ if (vlen < 0)
+ {
+ // TODO not actual with SwapFile, but if it will be reworked can be so
+ streamLength = stream.available();
+ LOG.warn("Cannot obtain exact Value data length, will use
available from the stream " + streamLength
+ + ". Property " + data.getQPath().getAsString());
+ }
+ else if (vlen <= Integer.MAX_VALUE)
+ {
+ streamLength = (int)vlen;
+ }
+ else
+ {
+ throw new RepositoryException("Value data large of allowed by JDBC
(Integer.MAX_VALUE) " + vlen
+ + ". Property " + data.getQPath().getAsString());
+ }
+
+ // set persistent file to ValueData, will be available for saving
Property.
+ streamData.setPersistedFile(swapFile);
+ stream = streamData.getAsStream();
+ }
+ storageId = null;
+ }
+ else
+ {
+ // write Value in external VS
+ channel.write(data.getIdentifier(), vd);
+ valueChanges.add(channel);
+ storageId = channel.getStorageId();
+ stream = null;
+ streamLength = 0;
+ }
+ addValueData(cid, i, stream, streamLength, storageId);
+ }
+ }
+
+ protected abstract int addNodeRecord(NodeData data) throws SQLException;
+
+ protected abstract int addPropertyRecord(PropertyData prop) throws SQLException;
+
+ protected abstract ResultSet findItemByIdentifier(String identifier) throws
SQLException;
+
+ protected abstract ResultSet findPropertyByName(String parentId, String name) throws
SQLException;
+
+ protected abstract ResultSet findItemByName(String parentId, String name, int index)
throws SQLException;
+
+ protected abstract ResultSet findChildNodesByParentIdentifier(String parentIdentifier)
throws SQLException;
+
+ protected abstract ResultSet findChildNodesCountByParentIdentifier(String
parentIdentifier) throws SQLException;
+
+ protected abstract ResultSet findChildPropertiesByParentIdentifier(String
parentIdentifier) throws SQLException;
+
+ protected abstract int addReference(PropertyData data) throws SQLException,
IOException;
+
+ protected abstract int renameNode(NodeData data) throws SQLException;
+
+ protected abstract int deleteReference(String propertyIdentifier) throws
SQLException;
+
+ protected abstract ResultSet findReferences(String nodeIdentifier) throws
SQLException;
+
+ protected abstract int deleteItemByIdentifier(String identifier) throws SQLException;
+
+ protected abstract int updateNodeByIdentifier(int version, int index, int orderNumb,
String identifier)
+ throws SQLException;
+
+ protected abstract int updatePropertyByIdentifier(int version, int type, String
identifier) throws SQLException;
+
+ // -------- values processing ------------
+ protected abstract int addValueData(String cid, int orderNumber, InputStream stream,
int streamLength,
+ String storageId) throws SQLException;
+
+ protected abstract int deleteValueData(String cid) throws SQLException;
+
+ protected abstract ResultSet findValuesByPropertyId(String cid) throws SQLException;
+
+ protected abstract ResultSet findValuesStorageDescriptorsByPropertyId(String cid)
throws SQLException;
+
+ @Deprecated
+ protected abstract ResultSet findValueByPropertyIdOrderNumber(String cid, int
orderNumb) throws SQLException;
+
+ protected abstract ResultSet findItemByIdentifierNew(String identifier) throws
SQLException;
+
+ protected abstract ResultSet findItemByNameNew(String parentId, String name, int
index) throws SQLException;
+
+ protected abstract ResultSet findChildNodesByParentIdentifierNew(String
parentIdentifier) throws SQLException;
+
+ protected abstract ResultSet getChildPropertiesByParentIdentifier(String
parentIdentifier) throws SQLException;
+
+ protected abstract ResultSet findReferenceProperties(String parentIdentifier) throws
SQLException;
+}
Added:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
(rev 0)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2009-12-25
15:55:34 UTC (rev 1194)
@@ -0,0 +1,802 @@
+/*
+ * 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.storage.jdbc.optimisation;
+
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.impl.storage.WorkspaceDataContainerBase;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.db.GenericConnectionFactory;
+import org.exoplatform.services.jcr.impl.storage.jdbc.db.OracleConnectionFactory;
+import
org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
+import org.exoplatform.services.jcr.impl.storage.jdbc.init.DBInitializer;
+import org.exoplatform.services.jcr.impl.storage.jdbc.init.DBInitializerException;
+import org.exoplatform.services.jcr.impl.storage.jdbc.init.IngresSQLDBInitializer;
+import org.exoplatform.services.jcr.impl.storage.jdbc.init.OracleDBInitializer;
+import org.exoplatform.services.jcr.impl.storage.jdbc.init.PgSQLDBInitializer;
+import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.HSQLDBConnectionFactory;
+import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.MySQLConnectionFactory;
+import org.exoplatform.services.jcr.impl.storage.jdbc.update.StorageUpdateManager;
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.naming.InitialContextInitializer;
+import org.picocontainer.Startable;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.Connection;
+
+import javax.jcr.RepositoryException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
+ * @version $Id:GenericWorkspaceDataContainer.java 13433 2007-03-15 16:07:23Z peterit $
+ */
+public class CQJDBCWorkspaceDataContainer extends WorkspaceDataContainerBase implements
Startable
+{
+
+ protected static final Log LOG =
ExoLogger.getLogger("jcr.JDBCWorkspaceDataContainer");
+
+ //configuration params
+
+ public final static String SOURCE_NAME = "source-name";
+
+ public final static String MULTIDB = "multi-db";
+
+ public final static String SINGLEDB = "single-db";
+
+ /**
+ * Describe which type of RDBMS will be used (DB creation metadata etc.)
+ */
+ public final static String DB_DIALECT = "dialect";
+
+ public final static String DB_DRIVER = "driverClassName";
+
+ public final static String DB_URL = "url";
+
+ public final static String DB_USERNAME = "username";
+
+ public final static String DB_PASSWORD = "password";
+
+ protected final String containerName;
+
+ protected final String dbSourceName;
+
+ protected final boolean multiDb;
+
+ protected final String dbDriver;
+
+ protected final String dbDialect;
+
+ protected final String dbUrl;
+
+ protected final String dbUserName;
+
+ protected final String dbPassword;
+
+ protected final ValueStoragePluginProvider valueStorageProvider;
+
+ protected String storageVersion;
+
+ protected int maxBufferSize;
+
+ protected File swapDirectory;
+
+ protected FileCleaner swapCleaner;
+
+ protected GenericConnectionFactory connFactory;
+
+ /**
+ * Shared connection factory.
+ *
+ * Issued to share JDBC connection between system and regular workspace in case of
same database
+ * used for storage.
+ *
+ */
+ class SharedConnectionFactory extends GenericConnectionFactory
+ {
+
+ /**
+ * JDBC connection.
+ */
+ final private Connection connection;
+
+ /**
+ * SharedConnectionFactory constructor.
+ *
+ * @param connection
+ * JDBC - connection
+ * @param containerName
+ * - container name
+ * @param multiDb
+ * - multidatabase status
+ * @param valueStorageProvider
+ * - external Value Storages provider
+ * @param maxBufferSize
+ * - Maximum buffer size (see configuration)
+ * @param swapDirectory
+ * - Swap directory (see configuration)
+ * @param swapCleaner
+ * - Swap cleaner (internal FileCleaner).
+ */
+ SharedConnectionFactory(Connection connection, String containerName, boolean
multiDb,
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
+ {
+
+ super(null, null, null, null, null, containerName, multiDb,
valueStorageProvider, maxBufferSize,
+ swapDirectory, swapCleaner);
+
+ this.connection = connection;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Connection getJdbcConnection() throws RepositoryException
+ {
+ return connection;
+ }
+ }
+
+ /**
+ * Constructor with value storage plugins.
+ *
+ * @param wsConfig
+ * Workspace configuration
+ * @param valueStrorageProvider
+ * External Value Stprages provider
+ * @throws RepositoryConfigurationException
+ * if Repository configuration is wrong
+ * @throws NamingException
+ * if JNDI exception (on DataSource lookup)
+ */
+ public CQJDBCWorkspaceDataContainer(WorkspaceEntry wsConfig, RepositoryEntry
repConfig,
+ InitialContextInitializer contextInit, ValueStoragePluginProvider
valueStorageProvider)
+ throws RepositoryConfigurationException, NamingException, RepositoryException,
IOException
+ {
+
+ checkIntegrity(wsConfig, repConfig);
+
+ this.containerName = wsConfig.getName();
+ this.multiDb =
Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
+ this.valueStorageProvider = valueStorageProvider;
+
+ // ------------- Database config ------------------
+ String pDbDialect = null;
+ try
+ {
+ pDbDialect =
detectDialect(wsConfig.getContainer().getParameterValue(DB_DIALECT));
+ LOG.info("Using a dialect '" + pDbDialect + "'");
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ LOG.info("Using a default dialect '" +
DBConstants.DB_DIALECT_GENERIC + "'");
+ pDbDialect = DBConstants.DB_DIALECT_GENERIC;
+ }
+ this.dbDialect = pDbDialect;
+
+ String pDbDriver = null;
+ String pDbUrl = null;
+ String pDbUserName = null;
+ String pDbPassword = null;
+ try
+ {
+ pDbDriver = wsConfig.getContainer().getParameterValue(DB_DRIVER);
+
+ // username/passwd may not pesent
+ try
+ {
+ pDbUserName = wsConfig.getContainer().getParameterValue(DB_USERNAME);
+ pDbPassword = wsConfig.getContainer().getParameterValue(DB_PASSWORD);
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ pDbUserName = pDbPassword = null;
+ }
+
+ pDbUrl = wsConfig.getContainer().getParameterValue(DB_URL); // last here!
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ }
+
+ if (pDbUrl != null)
+ {
+ this.dbDriver = pDbDriver;
+ this.dbUrl = pDbUrl;
+ this.dbUserName = pDbUserName;
+ this.dbPassword = pDbPassword;
+ this.dbSourceName = null;
+ LOG.info("Connect to JCR database as user '" + this.dbUserName +
"'");
+ }
+ else
+ {
+ this.dbDriver = null;
+ this.dbUrl = null;
+ this.dbUserName = null;
+ this.dbPassword = null;
+
+ String sn;
+ try
+ {
+ sn = wsConfig.getContainer().getParameterValue(SOURCE_NAME);
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ sn = wsConfig.getContainer().getParameterValue("sourceName"); //
TODO for backward comp,
+ // remove in rel.2.0
+ }
+ this.dbSourceName = sn;
+ }
+
+ // ------------- Values swap config ------------------
+ try
+ {
+ this.maxBufferSize =
wsConfig.getContainer().getParameterInteger(MAXBUFFERSIZE_PROP);
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ this.maxBufferSize = DEF_MAXBUFFERSIZE;
+ }
+
+ try
+ {
+ String sdParam = wsConfig.getContainer().getParameterValue(SWAPDIR_PROP);
+ this.swapDirectory = new File(sdParam);
+ }
+ catch (RepositoryConfigurationException e1)
+ {
+ this.swapDirectory = new File(DEF_SWAPDIR);
+ }
+ if (!swapDirectory.exists())
+ swapDirectory.mkdirs();
+
+ this.swapCleaner = new FileCleaner(false);
+
+ initDatabase();
+
+ String suParam = null;
+ boolean enableStorageUpdate = false;
+ try
+ {
+ suParam =
wsConfig.getContainer().getParameterValue("update-storage");
+ enableStorageUpdate = Boolean.parseBoolean(suParam);
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("update-storage parameter is not set " + dbSourceName);
+ }
+
+ this.storageVersion =
+ StorageUpdateManager.checkVersion(dbSourceName,
this.connFactory.getJdbcConnection(), multiDb,
+ enableStorageUpdate);
+
+ LOG.info(getInfo());
+ }
+
+ /**
+ * Prepare sefault connection factory.
+ *
+ * @return GenericConnectionFactory
+ * @throws NamingException
+ * on JNDI error
+ * @throws RepositoryException
+ * on Storage error
+ */
+ protected GenericConnectionFactory defaultConnectionFactory() throws NamingException,
RepositoryException
+ {
+ // by default
+ if (dbSourceName != null)
+ {
+ DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
+ if (ds != null)
+ return new GenericConnectionFactory(ds, containerName, multiDb,
valueStorageProvider, maxBufferSize,
+ swapDirectory, swapCleaner);
+
+ throw new RepositoryException("Datasource '" + dbSourceName +
"' is not bound in this context.");
+ }
+
+ return new GenericConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ }
+
+ /**
+ * Prepare default DB initializer.
+ *
+ * @param sqlPath
+ * - path to SQL script (database creation script)
+ * @return DBInitializer instance
+ * @throws NamingException
+ * on JNDI error
+ * @throws RepositoryException
+ * on Storage error
+ * @throws IOException
+ * on I/O error
+ */
+ protected DBInitializer defaultDBInitializer(String sqlPath) throws NamingException,
RepositoryException,
+ IOException
+ {
+ return new DBInitializer(containerName, this.connFactory.getJdbcConnection(),
sqlPath, multiDb);
+ }
+
+ /**
+ * Checks if DataSources used in right manner.
+ *
+ * @param wsConfig
+ * Workspace configuration
+ * @param repConfig
+ * Repository configuration
+ * @throws RepositoryConfigurationException
+ * in case of configuration errors
+ */
+ protected void checkIntegrity(WorkspaceEntry wsConfig, RepositoryEntry repConfig)
+ throws RepositoryConfigurationException
+ {
+ boolean isMulti;
+ for (WorkspaceEntry wsEntry : repConfig.getWorkspaceEntries())
+ {
+ if (wsEntry.getName().equals(wsConfig.getName())
+ ||
!wsEntry.getContainer().getType().equals(wsConfig.getContainer().getType())
+ || !wsEntry.getContainer().getType().equals(this.getClass().getName()))
+ continue;
+
+ // MULTIDB
+ if (!wsEntry.getContainer().getParameterValue(MULTIDB).equals(
+ wsConfig.getContainer().getParameterValue(MULTIDB)))
+ {
+ throw new RepositoryConfigurationException("All workspaces must be
" + MULTIDB + " or " + SINGLEDB
+ + ". But " + wsEntry.getName() + "- multi-db=" +
wsEntry.getContainer().getParameterValue(MULTIDB)
+ + " and " + wsConfig.getName() + "- multi-db=" +
wsConfig.getContainer().getParameterValue(MULTIDB));
+ }
+
+ isMulti =
Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
+
+ // source name
+ String wsSourceName = null;
+ String newWsSourceName = null;
+ try
+ {
+ wsSourceName =
wsEntry.getContainer().getParameterValue("sourceName");
+ newWsSourceName =
wsConfig.getContainer().getParameterValue("sourceName");
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ }
+
+ if (wsSourceName != null && newWsSourceName != null)
+ {
+ if (isMulti)
+ {
+ if (wsSourceName.equals(newWsSourceName))
+ {
+ throw new RepositoryConfigurationException("SourceName " +
wsSourceName + " alredy in use in "
+ + wsEntry.getName() + ". SourceName must be different in "
+ MULTIDB
+ + ". Check configuration for " + wsConfig.getName());
+ }
+ }
+ else
+ {
+ if (!wsSourceName.equals(newWsSourceName))
+ {
+ throw new RepositoryConfigurationException("SourceName must be
equals in " + SINGLEDB + " "
+ + "repository." + " Check " + wsEntry.getName()
+ " and " + wsConfig.getName());
+ }
+ }
+ continue;
+ }
+
+ // db-url
+ String wsUri = null;
+ String newWsUri = null;
+ try
+ {
+ wsUri = wsEntry.getContainer().getParameterValue("db-url");
+ newWsUri = wsConfig.getContainer().getParameterValue("db-url");
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ }
+
+ if (wsUri != null && newWsUri != null)
+ {
+ if (isMulti)
+ {
+ if (wsUri.equals(newWsUri))
+ {
+ throw new RepositoryConfigurationException("db-url " + wsUri
+ " alredy in use in "
+ + wsEntry.getName() + ". db-url must be different in " +
MULTIDB + ". Check configuration for "
+ + wsConfig.getName());
+
+ }
+ }
+ else
+ {
+ if (!wsUri.equals(newWsUri))
+ {
+ throw new RepositoryConfigurationException("db-url must be equals
in " + SINGLEDB + " "
+ + "repository." + " Check " + wsEntry.getName()
+ " and " + wsConfig.getName());
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Init storage database.
+ *
+ * @throws NamingException
+ * on JNDI error
+ * @throws RepositoryException
+ * on storage error
+ * @throws IOException
+ * on I/O error
+ */
+ protected void initDatabase() throws NamingException, RepositoryException,
IOException
+ {
+
+ DBInitializer dbInitilizer = null;
+ String sqlPath = null;
+ if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
+ {
+ LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is
experimental!");
+ // sample of connection factory customization
+ if (dbSourceName != null)
+ this.connFactory = defaultConnectionFactory();
+ else
+ this.connFactory =
+ new OracleConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ora.sql";
+
+ // a particular db initializer may be configured here too
+ dbInitilizer = new OracleDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_ORACLE)
+ {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ora.sql";
+ dbInitilizer = new OracleDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_PGSQL)
+ {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.pgsql.sql";
+ dbInitilizer = new PgSQLDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_MYSQL)
+ {
+ // [PN] 28.06.07
+ if (dbSourceName != null)
+ {
+ DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
+ if (ds != null)
+ this.connFactory =
+ new MySQLConnectionFactory(ds, containerName, multiDb,
valueStorageProvider, maxBufferSize,
+ swapDirectory, swapCleaner);
+ else
+ throw new RepositoryException("Datasource '" + dbSourceName
+ "' is not bound in this context.");
+ }
+ else
+ this.connFactory =
+ new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mysql.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8)
+ {
+ // [PN] 13.07.08
+ if (dbSourceName != null)
+ {
+ DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
+ if (ds != null)
+ this.connFactory =
+ new MySQLConnectionFactory(ds, containerName, multiDb,
valueStorageProvider, maxBufferSize,
+ swapDirectory, swapCleaner);
+ else
+ throw new RepositoryException("Datasource '" + dbSourceName
+ "' is not bound in this context.");
+ }
+ else
+ this.connFactory =
+ new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mysql-utf8.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_MSSQL)
+ {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mssql.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_DERBY)
+ {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.derby.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_DB2)
+ {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.db2.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_DB2V8)
+ {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.db2v8.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_SYBASE)
+ {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.sybase.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_INGRES)
+ {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ingres.sql";
+ // using Postgres initializer
+ dbInitilizer =
+ new IngresSQLDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_HSQLDB)
+ {
+ if (dbSourceName != null)
+ {
+ DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
+ if (ds != null)
+ this.connFactory =
+ new HSQLDBConnectionFactory(ds, containerName, multiDb,
valueStorageProvider, maxBufferSize,
+ swapDirectory, swapCleaner);
+ else
+ throw new RepositoryException("Datasource '" + dbSourceName
+ "' is not bound in this context.");
+ }
+ else
+ this.connFactory =
+ new HSQLDBConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
+ valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ }
+ else
+ {
+ // generic, DB_HSQLDB
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ }
+
+ // database type
+ try
+ {
+ dbInitilizer.init();
+ }
+ catch (DBInitializerException e)
+ {
+ LOG.error("Error of init db " + e, e);
+ }
+ }
+
+ /**
+ * Return ConnectionFactory.
+ *
+ * @return WorkspaceStorageConnectionFactory connection
+ */
+ protected GenericConnectionFactory getConnectionFactory()
+ {
+ return connFactory;
+ }
+
+ protected String detectDialect(String confParam)
+ {
+ for (String dbType : DBConstants.DB_DIALECTS)
+ {
+ if (dbType.equalsIgnoreCase(confParam))
+ return dbType;
+ }
+
+ return DBConstants.DB_DIALECT_GENERIC; // by default
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WorkspaceStorageConnection openConnection() throws RepositoryException
+ {
+
+ return connFactory.openConnection();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WorkspaceStorageConnection openConnection(boolean readOnly) throws
RepositoryException
+ {
+
+ return connFactory.openConnection(readOnly);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original)
throws RepositoryException
+ {
+
+ if (original instanceof CQJDBCStorageConnection)
+ {
+ WorkspaceStorageConnectionFactory cFactory =
+ new
SharedConnectionFactory(((CQJDBCStorageConnection)original).getJdbcConnection(),
containerName,
+ multiDb, valueStorageProvider, maxBufferSize, swapDirectory,
swapCleaner);
+
+ return cFactory.openConnection();
+ }
+ else
+ {
+ return openConnection();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName()
+ {
+ return containerName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getInfo()
+ {
+ String str =
+ "JDBC based JCR Workspace Data container \n" + "container name:
" + containerName + " \n"
+ + "data source JNDI name: " + dbSourceName + "\n" +
"is multi database: " + multiDb + "\n"
+ + "storage version: " + storageVersion + "\n" +
"value storage provider: " + valueStorageProvider + "\n"
+ + "max buffer size (bytes): " + maxBufferSize + "\n" +
"swap directory path: "
+ + swapDirectory.getAbsolutePath();
+ return str;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getStorageVersion()
+ {
+ return storageVersion;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void start()
+ {
+ this.swapCleaner.start();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void stop()
+ {
+ this.swapCleaner.halt();
+ this.swapCleaner.interrupt();
+
+ // TODO HSQLDB Stop (debug)
+ // if (dbDialect.equals(DB_DIALECT_GENERIC) ||
+ // dbDialect.equals(DB_DIALECT_HSQLDB)) {
+ // // shutdown in-process HSQLDB database
+ // System.out.println("Shutdown in-process HSQLDB database...");
+ // try {
+ // JDBCStorageConnection conn = (JDBCStorageConnection) openConnection();
+ // Connection jdbcConn = conn.getJdbcConnection();
+ // String dbUrl = jdbcConn.getMetaData().getURL();
+ // if (dbUrl.startsWith("jdbc:hsqldb:file") ||
+ // dbUrl.startsWith("jdbc:hsqldb:mem")) {
+ // // yeah, there is in-process hsqldb, shutdown it now
+ // jdbcConn.createStatement().execute("SHUTDOWN");
+ // System.out.println("Shutdown in-process HSQLDB database... done.");
+ // }
+ // } catch (Throwable e) {
+ // log.error("JDBC Data container stop error " + e);
+ // e.printStackTrace();
+ // }
+ // }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSame(WorkspaceDataContainer another)
+ {
+ if (another == this)
+ return true;
+
+ if (another instanceof CQJDBCWorkspaceDataContainer)
+ {
+ CQJDBCWorkspaceDataContainer anotherJdbc =
(CQJDBCWorkspaceDataContainer)another;
+
+ if (getDbSourceName() != null)
+ // by jndi ds name
+ return getDbSourceName().equals(anotherJdbc.getDbSourceName());
+
+ // by db connection params
+ return getDbDriver().equals(anotherJdbc.getDbDriver()) &&
getDbUrl().equals(anotherJdbc.getDbUrl())
+ && getDbUserName().equals(anotherJdbc.getDbUserName());
+ }
+
+ return false;
+ }
+
+ /**
+ * Used in <code>equals()</code>.
+ *
+ * @return DataSource name
+ */
+ protected String getDbSourceName()
+ {
+ return dbSourceName;
+ }
+
+ /**
+ * Used in <code>equals()</code>.
+ *
+ * @return JDBC driver
+ */
+ protected String getDbDriver()
+ {
+ return dbDriver;
+ }
+
+ /**
+ * Used in <code>equals()</code>.
+ *
+ * @return Database URL
+ */
+ protected String getDbUrl()
+ {
+ return dbUrl;
+ }
+
+ /**
+ * Used in <code>equals()</code>.
+ *
+ * @return Database username
+ */
+ protected String getDbUserName()
+ {
+ return dbUserName;
+ }
+}
Deleted:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCStorageConnection.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCStorageConnection.java 2009-12-25
15:51:39 UTC (rev 1193)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCStorageConnection.java 2009-12-25
15:55:34 UTC (rev 1194)
@@ -1,2532 +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.storage.jdbc.optimisation;
-
-import org.exoplatform.services.jcr.access.AccessControlEntry;
-import org.exoplatform.services.jcr.access.AccessControlList;
-import org.exoplatform.services.jcr.dataflow.ItemState;
-import org.exoplatform.services.jcr.dataflow.persistent.PersistedNodeData;
-import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
-import org.exoplatform.services.jcr.datamodel.IllegalACLException;
-import org.exoplatform.services.jcr.datamodel.IllegalNameException;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.datamodel.ValueData;
-import org.exoplatform.services.jcr.impl.Constants;
-import
org.exoplatform.services.jcr.impl.dataflow.persistent.ByteArrayPersistedValueData;
-import
org.exoplatform.services.jcr.impl.dataflow.persistent.CleanableFilePersistedValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData;
-import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.storage.jdbc.PrimaryTypeNotFoundException;
-import org.exoplatform.services.jcr.impl.storage.value.ValueStorageNotFoundException;
-import org.exoplatform.services.jcr.impl.storage.value.fs.operations.ValueFileIOHelper;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.impl.util.io.SwapFile;
-import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.jcr.storage.value.ValueIOChannel;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady
Azarenkov</a>
- * @version $Id: JDBCStorageConnection.java 34801 2009-07-31 15:44:50Z dkatayev $
- */
-abstract public class NewJDBCStorageConnection extends DBConstants implements
WorkspaceStorageConnection
-{
-
- /**
- * Connection logger.
- */
- protected static final Log LOG =
ExoLogger.getLogger("jcr.JDBCStorageConnection");
-
- /**
- * NODE type.
- */
- public static final int I_CLASS_NODE = 1;
-
- /**
- * PROPERTY type.
- */
- public static final int I_CLASS_PROPERTY = 2;
-
- protected final ValueStoragePluginProvider valueStorageProvider;
-
- protected final int maxBufferSize;
-
- protected final File swapDirectory;
-
- protected final FileCleaner swapCleaner;
-
- protected final Connection dbConnection;
-
- protected final String containerName;
-
- protected final NewSQLExceptionHandler exceptionHandler;
-
- protected final List<ValueIOChannel> valueChanges;
-
- /**
- * Read-only flag, if true the connection is marked as READ-ONLY.
- */
- protected final boolean readOnly;
-
- /**
- * JDBCStorageConnection constructor.
- *
- * @param dbConnection
- * JDBC connection
- * @param containerName
- * Workspace conatiner name
- * @param valueStorageProvider
- * External Value Storage provider
- * @param maxBufferSize
- * maximum buffer size (config)
- * @param swapDirectory
- * swap directory (config)
- * @param swapCleaner
- * swap cleaner (FileCleaner)
- * @throws SQLException
- * database error
- */
- protected NewJDBCStorageConnection(Connection dbConnection, boolean readOnly, String
containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
- throws SQLException
- {
-
- this.valueStorageProvider = valueStorageProvider;
-
- this.maxBufferSize = maxBufferSize;
- this.swapDirectory = swapDirectory;
- this.swapCleaner = swapCleaner;
- this.containerName = containerName;
-
- this.dbConnection = dbConnection;
- this.readOnly = readOnly;
-
- // Fix for Sybase jConnect JDBC driver bug.
- // Which throws SQLException(JZ016: The AutoCommit option is already set to
- // false)
- // if conn.setAutoCommit(false) called twise or more times with value
- // 'false'.
- if (dbConnection.getAutoCommit())
- {
- dbConnection.setAutoCommit(false);
- }
-
- prepareQueries();
- this.exceptionHandler = new NewSQLExceptionHandler(containerName, this);
-
- this.valueChanges = new ArrayList<ValueIOChannel>();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- return true;
-
- if (obj instanceof JDBCStorageConnection)
- {
- JDBCStorageConnection another = (JDBCStorageConnection)obj;
- return getJdbcConnection() == another.getJdbcConnection();
- }
-
- return false;
- }
-
- /**
- * Return JDBC connection obtained from initialized data source. NOTE: Helper can
obtain one new
- * connection per each call of the method or return one obtained once.
- */
- public Connection getJdbcConnection()
- {
- return dbConnection;
- }
-
- /**
- * Prepared queries at start time.
- *
- * @throws SQLException
- * database error
- */
- abstract protected void prepareQueries() throws SQLException;
-
- /**
- * Used in Single Db Connection classes for Identifier related queries.
- *
- * @param identifier
- * Item id
- * @return String with container internal id
- */
- protected abstract String getInternalId(String identifier);
-
- /**
- * Used in loadXYZRecord methods for extract real Identifier from container value.
- *
- * @param internalId
- * @return
- */
- protected abstract String getIdentifier(String internalId);
-
- // ---------------- WorkspaceStorageConnection -------------
-
- /**
- * @throws IllegalStateException
- * if connection is closed.
- */
- protected void checkIfOpened() throws IllegalStateException
- {
- if (!isOpened())
- throw new IllegalStateException("Connection is closed");
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isOpened()
- {
- try
- {
- return !dbConnection.isClosed();
- }
- catch (SQLException e)
- {
- LOG.error(e);
- return false;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public final void rollback() throws IllegalStateException, RepositoryException
- {
- checkIfOpened();
- try
- {
- dbConnection.rollback();
- dbConnection.close();
-
- // rollback from the end
- for (int p = valueChanges.size() - 1; p >= 0; p--)
- valueChanges.get(p).rollback();
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- valueChanges.clear();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public final void close() throws IllegalStateException, RepositoryException
- {
- checkIfOpened();
- try
- {
- // If READ-ONLY status back it to READ-WRITE (we assume it was original state)
- if (readOnly)
- dbConnection.setReadOnly(true);
-
- dbConnection.close();
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public final void commit() throws IllegalStateException, RepositoryException
- {
- checkIfOpened();
- try
- {
- dbConnection.commit();
- dbConnection.close();
-
- try
- {
- for (ValueIOChannel vo : valueChanges)
- vo.commit();
-
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- valueChanges.clear();
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void add(NodeData data) throws RepositoryException,
UnsupportedOperationException, InvalidItemStateException,
- IllegalStateException
- {
- checkIfOpened();
- try
- {
- addNodeRecord(data);
- if (LOG.isDebugEnabled())
- LOG.debug("Node added " + data.getQPath().getAsString() + ",
" + data.getIdentifier() + ", "
- + data.getPrimaryTypeName().getAsString());
-
- }
- catch (SQLException e)
- {
- if (LOG.isDebugEnabled())
- LOG.error("Node add. Database error: " + e);
-
- exceptionHandler.handleAddException(e, data);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void add(PropertyData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- checkIfOpened();
-
- try
- {
- addPropertyRecord(data);
-
- if (data.getType() == PropertyType.REFERENCE)
- {
- try
- {
- addReference(data);
- }
- catch (IOException e)
- {
- throw new RepositoryException("Can't read REFERENCE property
(" + data.getQPath() + " "
- + data.getIdentifier() + ") value: " + e.getMessage(), e);
- }
- }
-
- addValues(getInternalId(data.getIdentifier()), data);
-
- if (LOG.isDebugEnabled())
- LOG.debug("Property added " + data.getQPath().getAsString() +
", " + data.getIdentifier()
- + (data.getValues() != null ? ", values count: " +
data.getValues().size() : ", NULL data"));
-
- }
- catch (IOException e)
- {
- if (LOG.isDebugEnabled())
- LOG.error("Property add. IO error: " + e, e);
- throw new RepositoryException("Error of Property Value add " + e, e);
- }
- catch (SQLException e)
- {
- if (LOG.isDebugEnabled())
- LOG.error("Property add. Database error: " + e, e);
- exceptionHandler.handleAddException(e, data);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void rename(NodeData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
-
- checkIfOpened();
- try
- {
- if (renameNode(data) <= 0)
- throw new JCRInvalidItemStateException("(rename) Node not found " +
data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
- ItemState.RENAMED);
- }
- catch (SQLException e)
- {
- if (LOG.isDebugEnabled())
- LOG.error("Property add. Database error: " + e, e);
- exceptionHandler.handleAddException(e, data);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void delete(NodeData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- checkIfOpened();
-
- final String cid = getInternalId(data.getIdentifier());
-
- try
- {
- int nc = deleteItemByIdentifier(cid);
- if (nc <= 0)
- throw new JCRInvalidItemStateException("(delete) Node not found " +
data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
- ItemState.DELETED);
-
- if (LOG.isDebugEnabled())
- LOG.debug("Node deleted " + data.getQPath().getAsString() + ",
" + data.getIdentifier() + ", "
- + ((NodeData)data).getPrimaryTypeName().getAsString());
-
- }
- catch (SQLException e)
- {
- if (LOG.isDebugEnabled())
- LOG.error("Node remove. Database error: " + e, e);
- exceptionHandler.handleDeleteException(e, data);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void delete(PropertyData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- checkIfOpened();
-
- final String cid = getInternalId(data.getIdentifier());
-
- try
- {
- deleteValues(cid, data, false);
-
- // delete references
- deleteReference(cid);
-
- // delete item
- int nc = deleteItemByIdentifier(cid);
- if (nc <= 0)
- throw new JCRInvalidItemStateException("(delete) Property not found
" + data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
- ItemState.DELETED);
-
- if (LOG.isDebugEnabled())
- LOG.debug("Property deleted "
- + data.getQPath().getAsString()
- + ", "
- + data.getIdentifier()
- + (((PropertyData)data).getValues() != null ? ", values count:
"
- + ((PropertyData)data).getValues().size() : ", NULL data"));
-
- }
- catch (IOException e)
- {
- if (LOG.isDebugEnabled())
- LOG.error("Property remove. IO error: " + e, e);
- throw new RepositoryException("Error of Property Value delete " + e,
e);
- }
- catch (SQLException e)
- {
- if (LOG.isDebugEnabled())
- LOG.error("Property remove. Database error: " + e, e);
- exceptionHandler.handleDeleteException(e, data);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void update(NodeData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- checkIfOpened();
- try
- {
- String cid = getInternalId(data.getIdentifier());
- // order numb update
- if (updateNodeByIdentifier(data.getPersistedVersion(),
data.getQPath().getIndex(), data.getOrderNumber(), cid) <= 0)
- throw new JCRInvalidItemStateException("(update) Node not found " +
data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
- ItemState.UPDATED);
-
- if (LOG.isDebugEnabled())
- LOG.debug("Node updated " + data.getQPath().getAsString() + ",
" + data.getIdentifier() + ", "
- + data.getPrimaryTypeName().getAsString());
-
- }
- catch (SQLException e)
- {
- if (LOG.isDebugEnabled())
- LOG.error("Node update. Database error: " + e, e);
- exceptionHandler.handleUpdateException(e, data);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void update(PropertyData data) throws RepositoryException,
UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- checkIfOpened();
-
- try
- {
- String cid = getInternalId(data.getIdentifier());
-
- // update type
- if (updatePropertyByIdentifier(data.getPersistedVersion(), data.getType(), cid)
<= 0)
- throw new JCRInvalidItemStateException("(update) Property not found
" + data.getQPath().getAsString() + " "
- + data.getIdentifier() + ". Probably was deleted by another session
", data.getIdentifier(),
- ItemState.UPDATED);
-
- // update reference
- try
- {
- deleteReference(cid);
-
- if (data.getType() == PropertyType.REFERENCE)
- {
- addReference(data);
- }
- }
- catch (IOException e)
- {
- throw new RepositoryException("Can't update REFERENCE property
(" + data.getQPath() + " "
- + data.getIdentifier() + ") value: " + e.getMessage(), e);
- }
-
- // do Values update: delete all and add all
- deleteValues(cid, data, true);
- addValues(cid, data);
-
- if (LOG.isDebugEnabled())
- LOG.debug("Property updated " + data.getQPath().getAsString() +
", " + data.getIdentifier()
- + (data.getValues() != null ? ", values count: " +
data.getValues().size() : ", NULL data"));
-
- }
- catch (IOException e)
- {
- if (LOG.isDebugEnabled())
- LOG.error("Property update. IO error: " + e, e);
- throw new RepositoryException("Error of Property Value update " + e,
e);
- }
- catch (SQLException e)
- {
- if (LOG.isDebugEnabled())
- LOG.error("Property update. Database error: " + e, e);
- exceptionHandler.handleUpdateException(e, data);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public List<NodeData> getChildNodesData(NodeData parent) throws
RepositoryException, IllegalStateException
- {
- checkIfOpened();
- try
- {
- // ResultSet node =
findChildNodesByParentIdentifier(getInternalId(parent.getIdentifier()));
- // List<NodeData> childrens = new ArrayList<NodeData>();
- // while (node.next())
- // childrens.add((NodeData)itemData(parent.getQPath(), node,
I_CLASS_NODE, parent.getACL()));
- //
- // return childrens;
- ResultSet resultSet =
findChildNodesByParentIdentifierNew(getInternalId(parent.getIdentifier()));
- if (resultSet.next())
- {
- Map<String, TempNodeData> tempNodes = loadNodesData(resultSet);
-
- List<NodeData> childrens = new
ArrayList<NodeData>(tempNodes.size());
- QPath parentQPath = parent.getQPath();
- AccessControlList parentACL = parent.getACL();
- for (TempNodeData data : tempNodes.values())
- {
- NodeData nodeData = loadNodeFromTemporaryNodeData(data, parentQPath,
parentACL);
- childrens.add(nodeData);
- }
- return childrens;
- }
- else
- {
- return new ArrayList<NodeData>();
- }
-
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- protected Map<String, TempNodeData> loadNodesData(ResultSet resultSet) throws
RepositoryException, IOException,
- SQLException
- {
-
- Map<String, TempNodeData> nodesData = new LinkedHashMap<String,
TempNodeData>();
- do
- {
- int itemClass = resultSet.getInt(COLUMN_CLASS);
- if (itemClass == I_CLASS_NODE)
- {
- TempNodeData data = new TempNodeData(resultSet);
- nodesData.put(data.cid, data);
- }
- else
- {
- String cpid = resultSet.getString(COLUMN_PARENTID);
- TempNodeData data = nodesData.get(cpid);
- if (data.properties == null)
- {
- data.properties = new HashMap<String, List<byte[]>>();
- }
- Map<String, List<byte[]>> properties = data.properties;
- String key = resultSet.getString(COLUMN_NAME);
- List<byte[]> values = properties.get(key);
- if (values == null)
- {
- values = new ArrayList<byte[]>();
- properties.put(key, values);
- }
- values.add(resultSet.getBytes(COLUMN_VDATA));
- }
- }
- while (resultSet.next());
-
- return nodesData;
-
- }
-
- private static class TempNodeData
- {
- String cid;
-
- String cname;
-
- int cversion;
-
- String cpid;
-
- int cindex;
-
- int cnordernumb;
-
- Map<String, List<byte[]>> properties = new HashMap<String,
List<byte[]>>();
-
- public TempNodeData(ResultSet item) throws SQLException
- {
- cid = item.getString(COLUMN_ID);
- cname = item.getString(COLUMN_NAME);
- cversion = item.getInt(COLUMN_VERSION);
-
- cpid = item.getString(COLUMN_PARENTID);
-
- cindex = item.getInt(COLUMN_INDEX);
- cnordernumb = item.getInt(COLUMN_NORDERNUM);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public int getChildNodesCount(NodeData parent) throws RepositoryException
- {
- checkIfOpened();
- try
- {
- ResultSet count =
findChildNodesCountByParentIdentifier(getInternalId(parent.getIdentifier()));
- if (count.next())
- {
- return count.getInt(1);
- }
- else
- {
- throw new RepositoryException("FATAL No resulton childNodes count for
" + parent.getQPath().getAsString());
- }
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public List<PropertyData> getChildPropertiesData(NodeData parent) throws
RepositoryException, IllegalStateException
- {
- checkIfOpened();
- try
- {
-
- ResultSet resultSet =
getChildPropertiesByParentIdentifier(getInternalId(parent.getIdentifier()));
- List<PropertyData> children = new ArrayList<PropertyData>();
- if (resultSet.next())
- {
- while (!resultSet.isAfterLast())
- children.add(loadPropertyRecord(resultSet, parent.getQPath()));
- }
-
- return children;
-
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * TODO left as current
- */
- public List<PropertyData> listChildPropertiesData(NodeData parent) throws
RepositoryException, IllegalStateException
- {
- checkIfOpened();
- try
- {
- ResultSet prop =
findChildPropertiesByParentIdentifier(getInternalId(parent.getIdentifier()));
- List<PropertyData> children = new ArrayList<PropertyData>();
- while (prop.next())
- children.add(propertyData(parent.getQPath(), prop));
-
- return children;
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public ItemData getItemData(String identifier) throws RepositoryException,
IllegalStateException
- {
- return getItemByIdentifier(getInternalId(identifier));
- }
-
- public ItemData getItemData(NodeData parentData, QPathEntry name) throws
RepositoryException, IllegalStateException
- {
-
- if (parentData != null)
- {
- return getItemByName(parentData, getInternalId(parentData.getIdentifier()),
name);
- }
-
- // it's a root node
- return getItemByName(null, null, name);
- }
-
- /**
- * {@inheritDoc}
- */
- public List<PropertyData> getReferencesData(String nodeIdentifier) throws
RepositoryException, IllegalStateException
- {
- checkIfOpened();
- try
- {
- ResultSet refProps = findReferences(getInternalId(nodeIdentifier));
- List<PropertyData> references = new ArrayList<PropertyData>();
- while (refProps.next())
- {
- references.add((PropertyData)itemData(null, refProps, I_CLASS_PROPERTY,
null));
- }
-
- // ResultSet resultSet =
findReferenceProperties(getInternalId(nodeIdentifier));
- // List<PropertyData> references = new
ArrayList<PropertyData>(); //
- // if (resultSet.next())
- // {
- // while (!resultSet.isAfterLast())
- // references.add(loadPropertyRecord(resultSet, null));
- // }
-
- return references;
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- // ------------------ Private methods ---------------
-
- /**
- * Get Item By Identifier.
- *
- * @param cid
- * Item id (container internal)
- * @return ItemData
- * @throws RepositoryException
- * Repository error
- * @throws IllegalStateException
- * if connection is closed
- */
- protected ItemData getItemByIdentifier(String cid) throws RepositoryException,
IllegalStateException
- {
- checkIfOpened();
- ResultSet resultSet = null;
- try
- {
- resultSet = findItemByIdentifierNew(cid);
- if (resultSet.next())
- {
- int itemType = resultSet.getInt(COLUMN_CLASS);
- if (itemType == I_CLASS_NODE)
- {
- Map<String, TempNodeData> node = loadNodesData(resultSet);
- return loadNodeFromTemporaryNodeData(node.get(cid), null, null);
- //return loadNodeRecord(resultSet, null, null);
- }
- else
- {
- return loadPropertyRecord(resultSet, null);
- }
-
- }
- return null;
- }
- catch (SQLException e)
- {
- throw new RepositoryException("getItemData() error", e);
- }
- catch (IOException e)
- {
- throw new RepositoryException("getItemData() error", e);
- }
- finally
- {
- try
- {
- if (resultSet != null)
- resultSet.close();
- }
- catch (SQLException e)
- {
- LOG.error("getItemData() Error close resultset " +
e.getMessage());
- }
- }
-
- }
-
- /**
- * Gets an item data from database.
- *
- * @param parentPath
- * - parent QPath
- * @param parentId
- * - parent container internal id (depends on Multi/Single DB)
- * @param name
- * - item name
- * @return - ItemData instance
- * @throws RepositoryException
- * Repository error
- * @throws IllegalStateException
- * if connection is closed
- */
- protected ItemData getItemByName(NodeData parent, String parentId, QPathEntry name)
throws RepositoryException,
- IllegalStateException
- {
- checkIfOpened();
- ResultSet resultSet = null;
- try
- {
- resultSet = findItemByNameNew(parentId, name.getAsString(), name.getIndex());
- if (resultSet.next())
- {
- // return itemData(parent.getQPath(), item, item.getInt(COLUMN_CLASS),
parent.getACL());
- int itemType = resultSet.getInt(COLUMN_CLASS);
- if (itemType == I_CLASS_NODE)
- {
- // Remember first node id. If node is not first in result set - it's a
bug.
- String firstNodeId = resultSet.getString(COLUMN_ID);
-
- // There may be two or more nodes, so load temp NodeDatas and return first
one.
- Map<String, TempNodeData> tempNodes = loadNodesData(resultSet);
-
- QPath parentQPath = parent.getQPath();
- AccessControlList parentACL = parent.getACL();
-
- NodeData nodeData =
loadNodeFromTemporaryNodeData(tempNodes.get(firstNodeId), parentQPath, parentACL);
- tempNodes.clear();
- return nodeData;
-
- //return loadNodeRecord(resultSet, parent.getQPath(), parent.getACL());
- }
- else
- {
- return loadPropertyRecord(resultSet, parent.getQPath());
- }
- }
-
- return null;
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- try
- {
- if (resultSet != null)
- resultSet.close();
- }
- catch (SQLException e)
- {
- LOG.error("getItemData() Error close resultset " +
e.getMessage());
- }
- }
- }
-
- /**
- * Build Item path by id.
- *
- * @param cpid
- * - Item id (container id)
- * @return Item QPath
- * @throws SQLException
- * - if database error occurs
- * @throws InvalidItemStateException
- * - if parent not found
- * @throws IllegalNameException
- * - if name on the path is wrong
- */
- private QPath traverseQPath(String cpid) throws SQLException,
InvalidItemStateException, IllegalNameException
- {
- // get item by Identifier usecase
- List<QPathEntry> qrpath = new ArrayList<QPathEntry>(); // reverted
path
- String caid = cpid; // container ancestor id
- do
- {
- ResultSet parent = null;
- try
- {
- parent = findItemByIdentifier(caid);
- if (!parent.next())
- throw new InvalidItemStateException("Parent not found, uuid: " +
getIdentifier(caid));
-
- QPathEntry qpe =
- new QPathEntry(InternalQName.parse(parent.getString(COLUMN_NAME)),
parent.getInt(COLUMN_INDEX));
- qrpath.add(qpe);
- caid = parent.getString(COLUMN_PARENTID);
- }
- finally
- {
- parent.close();
- }
- }
- while (!caid.equals(Constants.ROOT_PARENT_UUID));
-
- QPathEntry[] qentries = new QPathEntry[qrpath.size()];
- int qi = 0;
- for (int i = qrpath.size() - 1; i >= 0; i--)
- {
- qentries[qi++] = qrpath.get(i);
- }
- return new QPath(qentries);
- }
-
- /**
- * ItemLocationInfo.
- *
- */
- class ItemLocationInfo
- {
- /**
- * Item qpath
- */
- final QPath qpath;
-
- /**
- * All ancestors of the item with qpath
- */
- final List<String> ancestors;
-
- /**
- * Item id.
- */
- final String itemId;
-
- /**
- * ItemLocationInfo constructor.
- *
- * @param qpath
- * Item path
- * @param ancestors
- * ancesstors id list
- * @param itemId
- * Item id
- */
- ItemLocationInfo(QPath qpath, List<String> ancestors, String itemId)
- {
- this.qpath = qpath;
- this.ancestors = ancestors;
- this.itemId = itemId;
- }
- }
-
- /**
- * Find ancestor permissions by cpid. Will search till find the permissions or meet a
root node.
- *
- * @param cpid
- * - initial parent node id
- * @return Collection<String>
- * @throws SQLException
- * if database error
- * @throws IllegalACLException
- * if wrong ACL
- * @throws IllegalNameException
- * if wrong QName
- * @throws RepositoryException
- * if Repository error
- */
- private List<AccessControlEntry> traverseACLPermissions(String cpid) throws
SQLException, IllegalACLException,
- IllegalNameException, RepositoryException
- {
- String caid = cpid;
- while (!caid.equals(Constants.ROOT_PARENT_UUID))
- {
- MixinInfo naMixins = readMixins(caid);
- if (naMixins.hasPrivilegeable())
- return readACLPermisions(caid);
-
- if (naMixins.parentId == null)
- caid = findParentId(caid);
- else
- caid = naMixins.parentId;
- }
-
- throw new IllegalACLException("Can not find permissions for a node with id
" + getIdentifier(cpid));
- }
-
- protected String findParentId(String cid) throws SQLException, RepositoryException
- {
- ResultSet pidrs = findItemByIdentifier(cid);
- try
- {
- if (pidrs.next())
- return pidrs.getString(COLUMN_PARENTID);
- else
- throw new RepositoryException("Item not found id: " +
getIdentifier(cid));
- }
- finally
- {
- pidrs.close();
- }
- }
-
- /**
- * Find ancestor owner by cpid. Will search till find the owner or meet a root node.
- *
- * @param cpid
- * - initial parent node id
- * @return owner name
- * @throws SQLException
- * if database error
- * @throws IllegalACLException
- * if wrong ACL
- * @throws IllegalNameException
- * if wrong QName
- * @throws RepositoryException
- * if Repository error
- */
- private String traverseACLOwner(String cpid) throws SQLException, IllegalACLException,
IllegalNameException,
- RepositoryException
- {
- String caid = cpid;
-
- while (!caid.equals(Constants.ROOT_PARENT_UUID))
- {
- MixinInfo naMixins = readMixins(caid);
- if (naMixins.hasOwneable())
- return readACLOwner(caid);
-
- if (naMixins.parentId == null)
- caid = findParentId(caid);
- else
- caid = naMixins.parentId;
- }
-
- throw new IllegalACLException("Can not find owner for a node with id " +
getIdentifier(cpid));
- }
-
- /**
- * Find ancestor ACL by cpid. Will search till find the ACL or meet a root node.
- *
- * @param cpid
- * - initial parent node id
- * @return owner name
- * @throws SQLException
- * if database error
- * @throws IllegalACLException
- * if wrong ACL
- * @throws IllegalNameException
- * if wrong QName
- * @throws RepositoryException
- * if Repository error
- */
- private AccessControlList traverseACL(String cpid) throws SQLException,
IllegalACLException, IllegalNameException,
- RepositoryException
- {
- String naOwner = null;
- List<AccessControlEntry> naPermissions = null;
-
- String caid = cpid;
-
- while (!caid.equals(Constants.ROOT_PARENT_UUID))
- {
- MixinInfo naMixins = readMixins(caid);
- if (naOwner == null && naMixins.hasOwneable())
- {
- naOwner = readACLOwner(caid);
- if (naPermissions != null)
- break;
- }
- if (naPermissions == null && naMixins.hasPrivilegeable())
- {
- naPermissions = readACLPermisions(caid);
- if (naOwner != null)
- break;
- }
-
- if (naMixins.parentId == null)
- caid = findParentId(caid);
- else
- caid = naMixins.parentId;
- }
-
- if (naOwner != null && naPermissions != null)
- {
- // got all
- return new AccessControlList(naOwner, naPermissions);
- }
- else if (naOwner == null && naPermissions == null)
- {
- // Default values (i.e. ACL is disabled in repository)
- return new AccessControlList();
- }
- else
- throw new IllegalACLException("ACL is not found for node with id " +
getIdentifier(cpid)
- + " or for its ancestors. But repository is ACL enabled.");
- }
-
- /**
- * [PN] Experimental. Use SP for traversing Qpath on the database server side. Hm, I
haven't a
- * good result for that yet. Few seconds only for TCK execution. PGSQL SP: CREATE OR
REPLACE
- * FUNCTION get_qpath(parentId VARCHAR) RETURNS SETOF record AS $$ DECLARE cur_item
RECORD; cur_id
- * varchar; BEGIN cur_id := parentId; WHILE NOT cur_id = ' ' LOOP SELECT id,
name, parent_id,
- * i_index INTO cur_item FROM JCR_SITEM WHERE ID=cur_id; IF NOT found THEN RETURN; END
IF; RETURN
- * NEXT cur_item; cur_id := cur_item.parent_id; END LOOP; RETURN; END; $$ LANGUAGE
plpgsql;
- *
- * @param cpid
- * @return
- * @throws SQLException
- * if database error
- * @throws InvalidItemStateException
- * if Item state is obsolete
- * @throws IllegalNameException
- * if invalid QName
- */
- private QPath traverseQPath_SP_PGSQL(String cpid) throws SQLException,
InvalidItemStateException,
- IllegalNameException
- {
- // get item by Identifier usecase:
- // find parent path in db by cpid
- if (cpid == null)
- {
- // root node
- return null; // Constants.ROOT_PATH
- }
- else
- {
- List<QPathEntry> qrpath = new ArrayList<QPathEntry>(); // reverted
path
- PreparedStatement cstmt = null;
- try
- {
- cstmt =
- dbConnection
- .prepareStatement("select * from get_qpath(?) AS (id varchar, name
varchar, parent_id varchar, i_index int)");
- cstmt.setString(1, cpid);
- // cstmt.setString(2, caid);
- ResultSet parent = cstmt.executeQuery();
-
- while (parent.next())
- {
- QPathEntry qpe =
- new QPathEntry(InternalQName.parse(parent.getString(COLUMN_NAME)),
parent.getInt(COLUMN_INDEX));
- qrpath.add(qpe);
- }
-
- // parent = findItemByIdentifier(caid);
- if (qrpath.size() <= 0)
- throw new InvalidItemStateException("Parent not found, uuid: " +
getIdentifier(cpid));
- }
- finally
- {
- if (cstmt != null)
- cstmt.close();
- }
-
- QPathEntry[] qentries = new QPathEntry[qrpath.size()];
- int qi = 0;
- for (int i = qrpath.size() - 1; i >= 0; i--)
- {
- qentries[qi++] = qrpath.get(i);
- }
- return new QPath(qentries);
- }
- }
-
- /**
- * Build ItemData.
- *
- * @param parentPath
- * - parent path
- * @param item
- * database - ResultSet with Item record(s)
- * @param itemClass
- * - Item type (Node or Property)
- * @param parentACL
- * - parent ACL
- * @return ItemData instance
- * @throws RepositoryException
- * Repository error
- * @throws SQLException
- * database error
- * @throws IOException
- * I/O error
- */
- private ItemData itemData(QPath parentPath, ResultSet item, int itemClass,
AccessControlList parentACL)
- throws RepositoryException, SQLException, IOException
- {
- String cid = item.getString(COLUMN_ID);
- String cname = item.getString(COLUMN_NAME);
- int cversion = item.getInt(COLUMN_VERSION);
-
- String cpid = item.getString(COLUMN_PARENTID);
- // if parent ID is empty string - it's a root node
- // cpid = cpid.equals(Constants.ROOT_PARENT_UUID) ? null : cpid;
-
- try
- {
- if (itemClass == I_CLASS_NODE)
- {
- int cindex = item.getInt(COLUMN_INDEX);
- int cnordernumb = item.getInt(COLUMN_NORDERNUM);
- return loadNodeRecord(parentPath, cname, cid, cpid, cindex, cversion,
cnordernumb, parentACL);
- }
-
- int cptype = item.getInt(COLUMN_PTYPE);
- boolean cpmultivalued = item.getBoolean(COLUMN_PMULTIVALUED);
- return loadPropertyRecord(parentPath, cname, cid, cpid, cversion, cptype,
cpmultivalued);
- }
- catch (InvalidItemStateException e)
- {
- throw new InvalidItemStateException("FATAL: Can't build item path for
name " + cname + " id: "
- + getIdentifier(cid) + ". " + e);
- }
- }
-
- /**
- * Read property data without value data. For listChildPropertiesData(NodeData).
- *
- * @param parentPath
- * - parent path
- * @param item
- * database - ResultSet with Item record(s)
- * @return PropertyData instance
- * @throws RepositoryException
- * Repository error
- * @throws SQLException
- * database error
- * @throws IOException
- * I/O error
- */
- private PropertyData propertyData(QPath parentPath, ResultSet item) throws
RepositoryException, SQLException,
- IOException
- {
- String cid = item.getString(COLUMN_ID);
- String cname = item.getString(COLUMN_NAME);
- int cversion = item.getInt(COLUMN_VERSION);
- String cpid = item.getString(COLUMN_PARENTID);
- int cptype = item.getInt(COLUMN_PTYPE);
- boolean cpmultivalued = item.getBoolean(COLUMN_PMULTIVALUED);
-
- try
- {
- InternalQName qname = InternalQName.parse(cname);
-
- QPath qpath = QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) :
parentPath, qname);
-
- PersistedPropertyData pdata =
- new PersistedPropertyData(getIdentifier(cid), qpath, getIdentifier(cpid),
cversion, cptype, cpmultivalued,
- new ArrayList<ValueData>());
-
- return pdata;
- }
- catch (InvalidItemStateException e)
- {
- throw new InvalidItemStateException("FATAL: Can't build property path
for name " + cname + " id: "
- + getIdentifier(cid) + ". " + e);
- }
- catch (IllegalNameException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * Mixin types description (internal use).
- *
- */
- class MixinInfo
- {
-
- /**
- * OWNEABLE constant.
- */
- static final int OWNEABLE = 0x0001; // bits 0001
-
- /**
- * PRIVILEGEABLE constant.
- */
- static final int PRIVILEGEABLE = 0x0002; // bits 0010
-
- /**
- * OWNEABLE_PRIVILEGEABLE constant.
- */
- static final int OWNEABLE_PRIVILEGEABLE = OWNEABLE | PRIVILEGEABLE; // bits 0011
-
- /**
- * Mixin types.
- */
- final List<InternalQName> mixinTypes;
-
- /**
- * oexo:owneable flag.
- */
- final boolean owneable;
-
- /**
- * exo:privilegeable flag.
- */
- final boolean privilegeable;
-
- /**
- * Parent Id.
- */
- final String parentId = null;
-
- /**
- * MixinInfo constructor.
- *
- * @param mixinTypes
- * mixin types
- * @param owneable
- * exo:owneable flag
- * @param privilegeable
- * exo:privilegeable flag
- */
- MixinInfo(List<InternalQName> mixinTypes, boolean owneable, boolean
privilegeable)
- {
- this.mixinTypes = mixinTypes;
- this.owneable = owneable;
- this.privilegeable = privilegeable;
- }
-
- /**
- * Return Mixin names array.
- *
- * @return InternalQName[] Mixin names array
- */
- InternalQName[] mixinNames()
- {
- if (mixinTypes != null)
- {
- InternalQName[] mns = new InternalQName[mixinTypes.size()];
- mixinTypes.toArray(mns);
- return mns;
- }
- else
- return new InternalQName[0];
- }
-
- /**
- * Tell is exo:privilegeable.
- *
- * @return boolean
- */
- boolean hasPrivilegeable()
- {
- return privilegeable;
- }
-
- /**
- * Tell is exo:owneable.
- *
- * @return boolean
- */
- boolean hasOwneable()
- {
- return owneable;
- }
- }
-
- /**
- * Read mixins from database.
- *
- * @param cid
- * - Item id (internal)
- * @return MixinInfo
- * @throws SQLException
- * database error
- * @throws IllegalNameException
- * if nodetype name in mixin record is wrong
- */
- protected MixinInfo readMixins(String cid) throws SQLException, IllegalNameException
- {
- ResultSet mtrs = findPropertyByName(cid, Constants.JCR_MIXINTYPES.getAsString());
-
- try
- {
- List<InternalQName> mts = null;
- boolean owneable = false;
- boolean privilegeable = false;
- if (mtrs.next())
- {
- mts = new ArrayList<InternalQName>();
- do
- {
- byte[] mxnb = mtrs.getBytes(COLUMN_VDATA);
- if (mxnb != null)
- {
- InternalQName mxn = InternalQName.parse(new String(mxnb));
- mts.add(mxn);
-
- if (!privilegeable && Constants.EXO_PRIVILEGEABLE.equals(mxn))
- privilegeable = true;
- else if (!owneable && Constants.EXO_OWNEABLE.equals(mxn))
- owneable = true;
- } // else, if SQL NULL - skip it
- }
- while (mtrs.next());
- }
-
- return new MixinInfo(mts, owneable, privilegeable);
- }
- finally
- {
- mtrs.close();
- }
- }
-
- /**
- * Return permission values or throw an exception. We assume the node is
mix:privilegeable.
- *
- * @param cid
- * Node id
- * @return list of ACL entries
- * @throws SQLException
- * database error
- * @throws IllegalACLException
- * if property exo:permissions is not found for node
- */
- protected List<AccessControlEntry> readACLPermisions(String cid) throws
SQLException, IllegalACLException
- {
- List<AccessControlEntry> naPermissions = new
ArrayList<AccessControlEntry>();
- ResultSet exoPerm = findPropertyByName(cid,
Constants.EXO_PERMISSIONS.getAsString());
- try
- {
- if (exoPerm.next())
- {
- do
- {
- StringTokenizer parser =
- new StringTokenizer(new String(exoPerm.getBytes(COLUMN_VDATA)),
AccessControlEntry.DELIMITER);
- naPermissions.add(new AccessControlEntry(parser.nextToken(),
parser.nextToken()));
- }
- while (exoPerm.next());
-
- return naPermissions;
- }
- else
- throw new IllegalACLException("Property exo:permissions is not found for
node with id: "
- + getIdentifier(cid));
- }
- finally
- {
- exoPerm.close();
- }
- }
-
- /**
- * Return owner value or throw an exception. We assume the node is mix:owneable.
- *
- * @param cid
- * Node id
- * @return ACL owner
- * @throws SQLException
- * database error
- * @throws IllegalACLException
- * Property exo:owner is not found for node
- */
- protected String readACLOwner(String cid) throws SQLException, IllegalACLException
- {
- ResultSet exoOwner = findPropertyByName(cid, Constants.EXO_OWNER.getAsString());
- try
- {
- if (exoOwner.next())
- return new String(exoOwner.getBytes(COLUMN_VDATA));
- else
- throw new IllegalACLException("Property exo:owner is not found for node
with id: " + getIdentifier(cid));
- }
- finally
- {
- exoOwner.close();
- }
- }
-
- /**
- * Load NodeData record.
- *
- * @param parentPath
- * parent path
- * @param cname
- * Node name
- * @param cid
- * Node id
- * @param cpid
- * Node parent id
- * @param cindex
- * Node index
- * @param cversion
- * Node persistent version
- * @param cnordernumb
- * Node order number
- * @param parentACL
- * Node parent ACL
- * @return PersistedNodeData
- * @throws RepositoryException
- * Repository error
- * @throws SQLException
- * database error
- */
- protected PersistedNodeData loadNodeRecord(QPath parentPath, String cname, String cid,
String cpid, int cindex,
- int cversion, int cnordernumb, AccessControlList parentACL) throws
RepositoryException, SQLException
- {
-
- try
- {
- InternalQName qname = InternalQName.parse(cname);
-
- QPath qpath;
- String parentCid;
- if (parentPath != null)
- {
- // get by parent and name
- qpath = QPath.makeChildPath(parentPath, qname, cindex);
- parentCid = cpid;
- }
- else
- {
- // get by id
- if (cpid.equals(Constants.ROOT_PARENT_UUID))
- {
- // root node
- qpath = Constants.ROOT_PATH;
- parentCid = null;
- }
- else
- {
- qpath = QPath.makeChildPath(traverseQPath(cpid), qname, cindex);
- parentCid = cpid;
- }
- }
-
- try
- {
- // PRIMARY
- ResultSet ptProp = findPropertyByName(cid,
Constants.JCR_PRIMARYTYPE.getAsString());
-
- if (!ptProp.next())
- throw new PrimaryTypeNotFoundException("FATAL ERROR primary type
record not found. Node "
- + qpath.getAsString() + ", id " + cid + ", container
" + this.containerName, null);
-
- byte[] data = ptProp.getBytes(COLUMN_VDATA);
- InternalQName ptName = InternalQName.parse(new String((data != null ? data :
new byte[]{})));
-
- // MIXIN
- MixinInfo mixins = readMixins(cid);
-
- // ACL
- AccessControlList acl; // NO DEFAULT values!
-
- if (mixins.hasOwneable())
- {
- // has own owner
- if (mixins.hasPrivilegeable())
- {
- // and permissions
- acl = new AccessControlList(readACLOwner(cid),
readACLPermisions(cid));
- }
- else if (parentACL != null)
- {
- // use permissions from existed parent
- acl =
- new AccessControlList(readACLOwner(cid), parentACL.hasPermissions()
? parentACL
- .getPermissionEntries() : null);
- }
- else
- {
- // have to search nearest ancestor permissions in ACL manager
- // acl = new AccessControlList(readACLOwner(cid),
traverseACLPermissions(cpid));
- acl = new AccessControlList(readACLOwner(cid), null);
- }
- }
- else if (mixins.hasPrivilegeable())
- {
- // has own permissions
- if (mixins.hasOwneable())
- {
- // and owner
- acl = new AccessControlList(readACLOwner(cid),
readACLPermisions(cid));
- }
- else if (parentACL != null)
- {
- // use owner from existed parent
- acl = new AccessControlList(parentACL.getOwner(),
readACLPermisions(cid));
- }
- else
- {
- // have to search nearest ancestor owner in ACL manager
- // acl = new AccessControlList(traverseACLOwner(cpid),
readACLPermisions(cid));
- acl = new AccessControlList(null, readACLPermisions(cid));
- }
- }
- else
- {
- if (parentACL != null)
- // construct ACL from existed parent ACL
- acl =
- new AccessControlList(parentACL.getOwner(),
parentACL.hasPermissions() ? parentACL
- .getPermissionEntries() : null);
- else
- // have to search nearest ancestor owner and permissions in ACL
manager
- // acl = traverseACL(cpid);
- acl = null;
- }
-
- return new PersistedNodeData(getIdentifier(cid), qpath,
getIdentifier(parentCid), cversion, cnordernumb,
- ptName, mixins.mixinNames(), acl);
- }
- catch (IllegalACLException e)
- {
- throw new RepositoryException("FATAL ERROR Node " +
getIdentifier(cid) + " " + qpath.getAsString()
- + " has wrong formed ACL. ", e);
- }
- }
- catch (IllegalNameException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * Load PropertyData record.
- *
- * @param parentPath
- * parent path
- * @param cname
- * Property name
- * @param cid
- * Property id
- * @param cpid
- * Property parent id
- * @param cversion
- * Property persistent verison
- * @param cptype
- * Property type
- * @param cpmultivalued
- * Property multivalued status
- * @return PersistedPropertyData
- * @throws RepositoryException
- * Repository error
- * @throws SQLException
- * database error
- * @throws IOException
- * I/O error
- */
- protected PersistedPropertyData loadPropertyRecord(QPath parentPath, String cname,
String cid, String cpid,
- int cversion, int cptype, boolean cpmultivalued) throws RepositoryException,
SQLException, IOException
- {
-
- // NOTE: cpid never should be null or root parent (' ')
-
- try
- {
- QPath qpath =
- QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) : parentPath,
InternalQName.parse(cname));
-
- String identifier = getIdentifier(cid);
- List<ValueData> values = readValues(cid, identifier, cversion);
- PersistedPropertyData pdata =
- new PersistedPropertyData(identifier, qpath, getIdentifier(cpid), cversion,
cptype, cpmultivalued, values);
-
- return pdata;
- }
- catch (IllegalNameException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- protected PersistedNodeData loadNodeRecord(ResultSet item, QPath parentPath,
AccessControlList pACL)
- throws RepositoryException, SQLException, IOException
- {
-
- String cid = item.getString(COLUMN_ID);
- String cname = item.getString(COLUMN_NAME);
- int cversion = item.getInt(COLUMN_VERSION);
- String cpid = item.getString(COLUMN_PARENTID);
- int cindex = item.getInt(COLUMN_INDEX);
- int cnordernumb = item.getInt(COLUMN_NORDERNUM);
- AccessControlList parentACL = pACL;
-
- try
- {
- InternalQName qname = InternalQName.parse(cname);
-
- // TODO can't avoid QPath traverse
- QPath qpath;
- String parentCid;
- if (parentPath != null)
- {
- // get by parent and name
- qpath = QPath.makeChildPath(parentPath, qname, cindex);
- parentCid = cpid;
- }
- else
- {
- // get by id
- if (cpid.equals(Constants.ROOT_PARENT_UUID))
- {
- // root node
- qpath = Constants.ROOT_PATH;
- parentCid = null;
- }
- else
- {
- qpath = QPath.makeChildPath(traverseQPath(cpid), qname, cindex);
- parentCid = cpid;
- }
- }
-
- // preload properties
-
- Map<String, List<byte[]>> properties = new LinkedHashMap<String,
List<byte[]>>();
-
- // PRIMARY
- if (!item.next() ||
!item.getString(COLUMN_NAME).equals(Constants.JCR_PRIMARYTYPE.getAsString()))
- {
- throw new SQLException("Node finded but primaryType property not "
+ cid);
- }
-
- byte[] data = item.getBytes(COLUMN_VDATA);
- InternalQName ptName = InternalQName.parse(new String((data != null ? data : new
byte[]{})));
-
- // // PRIMARY
- // ResultSet ptProp = findPropertyByName(cid,
Constants.JCR_PRIMARYTYPE.getAsString());
- //
- // if (!ptProp.next())
- // throw new PrimaryTypeNotFoundException("FATAL ERROR
primary type record not found. Node "
- // + qpath.getAsString() + ", id " + cid + ",
container " + this.containerName, null);
- //
- // byte[] data = ptProp.getBytes(COLUMN_VDATA);
- // InternalQName ptName = InternalQName.parse(new String((data !=
null ? data : new byte[]{})));
-
- // MIXIN
- MixinInfo mixins = null;
- List<InternalQName> mts = null;
- boolean owneable = false;
- boolean privilegeable = false;
- while (item.next() &&
item.getString(COLUMN_NAME).equals(Constants.JCR_MIXINTYPES.getAsString()))
- {
- mts = new ArrayList<InternalQName>();
- byte[] mxnb = item.getBytes(COLUMN_VDATA);
- if (mxnb != null)
- {
- InternalQName mxn = InternalQName.parse(new String(mxnb));
- mts.add(mxn);
-
- if (!privilegeable && Constants.EXO_PRIVILEGEABLE.equals(mxn))
- privilegeable = true;
- else if (!owneable && Constants.EXO_OWNEABLE.equals(mxn))
- owneable = true;
- } // else, if SQL NULL - skip it
-
- }
-
- mixins = new MixinInfo(mts, owneable, privilegeable);
-
- try
- {
- // ACL
- AccessControlList acl; // NO DEFAULT values!
-
- if (mixins.hasOwneable())
- {
- // has own owner
- if (mixins.hasPrivilegeable())
- {
- // and permissions
- acl = new AccessControlList(readACLOwner(cid),
readACLPermisions(cid));
- }
- else if (parentACL != null)
- {
- // use permissions from existed parent
- acl =
- new AccessControlList(readACLOwner(cid), parentACL.hasPermissions()
? parentACL
- .getPermissionEntries() : null);
- }
- else
- {
- // have to search nearest ancestor permissions in ACL manager
- // acl = new AccessControlList(readACLOwner(cid),
traverseACLPermissions(cpid));
- acl = new AccessControlList(readACLOwner(cid), null);
- }
- }
- else if (mixins.hasPrivilegeable())
- {
- // has own permissions
- if (mixins.hasOwneable())
- {
- // and owner
- acl = new AccessControlList(readACLOwner(cid),
readACLPermisions(cid));
- }
- else if (parentACL != null)
- {
- // use owner from existed parent
- acl = new AccessControlList(parentACL.getOwner(),
readACLPermisions(cid));
- }
- else
- {
- // have to search nearest ancestor owner in ACL manager
- // acl = new AccessControlList(traverseACLOwner(cpid),
readACLPermisions(cid));
- acl = new AccessControlList(null, readACLPermisions(cid));
- }
- }
- else
- {
- if (parentACL != null)
- // construct ACL from existed parent ACL
- acl =
- new AccessControlList(parentACL.getOwner(),
parentACL.hasPermissions() ? parentACL
- .getPermissionEntries() : null);
- else
- // have to search nearest ancestor owner and permissions in ACL
manager
- // acl = traverseACL(cpid);
- acl = null;
- }
-
- return new PersistedNodeData(getIdentifier(cid), qpath,
getIdentifier(parentCid), cversion, cnordernumb,
- ptName, mixins.mixinNames(), acl);
-
- }
- catch (IllegalACLException e)
- {
- throw new RepositoryException("FATAL ERROR Node " +
getIdentifier(cid) + " " + qpath.getAsString()
- + " has wrong formed ACL. ", e);
- }
- }
- catch (IllegalNameException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- protected PersistedNodeData loadNodeFromTemporaryNodeData(TempNodeData buf, QPath
parentPath, AccessControlList pACL)
- throws RepositoryException, SQLException, IOException
- {
-
- String cid = buf.cid;
- String cname = buf.cname;
- int cversion = buf.cversion;
- String cpid = buf.cpid;
- int cindex = buf.cindex;
- int cnordernumb = buf.cnordernumb;
- AccessControlList parentACL = pACL;
-
- try
- {
- InternalQName qname = InternalQName.parse(cname);
-
- // TODO can't avoid QPath traverse
- QPath qpath;
- String parentCid;
- if (parentPath != null)
- {
- // get by parent and name
- qpath = QPath.makeChildPath(parentPath, qname, cindex);
- parentCid = cpid;
- }
- else
- {
- // get by id
- if (cpid.equals(Constants.ROOT_PARENT_UUID))
- {
- // root node
- qpath = Constants.ROOT_PATH;
- parentCid = null;
- }
- else
- {
- qpath = QPath.makeChildPath(traverseQPath(cpid), qname, cindex);
- parentCid = cpid;
- }
- }
-
- // PRIMARY
-
- List<byte[]> primaryType =
buf.properties.get(Constants.JCR_PRIMARYTYPE.getAsString());
- if (primaryType == null || primaryType.size() == 0)
- {
- throw new SQLException("Node finded but primaryType property not "
+ cid);
- }
-
- byte[] data = primaryType.get(0);
- InternalQName ptName = InternalQName.parse(new String((data != null ? data : new
byte[]{})));
-
- // MIXIN
- MixinInfo mixins = null;
- List<InternalQName> mts = null;
- boolean owneable = false;
- boolean privilegeable = false;
- List<byte[]> mixinTypes =
buf.properties.get(Constants.JCR_MIXINTYPES.getAsString());
- if (mixinTypes != null)
- {
- mts = new ArrayList<InternalQName>();
- for (byte[] mxnb : mixinTypes)
- {
- InternalQName mxn = InternalQName.parse(new String(mxnb));
- mts.add(mxn);
-
- if (!privilegeable && Constants.EXO_PRIVILEGEABLE.equals(mxn))
- privilegeable = true;
- else if (!owneable && Constants.EXO_OWNEABLE.equals(mxn))
- owneable = true;
- }
- }
-
- mixins = new MixinInfo(mts, owneable, privilegeable);
-
- try
- {
- // ACL
- AccessControlList acl; // NO DEFAULT values!
-
- if (mixins.hasOwneable())
- {
- // has own owner
- if (mixins.hasPrivilegeable())
- {
- // and permissions
- acl = new AccessControlList(readACLOwner(cid),
readACLPermisions(cid));
- }
- else if (parentACL != null)
- {
- // use permissions from existed parent
- acl =
- new AccessControlList(readACLOwner(cid), parentACL.hasPermissions()
? parentACL
- .getPermissionEntries() : null);
- }
- else
- {
- // have to search nearest ancestor permissions in ACL manager
- // acl = new AccessControlList(readACLOwner(cid),
traverseACLPermissions(cpid));
- acl = new AccessControlList(readACLOwner(cid), null);
- }
- }
- else if (mixins.hasPrivilegeable())
- {
- // has own permissions
- if (mixins.hasOwneable())
- {
- // and owner
- acl = new AccessControlList(readACLOwner(cid),
readACLPermisions(cid));
- }
- else if (parentACL != null)
- {
- // use owner from existed parent
- acl = new AccessControlList(parentACL.getOwner(),
readACLPermisions(cid));
- }
- else
- {
- // have to search nearest ancestor owner in ACL manager
- // acl = new AccessControlList(traverseACLOwner(cpid),
readACLPermisions(cid));
- acl = new AccessControlList(null, readACLPermisions(cid));
- }
- }
- else
- {
- if (parentACL != null)
- // construct ACL from existed parent ACL
- acl =
- new AccessControlList(parentACL.getOwner(),
parentACL.hasPermissions() ? parentACL
- .getPermissionEntries() : null);
- else
- // have to search nearest ancestor owner and permissions in ACL
manager
- // acl = traverseACL(cpid);
- acl = null;
- }
-
- return new PersistedNodeData(getIdentifier(cid), qpath,
getIdentifier(parentCid), cversion, cnordernumb,
- ptName, mixins.mixinNames(), acl);
-
- }
- catch (IllegalACLException e)
- {
- throw new RepositoryException("FATAL ERROR Node " +
getIdentifier(cid) + " " + qpath.getAsString()
- + " has wrong formed ACL. ", e);
- }
- }
- catch (IllegalNameException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- protected PersistedPropertyData loadPropertyRecord(ResultSet item, QPath parentPath)
throws RepositoryException,
- SQLException, IOException
- {
- String cid = item.getString(COLUMN_ID);
- String cname = item.getString(COLUMN_NAME);
- int cversion = item.getInt(COLUMN_VERSION);
-
- String cpid = item.getString(COLUMN_PARENTID);
- // if parent ID is empty string - it's a root node
- // cpid = cpid.equals(Constants.ROOT_PARENT_UUID) ? null : cpid;
-
- try
- {
- int cptype = item.getInt(COLUMN_PTYPE);
- boolean cpmultivalued = item.getBoolean(COLUMN_PMULTIVALUED);
- try
- {
- QPath qpath =
- QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) : parentPath,
InternalQName.parse(cname));
-
- List<ValueData> data = new ArrayList<ValueData>();
-
- String identifier = getIdentifier(cid);
-
- do
- {
- final int orderNum = item.getInt(COLUMN_VORDERNUM);
- final String storageId = item.getString(COLUMN_VSTORAGE_DESC);
- ValueData vdata =
- item.wasNull() ? readValueData(cid, orderNum, cversion,
item.getBinaryStream(COLUMN_VDATA))
- : readValueData(identifier, orderNum, storageId);
- data.add(vdata);
- }
- while (item.next() && item.getString(COLUMN_ID) == cid);
-
- PersistedPropertyData pdata =
- new PersistedPropertyData(identifier, qpath, getIdentifier(cpid),
cversion, cptype, cpmultivalued, data);
-
- return pdata;
- }
- catch (IllegalNameException e)
- {
- throw new RepositoryException(e);
- }
- }
- catch (InvalidItemStateException e)
- {
- throw new InvalidItemStateException("FATAL: Can't build item path for
name " + cname + " id: "
- + getIdentifier(cid) + ". " + e);
- }
- }
-
- /**
- * Delete Property Values.
- *
- * @param cid
- * Property id
- * @param pdata
- * PropertyData
- * @param update
- * boolean true if it's delete-add sequence (update operation)
- * @throws IOException
- * i/O error
- * @throws SQLException
- * if database error occurs
- * @throws ValueStorageNotFoundException
- * if no such storage found with Value storageId
- */
- private void deleteValues(String cid, PropertyData pdata, boolean update) throws
IOException, SQLException,
- ValueStorageNotFoundException
- {
-
- final ResultSet valueRecords = findValuesStorageDescriptorsByPropertyId(cid);
- try
- {
- if (valueRecords.next())
- {
- // delete all Values in database
- deleteValueData(cid);
-
- do
- {
- final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
- if (!valueRecords.wasNull())
- {
- final ValueIOChannel channel =
valueStorageProvider.getChannel(storageId);
- try
- {
- channel.delete(pdata.getIdentifier());
- valueChanges.add(channel);
- }
- finally
- {
- channel.close();
- }
- }
- }
- while (valueRecords.next());
- }
- }
- finally
- {
- valueRecords.close();
- }
- }
-
- /**
- * Read Property Values.
- *
- * @param identifier
- * property identifier
- * @param cid
- * Property id
- * @param pdata
- * PropertyData
- * @return list of ValueData
- * @throws IOException
- * i/O error
- * @throws SQLException
- * if database errro occurs
- * @throws ValueStorageNotFoundException
- * if no such storage found with Value storageId
- */
- private List<ValueData> readValues(String cid, String identifier, int cversion)
throws IOException, SQLException,
- ValueStorageNotFoundException
- {
-
- List<ValueData> data = new ArrayList<ValueData>();
-
- final ResultSet valueRecords = findValuesByPropertyId(cid);
- try
- {
- while (valueRecords.next())
- {
- final int orderNum = valueRecords.getInt(COLUMN_VORDERNUM);
- final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
- ValueData vdata =
- valueRecords.wasNull() ? readValueData(cid, orderNum, cversion,
valueRecords
- .getBinaryStream(COLUMN_VDATA)) : readValueData(identifier, orderNum,
storageId);
- data.add(vdata);
- }
- }
- finally
- {
- valueRecords.close();
- }
-
- return data;
- }
-
- /**
- * Read ValueData from External Storage.
- *
- * @param pdata
- * PropertyData
- * @param orderNumber
- * Value order number
- * @param storageId
- * external Value storage id
- * @return ValueData
- * @throws SQLException
- * database error
- * @throws IOException
- * I/O error
- * @throws ValueStorageNotFoundException
- * if no such storage found with Value storageId
- */
- protected ValueData readValueData(String identifier, int orderNumber, String
storageId) throws SQLException,
- IOException, ValueStorageNotFoundException
- {
- ValueIOChannel channel = valueStorageProvider.getChannel(storageId);
- try
- {
- return channel.read(identifier, orderNumber, maxBufferSize);
- }
- finally
- {
- channel.close();
- }
- }
-
- /**
- * Read ValueData from database.
- *
- * @param cid
- * Property id
- * @param orderNumber
- * Value order number
- * @param version
- * persistent version (used for BLOB swapping)
- * @param content
- * @return ValueData
- * @throws SQLException
- * database error
- * @throws IOException
- * I/O error (swap)
- */
- protected ValueData readValueData(String cid, int orderNumber, int version, final
InputStream content)
- throws SQLException, IOException
- {
-
- ResultSet valueResultSet = null;
-
- byte[] buffer = new byte[0];
- byte[] spoolBuffer = new byte[ValueFileIOHelper.IOBUFFER_SIZE];
- int read;
- int len = 0;
- OutputStream out = null;
-
- SwapFile swapFile = null;
- try
- {
- // stream from database
- if (content != null)
- while ((read = content.read(spoolBuffer)) >= 0)
- {
- if (out != null)
- {
- // spool to temp file
- out.write(spoolBuffer, 0, read);
- len += read;
- }
- else if (len + read > maxBufferSize)
- {
- // threshold for keeping data in memory exceeded;
- // create temp file and spool buffer contents
- swapFile = SwapFile.get(swapDirectory, cid + orderNumber +
"." + version);
- if (swapFile.isSpooled())
- {
- // break, value already spooled
- buffer = null;
- break;
- }
- out = new FileOutputStream(swapFile);
- out.write(buffer, 0, len);
- out.write(spoolBuffer, 0, read);
- buffer = null;
- len += read;
- }
- else
- {
- // reallocate new buffer and spool old buffer contents
- byte[] newBuffer = new byte[len + read];
- System.arraycopy(buffer, 0, newBuffer, 0, len);
- System.arraycopy(spoolBuffer, 0, newBuffer, len, read);
- buffer = newBuffer;
- len += read;
- }
- }
- }
- finally
- {
- if (valueResultSet != null)
- valueResultSet.close();
- if (out != null)
- {
- out.close();
- swapFile.spoolDone();
- }
- }
-
- if (buffer == null)
- return new CleanableFilePersistedValueData(orderNumber, swapFile, swapCleaner);
-
- return new ByteArrayPersistedValueData(orderNumber, buffer);
- }
-
- /**
- * Writes value data to swap file.
- *
- * @param cid
- * Property id
- * @param orderNumber
- * Value order number
- * @param version
- * persistent version (used for BLOB swapping)
- * @param content
- * @return ValueData
- * @throws SQLException
- * database error
- * @throws IOException
- * I/O error (swap)
- */
- protected SwapFile swapValueData(String cid, int orderNumber, int version, final
InputStream content)
- throws SQLException, IOException
- {
-
- byte[] spoolBuffer = new byte[ValueFileIOHelper.IOBUFFER_SIZE];
- int read;
- int len = 0;
-
- SwapFile swapFile = SwapFile.get(swapDirectory, cid + orderNumber + "." +
version);
- OutputStream out = new FileOutputStream(swapFile);;
-
- if (swapFile.isSpooled())
- {
- return swapFile;
- }
-
- try
- {
- if (content != null)
- while ((read = content.read(spoolBuffer)) >= 0)
- {
- // spool to temp file
- out.write(spoolBuffer, 0, read);
- len += read;
- }
- }
- finally
- {
- out.close();
- swapFile.spoolDone();
- }
-
- return swapFile;
- }
-
- /**
- * Add Values to Property record.
- *
- * @param data
- * PropertyData
- * @throws SQLException
- * database error
- * @throws IOException
- * I/O error
- * @thorws RepositoryException if Value data large of JDBC accepted
(Integer.MAX_VALUE)
- */
- protected void addValues(String cid, PropertyData data) throws IOException,
SQLException, RepositoryException
- {
- List<ValueData> vdata = data.getValues();
-
- for (int i = 0; i < vdata.size(); i++)
- {
- ValueData vd = vdata.get(i);
- ValueIOChannel channel = valueStorageProvider.getApplicableChannel(data, i);
- InputStream stream;
- int streamLength;
- String storageId;
- if (channel == null)
- {
- // prepare write of Value in database
- if (vd.isByteArray())
- {
- byte[] dataBytes = vd.getAsByteArray();
- stream = new ByteArrayInputStream(dataBytes);
- streamLength = dataBytes.length;
- }
- else
- {
- // it's StreamPersistedValueData
- StreamPersistedValueData streamData = (StreamPersistedValueData)vd;
- stream = streamData.getStream();
-
- // TODO spool on JDBC driver read - multiplexing the data to two stores,
database and spool file, with one read.
- SwapFile swapFile = swapValueData(cid, i, data.getPersistedVersion(),
stream);
-
- long vlen = swapFile.length();
- if (vlen < 0)
- {
- // TODO not actual with SwapFile, but if it will be reworked can be so
- streamLength = stream.available();
- LOG.warn("Cannot obtain exact Value data length, will use
available from the stream " + streamLength
- + ". Property " + data.getQPath().getAsString());
- }
- else if (vlen <= Integer.MAX_VALUE)
- {
- streamLength = (int)vlen;
- }
- else
- {
- throw new RepositoryException("Value data large of allowed by JDBC
(Integer.MAX_VALUE) " + vlen
- + ". Property " + data.getQPath().getAsString());
- }
-
- // set persistent file to ValueData, will be available for saving
Property.
- streamData.setPersistedFile(swapFile);
- stream = streamData.getAsStream();
- }
- storageId = null;
- }
- else
- {
- // write Value in external VS
- channel.write(data.getIdentifier(), vd);
- valueChanges.add(channel);
- storageId = channel.getStorageId();
- stream = null;
- streamLength = 0;
- }
- addValueData(cid, i, stream, streamLength, storageId);
- }
- }
-
- protected abstract int addNodeRecord(NodeData data) throws SQLException;
-
- protected abstract int addPropertyRecord(PropertyData prop) throws SQLException;
-
- protected abstract ResultSet findItemByIdentifier(String identifier) throws
SQLException;
-
- protected abstract ResultSet findPropertyByName(String parentId, String name) throws
SQLException;
-
- protected abstract ResultSet findItemByName(String parentId, String name, int index)
throws SQLException;
-
- protected abstract ResultSet findChildNodesByParentIdentifier(String parentIdentifier)
throws SQLException;
-
- protected abstract ResultSet findChildNodesCountByParentIdentifier(String
parentIdentifier) throws SQLException;
-
- protected abstract ResultSet findChildPropertiesByParentIdentifier(String
parentIdentifier) throws SQLException;
-
- protected abstract int addReference(PropertyData data) throws SQLException,
IOException;
-
- protected abstract int renameNode(NodeData data) throws SQLException;
-
- protected abstract int deleteReference(String propertyIdentifier) throws
SQLException;
-
- protected abstract ResultSet findReferences(String nodeIdentifier) throws
SQLException;
-
- protected abstract int deleteItemByIdentifier(String identifier) throws SQLException;
-
- protected abstract int updateNodeByIdentifier(int version, int index, int orderNumb,
String identifier)
- throws SQLException;
-
- protected abstract int updatePropertyByIdentifier(int version, int type, String
identifier) throws SQLException;
-
- // -------- values processing ------------
- protected abstract int addValueData(String cid, int orderNumber, InputStream stream,
int streamLength,
- String storageId) throws SQLException;
-
- protected abstract int deleteValueData(String cid) throws SQLException;
-
- protected abstract ResultSet findValuesByPropertyId(String cid) throws SQLException;
-
- protected abstract ResultSet findValuesStorageDescriptorsByPropertyId(String cid)
throws SQLException;
-
- @Deprecated
- protected abstract ResultSet findValueByPropertyIdOrderNumber(String cid, int
orderNumb) throws SQLException;
-
- protected abstract ResultSet findItemByIdentifierNew(String identifier) throws
SQLException;
-
- protected abstract ResultSet findItemByNameNew(String parentId, String name, int
index) throws SQLException;
-
- protected abstract ResultSet findChildNodesByParentIdentifierNew(String
parentIdentifier) throws SQLException;
-
- protected abstract ResultSet getChildPropertiesByParentIdentifier(String
parentIdentifier) throws SQLException;
-
- protected abstract ResultSet findReferenceProperties(String parentIdentifier) throws
SQLException;
-}
Deleted:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCWorkspaceDataContainer.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCWorkspaceDataContainer.java 2009-12-25
15:51:39 UTC (rev 1193)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewJDBCWorkspaceDataContainer.java 2009-12-25
15:55:34 UTC (rev 1194)
@@ -1,802 +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.storage.jdbc.optimisation;
-
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.RepositoryEntry;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.impl.storage.WorkspaceDataContainerBase;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
-import org.exoplatform.services.jcr.impl.storage.jdbc.db.GenericConnectionFactory;
-import org.exoplatform.services.jcr.impl.storage.jdbc.db.OracleConnectionFactory;
-import
org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
-import org.exoplatform.services.jcr.impl.storage.jdbc.init.DBInitializer;
-import org.exoplatform.services.jcr.impl.storage.jdbc.init.DBInitializerException;
-import org.exoplatform.services.jcr.impl.storage.jdbc.init.IngresSQLDBInitializer;
-import org.exoplatform.services.jcr.impl.storage.jdbc.init.OracleDBInitializer;
-import org.exoplatform.services.jcr.impl.storage.jdbc.init.PgSQLDBInitializer;
-import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.HSQLDBConnectionFactory;
-import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.MySQLConnectionFactory;
-import org.exoplatform.services.jcr.impl.storage.jdbc.update.StorageUpdateManager;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
-import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.services.naming.InitialContextInitializer;
-import org.picocontainer.Startable;
-
-import java.io.File;
-import java.io.IOException;
-import java.sql.Connection;
-
-import javax.jcr.RepositoryException;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
- * @version $Id:GenericWorkspaceDataContainer.java 13433 2007-03-15 16:07:23Z peterit $
- */
-public class NewJDBCWorkspaceDataContainer extends WorkspaceDataContainerBase implements
Startable
-{
-
- protected static final Log LOG =
ExoLogger.getLogger("jcr.JDBCWorkspaceDataContainer");
-
- //configuration params
-
- public final static String SOURCE_NAME = "source-name";
-
- public final static String MULTIDB = "multi-db";
-
- public final static String SINGLEDB = "single-db";
-
- /**
- * Describe which type of RDBMS will be used (DB creation metadata etc.)
- */
- public final static String DB_DIALECT = "dialect";
-
- public final static String DB_DRIVER = "driverClassName";
-
- public final static String DB_URL = "url";
-
- public final static String DB_USERNAME = "username";
-
- public final static String DB_PASSWORD = "password";
-
- protected final String containerName;
-
- protected final String dbSourceName;
-
- protected final boolean multiDb;
-
- protected final String dbDriver;
-
- protected final String dbDialect;
-
- protected final String dbUrl;
-
- protected final String dbUserName;
-
- protected final String dbPassword;
-
- protected final ValueStoragePluginProvider valueStorageProvider;
-
- protected String storageVersion;
-
- protected int maxBufferSize;
-
- protected File swapDirectory;
-
- protected FileCleaner swapCleaner;
-
- protected GenericConnectionFactory connFactory;
-
- /**
- * Shared connection factory.
- *
- * Issued to share JDBC connection between system and regular workspace in case of
same database
- * used for storage.
- *
- */
- class SharedConnectionFactory extends GenericConnectionFactory
- {
-
- /**
- * JDBC connection.
- */
- final private Connection connection;
-
- /**
- * SharedConnectionFactory constructor.
- *
- * @param connection
- * JDBC - connection
- * @param containerName
- * - container name
- * @param multiDb
- * - multidatabase status
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- */
- SharedConnectionFactory(Connection connection, String containerName, boolean
multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File
swapDirectory, FileCleaner swapCleaner)
- {
-
- super(null, null, null, null, null, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
-
- this.connection = connection;
- }
-
- /**
- * {@inheritDoc}
- */
- public Connection getJdbcConnection() throws RepositoryException
- {
- return connection;
- }
- }
-
- /**
- * Constructor with value storage plugins.
- *
- * @param wsConfig
- * Workspace configuration
- * @param valueStrorageProvider
- * External Value Stprages provider
- * @throws RepositoryConfigurationException
- * if Repository configuration is wrong
- * @throws NamingException
- * if JNDI exception (on DataSource lookup)
- */
- public NewJDBCWorkspaceDataContainer(WorkspaceEntry wsConfig, RepositoryEntry
repConfig,
- InitialContextInitializer contextInit, ValueStoragePluginProvider
valueStorageProvider)
- throws RepositoryConfigurationException, NamingException, RepositoryException,
IOException
- {
-
- checkIntegrity(wsConfig, repConfig);
-
- this.containerName = wsConfig.getName();
- this.multiDb =
Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
- this.valueStorageProvider = valueStorageProvider;
-
- // ------------- Database config ------------------
- String pDbDialect = null;
- try
- {
- pDbDialect =
detectDialect(wsConfig.getContainer().getParameterValue(DB_DIALECT));
- LOG.info("Using a dialect '" + pDbDialect + "'");
- }
- catch (RepositoryConfigurationException e)
- {
- LOG.info("Using a default dialect '" +
DBConstants.DB_DIALECT_GENERIC + "'");
- pDbDialect = DBConstants.DB_DIALECT_GENERIC;
- }
- this.dbDialect = pDbDialect;
-
- String pDbDriver = null;
- String pDbUrl = null;
- String pDbUserName = null;
- String pDbPassword = null;
- try
- {
- pDbDriver = wsConfig.getContainer().getParameterValue(DB_DRIVER);
-
- // username/passwd may not pesent
- try
- {
- pDbUserName = wsConfig.getContainer().getParameterValue(DB_USERNAME);
- pDbPassword = wsConfig.getContainer().getParameterValue(DB_PASSWORD);
- }
- catch (RepositoryConfigurationException e)
- {
- pDbUserName = pDbPassword = null;
- }
-
- pDbUrl = wsConfig.getContainer().getParameterValue(DB_URL); // last here!
- }
- catch (RepositoryConfigurationException e)
- {
- }
-
- if (pDbUrl != null)
- {
- this.dbDriver = pDbDriver;
- this.dbUrl = pDbUrl;
- this.dbUserName = pDbUserName;
- this.dbPassword = pDbPassword;
- this.dbSourceName = null;
- LOG.info("Connect to JCR database as user '" + this.dbUserName +
"'");
- }
- else
- {
- this.dbDriver = null;
- this.dbUrl = null;
- this.dbUserName = null;
- this.dbPassword = null;
-
- String sn;
- try
- {
- sn = wsConfig.getContainer().getParameterValue(SOURCE_NAME);
- }
- catch (RepositoryConfigurationException e)
- {
- sn = wsConfig.getContainer().getParameterValue("sourceName"); //
TODO for backward comp,
- // remove in rel.2.0
- }
- this.dbSourceName = sn;
- }
-
- // ------------- Values swap config ------------------
- try
- {
- this.maxBufferSize =
wsConfig.getContainer().getParameterInteger(MAXBUFFERSIZE_PROP);
- }
- catch (RepositoryConfigurationException e)
- {
- this.maxBufferSize = DEF_MAXBUFFERSIZE;
- }
-
- try
- {
- String sdParam = wsConfig.getContainer().getParameterValue(SWAPDIR_PROP);
- this.swapDirectory = new File(sdParam);
- }
- catch (RepositoryConfigurationException e1)
- {
- this.swapDirectory = new File(DEF_SWAPDIR);
- }
- if (!swapDirectory.exists())
- swapDirectory.mkdirs();
-
- this.swapCleaner = new FileCleaner(false);
-
- initDatabase();
-
- String suParam = null;
- boolean enableStorageUpdate = false;
- try
- {
- suParam =
wsConfig.getContainer().getParameterValue("update-storage");
- enableStorageUpdate = Boolean.parseBoolean(suParam);
- }
- catch (RepositoryConfigurationException e)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("update-storage parameter is not set " + dbSourceName);
- }
-
- this.storageVersion =
- StorageUpdateManager.checkVersion(dbSourceName,
this.connFactory.getJdbcConnection(), multiDb,
- enableStorageUpdate);
-
- LOG.info(getInfo());
- }
-
- /**
- * Prepare sefault connection factory.
- *
- * @return GenericConnectionFactory
- * @throws NamingException
- * on JNDI error
- * @throws RepositoryException
- * on Storage error
- */
- protected GenericConnectionFactory defaultConnectionFactory() throws NamingException,
RepositoryException
- {
- // by default
- if (dbSourceName != null)
- {
- DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
- if (ds != null)
- return new GenericConnectionFactory(ds, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
-
- throw new RepositoryException("Datasource '" + dbSourceName +
"' is not bound in this context.");
- }
-
- return new GenericConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
- }
-
- /**
- * Prepare default DB initializer.
- *
- * @param sqlPath
- * - path to SQL script (database creation script)
- * @return DBInitializer instance
- * @throws NamingException
- * on JNDI error
- * @throws RepositoryException
- * on Storage error
- * @throws IOException
- * on I/O error
- */
- protected DBInitializer defaultDBInitializer(String sqlPath) throws NamingException,
RepositoryException,
- IOException
- {
- return new DBInitializer(containerName, this.connFactory.getJdbcConnection(),
sqlPath, multiDb);
- }
-
- /**
- * Checks if DataSources used in right manner.
- *
- * @param wsConfig
- * Workspace configuration
- * @param repConfig
- * Repository configuration
- * @throws RepositoryConfigurationException
- * in case of configuration errors
- */
- protected void checkIntegrity(WorkspaceEntry wsConfig, RepositoryEntry repConfig)
- throws RepositoryConfigurationException
- {
- boolean isMulti;
- for (WorkspaceEntry wsEntry : repConfig.getWorkspaceEntries())
- {
- if (wsEntry.getName().equals(wsConfig.getName())
- ||
!wsEntry.getContainer().getType().equals(wsConfig.getContainer().getType())
- || !wsEntry.getContainer().getType().equals(this.getClass().getName()))
- continue;
-
- // MULTIDB
- if (!wsEntry.getContainer().getParameterValue(MULTIDB).equals(
- wsConfig.getContainer().getParameterValue(MULTIDB)))
- {
- throw new RepositoryConfigurationException("All workspaces must be
" + MULTIDB + " or " + SINGLEDB
- + ". But " + wsEntry.getName() + "- multi-db=" +
wsEntry.getContainer().getParameterValue(MULTIDB)
- + " and " + wsConfig.getName() + "- multi-db=" +
wsConfig.getContainer().getParameterValue(MULTIDB));
- }
-
- isMulti =
Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
-
- // source name
- String wsSourceName = null;
- String newWsSourceName = null;
- try
- {
- wsSourceName =
wsEntry.getContainer().getParameterValue("sourceName");
- newWsSourceName =
wsConfig.getContainer().getParameterValue("sourceName");
- }
- catch (RepositoryConfigurationException e)
- {
- }
-
- if (wsSourceName != null && newWsSourceName != null)
- {
- if (isMulti)
- {
- if (wsSourceName.equals(newWsSourceName))
- {
- throw new RepositoryConfigurationException("SourceName " +
wsSourceName + " alredy in use in "
- + wsEntry.getName() + ". SourceName must be different in "
+ MULTIDB
- + ". Check configuration for " + wsConfig.getName());
- }
- }
- else
- {
- if (!wsSourceName.equals(newWsSourceName))
- {
- throw new RepositoryConfigurationException("SourceName must be
equals in " + SINGLEDB + " "
- + "repository." + " Check " + wsEntry.getName()
+ " and " + wsConfig.getName());
- }
- }
- continue;
- }
-
- // db-url
- String wsUri = null;
- String newWsUri = null;
- try
- {
- wsUri = wsEntry.getContainer().getParameterValue("db-url");
- newWsUri = wsConfig.getContainer().getParameterValue("db-url");
- }
- catch (RepositoryConfigurationException e)
- {
- }
-
- if (wsUri != null && newWsUri != null)
- {
- if (isMulti)
- {
- if (wsUri.equals(newWsUri))
- {
- throw new RepositoryConfigurationException("db-url " + wsUri
+ " alredy in use in "
- + wsEntry.getName() + ". db-url must be different in " +
MULTIDB + ". Check configuration for "
- + wsConfig.getName());
-
- }
- }
- else
- {
- if (!wsUri.equals(newWsUri))
- {
- throw new RepositoryConfigurationException("db-url must be equals
in " + SINGLEDB + " "
- + "repository." + " Check " + wsEntry.getName()
+ " and " + wsConfig.getName());
- }
- }
- }
- }
- }
-
- /**
- * Init storage database.
- *
- * @throws NamingException
- * on JNDI error
- * @throws RepositoryException
- * on storage error
- * @throws IOException
- * on I/O error
- */
- protected void initDatabase() throws NamingException, RepositoryException,
IOException
- {
-
- DBInitializer dbInitilizer = null;
- String sqlPath = null;
- if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
- {
- LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is
experimental!");
- // sample of connection factory customization
- if (dbSourceName != null)
- this.connFactory = defaultConnectionFactory();
- else
- this.connFactory =
- new OracleConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
-
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ora.sql";
-
- // a particular db initializer may be configured here too
- dbInitilizer = new OracleDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_ORACLE)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ora.sql";
- dbInitilizer = new OracleDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_PGSQL)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.pgsql.sql";
- dbInitilizer = new PgSQLDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_MYSQL)
- {
- // [PN] 28.06.07
- if (dbSourceName != null)
- {
- DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
- if (ds != null)
- this.connFactory =
- new MySQLConnectionFactory(ds, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
- else
- throw new RepositoryException("Datasource '" + dbSourceName
+ "' is not bound in this context.");
- }
- else
- this.connFactory =
- new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
-
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mysql.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8)
- {
- // [PN] 13.07.08
- if (dbSourceName != null)
- {
- DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
- if (ds != null)
- this.connFactory =
- new MySQLConnectionFactory(ds, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
- else
- throw new RepositoryException("Datasource '" + dbSourceName
+ "' is not bound in this context.");
- }
- else
- this.connFactory =
- new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
-
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mysql-utf8.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_MSSQL)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.mssql.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_DERBY)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.derby.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_DB2)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.db2.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_DB2V8)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.db2v8.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_SYBASE)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.sybase.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_INGRES)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.ingres.sql";
- // using Postgres initializer
- dbInitilizer =
- new IngresSQLDBInitializer(containerName,
this.connFactory.getJdbcConnection(), sqlPath, multiDb);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_HSQLDB)
- {
- if (dbSourceName != null)
- {
- DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
- if (ds != null)
- this.connFactory =
- new HSQLDBConnectionFactory(ds, containerName, multiDb,
valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
- else
- throw new RepositoryException("Datasource '" + dbSourceName
+ "' is not bound in this context.");
- }
- else
- this.connFactory =
- new HSQLDBConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword,
containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else
- {
- // generic, DB_HSQLDB
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" :
"s") + "jdbc.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
-
- // database type
- try
- {
- dbInitilizer.init();
- }
- catch (DBInitializerException e)
- {
- LOG.error("Error of init db " + e, e);
- }
- }
-
- /**
- * Return ConnectionFactory.
- *
- * @return WorkspaceStorageConnectionFactory connection
- */
- protected GenericConnectionFactory getConnectionFactory()
- {
- return connFactory;
- }
-
- protected String detectDialect(String confParam)
- {
- for (String dbType : DBConstants.DB_DIALECTS)
- {
- if (dbType.equalsIgnoreCase(confParam))
- return dbType;
- }
-
- return DBConstants.DB_DIALECT_GENERIC; // by default
- }
-
- /**
- * {@inheritDoc}
- */
- public WorkspaceStorageConnection openConnection() throws RepositoryException
- {
-
- return connFactory.openConnection();
- }
-
- /**
- * {@inheritDoc}
- */
- public WorkspaceStorageConnection openConnection(boolean readOnly) throws
RepositoryException
- {
-
- return connFactory.openConnection(readOnly);
- }
-
- /**
- * {@inheritDoc}
- */
- public WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original)
throws RepositoryException
- {
-
- if (original instanceof NewJDBCStorageConnection)
- {
- WorkspaceStorageConnectionFactory cFactory =
- new
SharedConnectionFactory(((NewJDBCStorageConnection)original).getJdbcConnection(),
containerName,
- multiDb, valueStorageProvider, maxBufferSize, swapDirectory,
swapCleaner);
-
- return cFactory.openConnection();
- }
- else
- {
- return openConnection();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public String getName()
- {
- return containerName;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getInfo()
- {
- String str =
- "JDBC based JCR Workspace Data container \n" + "container name:
" + containerName + " \n"
- + "data source JNDI name: " + dbSourceName + "\n" +
"is multi database: " + multiDb + "\n"
- + "storage version: " + storageVersion + "\n" +
"value storage provider: " + valueStorageProvider + "\n"
- + "max buffer size (bytes): " + maxBufferSize + "\n" +
"swap directory path: "
- + swapDirectory.getAbsolutePath();
- return str;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getStorageVersion()
- {
- return storageVersion;
- }
-
- /**
- * {@inheritDoc}
- */
- public void start()
- {
- this.swapCleaner.start();
- }
-
- /**
- * {@inheritDoc}
- */
- public void stop()
- {
- this.swapCleaner.halt();
- this.swapCleaner.interrupt();
-
- // TODO HSQLDB Stop (debug)
- // if (dbDialect.equals(DB_DIALECT_GENERIC) ||
- // dbDialect.equals(DB_DIALECT_HSQLDB)) {
- // // shutdown in-process HSQLDB database
- // System.out.println("Shutdown in-process HSQLDB database...");
- // try {
- // JDBCStorageConnection conn = (JDBCStorageConnection) openConnection();
- // Connection jdbcConn = conn.getJdbcConnection();
- // String dbUrl = jdbcConn.getMetaData().getURL();
- // if (dbUrl.startsWith("jdbc:hsqldb:file") ||
- // dbUrl.startsWith("jdbc:hsqldb:mem")) {
- // // yeah, there is in-process hsqldb, shutdown it now
- // jdbcConn.createStatement().execute("SHUTDOWN");
- // System.out.println("Shutdown in-process HSQLDB database... done.");
- // }
- // } catch (Throwable e) {
- // log.error("JDBC Data container stop error " + e);
- // e.printStackTrace();
- // }
- // }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isSame(WorkspaceDataContainer another)
- {
- if (another == this)
- return true;
-
- if (another instanceof NewJDBCWorkspaceDataContainer)
- {
- NewJDBCWorkspaceDataContainer anotherJdbc =
(NewJDBCWorkspaceDataContainer)another;
-
- if (getDbSourceName() != null)
- // by jndi ds name
- return getDbSourceName().equals(anotherJdbc.getDbSourceName());
-
- // by db connection params
- return getDbDriver().equals(anotherJdbc.getDbDriver()) &&
getDbUrl().equals(anotherJdbc.getDbUrl())
- && getDbUserName().equals(anotherJdbc.getDbUserName());
- }
-
- return false;
- }
-
- /**
- * Used in <code>equals()</code>.
- *
- * @return DataSource name
- */
- protected String getDbSourceName()
- {
- return dbSourceName;
- }
-
- /**
- * Used in <code>equals()</code>.
- *
- * @return JDBC driver
- */
- protected String getDbDriver()
- {
- return dbDriver;
- }
-
- /**
- * Used in <code>equals()</code>.
- *
- * @return Database URL
- */
- protected String getDbUrl()
- {
- return dbUrl;
- }
-
- /**
- * Used in <code>equals()</code>.
- *
- * @return Database username
- */
- protected String getDbUserName()
- {
- return dbUserName;
- }
-}
Deleted:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewSQLExceptionHandler.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewSQLExceptionHandler.java 2009-12-25
15:51:39 UTC (rev 1193)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/NewSQLExceptionHandler.java 2009-12-25
15:55:34 UTC (rev 1194)
@@ -1,395 +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.storage.jdbc.optimisation;
-
-import org.exoplatform.services.jcr.dataflow.ItemState;
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
-import org.exoplatform.services.jcr.impl.storage.JCRItemExistsException;
-
-import java.io.IOException;
-import java.sql.SQLException;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.ItemExistsException;
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * The eXo JCR database has constraints can be violated.
- *
- * JCR_PK_XCONTAINER - Can not be exisits two containers with same version
- *
- * JCR_PK_XITEM - Item already exists with this ID JCR_FK_XITEM_PARENT - Parent not found
by ID
- * JCR_IDX_XITEM_PARENT - Item already exists with the parent, name, index, type(N/P),
persisted
- * version JCR_IDX_XITEM_PARENT_NAME - Item already exists with the type(N/P), parent,
name, index,
- * persisted version JCR_IDX_XITEM_PARENT_ID - Item already exists with the type(N/P),
parent, ID,
- * persisted version
- *
- * JCR_PK_XVALUE - Value already exists with the ID (impossible, ID is autiincremented)
- * JCR_FK_XVALUE_PROPERTY - There is no property exists for the value.
JCR_IDX_XVALUE_PROPERTY -
- * Value already exists with the property and order number
- *
- * JCR_PK_XREF - Reference already exists to the node from property with order number
- * JCR_IDX_XREF_PROPERTY - Reference already exists with the property and order number
- *
- * @author Peter Nedonosko
- * @version $Id: SQLExceptionHandler.java 34801 2009-07-31 15:44:50Z dkatayev $
- */
-
-public class NewSQLExceptionHandler
-{
-
- /**
- * Ccontainer name.
- */
- private final String containerName;
-
- /**
- * Storage connection.
- */
- private final NewJDBCStorageConnection conn;
-
- // ---------------- SQLException handler -------------------
-
- /**
- * SQLExceptionHandler constructor.
- *
- * @param containerName
- * - workspace container name
- * @param conn
- * - storage connection
- */
- NewSQLExceptionHandler(String containerName, NewJDBCStorageConnection conn)
- {
- this.containerName = containerName;
- this.conn = conn;
- }
-
- /**
- * Handle Add SQLException.
- *
- * @param e
- * - an SQLException
- * @param item
- * - context ItemData
- * @return String with error message
- * @throws RepositoryException
- * if <code>RepositoryException</code> should be thrown
- * @throws InvalidItemStateException
- * if <code>InvalidItemStateException</code> should be thrown
- */
- protected String handleAddException(SQLException e, ItemData item) throws
RepositoryException,
- InvalidItemStateException
- {
- String message = "[" + containerName + "] ADD " +
(item.isNode() ? "NODE. " : "PROPERTY. ");
- String errMessage = e.getMessage();
- String itemInfo =
- item.getQPath().getAsString() + ", ID: " + item.getIdentifier() +
", ParentID: " + item.getParentIdentifier()
- + (errMessage != null ? ". Cause >>>> " + errMessage :
"");
-
- if (errMessage != null)
- {
- // try detect error by foreign key names
- String umsg = errMessage.toLowerCase().toUpperCase();
- if (umsg.indexOf(conn.JCR_FK_ITEM_PARENT) >= 0)
- {
- message += "Parent not found. Item " + itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.ADDED, e);
- }
- else if (umsg.indexOf(conn.JCR_PK_ITEM) >= 0)
- {
- message += "Item already exists. Condition: ID. " + itemInfo;
- // InvalidItemStateException ! - because it's impossible add new item
with existed UUID
- throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.ADDED, e);
- }
- else if (umsg.indexOf(conn.JCR_IDX_ITEM_PARENT) >= 0 ||
umsg.indexOf(conn.JCR_IDX_ITEM_PARENT_NAME) >= 0)
- {
- message += "Item already exists. Condition: parent ID, name, index.
" + itemInfo;
- throw new ItemExistsException(message, e);
- }
- else if (umsg.indexOf(conn.JCR_IDX_ITEM_PARENT_ID) >= 0)
- {
- message += "Item already exists. Condition: parent ID and ID. " +
itemInfo;
- throw new ItemExistsException(message, e);
- }
- else if (umsg.indexOf(conn.JCR_FK_VALUE_PROPERTY) >= 0)
- {
- message += "Property is not exist but the value is being created.
Condition: property ID. " + itemInfo;
- throw new RepositoryException(message, e);
- }
- else if (umsg.indexOf(conn.JCR_IDX_VALUE_PROPERTY) >= 0)
- {
- message += "Property already exists. Condition: property ID, order
number. " + itemInfo;
- throw new RepositoryException(message, e);
- }
- else if (umsg.indexOf(conn.JCR_PK_VALUE) >= 0)
- {
- message +=
- "[FATAL] Value already exists with the ValueID. Impossible state,
check is ValueID is autoincremented. "
- + itemInfo;
- throw new RepositoryException(message, e);
- }
- else if (umsg.indexOf(conn.JCR_PK_REF) >= 0)
- {
- message += "Reference chain already exists. Condition: node ID, property
ID, order number. " + itemInfo;
- throw new RepositoryException(message, e);
- }
- else if (umsg.indexOf(conn.JCR_IDX_REF_PROPERTY) >= 0)
- {
- message += "Referenceable property value already exists. Condition:
property ID, order number. " + itemInfo;
- throw new RepositoryException(message, e);
- }
- }
-
- // try detect integrity violation
- RepositoryException ownException = null;
- try
- {
- NodeData parent = (NodeData)conn.getItemData(item.getParentIdentifier());
- if (parent != null)
- {
- // have a parent
- try
- {
- ItemData me = conn.getItemData(item.getIdentifier());
- if (me != null)
- {
- // item already exists
- message += "Item already exists in storage: " + itemInfo;
- ownException = new JCRItemExistsException(message, me.getIdentifier(),
ItemState.ADDED, e);
- throw ownException;
- }
-
- me = conn.getItemData(parent, new QPathEntry(item.getQPath().getName(),
item.getQPath().getIndex()));
- if (me != null)
- {
- message += "Item already exists in storage: " + itemInfo;
- ownException = new JCRItemExistsException(message, me.getIdentifier(),
ItemState.ADDED, e);
- throw ownException;
- }
-
- }
- catch (Exception ep)
- {
- // item not found or other things but error of item reading
- if (ownException != null)
- throw ownException;
- }
-
- // MySQL violation
- if
(e.getClass().getName().indexOf("MySQLIntegrityConstraintViolationException")
>= 0
- && errMessage.indexOf(item.getIdentifier()) >= 0)
- {
- // it's JCR_PK_ITEM violation
- message += "Item already exists. Condition: ID. " + itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.ADDED, e);
- }
-
- message += "Error of item add. " + itemInfo;
- ownException = new RepositoryException(message, e);
- throw ownException;
- }
- }
- catch (Exception ep)
- {
- // no parent or error access it
- if (ownException != null)
- throw ownException;
- }
- message += "Error of item add. " + itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.ADDED, e);
- }
-
- /**
- * Handle Add IOException.
- *
- * @param e
- * - an IOException
- * @param item
- * - context ItemData
- * @return String with error message
- * @throws RepositoryException
- * if <code>RepositoryException</code> should be thrown
- * @throws InvalidItemStateException
- * if <code>InvalidItemStateException</code> should be thrown
- */
- protected String handleAddException(IOException e, ItemData item) throws
RepositoryException,
- InvalidItemStateException
- {
- String message = "[" + containerName + "] ADD " +
(item.isNode() ? "NODE. " : "PROPERTY. ");
- String errMessage = e.getMessage();
- String itemInfo =
- item.getQPath().getAsString() + ", ID: " + item.getIdentifier() +
", ParentID: " + item.getParentIdentifier()
- + (errMessage != null ? ". Cause >>>> " + errMessage :
"");
-
- // try detect integrity violation
- RepositoryException ownException = null;
- try
- {
- NodeData parent = (NodeData)conn.getItemData(item.getParentIdentifier());
- if (parent != null)
- {
- // have a parent
- try
- {
- ItemData me = conn.getItemData(item.getIdentifier());
- if (me != null)
- {
- // item already exists
- message += "Item already exists in storage: " + itemInfo;
- ownException = new ItemExistsException(message, e);
- throw ownException;
- }
-
- me = conn.getItemData(parent, new QPathEntry(item.getQPath().getName(),
item.getQPath().getIndex()));
- if (me != null)
- {
- message += "Item already exists in storage: " + itemInfo;
- ownException = new ItemExistsException(message, e);
- throw ownException;
- }
-
- }
- catch (Exception ep)
- {
- // item not found or other things but error of item reading
- if (ownException != null)
- throw ownException;
- }
- message += "Error of item add. " + itemInfo;
- ownException = new RepositoryException(message, e);
- throw ownException;
- }
- }
- catch (Exception ep)
- {
- // no parent or error access it
- if (ownException != null)
- throw ownException;
- }
- message += "Error of item add. " + itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.ADDED, e);
- }
-
- /**
- * Handle delete Exceptions.
- *
- * @param e
- * - an SQLException
- * @param item
- * - context ItemData
- * @return String with error message
- * @throws RepositoryException
- * if <code>RepositoryException</code> should be thrown
- * @throws InvalidItemStateException
- * if <code>InvalidItemStateException</code> should be thrown
- */
- protected String handleDeleteException(SQLException e, ItemData item) throws
RepositoryException,
- InvalidItemStateException
- {
- String message = "[" + containerName + "] DELETE " +
(item.isNode() ? "NODE. " : "PROPERTY. ");
- String errMessage = e.getMessage();
- String itemInfo =
- item.getQPath().getAsString() + " " + item.getIdentifier()
- + (errMessage != null ? ". Cause >>>> " + errMessage :
"");
-
- if (errMessage != null)
- {
- // try detect error by foreign key names
- String umsg = errMessage.toLowerCase().toUpperCase();
- if (umsg.indexOf(conn.JCR_FK_ITEM_PARENT) >= 0)
- {
- message += "Can not delete parent till childs exists. Item " +
itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.DELETED, e);
- }
- else if (umsg.indexOf(conn.JCR_FK_VALUE_PROPERTY) >= 0)
- {
- message +=
- "[FATAL] Can not delete property item till it contains values.
Condition: property ID. " + itemInfo;
- throw new RepositoryException(message, e);
- }
- }
-
- message += "Error of item delete " + itemInfo;
- throw new RepositoryException(message, e);
- }
-
- /**
- * Handle update Exceptions.
- *
- * @param e
- * - an SQLException
- * @param item
- * - context ItemData
- * @return String with error message
- * @throws RepositoryException
- * if <code>RepositoryException</code> should be thrown
- * @throws InvalidItemStateException
- * if <code>InvalidItemStateException</code> should be thrown
- */
- protected String handleUpdateException(SQLException e, ItemData item) throws
RepositoryException,
- InvalidItemStateException
- {
- String message = "[" + containerName + "] EDIT " +
(item.isNode() ? "NODE. " : "PROPERTY. ");
- String errMessage = e.getMessage();
- String itemInfo =
- item.getQPath().getAsString() + " " + item.getIdentifier()
- + (errMessage != null ? ". Cause >>>> " + errMessage :
"");
-
- if (errMessage != null)
- // try detect error by foreign key names
- if (errMessage.toLowerCase().toUpperCase().indexOf(conn.JCR_FK_VALUE_PROPERTY)
>= 0)
- {
- message += "Property is not exists but the value is being created.
Condition: property ID. " + itemInfo;
- throw new RepositoryException(message, e);
- }
- else if (errMessage.toLowerCase().toUpperCase().indexOf(conn.JCR_PK_ITEM) >=
0)
- {
- message += "Item already exists. Condition: ID. " + itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.UPDATED, e);
- }
-
- // try detect integrity violation
- RepositoryException ownException = null;
- try
- {
- ItemData me = conn.getItemData(item.getIdentifier());
- if (me != null)
- {
- // item already exists
- message += "Item already exists. But update errors. " + itemInfo;
- ownException = new RepositoryException(message, e);
- throw ownException;
- }
- }
- catch (Exception ep)
- {
- // item not found or other things but error of item reading
- if (ownException != null)
- throw ownException;
- }
- message += "Error of item update. " + itemInfo;
- throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.UPDATED, e);
- }
-
-}
Added:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/SQLExceptionHandler.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/SQLExceptionHandler.java
(rev 0)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/SQLExceptionHandler.java 2009-12-25
15:55:34 UTC (rev 1194)
@@ -0,0 +1,395 @@
+/*
+ * 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.storage.jdbc.optimisation;
+
+import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
+import org.exoplatform.services.jcr.impl.storage.JCRItemExistsException;
+
+import java.io.IOException;
+import java.sql.SQLException;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * The eXo JCR database has constraints can be violated.
+ *
+ * JCR_PK_XCONTAINER - Can not be exisits two containers with same version
+ *
+ * JCR_PK_XITEM - Item already exists with this ID JCR_FK_XITEM_PARENT - Parent not found
by ID
+ * JCR_IDX_XITEM_PARENT - Item already exists with the parent, name, index, type(N/P),
persisted
+ * version JCR_IDX_XITEM_PARENT_NAME - Item already exists with the type(N/P), parent,
name, index,
+ * persisted version JCR_IDX_XITEM_PARENT_ID - Item already exists with the type(N/P),
parent, ID,
+ * persisted version
+ *
+ * JCR_PK_XVALUE - Value already exists with the ID (impossible, ID is autiincremented)
+ * JCR_FK_XVALUE_PROPERTY - There is no property exists for the value.
JCR_IDX_XVALUE_PROPERTY -
+ * Value already exists with the property and order number
+ *
+ * JCR_PK_XREF - Reference already exists to the node from property with order number
+ * JCR_IDX_XREF_PROPERTY - Reference already exists with the property and order number
+ *
+ * @author Peter Nedonosko
+ * @version $Id: SQLExceptionHandler.java 34801 2009-07-31 15:44:50Z dkatayev $
+ */
+
+public class SQLExceptionHandler
+{
+
+ /**
+ * Ccontainer name.
+ */
+ private final String containerName;
+
+ /**
+ * Storage connection.
+ */
+ private final CQJDBCStorageConnection conn;
+
+ // ---------------- SQLException handler -------------------
+
+ /**
+ * SQLExceptionHandler constructor.
+ *
+ * @param containerName
+ * - workspace container name
+ * @param conn
+ * - storage connection
+ */
+ SQLExceptionHandler(String containerName, CQJDBCStorageConnection conn)
+ {
+ this.containerName = containerName;
+ this.conn = conn;
+ }
+
+ /**
+ * Handle Add SQLException.
+ *
+ * @param e
+ * - an SQLException
+ * @param item
+ * - context ItemData
+ * @return String with error message
+ * @throws RepositoryException
+ * if <code>RepositoryException</code> should be thrown
+ * @throws InvalidItemStateException
+ * if <code>InvalidItemStateException</code> should be thrown
+ */
+ protected String handleAddException(SQLException e, ItemData item) throws
RepositoryException,
+ InvalidItemStateException
+ {
+ String message = "[" + containerName + "] ADD " +
(item.isNode() ? "NODE. " : "PROPERTY. ");
+ String errMessage = e.getMessage();
+ String itemInfo =
+ item.getQPath().getAsString() + ", ID: " + item.getIdentifier() +
", ParentID: " + item.getParentIdentifier()
+ + (errMessage != null ? ". Cause >>>> " + errMessage :
"");
+
+ if (errMessage != null)
+ {
+ // try detect error by foreign key names
+ String umsg = errMessage.toLowerCase().toUpperCase();
+ if (umsg.indexOf(conn.JCR_FK_ITEM_PARENT) >= 0)
+ {
+ message += "Parent not found. Item " + itemInfo;
+ throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.ADDED, e);
+ }
+ else if (umsg.indexOf(conn.JCR_PK_ITEM) >= 0)
+ {
+ message += "Item already exists. Condition: ID. " + itemInfo;
+ // InvalidItemStateException ! - because it's impossible add new item
with existed UUID
+ throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.ADDED, e);
+ }
+ else if (umsg.indexOf(conn.JCR_IDX_ITEM_PARENT) >= 0 ||
umsg.indexOf(conn.JCR_IDX_ITEM_PARENT_NAME) >= 0)
+ {
+ message += "Item already exists. Condition: parent ID, name, index.
" + itemInfo;
+ throw new ItemExistsException(message, e);
+ }
+ else if (umsg.indexOf(conn.JCR_IDX_ITEM_PARENT_ID) >= 0)
+ {
+ message += "Item already exists. Condition: parent ID and ID. " +
itemInfo;
+ throw new ItemExistsException(message, e);
+ }
+ else if (umsg.indexOf(conn.JCR_FK_VALUE_PROPERTY) >= 0)
+ {
+ message += "Property is not exist but the value is being created.
Condition: property ID. " + itemInfo;
+ throw new RepositoryException(message, e);
+ }
+ else if (umsg.indexOf(conn.JCR_IDX_VALUE_PROPERTY) >= 0)
+ {
+ message += "Property already exists. Condition: property ID, order
number. " + itemInfo;
+ throw new RepositoryException(message, e);
+ }
+ else if (umsg.indexOf(conn.JCR_PK_VALUE) >= 0)
+ {
+ message +=
+ "[FATAL] Value already exists with the ValueID. Impossible state,
check is ValueID is autoincremented. "
+ + itemInfo;
+ throw new RepositoryException(message, e);
+ }
+ else if (umsg.indexOf(conn.JCR_PK_REF) >= 0)
+ {
+ message += "Reference chain already exists. Condition: node ID, property
ID, order number. " + itemInfo;
+ throw new RepositoryException(message, e);
+ }
+ else if (umsg.indexOf(conn.JCR_IDX_REF_PROPERTY) >= 0)
+ {
+ message += "Referenceable property value already exists. Condition:
property ID, order number. " + itemInfo;
+ throw new RepositoryException(message, e);
+ }
+ }
+
+ // try detect integrity violation
+ RepositoryException ownException = null;
+ try
+ {
+ NodeData parent = (NodeData)conn.getItemData(item.getParentIdentifier());
+ if (parent != null)
+ {
+ // have a parent
+ try
+ {
+ ItemData me = conn.getItemData(item.getIdentifier());
+ if (me != null)
+ {
+ // item already exists
+ message += "Item already exists in storage: " + itemInfo;
+ ownException = new JCRItemExistsException(message, me.getIdentifier(),
ItemState.ADDED, e);
+ throw ownException;
+ }
+
+ me = conn.getItemData(parent, new QPathEntry(item.getQPath().getName(),
item.getQPath().getIndex()));
+ if (me != null)
+ {
+ message += "Item already exists in storage: " + itemInfo;
+ ownException = new JCRItemExistsException(message, me.getIdentifier(),
ItemState.ADDED, e);
+ throw ownException;
+ }
+
+ }
+ catch (Exception ep)
+ {
+ // item not found or other things but error of item reading
+ if (ownException != null)
+ throw ownException;
+ }
+
+ // MySQL violation
+ if
(e.getClass().getName().indexOf("MySQLIntegrityConstraintViolationException")
>= 0
+ && errMessage.indexOf(item.getIdentifier()) >= 0)
+ {
+ // it's JCR_PK_ITEM violation
+ message += "Item already exists. Condition: ID. " + itemInfo;
+ throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.ADDED, e);
+ }
+
+ message += "Error of item add. " + itemInfo;
+ ownException = new RepositoryException(message, e);
+ throw ownException;
+ }
+ }
+ catch (Exception ep)
+ {
+ // no parent or error access it
+ if (ownException != null)
+ throw ownException;
+ }
+ message += "Error of item add. " + itemInfo;
+ throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.ADDED, e);
+ }
+
+ /**
+ * Handle Add IOException.
+ *
+ * @param e
+ * - an IOException
+ * @param item
+ * - context ItemData
+ * @return String with error message
+ * @throws RepositoryException
+ * if <code>RepositoryException</code> should be thrown
+ * @throws InvalidItemStateException
+ * if <code>InvalidItemStateException</code> should be thrown
+ */
+ protected String handleAddException(IOException e, ItemData item) throws
RepositoryException,
+ InvalidItemStateException
+ {
+ String message = "[" + containerName + "] ADD " +
(item.isNode() ? "NODE. " : "PROPERTY. ");
+ String errMessage = e.getMessage();
+ String itemInfo =
+ item.getQPath().getAsString() + ", ID: " + item.getIdentifier() +
", ParentID: " + item.getParentIdentifier()
+ + (errMessage != null ? ". Cause >>>> " + errMessage :
"");
+
+ // try detect integrity violation
+ RepositoryException ownException = null;
+ try
+ {
+ NodeData parent = (NodeData)conn.getItemData(item.getParentIdentifier());
+ if (parent != null)
+ {
+ // have a parent
+ try
+ {
+ ItemData me = conn.getItemData(item.getIdentifier());
+ if (me != null)
+ {
+ // item already exists
+ message += "Item already exists in storage: " + itemInfo;
+ ownException = new ItemExistsException(message, e);
+ throw ownException;
+ }
+
+ me = conn.getItemData(parent, new QPathEntry(item.getQPath().getName(),
item.getQPath().getIndex()));
+ if (me != null)
+ {
+ message += "Item already exists in storage: " + itemInfo;
+ ownException = new ItemExistsException(message, e);
+ throw ownException;
+ }
+
+ }
+ catch (Exception ep)
+ {
+ // item not found or other things but error of item reading
+ if (ownException != null)
+ throw ownException;
+ }
+ message += "Error of item add. " + itemInfo;
+ ownException = new RepositoryException(message, e);
+ throw ownException;
+ }
+ }
+ catch (Exception ep)
+ {
+ // no parent or error access it
+ if (ownException != null)
+ throw ownException;
+ }
+ message += "Error of item add. " + itemInfo;
+ throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.ADDED, e);
+ }
+
+ /**
+ * Handle delete Exceptions.
+ *
+ * @param e
+ * - an SQLException
+ * @param item
+ * - context ItemData
+ * @return String with error message
+ * @throws RepositoryException
+ * if <code>RepositoryException</code> should be thrown
+ * @throws InvalidItemStateException
+ * if <code>InvalidItemStateException</code> should be thrown
+ */
+ protected String handleDeleteException(SQLException e, ItemData item) throws
RepositoryException,
+ InvalidItemStateException
+ {
+ String message = "[" + containerName + "] DELETE " +
(item.isNode() ? "NODE. " : "PROPERTY. ");
+ String errMessage = e.getMessage();
+ String itemInfo =
+ item.getQPath().getAsString() + " " + item.getIdentifier()
+ + (errMessage != null ? ". Cause >>>> " + errMessage :
"");
+
+ if (errMessage != null)
+ {
+ // try detect error by foreign key names
+ String umsg = errMessage.toLowerCase().toUpperCase();
+ if (umsg.indexOf(conn.JCR_FK_ITEM_PARENT) >= 0)
+ {
+ message += "Can not delete parent till childs exists. Item " +
itemInfo;
+ throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.DELETED, e);
+ }
+ else if (umsg.indexOf(conn.JCR_FK_VALUE_PROPERTY) >= 0)
+ {
+ message +=
+ "[FATAL] Can not delete property item till it contains values.
Condition: property ID. " + itemInfo;
+ throw new RepositoryException(message, e);
+ }
+ }
+
+ message += "Error of item delete " + itemInfo;
+ throw new RepositoryException(message, e);
+ }
+
+ /**
+ * Handle update Exceptions.
+ *
+ * @param e
+ * - an SQLException
+ * @param item
+ * - context ItemData
+ * @return String with error message
+ * @throws RepositoryException
+ * if <code>RepositoryException</code> should be thrown
+ * @throws InvalidItemStateException
+ * if <code>InvalidItemStateException</code> should be thrown
+ */
+ protected String handleUpdateException(SQLException e, ItemData item) throws
RepositoryException,
+ InvalidItemStateException
+ {
+ String message = "[" + containerName + "] EDIT " +
(item.isNode() ? "NODE. " : "PROPERTY. ");
+ String errMessage = e.getMessage();
+ String itemInfo =
+ item.getQPath().getAsString() + " " + item.getIdentifier()
+ + (errMessage != null ? ". Cause >>>> " + errMessage :
"");
+
+ if (errMessage != null)
+ // try detect error by foreign key names
+ if (errMessage.toLowerCase().toUpperCase().indexOf(conn.JCR_FK_VALUE_PROPERTY)
>= 0)
+ {
+ message += "Property is not exists but the value is being created.
Condition: property ID. " + itemInfo;
+ throw new RepositoryException(message, e);
+ }
+ else if (errMessage.toLowerCase().toUpperCase().indexOf(conn.JCR_PK_ITEM) >=
0)
+ {
+ message += "Item already exists. Condition: ID. " + itemInfo;
+ throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.UPDATED, e);
+ }
+
+ // try detect integrity violation
+ RepositoryException ownException = null;
+ try
+ {
+ ItemData me = conn.getItemData(item.getIdentifier());
+ if (me != null)
+ {
+ // item already exists
+ message += "Item already exists. But update errors. " + itemInfo;
+ ownException = new RepositoryException(message, e);
+ throw ownException;
+ }
+ }
+ catch (Exception ep)
+ {
+ // item not found or other things but error of item reading
+ if (ownException != null)
+ throw ownException;
+ }
+ message += "Error of item update. " + itemInfo;
+ throw new JCRInvalidItemStateException(message, item.getIdentifier(),
ItemState.UPDATED, e);
+ }
+
+}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2009-12-25
15:51:39 UTC (rev 1193)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2009-12-25
15:55:34 UTC (rev 1194)
@@ -23,7 +23,7 @@
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.dataflow.ValueDataConvertor;
-import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCStorageConnection;
+import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCStorageConnection;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -48,7 +48,7 @@
* pnedonosko $
*/
-public class MultiDbJDBCConnection extends NewJDBCStorageConnection
+public class MultiDbJDBCConnection extends CQJDBCStorageConnection
{
protected PreparedStatement findItemById;
@@ -193,13 +193,9 @@
FIND_ITEM_BY_NAME_NEW =
"select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT
OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
+ ", (select ID from JCR_MITEM where PARENT_ID=? and NAME=? and
I_INDEX=?) I2"
- + " where (I.ID=I2.ID) or (I.PARENT_ID=I2.ID and I.I_CLASS=2 and I.NAME
IN
('[http://www.jcp.org/jcr/1.0]primaryType','[http://www.jcp.org/jcr/1.0]mixinTypes'))"
- + " order by I.I_CLASS, I.NAME DESC";
+ + " where (I.ID=I2.ID) or (I.PARENT_ID=I2.ID and I.I_CLASS=2 and
(
I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or
I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or
I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or
I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions'))"
+ + " order by I.I_CLASS, I.N_ORDER_NUM";
- // "select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from (select *
from JCR_MITEM where PARENT_ID=? and NAME=?) I LEFT OUTER JOIN JCR_MVALUE V ON
(V.PROPERTY_ID=I.ID)"
- // + ", (select ID from JCR_MITEM where I_CLASS=1 and PARENT_ID=? and
NAME=?) I2"
- // + " where (I.ID=I2.ID) or (I.PARENT_ID=I2.ID and I.I_CLASS=2 and
I.NAME IN
('[http://www.jcp.org/jcr/1.0]primaryType','[http://www.jcp.org/jcr/1.0]mixinTypes'))
order by I.I_CLASS, I.NAME DESC";// order by I.I_CLASS, I.N_ORDER_NUM";
-
FIND_PROPERTY_BY_NAME =
"select V.DATA" + " from JCR_MITEM I, JCR_MVALUE V"
+ " where I.I_CLASS=2 and I.PARENT_ID=? and I.NAME=? and
I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
@@ -227,7 +223,7 @@
+ " from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON
(V.PROPERTY_ID=I.ID), (select ID from JCR_MITEM where PARENT_ID=? AND I_CLASS=1) I2"
+ " where (I.I_CLASS=1 AND I.ID=I2.ID) OR (I.I_CLASS=2 and
I.PARENT_ID=I2.ID and"
+ " (
I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' OR
I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes')) order by I.I_CLASS,
I.N_ORDER_NUM";
-
//,'[http://www.exoplatform.com/jcr/exo/1.0]owner','[http://www.exoplatform.com/jcr/exo/1.0]permissions'
+ //,
FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + "
where I_CLASS=1 and PARENT_ID=?";
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2009-12-25
15:51:39 UTC (rev 1193)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2009-12-25
15:55:34 UTC (rev 1194)
@@ -22,7 +22,7 @@
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
-import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCStorageConnection;
+import
org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCStorageConnection;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -46,7 +46,7 @@
* @version $Id: SingleDbJDBCConnection.java 20950 2008-10-06 14:23:07Z
* pnedonosko $
*/
-public class SingleDbJDBCConnection extends NewJDBCStorageConnection
+public class SingleDbJDBCConnection extends CQJDBCStorageConnection
{
protected PreparedStatement findItemById;
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.mysql.xml
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.mysql.xml 2009-12-25
15:51:39 UTC (rev 1193)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.mysql.xml 2009-12-25
15:55:34 UTC (rev 1194)
@@ -229,9 +229,9 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName"
value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:13306/portal" />
- <property name="username" value="exoadmin" />
- <property name="password" value="exo12321" />
+ <property name="url"
value="jdbc:mysql://localhost/portal" />
+ <property name="username" value="root" />
+ <property name="password" value="eXoAdmin" />
<property name="maxActive" value="20" />
<property name="maxIdle" value="5" />
<property name="initialSize" value="2" />
@@ -259,9 +259,9 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName"
value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:13306/jcr1" />
- <property name="username" value="exoadmin" />
- <property name="password" value="exo12321" />
+ <property name="url" value="jdbc:mysql://localhost/jcr1"
/>
+ <property name="username" value="root" />
+ <property name="password" value="eXoAdmin" />
<property name="maxActive" value="20" />
<property name="maxIdle" value="5" />
<property name="initialSize" value="2" />
@@ -289,9 +289,9 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName"
value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:13306/jcr2" />
- <property name="username" value="exoadmin" />
- <property name="password" value="exo12321" />
+ <property name="url" value="jdbc:mysql://localhost/jcr2"
/>
+ <property name="username" value="root" />
+ <property name="password" value="eXoAdmin" />
<property name="maxActive" value="20" />
<property name="maxIdle" value="5" />
<property name="initialSize" value="2" />
@@ -319,9 +319,9 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName"
value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:13306/jcr3" />
- <property name="username" value="exoadmin" />
- <property name="password" value="exo12321" />
+ <property name="url" value="jdbc:mysql://localhost/jcr3"
/>
+ <property name="username" value="root" />
+ <property name="password" value="eXoAdmin" />
<property name="maxActive" value="20" />
<property name="maxIdle" value="5" />
<property name="initialSize" value="2" />
@@ -349,9 +349,9 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName"
value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:13306/portaltck" />
- <property name="username" value="exoadmin" />
- <property name="password" value="exo12321" />
+ <property name="url"
value="jdbc:mysql://localhost/portaltck" />
+ <property name="username" value="root" />
+ <property name="password" value="eXoAdmin" />
<property name="maxActive" value="20" />
<property name="maxIdle" value="5" />
<property name="initialSize" value="2" />
@@ -379,9 +379,9 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName"
value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:13306/jcrtck" />
- <property name="username" value="exoadmin" />
- <property name="password" value="exo12321" />
+ <property name="url"
value="jdbc:mysql://localhost/jcrtck" />
+ <property name="username" value="root" />
+ <property name="password" value="eXoAdmin" />
<property name="maxActive" value="20" />
<property name="maxIdle" value="5" />
<property name="initialSize" value="2" />
@@ -409,9 +409,9 @@
<name>ref-addresses</name>
<description>ref-addresses</description>
<property name="driverClassName"
value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:13306/jcr2tck" />
- <property name="username" value="exoadmin" />
- <property name="password" value="exo12321" />
+ <property name="url"
value="jdbc:mysql://localhost/jcr2tck" />
+ <property name="username" value="root" />
+ <property name="password" value="eXoAdmin" />
<property name="maxActive" value="20" />
<property name="maxIdle" value="5" />
<property name="initialSize" value="2" />
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2009-12-25
15:51:39 UTC (rev 1193)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2009-12-25
15:55:34 UTC (rev 1194)
@@ -176,7 +176,7 @@
<name>working-conf</name>
<description>working-conf</description>
<property name="source-name" value="jdbcjcr"/>
- <property name="dialect" value="hsqldb"/>
+ <property name="dialect" value="mysql"/>
<property name="persister-class-name"
value="org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister"/>
</properties-param>
</init-params>
@@ -227,11 +227,14 @@
</value-param>
<properties-param>
<name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/portal"/>
- <property name="username" value="sa"/>
- <property name="password" value=""/>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="com.mysql.jdbc.Driver" />
+ <property name="url"
value="jdbc:mysql://mysql.exoua-int/KarpenkoJ2tck"/>
+ <property name="username" value="root"/>
+ <property name="password" value="eXoAdmin"/>
+ <property name="maxActive" value="100" />
+ <property name="maxIdle" value="5" />
+ <property name="initialSize" value="5" />
</properties-param>
</init-params>
</component-plugin>
@@ -255,10 +258,13 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcr"/>
- <property name="username" value="sa"/>
- <property name="password" value=""/>
+ <property name="driverClassName"
value="com.mysql.jdbc.Driver" />
+ <property name="url"
value="jdbc:mysql://mysql.exoua-int/KarpenkoJCR2"/>
+ <property name="username" value="root"/>
+ <property name="password" value="eXoAdmin"/>
+ <property name="maxActive" value="100" />
+ <property name="maxIdle" value="5" />
+ <property name="initialSize" value="5" />
</properties-param>
</init-params>
</component-plugin>
@@ -282,14 +288,17 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcr2"/>
- <property name="username" value="sa"/>
- <property name="password" value=""/>
+ <property name="driverClassName"
value="com.mysql.jdbc.Driver" />
+ <property name="url"
value="jdbc:mysql://mysql.exoua-int/KarpenkoPtck"/>
+ <property name="username" value="root"/>
+ <property name="password" value="eXoAdmin"/>
+ <property name="maxActive" value="100" />
+ <property name="maxIdle" value="5" />
+ <property name="initialSize" value="5" />
</properties-param>
</init-params>
</component-plugin>
- <component-plugin>
+ <component-plugin>
<name>bind.datasource</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.services.naming.BindReferencePlugin</type>
@@ -309,14 +318,18 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcr3"/>
- <property name="username" value="sa"/>
- <property name="password" value=""/>
+ <property name="driverClassName"
value="com.mysql.jdbc.Driver" />
+ <property name="url"
value="jdbc:mysql://mysql.exoua-int/KarpenkoBD3"/>
+ <property name="username" value="root"/>
+ <property name="password" value="eXoAdmin"/>
+ <property name="maxActive" value="100" />
+ <property name="maxIdle" value="5" />
+ <property name="initialSize" value="5" />
+
</properties-param>
</init-params>
</component-plugin>
- <component-plugin>
+ <!--component-plugin>
<name>bind.datasource</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.services.naming.BindReferencePlugin</type>
@@ -342,7 +355,7 @@
<property name="password" value=""/>
</properties-param>
</init-params>
- </component-plugin>
+ </component-plugin-->
<component-plugin>
<name>bind.datasource</name>
<set-method>addPlugin</set-method>
@@ -363,10 +376,14 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/portaltck"/>
- <property name="username" value="sa"/>
- <property name="password" value=""/>
+ <property name="driverClassName"
value="com.mysql.jdbc.Driver" />
+ <property name="url"
value="jdbc:mysql://mysql.exoua-int/KarpenkoBD1"/>
+ <property name="username" value="root"/>
+ <property name="password" value="eXoAdmin"/>
+ <property name="maxActive" value="100" />
+ <property name="maxIdle" value="5" />
+ <property name="initialSize" value="5" />
+
</properties-param>
</init-params>
</component-plugin>
@@ -390,10 +407,13 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcrtck"/>
- <property name="username" value="sa"/>
- <property name="password" value=""/>
+ <property name="driverClassName"
value="com.mysql.jdbc.Driver" />
+ <property name="url"
value="jdbc:mysql://mysql.exoua-int/KarpenkoBD2"/>
+ <property name="username" value="root"/>
+ <property name="password" value="eXoAdmin"/>
+ <property name="maxActive" value="100" />
+ <property name="maxIdle" value="5" />
+ <property name="initialSize" value="5" />
</properties-param>
</init-params>
</component-plugin>
@@ -417,14 +437,18 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
- <property name="url"
value="jdbc:hsqldb:file:target/temp/data/jcr2tck"/>
- <property name="username" value="sa"/>
- <property name="password" value=""/>
+ <property name="driverClassName"
value="com.mysql.jdbc.Driver" />
+ <property name="url"
value="jdbc:mysql://mysql.exoua-int/KarpenkoJtck"/>
+ <property name="username" value="root"/>
+ <property name="password" value="eXoAdmin"/>
+ <property name="maxActive" value="100" />
+ <property name="maxIdle" value="5" />
+ <property name="initialSize" value="5" />
+
</properties-param>
</init-params>
</component-plugin>
- <component-plugin>
+ <!--component-plugin>
<name>bind.datasource</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.services.naming.BindReferencePlugin</type>
@@ -504,7 +528,7 @@
<property name="password" value=""/>
</properties-param>
</init-params>
- </component-plugin>
+ </component-plugin-->
<!-- Resource configuration for UserTransaction
use JOTM
-->
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.mysql.xml
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.mysql.xml 2009-12-25
15:51:39 UTC (rev 1193)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.mysql.xml 2009-12-25
15:55:34 UTC (rev 1194)
@@ -1,407 +1,407 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-
--->
-<repository-service default-repository="db1">
- <repositories>
- <repository name="db1" system-workspace="ws"
default-workspace="ws">
- <security-domain>exo-domain</security-domain>
- <!-- access-control>optional</access-control -->
- <!-- access-control>disable</access-control -->
- <session-max-age>1h</session-max-age>
-
<authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
- <workspaces>
- <workspace name="ws">
- <!-- for system storage -->
- <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr"
/>
- <property name="dialect" value="mysql" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false"
/>
- <property name="max-buffer-size" value="200k"
/>
- <property name="swap-directory"
value="target/temp/swap/ws" />
- </properties>
- <value-storages>
- <value-storage id="ws"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path"
value="target/temp/values/ws" />
- <property name="digest-algo"
value="MD5" />
- <property name="vcas-type"
value="org.exoplatform.services.jcr.impl.storage.value.cas.JDBCValueContentAddressStorageImpl"
/>
- <property name="jdbc-source-name"
value="jdbcjcr" />
- <property name="jdbc-dialect"
value="mysql" />
- </properties>
- <filters>
- <filter property-type="Binary" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype"
value="nt:unstructured" />
- </properties>
- </initializer>
- <!-- initializer
class="org.exoplatform.services.jcr.impl.core.RestoreWorkspaceInitializer">
- <properties>
- <property name="restore-path"
value="./sv_export_root.xml" />
- <property name="restore-path"
value="./src/test/resources/import-export/restore_db1_ws1.xml" />
- </properties>
- </initializer
--->
- <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
- <properties>
- <property name="max-size" value="2k" />
- <property name="live-time" value="20m" />
- <property name="statistic-period" value="30"
/>
- <property name="statistic-log" value="false"
/>
- </properties>
- </cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir"
value="target/temp/index/db1/ws" />
- </properties>
- </query-handler>
- <lock-manager>
- <time-out>15m</time-out>
- <persister
class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
- <properties>
- <property name="path"
value="target/temp/lock" />
- </properties>
- </persister>
- </lock-manager>
- </workspace>
-
- <workspace name="ws1">
- <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr1"
/>
- <property name="dialect" value="mysql" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false"
/>
- <property name="max-buffer-size" value="200k"
/>
- <property name="swap-directory"
value="target/temp/swap/ws1" />
- </properties>
- <value-storages>
- <value-storage id="ws1"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path"
value="target/temp/values/ws1" />
- </properties>
- <filters>
- <filter property-type="Binary" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
- <properties>
- <property name="max-size" value="2k" />
- <property name="live-time" value="20m" />
- </properties>
- </cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir"
value="target/temp/index/db1/ws1" />
- <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
- <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
- <property name="support-highlighting"
value="true" />
- <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
- <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
- </properties>
- </query-handler>
- </workspace>
-
- <workspace name="ws2">
- <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr2"
/>
- <property name="dialect" value="mysql" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false"
/>
- <property name="max-buffer-size" value="200k"
/>
- <property name="swap-directory"
value="target/temp/swap/ws2" />
- </properties>
- <value-storages>
- <value-storage id="ws2"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path"
value="target/temp/values/ws2" />
- </properties>
- <filters>
- <filter property-type="Binary" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
- <properties>
- <property name="max-size" value="2k" />
- <property name="live-time" value="20m" />
- </properties>
- </cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir"
value="target/temp/index/db1/ws2" />
- <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
- <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
- <property name="support-highlighting"
value="true" />
- <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
- <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
- </properties>
- </query-handler>
- </workspace>
-
- <workspace name="ws3">
- <!-- for system storage -->
- <container
- class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr3" />
- <property name="dialect" value="mysql" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false" />
- <property name="max-buffer-size" value="200k" />
- <property name="swap-directory"
value="target/temp/swap/ws3" />
- </properties>
- <value-storages>
- <!--
- This storage is used to check whether properties are removed
- correctly from each value-storage
- (TestRemoveFromValueStorage.java)
- -->
- <value-storage id="ws3_big"
- class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path" value="target/temp/values/ws3_big"
/>
- </properties>
- <filters>
- <filter property-type="Binary" min-value-size="1024K"
/>
- </filters>
- </value-storage>
- <value-storage id="ws3"
- class="org.exoplatform.services.jcr.impl.storage.value.fs.CASableTreeFileValueStorage">
- <properties>
- <property name="path" value="target/temp/values/ws3"
/>
- <property name="digest-algo" value="MD5" />
- <property name="vcas-type"
- value="org.exoplatform.services.jcr.impl.storage.value.cas.JDBCValueContentAddressStorageImpl"
/>
- <property name="jdbc-source-name" value="jdbcjcr" />
- <property name="jdbc-dialect" value="mysql" />
- </properties>
- <filters>
- <filter property-type="Binary" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer
- class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype" value="nt:unstructured"
/>
- </properties>
- </initializer>
- <cache enabled="true"
- class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
- <properties>
- <property name="max-size" value="2k" />
- <property name="live-time" value="20m" />
- </properties>
- </cache>
- <query-handler
- class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir"
value="target/temp/index/db1/ws3" />
- <property name="synonymprovider-class"
- value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
- <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
- <property name="support-highlighting" value="true" />
- <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
- <property name="query-class"
- value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class"
- value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
- </properties>
- </query-handler>
- </workspace>
- </workspaces>
- </repository>
-
- <repository name="db1tck" system-workspace="ws"
default-workspace="ws">
- <security-domain>exo-domain</security-domain>
- <!-- access-control>optional</access-control -->
- <!-- access-control>disable</access-control -->
- <session-max-age>1h</session-max-age>
-
<authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
- <workspaces>
- <workspace name="ws">
- <!-- for system storage -->
- <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name"
value="jdbcjcrtck" />
- <property name="dialect" value="mysql" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false"
/>
- <property name="max-buffer-size" value="200k"
/>
- <property name="swap-directory"
value="target/temp/swap/wstck" />
- </properties>
- <value-storages>
- <value-storage id="ws"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path"
value="target/temp/values/wstck" />
- </properties>
- <filters>
- <filter property-type="Binary"
min-value-size="100K" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype"
value="nt:unstructured" />
- <property name="root-permissions" value="any
read;*:/platform/administrators read;*:/platform/administrators
add_node;*:/platform/administrators set_property;*:/platform/administrators remove"
/>
- </properties>
- </initializer>
- <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
- <properties>
- <property name="max-size" value="2k" />
- <property name="live-time" value="20m" />
- </properties>
- </cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir"
value="target/temp/index/db1tck/ws" />
- <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
- <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
- <property name="support-highlighting"
value="true" />
- <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
- <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="excerptprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.WeightedHTMLExcerpt"
/>
- <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
- </properties>
- </query-handler>
- <lock-manager>
- <time-out>15m</time-out>
- <persister
class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
- <properties>
- <property name="path"
value="target/temp/locktck" />
- </properties>
- </persister>
- </lock-manager>
- </workspace>
-
- <workspace name="ws1">
- <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name"
value="jdbcjcr1tck" />
- <property name="dialect" value="mysql" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false"
/>
- <property name="max-buffer-size" value="200k"
/>
- <property name="swap-directory"
value="target/temp/swap/ws1tck" />
- </properties>
- <value-storages>
- <value-storage id="ws1"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path"
value="target/temp/values/ws1tck" />
- </properties>
- <filters>
- <filter property-type="Binary"
min-value-size="100K" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype"
value="nt:unstructured" />
- <property name="root-permissions" value="any
read;*:/platform/administrators read;*:/platform/administrators
add_node;*:/platform/administrators set_property;*:/platform/administrators remove"
/>
- </properties>
- </initializer>
- <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
- <properties>
- <property name="max-size" value="2k" />
- <property name="live-time" value="20m" />
- </properties>
- </cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir"
value="target/temp/index/db1tck/ws1" />
- <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
- <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
- <property name="support-highlighting"
value="true" />
- <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
- <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
- </properties>
- </query-handler>
- </workspace>
-
- <workspace name="ws2">
- <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name"
value="jdbcjcr2tck" />
- <property name="dialect" value="mysql" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false"
/>
- <property name="max-buffer-size" value="200k"
/>
- <property name="swap-directory"
value="target/temp/swap/ws2tck" />
- </properties>
- <value-storages>
- <value-storage id="ws2"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path"
value="target/temp/values/ws2tck" />
- </properties>
- <filters>
- <filter property-type="Binary"
min-value-size="100K" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype"
value="nt:unstructured" />
- <property name="root-permissions" value="any
read;*:/platform/administrators read;*:/platform/administrators
add_node;*:/platform/administrators set_property;*:/platform/administrators remove"
/>
- </properties>
- </initializer>
- <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
- <properties>
- <property name="max-size" value="2k" />
- <property name="live-time" value="20m" />
- </properties>
- </cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir"
value="target/temp/index/db1tck/ws2" />
- <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
- <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
- <property name="support-highlighting"
value="true" />
- <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
- <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
- <property name="excerptprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.WeightedHTMLExcerpt"/>
- <property name="extractorPoolSize"
value="2"/>
- <property name="extractorTimeout"
value="10"/>
- </properties>
- </query-handler>
- </workspace>
- </workspaces>
- </repository>
- </repositories>
-</repository-service>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+-->
+<repository-service default-repository="db1">
+ <repositories>
+ <repository name="db1" system-workspace="ws"
default-workspace="ws">
+ <security-domain>exo-domain</security-domain>
+ <!-- access-control>optional</access-control -->
+ <!-- access-control>disable</access-control -->
+ <session-max-age>1h</session-max-age>
+
<authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
+ <workspaces>
+ <workspace name="ws">
+ <!-- for system storage -->
+ <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr"
/>
+ <property name="dialect" value="mysql" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false"
/>
+ <property name="max-buffer-size" value="200k"
/>
+ <property name="swap-directory"
value="target/temp/swap/ws" />
+ </properties>
+ <value-storages>
+ <value-storage id="ws"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path"
value="target/temp/values/ws" />
+ <property name="digest-algo"
value="MD5" />
+ <property name="vcas-type"
value="org.exoplatform.services.jcr.impl.storage.value.cas.JDBCValueContentAddressStorageImpl"
/>
+ <property name="jdbc-source-name"
value="jdbcjcr" />
+ <property name="jdbc-dialect"
value="mysql" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype"
value="nt:unstructured" />
+ </properties>
+ </initializer>
+ <!-- initializer
class="org.exoplatform.services.jcr.impl.core.RestoreWorkspaceInitializer">
+ <properties>
+ <property name="restore-path"
value="./sv_export_root.xml" />
+ <property name="restore-path"
value="./src/test/resources/import-export/restore_db1_ws1.xml" />
+ </properties>
+ </initializer
+-->
+ <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ <property name="statistic-period" value="30"
/>
+ <property name="statistic-log" value="false"
/>
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db1/ws" />
+ </properties>
+ </query-handler>
+ <lock-manager>
+ <time-out>15m</time-out>
+ <persister
class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
+ <properties>
+ <property name="path"
value="target/temp/lock" />
+ </properties>
+ </persister>
+ </lock-manager>
+ </workspace>
+
+ <workspace name="ws1">
+ <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr1"
/>
+ <property name="dialect" value="mysql" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false"
/>
+ <property name="max-buffer-size" value="200k"
/>
+ <property name="swap-directory"
value="target/temp/swap/ws1" />
+ </properties>
+ <value-storages>
+ <value-storage id="ws1"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path"
value="target/temp/values/ws1" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db1/ws1" />
+ <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
+ <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
+ <property name="support-highlighting"
value="true" />
+ <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
+ <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
+ <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
+ </properties>
+ </query-handler>
+ </workspace>
+
+ <workspace name="ws2">
+ <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr2"
/>
+ <property name="dialect" value="mysql" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false"
/>
+ <property name="max-buffer-size" value="200k"
/>
+ <property name="swap-directory"
value="target/temp/swap/ws2" />
+ </properties>
+ <value-storages>
+ <value-storage id="ws2"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path"
value="target/temp/values/ws2" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db1/ws2" />
+ <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
+ <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
+ <property name="support-highlighting"
value="true" />
+ <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
+ <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
+ <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
+ </properties>
+ </query-handler>
+ </workspace>
+
+ <workspace name="ws3">
+ <!-- for system storage -->
+ <container
+ class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr3" />
+ <property name="dialect" value="mysql" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false" />
+ <property name="max-buffer-size" value="200k" />
+ <property name="swap-directory"
value="target/temp/swap/ws3" />
+ </properties>
+ <value-storages>
+ <!--
+ This storage is used to check whether properties are removed
+ correctly from each value-storage
+ (TestRemoveFromValueStorage.java)
+ -->
+ <value-storage id="ws3_big"
+ class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path" value="target/temp/values/ws3_big"
/>
+ </properties>
+ <filters>
+ <filter property-type="Binary" min-value-size="1024K"
/>
+ </filters>
+ </value-storage>
+ <value-storage id="ws3"
+ class="org.exoplatform.services.jcr.impl.storage.value.fs.CASableTreeFileValueStorage">
+ <properties>
+ <property name="path" value="target/temp/values/ws3"
/>
+ <property name="digest-algo" value="MD5" />
+ <property name="vcas-type"
+ value="org.exoplatform.services.jcr.impl.storage.value.cas.JDBCValueContentAddressStorageImpl"
/>
+ <property name="jdbc-source-name" value="jdbcjcr" />
+ <property name="jdbc-dialect" value="mysql" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer
+ class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype" value="nt:unstructured"
/>
+ </properties>
+ </initializer>
+ <cache enabled="true"
+ class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ </properties>
+ </cache>
+ <query-handler
+ class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db1/ws3" />
+ <property name="synonymprovider-class"
+ value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
+ <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
+ <property name="support-highlighting" value="true" />
+ <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
+ <property name="query-class"
+ value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
+ <property name="spellchecker-class"
+ value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
+ </properties>
+ </query-handler>
+ </workspace>
+ </workspaces>
+ </repository>
+
+ <repository name="db1tck" system-workspace="ws"
default-workspace="ws">
+ <security-domain>exo-domain</security-domain>
+ <!-- access-control>optional</access-control -->
+ <!-- access-control>disable</access-control -->
+ <session-max-age>1h</session-max-age>
+
<authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
+ <workspaces>
+ <workspace name="ws">
+ <!-- for system storage -->
+ <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name"
value="jdbcjcrtck" />
+ <property name="dialect" value="mysql" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false"
/>
+ <property name="max-buffer-size" value="200k"
/>
+ <property name="swap-directory"
value="target/temp/swap/wstck" />
+ </properties>
+ <value-storages>
+ <value-storage id="ws"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path"
value="target/temp/values/wstck" />
+ </properties>
+ <filters>
+ <filter property-type="Binary"
min-value-size="100K" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype"
value="nt:unstructured" />
+ <property name="root-permissions" value="any
read;*:/platform/administrators read;*:/platform/administrators
add_node;*:/platform/administrators set_property;*:/platform/administrators remove"
/>
+ </properties>
+ </initializer>
+ <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db1tck/ws" />
+ <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
+ <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
+ <property name="support-highlighting"
value="true" />
+ <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
+ <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
+ <property name="excerptprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.WeightedHTMLExcerpt"
/>
+ <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
+ </properties>
+ </query-handler>
+ <lock-manager>
+ <time-out>15m</time-out>
+ <persister
class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
+ <properties>
+ <property name="path"
value="target/temp/locktck" />
+ </properties>
+ </persister>
+ </lock-manager>
+ </workspace>
+
+ <workspace name="ws1">
+ <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name"
value="jdbcjcr1tck" />
+ <property name="dialect" value="mysql" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false"
/>
+ <property name="max-buffer-size" value="200k"
/>
+ <property name="swap-directory"
value="target/temp/swap/ws1tck" />
+ </properties>
+ <value-storages>
+ <value-storage id="ws1"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path"
value="target/temp/values/ws1tck" />
+ </properties>
+ <filters>
+ <filter property-type="Binary"
min-value-size="100K" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype"
value="nt:unstructured" />
+ <property name="root-permissions" value="any
read;*:/platform/administrators read;*:/platform/administrators
add_node;*:/platform/administrators set_property;*:/platform/administrators remove"
/>
+ </properties>
+ </initializer>
+ <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db1tck/ws1" />
+ <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
+ <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
+ <property name="support-highlighting"
value="true" />
+ <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
+ <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
+ <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
+ </properties>
+ </query-handler>
+ </workspace>
+
+ <workspace name="ws2">
+ <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name"
value="jdbcjcr2tck" />
+ <property name="dialect" value="mysql" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false"
/>
+ <property name="max-buffer-size" value="200k"
/>
+ <property name="swap-directory"
value="target/temp/swap/ws2tck" />
+ </properties>
+ <value-storages>
+ <value-storage id="ws2"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path"
value="target/temp/values/ws2tck" />
+ </properties>
+ <filters>
+ <filter property-type="Binary"
min-value-size="100K" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype"
value="nt:unstructured" />
+ <property name="root-permissions" value="any
read;*:/platform/administrators read;*:/platform/administrators
add_node;*:/platform/administrators set_property;*:/platform/administrators remove"
/>
+ </properties>
+ </initializer>
+ <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db1tck/ws2" />
+ <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
+ <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
+ <property name="support-highlighting"
value="true" />
+ <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
+ <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
+ <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
+ <property name="excerptprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.WeightedHTMLExcerpt"/>
+ <property name="extractorPoolSize"
value="2"/>
+ <property name="extractorTimeout"
value="10"/>
+ </properties>
+ </query-handler>
+ </workspace>
+ </workspaces>
+ </repository>
+ </repositories>
+</repository-service>
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2009-12-25
15:51:39 UTC (rev 1193)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2009-12-25
15:55:34 UTC (rev 1194)
@@ -1,407 +1,407 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-
--->
-<repository-service default-repository="db1">
- <repositories>
- <repository name="db1" system-workspace="ws"
default-workspace="ws">
- <security-domain>exo-domain</security-domain>
- <!-- access-control>optional</access-control -->
- <!-- access-control>disable</access-control -->
- <session-max-age>1h</session-max-age>
-
<authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
- <workspaces>
- <workspace name="ws">
- <!-- for system storage -->
- <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr"
/>
- <property name="dialect" value="hsqldb"
/>
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false"
/>
- <property name="max-buffer-size" value="200k"
/>
- <property name="swap-directory"
value="target/temp/swap/ws" />
- </properties>
- <value-storages>
- <value-storage id="ws"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path"
value="target/temp/values/ws" />
- <property name="digest-algo"
value="MD5" />
- <property name="vcas-type"
value="org.exoplatform.services.jcr.impl.storage.value.cas.JDBCValueContentAddressStorageImpl"
/>
- <property name="jdbc-source-name"
value="jdbcjcr" />
- <property name="jdbc-dialect"
value="hsqldb" />
- </properties>
- <filters>
- <filter property-type="Binary" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype"
value="nt:unstructured" />
- </properties>
- </initializer>
- <!-- initializer
class="org.exoplatform.services.jcr.impl.core.RestoreWorkspaceInitializer">
- <properties>
- <property name="restore-path"
value="./sv_export_root.xml" />
- <property name="restore-path"
value="./src/test/resources/import-export/restore_db1_ws1.xml" />
- </properties>
- </initializer
--->
- <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
- <properties>
- <property name="max-size" value="2k" />
- <property name="live-time" value="20m" />
- <property name="statistic-period" value="30"
/>
- <property name="statistic-log" value="false"
/>
- </properties>
- </cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir"
value="target/temp/index/db1/ws" />
- </properties>
- </query-handler>
- <lock-manager>
- <time-out>15m</time-out>
- <persister
class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
- <properties>
- <property name="path"
value="target/temp/lock" />
- </properties>
- </persister>
- </lock-manager>
- </workspace>
-
- <workspace name="ws1">
- <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr1"
/>
- <property name="dialect" value="hsqldb"
/>
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false"
/>
- <property name="max-buffer-size" value="200k"
/>
- <property name="swap-directory"
value="target/temp/swap/ws1" />
- </properties>
- <value-storages>
- <value-storage id="ws1"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path"
value="target/temp/values/ws1" />
- </properties>
- <filters>
- <filter property-type="Binary" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
- <properties>
- <property name="max-size" value="2k" />
- <property name="live-time" value="20m" />
- </properties>
- </cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir"
value="target/temp/index/db1/ws1" />
- <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
- <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
- <property name="support-highlighting"
value="true" />
- <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
- <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
- </properties>
- </query-handler>
- </workspace>
-
- <workspace name="ws2">
- <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr2"
/>
- <property name="dialect" value="hsqldb"
/>
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false"
/>
- <property name="max-buffer-size" value="200k"
/>
- <property name="swap-directory"
value="target/temp/swap/ws2" />
- </properties>
- <value-storages>
- <value-storage id="ws2"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path"
value="target/temp/values/ws2" />
- </properties>
- <filters>
- <filter property-type="Binary" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
- <properties>
- <property name="max-size" value="2k" />
- <property name="live-time" value="20m" />
- </properties>
- </cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir"
value="target/temp/index/db1/ws2" />
- <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
- <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
- <property name="support-highlighting"
value="true" />
- <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
- <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
- </properties>
- </query-handler>
- </workspace>
-
- <workspace name="ws3">
- <!-- for system storage -->
- <container
- class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name" value="jdbcjcr3" />
- <property name="dialect" value="hsqldb" />
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false" />
- <property name="max-buffer-size" value="200k" />
- <property name="swap-directory"
value="target/temp/swap/ws3" />
- </properties>
- <value-storages>
- <!--
- This storage is used to check whether properties are removed
- correctly from each value-storage
- (TestRemoveFromValueStorage.java)
- -->
- <value-storage id="ws3_big"
- class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path" value="target/temp/values/ws3_big"
/>
- </properties>
- <filters>
- <filter property-type="Binary" min-value-size="1024K"
/>
- </filters>
- </value-storage>
- <value-storage id="ws3"
- class="org.exoplatform.services.jcr.impl.storage.value.fs.CASableTreeFileValueStorage">
- <properties>
- <property name="path" value="target/temp/values/ws3"
/>
- <property name="digest-algo" value="MD5" />
- <property name="vcas-type"
- value="org.exoplatform.services.jcr.impl.storage.value.cas.JDBCValueContentAddressStorageImpl"
/>
- <property name="jdbc-source-name" value="jdbcjcr" />
- <property name="jdbc-dialect" value="hsqldb" />
- </properties>
- <filters>
- <filter property-type="Binary" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer
- class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype" value="nt:unstructured"
/>
- </properties>
- </initializer>
- <cache enabled="true"
- class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
- <properties>
- <property name="max-size" value="2k" />
- <property name="live-time" value="20m" />
- </properties>
- </cache>
- <query-handler
- class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir"
value="target/temp/index/db1/ws3" />
- <property name="synonymprovider-class"
- value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
- <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
- <property name="support-highlighting" value="true" />
- <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
- <property name="query-class"
- value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class"
- value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
- </properties>
- </query-handler>
- </workspace>
- </workspaces>
- </repository>
-
- <repository name="db1tck" system-workspace="ws"
default-workspace="ws">
- <security-domain>exo-domain</security-domain>
- <!-- access-control>optional</access-control -->
- <!-- access-control>disable</access-control -->
- <session-max-age>1h</session-max-age>
-
<authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
- <workspaces>
- <workspace name="ws">
- <!-- for system storage -->
- <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name"
value="jdbcjcrtck" />
- <property name="dialect" value="hsqldb"
/>
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false"
/>
- <property name="max-buffer-size" value="200k"
/>
- <property name="swap-directory"
value="target/temp/swap/wstck" />
- </properties>
- <value-storages>
- <value-storage id="ws"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path"
value="target/temp/values/wstck" />
- </properties>
- <filters>
- <filter property-type="Binary"
min-value-size="100K" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype"
value="nt:unstructured" />
- <property name="root-permissions" value="any
read;*:/platform/administrators read;*:/platform/administrators
add_node;*:/platform/administrators set_property;*:/platform/administrators remove"
/>
- </properties>
- </initializer>
- <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
- <properties>
- <property name="max-size" value="2k" />
- <property name="live-time" value="20m" />
- </properties>
- </cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir"
value="target/temp/index/db1tck/ws" />
- <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
- <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
- <property name="support-highlighting"
value="true" />
- <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
- <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="excerptprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.WeightedHTMLExcerpt"
/>
- <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
- </properties>
- </query-handler>
- <lock-manager>
- <time-out>15m</time-out>
- <persister
class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
- <properties>
- <property name="path"
value="target/temp/locktck" />
- </properties>
- </persister>
- </lock-manager>
- </workspace>
-
- <workspace name="ws1">
- <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name"
value="jdbcjcr1tck" />
- <property name="dialect" value="hsqldb"
/>
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false"
/>
- <property name="max-buffer-size" value="200k"
/>
- <property name="swap-directory"
value="target/temp/swap/ws1tck" />
- </properties>
- <value-storages>
- <value-storage id="ws1"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path"
value="target/temp/values/ws1tck" />
- </properties>
- <filters>
- <filter property-type="Binary"
min-value-size="100K" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype"
value="nt:unstructured" />
- <property name="root-permissions" value="any
read;*:/platform/administrators read;*:/platform/administrators
add_node;*:/platform/administrators set_property;*:/platform/administrators remove"
/>
- </properties>
- </initializer>
- <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
- <properties>
- <property name="max-size" value="2k" />
- <property name="live-time" value="20m" />
- </properties>
- </cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir"
value="target/temp/index/db1tck/ws1" />
- <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
- <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
- <property name="support-highlighting"
value="true" />
- <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
- <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
- </properties>
- </query-handler>
- </workspace>
-
- <workspace name="ws2">
- <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
- <properties>
- <property name="source-name"
value="jdbcjcr2tck" />
- <property name="dialect" value="hsqldb"
/>
- <property name="multi-db" value="true" />
- <property name="update-storage" value="false"
/>
- <property name="max-buffer-size" value="200k"
/>
- <property name="swap-directory"
value="target/temp/swap/ws2tck" />
- </properties>
- <value-storages>
- <value-storage id="ws2"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
- <properties>
- <property name="path"
value="target/temp/values/ws2tck" />
- </properties>
- <filters>
- <filter property-type="Binary"
min-value-size="100K" />
- </filters>
- </value-storage>
- </value-storages>
- </container>
- <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
- <properties>
- <property name="root-nodetype"
value="nt:unstructured" />
- <property name="root-permissions" value="any
read;*:/platform/administrators read;*:/platform/administrators
add_node;*:/platform/administrators set_property;*:/platform/administrators remove"
/>
- </properties>
- </initializer>
- <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
- <properties>
- <property name="max-size" value="2k" />
- <property name="live-time" value="20m" />
- </properties>
- </cache>
- <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
- <properties>
- <property name="index-dir"
value="target/temp/index/db1tck/ws2" />
- <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
- <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
- <property name="support-highlighting"
value="true" />
- <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
- <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
- <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
- <property name="excerptprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.WeightedHTMLExcerpt"/>
- <property name="extractorPoolSize"
value="2"/>
- <property name="extractorTimeout"
value="10"/>
- </properties>
- </query-handler>
- </workspace>
- </workspaces>
- </repository>
- </repositories>
-</repository-service>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+-->
+<repository-service default-repository="db1">
+ <repositories>
+ <repository name="db1" system-workspace="ws"
default-workspace="ws">
+ <security-domain>exo-domain</security-domain>
+ <!-- access-control>optional</access-control -->
+ <!-- access-control>disable</access-control -->
+ <session-max-age>1h</session-max-age>
+
<authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
+ <workspaces>
+ <workspace name="ws">
+ <!-- for system storage -->
+ <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr"
/>
+ <property name="dialect" value="mysql" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false"
/>
+ <property name="max-buffer-size" value="200k"
/>
+ <property name="swap-directory"
value="target/temp/swap/ws" />
+ </properties>
+ <value-storages>
+ <value-storage id="ws"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path"
value="target/temp/values/ws" />
+ <property name="digest-algo"
value="MD5" />
+ <property name="vcas-type"
value="org.exoplatform.services.jcr.impl.storage.value.cas.JDBCValueContentAddressStorageImpl"
/>
+ <property name="jdbc-source-name"
value="jdbcjcr" />
+ <property name="jdbc-dialect"
value="hsqldb" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype"
value="nt:unstructured" />
+ </properties>
+ </initializer>
+ <!-- initializer
class="org.exoplatform.services.jcr.impl.core.RestoreWorkspaceInitializer">
+ <properties>
+ <property name="restore-path"
value="./sv_export_root.xml" />
+ <property name="restore-path"
value="./src/test/resources/import-export/restore_db1_ws1.xml" />
+ </properties>
+ </initializer
+-->
+ <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ <property name="statistic-period" value="30"
/>
+ <property name="statistic-log" value="false"
/>
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db1/ws" />
+ </properties>
+ </query-handler>
+ <lock-manager>
+ <time-out>15m</time-out>
+ <persister
class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
+ <properties>
+ <property name="path"
value="target/temp/lock" />
+ </properties>
+ </persister>
+ </lock-manager>
+ </workspace>
+
+ <workspace name="ws1">
+ <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr1"
/>
+ <property name="dialect" value="mysql" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false"
/>
+ <property name="max-buffer-size" value="200k"
/>
+ <property name="swap-directory"
value="target/temp/swap/ws1" />
+ </properties>
+ <value-storages>
+ <value-storage id="ws1"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path"
value="target/temp/values/ws1" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db1/ws1" />
+ <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
+ <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
+ <property name="support-highlighting"
value="true" />
+ <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
+ <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
+ <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
+ </properties>
+ </query-handler>
+ </workspace>
+
+ <workspace name="ws2">
+ <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr2"
/>
+ <property name="dialect" value="mysql" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false"
/>
+ <property name="max-buffer-size" value="200k"
/>
+ <property name="swap-directory"
value="target/temp/swap/ws2" />
+ </properties>
+ <value-storages>
+ <value-storage id="ws2"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path"
value="target/temp/values/ws2" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db1/ws2" />
+ <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
+ <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
+ <property name="support-highlighting"
value="true" />
+ <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
+ <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
+ <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
+ </properties>
+ </query-handler>
+ </workspace>
+
+ <workspace name="ws3">
+ <!-- for system storage -->
+ <container
+ class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr3" />
+ <property name="dialect" value="mysql" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false" />
+ <property name="max-buffer-size" value="200k" />
+ <property name="swap-directory"
value="target/temp/swap/ws3" />
+ </properties>
+ <value-storages>
+ <!--
+ This storage is used to check whether properties are removed
+ correctly from each value-storage
+ (TestRemoveFromValueStorage.java)
+ -->
+ <value-storage id="ws3_big"
+ class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path" value="target/temp/values/ws3_big"
/>
+ </properties>
+ <filters>
+ <filter property-type="Binary" min-value-size="1024K"
/>
+ </filters>
+ </value-storage>
+ <value-storage id="ws3"
+ class="org.exoplatform.services.jcr.impl.storage.value.fs.CASableTreeFileValueStorage">
+ <properties>
+ <property name="path" value="target/temp/values/ws3"
/>
+ <property name="digest-algo" value="MD5" />
+ <property name="vcas-type"
+ value="org.exoplatform.services.jcr.impl.storage.value.cas.JDBCValueContentAddressStorageImpl"
/>
+ <property name="jdbc-source-name" value="jdbcjcr" />
+ <property name="jdbc-dialect" value="hsqldb" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer
+ class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype" value="nt:unstructured"
/>
+ </properties>
+ </initializer>
+ <cache enabled="true"
+ class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ </properties>
+ </cache>
+ <query-handler
+ class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db1/ws3" />
+ <property name="synonymprovider-class"
+ value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
+ <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
+ <property name="support-highlighting" value="true" />
+ <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
+ <property name="query-class"
+ value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
+ <property name="spellchecker-class"
+ value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
+ </properties>
+ </query-handler>
+ </workspace>
+ </workspaces>
+ </repository>
+
+ <repository name="db1tck" system-workspace="ws"
default-workspace="ws">
+ <security-domain>exo-domain</security-domain>
+ <!-- access-control>optional</access-control -->
+ <!-- access-control>disable</access-control -->
+ <session-max-age>1h</session-max-age>
+
<authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
+ <workspaces>
+ <workspace name="ws">
+ <!-- for system storage -->
+ <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name"
value="jdbcjcrtck" />
+ <property name="dialect" value="mysql" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false"
/>
+ <property name="max-buffer-size" value="200k"
/>
+ <property name="swap-directory"
value="target/temp/swap/wstck" />
+ </properties>
+ <value-storages>
+ <value-storage id="ws"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path"
value="target/temp/values/wstck" />
+ </properties>
+ <filters>
+ <filter property-type="Binary"
min-value-size="100K" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype"
value="nt:unstructured" />
+ <property name="root-permissions" value="any
read;*:/platform/administrators read;*:/platform/administrators
add_node;*:/platform/administrators set_property;*:/platform/administrators remove"
/>
+ </properties>
+ </initializer>
+ <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db1tck/ws" />
+ <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
+ <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
+ <property name="support-highlighting"
value="true" />
+ <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
+ <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
+ <property name="excerptprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.WeightedHTMLExcerpt"
/>
+ <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
+ </properties>
+ </query-handler>
+ <lock-manager>
+ <time-out>15m</time-out>
+ <persister
class="org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister">
+ <properties>
+ <property name="path"
value="target/temp/locktck" />
+ </properties>
+ </persister>
+ </lock-manager>
+ </workspace>
+
+ <workspace name="ws1">
+ <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name"
value="jdbcjcr1tck" />
+ <property name="dialect" value="mysql" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false"
/>
+ <property name="max-buffer-size" value="200k"
/>
+ <property name="swap-directory"
value="target/temp/swap/ws1tck" />
+ </properties>
+ <value-storages>
+ <value-storage id="ws1"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path"
value="target/temp/values/ws1tck" />
+ </properties>
+ <filters>
+ <filter property-type="Binary"
min-value-size="100K" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype"
value="nt:unstructured" />
+ <property name="root-permissions" value="any
read;*:/platform/administrators read;*:/platform/administrators
add_node;*:/platform/administrators set_property;*:/platform/administrators remove"
/>
+ </properties>
+ </initializer>
+ <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db1tck/ws1" />
+ <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
+ <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
+ <property name="support-highlighting"
value="true" />
+ <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
+ <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
+ <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
+ </properties>
+ </query-handler>
+ </workspace>
+
+ <workspace name="ws2">
+ <container
class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.NewJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name"
value="jdbcjcr2tck" />
+ <property name="dialect" value="mysql" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false"
/>
+ <property name="max-buffer-size" value="200k"
/>
+ <property name="swap-directory"
value="target/temp/swap/ws2tck" />
+ </properties>
+ <value-storages>
+ <value-storage id="ws2"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path"
value="target/temp/values/ws2tck" />
+ </properties>
+ <filters>
+ <filter property-type="Binary"
min-value-size="100K" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer
class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype"
value="nt:unstructured" />
+ <property name="root-permissions" value="any
read;*:/platform/administrators read;*:/platform/administrators
add_node;*:/platform/administrators set_property;*:/platform/administrators remove"
/>
+ </properties>
+ </initializer>
+ <cache enabled="true"
class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ </properties>
+ </cache>
+ <query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir"
value="target/temp/index/db1tck/ws2" />
+ <property name="synonymprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider"
/>
+ <property name="synonymprovider-config-path"
value="../../synonyms.properties" />
+ <property name="support-highlighting"
value="true" />
+ <property name="indexing-configuration-path"
value="../../indexing-configuration.xml" />
+ <property name="query-class"
value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
+ <property name="spellchecker-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval"
/>
+ <property name="excerptprovider-class"
value="org.exoplatform.services.jcr.impl.core.query.lucene.WeightedHTMLExcerpt"/>
+ <property name="extractorPoolSize"
value="2"/>
+ <property name="extractorTimeout"
value="10"/>
+ </properties>
+ </query-handler>
+ </workspace>
+ </workspaces>
+ </repository>
+ </repositories>
+</repository-service>