exo-jcr SVN: r5869 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-03-15 08:32:14 -0400 (Thu, 15 Mar 2012)
New Revision: 5869
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
Log:
EXOJCR-1809: revert changes
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2012-03-15 10:48:05 UTC (rev 5868)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2012-03-15 12:32:14 UTC (rev 5869)
@@ -75,12 +75,15 @@
private final long expirationTimeOut;
+ private final TransactionManager tm;
+
protected static final Log LOG =
ExoLogger.getLogger("org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.BufferedJBossCache");
public BufferedJBossCache(Cache<Serializable, Object> parentCache, boolean useExpiration, long expirationTimeOut)
{
super();
+ this.tm = ((CacheSPI<Serializable, Object>)parentCache).getTransactionManager();
this.parentCache = parentCache;
this.useExpiration = useExpiration;
this.expirationTimeOut = expirationTimeOut;
@@ -128,7 +131,6 @@
*/
private void commitChanges(List<ChangesContainer> containers)
{
- TransactionManager tm = getTransactionManager();
for (ChangesContainer cacheChange : containers)
{
boolean isTxCreated = false;
14 years, 1 month
exo-jcr SVN: r5868 - in jcr/branches/1.15.x: exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup and 1 other directory.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2012-03-15 06:48:05 -0400 (Thu, 15 Mar 2012)
New Revision: 5868
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java
Log:
EXOJCR-1786 : The repository container is unregenerate all components and remove this container from parent container on fail on instantiation of repository container.
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2012-03-15 10:16:50 UTC (rev 5867)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2012-03-15 10:48:05 UTC (rev 5868)
@@ -72,6 +72,7 @@
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
import java.util.List;
import javax.jcr.NamespaceRegistry;
@@ -150,11 +151,21 @@
public Void run()
{
context.setName(parent.getContext().getName() + "-" + name);
- parent.registerComponentInstance(name, RepositoryContainer.this);
+ try
+ {
+ parent.registerComponentInstance(name, RepositoryContainer.this);
+ registerComponents();
+ }
+ catch (Throwable t)
+ {
+ unregisterAllComponents();
+ parent.unregisterComponent(name);
+ throw new IllegalStateException("Can not register repository container " + name
+ + " in parent container.", t);
+ }
return null;
}
});
- registerComponents();
}
/**
@@ -172,26 +183,7 @@
public RepositoryContainer(final ExoContainer parent, RepositoryEntry config) throws RepositoryException,
RepositoryConfigurationException
{
-
- super(new MX4JComponentAdapterFactory(), parent);
-
- // Defaults:
- if (config.getAccessControl() == null)
- config.setAccessControl(AccessControlPolicy.OPTIONAL);
-
- this.config = config;
- this.name = config.getName();
- SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
- {
- public Void run()
- {
- context.setName(parent.getContext().getName() + "-" + name);
- parent.registerComponentInstance(name, RepositoryContainer.this);
- return null;
- }
- });
-
- registerComponents();
+ this(parent, config, new ArrayList<ComponentPlugin>());
}
public LocationFactory getLocationFactory()
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java 2012-03-15 10:16:50 UTC (rev 5867)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java 2012-03-15 10:48:05 UTC (rev 5868)
@@ -19,6 +19,7 @@
import org.apache.commons.collections.map.HashedMap;
import org.exoplatform.commons.utils.PrivilegedFileHelper;
import org.exoplatform.commons.utils.PrivilegedSystemHelper;
+import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.SimpleParameterEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
@@ -1457,7 +1458,269 @@
checkConent(repositoryService.getRepository(repository.getConfiguration().getName()), repository
.getConfiguration().getSystemWorkspaceName());
}
+
+ public void testCreateRepositoryAfterFailRestoreOnSystemWS() throws Exception
+ {
+ // create repository
+ RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
+ String dsName = helper.createDatasource();
+ RepositoryEntry repoEntry = helper.createRepositoryEntry(false, null, dsName);
+ service.createRepository(repoEntry);
+ ManageableRepository repository = service.getRepository(repoEntry.getName());
+
+ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(false, dsName);
+ helper.addWorkspace(repository, wsEntry);
+ service.getConfig().retain();
+
+ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
+
+ // backup
+ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+ config.setBackupDir(backDir);
+
+ RepositoryBackupChain bch = backup.startBackup(config);
+ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+ File backLog = new File(bch.getLogFilePath());
+ assertTrue(backLog.exists());
+
+ // copy repository entry and set new ata source
+ RepositoryEntry newRepoEntry = helper.copyRepositoryEntry(repoEntry);
+ String newDSName = helper.createDatasource();
+ for (WorkspaceEntry ws : newRepoEntry.getWorkspaceEntries())
+ {
+ for (int i = 0; i < ws.getContainer().getParameters().size(); i++)
+ {
+ SimpleParameterEntry spe = ws.getContainer().getParameters().get(i);
+
+ if (spe.getName().equals("source-name"))
+ {
+ ws.getContainer().getParameters().set(i, new SimpleParameterEntry(spe.getName(), newDSName));
+ break;
+ }
+ }
+ }
+
+ // create repository entry with name of data source name is wrong in system workspace
+ RepositoryEntry wrongRepoEntry = helper.copyRepositoryEntry(repoEntry);
+ for (WorkspaceEntry ws : wrongRepoEntry.getWorkspaceEntries())
+ {
+ if (repository.getConfiguration().getSystemWorkspaceName().equals(ws.getName()))
+ {
+ for (int i = 0; i < ws.getContainer().getParameters().size(); i++)
+ {
+ SimpleParameterEntry spe = ws.getContainer().getParameters().get(i);
+
+ if (spe.getName().equals("source-name"))
+ {
+ ws.getContainer().getParameters().set(i,
+ new SimpleParameterEntry(spe.getName(), spe.getValue() + "_wrong"));
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ // remove existed repository
+ removeRepositoryFully(repository.getConfiguration().getName());
+
+ // wrong restore
+ try
+ {
+ backup.restore(new RepositoryBackupChainLog(backLog), wrongRepoEntry, false);
+ fail();
+ }
+ catch (Exception e)
+ {
+ //ok
+ }
+
+ // restore
+ long timeOfRestore = System.currentTimeMillis();
+ backup.restore(new RepositoryBackupChainLog(backLog), newRepoEntry, false);
+ log.info("Total time of restore the repository = " + ((System.currentTimeMillis() - timeOfRestore)) + "ms.");
+ checkConent(repositoryService.getRepository(newRepoEntry.getName()), newRepoEntry.getSystemWorkspaceName());
+ }
+
+ public void testCreateRepositoryAfterFailRestoreOnNonSystemWS() throws Exception
+ {
+ // create repository
+ RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
+ String dsName = helper.createDatasource();
+ RepositoryEntry repoEntry = helper.createRepositoryEntry(false, null, dsName);
+ service.createRepository(repoEntry);
+
+ ManageableRepository repository = service.getRepository(repoEntry.getName());
+
+ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(false, dsName);
+ helper.addWorkspace(repository, wsEntry);
+ service.getConfig().retain();
+
+ addConent(repository, wsEntry.getName());
+
+ // backup
+ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+ config.setBackupDir(backDir);
+
+ RepositoryBackupChain bch = backup.startBackup(config);
+ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+ File backLog = new File(bch.getLogFilePath());
+ assertTrue(backLog.exists());
+
+ // copy repository entry and set new ata source
+ RepositoryEntry newRepoEntry = helper.copyRepositoryEntry(repoEntry);
+ String newDSName = helper.createDatasource();
+ for (WorkspaceEntry ws : newRepoEntry.getWorkspaceEntries())
+ {
+ for (int i = 0; i < ws.getContainer().getParameters().size(); i++)
+ {
+ SimpleParameterEntry spe = ws.getContainer().getParameters().get(i);
+
+ if (spe.getName().equals("source-name"))
+ {
+ ws.getContainer().getParameters().set(i, new SimpleParameterEntry(spe.getName(), newDSName));
+ break;
+ }
+ }
+ }
+
+ // create repository entry with name of data source name is wrong in second workspace
+ RepositoryEntry wrongRepoEntry = helper.copyRepositoryEntry(repoEntry);
+ for (WorkspaceEntry ws : wrongRepoEntry.getWorkspaceEntries())
+ {
+ if (wsEntry.getName().equals(ws.getName()))
+ {
+ for (int i = 0; i < ws.getContainer().getParameters().size(); i++)
+ {
+ SimpleParameterEntry spe = ws.getContainer().getParameters().get(i);
+
+ if (spe.getName().equals("source-name"))
+ {
+ ws.getContainer().getParameters().set(i,
+ new SimpleParameterEntry(spe.getName(), spe.getValue() + "_wrong"));
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ // remove existed repository
+ removeRepositoryFully(repository.getConfiguration().getName());
+
+ // wrong restore
+ try
+ {
+ backup.restore(new RepositoryBackupChainLog(backLog), wrongRepoEntry, false);
+ fail();
+ }
+ catch (Exception e)
+ {
+ //ok
+ }
+
+ // restore
+ long timeOfRestore = System.currentTimeMillis();
+ backup.restore(new RepositoryBackupChainLog(backLog), newRepoEntry, false);
+ log.info("Total time of restore the repository = " + ((System.currentTimeMillis() - timeOfRestore)) + "ms.");
+ checkConent(repositoryService.getRepository(newRepoEntry.getName()), wsEntry.getName());
+ }
+
+ public void testCreateRepositoryAfterFailRestoreWithFailConfiguration() throws Exception
+ {
+ // create repository
+ RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
+ String dsName = helper.createDatasource();
+ RepositoryEntry repoEntry = helper.createRepositoryEntry(false, null, dsName);
+ service.createRepository(repoEntry);
+
+ ManageableRepository repository = service.getRepository(repoEntry.getName());
+
+ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(false, dsName);
+ helper.addWorkspace(repository, wsEntry);
+ service.getConfig().retain();
+
+ addConent(repository, wsEntry.getName());
+
+ // backup
+ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+ config.setBackupDir(backDir);
+
+ RepositoryBackupChain bch = backup.startBackup(config);
+ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+ File backLog = new File(bch.getLogFilePath());
+ assertTrue(backLog.exists());
+
+ // copy repository entry and set new data source
+ RepositoryEntry newRepoEntry = helper.copyRepositoryEntry(repoEntry);
+ String newDSName = helper.createDatasource();
+ for (WorkspaceEntry ws : newRepoEntry.getWorkspaceEntries())
+ {
+ for (int i = 0; i < ws.getContainer().getParameters().size(); i++)
+ {
+ SimpleParameterEntry spe = ws.getContainer().getParameters().get(i);
+
+ if (spe.getName().equals("source-name"))
+ {
+ ws.getContainer().getParameters().set(i, new SimpleParameterEntry(spe.getName(), newDSName));
+ break;
+ }
+ }
+ }
+
+ // create repository entry with name of data source name is wrong in second workspace
+ RepositoryEntry wrongRepoEntry = helper.copyRepositoryEntry(repoEntry);
+ for (WorkspaceEntry ws : wrongRepoEntry.getWorkspaceEntries())
+ {
+ if (wsEntry.getName().equals(ws.getName()))
+ {
+ ws.getContainer().setType("wrong parameter");
+ }
+ }
+
+ // remove existed repository
+ removeRepositoryFully(repository.getConfiguration().getName());
+
+ // wrong restore
+ try
+ {
+ backup.restore(new RepositoryBackupChainLog(backLog), wrongRepoEntry, false);
+ fail();
+ }
+ catch (Exception e)
+ {
+ //ok
+ }
+
+ // restore
+ long timeOfRestore = System.currentTimeMillis();
+ backup.restore(new RepositoryBackupChainLog(backLog), newRepoEntry, false);
+ log.info("Total time of restore the repository = " + ((System.currentTimeMillis() - timeOfRestore)) + "ms.");
+ checkConent(repositoryService.getRepository(newRepoEntry.getName()), wsEntry.getName());
+ }
+
/**
* Set new backup directory in RepositoryBackupChainLog
*
14 years, 1 month
exo-jcr SVN: r5867 - jcr/branches/1.12.x/patch/1.12.13-GA/JCR-1713.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-03-15 06:16:50 -0400 (Thu, 15 Mar 2012)
New Revision: 5867
Modified:
jcr/branches/1.12.x/patch/1.12.13-GA/JCR-1713/JCR-1713.patch
Log:
JCR-1713: patch updated
Modified: jcr/branches/1.12.x/patch/1.12.13-GA/JCR-1713/JCR-1713.patch
===================================================================
--- jcr/branches/1.12.x/patch/1.12.13-GA/JCR-1713/JCR-1713.patch 2012-03-15 09:47:28 UTC (rev 5866)
+++ jcr/branches/1.12.x/patch/1.12.13-GA/JCR-1713/JCR-1713.patch 2012-03-15 10:16:50 UTC (rev 5867)
@@ -1,6 +1,79 @@
+Index: exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java
+===================================================================
+--- exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java (revision 5842)
++++ exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/ext/TestCaching.java (working copy)
+@@ -76,6 +76,8 @@
+ ContainerResponse response = service(WebDAVMethods.GET, getPathWS() + path, "", headers, null);
+
+ assertEquals(HTTPStatus.OK, response.getStatus());
++
++ ((InputStream)response.getEntity()).close();
+ }
+
+ public void testIfModifiedSince() throws Exception
+@@ -116,6 +118,8 @@
+ String cacheControlHeader = response.getHttpHeaders().get(HttpHeaders.CACHE_CONTROL).toString();
+ cacheControlHeader = cacheControlHeader.substring(1, cacheControlHeader.length() - 1);
+ assertEquals(cacheControlHeader, cacheControlType.getCacheValue());
++
++ ((InputStream)response.getEntity()).close();
+ }
+ }
+
+Index: exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestGet.java
+===================================================================
+--- exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestGet.java (revision 5842)
++++ exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/command/TestGet.java (working copy)
+@@ -80,6 +80,8 @@
+ }
+ String str = sw.toString();
+ assertEquals(fileContent, str);
++
++ content.close();
+ }
+
+ public void testNotFoundGet() throws Exception
+Index: exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
+===================================================================
+--- exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java (revision 5842)
++++ exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java (working copy)
+@@ -144,13 +144,16 @@
+ // check before any other reads
+ if (ifModifiedSince != null)
+ {
++ istream.close();
++
+ DateFormat dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.MODIFICATION, Locale.US);
+ Date lastModifiedDate = dateFormat.parse(lastModifiedProperty.getValue());
+
+ dateFormat = new SimpleDateFormat(WebDavConst.DateFormat.IF_MODIFIED_SINCE_PATTERN, Locale.US);
+ Date ifModifiedSinceDate = dateFormat.parse(ifModifiedSince);
+
+- if(ifModifiedSinceDate.getTime() >= lastModifiedDate.getTime()){
++ if (ifModifiedSinceDate.getTime() >= lastModifiedDate.getTime())
++ {
+ return Response.notModified().entity("Not Modified").build();
+ }
+ }
+@@ -181,9 +184,13 @@
+ {
+ Range range = ranges.get(0);
+ if (!validateRange(range, contentLength))
+- return Response.status(HTTPStatus.REQUESTED_RANGE_NOT_SATISFIABLE).header(
+- ExtHttpHeaders.CONTENTRANGE, "bytes */" + contentLength).build();
++ {
++ istream.close();
+
++ return Response.status(HTTPStatus.REQUESTED_RANGE_NOT_SATISFIABLE)
++ .header(ExtHttpHeaders.CONTENTRANGE, "bytes */" + contentLength).build();
++ }
++
+ long start = range.getStart();
+ long end = range.getEnd();
+ long returnedContentLength = (end - start + 1);
Index: exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/query-handler-config.xml
===================================================================
---- exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/query-handler-config.xml (revision 5698)
+--- exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/query-handler-config.xml (revision 5842)
+++ exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/query-handler-config.xml (working copy)
@@ -177,14 +177,6 @@
<jgroupsConfig multiplexerStack="jcr.stack" />
@@ -19,7 +92,7 @@
<para>See more about template configurations <link
Index: exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/lock-manager-config.xml
===================================================================
---- exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/lock-manager-config.xml (revision 5698)
+--- exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/lock-manager-config.xml (revision 5842)
+++ exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/lock-manager-config.xml (working copy)
@@ -1,143 +1,160 @@
-<?xml version='1.0' encoding='UTF-8'?>
@@ -553,7 +626,7 @@
</tbody>
Index: exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/jbosscache-configuration-templates.xml
===================================================================
---- exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/jbosscache-configuration-templates.xml (revision 5698)
+--- exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/jbosscache-configuration-templates.xml (revision 5842)
+++ exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/jbosscache-configuration-templates.xml (working copy)
@@ -84,7 +84,7 @@
<programlisting><?xml version="1.0" encoding="UTF-8"?>
@@ -634,7 +707,7 @@
<table>
Index: exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestJBossCacheWorkspaceStorageCacheInClusterMode.java
===================================================================
---- exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestJBossCacheWorkspaceStorageCacheInClusterMode.java (revision 5698)
+--- exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestJBossCacheWorkspaceStorageCacheInClusterMode.java (revision 5842)
+++ exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/TestJBossCacheWorkspaceStorageCacheInClusterMode.java (working copy)
@@ -759,6 +759,10 @@
public void rollback() throws IllegalStateException, RepositoryException
@@ -649,7 +722,7 @@
InvalidItemStateException, IllegalStateException
Index: exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
===================================================================
---- exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java (revision 5698)
+--- exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java (revision 5842)
+++ exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java (working copy)
@@ -412,6 +412,10 @@
public void commit() throws IllegalStateException, RepositoryException
@@ -670,351 +743,862 @@
public int getLastOrderNumber(NodeData parent) throws RepositoryException
{
return -1;
-Index: exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-jbosscache-lock.xml
+Index: exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java
===================================================================
---- exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-jbosscache-lock.xml (revision 5698)
-+++ exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-jbosscache-lock.xml (working copy)
-@@ -19,7 +19,7 @@
- For another cache-loader class you should use another template with
- cache-loader specific parameters
- -->
-- <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="false"
-+ <loader class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.JDBCCacheLoader" async="false" fetchPersistentState="false"
- ignoreModifications="false" purgeOnStartup="false">
- <properties>
- cache.jdbc.table.name=${jbosscache-cl-cache.jdbc.table.name}
-Index: exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lock.xml
+--- exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java (revision 5842)
++++ exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestRandomValueIO.java (working copy)
+@@ -18,16 +18,13 @@
+ */
+ package org.exoplatform.services.jcr.impl.storage.fs;
+
+-import org.exoplatform.services.jcr.JcrImplBaseTest;
+-import org.exoplatform.services.jcr.core.value.EditableBinaryValue;
+-import org.exoplatform.services.jcr.core.value.ReadableBinaryValue;
+-
+ import java.io.BufferedInputStream;
+ import java.io.ByteArrayInputStream;
+ import java.io.ByteArrayOutputStream;
+ import java.io.File;
+ import java.io.FileInputStream;
+ import java.io.IOException;
++import java.io.InputStream;
+ import java.util.Calendar;
+ import java.util.Random;
+
+@@ -35,6 +32,10 @@
+ import javax.jcr.Property;
+ import javax.jcr.Session;
+
++import org.exoplatform.services.jcr.JcrImplBaseTest;
++import org.exoplatform.services.jcr.core.value.EditableBinaryValue;
++import org.exoplatform.services.jcr.core.value.ReadableBinaryValue;
++
+ /**
+ * Created by The eXo Platform SAS
+ *
+@@ -476,7 +477,9 @@
+ testRoot.save();
+
+ byte[] buff = new byte[npos];
+- testRoot.getProperty(pname).getStream().read(buff);
++ InputStream stream = testRoot.getProperty(pname).getStream();
++ stream.read(buff);
++ stream.close();
+
+ assertEquals("Value content is wrong ", content.substring(0, npos), new String(buff));
+
+Index: exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java
===================================================================
---- exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lock.xml (revision 5698)
-+++ exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lock.xml (working copy)
-@@ -13,7 +13,7 @@
- For another cache-loader class you should use another template with
- cache-loader specific parameters
- -->
-- <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="false"
-+ <loader class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.JDBCCacheLoader" async="false" fetchPersistentState="false"
- ignoreModifications="false" purgeOnStartup="false">
- <properties>
- cache.jdbc.table.name=${jbosscache-cl-cache.jdbc.table.name}
-Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JDBCConnectionFactory.java
-===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JDBCConnectionFactory.java (revision 0)
-+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JDBCConnectionFactory.java (revision 0)
-@@ -0,0 +1,244 @@
-+/*
-+ * Copyright (C) 2012 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.core.lock.jbosscache;
+--- exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java (revision 5842)
++++ exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileIOChannel.java (working copy)
+@@ -18,6 +18,13 @@
+ */
+ package org.exoplatform.services.jcr.impl.storage.value.fs;
+
++import java.io.File;
++import java.io.FileInputStream;
++import java.io.FileOutputStream;
++import java.io.InputStream;
++import java.util.ArrayList;
++import java.util.List;
+
-+import org.exoplatform.services.log.ExoLogger;
-+import org.exoplatform.services.log.Log;
-+import org.jboss.cache.loader.AdjListJDBCCacheLoaderConfig;
-+import org.jboss.cache.loader.ConnectionFactory;
+ import junit.framework.TestCase;
+
+ import org.exoplatform.services.jcr.datamodel.ValueData;
+@@ -25,12 +32,6 @@
+ import org.exoplatform.services.jcr.impl.storage.value.ValueDataResourceHolder;
+ import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+
+-import java.io.File;
+-import java.io.FileInputStream;
+-import java.io.FileOutputStream;
+-import java.util.ArrayList;
+-import java.util.List;
+-
+ /**
+ * Created by The eXo Platform SAS.
+ *
+@@ -110,14 +111,20 @@
+ assertEquals(0, v0.getOrderNumber());
+ assertEquals(10, v0.getAsByteArray().length);
+ assertTrue(v0.isByteArray());
+- assertNotNull(v0.getAsStream());
+
++ InputStream in = v0.getAsStream();
++ assertNotNull(in);
++ in.close();
+
-+import java.sql.Connection;
-+import java.sql.SQLException;
+ ValueData v1 = channel.read("testReadFromIOChannel", 1, 11);
+ assertEquals(20, v1.getLength());
+ assertEquals(1, v1.getOrderNumber());
+ assertFalse(v1.isByteArray());
+- assertNotNull(v1.getAsStream());
+
++ in = v1.getAsStream();
++ assertNotNull(in);
++ in.close();
+
-+import javax.naming.InitialContext;
-+import javax.naming.NamingException;
-+import javax.sql.DataSource;
-+
-+/**
-+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
-+ * @version $Id$
-+ */
-+public class JDBCConnectionFactory implements ConnectionFactory
-+{
-+
-+ /**
-+ * Logger
-+ */
-+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.NonManagedConnectionFactory");
-+ private static final boolean trace = LOG.isTraceEnabled();
-+
-+ static final ThreadLocal<Connection> connection = new ThreadLocal<Connection>();
-+
-+ private DataSource dataSource;
-+ private String datasourceName;
-+
-+ public void setConfig(AdjListJDBCCacheLoaderConfig config)
-+ {
-+ datasourceName = config.getDatasourceName();
-+ }
-+
-+ public void start() throws Exception
-+ {
-+ // A datasource will be registered in JNDI in the start portion of
-+ // its lifecycle, so now that we are in start() we can look it up
-+ InitialContext ctx = null;
-+ try
-+ {
-+ ctx = new InitialContext();
-+ dataSource = (DataSource) ctx.lookup(datasourceName);
-+ if (trace)
-+ {
-+ LOG.trace("Datasource lookup for " + datasourceName + " succeded: " + dataSource);
-+ }
-+ }
-+ catch (NamingException e)
-+ {
-+ reportAndRethrowError("Failed to lookup datasource " + datasourceName, e);
-+ }
+ try
+ {
+ v1.getAsByteArray();
+Index: exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/Probe.java
+===================================================================
+--- exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/Probe.java (revision 5842)
++++ exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/Probe.java (working copy)
+@@ -20,6 +20,7 @@
+
+ import java.io.File;
+ import java.io.FileInputStream;
++import java.io.IOException;
+
+ /**
+ * Created by The eXo Platform SAS.
+@@ -47,21 +48,32 @@
+
+ public void run()
+ {
+- System.out.println("Thread started " + this.getName());
++ FileInputStream is = null;
+ try
+ {
+- FileInputStream is = new FileInputStream(file);
++ is = new FileInputStream(file);
+ while (is.read() > 0)
+ {
+ len++;
+ }
+-
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+- System.out.println("Thread finished " + this.getName() + " read: " + len);
+ finally
+ {
-+ if (ctx != null)
++ if (is != null)
+ {
+ try
+ {
-+ ctx.close();
++ is.close();
+ }
-+ catch (NamingException e)
++ catch (IOException e)
+ {
-+ LOG.warn("Failed to close naming context.", e);
+ }
+ }
+ }
-+ }
-+
-+ public void prepare(Object tx)
-+ {
-+ Connection con = getConnection();
+ }
+
+ public int getLen()
+Index: exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java
+===================================================================
+--- exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java (revision 5842)
++++ exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java (working copy)
+@@ -298,65 +298,88 @@
+ protected void compareStream(InputStream etalon, InputStream data, long etalonPos, long dataPos, long length)
+ throws IOException, CompareStreamException
+ {
+- int dindex = 0;
+ try
+ {
-+ if (con.getAutoCommit())
-+ {
-+ con.setAutoCommit(false);
-+ }
-+ }
-+ catch (Exception e)
-+ {
-+ reportAndRethrowError("Failed to set auto-commit", e);
-+ }
++ int dindex = 0;
+
+- skipStream(etalon, etalonPos);
+- skipStream(data, dataPos);
++ skipStream(etalon, etalonPos);
++ skipStream(data, dataPos);
+
+- byte[] ebuff = new byte[1024];
+- int eread = 0;
++ byte[] ebuff = new byte[1024];
++ int eread = 0;
+
+- while ((eread = etalon.read(ebuff)) > 0)
+- {
+- byte[] dbuff = new byte[eread];
+- int erindex = 0;
+- while (erindex < eread)
++ while ((eread = etalon.read(ebuff)) > 0)
+ {
+- int dread = -1;
+- try
++ byte[] dbuff = new byte[eread];
++ int erindex = 0;
++ while (erindex < eread)
+ {
+- dread = data.read(dbuff);
+- }
+- catch (IOException e)
+- {
+- throw new CompareStreamException("Streams is not equals by length or data stream is unreadable. Cause: "
+- + e.getMessage());
+- }
++ int dread = -1;
++ try
++ {
++ dread = data.read(dbuff);
++ }
++ catch (IOException e)
++ {
++ throw new CompareStreamException(
++ "Streams is not equals by length or data stream is unreadable. Cause: " + e.getMessage());
++ }
+
+- if (dread == -1)
+- {
+- throw new CompareStreamException(
+- "Streams is not equals by length. Data end-of-stream reached at position " + dindex);
+- }
+-
+- for (int i = 0; i < dread; i++)
+- {
+- byte eb = ebuff[i];
+- byte db = dbuff[i];
+- if (eb != db)
++ if (dread == -1)
+ {
+- throw new CompareStreamException("Streams is not equals. Wrong byte stored at position " + dindex
+- + " of data stream. Expected 0x" + Integer.toHexString(eb) + " '" + new String(new byte[]{eb})
+- + "' but found 0x" + Integer.toHexString(db) + " '" + new String(new byte[]{db}) + "'");
++ throw new CompareStreamException(
++ "Streams is not equals by length. Data end-of-stream reached at position " + dindex);
+ }
+
+- erindex++;
+- dindex++;
+- if (length > 0 && dindex >= length)
++ for (int i = 0; i < dread; i++)
+ {
+- return; // tested length reached
++ byte eb = ebuff[i];
++ byte db = dbuff[i];
++ if (eb != db)
++ {
++ throw new CompareStreamException("Streams is not equals. Wrong byte stored at position " + dindex
++ + " of data stream. Expected 0x" + Integer.toHexString(eb) + " '" + new String(new byte[]{eb})
++ + "' but found 0x" + Integer.toHexString(db) + " '" + new String(new byte[]{db}) + "'");
++ }
+
-+ /* Connection set in ThreadLocal, no reason to return. It was previously returned for legacy purpouses
-+ and to trace log the connection opening in JDBCCacheLoader. */
-+ connection.set(con);
++ erindex++;
++ dindex++;
++ if (length > 0 && dindex >= length)
++ {
++ return; // tested length reached
++ }
+ }
+
-+ if (trace)
-+ {
-+ LOG.trace("opened tx connection: tx=" + tx + ", con=" + con);
-+ }
-+
-+ }
-+
-+ public Connection getConnection()
-+ {
-+ Connection con = connection.get();
-+
-+ if (con == null)
-+ {
-+ try
-+ {
-+ con = checkoutConnection();
-+ // connection.set(con);
++ if (dread < eread)
++ dbuff = new byte[eread - dread];
+ }
+ }
-+ catch (SQLException e)
+
+- if (dread < eread)
+- dbuff = new byte[eread - dread];
++ if (data.available() > 0)
+ {
-+ reportAndRethrowError("Failed to get connection for datasource=" + datasourceName, e);
-+ }
-+ }
-+
-+ if (trace)
-+ {
-+ LOG.trace("using connection: " + con);
-+ }
-+
-+ return con;
-+ }
-+
-+ public Connection checkoutConnection() throws SQLException
-+ {
-+ return dataSource.getConnection();
-+ }
-+
-+ public void commit(Object tx)
-+ {
-+ Connection con = connection.get();
-+ if (con == null)
-+ {
-+ throw new IllegalStateException("Failed to commit: thread is not associated with the connection!");
-+ }
-+
-+ try
-+ {
-+ con.commit();
-+ if (trace)
-+ {
-+ LOG.trace("committed tx=" + tx + ", con=" + con);
-+ }
-+ }
-+ catch (SQLException e)
-+ {
-+ reportAndRethrowError("Failed to commit", e);
-+ }
++ throw new CompareStreamException(
++ "Streams is not equals by length. Data stream contains more data. Were read " + dindex);
+ }
+ }
+ finally
+ {
-+ closeTxConnection(con);
-+ }
-+ }
-+
-+ public void rollback(Object tx)
-+ {
-+ Connection con = connection.get();
-+
-+ try
-+ {
-+ con.rollback();
-+ if (trace)
-+ {
-+ LOG.trace("rolledback tx=" + tx + ", con=" + con);
-+ }
-+ }
-+ catch (SQLException e)
-+ {
-+ reportAndRethrowError("Failed to rollback", e);
-+ }
-+ finally
-+ {
-+ closeTxConnection(con);
-+ }
-+ }
-+
-+ public void close(Connection con)
-+ {
-+ if (con != null && con != connection.get())
-+ {
+ try
+ {
-+ con.close();
-+
-+ if (trace)
-+ {
-+ LOG.trace("closed non tx connection: " + con);
-+ }
++ data.close();
+ }
-+ catch (SQLException e)
++ catch (IOException e)
+ {
-+ LOG.warn("Failed to close connection " + con, e);
++ log.error(e.getMessage(), e);
+ }
-+ }
-+ }
-+
-+ public void stop()
-+ {
-+ }
-+
-+ private void closeTxConnection(Connection con)
-+ {
-+ safeClose(con);
-+ connection.set(null);
-+ }
-+
-+ private void safeClose(Connection con)
-+ {
-+ if (con != null)
-+ {
+
+- if (data.available() > 0)
+- {
+- throw new CompareStreamException("Streams is not equals by length. Data stream contains more data. Were read "
+- + dindex);
+ try
+ {
-+ con.close();
++ etalon.close();
+ }
-+ catch (SQLException e)
++ catch (IOException e)
+ {
-+ LOG.warn("Failed to close connection", e);
++ log.error(e.getMessage(), e);
+ }
-+ }
-+ }
+ }
+ }
+
+Index: exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/i18n/TestI18nValues.java
+===================================================================
+--- exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/i18n/TestI18nValues.java (revision 5842)
++++ exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/i18n/TestI18nValues.java (working copy)
+@@ -201,6 +201,7 @@
+ int rec = is.read(buf);
+ baos.write(buf, 0, rec);
+ }
++ is.close();
+ byte[] valueBytes = baos.toByteArray();
+ String content = new String(valueBytes, "UTF-8");
+ assertTrue("Content must be identical. '" + source + "' = '" + content + "'", equalsBinary(valueBytes, source
+@@ -264,6 +265,7 @@
+ int rec = is.read(buf);
+ baos.write(buf, 0, rec);
+ }
++ is.close();
+ byte[] valueBytes = baos.toByteArray();
+ String content = new String(valueBytes, "UTF-8");
+ assertTrue("Content must be identical. '" + source + "' = '" + content + "'", equalsBinary(valueBytes, source
+Index: exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/version/FileRestoreTest.java
+===================================================================
+--- exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/version/FileRestoreTest.java (revision 5842)
++++ exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/version/FileRestoreTest.java (working copy)
+@@ -18,16 +18,17 @@
+ */
+ package org.exoplatform.services.jcr.usecases.version;
+
+-import org.exoplatform.services.jcr.usecases.BaseUsecasesTest;
+-
+ import java.io.File;
+ import java.io.FileInputStream;
+ import java.io.FileOutputStream;
++import java.io.InputStream;
+ import java.util.Calendar;
+
+ import javax.jcr.Node;
+ import javax.jcr.version.Version;
+
++import org.exoplatform.services.jcr.usecases.BaseUsecasesTest;
+
-+ private void reportAndRethrowError(String message, Exception cause) throws IllegalStateException
-+ {
-+ LOG.error(message, cause);
-+ throw new IllegalStateException(message, cause);
-+ }
-+}
+ /**
+ * Created by The eXo Platform SAS.
+ *
+@@ -88,18 +89,18 @@
+ file.getNode("jcr:content").setProperty("jcr:data", new FileInputStream(tempFile2));
+ session.save();
+
+- log
+- .info("ADD VERSION #2 : file size = " + contentNode.getProperty("jcr:data").getStream().available() + " bytes");
+- compareStream(new FileInputStream(tempFile2), contentNode.getProperty("jcr:data").getStream());
++ InputStream in = contentNode.getProperty("jcr:data").getStream();
++ log.info("ADD VERSION #2 : file size = " + in.available() + " bytes");
++ compareStream(new FileInputStream(tempFile2), in);
+
+ file.checkin(); // v2
+ file.checkout();
+ file.getNode("jcr:content").setProperty("jcr:data", new FileInputStream(tempFile3));
+ session.save();
+
+- log
+- .info("ADD VERSION #3 : file size = " + contentNode.getProperty("jcr:data").getStream().available() + " bytes");
+- compareStream(new FileInputStream(tempFile3), contentNode.getProperty("jcr:data").getStream());
++ in = contentNode.getProperty("jcr:data").getStream();
++ log.info("ADD VERSION #3 : file size = " + in.available() + " bytes");
++ compareStream(new FileInputStream(tempFile3), in);
+
+ // restore version v2
+ Version v2 = file.getBaseVersion();
+Index: exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/TestExportImportAmongSessions.java
+===================================================================
+--- exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/TestExportImportAmongSessions.java (revision 5842)
++++ exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/common/TestExportImportAmongSessions.java (working copy)
+@@ -82,6 +82,7 @@
+ InputStream storedData = ntFile.getProperty("jcr:content/jcr:data").getStream();
+ assertTrue("AFTER EXPORT/IMPORT. Binary content must be same", checkBinaryEquals(new ByteArrayInputStream(
+ TEST_BINARY_CONTENT), storedData));
++ storedData.close();
+ }
+ catch (RepositoryException e)
+ {
+@@ -112,6 +113,7 @@
+ Node ntFile = testNode.getNode(TEST_NTFILE);
+ InputStream storedData = ntFile.getProperty("jcr:content/jcr:data").getStream();
+ assertTrue("BEFORE EXPORT/IMPORT. Binary content must be same", checkBinaryEquals(etalonData, storedData));
++ storedData.close();
+
+ File outputFile = File.createTempFile("jcr_bin_test", ".tmp");
+ outputFile.deleteOnExit();
+@@ -130,6 +132,7 @@
+ storedData = ntFile.getProperty("jcr:content/jcr:data").getStream();
+ assertTrue("AFTER EXPORT/IMPORT. Binary content must be same", checkBinaryEquals(new ByteArrayInputStream(
+ TEST_BINARY_CONTENT), storedData));
++ storedData.close();
+ }
+ catch (RepositoryException e)
+ {
+@@ -145,6 +148,7 @@
+ storedData = ntFile.getProperty("jcr:content/jcr:data").getStream();
+ assertTrue("AFTER EXPORT/IMPORT AFTER SAVE. Binary content must be same", checkBinaryEquals(
+ new ByteArrayInputStream(TEST_BINARY_CONTENT), storedData));
++ storedData.close();
+ }
+ catch (RepositoryException e)
+ {
+Index: exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-jbosscache-lock.xml
+===================================================================
+--- exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-jbosscache-lock.xml (revision 5842)
++++ exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-jbosscache-lock.xml (working copy)
+@@ -19,7 +19,7 @@
+ For another cache-loader class you should use another template with
+ cache-loader specific parameters
+ -->
+- <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="false"
++ <loader class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.JDBCCacheLoader" async="false" fetchPersistentState="false"
+ ignoreModifications="false" purgeOnStartup="false">
+ <properties>
+ cache.jdbc.table.name=${jbosscache-cl-cache.jdbc.table.name}
+Index: exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lock.xml
+===================================================================
+--- exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lock.xml (revision 5842)
++++ exo.jcr.component.core/src/test/resources/conf/standalone/test-jbosscache-lock.xml (working copy)
+@@ -13,7 +13,7 @@
+ For another cache-loader class you should use another template with
+ cache-loader specific parameters
+ -->
+- <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="false" fetchPersistentState="false"
++ <loader class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.JDBCCacheLoader" async="false" fetchPersistentState="false"
+ ignoreModifications="false" purgeOnStartup="false">
+ <properties>
+ cache.jdbc.table.name=${jbosscache-cl-cache.jdbc.table.name}
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JDBCConnectionFactory.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JDBCConnectionFactory.java (revision 0)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JDBCConnectionFactory.java (revision 0)
+@@ -0,0 +1,244 @@
++/*
++ * Copyright (C) 2012 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.core.lock.jbosscache;
++
++import org.exoplatform.services.log.ExoLogger;
++import org.exoplatform.services.log.Log;
++import org.jboss.cache.loader.AdjListJDBCCacheLoaderConfig;
++import org.jboss.cache.loader.ConnectionFactory;
++
++import java.sql.Connection;
++import java.sql.SQLException;
++
++import javax.naming.InitialContext;
++import javax.naming.NamingException;
++import javax.sql.DataSource;
++
++/**
++ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
++ * @version $Id$
++ */
++public class JDBCConnectionFactory implements ConnectionFactory
++{
++
++ /**
++ * Logger
++ */
++ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.NonManagedConnectionFactory");
++ private static final boolean trace = LOG.isTraceEnabled();
++
++ static final ThreadLocal<Connection> connection = new ThreadLocal<Connection>();
++
++ private DataSource dataSource;
++ private String datasourceName;
++
++ public void setConfig(AdjListJDBCCacheLoaderConfig config)
++ {
++ datasourceName = config.getDatasourceName();
++ }
++
++ public void start() throws Exception
++ {
++ // A datasource will be registered in JNDI in the start portion of
++ // its lifecycle, so now that we are in start() we can look it up
++ InitialContext ctx = null;
++ try
++ {
++ ctx = new InitialContext();
++ dataSource = (DataSource) ctx.lookup(datasourceName);
++ if (trace)
++ {
++ LOG.trace("Datasource lookup for " + datasourceName + " succeded: " + dataSource);
++ }
++ }
++ catch (NamingException e)
++ {
++ reportAndRethrowError("Failed to lookup datasource " + datasourceName, e);
++ }
++ finally
++ {
++ if (ctx != null)
++ {
++ try
++ {
++ ctx.close();
++ }
++ catch (NamingException e)
++ {
++ LOG.warn("Failed to close naming context.", e);
++ }
++ }
++ }
++ }
++
++ public void prepare(Object tx)
++ {
++ Connection con = getConnection();
++ try
++ {
++ if (con.getAutoCommit())
++ {
++ con.setAutoCommit(false);
++ }
++ }
++ catch (Exception e)
++ {
++ reportAndRethrowError("Failed to set auto-commit", e);
++ }
++
++ /* Connection set in ThreadLocal, no reason to return. It was previously returned for legacy purpouses
++ and to trace log the connection opening in JDBCCacheLoader. */
++ connection.set(con);
++
++ if (trace)
++ {
++ LOG.trace("opened tx connection: tx=" + tx + ", con=" + con);
++ }
++
++ }
++
++ public Connection getConnection()
++ {
++ Connection con = connection.get();
++
++ if (con == null)
++ {
++ try
++ {
++ con = checkoutConnection();
++ // connection.set(con);
++ }
++ catch (SQLException e)
++ {
++ reportAndRethrowError("Failed to get connection for datasource=" + datasourceName, e);
++ }
++ }
++
++ if (trace)
++ {
++ LOG.trace("using connection: " + con);
++ }
++
++ return con;
++ }
++
++ public Connection checkoutConnection() throws SQLException
++ {
++ return dataSource.getConnection();
++ }
++
++ public void commit(Object tx)
++ {
++ Connection con = connection.get();
++ if (con == null)
++ {
++ throw new IllegalStateException("Failed to commit: thread is not associated with the connection!");
++ }
++
++ try
++ {
++ con.commit();
++ if (trace)
++ {
++ LOG.trace("committed tx=" + tx + ", con=" + con);
++ }
++ }
++ catch (SQLException e)
++ {
++ reportAndRethrowError("Failed to commit", e);
++ }
++ finally
++ {
++ closeTxConnection(con);
++ }
++ }
++
++ public void rollback(Object tx)
++ {
++ Connection con = connection.get();
++
++ try
++ {
++ con.rollback();
++ if (trace)
++ {
++ LOG.trace("rolledback tx=" + tx + ", con=" + con);
++ }
++ }
++ catch (SQLException e)
++ {
++ reportAndRethrowError("Failed to rollback", e);
++ }
++ finally
++ {
++ closeTxConnection(con);
++ }
++ }
++
++ public void close(Connection con)
++ {
++ if (con != null && con != connection.get())
++ {
++ try
++ {
++ con.close();
++
++ if (trace)
++ {
++ LOG.trace("closed non tx connection: " + con);
++ }
++ }
++ catch (SQLException e)
++ {
++ LOG.warn("Failed to close connection " + con, e);
++ }
++ }
++ }
++
++ public void stop()
++ {
++ }
++
++ private void closeTxConnection(Connection con)
++ {
++ safeClose(con);
++ connection.set(null);
++ }
++
++ private void safeClose(Connection con)
++ {
++ if (con != null)
++ {
++ try
++ {
++ con.close();
++ }
++ catch (SQLException e)
++ {
++ LOG.warn("Failed to close connection", e);
++ }
++ }
++ }
++
++ private void reportAndRethrowError(String message, Exception cause) throws IllegalStateException
++ {
++ LOG.error(message, cause);
++ throw new IllegalStateException(message, cause);
++ }
++}
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JDBCCacheLoader.java
===================================================================
--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JDBCCacheLoader.java (revision 0)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JDBCCacheLoader.java (revision 0)
@@ -0,0 +1,62 @@
-+/*
-+ * Copyright (C) 2012 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.core.lock.jbosscache;
-+
-+import org.jboss.cache.config.CacheLoaderConfig;
-+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
-+import org.jboss.cache.loader.AdjListJDBCCacheLoaderConfig;
-+
-+/**
-+ * This class is used to override the method AdjListJDBCCacheLoader#setConfig in order
-+ * to be able to use a data source name even in case of non managed data sources.
-+ *
-+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
-+ * @version $Id$
-+ */
-+public class JDBCCacheLoader extends org.jboss.cache.loader.JDBCCacheLoader
-+{
-+
-+ @Override
-+ public void setConfig(IndividualCacheLoaderConfig base)
-+ {
-+ super.setConfig(base);
-+ AdjListJDBCCacheLoaderConfig config = processConfig(base);
-+
-+ if (config.getDatasourceName() == null)
-+ {
-+ return;
-+ }
-+ /* We create the JDBCConnectionFactory instance but the JNDI lookup is no done until
-+the start method is called, since that's when its registered in its lifecycle */
-+ cf = new JDBCConnectionFactory();
-+ /* We set the configuration */
-+ cf.setConfig(config);
-+ }
-+
-+ /**
-+ * {@inheritDoc}
-+ */
-+ @Override
-+ protected AdjListJDBCCacheLoaderConfig processConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
-+ {
-+ AdjListJDBCCacheLoaderConfig config = super.processConfig(base);
-+ config.setClassName(getClass().getName());
-+ return config;
-+ }
-+}
++/*
++ * Copyright (C) 2012 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.core.lock.jbosscache;
++
++import org.jboss.cache.config.CacheLoaderConfig;
++import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
++import org.jboss.cache.loader.AdjListJDBCCacheLoaderConfig;
++
++/**
++ * This class is used to override the method AdjListJDBCCacheLoader#setConfig in order
++ * to be able to use a data source name even in case of non managed data sources.
++ *
++ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
++ * @version $Id$
++ */
++public class JDBCCacheLoader extends org.jboss.cache.loader.JDBCCacheLoader
++{
++
++ @Override
++ public void setConfig(IndividualCacheLoaderConfig base)
++ {
++ super.setConfig(base);
++ AdjListJDBCCacheLoaderConfig config = processConfig(base);
++
++ if (config.getDatasourceName() == null)
++ {
++ return;
++ }
++ /* We create the JDBCConnectionFactory instance but the JNDI lookup is no done until
++the start method is called, since that's when its registered in its lifecycle */
++ cf = new JDBCConnectionFactory();
++ /* We set the configuration */
++ cf.setConfig(config);
++ }
++
++ /**
++ * {@inheritDoc}
++ */
++ @Override
++ protected AdjListJDBCCacheLoaderConfig processConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
++ {
++ AdjListJDBCCacheLoaderConfig config = super.processConfig(base);
++ config.setClassName(getClass().getName());
++ return config;
++ }
++}
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BinaryValue.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BinaryValue.java (revision 5842)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BinaryValue.java (working copy)
+@@ -196,9 +196,7 @@
+ // edited BLOB file, make a copy
+ try
+ {
+- EditableValueData copy =
+- new EditableValueData(oldValue.getAsStream(), oldValue.getOrderNumber(), null, -1, null);
+- return copy;
++ return new EditableValueData(oldValue.getAsStream(), oldValue.getOrderNumber(), null, -1, null);
+ }
+ catch (FileNotFoundException e)
+ {
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BaseValue.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BaseValue.java (revision 5842)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BaseValue.java (working copy)
+@@ -252,14 +252,7 @@
+ */
+ public long getLength()
+ {
+- try
+- {
+- return getLocalData(type == PropertyType.BINARY).getLength();
+- }
+- catch (IOException e)
+- {
+- throw new RuntimeException(e);
+- }
++ return getInternalData().getLength();
+ }
+
+ /**
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/exporting/SystemViewContentExporter.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/exporting/SystemViewContentExporter.java (revision 5842)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/exporting/SystemViewContentExporter.java (working copy)
+@@ -191,13 +191,20 @@
+ else
+ {
+ InputStream is = data.getAsStream();
+- byte[] buffer = new byte[3 * 1024 * 3];
+- int len;
+- while ((len = is.read(buffer)) > 0)
++ try
+ {
+- char[] charbuf1 = Base64.encode(buffer, 0, len, 0, "").toCharArray();
+- contentHandler.characters(charbuf1, 0, charbuf1.length);
++ byte[] buffer = new byte[3 * 1024 * 3];
++ int len;
++ while ((len = is.read(buffer)) > 0)
++ {
++ char[] charbuf1 = Base64.encode(buffer, 0, len, 0, "").toCharArray();
++ contentHandler.characters(charbuf1, 0, charbuf1.length);
++ }
+ }
++ finally
++ {
++ is.close();
++ }
+ }
+ }
+ }
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/exporting/SystemViewStreamExporter.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/exporting/SystemViewStreamExporter.java (revision 5842)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/exporting/SystemViewStreamExporter.java (working copy)
+@@ -190,13 +190,20 @@
+ else
+ {
+ InputStream is = data.getAsStream();
+- byte[] buffer = new byte[BUFFER_SIZE];
+- int len;
+- while ((len = is.read(buffer)) > 0)
++ try
+ {
+- char[] charbuf1 = Base64.encode(buffer, 0, len, 0, "").toCharArray();
+- writer.writeCharacters(charbuf1, 0, charbuf1.length);
++ byte[] buffer = new byte[BUFFER_SIZE];
++ int len;
++ while ((len = is.read(buffer)) > 0)
++ {
++ char[] charbuf1 = Base64.encode(buffer, 0, len, 0, "").toCharArray();
++ writer.writeCharacters(charbuf1, 0, charbuf1.length);
++ }
+ }
++ finally
++ {
++ is.close();
++ }
+ }
+ }
+ }
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java (revision 5842)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java (working copy)
+@@ -129,12 +129,10 @@
+ {
+ byte[] tmpBuff = new byte[2048];
+ int read = 0;
+- int len = 0;
+
+ while ((read = stream.read(tmpBuff)) >= 0)
+ {
+ sfout.write(tmpBuff, 0, read);
+- len += read;
+ }
+ }
+ catch (final IOException e)
+@@ -156,6 +154,10 @@
+ }
+ };
+ }
++ finally
++ {
++ stream.close();
++ }
+
+ this.data = null;
+
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java (revision 5698)
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java (revision 5842)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java (working copy)
@@ -58,6 +58,9 @@
@@ -1227,9 +1811,92 @@
public int getLastOrderNumber(final NodeData nodeData) throws RepositoryException
{
final WorkspaceStorageConnection con = dataContainer.openConnection();
+Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
+===================================================================
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java (revision 5842)
++++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java (working copy)
+@@ -57,8 +57,6 @@
+
+ protected File file;
+
+- protected FileChannel channel;
+-
+ /**
+ * Empty constructor to serialization.
+ */
+@@ -112,37 +110,46 @@
+ */
+ public long read(OutputStream stream, long length, long position) throws IOException
+ {
+- if (channel == null)
+- {
+- channel = new FileInputStream(file).getChannel();
+- }
++ FileInputStream in = new FileInputStream(file);
+
+- // validation
+- if (position >= channel.size() && position > 0)
++ try
+ {
+- throw new IOException("Position " + position + " out of value size " + channel.size());
+- }
++ FileChannel channel = in.getChannel();
+
+- if (position + length >= channel.size())
+- {
+- length = channel.size() - position;
+- }
++ // validation
++ if (position >= channel.size() && position > 0)
++ {
++ throw new IOException("Position " + position + " out of value size " + channel.size());
++ }
+
+- MappedByteBuffer bb = channel.map(FileChannel.MapMode.READ_ONLY, position, length);
++ if (position + length >= channel.size())
++ {
++ length = channel.size() - position;
++ }
+
+- WritableByteChannel ch;
+- if (stream instanceof FileOutputStream)
+- {
+- ch = ((FileOutputStream)stream).getChannel();
++ WritableByteChannel ch;
++ if (stream instanceof FileOutputStream)
++ {
++ ch = ((FileOutputStream)stream).getChannel();
++ }
++ else
++ {
++ ch = Channels.newChannel(stream);
++ }
++
++ long size = 0;
++ do
++ {
++ size += channel.transferTo(position, length, ch);
++ }
++ while (size != length);
++
++ return size;
+ }
+- else
++ finally
+ {
+- ch = Channels.newChannel(stream);
++ in.close();
+ }
+- ch.write(bb);
+- ch.close();
+-
+- return length;
+ }
+
+ /**
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java (revision 5698)
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java (revision 5842)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java (working copy)
@@ -43,7 +43,6 @@
import java.util.concurrent.CountDownLatch;
@@ -1288,7 +1955,7 @@
/**
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java
===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java (revision 5698)
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java (revision 5842)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java (working copy)
@@ -235,6 +235,10 @@
public void rollback() throws IllegalStateException, RepositoryException
@@ -1303,7 +1970,7 @@
{
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java (revision 5698)
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java (revision 5842)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java (working copy)
@@ -336,18 +336,40 @@
{
@@ -1464,7 +2131,7 @@
/**
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java
===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java (revision 5698)
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java (revision 5842)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java (working copy)
@@ -63,6 +63,12 @@
* <code>rollback()</code>
@@ -1514,7 +2181,7 @@
Statistics s = ALL_STATISTICS.get(ROLLBACK_DESCR);
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileIOChannel.java
===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileIOChannel.java (revision 5698)
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileIOChannel.java (revision 5842)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/FileIOChannel.java (working copy)
@@ -121,6 +121,15 @@
/**
@@ -1557,7 +2224,7 @@
* {@inheritDoc}
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java
===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java (revision 5698)
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java (revision 5842)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java (working copy)
@@ -148,61 +148,67 @@
* {@inheritDoc}
@@ -1665,7 +2332,7 @@
if (fileLock != null)
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/DeleteValues.java
===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/DeleteValues.java (revision 5698)
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/DeleteValues.java (revision 5842)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/DeleteValues.java (working copy)
@@ -23,6 +23,7 @@
@@ -1776,7 +2443,7 @@
}
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/WriteValue.java
===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/WriteValue.java (revision 5698)
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/WriteValue.java (revision 5842)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/WriteValue.java (working copy)
@@ -79,34 +79,47 @@
fileLock = new ValueFileLock(file);
@@ -1840,7 +2507,7 @@
}
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableDeleteValues.java
===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableDeleteValues.java (revision 5698)
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableDeleteValues.java (revision 5842)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableDeleteValues.java (working copy)
@@ -81,11 +81,11 @@
* {@inheritDoc}
@@ -1858,7 +2525,7 @@
{
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java
===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java (revision 5698)
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java (revision 5842)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java (working copy)
@@ -276,4 +276,19 @@
@@ -1882,7 +2549,7 @@
}
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/ValueOperation.java
===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/ValueOperation.java (revision 5698)
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/ValueOperation.java (revision 5842)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/ValueOperation.java (working copy)
@@ -49,11 +49,26 @@
void rollback() throws IOException;
@@ -1914,7 +2581,7 @@
}
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java
===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java (revision 5698)
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java (revision 5842)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java (working copy)
@@ -38,7 +38,7 @@
* should have "opened" state. The connection becomes "closed" (invalid for using) after calling
@@ -2138,7 +2805,7 @@
Index: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/value/ValueIOChannel.java
===================================================================
---- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/value/ValueIOChannel.java (revision 5698)
+--- exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/value/ValueIOChannel.java (revision 5842)
+++ exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/value/ValueIOChannel.java (working copy)
@@ -78,12 +78,28 @@
String getStorageId();
@@ -2172,7 +2839,7 @@
* Rollback channel changes.
Index: exo.jcr.component.core/src/main/resources/conf/portal/cluster/jbosscache-lock.xml
===================================================================
---- exo.jcr.component.core/src/main/resources/conf/portal/cluster/jbosscache-lock.xml (revision 5698)
+--- exo.jcr.component.core/src/main/resources/conf/portal/cluster/jbosscache-lock.xml (revision 5842)
+++ exo.jcr.component.core/src/main/resources/conf/portal/cluster/jbosscache-lock.xml (working copy)
@@ -18,7 +18,7 @@
For another cache-loader class you should use another template with
@@ -2183,3 +2850,4067 @@
ignoreModifications="false" purgeOnStartup="false">
<properties>
cache.jdbc.table.name=${jbosscache-cl-cache.jdbc.table.name}
+Index: exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/BaseStandaloneTest.java
+===================================================================
+--- exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/BaseStandaloneTest.java (revision 5842)
++++ exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/BaseStandaloneTest.java (working copy)
+@@ -295,60 +295,67 @@
+ protected void compareStream(InputStream etalon, InputStream data, long etalonPos, long dataPos, long length)
+ throws IOException, CompareStreamException
+ {
++ try
++ {
++ int dindex = 0;
+
+- int dindex = 0;
++ skipStream(etalon, etalonPos);
++ skipStream(data, dataPos);
+
+- skipStream(etalon, etalonPos);
+- skipStream(data, dataPos);
++ byte[] ebuff = new byte[1024];
++ int eread = 0;
+
+- byte[] ebuff = new byte[1024];
+- int eread = 0;
++ while ((eread = etalon.read(ebuff)) > 0)
++ {
+
+- while ((eread = etalon.read(ebuff)) > 0)
+- {
+-
+- byte[] dbuff = new byte[eread];
+- int erindex = 0;
+- while (erindex < eread)
+- {
+- int dread = -1;
+- try
++ byte[] dbuff = new byte[eread];
++ int erindex = 0;
++ while (erindex < eread)
+ {
+- dread = data.read(dbuff);
+- }
+- catch (IOException e)
+- {
+- throw new CompareStreamException("Streams is not equals by length or data stream is unreadable. Cause: "
+- + e.getMessage());
+- }
++ int dread = -1;
++ try
++ {
++ dread = data.read(dbuff);
++ }
++ catch (IOException e)
++ {
++ throw new CompareStreamException(
++ "Streams is not equals by length or data stream is unreadable. Cause: " + e.getMessage());
++ }
+
+- if (dread == -1)
+- throw new CompareStreamException(
+- "Streams is not equals by length. Data end-of-stream reached at position " + dindex);
++ if (dread == -1)
++ throw new CompareStreamException(
++ "Streams is not equals by length. Data end-of-stream reached at position " + dindex);
+
+- for (int i = 0; i < dread; i++)
+- {
+- byte eb = ebuff[i];
+- byte db = dbuff[i];
+- if (eb != db)
+- throw new CompareStreamException("Streams is not equals. Wrong byte stored at position " + dindex
+- + " of data stream. Expected 0x" + Integer.toHexString(eb) + " '" + new String(new byte[]{eb})
+- + "' but found 0x" + Integer.toHexString(db) + " '" + new String(new byte[]{db}) + "'");
++ for (int i = 0; i < dread; i++)
++ {
++ byte eb = ebuff[i];
++ byte db = dbuff[i];
++ if (eb != db)
++ throw new CompareStreamException("Streams is not equals. Wrong byte stored at position " + dindex
++ + " of data stream. Expected 0x" + Integer.toHexString(eb) + " '" + new String(new byte[]{eb})
++ + "' but found 0x" + Integer.toHexString(db) + " '" + new String(new byte[]{db}) + "'");
+
+- erindex++;
+- dindex++;
+- if (length > 0 && dindex >= length)
+- return; // tested length reached
++ erindex++;
++ dindex++;
++ if (length > 0 && dindex >= length)
++ return; // tested length reached
++ }
++
++ if (dread < eread)
++ dbuff = new byte[eread - dread];
+ }
++ }
+
+- if (dread < eread)
+- dbuff = new byte[eread - dread];
+- }
++ if (data.available() > 0)
++ throw new CompareStreamException(
++ "Streams is not equals by length. Data stream contains more data. Were read " + dindex);
+ }
+-
+- if (data.available() > 0)
+- throw new CompareStreamException("Streams is not equals by length. Data stream contains more data. Were read "
+- + dindex);
++ finally
++ {
++ etalon.close();
++ data.close();
++ }
+ }
+
+ protected void skipStream(InputStream stream, long pos) throws IOException
+Index: exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java
+===================================================================
+--- exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java (revision 5842)
++++ exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java (working copy)
+@@ -16,26 +16,29 @@
+ */
+ package org.exoplatform.services.jcr.ext.backup;
+
++import java.io.File;
++import java.io.FileInputStream;
++import java.io.FileOutputStream;
++import java.io.IOException;
++import java.io.InputStream;
++import java.io.OutputStream;
++import java.util.List;
++import java.util.Map;
++
++import javax.jcr.Node;
++
+ import org.apache.commons.collections.map.HashedMap;
+ import org.exoplatform.services.jcr.config.RepositoryEntry;
++import org.exoplatform.services.jcr.config.SimpleParameterEntry;
+ import org.exoplatform.services.jcr.config.WorkspaceEntry;
+ import org.exoplatform.services.jcr.core.ManageableRepository;
+ import org.exoplatform.services.jcr.ext.backup.impl.JobRepositoryRestore;
+ import org.exoplatform.services.jcr.ext.backup.impl.JobWorkspaceRestore;
+-import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
++import org.exoplatform.services.jcr.impl.Constants;
+ import org.exoplatform.services.jcr.impl.core.SessionImpl;
++import org.exoplatform.services.jcr.util.IdGenerator;
++import org.exoplatform.services.jcr.util.TesterConfigurationHelper;
+
+-import java.io.ByteArrayInputStream;
+-import java.io.File;
+-import java.io.FileInputStream;
+-import java.util.Map;
+-
+-import javax.jcr.Node;
+-import javax.jcr.RepositoryException;
+-import javax.jcr.Session;
+-import javax.jcr.Value;
+-import javax.jcr.lock.Lock;
+-
+ /**
+ * Created by The eXo Platform SAS.
+ *
+@@ -44,613 +47,246 @@
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id: AbstractBackupUseCasesTest.java 3709 2010-12-22 11:56:25Z tolusha $
+ */
+-public abstract class AbstractBackupUseCasesTest
+- extends AbstractBackupTestCase
++public abstract class AbstractBackupUseCasesTest extends AbstractBackupTestCase
+ {
+
+- private static volatile long uuIndex;
++ protected TesterConfigurationHelper helper = TesterConfigurationHelper.getInstance();
+
+- protected static synchronized long getUUIndex()
++ File blob;
++
++ public void setUp() throws Exception
+ {
+- return uuIndex++;
++ super.setUp();
++ blob = createBLOBTempFile(300);
+ }
+
+ public void testFullBackupRestore() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(true, null);
++ helper.addWorkspace(repository, wsEntry);
++ addConent(repository, wsEntry.getName());
++
+ // backup
+- File backDir = new File("target/backup/" + workspaceNameToBackup + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+-
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
+-
+ // restore
+- RepositoryEntry re =
+- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+- WorkspaceEntry ws1back = makeWorkspaceEntry(workspaceNameToRestore, dataSourceToWorkspaceRestore);
++ WorkspaceEntry newWS = helper.createWorkspaceEntry(true, null);
+
+- // BackupChainLog bchLog = new BackupChainLog(backDir, rconfig);
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+- backup.restore(bchLog, re.getName(), ws1back, false);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) getReposityToBackup().login(credentials, workspaceNameToRestore);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.restore(bchLog, config.getRepository(), newWS, false);
++ checkConent(repository, newWS.getName());
+ }
+
+ public void testIncrementalBackupRestore() throws Exception
+ {
+- // full backup & incremental
+- File backDir = new File("target/backup/" + workspaceNameToBackup + getUUIndex());
+- backDir.mkdirs();
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(true, null);
++ helper.addWorkspace(repository, wsEntry);
++ addConent(repository, wsEntry.getName());
+
+- BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
+- config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
+-
+- config.setBackupDir(backDir);
+-
+- backup.startBackup(config);
+-
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // add some changes which will be logged in incremental log
+- ws1TestRoot.getNode("node_3").remove();
+- ws1TestRoot.getNode("node_4").remove();
+- ws1TestRoot.getNode("node_5").remove();
+- ws1TestRoot.addNode("node #3").setProperty("exo:data", "property #3");
+- ws1TestRoot.addNode("node #5").setProperty("exo:extraData", "property #5");
+-
+- ws1TestRoot.addNode("binary_data").setProperty("data", new FileInputStream(createBLOBTempFile(500)));
+-
+- ws1TestRoot.save(); // log here via listener
+-
+- // stop all
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
+-
+- // restore
+- RepositoryEntry re =
+- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+- WorkspaceEntry ws1back = makeWorkspaceEntry(workspaceNameToRestore, dataSourceToWorkspaceRestore);
+-
+- File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
+-
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
+-
+- backup.restore(bchLog, repositoryNameToBackup, ws1back, false);
+-
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) getReposityToBackup().login(credentials, workspaceNameToRestore);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertFalse("Node should be removed", ws1backTestRoot.hasNode("node_3"));
+- assertFalse("Node should be removed", ws1backTestRoot.hasNode("node_4"));
+- assertFalse("Node should be removed", ws1backTestRoot.hasNode("node_5"));
+-
+- assertEquals("Restored content should be same", "property #3", ws1backTestRoot.getNode("node #3")
+- .getProperty("exo:data").getString());
+- assertEquals("Restored content should be same", "property #5", ws1backTestRoot.getNode("node #5")
+- .getProperty("exo:extraData").getString());
+-
+- assertFalse("Proeprty should be removed", ws1backTestRoot.getNode("node #5").hasProperty("exo:data"));
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
+- }
+-
+- public void testIncrementalBackupRestore2() throws Exception
+- {
+- // full backup with BLOBs & incremental with BLOBs
+-
+- // BLOBs for full
+- File tempf = createBLOBTempFile("testIncrementalBackupRestore2-", 5 * 1024); // 5M
+- tempf.deleteOnExit();
+- ws1TestRoot.addNode("node_101").setProperty("exo:data", new FileInputStream(tempf));
+- ws1TestRoot.addNode("node_102").setProperty("exo:extraData", new FileInputStream(tempf));
+-
+- File backDir = new File("target/backup/" + workspaceNameToBackup + getUUIndex());
++ // backup
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
+ config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
++ addIncrementalConent(repository, wsEntry.getName());
+
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
++ backup.stopBackup(bch);
+
+- // add some changes which will be logged in incremental log
+- ws1TestRoot.addNode("node #53").setProperty("exo:extraData", "property #53");
+- ws1TestRoot.save(); // log here via listener
+-
+- // BLOBs for incr
+- ws1TestRoot.getNode("node_1").setProperty("exo:extraData", new FileInputStream(tempf));
+- ws1TestRoot.getNode("node_5").setProperty("exo:data", new FileInputStream(tempf));
+-
+- ws1TestRoot.addNode("node_101").setProperty("exo:data", new FileInputStream(tempf));
+- ws1TestRoot.addNode("node_102").setProperty("exo:data", new FileInputStream(tempf));
+- ws1TestRoot.save(); // log here via listener
+-
+- ws1TestRoot.getNode("node_2").setProperty("exo:data", (Value) null); // remove property
+- ws1TestRoot.getNode("node_3").setProperty("exo:data", new ByteArrayInputStream("aaa".getBytes())); // set
+- // aaa
+- // bytes
+- ws1TestRoot.getNode("node_4").remove(); // (*)
+- ws1TestRoot.save(); // log here via listener
+-
+- ws1TestRoot.getNode("node_5").addMixin("mix:lockable");
+- ws1TestRoot.save(); // log here via listener
+- Lock n107lock = ws1TestRoot.getNode("node_5").lock(true, false);
+- ws1TestRoot.getSession().move(ws1TestRoot.getNode("node #53").getPath(),
+- ws1TestRoot.getNode("node_5").getPath() + "/node #53");
+- ws1TestRoot.save(); // log here via listener
+-
+- ws1TestRoot.getNode("node_6").addMixin("mix:referenceable");
+- String id6 = ws1TestRoot.getNode("node_6").getUUID();
+- ws1TestRoot.save(); // log here via listener
+-
+- // before(*), log here via listener
+- ws1TestRoot.getSession().getWorkspace().move(ws1TestRoot.getNode("node_6").getPath(),
+- ws1TestRoot.getPath() + "/node_4"); // in place of
+- // 4 removed
+-
+- // stop all
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
+-
+ // restore
+- RepositoryEntry re =
+- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+- WorkspaceEntry ws1back = makeWorkspaceEntry(workspaceNameToRestore, dataSourceToWorkspaceRestore);
++ WorkspaceEntry newWS = helper.createWorkspaceEntry(true, null);
+
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+- backup.restore(bchLog, repositoryNameToBackup, ws1back, false);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) getReposityToBackup().login(credentials, workspaceNameToRestore);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+-
+- assertTrue("Node should exists", ws1backTestRoot.getNode("node_5").hasNode("node #53"));
+- assertTrue("Property should exists", ws1backTestRoot.getNode("node_5")
+- .hasProperty("node #53/exo:extraData"));
+-
+- assertTrue("Node should exists", ws1backTestRoot.hasNode("node_7"));
+- assertTrue("Property should exists", ws1backTestRoot.hasProperty("node_5/exo:data"));
+- assertTrue("Property should exists", ws1backTestRoot.hasProperty("node_1/exo:extraData"));
+- assertTrue("Node should exists", ws1backTestRoot.hasNode("node_102"));
+-
+- compareStream(new FileInputStream(tempf), ws1backTestRoot.getNode("node_5").getProperty("exo:data")
+- .getStream());
+- compareStream(new FileInputStream(tempf), ws1backTestRoot.getNode("node_1").getProperty("exo:extraData")
+- .getStream());
+-
+- assertFalse("Property should be removed", ws1backTestRoot.getNode("node_2").hasProperty("exo:data"));
+-
+- compareStream(new ByteArrayInputStream("aaa".getBytes()), ws1backTestRoot.getNode("node_3").getProperty(
+- "exo:data").getStream());
+-
+- assertTrue("Node should be mix:lockable ", ws1backTestRoot.getNode("node_5").isNodeType("mix:lockable"));
+- assertFalse("Node should be not locked ", ws1backTestRoot.getNode("node_5").isLocked());
+-
+- assertEquals("Node should be mix:referenceable and UUID should be " + id6, id6, ws1backTestRoot.getNode(
+- "node_4").getUUID());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.restore(bchLog, config.getRepository(), newWS, false);
++ checkConent(repository, newWS.getName());
++ checkIncrementalConent(repository, newWS.getName());
+ }
+
+ public void testFullBackupRestoreAsync() throws Exception
+ {
+- SessionImpl sessionWS1 = (SessionImpl) getReposityToBackup().login(credentials, workspaceNameToBackup);
+- sessionWS1.getRootNode().getNode("backupTest").getNode("node_5").setProperty("exo:data",
+- "Restored content should be same");
+- sessionWS1.save();
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(true, null);
++ helper.addWorkspace(repository, wsEntry);
++ addConent(repository, wsEntry.getName());
+
+ // backup
+- File backDir = new File("target/backup/" + workspaceNameToBackup + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+-
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
+-
+ // restore
+- WorkspaceEntry ws1back = makeWorkspaceEntry(workspaceNameToRestore, dataSourceToWorkspaceRestore);
++ WorkspaceEntry newWS = helper.createWorkspaceEntry(true, null);
+
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+- backup.restore(bchLog, repositoryNameToBackup, ws1back, true);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- while (backup.getLastRestore(repositoryNameToBackup, workspaceNameToRestore).getStateRestore() != JobWorkspaceRestore.RESTORE_SUCCESSFUL
+- && backup.getLastRestore(repositoryNameToBackup, workspaceNameToRestore).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
+- {
+- Thread.sleep(50);
+- }
++ backup.restore(bchLog, config.getRepository(), newWS, true);
++ waitEndOfRestore(config.getRepository(), newWS.getName());
+
+- if (backup.getLastRestore(repositoryNameToBackup, workspaceNameToRestore).getStateRestore() == JobWorkspaceRestore.RESTORE_FAIL)
+- throw (Exception) backup.getLastRestore(repositoryNameToBackup, workspaceNameToRestore)
+- .getRestoreException();
+-
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) getReposityToBackup().login(credentials, workspaceNameToRestore);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "Restored content should be same", ws1backTestRoot.getNode(
+- "node_5").getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ assertEquals(backup.getLastRestore(config.getRepository(), newWS.getName()).getStateRestore(),
++ JobWorkspaceRestore.RESTORE_SUCCESSFUL);
++ checkConent(repository, newWS.getName());
+ }
+
+ public void testAutoStopBackupFull() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(true, null);
++ helper.addWorkspace(repository, wsEntry);
++
+ // backup
+- File backDir = new File("target/backup/" + workspaceNameToBackup + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+
+- while (!bch.isFinished())
++ Thread.sleep(30000);
++ try
+ {
+- Thread.yield();
+- Thread.sleep(50);
++ assertEquals(backup.getCurrentBackups().size(), 0);
+ }
+-
+- Thread.sleep(5000);
+-
+- for (BackupChain chain : backup.getCurrentBackups())
+- if (bch.getBackupId().equals(chain.getBackupId()))
+- fail("The backup with id '" + chain.getBackupId() + "' should not be active");
++ finally
++ {
++ backup.stopBackup(bch);
++ }
+ }
+
+ public void testAutoStopBackupIncr() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(true, null);
++ helper.addWorkspace(repository, wsEntry);
++
+ // backup
+- File backDir = new File("target/backup/" + workspaceNameToBackup + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
+ config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
+- config.setBackupDir(backDir);
+ config.setIncrementalJobPeriod(3);
+ config.setIncrementalJobNumber(0);
++ config.setBackupDir(backDir);
+
+ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
++ Thread.sleep(10000);
++ try
+ {
+- Thread.yield();
+- Thread.sleep(50);
++ assertEquals(backup.getCurrentBackups().size(), 1);
+ }
+-
+- boolean isFail = true;
+-
+- for (BackupChain chain : backup.getCurrentBackups())
+- if (bch.getBackupId().equals(chain.getBackupId()))
+- isFail = false;
+-
+- if (isFail)
+- fail("The backup with id '" + bch.getBackupId() + "' should be active");
+-
+- backup.stopBackup(bch);
++ finally
++ {
++ backup.stopBackup(bch);
++ }
+ }
+
+- public void testAutoStopBackupIncrRepetion() throws Exception
++ public void _testAutoStopBackupIncrRepetion() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(true, null);
++ helper.addWorkspace(repository, wsEntry);
++
+ // backup
+- File backDir = new File("target/backup/" + workspaceNameToBackup + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
+ config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
+- config.setBackupDir(backDir);
+ config.setIncrementalJobPeriod(4);
+ config.setIncrementalJobNumber(2);
++ config.setBackupDir(backDir);
+
+- final BackupChain bch = backup.startBackup(config);
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+
+- while (!bch.isFinished())
++ Thread.sleep(60000);
++ try
+ {
+- Thread.yield();
+- Thread.sleep(50);
++ assertEquals(backup.getCurrentBackups().size(), 0);
+ }
+-
+- Thread.sleep(5000);
+-
+- for (BackupChain chain : backup.getCurrentBackups())
+- if (bch.getBackupId().equals(chain.getBackupId()))
+- fail("The backup with id '" + chain.getBackupId() + "' should not be active");
+- }
+-
+- public void testTwoRestores() throws Exception
+- {
++ finally
+ {
+- SessionImpl sessionWS1 = (SessionImpl) getReposityToBackup().login(credentials, workspaceNameToBackup);
+-
+- sessionWS1.getRootNode().addNode("asdasdasda", "nt:unstructured").setProperty("data",
+- new FileInputStream(createBLOBTempFile(1024)));
+- sessionWS1.save();
+-
+- // 1-st backup
+- File backDir = new File("target/backup/" + workspaceNameToBackup + getUUIndex());
+- backDir.mkdirs();
+-
+- BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
+- config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+- config.setBackupDir(backDir);
+-
+- BackupChain bch = backup.startBackup(config);
+-
+- // wait till full backup will be stopped
+- while (!bch.isFinished())
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // 1-st restore
+- WorkspaceEntry ws1_restore_1 = makeWorkspaceEntry(workspaceNameToRestore, dataSourceToWorkspaceRestore);
+-
+- File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
+-
+- backup.restore(bchLog, repositoryNameToBackup, ws1_restore_1, false);
+-
+- // check
+- SessionImpl back1 = (SessionImpl) getReposityToBackup().login(credentials, workspaceNameToRestore);
+- assertNotNull(back1.getRootNode().getNode("asdasdasda").getProperty("data"));
+-
+- // add date to restored workspace
+- back1.getRootNode().addNode("gdfgrghfhf", "nt:unstructured").setProperty("data",
+- new FileInputStream(createBLOBTempFile(1024)));
+- back1.save();
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.stopBackup(bch);
+ }
+-
+- {
+- // 2-st backup
+- File backDir = new File("target/backup/" + workspaceNameToBackup + getUUIndex());
+- backDir.mkdirs();
+-
+- BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToRestore);
+- config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+- config.setBackupDir(backDir);
+-
+- BackupChain bch = backup.startBackup(config);
+-
+- // wait till full backup will be stopped
+- while (!bch.isFinished())
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- removeWorkspaceFully(repositoryNameToBackup, workspaceNameToRestore);
+-
+- // 2-st restore
+- WorkspaceEntry ws1_restore_2 = makeWorkspaceEntry(workspaceNameToRestore, dataSourceToWorkspaceRestore);
+-
+- File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
+-
+- backup.restore(bchLog, repositoryNameToBackup, ws1_restore_2, false);
+-
+- // check
+- SessionImpl back2 = (SessionImpl) getReposityToBackup().login(credentials, workspaceNameToRestore);
+- assertNotNull(back2.getRootNode().getNode("gdfgrghfhf").getProperty("data"));
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
+- }
+ }
+
+- public void testStartFullBackupWIthJobPeriod() throws Exception
+- {
+- // backup
+- File backDir = new File("target/backup" + workspaceNameToBackup + getUUIndex());
+- backDir.mkdirs();
+-
+- BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
+- config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+- config.setBackupDir(backDir);
+- config.setIncrementalJobPeriod(3600);
+-
+- backup.startBackup(config);
+-
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+- }
+-
+ public void testNegativeIncremetalJobPeriod() throws Exception
+ {
+ // backup
+- File backDir = new File("target/backup/ws1_negative_period" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository("fake");
++ config.setWorkspace("fake");
+ config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
+ config.setIncrementalJobPeriod(-1000);
+-
+ config.setBackupDir(backDir);
+
+ try
+@@ -660,22 +296,20 @@
+ }
+ catch (BackupConfigurationException e)
+ {
+- //ok
+ }
+ }
+
+ public void testNegativeIncremetalJobNumber() throws Exception
+ {
+ // backup
+- File backDir = new File("target/backup/ws1_negative_job_number" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository("fake");
++ config.setWorkspace("fake");
+ config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
+ config.setIncrementalJobNumber(-5);
+-
+ config.setBackupDir(backDir);
+
+ try
+@@ -685,2051 +319,1233 @@
+ }
+ catch (BackupConfigurationException e)
+ {
+- //ok
+ }
+ }
+
+- public void testRestoreAfterFAilureRestore() throws Exception
++ public void testRestoreAfterFailureRestore() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(true, null);
++ helper.addWorkspace(repository, wsEntry);
++ addConent(repository, wsEntry.getName());
++
+ // backup
+- File backDir = new File("target/backup/" + workspaceNameToBackup + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+-
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
+-
+ // restore
+- RepositoryEntry re =
+- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+- WorkspaceEntry ws1back = makeWorkspaceEntry(workspaceNameToRestore, dataSourceToWorkspaceRestore + "NOT_EXIST");
++ WorkspaceEntry newWS = helper.createWorkspaceEntry(true, "NOT_EXISTED_DS");
+
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- try
+- {
+- backup.restore(bchLog, repositoryNameToBackup, ws1back, false);
+- fail("The backup can not be restored.");
+- }
+- catch (Exception e)
+- {
+- //ok
++ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+- WorkspaceEntry ws1backTwo = makeWorkspaceEntry(workspaceNameToRestore, dataSourceToWorkspaceRestore);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- backup.restore(bchLog, repositoryNameToBackup, ws1backTwo, false);
+- }
+-
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) getReposityToBackup().login(credentials, workspaceNameToRestore);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
++ try
++ {
++ backup.restore(bchLog, config.getRepository(), newWS, false);
++ fail("Exception should be thrown");
+ }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ catch (Exception e)
++ {
++ }
++
++ newWS = helper.createWorkspaceEntry(true, null);
++ backup.restore(bchLog, config.getRepository(), newWS, false);
++
++ checkConent(repository, newWS.getName());
+ }
+
+ public void testRepositoryFullBackupRestore() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
+-
+- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getState() != RepositoryBackupChain.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+-
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+ // restore
+- RepositoryEntry newRepositoryEntry =
+- makeRepositoryEntry(repositoryNameToRestore, getReposityToBackup().getConfiguration(),
+- dataSourceToRepositoryRestore, null);
++ RepositoryEntry newRE =
++ helper.createRepositoryEntry(true, repository.getConfiguration().getSystemWorkspaceName(), null);
+
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+- backup.restore(bchLog, newRepositoryEntry, false);
+- assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(
+- newRepositoryEntry.getName()).getStateRestore());
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- // check
+- ManageableRepository restoredRepository = repositoryService.getRepository(repositoryNameToRestore);
+-
+- for (String wsName : restoredRepository.getWorkspaceNames())
+- {
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.restore(bchLog, newRE, false);
++ checkConent(repositoryService.getRepository(newRE.getName()), newRE.getSystemWorkspaceName());
+ }
+
+ public void testRepositoryFullAndIncrementalBackupRestore() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
+- config.setIncrementalJobPeriod(1000);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+
+- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryNameToBackup);
++ addIncrementalConent(repository, repository.getConfiguration().getSystemWorkspaceName());
+
+- // wait till full backup will be stopped
+- while (bch.getState() != RepositoryBackupChain.FULL_BACKUP_FINISHED_INCREMENTAL_BACKUP_WORKING)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- //will be saved in incremental backup
+- Session wsSession = getReposityToBackup().login(credentials, "ws");
+- wsSession.getRootNode().getNode("backupTest").addNode("binary_data")
+- .setProperty("data",
+- new FileInputStream(createBLOBTempFile(500)));
+- wsSession.save();
+-
+- // stop fullBackup
+-
+ backup.stopBackup(bch);
+
+ // restore
+- RepositoryEntry newRepositoryEntry =
+- makeRepositoryEntry(repositoryNameToRestore, getReposityToBackup().getConfiguration(),
+- dataSourceToRepositoryRestore, null);
++ RepositoryEntry newRE =
++ helper.createRepositoryEntry(true, repository.getConfiguration().getSystemWorkspaceName(), null);
+
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+- backup.restore(bchLog, newRepositoryEntry, false);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- // check
+- ManageableRepository restoredRepository = repositoryService.getRepository(repositoryNameToRestore);
+-
+- for (String wsName : restoredRepository.getWorkspaceNames())
+- {
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+-
+- if (wsName.equals("ws"))
+- {
+- assertNotNull(ws1backTestRoot.getNode("binary_data"));
+- assertNotNull(ws1backTestRoot.getNode("binary_data").getProperty("data"));
+- }
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.restore(bchLog, newRE, false);
++ checkConent(repositoryService.getRepository(newRE.getName()), newRE.getSystemWorkspaceName());
++ checkIncrementalConent(repositoryService.getRepository(newRE.getName()), newRE.getSystemWorkspaceName());
+ }
+
+ public void testRepositoryFullBackupAsynchronusRestore() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
+-
+- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getState() != RepositoryBackupChain.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+-
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+ // restore
+- RepositoryEntry newRepositoryEntry =
+- makeRepositoryEntry(repositoryNameToRestore, getReposityToBackup().getConfiguration(),
+- dataSourceToRepositoryRestore, null);
++ RepositoryEntry newRE =
++ helper.createRepositoryEntry(true, repository.getConfiguration().getSystemWorkspaceName(), null);
+
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+- backup.restore(bchLog, newRepositoryEntry, true);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- JobRepositoryRestore job = backup.getLastRepositoryRestore(repositoryNameToRestore);
++ backup.restore(bchLog, newRE, true);
++ waitEndOfRestore(newRE.getName());
+
+- while (job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL
+- || job.getStateRestore() == JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // check
+- ManageableRepository restoredRepository = repositoryService.getRepository(repositoryNameToRestore);
+-
+- for (String wsName : restoredRepository.getWorkspaceNames())
+- {
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ checkConent(repositoryService.getRepository(newRE.getName()), newRE.getSystemWorkspaceName());
+ }
+
+ public void testRepositoryFullBackupAsynchronusRestoreWorkspaceMapping() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
+-
+- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getState() != RepositoryBackupChain.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+-
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+ // restore
+- RepositoryEntry newRepositoryEntry =
+- makeRepositoryEntry(repositoryNameToRestore, getReposityToBackup().getConfiguration(),
+- dataSourceToRepositoryRestore, null);
++ RepositoryEntry newRE = helper.createRepositoryEntry(true, null, null);
+
+ // create workspace mappingS
+ Map<String, String> workspaceMapping = new HashedMap();
+- for (WorkspaceEntry we : newRepositoryEntry.getWorkspaceEntries())
+- {
+- workspaceMapping.put(we.getName(), we.getName() + "_mapped");
+- }
++ workspaceMapping.put(repository.getConfiguration().getSystemWorkspaceName(), newRE.getSystemWorkspaceName());
+
+- // Change workspaeNames
+- for (WorkspaceEntry we : newRepositoryEntry.getWorkspaceEntries())
+- {
+- if (newRepositoryEntry.getSystemWorkspaceName().equals(we.getName()))
+- {
+- newRepositoryEntry.setSystemWorkspaceName(workspaceMapping.get(we.getName()));
+- newRepositoryEntry.setDefaultWorkspaceName(workspaceMapping.get(we.getName()));
+- }
+-
+- we.setName(workspaceMapping.get(we.getName()));
+- we.setUniqueName(we.getUniqueName() + workspaceMapping.get(we.getName()));
+- }
+-
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+- backup.restore(bchLog, newRepositoryEntry, workspaceMapping, true);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- JobRepositoryRestore job = backup.getLastRepositoryRestore(repositoryNameToRestore);
++ backup.restore(bchLog, newRE, workspaceMapping, true);
++ waitEndOfRestore(newRE.getName());
+
+- while (job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL
+- || job.getStateRestore() == JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // check
+- ManageableRepository restoredRepository = repositoryService.getRepository(repositoryNameToRestore);
+-
+- for (String wsName : restoredRepository.getWorkspaceNames())
+- {
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) restoredRepository.login(credentials, workspaceMapping.get(wsName));
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ checkConent(repositoryService.getRepository(newRE.getName()), newRE.getSystemWorkspaceName());
+ }
+
+- public void testAutoStopRepositoryBackupIncrRepetion() throws Exception
++ public void _testAutoStopRepositoryBackupIncrRepetion() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
+- config.setBackupDir(backDir);
+ config.setIncrementalJobPeriod(4);
+ config.setIncrementalJobNumber(2);
++ config.setBackupDir(backDir);
+
+- final RepositoryBackupChain bch = backup.startBackup(config);
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- while (!bch.isFinished())
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
++ // restore
++ RepositoryEntry newRE = helper.createRepositoryEntry(true, null, null);
+
+- Thread.sleep(5000);
++ // create workspace mappingS
++ Map<String, String> workspaceMapping = new HashedMap();
++ workspaceMapping.put(repository.getConfiguration().getSystemWorkspaceName(), newRE.getSystemWorkspaceName());
+
+- for (RepositoryBackupChain chain : backup.getCurrentRepositoryBackups())
+- if (bch.getBackupId().equals(chain.getBackupId()))
+- fail("The backup with id '" + chain.getBackupId() + "' should not be active");
++ File backLog = new File(bch.getLogFilePath());
++ assertTrue(backLog.exists());
++
++ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
++
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
++
++ backup.restore(bchLog, newRE, workspaceMapping, true);
++ waitEndOfRestore(newRE.getName());
++
++ Thread.sleep(60000);
++ assertEquals(backup.getCurrentRepositoryBackups().size(), 0);
+ }
+
+ public void testRepositoryRestoreFail() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
+-
+- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getState() != RepositoryBackupChain.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+- Thread.sleep(5000);
+-
+- String repoName = repositoryNameToRestore + System.currentTimeMillis();
+-
+ // restore
+- RepositoryEntry newRepositoryEntry =
+- makeRepositoryEntry(repoName, getReposityToBackup().getConfiguration(), dataSourceToRepositoryRestore,
+- null);
++ RepositoryEntry newRE = helper.createRepositoryEntry(true, null, null);
++ newRE.getWorkspaceEntries().get(0).getQueryHandler().setType("gg");
+
+- //create broken system workspaceEntry
+- newRepositoryEntry.getWorkspaceEntries().get(0).getQueryHandler().setType("gg");
++ // create workspace mappingS
++ Map<String, String> workspaceMapping = new HashedMap();
++ workspaceMapping.put(repository.getConfiguration().getSystemWorkspaceName(), newRE.getSystemWorkspaceName());
+
+- File backLog = new File(backup.getRepositoryBackupsLogs()[0].getLogFilePath());
++ File backLog = new File(bch.getLogFilePath());
++ assertTrue(backLog.exists());
+
+ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
++
+ try
+ {
+- backup.restore(bchLog, newRepositoryEntry, false);
+- fail("The backup " + backLog.getAbsolutePath() + "shoulde not restored.");
++ backup.restore(bchLog, newRE, workspaceMapping, false);
++ fail("Exception should be thrown");
+ }
+ catch (RepositoryRestoreExeption e)
+ {
+- // ok.
+ }
+-
+- // check
+- try
+- {
+- ManageableRepository restoredRepository = repositoryService.getRepository(repoName);
+- fail("The repository " + repositoryNameToRestore + "shoulde not exists.");
+- }
+- catch (RepositoryException e)
+- {
+- // ok.
+- }
+ }
+
+- public void testIncrementalBackupRestoreEXOJCR_737() throws Exception
++ public void testExistedWorkspaceRestoreMultiDB() throws Exception
+ {
+- // full backup with BLOBs & incremental with BLOBs
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(true, null);
++ helper.addWorkspace(repository, wsEntry);
++ addConent(repository, wsEntry.getName());
+
+- // BLOBs for full
+- File tempf = createBLOBTempFile("testIncrementalBackupRestore737-", 5 * 1024); // 5M
+- tempf.deleteOnExit();
+-
+- File backDir = new File("target/backup/" + getUUIndex());
++ // backup
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
+- config.setBackupType(BackupManager.FULL_AND_INCREMENTAL);
+-
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
++ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
++ // restore
++ File backLog = new File(bch.getLogFilePath());
++ assertTrue(backLog.exists());
+
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
++ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+- // add data
+- ws1Session.getRootNode().addNode("node_101").setProperty("exo:data", new FileInputStream(tempf));
+- ws1Session.getRootNode().addNode("node_102").setProperty("exo:extraData", new FileInputStream(tempf));
+- ws1Session.getRootNode().save(); // log here via listener
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- // stop backup
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
++ backup.restoreExistingWorkspace(bchLog, repository.getConfiguration().getName(), repository.getConfiguration()
++ .getWorkspaceEntries().get(1), false);
++ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(1).getName());
++ }
+
+- //remove data
+- ws1Session.getRootNode().getNode("node_101").remove();
+- ws1Session.getRootNode().getNode("node_102").remove();
+- ws1Session.getRootNode().save();
++ public void testExistedWorkspaceRestoreSingleDB() throws Exception
++ {
++ // prepare
++ String dsName = helper.createDatasource();
+
+- // restore
+- WorkspaceEntry ws1back = makeWorkspaceEntry(workspaceNameToRestore, dataSourceToWorkspaceRestore);
++ ManageableRepository repository = helper.createRepository(container, false, dsName);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(false, dsName);
++ helper.addWorkspace(repository, wsEntry);
++ addConent(repository, wsEntry.getName());
+
+- File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
++ // backup
++ File backDir = new File("target/backup/" + IdGenerator.generate());
++ backDir.mkdirs();
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ BackupConfig config = new BackupConfig();
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
++ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
++ config.setBackupDir(backDir);
+
+- backup.restore(bchLog, repositoryNameToBackup, ws1back, false);
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) getReposityToBackup().login(credentials, workspaceNameToRestore);
++ // restore
++ File backLog = new File(bch.getLogFilePath());
++ assertTrue(backLog.exists());
+
+- Node node_101 = back1.getRootNode().getNode("node_101");
+- assertNotNull(node_101);
+- assertEquals(tempf.length(), node_101.getProperty("exo:data").getStream().available());
+- compareStream(new FileInputStream(tempf), node_101.getProperty("exo:data").getStream());
++ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+- Node node_102 = back1.getRootNode().getNode("node_102");
+- assertNotNull(node_102);
+- assertEquals(tempf.length(), node_102.getProperty("exo:extraData").getStream().available());
+- compareStream(new FileInputStream(tempf), node_102.getProperty("exo:extraData").getStream());
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.restoreExistingWorkspace(bchLog, repository.getConfiguration().getName(), repository.getConfiguration()
++ .getWorkspaceEntries().get(1), false);
++ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(1).getName());
+ }
+
+- public void testExistedWorkspaceRestoreMultiDB() throws Exception
++ public void testExistedWorkspaceRestoreAsync() throws Exception
+ {
+- String repositoryNameToBackup = "db8";
+- SessionImpl ws1Session =
+- (SessionImpl)repositoryService.getRepository(repositoryNameToBackup).login(credentials, "ws1");
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(true, null);
++ helper.addWorkspace(repository, wsEntry);
++ addConent(repository, wsEntry.getName());
+
+- ws1Session.getRootNode().addNode("TESTNODE");
+- ws1Session.save();
+-
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+-
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
+-
+ // restore
+- RepositoryEntry re =
+- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+- WorkspaceEntry ws1 = null;
+- for (WorkspaceEntry we : re.getWorkspaceEntries())
+- {
+- if (ws1Session.getWorkspace().getName().equals(we.getName()))
+- {
+- ws1 = we;
+- break;
+- }
+- }
+-
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+- backup.restoreExistingWorkspace(bchLog, repositoryNameToBackup, ws1, false);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl)repositoryService.getRepository("db8").login(credentials, "ws1");
+- Node ws1backTestRoot = back1.getRootNode().getNode("TESTNODE");
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
++ backup.restoreExistingWorkspace(bchLog, repository.getConfiguration().getName(), repository.getConfiguration()
++ .getWorkspaceEntries().get(1), true);
++ waitEndOfRestore(repository.getConfiguration().getName(), repository.getConfiguration().getWorkspaceEntries()
++ .get(1).getName());
+
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ assertEquals(
++ backup.getLastRestore(repository.getConfiguration().getName(),
++ repository.getConfiguration().getWorkspaceEntries().get(1).getName()).getStateRestore(),
++ JobWorkspaceRestore.RESTORE_SUCCESSFUL);
++
++ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(1).getName());
+ }
+
+- public void testExistedWorkspaceRestore() throws Exception
++ public void testExistedRepositoryRestoreMultiDB() throws Exception
+ {
+- SessionImpl ws1Session = (SessionImpl) repositoryService.getRepository("db7").login(credentials, "ws1");
++ // prepare
++ String dsName = helper.createDatasource();
++ ManageableRepository repository = helper.createRepository(container, true, dsName);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
+
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+- BackupConfig config = new BackupConfig();
+- config.setRepository("db7");
+- config.setWorkspace(workspaceNameToBackup);
++ RepositoryBackupConfig config = new RepositoryBackupConfig();
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- BackupChain bch = backup.findBackup("db7", workspaceNameToBackup);
+
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
++ File backLog = new File(bch.getLogFilePath());
++ assertTrue(backLog.exists());
+
+- // stop fullBackup
++ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+ // restore
+- RepositoryEntry re =
+- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+- WorkspaceEntry ws1 = null;
+- for (WorkspaceEntry we : re.getWorkspaceEntries())
+- {
+- if (ws1Session.getWorkspace().getName().equals(we.getName()))
+- {
+- ws1 = we;
+- break;
+- }
+- }
++ RepositoryEntry newRE =
++ helper.createRepositoryEntry(true, repository.getConfiguration().getSystemWorkspaceName(), dsName);
++ newRE.setName(repository.getConfiguration().getName());
+
++ backup.restoreExistingRepository(bchLog, newRE, false);
++ checkConent(repositoryService.getRepository(newRE.getName()), newRE.getSystemWorkspaceName());
++ }
++
++ public void testExistedRepositoryRestoreSingelDB() throws Exception
++ {
++ // prepare
++ String dsName = helper.createDatasource();
++ ManageableRepository repository = helper.createRepository(container, false, dsName);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
++ // backup
++ File backDir = new File("target/backup/" + IdGenerator.generate());
++ backDir.mkdirs();
++
++ RepositoryBackupConfig config = new RepositoryBackupConfig();
++ config.setRepository(repository.getConfiguration().getName());
++ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
++ config.setBackupDir(backDir);
++
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
++
++
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+- backup.restoreExistingWorkspace(bchLog, "db7", ws1, false);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) repositoryService.getRepository("db7").login(credentials, "ws1");
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ // restore
++ RepositoryEntry newRE =
++ helper.createRepositoryEntry(false, repository.getConfiguration().getSystemWorkspaceName(), dsName);
++ newRE.setName(repository.getConfiguration().getName());
++
++ backup.restoreExistingRepository(bchLog, newRE, false);
++ checkConent(repositoryService.getRepository(newRE.getName()), newRE.getSystemWorkspaceName());
+ }
+
+- public void testExistedWorkspaceRestoreAsync() throws Exception
++ public void testExistedRepositoryRestoreAsync() throws Exception
+ {
++ // prepare
++ String dsName = helper.createDatasource();
++ ManageableRepository repository = helper.createRepository(container, false, dsName);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+- BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ RepositoryBackupConfig config = new RepositoryBackupConfig();
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
++ File backLog = new File(bch.getLogFilePath());
++ assertTrue(backLog.exists());
+
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
++ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+- // stop fullBackup
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
+-
+ // restore
+- RepositoryEntry re =
+- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+- WorkspaceEntry ws1 = null;
+- for (WorkspaceEntry we : re.getWorkspaceEntries())
+- {
+- if (ws1Session.getWorkspace().getName().equals(we.getName()))
+- {
+- ws1 = we;
+- break;
+- }
+- }
++ RepositoryEntry newRE =
++ helper.createRepositoryEntry(false, repository.getConfiguration().getSystemWorkspaceName(), dsName);
++ newRE.setName(repository.getConfiguration().getName());
+
+- File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
++ backup.restoreExistingRepository(bchLog, newRE, true);
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ waitEndOfRestore(repository.getConfiguration().getName());
+
+- backup.restoreExistingWorkspace(bchLog, repositoryNameToBackup, ws1, true);
++ assertEquals(JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL,
++ backup.getLastRepositoryRestore(repository.getConfiguration().getName()).getStateRestore());
+
+- while (backup.getLastRestore(repositoryNameToBackup, ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_SUCCESSFUL
+- && backup.getLastRestore(repositoryNameToBackup, ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
+- {
+- Thread.sleep(50);
+- }
+-
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 =
+- (SessionImpl) repositoryService.getRepository(repositoryNameToBackup).login(credentials,
+- workspaceNameToBackup);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ checkConent(repositoryService.getRepository(newRE.getName()), newRE.getSystemWorkspaceName());
+ }
+
+- public void testExistedWorkspaceRestoreAsync2() throws Exception
++
++ public void testExistedWorkspaceRestoreWithConfig() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(true, null);
++ helper.addWorkspace(repository, wsEntry);
++ addConent(repository, wsEntry.getName());
+
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+-
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
+-
+ // restore
+- RepositoryEntry re =
+- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+- WorkspaceEntry ws1 = null;
+- for (WorkspaceEntry we : re.getWorkspaceEntries())
+- {
+- if (ws1Session.getWorkspace().getName().equals(we.getName()))
+- {
+- ws1 = we;
+- break;
+- }
+- }
+-
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+- backup.restoreExistingWorkspace(bchLog.getBackupId(), repositoryNameToBackup, ws1, true);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- while (backup.getLastRestore(repositoryNameToBackup, ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_SUCCESSFUL
+- && backup.getLastRestore(repositoryNameToBackup, ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
+- {
+- Thread.sleep(50);
+- }
+-
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 =
+- (SessionImpl) repositoryService.getRepository(repositoryNameToBackup).login(credentials,
+- workspaceNameToBackup);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.restoreExistingWorkspace(bchLog.getBackupId(), false);
++ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(1).getName());
+ }
+
+- public void testExistedRepositoryRestore() throws Exception
++ public void testExistedRepositoryRestoreWithConfig() throws Exception
+ {
++ // prepare
++ String dsName = helper.createDatasource();
++ ManageableRepository repository = helper.createRepository(container, true, dsName);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
+-
+- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getState() != RepositoryBackupChain.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+-
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+- // restore
+- RepositoryEntry re =
+- makeRepositoryEntry(repositoryNameToBackup, getReposityToBackup().getConfiguration(), null, null);
+-
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+- backup.restoreExistingRepository(bchLog, re, false);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(repositoryNameToBackup)
+- .getStateRestore());
++ // restore
++ RepositoryEntry newRE =
++ helper.createRepositoryEntry(true, repository.getConfiguration().getSystemWorkspaceName(), dsName);
++ newRE.setName(repository.getConfiguration().getName());
+
+- // check
+- ManageableRepository restoredRepository = repositoryService.getRepository(repositoryNameToBackup);
+-
+- for (String wsName : restoredRepository.getWorkspaceNames())
+- {
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.restoreExistingRepository(bchLog.getBackupId(), false);
++ checkConent(repositoryService.getRepository(newRE.getName()), newRE.getSystemWorkspaceName());
+ }
+
+- public void testExistedRepositoryRestoreSingelDB() throws Exception
++ public void testWorkspaceRestoreWithConfig() throws Exception
+ {
+- RepositoryImpl repositoryDB7 = (RepositoryImpl) repositoryService.getRepository(repositoryNameToBackupSingleDB);
+- SessionImpl sessionWS = (SessionImpl) repositoryDB7.login(credentials, workspaceNameToBackup);
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(true, null);
++ helper.addWorkspace(repository, wsEntry);
++ addConent(repository, wsEntry.getName());
+
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+- RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackupSingleDB);
++ BackupConfig config = new BackupConfig();
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
+-
+- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryNameToBackupSingleDB);
+-
+- // wait till full backup will be stopped
+- while (bch.getState() != RepositoryBackupChain.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+-
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+- // restore
+- RepositoryEntry baseRE =
+- (RepositoryEntry) sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+- RepositoryEntry re = makeRepositoryEntry(baseRE.getName(), baseRE, null, null);
++ removeWorkspaceFully(repository.getConfiguration().getName(), wsEntry.getName());
+
++ // restore
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+- backup.restoreExistingRepository(bchLog, re, false);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(re.getName())
+- .getStateRestore());
+-
+- // check
+- ManageableRepository restoredRepository = repositoryService.getRepository(repositoryNameToBackupSingleDB);
+-
+- for (String wsName : restoredRepository.getWorkspaceNames())
+- {
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.restoreWorkspace(bchLog.getBackupId(), false);
++ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(1).getName());
+ }
+
+- public void testExistedRepositoryRestoreAsync() throws Exception
++ public void testRepositoryRestoreWithConfig() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
+-
+- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getState() != RepositoryBackupChain.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+-
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+ // restore
+- RepositoryEntry re =
+- makeRepositoryEntry(repositoryNameToBackup, getReposityToBackup().getConfiguration(), null, null);
++ removeRepositoryFully(repository.getConfiguration().getName());
+
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+- backup.restoreExistingRepository(bchLog, re, true);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- JobRepositoryRestore job = backup.getLastRepositoryRestore(repositoryNameToBackup);
++ backup.restoreRepository(bchLog.getBackupId(), false);
+
+- while (job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL
+- && job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
+- {
+- Thread.sleep(50);
+- }
+-
+- assertEquals(JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(
+- repositoryNameToBackup).getStateRestore());
+-
+- // check
+- ManageableRepository restoredRepository = repositoryService.getRepository(repositoryNameToBackup);
+-
+- for (String wsName : restoredRepository.getWorkspaceNames())
+- {
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ checkConent(repositoryService.getRepository(config.getRepository()),
++ repositoryService.getRepository(config.getRepository()).getConfiguration().getSystemWorkspaceName());
+ }
+
+- public void testExistedRepositoryRestoreAsync2() throws Exception
++ public void testRepositoryRestoreWithNullConfig() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
+ // backup
+- File backDir = new File("target/backup");
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
+-
+- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getState() != RepositoryBackupChain.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+-
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+ // restore
+- RepositoryEntry re =
+- makeRepositoryEntry(repositoryNameToBackup, getReposityToBackup().getConfiguration(), null, null);
++ removeRepositoryFully(repository.getConfiguration().getName());
+
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+- backup.restoreExistingRepository(bchLog.getBackupId(), re, true);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- JobRepositoryRestore job = backup.getLastRepositoryRestore(repositoryNameToBackup);
+-
+- while (job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL
+- && job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
+- {
+- Thread.sleep(50);
+- }
+-
+- assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(repositoryNameToBackup)
+- .getStateRestore());
+-
+- // check
+- ManageableRepository restoredRepository = repositoryService.getRepository(repositoryNameToBackup);
+-
+- for (String wsName : restoredRepository.getWorkspaceNames())
+- {
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.restore(bchLog, null, false);
++ checkConent(repositoryService.getRepository(config.getRepository()),
++ repositoryService.getRepository(config.getRepository()).getConfiguration().getSystemWorkspaceName());
+ }
+
+- public void testExistedWorkspaceRestoreSingelDB() throws Exception
++ public void testWorkspaceRestoreWithNullConfig() throws Exception
+ {
+- RepositoryImpl repositoryDB7 = (RepositoryImpl) repositoryService.getRepository(repositoryNameToBackupSingleDB);
+- SessionImpl sessionWS = (SessionImpl) repositoryDB7.login(credentials, workspaceNameToBackup);
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(true, null);
++ helper.addWorkspace(repository, wsEntry);
++ addConent(repository, wsEntry.getName());
+
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackupSingleDB);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- BackupChain bch = backup.findBackup(repositoryNameToBackupSingleDB, workspaceNameToBackup);
++ removeWorkspaceFully(repository.getConfiguration().getName(), wsEntry.getName());
+
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
++ // restore
++ File backLog = new File(bch.getLogFilePath());
++ assertTrue(backLog.exists());
+
+- // stop fullBackup
++ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- // restore
+- RepositoryEntry re = (RepositoryEntry) sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+- WorkspaceEntry ws1 = null;
+- for (WorkspaceEntry we : re.getWorkspaceEntries())
++ try
+ {
+- if (sessionWS.getWorkspace().getName().equals(we.getName()))
+- {
+- ws1 = we;
+- break;
+- }
++ backup.restore(bchLog, repository.getConfiguration().getName() + "not_exists", null, false);
++ fail("Exception should be thrown");
+ }
+-
+- File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
++ catch (Exception e)
+ {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
+-
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
+-
+- backup.restoreExistingWorkspace(bchLog, repositoryNameToBackupSingleDB, ws1, false);
+-
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- repositoryDB7 = (RepositoryImpl) repositoryService.getRepository(repositoryNameToBackupSingleDB);
+- back1 = (SessionImpl) repositoryDB7.login(credentials, workspaceNameToBackup);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+ }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++
++ backup.restore(bchLog, repository.getConfiguration().getName(), null, false);
++ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(1).getName());
+ }
+
+- public void testExistedWorkspaceRestoreWithConfig() throws Exception
++ public void testExistedWorkspaceRestoreWithConfigBackupSetDir() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(true, null);
++ helper.addWorkspace(repository, wsEntry);
++ addConent(repository, wsEntry.getName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
+-
+- super.tearDown();
+-
++ // restore
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+- backup.restoreExistingWorkspace(bchLog.getBackupId(), false);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 =
+- (SessionImpl) repositoryService.getRepository(repositoryNameToBackup).login(credentials,
+- workspaceNameToBackup);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.restoreExistingWorkspace(bchLog.getBackupConfig().getBackupDir(), false);
++ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(1).getName());
+ }
+
+- public void testExistedRepositoryRestoreWithConfig() throws Exception
++ public void testExistedRepositoryRestoreWithConfigBackupSetDir() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
+-
+- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getState() != RepositoryBackupChain.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+- // check
+- super.tearDown();
+-
+- // restore
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+- backup.restoreExistingRepository(bchLog.getBackupId(), false);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(repositoryNameToBackup)
+- .getStateRestore());
+-
+- // check
+- ManageableRepository restoredRepository = repositoryService.getRepository(repositoryNameToBackup);
+-
+- for (String wsName : restoredRepository.getWorkspaceNames())
+- {
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.restoreExistingRepository(bchLog.getBackupConfig().getBackupDir(), false);
++ checkConent(repositoryService.getRepository(config.getRepository()),
++ repositoryService.getRepository(config.getRepository()).getConfiguration().getSystemWorkspaceName());
+ }
+
+- public void testWorkspaceRestoreWithConfig() throws Exception
++ public void testWorkspaceRestoreWithConfigBackupSetDir() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(true, null);
++ helper.addWorkspace(repository, wsEntry);
++ addConent(repository, wsEntry.getName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry.getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
++ removeWorkspaceFully(repository.getConfiguration().getName(), wsEntry.getName());
+
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+-
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
+-
+- //TODO
+- // super.tearDown();
+- removeWorkspaceFullySingleDB(repositoryNameToBackup, workspaceNameToBackup);
+-
++ // restore
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+- backup.restoreWorkspace(bchLog.getBackupId(), false);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) repositoryService.getRepository(repositoryNameToBackup).login(credentials, "ws1");
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.restoreWorkspace(bchLog.getBackupConfig().getBackupDir(), false);
++ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(1).getName());
+ }
+
+- public void testRepositoryRestoreWithConfig() throws Exception
++ public void testRepositoryRestoreWithConfigBackupSetDir() throws Exception
+ {
++ // prepare
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
+-
+- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getState() != RepositoryBackupChain.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
+-
+- // stop fullBackup
+-
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+- //TODO
+- super.tearDown();
+- removeRepositoryFully(repositoryNameToBackup);
++ // restore
++ removeRepositoryFully(repository.getConfiguration().getName());
+
+- // restore
+ File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
++ assertTrue(backLog.exists());
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+- backup.restoreRepository(bchLog.getBackupId(), false);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(repositoryNameToBackup)
+- .getStateRestore());
+-
+- // check
+- ManageableRepository restoredRepository = repositoryService.getRepository(repositoryNameToBackup);
+-
+- for (String wsName : restoredRepository.getWorkspaceNames())
+- {
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.restoreRepository(bchLog.getBackupConfig().getBackupDir(), false);
++ checkConent(repositoryService.getRepository(config.getRepository()),
++ repositoryService.getRepository(config.getRepository()).getConfiguration().getSystemWorkspaceName());
+ }
+
+- public void testRepositoryRestoreWithNullConfig() throws Exception
++ public void testRelativeBackupDir() throws Exception
+ {
++ // prepare stage #1
++ ManageableRepository repository = helper.createRepository(container, true, null);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
+ // backup
+- File backDir = new File((File.createTempFile("12123", "123")).getParent() + File.separator + getUUIndex());
+- backDir.mkdirs();
++ File backDir = new File("target");
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryNameToBackup);
++ // prepare stage #2
++ String repositoryBackupChainLogPath = bch.getLogFilePath();
+
+- // wait till full backup will be stopped
+- while (bch.getState() != RepositoryBackupChain.FINISHED)
++ String relativePrefixBackupDir = backDir.getCanonicalFile().getParent() + File.separator;
++
++ String newBackupDir =
++ bch.getBackupConfig().getBackupDir().getCanonicalPath().replace(relativePrefixBackupDir, "");
++ String newBackupDirForWrite = newBackupDir;
++ if (File.separator.equals("\\"))
+ {
+- Thread.yield();
+- Thread.sleep(50);
++ newBackupDirForWrite = newBackupDir.replaceAll("\\\\", "\\\\\\\\");
+ }
+
+- // stop fullBackup
++ File dest = new File(repositoryBackupChainLogPath + ".xml");
++ dest.createNewFile();
+
+- backup.stopBackup(bch);
++ RepositoryBackupChainLog newRepositoryBackupChainLog = null;
+
+- //TODO
+- super.tearDown();
+- removeRepositoryFully(repositoryNameToBackup);
++ String sConfig =
++ setNewBackupDirInRepositoryBackupChainLog(new File(repositoryBackupChainLogPath), dest, newBackupDirForWrite);
+
+- // restore
+- File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
++ assertTrue(sConfig.contains(newBackupDir));
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ // check
++ newRepositoryBackupChainLog = new RepositoryBackupChainLog(dest);
+
+- backup.restore(bchLog, null, false);
++ assertEquals(bch.getBackupConfig().getBackupDir().getCanonicalPath(), newRepositoryBackupChainLog
++ .getBackupConfig().getBackupDir().getCanonicalPath());
++ }
+
+- assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(repositoryNameToBackup)
+- .getStateRestore());
++ /**
++ * Use JobExistingWorkspaceSameConfigRestore to restore.
++ */
+
+- // check
+- ManageableRepository restoredRepository = repositoryService.getRepository(repositoryNameToBackup);
++ public void testExistedWorkspaceRestoreSingleDBTwoWS() throws Exception
++ {
++ // prepare
++ String dsName1 = helper.createDatasource();
++ String dsName2 = helper.createDatasource();
+
+- for (String wsName : restoredRepository.getWorkspaceNames())
+- {
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
+- }
++ ManageableRepository repository = helper.createRepository(container, false, dsName1);
++ WorkspaceEntry wsEntry1 = helper.createWorkspaceEntry(false, dsName1);
++ helper.addWorkspace(repository, wsEntry1);
++ addConent(repository, wsEntry1.getName());
+
+- public void testWorkspaceRestoreWithNullConfig() throws Exception
+- {
++ WorkspaceEntry wsEntry2 = helper.createWorkspaceEntry(false, dsName2);
++ helper.addWorkspace(repository, wsEntry2);
++ addConent(repository, wsEntry2.getName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry1.getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
++ // restore
++ File backLog = new File(bch.getLogFilePath());
++ assertTrue(backLog.exists());
+
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
++ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+- // stop fullBackup
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
++ backup.restoreExistingWorkspace(bchLog, repository.getConfiguration().getName(), repository.getConfiguration()
++ .getWorkspaceEntries().get(1), false);
++ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(1).getName());
++ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(2).getName());
++ }
+
+- //TODO
+- removeWorkspaceFullySingleDB(repositoryNameToBackup, workspaceNameToBackup);
++ /**
++ * Use JobExistingWorkspaceRestore to restore.
++ */
+
+- File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
++ public void testExistedWorkspaceRestoreSingleDBTwoWSWithDiffConfig() throws Exception
++ {
++ // prepare
++ String dsName1 = helper.createDatasource();
++ String dsName2 = helper.createDatasource();
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ ManageableRepository repository = helper.createRepository(container, false, dsName1);
++ WorkspaceEntry wsEntry1 = helper.createWorkspaceEntry(false, dsName1);
++ helper.addWorkspace(repository, wsEntry1);
++ addConent(repository, wsEntry1.getName());
+
+- try
+- {
+- backup.restore(bchLog, repositoryNameToBackup + "not_exists", null, false);
+- fail("Should be throw exception WorkspaceRestoreException");
+- }
+- catch (WorkspaceRestoreException e)
+- {
+- //ok
+- }
++ WorkspaceEntry wsEntry2 = helper.createWorkspaceEntry(false, dsName2);
++ helper.addWorkspace(repository, wsEntry2);
++ addConent(repository, wsEntry2.getName());
+
+- backup.restore(bchLog, repositoryNameToBackup, null, false);
+-
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) getReposityToBackup().login(credentials, workspaceNameToBackup);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
+- }
+-
+- public void testExistedWorkspaceRestoreWithConfigBackupSetDir() throws Exception
+- {
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
++ config.setWorkspace(wsEntry1.getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ BackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
++ // restore
++ File backLog = new File(bch.getLogFilePath());
++ assertTrue(backLog.exists());
+
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
++ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+- // stop fullBackup
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- super.tearDown();
++ // change cofig
++ WorkspaceEntry wsEntry = helper.copyWorkspaceEntry(repository.getConfiguration().getWorkspaceEntries().get(1));
+
+- File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
++ List<SimpleParameterEntry> params = wsEntry.getContainer().getParameters();
++ params.set(2, new SimpleParameterEntry("max-buffer-size", "307200"));
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ wsEntry.getContainer().setParameters(params);
+
+- backup.restoreExistingWorkspace(bchLog.getBackupConfig().getBackupDir(), false);
+-
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) getReposityToBackup().login(credentials, workspaceNameToBackup);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ backup.restoreExistingWorkspace(bchLog, repository.getConfiguration().getName(), wsEntry, false);
++ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(1).getName());
++ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(2).getName());
+ }
+
+- public void testExistedRepositoryRestoreWithConfigBackupSetDir() throws Exception
++ public void testExistedRepositoryRestoreSingelDBSameConfig() throws Exception
+ {
++ // prepare
++ String dsName = helper.createDatasource();
++ ManageableRepository repository = helper.createRepository(container, false, dsName);
++ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
++
++ WorkspaceEntry wsEntry1 = helper.createWorkspaceEntry(false, dsName);
++ helper.addWorkspace(repository, wsEntry1);
++ addConent(repository, wsEntry1.getName());
++
+ // backup
+- File backDir = new File("target/backup/" + getUUIndex());
++ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackup);
++ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+ config.setBackupDir(backDir);
+
+- backup.startBackup(config);
++ RepositoryBackupChain bch = backup.startBackup(config);
++ waitEndOfBackup(bch);
++ backup.stopBackup(bch);
+
+- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryNameToBackup);
++ File backLog = new File(bch.getLogFilePath());
++ assertTrue(backLog.exists());
+
+- // wait till full backup will be stopped
+- while (bch.getState() != RepositoryBackupChain.FINISHED)
+- {
+- Thread.yield();
+- Thread.sleep(50);
+- }
++ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+- // stop fullBackup
+- backup.stopBackup(bch);
++ assertNotNull(bchLog.getStartedTime());
++ assertNotNull(bchLog.getFinishedTime());
+
+- // check
+- super.tearDown();
++ // restore
++ long timeOfRestore = System.currentTimeMillis();
++ backup.restoreExistingRepository(bchLog, helper.copyRepositoryEntry(repository.getConfiguration()), false);
++ checkConent(repositoryService.getRepository(repository.getConfiguration().getName()), repository
++ .getConfiguration().getSystemWorkspaceName());
++ }
+
+- // restore
+- File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
+- {
+- RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
++ /**
++ * Set new backup directory in RepositoryBackupChainLog
++ *
++ * @param src
++ * source file of RepositoryBackupChainLog
++ * @param dest
++ * destination file of RepositoryBackupChainLog
++ * @param newBackupDir
++ * @return String
++ * the content of file destination
++ * @throws IOException
++ */
++ protected String setNewBackupDirInRepositoryBackupChainLog(File src, File dest, String newBackupDir)
++ throws IOException
++ {
++ InputStream in = new FileInputStream(src);
++ OutputStream out = new FileOutputStream(dest);
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ byte[] buf = new byte[(int)(src.length())];
++ in.read(buf);
+
+- backup.restoreExistingRepository(bchLog.getBackupConfig().getBackupDir(), false);
++ String sConfig = new String(buf, Constants.DEFAULT_ENCODING);
++ sConfig = sConfig.replaceAll("<backup-dir>.+</backup-dir>", "<backup-dir>" + newBackupDir + "</backup-dir>");
+
+- assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(repositoryNameToBackup)
+- .getStateRestore());
++ out.write(sConfig.getBytes(Constants.DEFAULT_ENCODING));
+
+- // check
+- ManageableRepository restoredRepository = repositoryService.getRepository(repositoryNameToBackup);
++ in.close();
++ out.close();
+
+- for (String wsName : restoredRepository.getWorkspaceNames())
++ return sConfig;
++ }
++
++ protected void deleteFolder(File f)
++ {
++ if (f.isDirectory())
++ {
++ for (File file : f.listFiles())
+ {
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
++ deleteFolder(file);
+ }
++
++ f.delete();
+ }
+ else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ {
++ f.delete();
++ }
+ }
+
+- public void testWorkspaceRestoreWithConfigBackupSetDir() throws Exception
++ public void addConent(ManageableRepository repository, String wsName) throws Exception
+ {
+- // backup
+- File backDir = new File((File.createTempFile("12123", "123")).getParent() + File.separator + getUUIndex());
+- backDir.mkdirs();
++ SessionImpl session = (SessionImpl)repository.login(credentials, wsName);
++ Node rootNode = session.getRootNode().addNode("test");
+
+- BackupConfig config = new BackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setWorkspace(workspaceNameToBackup);
+- config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
++ // add some changes which will be logged in incremental log
++ rootNode.addNode("node1").setProperty("prop1", "value1");
++ rootNode.addNode("node2").setProperty("prop2", new FileInputStream(blob));
++ rootNode.addNode("node3").addMixin("mix:lockable");
++ session.save();
++ }
+
+- config.setBackupDir(backDir);
+-
+- backup.startBackup(config);
+-
+- BackupChain bch = backup.findBackup(repositoryNameToBackup, workspaceNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getFullBackupState() != BackupJob.FINISHED)
++ public void waitEndOfBackup(BackupChain bch) throws Exception
++ {
++ while (bch.getFullBackupState() != BackupChain.FINISHED)
+ {
+ Thread.yield();
+ Thread.sleep(50);
+ }
++ }
+
+- // stop fullBackup
+-
+- if (bch != null)
+- backup.stopBackup(bch);
+- else
+- fail("Can't get fullBackup chain");
+-
+- //TODO
+- removeWorkspaceFullySingleDB(repositoryNameToBackup, workspaceNameToBackup);
+-
+- File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
++ public void waitEndOfBackup(RepositoryBackupChain bch) throws Exception
++ {
++ while (bch.getState() != RepositoryBackupChain.FINISHED
++ && bch.getState() != RepositoryBackupChain.FULL_BACKUP_FINISHED_INCREMENTAL_BACKUP_WORKING)
+ {
+- BackupChainLog bchLog = new BackupChainLog(backLog);
+-
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
+-
+- backup.restoreWorkspace(bchLog.getBackupConfig().getBackupDir(), false);
+-
+- // check
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) getReposityToBackup().login(credentials, "ws1");
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
++ Thread.yield();
++ Thread.sleep(50);
+ }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
+ }
+
+- public void testRepositoryRestoreWithConfigBackupSetDir() throws Exception
++ public void waitEndOfRestore(String repositoryName) throws Exception
+ {
+- // backup
+- File backDir = new File((File.createTempFile("12123", "123")).getParent() + File.separator + getUUIndex());
+- backDir.mkdirs();
++ while (backup.getLastRepositoryRestore(repositoryName).getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL
++ && backup.getLastRepositoryRestore(repositoryName).getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
++ {
++ Thread.sleep(50);
++ }
++ }
+
+- RepositoryBackupConfig config = new RepositoryBackupConfig();
+- config.setRepository(repositoryNameToBackup);
+- config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+-
+- config.setBackupDir(backDir);
+-
+- backup.startBackup(config);
+-
+- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryNameToBackup);
+-
+- // wait till full backup will be stopped
+- while (bch.getState() != RepositoryBackupChain.FINISHED)
++ public void waitEndOfRestore(String repositoryName, String workspaceName) throws Exception
++ {
++ while (backup.getLastRestore(repositoryName, workspaceName).getStateRestore() != JobWorkspaceRestore.RESTORE_SUCCESSFUL
++ && backup.getLastRestore(repositoryName, workspaceName).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
+ {
+- Thread.yield();
+ Thread.sleep(50);
+ }
++ }
+
+- // stop fullBackup
++ public void checkConent(ManageableRepository repository, String wsName) throws Exception
++ {
++ SessionImpl session = (SessionImpl)repository.login(credentials, wsName);
+
+- backup.stopBackup(bch);
++ Node rootNode = session.getRootNode().getNode("test");
++ assertEquals(rootNode.getNode("node1").getProperty("prop1").getString(), "value1");
+
+- //TODO
+- super.tearDown();
+- removeRepositoryFully(repositoryNameToBackup);
+-
+- // restore
+- File backLog = new File(bch.getLogFilePath());
+- if (backLog.exists())
++ InputStream in = rootNode.getNode("node2").getProperty("prop2").getStream();
++ try
+ {
+- RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
++ compareStream(new FileInputStream(blob), in);
++ }
++ finally
++ {
++ in.close();
++ }
++ }
+
+- assertNotNull(bchLog.getStartedTime());
+- assertNotNull(bchLog.getFinishedTime());
++ public void checkIncrementalConent(ManageableRepository repository, String wsName) throws Exception
++ {
++ SessionImpl session = (SessionImpl)repository.login(credentials, wsName);
+
+- backup.restoreRepository(bchLog.getBackupConfig().getBackupDir(), false);
++ Node rootNode = session.getRootNode().getNode("testIncremental");
++ assertEquals(rootNode.getNode("node1").getProperty("prop1").getString(), "value1");
+
+- assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(repositoryNameToBackup)
+- .getStateRestore());
++ InputStream in = rootNode.getNode("node2").getProperty("prop2").getStream();
++ try
++ {
++ compareStream(new FileInputStream(blob), in);
++ }
++ finally
++ {
++ in.close();
++ }
++ }
+
+- // check
+- ManageableRepository restoredRepository = repositoryService.getRepository(repositoryNameToBackup);
++ public void addIncrementalConent(ManageableRepository repository, String wsName) throws Exception
++ {
++ SessionImpl session = (SessionImpl)repository.login(credentials, wsName);
++ Node rootNode = session.getRootNode().addNode("testIncremental");
+
+- for (String wsName : restoredRepository.getWorkspaceNames())
+- {
+- SessionImpl back1 = null;
+- try
+- {
+- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+- Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
+- assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
+- .getProperty("exo:data").getString());
+- }
+- catch (Exception e)
+- {
+- e.printStackTrace();
+- fail(e.getMessage());
+- }
+- finally
+- {
+- if (back1 != null)
+- back1.logout();
+- }
+- }
+- }
+- else
+- fail("There are no backup files in " + backDir.getAbsolutePath());
++ // add some changes which will be logged in incremental log
++ rootNode.addNode("node1").setProperty("prop1", "value1");
++ rootNode.addNode("node2").setProperty("prop2", new FileInputStream(blob));
++ rootNode.addNode("node3").addMixin("mix:lockable");
++ session.save();
+ }
++
+ }
+Index: exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/util/TesterConfigurationHelper.java
+===================================================================
+--- exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/util/TesterConfigurationHelper.java (revision 0)
++++ exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/util/TesterConfigurationHelper.java (revision 0)
+@@ -0,0 +1,354 @@
++/*
++ * 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.util;
++
++import java.util.ArrayList;
++import java.util.List;
++import java.util.Properties;
++
++import javax.jcr.RepositoryException;
++import javax.naming.Context;
++import javax.naming.InitialContext;
++import javax.sql.DataSource;
++
++import org.apache.commons.dbcp.BasicDataSourceFactory;
++import org.exoplatform.container.ExoContainer;
++import org.exoplatform.services.jcr.RepositoryService;
++import org.exoplatform.services.jcr.config.CacheEntry;
++import org.exoplatform.services.jcr.config.ContainerEntry;
++import org.exoplatform.services.jcr.config.QueryHandlerEntry;
++import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
++import org.exoplatform.services.jcr.config.RepositoryEntry;
++import org.exoplatform.services.jcr.config.SimpleParameterEntry;
++import org.exoplatform.services.jcr.config.ValueStorageEntry;
++import org.exoplatform.services.jcr.config.ValueStorageFilterEntry;
++import org.exoplatform.services.jcr.config.WorkspaceEntry;
++import org.exoplatform.services.jcr.core.ManageableRepository;
++import org.exoplatform.services.log.ExoLogger;
++import org.exoplatform.services.log.Log;
++
++/**
++ * Created by The eXo Platform SAS
++ *
++ * @author <a href="mailto:Sergey.Kabashnyuk@gmail.com">Sergey Kabashnyuk</a>
++ * @version $Id: ConfigurationHelper.java 11907 2008-03-13 15:36:21Z ksm $
++ */
++public class TesterConfigurationHelper
++{
++ private static Log log = ExoLogger.getLogger("exo.jcr.component.core.ConfigurationHelper");
++
++ private static TesterConfigurationHelper instance;
++
++ private TesterConfigurationHelper()
++ {
++ System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.exoplatform.services.naming.SimpleContextFactory");
++ }
++
++ /**
++ * Add new workspace to repository.
++ */
++ public void addWorkspace(ManageableRepository repository, WorkspaceEntry workspaceEntry)
++ throws RepositoryConfigurationException, RepositoryException
++ {
++ repository.configWorkspace(workspaceEntry);
++ repository.createWorkspace(workspaceEntry.getName());
++ }
++
++ /**
++ * Create new datasource.
++ *
++ * @return datasource name
++ */
++ public String createDatasource() throws Exception
++ {
++ String dsName = IdGenerator.generate();
++
++ Properties properties = new Properties();
++ properties.setProperty("driverClassName", "org.hsqldb.jdbcDriver");
++ properties.setProperty("url", "jdbc:hsqldb:file:target/temp/data/" + dsName);
++ properties.setProperty("username", "sa");
++ properties.setProperty("password", "");
++
++ DataSource ds = BasicDataSourceFactory.createDataSource(properties);
++
++ new InitialContext().bind(dsName, ds);
++
++ return dsName;
++
++ }
++
++ public ManageableRepository createRepository(ExoContainer container, boolean isMultiDb, String dsName)
++ throws Exception
++ {
++ RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
++ RepositoryEntry repoEntry = createRepositoryEntry(isMultiDb, null, dsName);
++ service.createRepository(repoEntry);
++
++ return service.getRepository(repoEntry.getName());
++ }
++
++ /**
++ * Create workspace entry.
++ */
++ public RepositoryEntry createRepositoryEntry(boolean isMultiDb, String systemWSName, String dsName) throws Exception
++ {
++ // create system workspace entry
++ List<String> ids = new ArrayList<String>();
++ ids.add("id");
++ WorkspaceEntry wsEntry = createWorkspaceEntry(isMultiDb, dsName, ids);
++
++ if (systemWSName != null)
++ {
++ wsEntry.setName(systemWSName);
++ }
++
++ RepositoryEntry repository = new RepositoryEntry();
++ repository.setSystemWorkspaceName(wsEntry.getName());
++ repository.setDefaultWorkspaceName(wsEntry.getName());
++ repository.setName("repo-" + IdGenerator.generate());
++ repository.setSessionTimeOut(3600000);
++ repository.setAuthenticationPolicy("org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator");
++ repository.setSecurityDomain("exo-domain");
++ repository.addWorkspace(wsEntry);
++
++ return repository;
++ }
++
++ /**
++ * Create copy of workspace entry.
++ */
++ public WorkspaceEntry copyWorkspaceEntry(WorkspaceEntry baseWorkspaceEntry) throws Exception
++ {
++ // container entry
++ ArrayList<SimpleParameterEntry> params = new ArrayList<SimpleParameterEntry>();
++ params.addAll(copyList(baseWorkspaceEntry.getContainer().getParameters()));
++ ContainerEntry containerEntry = new ContainerEntry(baseWorkspaceEntry.getContainer().getType(), params);
++ containerEntry.setParameters(params);
++
++ // value storage
++ ArrayList<ValueStorageEntry> list = new ArrayList<ValueStorageEntry>();
++
++ for (ValueStorageEntry baseValueStorageEntry : baseWorkspaceEntry.getContainer().getValueStorages())
++ {
++ ArrayList<ValueStorageFilterEntry> vsparams = new ArrayList<ValueStorageFilterEntry>();
++
++ for (ValueStorageFilterEntry baseValueStorageFilterEntry : baseValueStorageEntry.getFilters())
++ {
++ ValueStorageFilterEntry filterEntry = new ValueStorageFilterEntry();
++ filterEntry.setPropertyType(baseValueStorageFilterEntry.getPropertyType());
++ filterEntry.setPropertyName(baseValueStorageFilterEntry.getPropertyName());
++ filterEntry.setAncestorPath(baseValueStorageFilterEntry.getAncestorPath());
++ filterEntry.setMinValueSize(baseValueStorageFilterEntry.getMinValueSize());
++
++ vsparams.add(filterEntry);
++ }
++
++ ValueStorageEntry valueStorageEntry = new ValueStorageEntry(baseValueStorageEntry.getType(), vsparams);
++ ArrayList<SimpleParameterEntry> spe = new ArrayList<SimpleParameterEntry>();
++ spe.addAll(copyList(baseValueStorageEntry.getParameters()));
++ valueStorageEntry.setId(baseValueStorageEntry.getId());
++ valueStorageEntry.setParameters(spe);
++ valueStorageEntry.setFilters(vsparams);
++
++ // containerEntry.setValueStorages();
++ list.add(valueStorageEntry);
++ }
++
++ containerEntry.setValueStorages(list);
++
++ // Indexer
++ params = new ArrayList<SimpleParameterEntry>();
++ params.addAll(copyList(baseWorkspaceEntry.getQueryHandler().getParameters()));
++ QueryHandlerEntry qEntry = new QueryHandlerEntry(baseWorkspaceEntry.getQueryHandler().getType(), params);
++
++ // Cache
++ params = new ArrayList<SimpleParameterEntry>();
++ params.addAll(copyList(baseWorkspaceEntry.getCache().getParameters()));
++ CacheEntry cacheEntry = new CacheEntry(params);
++ cacheEntry.setType(baseWorkspaceEntry.getCache().getType());
++
++ WorkspaceEntry workspaceEntry = new WorkspaceEntry();
++ workspaceEntry.setContainer(containerEntry);
++ workspaceEntry.setCache(cacheEntry);
++ workspaceEntry.setQueryHandler(qEntry);
++ workspaceEntry.setName(baseWorkspaceEntry.getName());
++ workspaceEntry.setUniqueName(baseWorkspaceEntry.getUniqueName());
++
++ return workspaceEntry;
++
++ }
++
++ /**
++ * Create copy of repository entry.
++ */
++ public RepositoryEntry copyRepositoryEntry(RepositoryEntry baseRepositoryEntry) throws Exception
++ {
++ ArrayList<WorkspaceEntry> wsEntries = new ArrayList<WorkspaceEntry>();
++
++ for (WorkspaceEntry wsEntry : baseRepositoryEntry.getWorkspaceEntries())
++ {
++ WorkspaceEntry newWSEntry = copyWorkspaceEntry(wsEntry);
++
++ wsEntries.add(newWSEntry);
++ }
++
++ RepositoryEntry newRepositoryEntry = new RepositoryEntry();
++
++ newRepositoryEntry.setSystemWorkspaceName(baseRepositoryEntry.getSystemWorkspaceName());
++ newRepositoryEntry.setAccessControl(baseRepositoryEntry.getAccessControl());
++ newRepositoryEntry.setAuthenticationPolicy(baseRepositoryEntry.getAuthenticationPolicy());
++ newRepositoryEntry.setDefaultWorkspaceName(baseRepositoryEntry.getDefaultWorkspaceName());
++ newRepositoryEntry.setName(baseRepositoryEntry.getName());
++ newRepositoryEntry.setSecurityDomain(baseRepositoryEntry.getSecurityDomain());
++ newRepositoryEntry.setSessionTimeOut(baseRepositoryEntry.getSessionTimeOut());
++
++ newRepositoryEntry.setWorkspaceEntries(wsEntries);
++ return newRepositoryEntry;
++
++ }
++
++ /**
++ * Create copy of list with SimpleParameterEntry-s
++ */
++ private List<SimpleParameterEntry> copyList(List<SimpleParameterEntry> baseArrayList)
++ {
++ ArrayList<SimpleParameterEntry> arrayList = new ArrayList<SimpleParameterEntry>();
++
++ for (SimpleParameterEntry baseParameter : baseArrayList)
++ {
++ arrayList.add(new SimpleParameterEntry(baseParameter.getName(), baseParameter.getValue()));
++ }
++
++ return arrayList;
++ }
++
++ /**
++ * Create workspace entry.
++ */
++ public WorkspaceEntry createWorkspaceEntry(boolean isMultiDb, String dsName) throws Exception
++ {
++ List<String> ids = new ArrayList<String>();
++ ids.add("id");
++
++ return createWorkspaceEntry(isMultiDb, dsName, ids);
++ }
++
++ /**
++ * Create workspace entry.
++ */
++ public WorkspaceEntry createWorkspaceEntry(boolean isMultiDb, String dsName, List<String> valueStorageIds)
++ throws Exception
++ {
++ if (dsName == null)
++ {
++ dsName = createDatasource();
++ }
++
++ String id = IdGenerator.generate();
++ String wsName = "ws-" + id;
++
++ // container entry
++ List params = new ArrayList();
++ params.add(new SimpleParameterEntry("source-name", dsName));
++ params.add(new SimpleParameterEntry("multi-db", isMultiDb ? "true" : "false"));
++ params.add(new SimpleParameterEntry("max-buffer-size", "204800"));
++ params.add(new SimpleParameterEntry("dialect", "auto"));
++ params.add(new SimpleParameterEntry("swap-directory", "target/temp/swap/" + wsName));
++
++ ContainerEntry containerEntry =
++ new ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer",
++ (ArrayList)params);
++ containerEntry.setParameters(params);
++
++ // value storage
++ ArrayList list = new ArrayList();
++ if (valueStorageIds != null)
++ {
++ for (String vsId : valueStorageIds)
++ {
++ ArrayList<ValueStorageFilterEntry> vsparams = new ArrayList<ValueStorageFilterEntry>();
++ ValueStorageFilterEntry filterEntry = new ValueStorageFilterEntry();
++ filterEntry.setPropertyType("Binary");
++ vsparams.add(filterEntry);
++
++ ValueStorageEntry valueStorageEntry =
++ new ValueStorageEntry("org.exoplatform.services.jcr.impl.storage.value.fs.SimpleFileValueStorage",
++ vsparams);
++ ArrayList<SimpleParameterEntry> spe = new ArrayList<SimpleParameterEntry>();
++ spe.add(new SimpleParameterEntry("path", "target/temp/values/" + wsName + "-" + vsId));
++ valueStorageEntry.setId(vsId);
++ valueStorageEntry.setParameters(spe);
++ valueStorageEntry.setFilters(vsparams);
++
++ // containerEntry.setValueStorages();
++ containerEntry.setParameters(params);
++ list.add(valueStorageEntry);
++ }
++ }
++
++ containerEntry.setValueStorages(list);
++
++ // Indexer
++ params = new ArrayList();
++ params.add(new SimpleParameterEntry("index-dir", "target/temp/index/" + wsName));
++ QueryHandlerEntry qEntry =
++ new QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex", params);
++
++ // Cache
++ ArrayList cacheParams = new ArrayList();
++ cacheParams.add(new SimpleParameterEntry("maxSize", "2000"));
++ cacheParams.add(new SimpleParameterEntry("liveTime", "20m"));
++ CacheEntry cacheEntry = new CacheEntry(cacheParams);
++ cacheEntry.setType("org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl");
++
++ WorkspaceEntry workspaceEntry = new WorkspaceEntry();
++ workspaceEntry.setContainer(containerEntry);
++ workspaceEntry.setCache(cacheEntry);
++ workspaceEntry.setQueryHandler(qEntry);
++ workspaceEntry.setName(wsName);
++ workspaceEntry.setUniqueName(wsName);
++
++ return workspaceEntry;
++ }
++
++ public List<String> getValueStorageIds(ArrayList<ValueStorageEntry> entries)
++ {
++ List<String> ids = new ArrayList<String>();
++ if (entries != null)
++ {
++ for (ValueStorageEntry entry : entries)
++ {
++ ids.add(entry.getId());
++ }
++ }
++
++ return ids;
++ }
++
++ public static TesterConfigurationHelper getInstance()
++ {
++ if (instance == null)
++ {
++ instance = new TesterConfigurationHelper();
++ }
++
++ return instance;
++ }
++
++}
14 years, 1 month
exo-jcr SVN: r5866 - in jcr/trunk: exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup and 1 other directory.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2012-03-15 05:47:28 -0400 (Thu, 15 Mar 2012)
New Revision: 5866
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java
Log:
EXOJCR-1786 : The repository container is unregenerate all components and remove this container from parent container on fail on instantiation of repository container.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2012-03-14 15:18:29 UTC (rev 5865)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2012-03-15 09:47:28 UTC (rev 5866)
@@ -73,6 +73,7 @@
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
import java.util.List;
import javax.jcr.NamespaceRegistry;
@@ -151,11 +152,20 @@
public Void run()
{
context.setName(parent.getContext().getName() + "-" + name);
- parent.registerComponentInstance(name, RepositoryContainer.this);
+ try
+ {
+ parent.registerComponentInstance(name, RepositoryContainer.this);
+ registerComponents();
+ }
+ catch (Throwable t)
+ {
+ unregisterAllComponents();
+ parent.unregisterComponent(name);
+ throw new IllegalStateException("Can not register repository container " + name + " in parent container.", t);
+ }
return null;
}
});
- registerComponents();
}
/**
@@ -173,26 +183,7 @@
public RepositoryContainer(final ExoContainer parent, RepositoryEntry config) throws RepositoryException,
RepositoryConfigurationException
{
-
- super(new MX4JComponentAdapterFactory(), parent);
-
- // Defaults:
- if (config.getAccessControl() == null)
- config.setAccessControl(AccessControlPolicy.OPTIONAL);
-
- this.config = config;
- this.name = config.getName();
- SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
- {
- public Void run()
- {
- context.setName(parent.getContext().getName() + "-" + name);
- parent.registerComponentInstance(name, RepositoryContainer.this);
- return null;
- }
- });
-
- registerComponents();
+ this(parent, config, new ArrayList<ComponentPlugin>());
}
public LocationFactory getLocationFactory()
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java 2012-03-14 15:18:29 UTC (rev 5865)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupUseCasesTest.java 2012-03-15 09:47:28 UTC (rev 5866)
@@ -19,6 +19,7 @@
import org.apache.commons.collections.map.HashedMap;
import org.exoplatform.commons.utils.PrivilegedFileHelper;
import org.exoplatform.commons.utils.PrivilegedSystemHelper;
+import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.SimpleParameterEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
@@ -1310,112 +1311,102 @@
/**
* Use JobExistingWorkspaceSameConfigRestore to restore.
*/
-
-
-
-
-
public void testExistedWorkspaceRestoreSingleDBTwoWS() throws Exception
{
- // prepare
- String dsName1 = helper.createDatasource();
- String dsName2 = helper.createDatasource();
+ // prepare
+ String dsName1 = helper.createDatasource();
+ String dsName2 = helper.createDatasource();
- ManageableRepository repository = helper.createRepository(container, false, dsName1);
- WorkspaceEntry wsEntry1 = helper.createWorkspaceEntry(false, dsName1);
- helper.addWorkspace(repository, wsEntry1);
- addConent(repository, wsEntry1.getName());
+ ManageableRepository repository = helper.createRepository(container, false, dsName1);
+ WorkspaceEntry wsEntry1 = helper.createWorkspaceEntry(false, dsName1);
+ helper.addWorkspace(repository, wsEntry1);
+ addConent(repository, wsEntry1.getName());
- WorkspaceEntry wsEntry2 = helper.createWorkspaceEntry(false, dsName2);
- helper.addWorkspace(repository, wsEntry2);
- addConent(repository, wsEntry2.getName());
+ WorkspaceEntry wsEntry2 = helper.createWorkspaceEntry(false, dsName2);
+ helper.addWorkspace(repository, wsEntry2);
+ addConent(repository, wsEntry2.getName());
- // backup
- File backDir = new File("target/backup/" + IdGenerator.generate());
- backDir.mkdirs();
+ // backup
+ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
- BackupConfig config = new BackupConfig();
- config.setRepository(repository.getConfiguration().getName());
- config.setWorkspace(wsEntry1.getName());
- config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
- config.setBackupDir(backDir);
+ BackupConfig config = new BackupConfig();
+ config.setRepository(repository.getConfiguration().getName());
+ config.setWorkspace(wsEntry1.getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+ config.setBackupDir(backDir);
- BackupChain bch = backup.startBackup(config);
- waitEndOfBackup(bch);
- backup.stopBackup(bch);
+ BackupChain bch = backup.startBackup(config);
+ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
- // restore
- File backLog = new File(bch.getLogFilePath());
- assertTrue(backLog.exists());
+ // restore
+ File backLog = new File(bch.getLogFilePath());
+ assertTrue(backLog.exists());
- BackupChainLog bchLog = new BackupChainLog(backLog);
+ BackupChainLog bchLog = new BackupChainLog(backLog);
- assertNotNull(bchLog.getStartedTime());
- assertNotNull(bchLog.getFinishedTime());
+ assertNotNull(bchLog.getStartedTime());
+ assertNotNull(bchLog.getFinishedTime());
- backup.restoreExistingWorkspace(bchLog, repository.getConfiguration().getName(), repository.getConfiguration()
- .getWorkspaceEntries().get(1), false);
- checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(1).getName());
- checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(2).getName());
+ backup.restoreExistingWorkspace(bchLog, repository.getConfiguration().getName(), repository.getConfiguration()
+ .getWorkspaceEntries().get(1), false);
+ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(1).getName());
+ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(2).getName());
}
/**
* Use JobExistingWorkspaceRestore to restore.
*/
-
-
-
-
-
public void testExistedWorkspaceRestoreSingleDBTwoWSWithDiffConfig() throws Exception
{
- // prepare
- String dsName1 = helper.createDatasource();
- String dsName2 = helper.createDatasource();
+ // prepare
+ String dsName1 = helper.createDatasource();
+ String dsName2 = helper.createDatasource();
- ManageableRepository repository = helper.createRepository(container, false, dsName1);
- WorkspaceEntry wsEntry1 = helper.createWorkspaceEntry(false, dsName1);
- helper.addWorkspace(repository, wsEntry1);
- addConent(repository, wsEntry1.getName());
+ ManageableRepository repository = helper.createRepository(container, false, dsName1);
+ WorkspaceEntry wsEntry1 = helper.createWorkspaceEntry(false, dsName1);
+ helper.addWorkspace(repository, wsEntry1);
+ addConent(repository, wsEntry1.getName());
- WorkspaceEntry wsEntry2 = helper.createWorkspaceEntry(false, dsName2);
- helper.addWorkspace(repository, wsEntry2);
- addConent(repository, wsEntry2.getName());
+ WorkspaceEntry wsEntry2 = helper.createWorkspaceEntry(false, dsName2);
+ helper.addWorkspace(repository, wsEntry2);
+ addConent(repository, wsEntry2.getName());
- // backup
- File backDir = new File("target/backup/" + IdGenerator.generate());
- backDir.mkdirs();
+ // backup
+ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
- BackupConfig config = new BackupConfig();
- config.setRepository(repository.getConfiguration().getName());
- config.setWorkspace(wsEntry1.getName());
- config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
- config.setBackupDir(backDir);
+ BackupConfig config = new BackupConfig();
+ config.setRepository(repository.getConfiguration().getName());
+ config.setWorkspace(wsEntry1.getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+ config.setBackupDir(backDir);
- BackupChain bch = backup.startBackup(config);
- waitEndOfBackup(bch);
- backup.stopBackup(bch);
+ BackupChain bch = backup.startBackup(config);
+ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
- // restore
- File backLog = new File(bch.getLogFilePath());
- assertTrue(backLog.exists());
+ // restore
+ File backLog = new File(bch.getLogFilePath());
+ assertTrue(backLog.exists());
- BackupChainLog bchLog = new BackupChainLog(backLog);
+ BackupChainLog bchLog = new BackupChainLog(backLog);
- assertNotNull(bchLog.getStartedTime());
- assertNotNull(bchLog.getFinishedTime());
-
- // change cofig
- WorkspaceEntry wsEntry = helper.copyWorkspaceEntry(repository.getConfiguration().getWorkspaceEntries().get(1));
+ assertNotNull(bchLog.getStartedTime());
+ assertNotNull(bchLog.getFinishedTime());
- List<SimpleParameterEntry> params = wsEntry.getContainer().getParameters();
- params.set(2, new SimpleParameterEntry("max-buffer-size", "307200"));
+ // change cofig
+ WorkspaceEntry wsEntry = helper.copyWorkspaceEntry(repository.getConfiguration().getWorkspaceEntries().get(1));
- wsEntry.getContainer().setParameters(params);
+ List<SimpleParameterEntry> params = wsEntry.getContainer().getParameters();
+ params.set(2, new SimpleParameterEntry("max-buffer-size", "307200"));
- backup.restoreExistingWorkspace(bchLog, repository.getConfiguration().getName(), wsEntry, false);
- checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(1).getName());
- checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(2).getName());
+ wsEntry.getContainer().setParameters(params);
+
+ backup.restoreExistingWorkspace(bchLog, repository.getConfiguration().getName(), wsEntry, false);
+ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(1).getName());
+ checkConent(repository, repository.getConfiguration().getWorkspaceEntries().get(2).getName());
}
public void testExistedRepositoryRestoreSingelDBSameConfig() throws Exception
@@ -1458,6 +1449,268 @@
.getConfiguration().getSystemWorkspaceName());
}
+ public void testCreateRepositoryAfterFailRestoreOnSystemWS() throws Exception
+ {
+ // create repository
+ RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
+ String dsName = helper.createDatasource();
+ RepositoryEntry repoEntry = helper.createRepositoryEntry(false, null, dsName);
+ service.createRepository(repoEntry);
+
+ ManageableRepository repository = service.getRepository(repoEntry.getName());
+
+ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(false, dsName);
+ helper.addWorkspace(repository, wsEntry);
+ service.getConfig().retain();
+
+ addConent(repository, repository.getConfiguration().getSystemWorkspaceName());
+
+ // backup
+ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+ config.setBackupDir(backDir);
+
+ RepositoryBackupChain bch = backup.startBackup(config);
+ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+ File backLog = new File(bch.getLogFilePath());
+ assertTrue(backLog.exists());
+
+ // copy repository entry and set new ata source
+ RepositoryEntry newRepoEntry = helper.copyRepositoryEntry(repoEntry);
+ String newDSName = helper.createDatasource();
+ for (WorkspaceEntry ws : newRepoEntry.getWorkspaceEntries())
+ {
+ for (int i = 0; i < ws.getContainer().getParameters().size(); i++)
+ {
+ SimpleParameterEntry spe = ws.getContainer().getParameters().get(i);
+
+ if (spe.getName().equals("source-name"))
+ {
+ ws.getContainer().getParameters().set(i, new SimpleParameterEntry(spe.getName(), newDSName));
+ break;
+ }
+ }
+ }
+
+ // create repository entry with name of data source name is wrong in system workspace
+ RepositoryEntry wrongRepoEntry = helper.copyRepositoryEntry(repoEntry);
+ for (WorkspaceEntry ws : wrongRepoEntry.getWorkspaceEntries())
+ {
+ if (repository.getConfiguration().getSystemWorkspaceName().equals(ws.getName()))
+ {
+ for (int i = 0; i < ws.getContainer().getParameters().size(); i++)
+ {
+ SimpleParameterEntry spe = ws.getContainer().getParameters().get(i);
+
+ if (spe.getName().equals("source-name"))
+ {
+ ws.getContainer().getParameters().set(i,
+ new SimpleParameterEntry(spe.getName(), spe.getValue() + "_wrong"));
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ // remove existed repository
+ removeRepositoryFully(repository.getConfiguration().getName());
+
+ // wrong restore
+ try
+ {
+ backup.restore(new RepositoryBackupChainLog(backLog), wrongRepoEntry, false);
+ fail();
+ }
+ catch (Exception e)
+ {
+ //ok
+ }
+
+ // restore
+ long timeOfRestore = System.currentTimeMillis();
+ backup.restore(new RepositoryBackupChainLog(backLog), newRepoEntry, false);
+ log.info("Total time of restore the repository = " + ((System.currentTimeMillis() - timeOfRestore)) + "ms.");
+ checkConent(repositoryService.getRepository(newRepoEntry.getName()), newRepoEntry.getSystemWorkspaceName());
+ }
+
+ public void testCreateRepositoryAfterFailRestoreOnNonSystemWS() throws Exception
+ {
+ // create repository
+ RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
+ String dsName = helper.createDatasource();
+ RepositoryEntry repoEntry = helper.createRepositoryEntry(false, null, dsName);
+ service.createRepository(repoEntry);
+
+ ManageableRepository repository = service.getRepository(repoEntry.getName());
+
+ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(false, dsName);
+ helper.addWorkspace(repository, wsEntry);
+ service.getConfig().retain();
+
+ addConent(repository, wsEntry.getName());
+
+ // backup
+ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+ config.setBackupDir(backDir);
+
+ RepositoryBackupChain bch = backup.startBackup(config);
+ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+ File backLog = new File(bch.getLogFilePath());
+ assertTrue(backLog.exists());
+
+ // copy repository entry and set new ata source
+ RepositoryEntry newRepoEntry = helper.copyRepositoryEntry(repoEntry);
+ String newDSName = helper.createDatasource();
+ for (WorkspaceEntry ws : newRepoEntry.getWorkspaceEntries())
+ {
+ for (int i = 0; i < ws.getContainer().getParameters().size(); i++)
+ {
+ SimpleParameterEntry spe = ws.getContainer().getParameters().get(i);
+
+ if (spe.getName().equals("source-name"))
+ {
+ ws.getContainer().getParameters().set(i, new SimpleParameterEntry(spe.getName(), newDSName));
+ break;
+ }
+ }
+ }
+
+ // create repository entry with name of data source name is wrong in second workspace
+ RepositoryEntry wrongRepoEntry = helper.copyRepositoryEntry(repoEntry);
+ for (WorkspaceEntry ws : wrongRepoEntry.getWorkspaceEntries())
+ {
+ if (wsEntry.getName().equals(ws.getName()))
+ {
+ for (int i = 0; i < ws.getContainer().getParameters().size(); i++)
+ {
+ SimpleParameterEntry spe = ws.getContainer().getParameters().get(i);
+
+ if (spe.getName().equals("source-name"))
+ {
+ ws.getContainer().getParameters().set(i,
+ new SimpleParameterEntry(spe.getName(), spe.getValue() + "_wrong"));
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ // remove existed repository
+ removeRepositoryFully(repository.getConfiguration().getName());
+
+ // wrong restore
+ try
+ {
+ backup.restore(new RepositoryBackupChainLog(backLog), wrongRepoEntry, false);
+ fail();
+ }
+ catch (Exception e)
+ {
+ //ok
+ }
+
+ // restore
+ long timeOfRestore = System.currentTimeMillis();
+ backup.restore(new RepositoryBackupChainLog(backLog), newRepoEntry, false);
+ log.info("Total time of restore the repository = " + ((System.currentTimeMillis() - timeOfRestore)) + "ms.");
+ checkConent(repositoryService.getRepository(newRepoEntry.getName()), wsEntry.getName());
+ }
+
+ public void testCreateRepositoryAfterFailRestoreWithFailConfiguration() throws Exception
+ {
+ // create repository
+ RepositoryService service = (RepositoryService)container.getComponentInstanceOfType(RepositoryService.class);
+ String dsName = helper.createDatasource();
+ RepositoryEntry repoEntry = helper.createRepositoryEntry(false, null, dsName);
+ service.createRepository(repoEntry);
+
+ ManageableRepository repository = service.getRepository(repoEntry.getName());
+
+ WorkspaceEntry wsEntry = helper.createWorkspaceEntry(false, dsName);
+ helper.addWorkspace(repository, wsEntry);
+ service.getConfig().retain();
+
+ addConent(repository, wsEntry.getName());
+
+ // backup
+ File backDir = new File("target/backup/" + IdGenerator.generate());
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+ config.setRepository(repository.getConfiguration().getName());
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+ config.setBackupDir(backDir);
+
+ RepositoryBackupChain bch = backup.startBackup(config);
+ waitEndOfBackup(bch);
+ backup.stopBackup(bch);
+
+ File backLog = new File(bch.getLogFilePath());
+ assertTrue(backLog.exists());
+
+ // copy repository entry and set new data source
+ RepositoryEntry newRepoEntry = helper.copyRepositoryEntry(repoEntry);
+ String newDSName = helper.createDatasource();
+ for (WorkspaceEntry ws : newRepoEntry.getWorkspaceEntries())
+ {
+ for (int i = 0; i < ws.getContainer().getParameters().size(); i++)
+ {
+ SimpleParameterEntry spe = ws.getContainer().getParameters().get(i);
+
+ if (spe.getName().equals("source-name"))
+ {
+ ws.getContainer().getParameters().set(i, new SimpleParameterEntry(spe.getName(), newDSName));
+ break;
+ }
+ }
+ }
+
+ // create repository entry with name of data source name is wrong in second workspace
+ RepositoryEntry wrongRepoEntry = helper.copyRepositoryEntry(repoEntry);
+ for (WorkspaceEntry ws : wrongRepoEntry.getWorkspaceEntries())
+ {
+ if (wsEntry.getName().equals(ws.getName()))
+ {
+ ws.getContainer().setType("wrong parameter");
+ }
+ }
+
+ // remove existed repository
+ removeRepositoryFully(repository.getConfiguration().getName());
+
+ // wrong restore
+ try
+ {
+ backup.restore(new RepositoryBackupChainLog(backLog), wrongRepoEntry, false);
+ fail();
+ }
+ catch (Exception e)
+ {
+ //ok
+ }
+
+ // restore
+ long timeOfRestore = System.currentTimeMillis();
+ backup.restore(new RepositoryBackupChainLog(backLog), newRepoEntry, false);
+ log.info("Total time of restore the repository = " + ((System.currentTimeMillis() - timeOfRestore)) + "ms.");
+ checkConent(repositoryService.getRepository(newRepoEntry.getName()), wsEntry.getName());
+ }
+
/**
* Set new backup directory in RepositoryBackupChainLog
*
14 years, 1 month
exo-jcr SVN: r5864 - in jcr/branches/1.15.x/exo.jcr.component.ext/src/test: resources/conf/standalone and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-03-14 10:33:08 -0400 (Wed, 14 Mar 2012)
New Revision: 5864
Modified:
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/usecase/TestBackupRestore.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-db2.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mssql.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mysql.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-oracle.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-pgsql.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-sybase.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml
Log:
EXOJCR-1772: Adopt RDBMS backup/restore/clean. Added more tests
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/usecase/TestBackupRestore.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/usecase/TestBackupRestore.java 2012-03-14 13:28:03 UTC (rev 5863)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/usecase/TestBackupRestore.java 2012-03-14 14:33:08 UTC (rev 5864)
@@ -83,6 +83,8 @@
{
repositoryBackupRestore("db4");
repositoryBackupRestore("db4");
+ repositoryBackupRestore("db8");
+ repositoryBackupRestore("db8");
}
public void testBackupRestoreExistingWorkspaceSingleDB() throws Exception
@@ -95,6 +97,8 @@
{
workspaceBackupRestore("db4");
workspaceBackupRestore("db4");
+ workspaceBackupRestore("db8");
+ workspaceBackupRestore("db8");
}
public void testJobExistingRepositorySameConfigRestoreSingleDB() throws Exception
@@ -107,6 +111,8 @@
{
repositoryBackupRestoreDirectlyOverJobExistingRepositorySameConfigRestore("db4");
repositoryBackupRestoreDirectlyOverJobExistingRepositorySameConfigRestore("db4");
+ repositoryBackupRestoreDirectlyOverJobExistingRepositorySameConfigRestore("db8");
+ repositoryBackupRestoreDirectlyOverJobExistingRepositorySameConfigRestore("db8");
}
public void testJobExistingRepositoryRestoreSingleDB() throws Exception
@@ -119,6 +125,8 @@
{
repositoryBackupRestoreDirectlyOverJobExistingRepositoryRestore("db4");
repositoryBackupRestoreDirectlyOverJobExistingRepositoryRestore("db4");
+ repositoryBackupRestoreDirectlyOverJobExistingRepositoryRestore("db8");
+ repositoryBackupRestoreDirectlyOverJobExistingRepositoryRestore("db8");
}
public void testJobRepositoryRestoreSingleDB() throws Exception
@@ -131,6 +139,8 @@
{
repositoryBackupRestoreDirectlyOverJobRepositoryRestore("db4");
repositoryBackupRestoreDirectlyOverJobRepositoryRestore("db4");
+ repositoryBackupRestoreDirectlyOverJobRepositoryRestore("db8");
+ repositoryBackupRestoreDirectlyOverJobRepositoryRestore("db8");
}
public void testJobExistingWorkspaceSameConfigRestoreSingleDB() throws Exception
@@ -143,6 +153,8 @@
{
workspaceBackupRestoreDirectlyOverJobExistingWorkspaceSameConfigRestore("db4");
workspaceBackupRestoreDirectlyOverJobExistingWorkspaceSameConfigRestore("db4");
+ workspaceBackupRestoreDirectlyOverJobExistingWorkspaceSameConfigRestore("db8");
+ workspaceBackupRestoreDirectlyOverJobExistingWorkspaceSameConfigRestore("db8");
}
public void testJobExistingWorkspaceRestoreSingleDB() throws Exception
@@ -155,6 +167,8 @@
{
workspaceBackupRestoreDirectlyOverJobExistingWorkspaceRestore("db4");
workspaceBackupRestoreDirectlyOverJobExistingWorkspaceRestore("db4");
+ workspaceBackupRestoreDirectlyOverJobExistingWorkspaceRestore("db8");
+ workspaceBackupRestoreDirectlyOverJobExistingWorkspaceRestore("db8");
}
public void testJobWorkspaceRestoreSingleDB() throws Exception
@@ -167,6 +181,8 @@
{
workspaceBackupRestoreDirectlyOverJobWorkspaceRestore("db4");
workspaceBackupRestoreDirectlyOverJobWorkspaceRestore("db4");
+ workspaceBackupRestoreDirectlyOverJobWorkspaceRestore("db8");
+ workspaceBackupRestoreDirectlyOverJobWorkspaceRestore("db8");
}
protected void repositoryBackupRestoreDirectlyOverJobExistingRepositorySameConfigRestore(String repositoryName)
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-db2.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-db2.xml 2012-03-14 13:28:03 UTC (rev 5863)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-db2.xml 2012-03-14 14:33:08 UTC (rev 5864)
@@ -243,6 +243,60 @@
<init-params>
<value-param>
<name>bind-name</name>
+ <value>jdbcjcr30</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr31</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws2" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
<value>jdbcjcr8</value>
</value-param>
<value-param>
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mssql.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mssql.xml 2012-03-14 13:28:03 UTC (rev 5863)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mssql.xml 2012-03-14 14:33:08 UTC (rev 5864)
@@ -189,6 +189,60 @@
<init-params>
<value-param>
<name>bind-name</name>
+ <value>jdbcjcr30</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr31</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws2" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
<value>jdbcjcr6</value>
</value-param>
<value-param>
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mysql.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mysql.xml 2012-03-14 13:28:03 UTC (rev 5863)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-mysql.xml 2012-03-14 14:33:08 UTC (rev 5864)
@@ -236,6 +236,60 @@
</properties-param>
</init-params>
</component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr30</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr31</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws2" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
<component-plugin>
<name>bind.datasource</name>
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-oracle.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-oracle.xml 2012-03-14 13:28:03 UTC (rev 5863)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-oracle.xml 2012-03-14 14:33:08 UTC (rev 5864)
@@ -236,6 +236,60 @@
</properties-param>
</init-params>
</component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr30</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr31</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws2" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
<component-plugin>
<name>bind.datasource</name>
<set-method>addPlugin</set-method>
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-pgsql.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-pgsql.xml 2012-03-14 13:28:03 UTC (rev 5863)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-pgsql.xml 2012-03-14 14:33:08 UTC (rev 5864)
@@ -238,6 +238,60 @@
</properties-param>
</init-params>
</component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr30</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr31</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws2" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
<component-plugin>
<name>bind.datasource</name>
<set-method>addPlugin</set-method>
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-sybase.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-sybase.xml 2012-03-14 13:28:03 UTC (rev 5863)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup-sybase.xml 2012-03-14 14:33:08 UTC (rev 5864)
@@ -243,6 +243,60 @@
<init-params>
<value-param>
<name>bind-name</name>
+ <value>jdbcjcr30</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr31</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws2" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
<value>jdbcjcr8</value>
</value-param>
<value-param>
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup.xml 2012-03-14 13:28:03 UTC (rev 5863)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-backup.xml 2012-03-14 14:33:08 UTC (rev 5864)
@@ -263,5 +263,59 @@
</properties-param>
</init-params>
</component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr30</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr31</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws2" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
</external-component-plugins>
</configuration>
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2012-03-14 13:28:03 UTC (rev 5863)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2012-03-14 14:33:08 UTC (rev 5864)
@@ -1104,6 +1104,60 @@
<init-params>
<value-param>
<name>bind-name</name>
+ <value>jdbcjcr30</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr31</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </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/db8ws2" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
<value>jdbcjcr_to_rest_repo_1</value>
</value-param>
<value-param>
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml 2012-03-14 13:28:03 UTC (rev 5863)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml 2012-03-14 14:33:08 UTC (rev 5864)
@@ -241,5 +241,116 @@
</workspace>
</workspaces>
</repository>
+
+ <repository name="db8" system-workspace="ws" default-workspace="ws">
+ <security-domain>exo-domain</security-domain>
+ <access-control>optional</access-control>
+ <authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
+ <workspaces>
+ <workspace name="ws">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr30" />
+ <property name="db-structure-type" value="multi" />
+ <property name="max-buffer-size" value="200k" />
+ <property name="swap-directory" value="target/temp/swap/db4ws" />
+ </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/db8ws" />
+ </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="10k" />
+ <property name="live-time" value="1h" />
+ </properties>
+ </cache>
+ <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir" value="target/temp/jcrlucenedb/db8ws" />
+ </properties>
+ </query-handler>
+ <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManagerImpl">
+ <properties>
+ <property name="time-out" value="15m" />
+ <property name="jbosscache-configuration" value="conf/standalone/test-jbosscache-lock.xml" />
+ <property name="jbosscache-cl-cache.jdbc.table.name" value="jcrlocks" />
+ <property name="jbosscache-cl-cache.jdbc.table.create" value="true" />
+ <property name="jbosscache-cl-cache.jdbc.table.drop" value="false" />
+ <property name="jbosscache-cl-cache.jdbc.table.primarykey" value="jcrlocks_pk" />
+ <property name="jbosscache-cl-cache.jdbc.fqn.column" value="fqn" />
+ <property name="jbosscache-cl-cache.jdbc.node.column" value="node" />
+ <property name="jbosscache-cl-cache.jdbc.parent.column" value="parent" />
+ <property name="jbosscache-cl-cache.jdbc.datasource" value="jdbcjcr30" />
+ <property name="jbosscache-shareable" value="true" />
+ </properties>
+ </lock-manager>
+ </workspace>
+
+ <workspace name="ws1">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr31" />
+ <property name="db-structure-type" value="multi" />
+ <property name="max-buffer-size" value="200k" />
+ <property name="swap-directory" value="target/temp/swap/db8ws1" />
+ </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/db8ws1" />
+ </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="10k" />
+ <property name="live-time" value="1h" />
+ </properties>
+ </cache>
+ <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir" value="target/temp/jcrlucenedb/db8ws1" />
+ </properties>
+ </query-handler>
+ <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManagerImpl">
+ <properties>
+ <property name="time-out" value="15m" />
+ <property name="jbosscache-configuration" value="conf/standalone/test-jbosscache-lock.xml" />
+ <property name="jbosscache-cl-cache.jdbc.table.name" value="jcrlocks" />
+ <property name="jbosscache-cl-cache.jdbc.table.create" value="true" />
+ <property name="jbosscache-cl-cache.jdbc.table.drop" value="false" />
+ <property name="jbosscache-cl-cache.jdbc.table.primarykey" value="jcrlocks_pk" />
+ <property name="jbosscache-cl-cache.jdbc.fqn.column" value="fqn" />
+ <property name="jbosscache-cl-cache.jdbc.node.column" value="node" />
+ <property name="jbosscache-cl-cache.jdbc.parent.column" value="parent" />
+ <property name="jbosscache-cl-cache.jdbc.datasource" value="jdbcjcr31" />
+ <property name="jbosscache-shareable" value="true" />
+ </properties>
+ </lock-manager>
+ </workspace>
+ </workspaces>
+ </repository>
</repositories>
</repository-service>
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml 2012-03-14 13:28:03 UTC (rev 5863)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml 2012-03-14 14:33:08 UTC (rev 5864)
@@ -844,5 +844,115 @@
</workspace>
</workspaces>
</repository>
+ <repository name="db8" system-workspace="ws" default-workspace="ws">
+ <security-domain>exo-domain</security-domain>
+ <access-control>optional</access-control>
+ <authentication-policy>org.exoplatform.services.jcr.impl.core.access.JAASAuthenticator</authentication-policy>
+ <workspaces>
+ <workspace name="ws">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr30" />
+ <property name="db-structure-type" value="multi" />
+ <property name="max-buffer-size" value="200k" />
+ <property name="swap-directory" value="target/temp/swap/db4ws" />
+ </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/db8ws" />
+ </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="10k" />
+ <property name="live-time" value="1h" />
+ </properties>
+ </cache>
+ <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir" value="target/temp/jcrlucenedb/db8ws" />
+ </properties>
+ </query-handler>
+ <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManagerImpl">
+ <properties>
+ <property name="time-out" value="15m" />
+ <property name="jbosscache-configuration" value="conf/standalone/test-jbosscache-lock.xml" />
+ <property name="jbosscache-cl-cache.jdbc.table.name" value="jcrlocks" />
+ <property name="jbosscache-cl-cache.jdbc.table.create" value="true" />
+ <property name="jbosscache-cl-cache.jdbc.table.drop" value="false" />
+ <property name="jbosscache-cl-cache.jdbc.table.primarykey" value="jcrlocks_pk" />
+ <property name="jbosscache-cl-cache.jdbc.fqn.column" value="fqn" />
+ <property name="jbosscache-cl-cache.jdbc.node.column" value="node" />
+ <property name="jbosscache-cl-cache.jdbc.parent.column" value="parent" />
+ <property name="jbosscache-cl-cache.jdbc.datasource" value="jdbcjcr30" />
+ <property name="jbosscache-shareable" value="true" />
+ </properties>
+ </lock-manager>
+ </workspace>
+
+ <workspace name="ws1">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr31" />
+ <property name="db-structure-type" value="multi" />
+ <property name="max-buffer-size" value="200k" />
+ <property name="swap-directory" value="target/temp/swap/db8ws1" />
+ </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/db8ws1" />
+ </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="10k" />
+ <property name="live-time" value="1h" />
+ </properties>
+ </cache>
+ <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir" value="target/temp/jcrlucenedb/db8ws1" />
+ </properties>
+ </query-handler>
+ <lock-manager class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManagerImpl">
+ <properties>
+ <property name="time-out" value="15m" />
+ <property name="jbosscache-configuration" value="conf/standalone/test-jbosscache-lock.xml" />
+ <property name="jbosscache-cl-cache.jdbc.table.name" value="jcrlocks" />
+ <property name="jbosscache-cl-cache.jdbc.table.create" value="true" />
+ <property name="jbosscache-cl-cache.jdbc.table.drop" value="false" />
+ <property name="jbosscache-cl-cache.jdbc.table.primarykey" value="jcrlocks_pk" />
+ <property name="jbosscache-cl-cache.jdbc.fqn.column" value="fqn" />
+ <property name="jbosscache-cl-cache.jdbc.node.column" value="node" />
+ <property name="jbosscache-cl-cache.jdbc.parent.column" value="parent" />
+ <property name="jbosscache-cl-cache.jdbc.datasource" value="jdbcjcr31" />
+ <property name="jbosscache-shareable" value="true" />
+ </properties>
+ </lock-manager>
+ </workspace>
+ </workspaces>
+ </repository>
</repositories>
</repository-service>
14 years, 1 month
exo-jcr SVN: r5863 - in jcr/branches/1.15.x: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms and 16 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-03-14 09:28:03 -0400 (Wed, 14 Mar 2012)
New Revision: 5863
Removed:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JBCShareableLockTableHandler.java.orig
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java.orig
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OracleConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OraclePoolConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java.orig
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/StorageDBInitializer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OraclePoolConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java.orig
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/developer-notes.txt
jcr/branches/1.15.x/exo.jcr.component.core/pom.xml
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DB2CleaningScipts.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScriptsFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/HSQLDBCleaningScipts.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/MySQLCleaningScipts.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/OracleCleaningScipts.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/SybaseCleaningScipts.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCDataContainerConfig.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/PgSQLDBInitializer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2ConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseConnectionFactory.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceSameConfigRestore.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/RdbmsWorkspaceInitializer.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/usecase/TestBackupRestore.java
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml
jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml
jcr/branches/1.15.x/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-1772: Adopt RDBMS backup/restore/clean
Modified: jcr/branches/1.15.x/exo.jcr.component.core/developer-notes.txt
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/developer-notes.txt 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/developer-notes.txt 2012-03-14 13:28:03 UTC (rev 5863)
@@ -15,4 +15,5 @@
* Removed BackupSchedulerException class
* EXOJCR-1728: Remove ReadOnly support for WorkspacePersistentDataManager
* Lucene 3.0
-* Isolated DB Concept (EXOJCR-1754)
\ No newline at end of file
+* Isolated DB Concept (EXOJCR-1754)
+* Not supported parameters driverClassName, url, username, password, sourceName in JDBC workspace datacontainer
\ No newline at end of file
Modified: jcr/branches/1.15.x/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/pom.xml 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/pom.xml 2012-03-14 13:28:03 UTC (rev 5863)
@@ -1018,3 +1018,4 @@
</profile>
</profiles>
</project>
+
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/DBCleanService.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -189,8 +189,6 @@
{
SecurityHelper.validateSecurityPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
- boolean multiDb = getMultiDbParameter(wsEntry);
-
String dialect = resolveDialect(wsEntry);
boolean autoCommit = dialect.equalsIgnoreCase(DialectConstants.DB_DIALECT_SYBASE);
@@ -290,7 +288,7 @@
{
try
{
- return Boolean.parseBoolean(wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.MULTIDB));
+ return JDBCWorkspaceDataContainer.getDatabaseType(wsEntry).isMultiDatabase();
}
catch (RepositoryConfigurationException e)
{
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DB2CleaningScipts.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DB2CleaningScipts.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DB2CleaningScipts.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -67,8 +67,8 @@
{
List<String> scripts = new ArrayList<String>();
- String constraintName = "JCR_FK_" + tablePrefix + "ITEM_PAREN";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM DROP CONSTRAINT " + constraintName);
+ String constraintName = "JCR_FK_" + itemTableSuffix + "_PAREN";
+ scripts.add("ALTER TABLE " + itemTableName + " DROP CONSTRAINT " + constraintName);
return scripts;
}
@@ -81,8 +81,8 @@
List<String> scripts = new ArrayList<String>();
String constraintName =
- "JCR_FK_" + tablePrefix + "ITEM_PAREN FOREIGN KEY(PARENT_ID) REFERENCES JCR_" + tablePrefix + "ITEM(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM ADD CONSTRAINT " + constraintName);
+ "JCR_FK_" + itemTableSuffix + "_PAREN FOREIGN KEY(PARENT_ID) REFERENCES " + itemTableName + "(ID)";
+ scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT " + constraintName);
return scripts;
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -18,8 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.clean.rdbms.scripts;
-import org.exoplatform.commons.utils.IOUtil;
-import org.exoplatform.commons.utils.PrivilegedFileHelper;
import org.exoplatform.services.database.utils.JDBCUtils;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.RepositoryEntry;
@@ -28,7 +26,6 @@
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -40,20 +37,32 @@
*/
public abstract class DBCleaningScripts
{
- protected final String tablePrefix;
+ protected String itemTableName;
+ protected String valueTableName;
+
+ protected String refTableName;
+
+ protected String itemTableSuffix;
+
+ protected String valueTableSuffix;
+
+ protected String refTableSuffix;
+
protected final String dialect;
+ protected final String workspaceName;
+
protected final boolean multiDb;
- protected final String workspaceName;
-
protected final List<String> cleaningScripts = new ArrayList<String>();
protected final List<String> committingScripts = new ArrayList<String>();
protected final List<String> rollbackingScripts = new ArrayList<String>();
+ protected final WorkspaceEntry wsEntry;
+
/**
* DBCleaningScripts constructor.
*
@@ -61,15 +70,27 @@
*/
DBCleaningScripts(String dialect, RepositoryEntry rEntry) throws DBCleanException
{
- if (getMultiDbParameter(rEntry.getWorkspaceEntries().get(0)))
+ for (WorkspaceEntry wsEntry : rEntry.getWorkspaceEntries())
{
- throw new DBCleanException("Not supported operation.");
+ try
+ {
+ if (JDBCWorkspaceDataContainer.getDatabaseType(wsEntry).isMultiDatabase())
+ {
+ throw new DBCleanException("Not supported operation.");
+ }
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ throw new DBCleanException(e);
+ }
}
this.multiDb = false;
- this.tablePrefix = "S";
this.workspaceName = null;
this.dialect = dialect;
+ this.wsEntry = rEntry.getWorkspaceEntries().get(0);
+
+ initTableNames(wsEntry);
}
/**
@@ -79,10 +100,20 @@
*/
DBCleaningScripts(String dialect, WorkspaceEntry wsEntry) throws DBCleanException
{
- this.multiDb = getMultiDbParameter(wsEntry);
- this.tablePrefix = multiDb ? "M" : "S";
+ try
+ {
+ this.multiDb = JDBCWorkspaceDataContainer.getDatabaseType(wsEntry).isMultiDatabase();
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ throw new DBCleanException(e);
+ }
+
this.workspaceName = wsEntry.getName();
this.dialect = dialect;
+ this.wsEntry = wsEntry;
+
+ initTableNames(wsEntry);
}
/**
@@ -217,8 +248,8 @@
{
List<String> scripts = new ArrayList<String>();
- String constraintName = "JCR_FK_" + tablePrefix + "ITEM_PARENT";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM " + constraintDroppingSyntax() + " " + constraintName);
+ String constraintName = "JCR_FK_" + itemTableSuffix + "_PARENT";
+ scripts.add("ALTER TABLE " + itemTableName + " " + constraintDroppingSyntax() + " " + constraintName);
return scripts;
}
@@ -231,8 +262,8 @@
List<String> scripts = new ArrayList<String>();
String constraintName =
- "JCR_FK_" + tablePrefix + "ITEM_PARENT FOREIGN KEY(PARENT_ID) REFERENCES JCR_" + tablePrefix + "ITEM(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM ADD CONSTRAINT " + constraintName);
+ "JCR_FK_" + itemTableSuffix + "_PARENT FOREIGN KEY(PARENT_ID) REFERENCES " + itemTableName + "(ID)";
+ scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT " + constraintName);
return scripts;
}
@@ -244,9 +275,9 @@
{
List<String> scripts = new ArrayList<String>();
- scripts.add("DROP TABLE JCR_" + tablePrefix + "VALUE_OLD");
- scripts.add("DROP TABLE JCR_" + tablePrefix + "ITEM_OLD");
- scripts.add("DROP TABLE JCR_" + tablePrefix + "REF_OLD");
+ scripts.add("DROP TABLE " + valueTableName + "_OLD");
+ scripts.add("DROP TABLE " + refTableName + "_OLD");
+ scripts.add("DROP TABLE " + itemTableName + "_OLD");
return scripts;
}
@@ -258,9 +289,9 @@
{
List<String> scripts = new ArrayList<String>();
- scripts.add("DROP TABLE JCR_" + tablePrefix + "VALUE");
- scripts.add("DROP TABLE JCR_" + tablePrefix + "ITEM");
- scripts.add("DROP TABLE JCR_" + tablePrefix + "REF");
+ scripts.add("DROP TABLE " + valueTableName);
+ scripts.add("DROP TABLE " + refTableName);
+ scripts.add("DROP TABLE " + itemTableName);
return scripts;
}
@@ -288,33 +319,27 @@
*/
protected Collection<String> getDBInitializationScripts() throws DBCleanException
{
- String scriptPath = DBInitializerHelper.scriptPath(dialect, multiDb);
-
- String script;
+ String dbScripts;
try
{
- script = IOUtil.getStreamContentAsString(PrivilegedFileHelper.getResourceAsStream(scriptPath));
+ dbScripts = DBInitializerHelper.prepareScripts(wsEntry, dialect);
}
- catch (FileNotFoundException e)
+ catch (IOException e)
{
throw new DBCleanException(e);
}
- catch (IllegalArgumentException e)
+ catch (RepositoryConfigurationException e)
{
throw new DBCleanException(e);
}
- catch (IOException e)
- {
- throw new DBCleanException(e);
- }
List<String> scripts = new ArrayList<String>();
- for (String query : JDBCUtils.splitWithSQLDelimiter(script))
+ for (String query : JDBCUtils.splitWithSQLDelimiter(dbScripts))
{
scripts.add(JDBCUtils.cleanWhitespaces(query));
}
- scripts.add(DBInitializerHelper.getRootNodeInitializeScript(multiDb));
+ scripts.add(DBInitializerHelper.getRootNodeInitializeScript(itemTableName, multiDb));
return scripts;
}
@@ -327,14 +352,17 @@
return "DROP CONSTRAINT";
}
- /**
- * Return {@link JDBCWorkspaceDataContainer#MULTIDB} parameter from workspace configuration.
- */
- private boolean getMultiDbParameter(WorkspaceEntry wsEntry) throws DBCleanException
+ private void initTableNames(WorkspaceEntry wsConfig) throws DBCleanException
{
try
{
- return Boolean.parseBoolean(wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.MULTIDB));
+ itemTableName = DBInitializerHelper.getItemTableName(wsConfig);
+ refTableName = DBInitializerHelper.getRefTableName(wsConfig);
+ valueTableName = DBInitializerHelper.getValueTableName(wsConfig);
+
+ itemTableSuffix = DBInitializerHelper.getItemTableSuffix(wsConfig);
+ valueTableSuffix = DBInitializerHelper.getValueTableSuffix(wsConfig);
+ refTableSuffix = DBInitializerHelper.getRefTableSuffix(wsConfig);
}
catch (RepositoryConfigurationException e)
{
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScriptsFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScriptsFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScriptsFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.impl.clean.rdbms.DBCleanException;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
/**
* @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
@@ -31,6 +32,13 @@
{
/**
* Prepare SQL scripts for cleaning workspace data from database.
+ *
+ * @param wsEntry
+ * workspace configuration
+ * @param dialect
+ * database dialect which is used, since {@link JDBCWorkspaceDataContainer#DB_DIALECT} parameter
+ * can contain {@link DialectConstants#DB_DIALECT_AUTO} value it is necessary to resolve dialect
+ * before based on database connection.
*/
public static DBCleaningScripts prepareScripts(String dialect, WorkspaceEntry wsEntry) throws DBCleanException
{
@@ -75,6 +83,13 @@
/**
* Prepare SQL scripts for cleaning repository data from database.
+ *
+ * @param rEntry
+ * repository configuration
+ * @param dialect
+ * database dialect which is used, since {@link JDBCWorkspaceDataContainer#DB_DIALECT} parameter
+ * can contain {@link DialectConstants#DB_DIALECT_AUTO} value it is necessary to resolve dialect
+ * before based on database connection.
*/
public static DBCleaningScripts prepareScripts(String dialect, RepositoryEntry rEntry) throws DBCleanException
{
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/HSQLDBCleaningScipts.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/HSQLDBCleaningScipts.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/HSQLDBCleaningScipts.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -66,29 +66,28 @@
Collection<String> scripts = new ArrayList<String>();
// renaming tables
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE RENAME TO JCR_" + tablePrefix + "VALUE_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM RENAME TO JCR_" + tablePrefix + "ITEM_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF RENAME TO JCR_" + tablePrefix + "REF_OLD");
+ scripts.add("ALTER TABLE " + valueTableName + " RENAME TO " + valueTableName + "_OLD");
+ scripts.add("ALTER TABLE " + itemTableName + " RENAME TO " + itemTableName + "_OLD");
+ scripts.add("ALTER TABLE " + refTableName + " RENAME TO " + refTableName + "_OLD");
// droping constraints
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE_OLD DROP CONSTRAINT JCR_FK_" + tablePrefix
- + "VALUE_PROPERTY");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM_OLD DROP CONSTRAINT JCR_FK_" + tablePrefix + "ITEM_PARENT");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM_OLD DROP CONSTRAINT JCR_PK_" + tablePrefix + "ITEM");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE_OLD DROP CONSTRAINT JCR_PK_" + tablePrefix + "VALUE");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF_OLD DROP CONSTRAINT JCR_PK_" + tablePrefix + "REF");
+ scripts.add("ALTER TABLE " + valueTableName + "_OLD DROP CONSTRAINT JCR_FK_" + valueTableSuffix + "_PROPERTY");
+ scripts.add("ALTER TABLE " + itemTableName + "_OLD DROP CONSTRAINT JCR_FK_" + itemTableSuffix + "_PARENT");
+ scripts.add("ALTER TABLE " + itemTableName + "_OLD DROP CONSTRAINT JCR_PK_" + itemTableSuffix);
+ scripts.add("ALTER TABLE " + valueTableName + "_OLD DROP CONSTRAINT JCR_PK_" + valueTableSuffix);
+ scripts.add("ALTER TABLE " + refTableName + "_OLD DROP CONSTRAINT JCR_PK_" + refTableSuffix);
// renaming indexes
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_ID RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_ID_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_N_ORDER_NUM RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_N_ORDER_NUM_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "VALUE_PROPERTY RENAME TO JCR_IDX_" + tablePrefix
- + "VALUE_PROPERTY_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "REF_PROPERTY RENAME TO JCR_IDX_" + tablePrefix
- + "REF_PROPERTY_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_ID RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_ID_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_N_ORDER_NUM RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_N_ORDER_NUM_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + valueTableSuffix + "_PROPERTY RENAME TO JCR_IDX_" + valueTableSuffix
+ + "_PROPERTY_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + refTableSuffix + "_PROPERTY RENAME TO JCR_IDX_" + refTableSuffix
+ + "_PROPERTY_OLD");
return scripts;
}
@@ -101,33 +100,31 @@
Collection<String> scripts = new ArrayList<String>();
// renaming tables
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE_OLD RENAME TO JCR_" + tablePrefix + "VALUE");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM_OLD RENAME TO JCR_" + tablePrefix + "ITEM");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF_OLD RENAME TO JCR_" + tablePrefix + "REF");
+ scripts.add("ALTER TABLE " + valueTableName + "_OLD RENAME TO " + valueTableName);
+ scripts.add("ALTER TABLE " + itemTableName + "_OLD RENAME TO " + itemTableName);
+ scripts.add("ALTER TABLE " + refTableName + "_OLD RENAME TO " + refTableName);
// creating constraints
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM ADD CONSTRAINT JCR_PK_" + tablePrefix
- + "ITEM PRIMARY KEY(ID)");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE ADD CONSTRAINT JCR_FK_" + tablePrefix
- + "VALUE_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES JCR_" + tablePrefix + "ITEM(ID)");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM ADD CONSTRAINT JCR_FK_" + tablePrefix
- + "ITEM_PARENT FOREIGN KEY(PARENT_ID) REFERENCES JCR_" + tablePrefix + "ITEM(ID)");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE ADD CONSTRAINT JCR_PK_" + tablePrefix
- + "VALUE PRIMARY KEY(ID)");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF ADD CONSTRAINT JCR_PK_" + tablePrefix
- + "REF PRIMARY KEY(NODE_ID, PROPERTY_ID, ORDER_NUM)");
+ scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT JCR_PK_" + itemTableSuffix + " PRIMARY KEY(ID)");
+ scripts.add("ALTER TABLE " + valueTableName + " ADD CONSTRAINT JCR_FK_" + valueTableSuffix
+ + "_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES " + itemTableName + "(ID)");
+ scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT JCR_FK_" + itemTableSuffix
+ + "_PARENT FOREIGN KEY(PARENT_ID) REFERENCES " + itemTableName + "(ID)");
+ scripts.add("ALTER TABLE " + valueTableName + " ADD CONSTRAINT JCR_PK_" + valueTableSuffix + " PRIMARY KEY(ID)");
+ scripts.add("ALTER TABLE " + refTableName + " ADD CONSTRAINT JCR_PK_" + refTableSuffix
+ + " PRIMARY KEY(NODE_ID, PROPERTY_ID, ORDER_NUM)");
// renaming indexes
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_ID_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_ID");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_N_ORDER_NUM_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_N_ORDER_NUM");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "VALUE_PROPERTY_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "VALUE_PROPERTY");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "REF_PROPERTY_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "REF_PROPERTY");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_OLD RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_ID_OLD RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_ID");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_N_ORDER_NUM_OLD RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_N_ORDER_NUM");
+ scripts.add("ALTER INDEX JCR_IDX_" + valueTableSuffix + "_PROPERTY_OLD RENAME TO JCR_IDX_" + valueTableSuffix
+ + "_PROPERTY");
+ scripts.add("ALTER INDEX JCR_IDX_" + refTableSuffix + "_PROPERTY_OLD RENAME TO JCR_IDX_" + refTableSuffix
+ + "_PROPERTY");
return scripts;
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/MySQLCleaningScipts.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/MySQLCleaningScipts.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/MySQLCleaningScipts.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -74,8 +74,8 @@
cleaningScripts.addAll(getIndexesDroppingScripts());
String constraintName =
- "JCR_FK_" + tablePrefix + "VALUE_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES JCR_" + tablePrefix + "ITEM(ID)";
- committingScripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE ADD CONSTRAINT " + constraintName);
+ "JCR_FK_" + valueTableSuffix + "_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES " + itemTableName + "(ID)";
+ committingScripts.add("ALTER TABLE " + valueTableName + " ADD CONSTRAINT " + constraintName);
}
/**
@@ -103,15 +103,14 @@
*/
private Collection<String> filter(Collection<String> scripts)
{
- String JCR_ITEM_PRIMARY_KEY = "CONSTRAINT JCR_PK_" + tablePrefix + "ITEM PRIMARY KEY(ID)";
+ String JCR_ITEM_PRIMARY_KEY = "CONSTRAINT JCR_PK_" + itemTableSuffix + " PRIMARY KEY(ID)";
String JCR_ITEM_FOREIGN_KEY =
- "CONSTRAINT JCR_FK_" + tablePrefix + "ITEM_PARENT FOREIGN KEY(PARENT_ID) REFERENCES JCR_" + tablePrefix
- + "ITEM(ID)";
+ "CONSTRAINT JCR_FK_" + itemTableSuffix + "_PARENT FOREIGN KEY(PARENT_ID) REFERENCES " + itemTableName + "(ID)";
- String JCR_VALUE_PRIMARY_KEY = "CONSTRAINT JCR_PK_" + tablePrefix + "VALUE PRIMARY KEY(ID)";
+ String JCR_VALUE_PRIMARY_KEY = "CONSTRAINT JCR_PK_" + valueTableSuffix + " PRIMARY KEY(ID)";
String JCR_VALUE_FOREIGN_KEY =
- "CONSTRAINT JCR_FK_" + tablePrefix + "VALUE_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES JCR_" + tablePrefix
- + "ITEM(ID)";
+ "CONSTRAINT JCR_FK_" + valueTableSuffix + "_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES " + itemTableName
+ + "(ID)";
Collection<String> filteredScripts = new ArrayList<String>();
@@ -141,9 +140,9 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE RENAME TO JCR_" + tablePrefix + "VALUE_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM RENAME TO JCR_" + tablePrefix + "ITEM_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF RENAME TO JCR_" + tablePrefix + "REF_OLD");
+ scripts.add("ALTER TABLE " + valueTableName + " RENAME TO " + valueTableName + "_OLD");
+ scripts.add("ALTER TABLE " + itemTableName + " RENAME TO " + itemTableName + "_OLD");
+ scripts.add("ALTER TABLE " + refTableName + " RENAME TO " + refTableName + "_OLD");
return scripts;
}
@@ -155,9 +154,9 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM_OLD RENAME TO JCR_" + tablePrefix + "ITEM");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE_OLD RENAME TO JCR_" + tablePrefix + "VALUE");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF_OLD RENAME TO JCR_" + tablePrefix + "REF");
+ scripts.add("ALTER TABLE " + itemTableName + "_OLD RENAME TO " + itemTableName);
+ scripts.add("ALTER TABLE " + valueTableName + "_OLD RENAME TO " + valueTableName);
+ scripts.add("ALTER TABLE " + refTableName + "_OLD RENAME TO " + refTableName);
return scripts;
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/OracleCleaningScipts.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/OracleCleaningScipts.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/OracleCleaningScipts.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -24,6 +24,7 @@
import org.exoplatform.services.jcr.impl.clean.rdbms.DBCleanException;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -61,7 +62,7 @@
prepareSimpleCleaningApproachScripts();
}
}
-
+
/**
* R{@inheritDoc}
*/
@@ -69,18 +70,18 @@
{
Collection<String> scripts = new ArrayList<String>();
- String constraintName = "JCR_PK_" + tablePrefix + "VALUE PRIMARY KEY(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE ADD CONSTRAINT " + constraintName);
+ String constraintName = "JCR_PK_" + valueTableSuffix + " PRIMARY KEY(ID)";
+ scripts.add("ALTER TABLE " + valueTableName + " ADD CONSTRAINT " + constraintName);
- constraintName = "JCR_PK_" + tablePrefix + "ITEM PRIMARY KEY(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM ADD CONSTRAINT " + constraintName);
+ constraintName = "JCR_PK_" + itemTableSuffix + " PRIMARY KEY(ID)";
+ scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT " + constraintName);
constraintName =
- "JCR_FK_" + tablePrefix + "VALUE_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES JCR_" + tablePrefix + "ITEM(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE ADD CONSTRAINT " + constraintName);
+ "JCR_FK_" + valueTableSuffix + "_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES " + itemTableName + "(ID)";
+ scripts.add("ALTER TABLE " + valueTableName + " ADD CONSTRAINT " + constraintName);
- constraintName = "JCR_PK_" + tablePrefix + "REF PRIMARY KEY(NODE_ID, PROPERTY_ID, ORDER_NUM)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF ADD CONSTRAINT " + constraintName);
+ constraintName = "JCR_PK_" + refTableSuffix + " PRIMARY KEY(NODE_ID, PROPERTY_ID, ORDER_NUM)";
+ scripts.add("ALTER TABLE " + refTableName + " ADD CONSTRAINT " + constraintName);
return scripts;
}
@@ -92,17 +93,17 @@
{
Collection<String> scripts = new ArrayList<String>();
- String constraintName = "JCR_PK_" + tablePrefix + "VALUE";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE DROP CONSTRAINT " + constraintName);
+ String constraintName = "JCR_PK_" + valueTableSuffix;
+ scripts.add("ALTER TABLE " + valueTableName + " DROP CONSTRAINT " + constraintName);
- constraintName = "JCR_FK_" + tablePrefix + "VALUE_PROPERTY";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE DROP CONSTRAINT " + constraintName);
+ constraintName = "JCR_FK_" + valueTableSuffix + "_PROPERTY";
+ scripts.add("ALTER TABLE " + valueTableName + " DROP CONSTRAINT " + constraintName);
- constraintName = "JCR_PK_" + tablePrefix + "ITEM";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM DROP CONSTRAINT " + constraintName);
+ constraintName = "JCR_PK_" + itemTableSuffix;
+ scripts.add("ALTER TABLE " + itemTableName + " DROP CONSTRAINT " + constraintName);
- constraintName = "JCR_PK_" + tablePrefix + "REF";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF DROP CONSTRAINT " + constraintName);
+ constraintName = "JCR_PK_" + refTableSuffix;
+ scripts.add("ALTER TABLE " + refTableName + " DROP CONSTRAINT " + constraintName);
return scripts;
}
@@ -114,12 +115,12 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("DROP INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_FK");
- scripts.add("DROP INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT");
- scripts.add("DROP INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_ID");
- scripts.add("DROP INDEX JCR_IDX_" + tablePrefix + "ITEM_N_ORDER_NUM");
- scripts.add("DROP INDEX JCR_IDX_" + tablePrefix + "VALUE_PROPERTY");
- scripts.add("DROP INDEX JCR_IDX_" + tablePrefix + "REF_PROPERTY");
+ scripts.add("DROP INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_FK");
+ scripts.add("DROP INDEX JCR_IDX_" + itemTableSuffix + "_PARENT");
+ scripts.add("DROP INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_ID");
+ scripts.add("DROP INDEX JCR_IDX_" + itemTableSuffix + "_N_ORDER_NUM");
+ scripts.add("DROP INDEX JCR_IDX_" + valueTableSuffix + "_PROPERTY");
+ scripts.add("DROP INDEX JCR_IDX_" + refTableSuffix + "_PROPERTY");
return scripts;
}
@@ -133,23 +134,27 @@
try
{
- scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" + tablePrefix + "ITEM_PARENT_FK ON JCR_"
- + tablePrefix + "ITEM", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" + tablePrefix + "ITEM_PARENT ON JCR_" + tablePrefix
- + "ITEM", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" + tablePrefix + "ITEM_PARENT_ID ON JCR_"
- + tablePrefix + "ITEM", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" + tablePrefix + "ITEM_N_ORDER_NUM ON JCR_"
- + tablePrefix + "ITEM", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" + tablePrefix + "VALUE_PROPERTY ON JCR_"
- + tablePrefix + "VALUE", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" + tablePrefix + "REF_PROPERTY ON JCR_"
- + tablePrefix + "REF", multiDb, dialect));
+ scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" + itemTableSuffix + "_PARENT_FK ON "
+ + itemTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" + itemTableSuffix + "_PARENT ON " + itemTableName,
+ multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" + itemTableSuffix + "_PARENT_ID ON "
+ + itemTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" + itemTableSuffix + "_N_ORDER_NUM ON "
+ + itemTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" + valueTableSuffix + "_PROPERTY ON "
+ + valueTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" + refTableSuffix + "_PROPERTY ON " + refTableName,
+ multiDb, dialect, wsEntry));
}
catch (RepositoryConfigurationException e)
{
throw new DBCleanException(e);
}
+ catch (IOException e)
+ {
+ throw new DBCleanException(e);
+ }
return scripts;
}
@@ -161,8 +166,8 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("DROP TRIGGER BI_JCR_" + tablePrefix + "VALUE");
- scripts.add("DROP SEQUENCE JCR_" + tablePrefix + "VALUE_SEQ");
+ scripts.add("DROP TRIGGER BI_" + valueTableName + "");
+ scripts.add("DROP SEQUENCE " + valueTableName + "_SEQ");
scripts.addAll(super.getTablesDroppingScripts());
@@ -176,8 +181,8 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("DROP TRIGGER BI_JCR_" + tablePrefix + "VALUE_OLD");
- scripts.add("DROP SEQUENCE JCR_" + tablePrefix + "VALUE_SEQ_OLD");
+ scripts.add("DROP TRIGGER BI_" + valueTableName + "_OLD");
+ scripts.add("DROP SEQUENCE " + valueTableName + "_SEQ_OLD");
scripts.addAll(super.getOldTablesDroppingScripts());
@@ -192,45 +197,45 @@
Collection<String> scripts = new ArrayList<String>();
// JCR_VALUE
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE RENAME TO JCR_" + tablePrefix + "VALUE_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE_OLD" + " RENAME CONSTRAINT JCR_PK_" + tablePrefix
- + "VALUE TO JCR_PK_" + tablePrefix + "VALUE_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE_OLD" + " RENAME CONSTRAINT JCR_FK_" + tablePrefix
- + "VALUE_PROPERTY TO JCR_FK_" + tablePrefix + "VALUE_PROPERTY_OLD");
+ scripts.add("ALTER TABLE " + valueTableName + " RENAME TO " + valueTableName + "_OLD");
+ scripts.add("ALTER TABLE " + valueTableName + "_OLD" + " RENAME CONSTRAINT JCR_PK_" + valueTableSuffix
+ + " TO JCR_PK_" + valueTableSuffix + "_OLD");
+ scripts.add("ALTER TABLE " + valueTableName + "_OLD" + " RENAME CONSTRAINT JCR_FK_" + valueTableSuffix
+ + "_PROPERTY TO JCR_FK_" + valueTableSuffix + "_PROPERTY_OLD");
- scripts.add("ALTER INDEX JCR_PK_" + tablePrefix + "VALUE RENAME TO JCR_PK_" + tablePrefix + "VALUE_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "VALUE_PROPERTY RENAME TO JCR_IDX_" + tablePrefix
- + "VALUE_PROPERTY_OLD");
+ scripts.add("ALTER INDEX JCR_PK_" + valueTableSuffix + " RENAME TO JCR_PK_" + valueTableSuffix + "_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + valueTableSuffix + "_PROPERTY RENAME TO JCR_IDX_" + valueTableSuffix
+ + "_PROPERTY_OLD");
// TRIGGER and SEQ
- scripts.add("RENAME JCR_" + tablePrefix + "VALUE_SEQ TO JCR_" + tablePrefix + "VALUE_SEQ_OLD");
- scripts.add("ALTER TRIGGER BI_JCR_" + tablePrefix + "VALUE RENAME TO BI_JCR_" + tablePrefix + "VALUE_OLD");
+ scripts.add("RENAME " + valueTableName + "_SEQ TO " + valueTableName + "_SEQ_OLD");
+ scripts.add("ALTER TRIGGER BI_" + valueTableName + " RENAME TO BI_" + valueTableName + "_OLD");
// JCR_ITEM
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM RENAME TO JCR_" + tablePrefix + "ITEM_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM_OLD RENAME CONSTRAINT JCR_PK_" + tablePrefix
- + "ITEM TO JCR_PK_" + tablePrefix + "ITEM_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM_OLD RENAME CONSTRAINT JCR_FK_" + tablePrefix
- + "ITEM_PARENT TO JCR_FK_" + tablePrefix + "ITEM_PARENT_OLD");
+ scripts.add("ALTER TABLE " + itemTableName + " RENAME TO " + itemTableName + "_OLD");
+ scripts.add("ALTER TABLE " + itemTableName + "_OLD RENAME CONSTRAINT JCR_PK_" + itemTableSuffix + " TO JCR_PK_"
+ + itemTableSuffix + "_OLD");
+ scripts.add("ALTER TABLE " + itemTableName + "_OLD RENAME CONSTRAINT JCR_FK_" + itemTableSuffix
+ + "_PARENT TO JCR_FK_" + itemTableSuffix + "_PARENT_OLD");
- scripts.add("ALTER INDEX JCR_PK_" + tablePrefix + "ITEM RENAME TO JCR_PK_" + tablePrefix + "ITEM_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_FK RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_FK_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_ID RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_ID_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_N_ORDER_NUM RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_N_ORDER_NUM_OLD");
+ scripts.add("ALTER INDEX JCR_PK_" + itemTableSuffix + " RENAME TO JCR_PK_" + itemTableSuffix + "_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_FK RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_FK_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_ID RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_ID_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_N_ORDER_NUM RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_N_ORDER_NUM_OLD");
// JCR_REF
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF RENAME TO JCR_" + tablePrefix + "REF_OLD");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF_OLD RENAME CONSTRAINT JCR_PK_" + tablePrefix
- + "REF TO JCR_PK_" + tablePrefix + "REF_OLD");
+ scripts.add("ALTER TABLE " + refTableName + " RENAME TO " + refTableName + "_OLD");
+ scripts.add("ALTER TABLE " + refTableName + "_OLD RENAME CONSTRAINT JCR_PK_" + refTableSuffix + " TO JCR_PK_"
+ + refTableSuffix + "_OLD");
- scripts.add("ALTER INDEX JCR_PK_" + tablePrefix + "REF RENAME TO JCR_PK_" + tablePrefix + "REF_OLD");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "REF_PROPERTY RENAME TO JCR_IDX_" + tablePrefix
- + "REF_PROPERTY_OLD");
+ scripts.add("ALTER INDEX JCR_PK_" + refTableSuffix + " RENAME TO JCR_PK_" + refTableSuffix + "_OLD");
+ scripts.add("ALTER INDEX JCR_IDX_" + refTableSuffix + "_PROPERTY RENAME TO JCR_IDX_" + refTableSuffix
+ + "_PROPERTY_OLD");
return scripts;
}
@@ -243,42 +248,42 @@
Collection<String> scripts = new ArrayList<String>();
// VALUE
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE_OLD RENAME TO JCR_" + tablePrefix + "VALUE");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE RENAME CONSTRAINT JCR_PK_" + tablePrefix
- + "VALUE_OLD TO JCR_PK_" + tablePrefix + "VALUE");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE RENAME CONSTRAINT JCR_FK_" + tablePrefix
- + "VALUE_PROPERTY_OLD TO JCR_FK_" + tablePrefix + "VALUE_PROPERTY");
- scripts.add("ALTER INDEX JCR_PK_" + tablePrefix + "VALUE_OLD RENAME TO JCR_PK_" + tablePrefix + "VALUE");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "VALUE_PROPERTY_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "VALUE_PROPERTY");
+ scripts.add("ALTER TABLE " + valueTableName + "_OLD RENAME TO " + valueTableName + "");
+ scripts.add("ALTER TABLE " + valueTableName + " RENAME CONSTRAINT JCR_PK_" + valueTableSuffix + "_OLD TO JCR_PK_"
+ + valueTableSuffix);
+ scripts.add("ALTER TABLE " + valueTableName + " RENAME CONSTRAINT JCR_FK_" + valueTableSuffix
+ + "_PROPERTY_OLD TO JCR_FK_" + valueTableSuffix + "_PROPERTY");
+ scripts.add("ALTER INDEX JCR_PK_" + valueTableSuffix + "_OLD RENAME TO JCR_PK_" + valueTableSuffix);
+ scripts.add("ALTER INDEX JCR_IDX_" + valueTableSuffix + "_PROPERTY_OLD RENAME TO JCR_IDX_" + valueTableSuffix
+ + "_PROPERTY");
// TRIGGER and SEQ
- scripts.add("RENAME JCR_" + tablePrefix + "VALUE_SEQ_OLD TO JCR_" + tablePrefix + "VALUE_SEQ");
- scripts.add("ALTER TRIGGER BI_JCR_" + tablePrefix + "VALUE_OLD RENAME TO BI_JCR_" + tablePrefix + "VALUE");
+ scripts.add("RENAME " + valueTableName + "_SEQ_OLD TO " + valueTableName + "_SEQ");
+ scripts.add("ALTER TRIGGER BI_" + valueTableName + "_OLD RENAME TO BI_" + valueTableName + "");
// ITEM
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM_OLD RENAME TO JCR_" + tablePrefix + "ITEM");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM RENAME CONSTRAINT JCR_PK_" + tablePrefix
- + "ITEM_OLD TO JCR_PK_" + tablePrefix + "ITEM");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM RENAME CONSTRAINT JCR_FK_" + tablePrefix
- + "ITEM_PARENT_OLD TO JCR_FK_" + tablePrefix + "ITEM_PARENT");
- scripts.add("ALTER INDEX JCR_PK_" + tablePrefix + "ITEM_OLD RENAME TO JCR_PK_" + tablePrefix + "ITEM");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_FK_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_FK");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_ID_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_PARENT_ID");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "ITEM_N_ORDER_NUM_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "ITEM_N_ORDER_NUM");
+ scripts.add("ALTER TABLE " + itemTableName + "_OLD RENAME TO " + itemTableName + "");
+ scripts.add("ALTER TABLE " + itemTableName + " RENAME CONSTRAINT JCR_PK_" + itemTableSuffix + "_OLD TO JCR_PK_"
+ + itemTableSuffix);
+ scripts.add("ALTER TABLE " + itemTableName + " RENAME CONSTRAINT JCR_FK_" + itemTableSuffix
+ + "_PARENT_OLD TO JCR_FK_" + itemTableSuffix + "_PARENT");
+ scripts.add("ALTER INDEX JCR_PK_" + itemTableSuffix + "_OLD RENAME TO JCR_PK_" + itemTableSuffix);
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_FK_OLD RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_FK");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_OLD RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_ID_OLD RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_PARENT_ID");
+ scripts.add("ALTER INDEX JCR_IDX_" + itemTableSuffix + "_N_ORDER_NUM_OLD RENAME TO JCR_IDX_" + itemTableSuffix
+ + "_N_ORDER_NUM");
// REF
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF_OLD RENAME TO JCR_" + tablePrefix + "REF");
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "REF RENAME CONSTRAINT JCR_PK_" + tablePrefix
- + "REF_OLD TO JCR_PK_" + tablePrefix + "REF");
- scripts.add("ALTER INDEX JCR_PK_" + tablePrefix + "REF_OLD RENAME TO JCR_PK_" + tablePrefix + "REF");
- scripts.add("ALTER INDEX JCR_IDX_" + tablePrefix + "REF_PROPERTY_OLD RENAME TO JCR_IDX_" + tablePrefix
- + "REF_PROPERTY");
+ scripts.add("ALTER TABLE " + refTableName + "_OLD RENAME TO " + refTableName + "");
+ scripts.add("ALTER TABLE " + refTableName + " RENAME CONSTRAINT JCR_PK_" + refTableSuffix + "_OLD TO JCR_PK_"
+ + refTableSuffix);
+ scripts.add("ALTER INDEX JCR_PK_" + refTableSuffix + "_OLD RENAME TO JCR_PK_" + refTableSuffix);
+ scripts.add("ALTER INDEX JCR_IDX_" + refTableSuffix + "_PROPERTY_OLD RENAME TO JCR_IDX_" + refTableSuffix
+ + "_PROPERTY");
return scripts;
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/SybaseCleaningScipts.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/SybaseCleaningScipts.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/SybaseCleaningScipts.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -24,6 +24,7 @@
import org.exoplatform.services.jcr.impl.clean.rdbms.DBCleanException;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -69,15 +70,15 @@
{
Collection<String> scripts = new ArrayList<String>();
- String constraintName = "JCR_PK_" + tablePrefix + "ITEM PRIMARY KEY(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM ADD CONSTRAINT " + constraintName);
+ String constraintName = "JCR_PK_" + itemTableSuffix + " PRIMARY KEY(ID)";
+ scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT " + constraintName);
- constraintName = "JCR_PK_" + tablePrefix + "VALUE PRIMARY KEY(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE ADD CONSTRAINT " + constraintName);
+ constraintName = "JCR_PK_" + valueTableSuffix + " PRIMARY KEY(ID)";
+ scripts.add("ALTER TABLE " + valueTableName + " ADD CONSTRAINT " + constraintName);
constraintName =
- "JCR_FK_" + tablePrefix + "VALUE_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES JCR_" + tablePrefix + "ITEM(ID)";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE ADD CONSTRAINT " + constraintName);
+ "JCR_FK_" + valueTableSuffix + "_PROPERTY FOREIGN KEY(PROPERTY_ID) REFERENCES " + itemTableName + "(ID)";
+ scripts.add("ALTER TABLE " + valueTableName + " ADD CONSTRAINT " + constraintName);
return scripts;
}
@@ -89,14 +90,14 @@
{
Collection<String> scripts = new ArrayList<String>();
- String constraintName = "JCR_FK_" + tablePrefix + "VALUE_PROPERTY";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE DROP CONSTRAINT " + constraintName);
+ String constraintName = "JCR_FK_" + valueTableSuffix + "_PROPERTY";
+ scripts.add("ALTER TABLE " + valueTableName + " DROP CONSTRAINT " + constraintName);
- constraintName = "JCR_PK_" + tablePrefix + "ITEM";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "ITEM DROP CONSTRAINT " + constraintName);
+ constraintName = "JCR_PK_" + itemTableSuffix;
+ scripts.add("ALTER TABLE " + itemTableName + " DROP CONSTRAINT " + constraintName);
- constraintName = "JCR_PK_" + tablePrefix + "VALUE";
- scripts.add("ALTER TABLE JCR_" + tablePrefix + "VALUE DROP CONSTRAINT " + constraintName);
+ constraintName = "JCR_PK_" + valueTableSuffix;
+ scripts.add("ALTER TABLE " + valueTableName + " DROP CONSTRAINT " + constraintName);
return scripts;
}
@@ -108,11 +109,11 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("DROP INDEX JCR_" + tablePrefix + "ITEM.JCR_IDX_" + tablePrefix + "ITEM_PARENT");
- scripts.add("DROP INDEX JCR_" + tablePrefix + "ITEM.JCR_IDX_" + tablePrefix + "ITEM_PARENT_ID");
- scripts.add("DROP INDEX JCR_" + tablePrefix + "ITEM.JCR_IDX_" + tablePrefix + "ITEM_N_ORDER_NUM");
- scripts.add("DROP INDEX JCR_" + tablePrefix + "VALUE.JCR_IDX_" + tablePrefix + "VALUE_PROPERTY");
- scripts.add("DROP INDEX JCR_" + tablePrefix + "REF.JCR_IDX_" + tablePrefix + "REF_PROPERTY");
+ scripts.add("DROP INDEX " + itemTableName + ".JCR_IDX_" + itemTableSuffix + "_PARENT");
+ scripts.add("DROP INDEX " + itemTableName + ".JCR_IDX_" + itemTableSuffix + "_PARENT_ID");
+ scripts.add("DROP INDEX " + itemTableName + ".JCR_IDX_" + itemTableSuffix + "_N_ORDER_NUM");
+ scripts.add("DROP INDEX " + valueTableName + ".JCR_IDX_" + valueTableSuffix + "_PROPERTY");
+ scripts.add("DROP INDEX " + refTableName + ".JCR_IDX_" + refTableSuffix + "_PROPERTY");
return scripts;
}
@@ -126,21 +127,25 @@
try
{
- scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT ON JCR_"
- + tablePrefix + "ITEM", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" + tablePrefix + "ITEM_PARENT_ID ON JCR_"
- + tablePrefix + "ITEM", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" + tablePrefix + "ITEM_N_ORDER_NUM ON JCR_"
- + tablePrefix + "ITEM", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" + tablePrefix + "VALUE_PROPERTY ON JCR_"
- + tablePrefix + "VALUE", multiDb, dialect));
- scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" + tablePrefix + "REF_PROPERTY ON JCR_"
- + tablePrefix + "REF", multiDb, dialect));
+ scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" + itemTableSuffix + "_PARENT ON "
+ + itemTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" + itemTableSuffix + "_PARENT_ID ON "
+ + itemTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" + itemTableSuffix + "_N_ORDER_NUM ON "
+ + itemTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("INDEX JCR_IDX_" + valueTableSuffix + "_PROPERTY ON "
+ + valueTableName, multiDb, dialect, wsEntry));
+ scripts.add(DBInitializerHelper.getObjectScript("JCR_IDX_" + refTableSuffix + "_PROPERTY ON " + refTableName,
+ multiDb, dialect, wsEntry));
}
catch (RepositoryConfigurationException e)
{
throw new DBCleanException(e);
}
+ catch (IOException e)
+ {
+ throw new DBCleanException(e);
+ }
return scripts;
}
@@ -152,12 +157,12 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("sp_rename JCR_" + tablePrefix + "VALUE, JCR_" + tablePrefix + "VALUE_OLD");
- scripts.add("sp_rename JCR_" + tablePrefix + "ITEM, JCR_" + tablePrefix + "ITEM_OLD");
- scripts.add("sp_rename JCR_" + tablePrefix + "REF, JCR_" + tablePrefix + "REF_OLD");
+ scripts.add("sp_rename " + valueTableName + ", " + valueTableName + "_OLD");
+ scripts.add("sp_rename " + itemTableName + ", " + itemTableName + "_OLD");
+ scripts.add("sp_rename " + refTableName + ", " + refTableName + "_OLD");
- scripts.add("sp_rename JCR_FK_" + tablePrefix + "VALUE_PROPERTY, JCR_FK_" + tablePrefix + "VALUE_PROPERTY_OLD");
- scripts.add("sp_rename JCR_FK_" + tablePrefix + "ITEM_PARENT, JCR_FK_" + tablePrefix + "ITEM_PARENT_OLD");
+ scripts.add("sp_rename JCR_FK_" + valueTableSuffix + "_PROPERTY, JCR_FK_" + valueTableSuffix + "_PROPERTY_OLD");
+ scripts.add("sp_rename JCR_FK_" + itemTableSuffix + "_PARENT, JCR_FK_" + itemTableSuffix + "_PARENT_OLD");
return scripts;
}
@@ -169,12 +174,12 @@
{
Collection<String> scripts = new ArrayList<String>();
- scripts.add("sp_rename JCR_" + tablePrefix + "VALUE_OLD, JCR_" + tablePrefix + "VALUE");
- scripts.add("sp_rename JCR_" + tablePrefix + "ITEM_OLD, JCR_" + tablePrefix + "ITEM");
- scripts.add("sp_rename JCR_" + tablePrefix + "REF_OLD, JCR_" + tablePrefix + "REF");
+ scripts.add("sp_rename " + valueTableName + "_OLD, " + valueTableName);
+ scripts.add("sp_rename " + itemTableName + "_OLD, " + itemTableName);
+ scripts.add("sp_rename " + refTableName + "_OLD, " + refTableName);
- scripts.add("sp_rename JCR_FK_" + tablePrefix + "VALUE_PROPERTY_OLD, JCR_FK_" + tablePrefix + "VALUE_PROPERTY");
- scripts.add("sp_rename JCR_FK_" + tablePrefix + "ITEM_PARENT_OLD, JCR_FK_" + tablePrefix + "ITEM_PARENT");
+ scripts.add("sp_rename JCR_FK_" + valueTableSuffix + "_PROPERTY_OLD, JCR_FK_" + valueTableSuffix + "_PROPERTY");
+ scripts.add("sp_rename JCR_FK_" + itemTableSuffix + "_PARENT_OLD, JCR_FK_" + itemTableSuffix + "_PARENT");
return scripts;
}
Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JBCShareableLockTableHandler.java.orig
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JBCShareableLockTableHandler.java.orig 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JBCShareableLockTableHandler.java.orig 2012-03-14 13:28:03 UTC (rev 5863)
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2003-2010 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.impl.core.lock.jbosscache;
-
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.impl.checker.InspectionQuery;
-import org.exoplatform.services.jcr.impl.core.lock.LockTableHandler;
-
-import java.sql.SQLException;
-
-/**
- * Provides means for nodes' IDs extraction in case we use {@link CacheableLockManagerImpl}
- * as {@link LockManager} based on shareable JBoss Cache instance.
- * Equally applicable for single and multi db configurations.
- *
- * @author <a href="mailto:dkuleshov@exoplatform.com">Dmitry Kuleshov</a>
- * @version $Id: JBCShareableLockTableHandler.java 34360 2009-07-22 23:58:59Z dkuleshov $
- *
- */
-public class JBCShareableLockTableHandler extends JBCLockTableHandler implements LockTableHandler
-{
-
- /**
- * JBCShareableLockTableHandler constructor.
- */
- public JBCShareableLockTableHandler(WorkspaceEntry workspaceEntry)
- {
- super(workspaceEntry);
- }
-
- /**
- * {@inheritDoc}
- */
- protected InspectionQuery getSelectQuery() throws SQLException
- {
- return new InspectionQuery("SELECT * FROM " + getTableName() + " WHERE " + getParentColumn() + "='/"
- + workspaceEntry.getUniqueName() + "/" + CacheableLockManagerImpl.LOCKS + "'", new String[]{getIdColumn()},
- "Locks table match");
- }
-
- protected InspectionQuery getDeleteQuery(String nodeId) throws SQLException
- {
- return new InspectionQuery("DELETE FROM " + getTableName() + " WHERE " + getIdColumn() + "='/"
- + workspaceEntry.getUniqueName() + "/" + CacheableLockManagerImpl.LOCKS + "/" + nodeId + "'", new String[]{},
- "");
- }
-
-}
\ No newline at end of file
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCDataContainerConfig.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCDataContainerConfig.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCDataContainerConfig.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -38,14 +38,8 @@
*/
MULTI {
@Override
- public boolean isSingleDatabase()
+ public boolean isMultiDatabase()
{
- return false;
- }
-
- @Override
- public boolean isSimpleTable()
- {
return true;
}
},
@@ -55,14 +49,8 @@
*/
SINGLE {
@Override
- public boolean isSingleDatabase()
+ public boolean isMultiDatabase()
{
- return true;
- }
-
- @Override
- public boolean isSimpleTable()
- {
return false;
}
},
@@ -73,28 +61,16 @@
*/
ISOLATED {
@Override
- public boolean isSingleDatabase()
+ public boolean isMultiDatabase()
{
return true;
}
-
- @Override
- public boolean isSimpleTable()
- {
- return true;
- }
};
/**
- * @return true if database structure type requires same database for workspaces within one repository
+ * @return true if every workspace stores data in separate table within one repository
*/
- public abstract boolean isSingleDatabase(); // TODO rename?
-
- /**
- * @return true if database structure type doesn't have CONTAINER_NAME field in ITEM's table
- */
- public abstract boolean isSimpleTable(); // TODO rename?
-
+ public abstract boolean isMultiDatabase();
}
/**
@@ -113,31 +89,11 @@
public String dbDialect;
/**
- * Database driver
- */
- public String dbDriver;
-
- /**
- * Database password
- */
- public String dbPassword;
-
- /**
* Datasource name
*/
public String dbSourceName;
/**
- * Database URL
- */
- public String dbUrl;
-
- /**
- * Database username
- */
- public String dbUserName;
-
- /**
* Data structure type, replaces deprecated multiDb
*/
public JDBCDataContainerConfig.DatabaseStructureType dbStructureType;
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -48,20 +48,20 @@
import org.exoplatform.services.jcr.impl.dataflow.serialization.ObjectReaderImpl;
import org.exoplatform.services.jcr.impl.dataflow.serialization.ObjectWriterImpl;
import org.exoplatform.services.jcr.impl.storage.WorkspaceDataContainerBase;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.GenericConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.HSQLDBConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.MySQLConnectionFactory;
-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.indexing.JdbcNodeDataIndexingIterator;
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.init.StorageDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.statistics.StatisticsJDBCStorageConnection;
import org.exoplatform.services.jcr.impl.storage.value.fs.FileValueStorage;
import org.exoplatform.services.jcr.impl.util.io.DirectoryHelper;
import org.exoplatform.services.jcr.impl.util.io.FileCleanerHolder;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerException;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
@@ -80,7 +80,6 @@
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
-import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
@@ -121,8 +120,6 @@
}
}
- //configuration params
-
public final static String SOURCE_NAME = "source-name";
@Deprecated
@@ -143,14 +140,6 @@
*/
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";
-
public final static String DB_FORCE_QUERY_HINTS = "force.query.hints";
protected JDBCDataContainerConfig containerConfig;
@@ -222,11 +211,9 @@
this.containerConfig.uniqueName = wsConfig.getUniqueName();
this.containerConfig.dbStructureType = getDatabaseType(wsConfig);
- String defaultSuffix = repConfig.getName() + "_" + wsConfig.getName();
- this.containerConfig.dbTableSuffix =
- wsConfig.getContainer().getParameterValue(DB_TABLENAME_SUFFIX, defaultSuffix).toUpperCase();
+ this.containerConfig.dbTableSuffix = getDBTableSuffix(wsConfig);
- this.containerConfig.multiDb = !containerConfig.dbStructureType.isSingleDatabase();
+ this.containerConfig.multiDb = containerConfig.dbStructureType.isMultiDatabase();
this.containerConfig.valueStorageProvider = valueStorageProvider;
this.containerConfig.dsProvider = dsProvider;
@@ -241,151 +228,56 @@
pDbDialect = DBConstants.DB_DIALECT_GENERIC;
}
- String pDbDriver = null;
- String pDbUrl = null;
- String pDbUserName = null;
- String pDbPassword = null;
- try
- {
- pDbDriver = wsConfig.getContainer().getParameterValue(DB_DRIVER);
+ this.containerConfig.dbSourceName = wsConfig.getContainer().getParameterValue(SOURCE_NAME);
- // 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 (dsProvider == null)
{
- if (LOG.isTraceEnabled())
- {
- LOG.trace("An exception occurred: " + e.getMessage());
- }
+ throw new IllegalArgumentException(
+ "Since a data source has been defined, the DataSourceProvider cannot be null, add it in your configuration.");
}
+ // the data source cannot be managed if there is no transaction manager
+ this.containerConfig.isManaged = dsProvider.isManaged(containerConfig.dbSourceName);
- if (pDbUrl != null)
+ if (pDbDialect == DBConstants.DB_DIALECT_GENERIC)
{
- this.containerConfig.dbDriver = pDbDriver;
- this.containerConfig.dbUrl = pDbUrl;
- this.containerConfig.dbUserName = pDbUserName;
- this.containerConfig.dbPassword = pDbPassword;
- this.containerConfig.dbSourceName = null;
- // A managed data source is only possible when the source name is not null
- this.containerConfig.isManaged = false;
- LOG.info("Connect to JCR database as user '" + this.containerConfig.dbUserName + "'");
-
- if (DBConstants.DB_DIALECT_GENERIC.equalsIgnoreCase(pDbDialect)
- || DBConstants.DB_DIALECT_AUTO.equalsIgnoreCase(pDbDialect))
+ // try to detect via JDBC metadata
+ final DataSource ds = getDataSource();
+ Connection jdbcConn = null;
+ try
{
- // try to detect via JDBC metadata
- Connection jdbcConn = null;
- try
+ jdbcConn = SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Connection>()
{
- jdbcConn =
- containerConfig.dbUserName != null ? DriverManager.getConnection(containerConfig.dbUrl,
- containerConfig.dbUserName, containerConfig.dbPassword) : DriverManager
- .getConnection(containerConfig.dbUrl);
-
- this.containerConfig.dbDialect = DialectDetecter.detect(jdbcConn.getMetaData());
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- if (jdbcConn != null)
+ public Connection run() throws Exception
{
- try
- {
- jdbcConn.close();
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
+ return ds.getConnection();
}
- }
- }
- else
- {
- this.containerConfig.dbDialect = pDbDialect;
- }
- }
- else
- {
- this.containerConfig.dbDriver = null;
- this.containerConfig.dbUrl = null;
- this.containerConfig.dbUserName = null;
- this.containerConfig.dbPassword = null;
+ });
- String sn;
- try
- {
- sn = wsConfig.getContainer().getParameterValue(SOURCE_NAME);
+ this.containerConfig.dbDialect = DialectDetecter.detect(jdbcConn.getMetaData());
}
- catch (RepositoryConfigurationException e)
+ catch (SQLException e)
{
- // for backward comp remove in rel.2.0
- sn = wsConfig.getContainer().getParameterValue("sourceName");
+ throw new RepositoryException(e);
}
- this.containerConfig.dbSourceName = sn;
- if (dsProvider == null)
+ finally
{
- throw new IllegalArgumentException(
- "Since a data source has been defined, the DataSourceProvider cannot be null, add it in your configuration.");
- }
- // the data source cannot be managed if there is no transaction manager
- this.containerConfig.isManaged = dsProvider.isManaged(containerConfig.dbSourceName);
-
- if (pDbDialect == DBConstants.DB_DIALECT_GENERIC)
- {
- // try to detect via JDBC metadata
- final DataSource ds = getDataSource();
- Connection jdbcConn = null;
- try
+ if (jdbcConn != null)
{
- jdbcConn = SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Connection>()
+ try
{
- public Connection run() throws Exception
- {
- return ds.getConnection();
- }
- });
-
- this.containerConfig.dbDialect = DialectDetecter.detect(jdbcConn.getMetaData());
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- if (jdbcConn != null)
+ jdbcConn.close();
+ }
+ catch (SQLException e)
{
- try
- {
- jdbcConn.close();
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
+ throw new RepositoryException(e);
}
}
}
- else
- {
- this.containerConfig.dbDialect = pDbDialect;
- }
}
+ else
+ {
+ this.containerConfig.dbDialect = pDbDialect;
+ }
LOG.info("Using a dialect '" + this.containerConfig.dbDialect + "'");
// check is there DB_FORCE_QUERY_HINTS parameter - by default its enabled
@@ -429,7 +321,7 @@
this.containerConfig.swapCleaner = fileCleanerHolder.getFileCleaner();
this.containerConfig.initScriptPath =
- DBInitializerHelper.scriptPath(containerConfig.dbDialect, containerConfig.dbStructureType.isSimpleTable());
+ DBInitializerHelper.scriptPath(containerConfig.dbDialect, containerConfig.dbStructureType.isMultiDatabase());
initDatabase();
@@ -447,13 +339,7 @@
*/
protected GenericConnectionFactory defaultConnectionFactory() throws NamingException, RepositoryException
{
- // by default
- if (containerConfig.dbSourceName != null)
- {
- return new GenericConnectionFactory(getDataSource(), containerConfig);
- }
-
- return new GenericConnectionFactory(containerConfig);
+ return new GenericConnectionFactory(getDataSource(), containerConfig);
}
/**
@@ -461,7 +347,7 @@
*
* @param sqlPath
* - path to SQL script (database creation script)
- * @return StorageDBInitializer instance
+ * @return DBInitializer instance
* @throws NamingException
* on JNDI error
* @throws RepositoryException
@@ -469,9 +355,9 @@
* @throws IOException
* on I/O error
*/
- protected StorageDBInitializer defaultDBInitializer() throws NamingException, RepositoryException, IOException
+ protected DBInitializer defaultDBInitializer() throws NamingException, RepositoryException, IOException
{
- return new StorageDBInitializer(this.connFactory.getJdbcConnection(), containerConfig);
+ return new DBInitializer(this.connFactory.getJdbcConnection(), containerConfig);
}
/**
@@ -487,7 +373,8 @@
protected void checkIntegrity(WorkspaceEntry wsConfig, RepositoryEntry repConfig)
throws RepositoryConfigurationException
{
- JDBCDataContainerConfig.DatabaseStructureType dbType;
+ DatabaseStructureType dbType = getDatabaseType(wsConfig);
+
for (WorkspaceEntry wsEntry : repConfig.getWorkspaceEntries())
{
if (wsEntry.getName().equals(wsConfig.getName())
@@ -497,15 +384,13 @@
continue;
}
- if (!getDatabaseType(wsEntry).equals(getDatabaseType(wsConfig)))
+ if (!getDatabaseType(wsEntry).equals(dbType))
{
throw new RepositoryConfigurationException("All workspaces must be of same DB type. But "
- + wsEntry.getName() + "- multi-db=" + getDatabaseType(wsEntry) + " and " + wsConfig.getName()
- + "- multi-db=" + getDatabaseType(wsConfig));
+ + wsEntry.getName() + "=" + getDatabaseType(wsEntry) + " and " + wsConfig.getName()
+ + "=" + dbType);
}
- dbType = getDatabaseType(wsConfig);
-
// source name
String wsSourceName = null;
String newWsSourceName = null;
@@ -524,7 +409,7 @@
if (wsSourceName != null && newWsSourceName != null)
{
- if (dbType.isSingleDatabase())
+ if (!dbType.isMultiDatabase() || dbType == DatabaseStructureType.ISOLATED)
{
if (!wsSourceName.equals(newWsSourceName))
{
@@ -536,50 +421,14 @@
{
if (wsSourceName.equals(newWsSourceName))
{
- throw new RepositoryConfigurationException("SourceName " + wsSourceName + " alredy in use in "
+ throw new RepositoryConfigurationException("SourceName " + wsSourceName + " already in use in "
+ wsEntry.getName() + ". SourceName must be different in " + dbType
+ "-database structure type. Check configuration for " + 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 (LOG.isTraceEnabled())
- {
- LOG.trace("An exception occurred: " + e.getMessage());
- }
- }
-
- if (wsUri != null && newWsUri != null)
- {
- if (dbType.isSingleDatabase())
- {
- if (!wsUri.equals(newWsUri))
- {
- throw new RepositoryConfigurationException("db-url must be equals in " + dbType
- + "-database repository." + " Check " + wsEntry.getName() + " and " + wsConfig.getName());
- }
- }
- else
- {
- if (wsUri.equals(newWsUri))
- {
- throw new RepositoryConfigurationException("db-url " + wsUri + " alredy in use in "
- + wsEntry.getName() + ". db-url must be different in " + dbType
- + "-database structure type. Check configuration for " + wsConfig.getName());
- }
- }
- }
}
}
@@ -595,21 +444,12 @@
*/
protected void initDatabase() throws NamingException, RepositoryException, IOException
{
-
- StorageDBInitializer dbInitializer = null;
+ DBInitializer dbInitializer = null;
if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
{
LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is experimental!");
- // sample of connection factory customization
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = defaultConnectionFactory();
- }
- else
- {
- this.connFactory = new OracleConnectionFactory(containerConfig);
- }
- // a particular db initializer may be configured here too
+
+ this.connFactory = defaultConnectionFactory();
dbInitializer = new OracleDBInitializer(this.connFactory.getJdbcConnection(), containerConfig);
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLE)
@@ -634,15 +474,7 @@
+ " if you don't expect any support and performances in read accesses are more important than the consistency"
+ " in your use-case. This dialect is only dedicated to the community.");
}
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new MySQLConnectionFactory(getDataSource(), containerConfig);
- }
- else
- {
- this.connFactory = new MySQLConnectionFactory(containerConfig);
- }
-
+ this.connFactory = new MySQLConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_MSSQL)
@@ -678,14 +510,7 @@
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_HSQLDB)
{
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new HSQLDBConnectionFactory(getDataSource(), containerConfig);
- }
- else
- {
- this.connFactory = new HSQLDBConnectionFactory(containerConfig);
- }
+ this.connFactory = new HSQLDBConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else
@@ -910,15 +735,7 @@
{
JDBCWorkspaceDataContainer anotherJdbc = (JDBCWorkspaceDataContainer)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 getDbSourceName().equals(anotherJdbc.getDbSourceName());
}
return false;
@@ -935,36 +752,6 @@
}
/**
- * Used in <code>equals()</code>.
- *
- * @return JDBC driver
- */
- protected String getDbDriver()
- {
- return containerConfig.dbDriver;
- }
-
- /**
- * Used in <code>equals()</code>.
- *
- * @return Database URL
- */
- protected String getDbUrl()
- {
- return containerConfig.dbUrl;
- }
-
- /**
- * Used in <code>equals()</code>.
- *
- * @return Database username
- */
- protected String getDbUserName()
- {
- return containerConfig.dbUserName;
- }
-
- /**
* {@inheritDoc}
*/
public boolean isCheckSNSNewConnection()
@@ -1025,27 +812,33 @@
"JDBCWorkspaceDataContainer.info")));
backupInfo.writeString(containerConfig.containerName);
- backupInfo.writeBoolean(containerConfig.multiDb);
+ backupInfo.writeString(containerConfig.dbStructureType.toString());
Map<String, String> scripts = new HashMap<String, String>();
- if (containerConfig.multiDb)
+ String itemTable = DBInitializerHelper.getItemTableName(containerConfig);
+ String valueTable = DBInitializerHelper.getValueTableName(containerConfig);
+ String refTable = DBInitializerHelper.getRefTableName(containerConfig);
+
+ backupInfo.writeString(itemTable);
+ backupInfo.writeString(valueTable);
+ backupInfo.writeString(refTable);
+
+ if (containerConfig.dbStructureType.isMultiDatabase())
{
- scripts.put("JCR_MITEM", "select * from JCR_MITEM where JCR_MITEM.NAME <> '" + Constants.ROOT_PARENT_NAME
- + "'");
- scripts.put("JCR_MVALUE", "select * from JCR_MVALUE");
- scripts.put("JCR_MREF", "select * from JCR_MREF");
+ scripts
+ .put(itemTable, "select * from " + itemTable + " where NAME <> '" + Constants.ROOT_PARENT_NAME + "'");
+ scripts.put(valueTable, "select * from " + valueTable);
+ scripts.put(refTable, "select * from " + refTable);
}
else
{
- scripts.put("JCR_SITEM", "select * from JCR_SITEM where CONTAINER_NAME='" + containerConfig.containerName
- + "'");
- scripts.put("JCR_SVALUE",
- "select V.* from JCR_SVALUE V, JCR_SITEM I where I.ID=V.PROPERTY_ID and I.CONTAINER_NAME='"
- + containerConfig.containerName + "'");
- scripts.put("JCR_SREF",
- "select R.* from JCR_SREF R, JCR_SITEM I where I.ID=R.PROPERTY_ID and I.CONTAINER_NAME='"
- + containerConfig.containerName + "'");
+ scripts.put(itemTable, "select * from " + itemTable + " where CONTAINER_NAME='"
+ + containerConfig.containerName + "'");
+ scripts.put(valueTable, "select V.* from " + valueTable + " V, " + itemTable
+ + " I where I.ID=V.PROPERTY_ID and I.CONTAINER_NAME='" + containerConfig.containerName + "'");
+ scripts.put(refTable, "select R.* from " + refTable + " R, " + itemTable
+ + " I where I.ID=R.PROPERTY_ID and I.CONTAINER_NAME='" + containerConfig.containerName + "'");
}
// using existing DataSource to get a JDBC Connection.
@@ -1149,24 +942,24 @@
"JDBCWorkspaceDataContainer.info")));
String srcContainerName = backupInfo.readString();
- boolean srcMultiDb = backupInfo.readBoolean();
+ DatabaseStructureType dbType = DatabaseStructureType.valueOf(backupInfo.readString());
Map<String, RestoreTableRule> tables = new LinkedHashMap<String, RestoreTableRule>();
// ITEM table
- String dstTableName = "JCR_" + (containerConfig.multiDb ? "M" : "S") + "ITEM";
- String srcTableName = "JCR_" + (srcMultiDb ? "M" : "S") + "ITEM";
+ String dstTableName = DBInitializerHelper.getItemTableName(containerConfig);
+ String srcTableName = backupInfo.readString();
RestoreTableRule restoreTableRule = new RestoreTableRule();
restoreTableRule.setSrcContainerName(srcContainerName);
- restoreTableRule.setSrcMultiDb(srcMultiDb);
+ restoreTableRule.setSrcMultiDb(dbType.isMultiDatabase());
restoreTableRule.setDstContainerName(containerConfig.containerName);
- restoreTableRule.setDstMultiDb(containerConfig.multiDb);
+ restoreTableRule.setDstMultiDb(containerConfig.dbStructureType.isMultiDatabase());
restoreTableRule.setSrcTableName(srcTableName);
if (containerConfig.multiDb)
{
- if (!srcMultiDb)
+ if (!dbType.isMultiDatabase())
{
// CONTAINER_NAME column index
restoreTableRule.setDeleteColumnIndex(4);
@@ -1180,7 +973,7 @@
}
else
{
- if (srcMultiDb)
+ if (dbType.isMultiDatabase())
{
// CONTAINER_NAME column index
restoreTableRule.setNewColumnIndex(4);
@@ -1206,20 +999,20 @@
tables.put(dstTableName, restoreTableRule);
// VALUE table
- dstTableName = "JCR_" + (containerConfig.multiDb ? "M" : "S") + "VALUE";
- srcTableName = "JCR_" + (srcMultiDb ? "M" : "S") + "VALUE";
+ dstTableName = DBInitializerHelper.getValueTableName(containerConfig);
+ srcTableName = backupInfo.readString();
restoreTableRule = new RestoreTableRule();
restoreTableRule.setSrcContainerName(srcContainerName);
- restoreTableRule.setSrcMultiDb(srcMultiDb);
+ restoreTableRule.setSrcMultiDb(dbType.isMultiDatabase());
restoreTableRule.setDstContainerName(containerConfig.containerName);
- restoreTableRule.setDstMultiDb(containerConfig.multiDb);
+ restoreTableRule.setDstMultiDb(containerConfig.dbStructureType.isMultiDatabase());
restoreTableRule.setSrcTableName(srcTableName);
// auto increment ID column
restoreTableRule.setSkipColumnIndex(0);
- if (!containerConfig.multiDb || !srcMultiDb)
+ if (!containerConfig.dbStructureType.isMultiDatabase() || !dbType.isMultiDatabase())
{
// PROPERTY_ID column index
Set<Integer> convertColumnIndex = new HashSet<Integer>();
@@ -1229,17 +1022,17 @@
tables.put(dstTableName, restoreTableRule);
// REF tables
- dstTableName = "JCR_" + (containerConfig.multiDb ? "M" : "S") + "REF";
- srcTableName = "JCR_" + (srcMultiDb ? "M" : "S") + "REF";
+ dstTableName = DBInitializerHelper.getRefTableName(containerConfig);
+ srcTableName = backupInfo.readString();
restoreTableRule = new RestoreTableRule();
restoreTableRule.setSrcContainerName(srcContainerName);
- restoreTableRule.setSrcMultiDb(srcMultiDb);
+ restoreTableRule.setSrcMultiDb(dbType.isMultiDatabase());
restoreTableRule.setDstContainerName(containerConfig.containerName);
- restoreTableRule.setDstMultiDb(containerConfig.multiDb);
+ restoreTableRule.setDstMultiDb(containerConfig.dbStructureType.isMultiDatabase());
restoreTableRule.setSrcTableName(srcTableName);
- if (!containerConfig.multiDb || !srcMultiDb)
+ if (!containerConfig.dbStructureType.isMultiDatabase() || !dbType.isMultiDatabase())
{
// NODE_ID and PROPERTY_ID column indexes
Set<Integer> convertColumnIndex = new HashSet<Integer>();
@@ -1420,12 +1213,9 @@
}
/**
- * @param wsConfig
- * @return
- * @throws RepositoryConfigurationException
+ * Returns {@link DatabaseStructureType} based on workspace configuration.
*/
- public static JDBCDataContainerConfig.DatabaseStructureType getDatabaseType(WorkspaceEntry wsConfig)
- throws RepositoryConfigurationException
+ public static DatabaseStructureType getDatabaseType(WorkspaceEntry wsConfig) throws RepositoryConfigurationException
{
try
{
@@ -1445,4 +1235,13 @@
return JDBCDataContainerConfig.DatabaseStructureType.valueOf(dbStructureType);
}
}
+
+ /**
+ * Returns value of {@link #DB_TABLENAME_SUFFIX} parameter from workspace configuration.
+ */
+ public static String getDBTableSuffix(WorkspaceEntry wsConfig)
+ {
+ return wsConfig.getContainer()
+ .getParameterValue(JDBCWorkspaceDataContainer.DB_TABLENAME_SUFFIX, wsConfig.getName()).toUpperCase();
+ }
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -40,9 +40,9 @@
import org.exoplatform.services.jcr.impl.core.lock.LockTableHandler;
import org.exoplatform.services.jcr.impl.core.lock.LockTableHandlerFactory;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeDataManagerImpl;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
import org.exoplatform.services.jcr.impl.storage.value.ValueDataNotFoundException;
import org.exoplatform.services.jcr.impl.storage.value.ValueStorageNotFoundException;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.jcr.storage.value.ValueIOChannel;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -472,68 +472,64 @@
private void initInspectionQueries()
{
- String itemTableSuffix = getItemTableSuffix(jdbcDataContainer.containerConfig.dbStructureType);
- String valueTableSuffix = getValueTableSuffix(jdbcDataContainer.containerConfig.dbStructureType);
- String referenceTableSuffix = getReferenceTableSuffix(jdbcDataContainer.containerConfig.dbStructureType);
+ String itemTable = DBInitializerHelper.getItemTableName(jdbcDataContainer.containerConfig);
+ String valueTable = DBInitializerHelper.getValueTableName(jdbcDataContainer.containerConfig);
+ String refTable = DBInitializerHelper.getRefTableName(jdbcDataContainer.containerConfig);
boolean singleDatabase =
jdbcDataContainer.containerConfig.dbStructureType == JDBCDataContainerConfig.DatabaseStructureType.SINGLE;
vsInspectionQuery =
- new InspectionQuery(singleDatabase ? "select V.PROPERTY_ID, V.ORDER_NUM, V.STORAGE_DESC from JCR_"
- + valueTableSuffix + " V, JCR_" + itemTableSuffix + " I" + " where I.CONTAINER_NAME='"
- + jdbcDataContainer.containerConfig.containerName
+ new InspectionQuery(singleDatabase ? "select V.PROPERTY_ID, V.ORDER_NUM, V.STORAGE_DESC from " + valueTable
+ + " V, " + itemTable + " I" + " where I.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
+ "' and V.PROPERTY_ID = I.ID and STORAGE_DESC is not null"
- : "select PROPERTY_ID, ORDER_NUM, STORAGE_DESC from JCR_" + valueTableSuffix
- + " where STORAGE_DESC is not null", new String[]{
- DBConstants.COLUMN_VPROPERTY_ID, DBConstants.COLUMN_VORDERNUM, DBConstants.COLUMN_VSTORAGE_DESC},
- "Items with value data stored in value storage", new DummyRepair());
+ : "select PROPERTY_ID, ORDER_NUM, STORAGE_DESC from " + valueTable + " where STORAGE_DESC is not null",
+ new String[]{DBConstants.COLUMN_VPROPERTY_ID, DBConstants.COLUMN_VORDERNUM,
+ DBConstants.COLUMN_VSTORAGE_DESC}, "Items with value data stored in value storage", new DummyRepair());
lockInspectionQuery =
- new InspectionQuery(singleDatabase ? "select distinct PARENT_ID from JCR_" + itemTableSuffix
- + " WHERE CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName + "'"
+ new InspectionQuery(singleDatabase ? "select distinct PARENT_ID from " + itemTable + " WHERE CONTAINER_NAME='"
+ + jdbcDataContainer.containerConfig.containerName + "'"
+ " AND I_CLASS=2 and (NAME='[http://www.jcp.org/jcr/1.0]lockOwner'"
- + " OR NAME='[http://www.jcp.org/jcr/1.0]lockIsDeep')" : "select distinct PARENT_ID from JCR_"
- + itemTableSuffix + " where I_CLASS=2 AND"
+ + " OR NAME='[http://www.jcp.org/jcr/1.0]lockIsDeep')" : "select distinct PARENT_ID from " + itemTable
+ + " where I_CLASS=2 AND"
+ " (NAME='[http://www.jcp.org/jcr/1.0]lockOwner' OR NAME='[http://www.jcp.org/jcr/1.0]lockIsDeep')",
new String[]{DBConstants.COLUMN_PARENTID}, "Items which have jcr:lockOwner and jcr:lockIsDeep properties",
new DummyRepair());
// ITEM tables
- itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from JCR_" + itemTableSuffix
+ itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
+ " I where I.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
- + "' and NOT EXISTS(select * from JCR_" + itemTableSuffix + " P where P.ID = I.PARENT_ID)"
- : "select * from JCR_" + itemTableSuffix + " I where NOT EXISTS(select * from JCR_" + itemTableSuffix
- + " P where P.ID = I.PARENT_ID)", new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID,
- DBConstants.COLUMN_NAME, DBConstants.COLUMN_CLASS}, "Items that do not have parent nodes",
- new RootAsParentAssigner(jdbcDataContainer.getConnectionFactory())));
+ + "' and NOT EXISTS(select * from " + itemTable + " P where P.ID = I.PARENT_ID)" : "select * from "
+ + itemTable + " I where NOT EXISTS(select * from " + itemTable + " P where P.ID = I.PARENT_ID)", new String[]{
+ DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME, DBConstants.COLUMN_CLASS},
+ "Items that do not have parent nodes", new RootAsParentAssigner(jdbcDataContainer.getConnectionFactory())));
- itemsInspectionQuery.add(new InspectionQueryFilteredMultivaluedProperties(singleDatabase ? "select * from JCR_"
- + itemTableSuffix + " P where P.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
- + "' and P.I_CLASS=2" + " and P.P_MULTIVALUED=? and NOT EXISTS( select * from JCR_" + valueTableSuffix
- + " V where V.PROPERTY_ID=P.ID)" : "select * from JCR_" + itemTableSuffix
- + " P where P.I_CLASS=2 and P.P_MULTIVALUED=? and NOT EXISTS( select * from JCR_" + valueTableSuffix + " V "
+ itemsInspectionQuery.add(new InspectionQueryFilteredMultivaluedProperties(singleDatabase ? "select * from "
+ + itemTable + " P where P.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
+ + "' and P.I_CLASS=2" + " and P.P_MULTIVALUED=? and NOT EXISTS( select * from " + valueTable
+ + " V where V.PROPERTY_ID=P.ID)" : "select * from " + itemTable
+ + " P where P.I_CLASS=2 and P.P_MULTIVALUED=? and NOT EXISTS( select * from " + valueTable + " V "
+ "where V.PROPERTY_ID=P.ID)", new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID,
DBConstants.COLUMN_NAME},
"A node that has a single valued properties with nothing declared in the VALUE table.", new PropertyRemover(
jdbcDataContainer.getConnectionFactory(), nodeTypeManager)));
- itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from JCR_" + itemTableSuffix
+ itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
+ " N where N.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
- + "' and N.I_CLASS=1 and NOT EXISTS (select * from JCR_" + itemTableSuffix + " P "
+ + "' and N.I_CLASS=1 and NOT EXISTS (select * from " + itemTable + " P "
+ "where P.I_CLASS=2 and P.PARENT_ID=N.ID and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' "
- + "and P.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName + "')" : "select * from JCR_"
- + itemTableSuffix + " N where N.I_CLASS=1 and NOT EXISTS " + "(select * from JCR_" + itemTableSuffix
+ + "and P.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName + "')" : "select * from "
+ + itemTable + " N where N.I_CLASS=1 and NOT EXISTS " + "(select * from " + itemTable
+ " P where P.I_CLASS=2 and P.PARENT_ID=N.ID " + "and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType')",
new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
"A node that doesn't have primary type property", new NodeRemover(jdbcDataContainer.getConnectionFactory(),
nodeTypeManager)));
- itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from JCR_" + valueTableSuffix
- + " V where NOT EXISTS(select * from JCR_" + itemTableSuffix + " P "
- + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)" : "select * from JCR_" + valueTableSuffix
- + " V where NOT EXISTS(select * from JCR_" + itemTableSuffix + " P "
- + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)", new String[]{DBConstants.COLUMN_ID,
+ itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + valueTable
+ + " V where NOT EXISTS(select * from " + itemTable + " P " + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)"
+ : "select * from " + valueTable + " V where NOT EXISTS(select * from " + itemTable + " P "
+ + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)", new String[]{DBConstants.COLUMN_ID,
DBConstants.COLUMN_VPROPERTY_ID}, "All value records that has not related property record",
new ValueRecordsRemover(jdbcDataContainer.getConnectionFactory(),
jdbcDataContainer.containerConfig.containerName, jdbcDataContainer.containerConfig.multiDb)));
@@ -543,107 +539,59 @@
if (jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
{
statement =
- singleDatabase ? "select V.* from JCR_" + valueTableSuffix + " V, JCR_" + itemTableSuffix
+ singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
+ " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
+ jdbcDataContainer.containerConfig.containerName
- + "' AND ((STORAGE_DESC is not null and not DATA like null))" : "select * from JCR_" + valueTableSuffix
+ + "' AND ((STORAGE_DESC is not null and not DATA like null))" : "select * from " + valueTable
+ " where (STORAGE_DESC is not null and not DATA like null)";
}
else if (jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLE)
|| jdbcDataContainer.containerConfig.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLEOCI))
{
statement =
- singleDatabase ? "select V.* from JCR_" + valueTableSuffix + " V, JCR_" + itemTableSuffix
+ singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
+ " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
+ jdbcDataContainer.containerConfig.containerName
- + "' AND (STORAGE_DESC is not null and DATA is not null)" : "select * from JCR_" + valueTableSuffix
+ + "' AND (STORAGE_DESC is not null and DATA is not null)" : "select * from " + valueTable
+ " where (STORAGE_DESC is not null and DATA is not null)";
}
else
{
statement =
- singleDatabase ? "select V.* from JCR_" + valueTableSuffix + " V, JCR_" + itemTableSuffix
+ singleDatabase ? "select V.* from " + valueTable + " V, " + itemTable
+ " I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
+ jdbcDataContainer.containerConfig.containerName
- + "' AND ((STORAGE_DESC is not null and DATA is not null))" : "select * from JCR_" + valueTableSuffix
+ + "' AND ((STORAGE_DESC is not null and DATA is not null))" : "select * from " + valueTable
+ " where (STORAGE_DESC is not null and DATA is not null)";
}
itemsInspectionQuery.add(new InspectionQuery(statement, new String[]{DBConstants.COLUMN_ID},
"Incorrect VALUE records. Both fields STORAGE_DESC and DATA contain not null value.", new DummyRepair()));
- itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from JCR_" + itemTableSuffix
+ itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
+ " I where I.ID = I.PARENT_ID and I.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
- + "' and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'" : "select * from JCR_" + itemTableSuffix
+ + "' and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'" : "select * from " + itemTable
+ " I where I.ID = I.PARENT_ID and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'", new String[]{
DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "An item is its own parent.",
new RootAsParentAssigner(jdbcDataContainer.getConnectionFactory())));
- itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from JCR_" + itemTableSuffix
+ itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable
+ " I where I.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
- + "' and EXISTS (select * from JCR_" + itemTableSuffix + " J WHERE I.CONTAINER_NAME = J.CONTAINER_NAME and"
+ + "' and EXISTS (select * from " + itemTable + " J WHERE I.CONTAINER_NAME = J.CONTAINER_NAME and"
+ " I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
- + " and I.VERSION != J.VERSION)" : "select * from JCR_" + itemTableSuffix
- + " I where EXISTS (select * from JCR_" + itemTableSuffix + " J"
+ + " and I.VERSION != J.VERSION)" : "select * from " + itemTable + " I where EXISTS (select * from "
+ + itemTable + " J"
+ " WHERE I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
+ " and I.VERSION != J.VERSION)", new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID,
DBConstants.COLUMN_NAME, DBConstants.COLUMN_VERSION, DBConstants.COLUMN_CLASS, DBConstants.COLUMN_INDEX},
"Several versions of same item.", new EarlierVersionsRemover(jdbcDataContainer.getConnectionFactory())));
- itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from JCR_" + itemTableSuffix + " P, JCR_"
- + valueTableSuffix + " V where P.ID=V.PROPERTY_ID and P.CONTAINER_NAME='"
- + jdbcDataContainer.containerConfig.containerName + "' and P.P_TYPE=9 and NOT EXISTS (select * from JCR_"
- + referenceTableSuffix + " R where P.ID=R.PROPERTY_ID)" : "select * from JCR_" + itemTableSuffix + " P, JCR_"
- + valueTableSuffix + " V where P.ID=V.PROPERTY_ID and P.P_TYPE=9 and NOT EXISTS " + "(select * from JCR_"
- + referenceTableSuffix + " R where P.ID=R.PROPERTY_ID)", new String[]{DBConstants.COLUMN_ID,
- DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "Reference properties without reference records",
- new PropertyRemover(jdbcDataContainer.getConnectionFactory(), nodeTypeManager)));
+ itemsInspectionQuery.add(new InspectionQuery(singleDatabase ? "select * from " + itemTable + " P, " + valueTable
+ + " V where P.ID=V.PROPERTY_ID and P.CONTAINER_NAME='" + jdbcDataContainer.containerConfig.containerName
+ + "' and P.P_TYPE=9 and NOT EXISTS (select * from " + refTable + " R where P.ID=R.PROPERTY_ID)"
+ : "select * from " + itemTable + " P, " + valueTable
+ + " V where P.ID=V.PROPERTY_ID and P.P_TYPE=9 and NOT EXISTS " + "(select * from " + refTable
+ + " R where P.ID=R.PROPERTY_ID)", new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID,
+ DBConstants.COLUMN_NAME}, "Reference properties without reference records", new PropertyRemover(
+ jdbcDataContainer.getConnectionFactory(), nodeTypeManager)));
}
-
- private String getItemTableSuffix(DatabaseStructureType dbStructureType)
- {
- if (dbStructureType == DatabaseStructureType.MULTI)
- {
- return "MITEM";
- }
- else if (dbStructureType == DatabaseStructureType.SINGLE)
- {
- return "SITEM";
- }
- else
- {
- return "I" + jdbcDataContainer.containerConfig.dbTableSuffix;
- }
- }
-
- private String getValueTableSuffix(DatabaseStructureType dbStructureType)
- {
- if (dbStructureType == DatabaseStructureType.MULTI)
- {
- return "MVALUE";
- }
- else if (dbStructureType == DatabaseStructureType.SINGLE)
- {
- return "SVALUE";
- }
- else
- {
- return "V" + jdbcDataContainer.containerConfig.dbTableSuffix;
- }
- }
-
- private String getReferenceTableSuffix(DatabaseStructureType dbStructureType)
- {
- if (dbStructureType == DatabaseStructureType.MULTI)
- {
- return "MREF";
- }
- else if (dbStructureType == DatabaseStructureType.SINGLE)
- {
- return "SREF";
- }
- else
- {
- return "R" + jdbcDataContainer.containerConfig.dbTableSuffix;
- }
- }
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -18,14 +18,12 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.db;
-import org.exoplatform.commons.utils.ClassLoading;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import java.sql.Connection;
-import java.sql.DriverManager;
import java.sql.SQLException;
import javax.jcr.RepositoryException;
@@ -57,31 +55,6 @@
}
/**
- * GenericConnectionFactory constructor with dbDriver class validation
- */
- public GenericConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
- this(null, containerConfig);
-
- try
- {
- ClassLoading.forName(this.containerConfig.dbDriver, this).newInstance();
- }
- catch (InstantiationException e)
- {
- throw new RepositoryException(e);
- }
- catch (IllegalAccessException e)
- {
- throw new RepositoryException(e);
- }
- catch (ClassNotFoundException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
* {@inheritDoc}
*/
public WorkspaceStorageConnection openConnection() throws RepositoryException
@@ -97,7 +70,7 @@
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new MultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerConfig);
}
@@ -118,10 +91,8 @@
{
try
{
- Connection conn =
- dbDataSource != null ? dbDataSource.getConnection() : (this.containerConfig.dbUserName != null
- ? DriverManager.getConnection(this.containerConfig.dbUrl, this.containerConfig.dbUserName,
- this.containerConfig.dbPassword) : DriverManager.getConnection(this.containerConfig.dbUrl));
+ Connection conn = dbDataSource.getConnection();
+
if (readOnly)
{
// set this feature only if it asked
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -44,22 +44,13 @@
}
/**
- * HSQLDBConnectionFactory constructor.
- */
- public HSQLDBConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
-
- super(containerConfig);
- }
-
- /**
* {@inheritDoc}
*/
public WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException
{
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new HSQLDBMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerConfig);
}
Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java.orig
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java.orig 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java.orig 2012-03-14 13:28:03 UTC (rev 5863)
@@ -1,679 +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.db;
-
-import org.exoplatform.services.jcr.datamodel.NodeData;
-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.dataflow.ValueDataConvertor;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.List;
-
-/**
- * Single database connection implementation.
- *
- * Created by The eXo Platform SAS. </br>
- *
- * @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady
- * Azarenkov</a>
- * @version $Id: MultiDbJDBCConnection.java 20950 2008-10-06 14:23:07Z
- * pnedonosko $
- */
-
-public class MultiDbJDBCConnection extends JDBCStorageConnection
-{
-
- /**
- * Multidatabase JDBC Connection constructor.
- *
- * @param dbConnection JDBC connection, shoudl be opened before
- * @param readOnly, boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName Workspace Storage Container name (see configuration)
- * @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).
- * @throws SQLException
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
- */
- public MultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
- throws SQLException
- {
-
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getIdentifier(final String internalId)
- {
- return internalId;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getInternalId(final String identifier)
- {
- return identifier;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void prepareQueries() throws SQLException
- {
- JCR_PK_ITEM = "JCR_PK_MITEM";
- JCR_FK_ITEM_PARENT = "JCR_FK_MITEM_PARENT";
- JCR_IDX_ITEM_PARENT = "JCR_IDX_MITEM_PARENT";
- JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_MITEM_PARENT_ID";
- JCR_PK_VALUE = "JCR_PK_MVALUE";
- JCR_FK_VALUE_PROPERTY = "JCR_FK_MVALUE_PROPERTY";
- JCR_IDX_VALUE_PROPERTY = "JCR_IDX_MVALUE_PROPERTY";
- JCR_PK_REF = "JCR_PK_MREF";
- JCR_IDX_REF_PROPERTY = "JCR_IDX_MREF_PROPERTY";
-
- FIND_ITEM_BY_ID = "select * from JCR_MITEM where ID=?";
-
- FIND_ITEM_BY_NAME =
- "select * from JCR_MITEM" + " where PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
-
- 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";
-
- FIND_REFERENCES =
- "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME" + " from JCR_MREF R, JCR_MITEM P"
- + " where R.NODE_ID=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2";
-
- FIND_VALUES_BY_PROPERTYID =
- "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=? order by ORDER_NUM";
-
- FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=?";
-
- FIND_VALUE_BY_PROPERTYID_OREDERNUMB =
- "select DATA, STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=? and ORDER_NUM=?";
-
- FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
-
- FIND_LAST_ORDER_NUMBER_BY_PARENTID =
- "select count(*), max(N_ORDER_NUM) from JCR_MITEM where I_CLASS=1 and PARENT_ID=?";
-
- FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?";
-
- FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?" + " order by ID";
-
- FIND_LOWEST_PROPERTY_VERSIONS =
- "select max(VERSION) as MAX_VERSION, PARENT_ID, NAME, I_CLASS, I_INDEX from JCR_SITEM WHERE I_CLASS=2"
- + " GROUP BY PARENT_ID, NAME, I_CLASS, I_INDEX HAVING count(VERSION) > 1";
-
- INSERT_NODE =
- "insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,"
- + I_CLASS_NODE + ",?,?)";
- INSERT_PROPERTY =
- "insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, P_TYPE, P_MULTIVALUED) VALUES(?,?,?,?,"
- + I_CLASS_PROPERTY + ",?,?,?)";
-
- INSERT_VALUE = "insert into JCR_MVALUE(DATA, ORDER_NUM, PROPERTY_ID, STORAGE_DESC) VALUES(?,?,?,?)";
- INSERT_REF = "insert into JCR_MREF(NODE_ID, PROPERTY_ID, ORDER_NUM) VALUES(?,?,?)";
-
- RENAME_NODE = "update JCR_MITEM set PARENT_ID=?, NAME =?, VERSION=?, I_INDEX =?, N_ORDER_NUM =? where ID=?";
-
- UPDATE_NODE = "update JCR_MITEM set VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
- UPDATE_PROPERTY = "update JCR_MITEM set VERSION=?, P_TYPE=? where ID=?";
- //UPDATE_VALUE = "update JCR_MVALUE set DATA=?, STORAGE_DESC=? where PROPERTY_ID=?, ORDER_NUM=?";
-
- DELETE_ITEM = "delete from JCR_MITEM where ID=?";
- DELETE_VALUE = "delete from JCR_MVALUE where PROPERTY_ID=?";
- DELETE_REF = "delete from JCR_MREF where PROPERTY_ID=?";
-
- FIND_NODES_COUNT = "select count(*) from JCR_MITEM I where I.I_CLASS=1";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addNodeRecord(NodeData data) throws SQLException
- {
- if (insertNode == null)
- insertNode = dbConnection.prepareStatement(INSERT_NODE);
- else
- insertNode.clearParameters();
-
- insertNode.setString(1, data.getIdentifier());
- insertNode.setString(2, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : data
- .getParentIdentifier());
- insertNode.setString(3, data.getQPath().getName().getAsString());
- insertNode.setInt(4, data.getPersistedVersion());
- insertNode.setInt(5, data.getQPath().getIndex());
- insertNode.setInt(6, data.getOrderNumber());
- return insertNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addPropertyRecord(PropertyData data) throws SQLException
- {
- if (insertProperty == null)
- insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
- else
- insertProperty.clearParameters();
-
- insertProperty.setString(1, data.getIdentifier());
- insertProperty.setString(2, data.getParentIdentifier());
- insertProperty.setString(3, data.getQPath().getName().getAsString());
- insertProperty.setInt(4, data.getPersistedVersion());
- insertProperty.setInt(5, data.getQPath().getIndex());
- insertProperty.setInt(6, data.getType());
- insertProperty.setBoolean(7, data.isMultiValued());
-
- return insertProperty.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addReference(PropertyData data) throws SQLException, IOException
- {
- if (insertReference == null)
- insertReference = dbConnection.prepareStatement(INSERT_REF);
- else
- insertReference.clearParameters();
-
- if (data.getQPath().getAsString().indexOf("versionableUuid") > 0)
- LOG.info("add ref versionableUuid " + data.getQPath().getAsString());
-
- List<ValueData> values = data.getValues();
- int added = 0;
- for (int i = 0; i < values.size(); i++)
- {
- ValueData vdata = values.get(i);
- String refNodeIdentifier = ValueDataConvertor.readString(vdata);
-
- insertReference.setString(1, refNodeIdentifier);
- insertReference.setString(2, data.getIdentifier());
- insertReference.setInt(3, i);
- added += insertReference.executeUpdate();
- }
-
- return added;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteReference(String propertyIdentifier) throws SQLException
- {
- if (deleteReference == null)
- deleteReference = dbConnection.prepareStatement(DELETE_REF);
- else
- deleteReference.clearParameters();
-
- deleteReference.setString(1, propertyIdentifier);
- return deleteReference.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteItemByIdentifier(String identifier) throws SQLException
- {
- if (deleteItem == null)
- deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
- else
- deleteItem.clearParameters();
-
- deleteItem.setString(1, identifier);
- return deleteItem.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int updateNodeByIdentifier(int version, int index, int orderNumb, String identifier) throws SQLException
- {
- if (updateNode == null)
- updateNode = dbConnection.prepareStatement(UPDATE_NODE);
- else
- updateNode.clearParameters();
-
- updateNode.setInt(1, version);
- updateNode.setInt(2, index);
- updateNode.setInt(3, orderNumb);
- updateNode.setString(4, identifier);
- return updateNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int updatePropertyByIdentifier(int version, int type, String identifier) throws SQLException
- {
- if (updateProperty == null)
- updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
- else
- updateProperty.clearParameters();
-
- updateProperty.setInt(1, version);
- updateProperty.setInt(2, type);
- updateProperty.setString(3, identifier);
- return updateProperty.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findItemByName(String parentId, String name, int index) throws SQLException
- {
- if (findItemByName == null)
- findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
- else
- findItemByName.clearParameters();
-
- findItemByName.setString(1, parentId);
- findItemByName.setString(2, name);
- findItemByName.setInt(3, index);
- return findItemByName.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findPropertyByName(String parentId, String name) throws SQLException
- {
- if (findPropertyByName == null)
- findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
- else
- findPropertyByName.clearParameters();
-
- findPropertyByName.setString(1, parentId);
- findPropertyByName.setString(2, name);
- return findPropertyByName.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findItemByIdentifier(String identifier) throws SQLException
- {
- if (findItemById == null)
- findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
- else
- findItemById.clearParameters();
-
- findItemById.setString(1, identifier);
- return findItemById.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findReferences(String nodeIdentifier) throws SQLException
- {
- if (findReferences == null)
- findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
- else
- findReferences.clearParameters();
-
- findReferences.setString(1, nodeIdentifier);
- return findReferences.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildNodesByParentIdentifier(String parentIdentifier) throws SQLException
- {
- if (findNodesByParentId == null)
- findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
- else
- findNodesByParentId.clearParameters();
-
- findNodesByParentId.setString(1, parentIdentifier);
- return findNodesByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier) throws SQLException
- {
- if (findLastOrderNumberByParentId == null)
- findLastOrderNumberByParentId = dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
- else
- findLastOrderNumberByParentId.clearParameters();
-
- findLastOrderNumberByParentId.setString(1, parentIdentifier);
- return findLastOrderNumberByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildNodesCountByParentIdentifier(String parentIdentifier) throws SQLException
- {
- if (findNodesCountByParentId == null)
- findNodesCountByParentId = dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
- else
- findNodesCountByParentId.clearParameters();
-
- findNodesCountByParentId.setString(1, parentIdentifier);
- return findNodesCountByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildPropertiesByParentIdentifier(String parentIdentifier) throws SQLException
- {
- if (findPropertiesByParentId == null)
- findPropertiesByParentId = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
- else
- findPropertiesByParentId.clearParameters();
-
- findPropertiesByParentId.setString(1, parentIdentifier);
- return findPropertiesByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- protected ResultSet findChildNodesByParentIdentifier(String parentCid, int fromOrderNum, int toOrderNum)
- throws SQLException
- {
- throw new UnsupportedOperationException("findChildNodesByParentIdentifier is not supported for old queries");
- }
-
- // -------- values processing ------------
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addValueData(String cid, int orderNumber, InputStream stream, int streamLength, String storageDesc)
- throws SQLException
- {
-
- if (insertValue == null)
- insertValue = dbConnection.prepareStatement(INSERT_VALUE);
- else
- insertValue.clearParameters();
-
- if (stream == null)
- {
- // [PN] store vd reference to external storage etc.
- insertValue.setNull(1, Types.BINARY);
- insertValue.setString(4, storageDesc);
- }
- else
- {
- insertValue.setBinaryStream(1, stream, streamLength);
- insertValue.setNull(4, Types.VARCHAR);
- }
-
- insertValue.setInt(2, orderNumber);
- insertValue.setString(3, cid);
- return insertValue.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteValueData(String cid) throws SQLException
- {
- if (deleteValue == null)
- deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
- else
- deleteValue.clearParameters();
-
- deleteValue.setString(1, cid);
- return deleteValue.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findValuesByPropertyId(String cid) throws SQLException
- {
- if (findValuesByPropertyId == null)
- findValuesByPropertyId = dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
- else
- findValuesByPropertyId.clearParameters();
-
- findValuesByPropertyId.setString(1, cid);
- return findValuesByPropertyId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws SQLException
- {
- if (findValueByPropertyIdOrderNumber == null)
- findValueByPropertyIdOrderNumber = dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
- else
- findValueByPropertyIdOrderNumber.clearParameters();
-
- findValueByPropertyIdOrderNumber.setString(1, cid);
- findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
- return findValueByPropertyIdOrderNumber.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int renameNode(NodeData data) throws SQLException
- {
- if (renameNode == null)
- renameNode = dbConnection.prepareStatement(RENAME_NODE);
- else
- renameNode.clearParameters();
-
- renameNode.setString(1, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : data
- .getParentIdentifier());
- renameNode.setString(2, data.getQPath().getName().getAsString());
- renameNode.setInt(3, data.getPersistedVersion());
- renameNode.setInt(4, data.getQPath().getIndex());
- renameNode.setInt(5, data.getOrderNumber());
- renameNode.setString(6, data.getIdentifier());
- return renameNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws SQLException
- {
- if (findValuesStorageDescriptorsByPropertyId == null)
- findValuesStorageDescriptorsByPropertyId =
- dbConnection.prepareStatement(FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID);
- else
- findValuesStorageDescriptorsByPropertyId.clearParameters();
-
- findValuesStorageDescriptorsByPropertyId.setString(1, cid);
- return findValuesStorageDescriptorsByPropertyId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findNodesAndProperties(String lastNodeId, int offset, int limit) throws SQLException
- {
- throw new UnsupportedOperationException(
- "The method findNodesAndProperties is not supported for this type of connection use the complex queries instead");
- }
-
- /**
- * {@inheritDoc}
- */
- protected void deleteLockProperties() throws SQLException
- {
- PreparedStatement removeValuesStatement = null;
- PreparedStatement removeItemsStatement = null;
-
- try
- {
- removeValuesStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_MVALUE WHERE PROPERTY_ID IN "
- + "(SELECT ID FROM JCR_MITEM WHERE NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
- + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
-
- removeItemsStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_MITEM WHERE NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep'"
- + " OR NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'");
-
- removeValuesStatement.executeUpdate();
- removeItemsStatement.executeUpdate();
- }
- finally
- {
- if (removeValuesStatement != null)
- {
- try
- {
- removeValuesStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
-
- if (removeItemsStatement != null)
- {
- try
- {
- removeItemsStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findNodesCount() throws SQLException
- {
- if (findNodesCount == null)
- {
- findNodesCount = dbConnection.prepareStatement(FIND_NODES_COUNT);
- }
- return findNodesCount.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- protected void deleteLockProperties(String nodeIdentifier) throws SQLException
- {
- PreparedStatement removeValuesStatement = null;
- PreparedStatement removeItemsStatement = null;
-
- try
- {
- removeValuesStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_MVALUE WHERE PROPERTY_ID IN"
- + " (SELECT ID FROM JCR_MITEM WHERE PARENT_ID=? AND"
- + " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
- + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
-
- removeItemsStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_MITEM WHERE PARENT_ID=? AND"
- + " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
- + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
-
- removeValuesStatement.setString(1, getInternalId(nodeIdentifier));
- removeItemsStatement.setString(1, getInternalId(nodeIdentifier));
-
- removeValuesStatement.executeUpdate();
- removeItemsStatement.executeUpdate();
- }
- finally
- {
- if (removeValuesStatement != null)
- {
- try
- {
- removeValuesStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
-
- if (removeItemsStatement != null)
- {
- try
- {
- removeItemsStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
- }
- }
-
-}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MySQLConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -38,15 +38,6 @@
{
/**
- * MySQLConnectionFactory constructor.
- */
- public MySQLConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
-
- super(containerConfig);
- }
-
- /**
* MySQLConnectionFactory constructor.
*/
public MySQLConnectionFactory(DataSource dbDataSource, JDBCDataContainerConfig containerConfig)
@@ -63,7 +54,7 @@
{
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new MySQLMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerConfig);
}
Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OracleConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OracleConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OracleConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -1,194 +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.db;
-
-import org.exoplatform.commons.utils.ClassLoading;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.util.Properties;
-
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS
- *
- * 23.03.2007
- *
- * Access Oracle implicit connection caching and pooling stuff using reflection to prevent Maven
- * dependecies on ora drivers from POM.
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id: OracleConnectionFactory.java 34801 2009-07-31 15:44:50Z dkatayev $
- */
-public class OracleConnectionFactory extends GenericConnectionFactory
-{
-
- public static int CONNCACHE_MAX_LIMIT = 25;
-
- public static int CONNCACHE_MIN_LIMIT = 2;
-
- public static int CONNCACHE_INACTIVITY_TIMEOUT = 3600;
-
- public static int CONNCACHE_ABADONDED_TIMEOUT = 1800;
-
- protected final Object ociDataSource;
-
- /**
- * OracleConnectionFactory constructor. For CLI interface ONLY!
- */
- public OracleConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
-
- // ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
-
- /*
- * ERROR: if no oci in path and oci url requested Error:
- * java.lang.reflect.InvocationTargetException java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- * sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by: java.lang.UnsatisfiedLinkError: no
- * ocijdbc10 in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
- * --------------------------------------------------------------------------- ERROR: if thin
- * url used and trying obtain oci data source java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- * sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by: java.lang.ClassCastException:
- * oracle.jdbc.driver.T4CConnection at
- * oracle.jdbc.pool.OracleOCIConnectionPool.createConnectionPool
- * (OracleOCIConnectionPool.java:893)
- */
-
- super(containerConfig);
-
- Object cds = null;
- try
- {
- Class<?> cdsClass = ClassLoading.loadClass("oracle.jdbc.pool.OracleDataSource", this);
- Constructor<?> cdsConstructor = cdsClass.getConstructor(new Class[]{});
- cds = cdsConstructor.newInstance(new Object[]{});
-
- // set cache properties
- Properties prop = new java.util.Properties();
- prop.setProperty("InitialLimit", String.valueOf(CONNCACHE_MIN_LIMIT));
- prop.setProperty("MinLimit", String.valueOf(CONNCACHE_MIN_LIMIT));
- prop.setProperty("MaxLimit", String.valueOf(CONNCACHE_MAX_LIMIT));
- prop.setProperty("InactivityTimeout", String.valueOf(CONNCACHE_INACTIVITY_TIMEOUT));
- prop.setProperty("AbandonedConnectionTimeout", String.valueOf(CONNCACHE_ABADONDED_TIMEOUT));
-
- Method setURL = cds.getClass().getMethod("setURL", new Class[]{String.class});
- setURL.invoke(cds, new Object[]{this.containerConfig.dbUrl});
-
- Method setUser = cds.getClass().getMethod("setUser", new Class[]{String.class});
- setUser.invoke(cds, new Object[]{this.containerConfig.dbUserName});
-
- Method setPassword = cds.getClass().getMethod("setPassword", new Class[]{String.class});
- setPassword.invoke(cds, new Object[]{this.containerConfig.dbPassword});
-
- Method setConnectionCachingEnabled =
- cds.getClass().getMethod("setConnectionCachingEnabled", new Class[]{boolean.class});
- setConnectionCachingEnabled.invoke(cds, new Object[]{true});
-
- Method setConnectionCacheProperties =
- cds.getClass().getMethod("setConnectionCacheProperties", new Class[]{Properties.class});
- setConnectionCacheProperties.invoke(cds, new Object[]{prop});
-
- Method setConnectionCacheName = cds.getClass().getMethod("setConnectionCacheName", new Class[]{String.class});
- setConnectionCacheName.invoke(cds, new Object[]{"EXOJCR_OCI__" + containerConfig.containerName});
-
- }
- catch (Throwable e)
- {
- cds = null;
- StringBuilder err = new StringBuilder("Oracle OCI connection cache is unavailable due to error ").append(e);
- if (e.getCause() != null)
- {
- err.append(" (").append(e.getCause()).append(")");
- }
- err.append(". Standard JDBC DriverManager will be used for connections opening.");
- if (log.isDebugEnabled())
- {
- log.warn(err, e);
- }
- else
- {
- log.warn(err);
- }
- }
- this.ociDataSource = cds; // actually instance of javax.sql.DataSource
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
- {
- if (ociDataSource != null)
- {
- try
- {
- Connection conn = getCachedConnection();
-
- if (readOnly)
- {
- // set this feature only if it asked
- conn.setReadOnly(true);
- }
-
- return conn;
- }
- catch (Throwable e)
- {
- throw new RepositoryException("Oracle OCI cached connection open error " + e, e);
- }
- }
-
- return super.getJdbcConnection(readOnly);
- }
-
- /**
- * Get CachedConnection.
- *
- * @return
- * @throws NoSuchMethodException
- * @throws IllegalArgumentException
- * @throws IllegalAccessException
- * @throws InvocationTargetException
- */
- protected Connection getCachedConnection() throws NoSuchMethodException, IllegalArgumentException,
- IllegalAccessException, InvocationTargetException
- {
-
- // NOTE: ociDataSource - actually instance of javax.sql.DataSource
- Method getConnection = ociDataSource.getClass().getMethod("getConnection", new Class[]{});
- Connection conn = (Connection)getConnection.invoke(ociDataSource, new Object[]{});
-
- return conn;
- }
-}
Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OraclePoolConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OraclePoolConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/OraclePoolConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -1,227 +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.db;
-
-import org.exoplatform.commons.utils.ClassLoading;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.util.Properties;
-
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS
- *
- * 16.03.2007
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id: OraclePoolConnectionFactory.java 34801 2009-07-31 15:44:50Z dkatayev $
- */
-public class OraclePoolConnectionFactory extends GenericConnectionFactory
-{
-
- public static int CONNPOOL_MAX_LIMIT = 20;
-
- public static int CONNPOOL_MIN_LIMIT = 2;
-
- public static int CONNPOOL_INCREMENT = 1;
-
- protected final Object ociPool;
-
- /**
- * OraclePoolConnectionFactory constructor. For CLI interface ONLY!
- */
- public OraclePoolConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
-
- // ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
-
- /*
- * ERROR: if no oci in path and oci url requested Error:
- * java.lang.reflect.InvocationTargetException java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- * sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by: java.lang.UnsatisfiedLinkError: no
- * ocijdbc10 in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
- * --------------------------------------------------------------------------- ERROR: if thin
- * url used and trying obtain oci data source java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- * sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by: java.lang.ClassCastException:
- * oracle.jdbc.driver.T4CConnection at
- * oracle.jdbc.pool.OracleOCIConnectionPool.createConnectionPool
- * (OracleOCIConnectionPool.java:893)
- */
-
- super(containerConfig);
-
- Object cpool = null;
- try
- {
- Class<?> cpoolClass = ClassLoading.loadClass("oracle.jdbc.pool.OracleOCIConnectionPool", this);
- Constructor<?> cpoolConstructor =
- cpoolClass.getConstructor(new Class[]{String.class, String.class, String.class, Properties.class});
-
- cpool =
- cpoolConstructor.newInstance(new Object[]{this.containerConfig.dbUserName, this.containerConfig.dbPassword,
- this.containerConfig.dbUrl, null});
- Method setConnectionCachingEnabled =
- cpool.getClass().getMethod("setConnectionCachingEnabled", new Class[]{boolean.class});
- setConnectionCachingEnabled.invoke(cpool, new Object[]{true});
- }
- catch (Throwable e)
- {
- cpool = null;
- StringBuilder err = new StringBuilder("Oracle OCI connection pool is unavailable due to error ").append(e);
- if (e.getCause() != null)
- {
- err.append(" (").append(e.getCause()).append(")");
- }
- err.append(". Standard JDBC DriverManager will be used for connections opening.");
- if (log.isDebugEnabled())
- {
- log.warn(err, e);
- }
- else
- {
- log.warn(err);
- }
- }
- this.ociPool = cpool;
-
- // configure using CONNPOOL_MAX_LIMIT, CONNPOOL_MIN_LIMIT, CONNPOOL_INCREMENT
- try
- {
- reconfigure();
- displayPoolConfig();
- }
- catch (Throwable e)
- {
- if (log.isDebugEnabled())
- {
- log.warn("Oracle OCI connection pool configuration error " + e, e);
- }
- else
- {
- log.warn("Oracle OCI connection pool configuration error " + e);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
- {
- if (ociPool != null)
- {
- try
- {
- Connection conn = getPoolConnection();
-
- if (readOnly)
- {
- // set this feature only if it asked
- conn.setReadOnly(true);
- }
-
- return conn;
- }
- catch (Throwable e)
- {
- throw new RepositoryException("Oracle OCI pool connection open error " + e, e);
- }
- }
-
- return super.getJdbcConnection(readOnly);
- }
-
- /**
- * getPoolConnection.
- *
- * @return
- * @throws NoSuchMethodException
- * @throws IllegalArgumentException
- * @throws IllegalAccessException
- * @throws InvocationTargetException
- */
- protected Connection getPoolConnection() throws NoSuchMethodException, IllegalArgumentException,
- IllegalAccessException, InvocationTargetException
- {
- Method getConnection = ociPool.getClass().getMethod("getConnection", new Class[]{});
- return (Connection)getConnection.invoke(ociPool, new Object[]{});
- }
-
- protected void reconfigure() throws NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
- InvocationTargetException, NoSuchFieldException
- {
- if (ociPool != null)
- {
- // Set up the initial pool configuration
- Properties p1 = new Properties();
- String minLimitName = (String)ociPool.getClass().getField("CONNPOOL_MIN_LIMIT").get(null);
- String maxLimitName = (String)ociPool.getClass().getField("CONNPOOL_MAX_LIMIT").get(null);
- String incrName = (String)ociPool.getClass().getField("CONNPOOL_INCREMENT").get(null);
-
- p1.put(minLimitName, Integer.toString(CONNPOOL_MIN_LIMIT));
- p1.put(maxLimitName, Integer.toString(CONNPOOL_MAX_LIMIT));
- p1.put(incrName, Integer.toString(CONNPOOL_INCREMENT));
-
- // Enable the initial configuration
- ociPool.getClass().getMethod("setPoolConfig", new Class[]{Properties.class}).invoke(ociPool, new Object[]{p1});
- }
- }
-
- /**
- * Display the current status of the OracleOCIConnectionPool.
- */
- protected void displayPoolConfig() throws NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
- InvocationTargetException
- {
- if (ociPool != null)
- {
-
- log.info(" =========== Oracle OCI connection pool config =========== ");
-
- log.info(" Min poolsize Limit:\t"
- + ociPool.getClass().getMethod("getMinLimit", new Class[]{}).invoke(ociPool, new Object[]{}));
-
- log.info(" Max poolsize Limit:\t"
- + ociPool.getClass().getMethod("getMaxLimit", new Class[]{}).invoke(ociPool, new Object[]{}));
-
- log.info(" PoolSize:\t\t\t"
- + ociPool.getClass().getMethod("getPoolSize", new Class[]{}).invoke(ociPool, new Object[]{}));
-
- log.info(" ActiveSize:\t\t"
- + ociPool.getClass().getMethod("getActiveSize", new Class[]{}).invoke(ociPool, new Object[]{}));
- }
- }
-
-}
Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java.orig
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java.orig 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java.orig 2012-03-14 13:28:03 UTC (rev 5863)
@@ -1,711 +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.db;
-
-import org.exoplatform.services.jcr.datamodel.NodeData;
-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.JDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.List;
-
-/**
- * Single database connection implementation.
- *
- * Created by The eXo Platform SAS 27.04.2006
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
- * Nedonosko</a>
- * @version $Id: SingleDbJDBCConnection.java 20950 2008-10-06 14:23:07Z
- * pnedonosko $
- */
-public class SingleDbJDBCConnection extends JDBCStorageConnection
-{
-
- /**
- * Singledatabase JDBC Connection constructor.
- *
- * @param dbConnection JDBC connection, shoudl be opened before
- * @param readOnly, boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName Workspace Storage Container name (see configuration)
- * @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).
- * @throws SQLException in case of database error
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
- */
- public SingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
- throws SQLException
- {
-
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getInternalId(final String identifier)
- {
- return containerName + identifier;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getIdentifier(final String internalId)
- {
-
- if (internalId == null) // possible for root parent
- return null;
-
- return internalId.substring(containerName.length());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void prepareQueries() throws SQLException
- {
-
- JCR_PK_ITEM = "JCR_PK_SITEM";
- JCR_FK_ITEM_PARENT = "JCR_FK_SITEM_PARENT";
- JCR_IDX_ITEM_PARENT = "JCR_IDX_SITEM_PARENT";
- JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_SITEM_PARENT_ID";
- JCR_PK_VALUE = "JCR_PK_SVALUE";
- JCR_FK_VALUE_PROPERTY = "JCR_FK_SVALUE_PROPERTY";
- JCR_IDX_VALUE_PROPERTY = "JCR_IDX_SVALUE_PROPERTY";
- JCR_PK_REF = "JCR_PK_SREF";
- JCR_IDX_REF_PROPERTY = "JCR_IDX_SREF_PROPERTY";
-
- FIND_ITEM_BY_ID = "select * from JCR_SITEM where ID=?";
-
- FIND_ITEM_BY_NAME =
- "select * from JCR_SITEM"
- + " where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
-
- FIND_PROPERTY_BY_NAME =
- "select V.DATA"
- + " from JCR_SITEM I, JCR_SVALUE V"
- + " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? and I.NAME=? and"
- + " I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
-
- FIND_REFERENCES =
- "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME" + " from JCR_SREF R, JCR_SITEM P"
- + " where R.NODE_ID=? and P.CONTAINER_NAME=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2";
-
- FIND_VALUES_BY_PROPERTYID =
- "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? order by ORDER_NUM";
-
- FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=?";
-
- FIND_VALUE_BY_PROPERTYID_OREDERNUMB =
- "select DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? and ORDER_NUM=?";
-
- FIND_NODES_BY_PARENTID =
- "select * from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
-
- FIND_LAST_ORDER_NUMBER_BY_PARENTID =
- "select count(*), max(N_ORDER_NUM) from JCR_SITEM where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
-
- FIND_NODES_COUNT_BY_PARENTID =
- "select count(ID) from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
-
- FIND_PROPERTIES_BY_PARENTID =
- "select * from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=?" + " order by ID";
-
- FIND_LOWEST_PROPERTY_VERSIONS =
- "select max(VERSION) as MAX_VERSION, PARENT_ID, NAME, CONTAINER_NAME, I_CLASS, I_INDEX from JCR_SITEM WHERE I_CLASS=2"
- + " GROUP BY PARENT_ID, CONTAINER_NAME, NAME, I_CLASS, I_INDEX HAVING count(VERSION) > 1";
-
- INSERT_NODE =
- "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,?,"
- + I_CLASS_NODE + ",?,?)";
- INSERT_PROPERTY =
- "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, P_TYPE, P_MULTIVALUED) "
- + "VALUES(?,?,?,?,?," + I_CLASS_PROPERTY + ",?,?,?)";
-
- INSERT_VALUE = "insert into JCR_SVALUE(DATA, ORDER_NUM, PROPERTY_ID, STORAGE_DESC) VALUES(?,?,?,?)";
- INSERT_REF = "insert into JCR_SREF(NODE_ID, PROPERTY_ID, ORDER_NUM) VALUES(?,?,?)";
-
- RENAME_NODE = "update JCR_SITEM set PARENT_ID=?, NAME=?, VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
-
- UPDATE_NODE = "update JCR_SITEM set VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
- UPDATE_PROPERTY = "update JCR_SITEM set VERSION=?, P_TYPE=? where ID=?";
- //UPDATE_VALUE = "update JCR_SVALUE set DATA=?, STORAGE_DESC=? where PROPERTY_ID=?, ORDER_NUM=?";
-
- DELETE_ITEM = "delete from JCR_SITEM where ID=?";
- DELETE_VALUE = "delete from JCR_SVALUE where PROPERTY_ID=?";
- DELETE_REF = "delete from JCR_SREF where PROPERTY_ID=?";
-
- FIND_NODES_COUNT = "select count(*) from JCR_SITEM I where I.I_CLASS=1 and I.CONTAINER_NAME=?";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addNodeRecord(NodeData data) throws SQLException
- {
- if (insertNode == null)
- insertNode = dbConnection.prepareStatement(INSERT_NODE);
- else
- insertNode.clearParameters();
-
- insertNode.setString(1, getInternalId(data.getIdentifier()));
- // if root then parent identifier equals space string
- insertNode.setString(2, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : getInternalId(data
- .getParentIdentifier()));
- insertNode.setString(3, data.getQPath().getName().getAsString());
- insertNode.setString(4, containerName);
- insertNode.setInt(5, data.getPersistedVersion());
- insertNode.setInt(6, data.getQPath().getIndex());
- insertNode.setInt(7, data.getOrderNumber());
- return insertNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addPropertyRecord(PropertyData data) throws SQLException
- {
- if (insertProperty == null)
- insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
- else
- insertProperty.clearParameters();
-
- insertProperty.setString(1, getInternalId(data.getIdentifier()));
- insertProperty.setString(2, getInternalId(data.getParentIdentifier()));
- insertProperty.setString(3, data.getQPath().getName().getAsString());
- insertProperty.setString(4, containerName);
- insertProperty.setInt(5, data.getPersistedVersion());
- insertProperty.setInt(6, data.getQPath().getIndex());
- insertProperty.setInt(7, data.getType());
- insertProperty.setBoolean(8, data.isMultiValued());
-
- return insertProperty.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addReference(PropertyData data) throws SQLException, IOException
- {
- if (insertReference == null)
- insertReference = dbConnection.prepareStatement(INSERT_REF);
- else
- insertReference.clearParameters();
-
- List<ValueData> values = data.getValues();
- int added = 0;
- for (int i = 0; i < values.size(); i++)
- {
- ValueData vdata = values.get(i);
- String refNodeIdentifier = new String(vdata.getAsByteArray());
-
- insertReference.setString(1, getInternalId(refNodeIdentifier));
- insertReference.setString(2, getInternalId(data.getIdentifier()));
- insertReference.setInt(3, i);
- added += insertReference.executeUpdate();
- }
- return added;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteReference(String propertyCid) throws SQLException
- {
- if (deleteReference == null)
- deleteReference = dbConnection.prepareStatement(DELETE_REF);
- else
- deleteReference.clearParameters();
-
- deleteReference.setString(1, propertyCid);
- return deleteReference.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteItemByIdentifier(String cid) throws SQLException
- {
- if (deleteItem == null)
- deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
- else
- deleteItem.clearParameters();
-
- deleteItem.setString(1, cid);
- return deleteItem.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildNodesByParentIdentifier(String parentCid) throws SQLException
- {
- if (findNodesByParentId == null)
- findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
- else
- findNodesByParentId.clearParameters();
-
- findNodesByParentId.setString(1, containerName);
- findNodesByParentId.setString(2, parentCid);
- return findNodesByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier) throws SQLException
- {
- if (findLastOrderNumberByParentId == null)
- findLastOrderNumberByParentId = dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
- else
- findLastOrderNumberByParentId.clearParameters();
-
- findLastOrderNumberByParentId.setString(1, containerName);
- findLastOrderNumberByParentId.setString(2, parentIdentifier);
- return findLastOrderNumberByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws SQLException
- {
- if (findNodesCountByParentId == null)
- findNodesCountByParentId = dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
- else
- findNodesCountByParentId.clearParameters();
-
- findNodesCountByParentId.setString(1, containerName);
- findNodesCountByParentId.setString(2, parentCid);
- return findNodesCountByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildPropertiesByParentIdentifier(String parentCid) throws SQLException
- {
- if (findPropertiesByParentId == null)
- findPropertiesByParentId = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
- else
- findPropertiesByParentId.clearParameters();
-
- findPropertiesByParentId.setString(1, containerName);
- findPropertiesByParentId.setString(2, parentCid);
- return findPropertiesByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findItemByName(String parentId, String name, int index) throws SQLException
- {
- if (findItemByName == null)
- findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
- else
- findItemByName.clearParameters();
-
- findItemByName.setString(1, containerName);
- findItemByName.setString(2, parentId);
- findItemByName.setString(3, name);
- findItemByName.setInt(4, index);
- return findItemByName.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findPropertyByName(String parentCid, String name) throws SQLException
- {
- if (findPropertyByName == null)
- findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
- else
- findPropertyByName.clearParameters();
-
- findPropertyByName.setString(1, containerName);
- findPropertyByName.setString(2, parentCid);
- findPropertyByName.setString(3, name);
- return findPropertyByName.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findItemByIdentifier(String cid) throws SQLException
- {
- if (findItemById == null)
- findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
- else
- findItemById.clearParameters();
-
- findItemById.setString(1, cid);
- return findItemById.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findReferences(String cid) throws SQLException
- {
- if (findReferences == null)
- findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
- else
- findReferences.clearParameters();
-
- findReferences.setString(1, cid);
- findReferences.setString(2, containerName);
- return findReferences.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int updateNodeByIdentifier(int version, int index, int orderNumb, String cid) throws SQLException
- {
- if (updateNode == null)
- updateNode = dbConnection.prepareStatement(UPDATE_NODE);
- else
- updateNode.clearParameters();
-
- updateNode.setInt(1, version);
- updateNode.setInt(2, index);
- updateNode.setInt(3, orderNumb);
- updateNode.setString(4, cid);
- return updateNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int updatePropertyByIdentifier(int version, int type, String cid) throws SQLException
- {
- if (updateProperty == null)
- updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
- else
- updateProperty.clearParameters();
-
- updateProperty.setInt(1, version);
- updateProperty.setInt(2, type);
- updateProperty.setString(3, cid);
- return updateProperty.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- protected ResultSet findChildNodesByParentIdentifier(String parentCid, int fromOrderNum, int toOrderNum)
- throws SQLException
- {
- throw new UnsupportedOperationException("findChildNodesByParentIdentifier is not supported for old queries");
- }
-
- // -------- values processing ------------
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addValueData(String cid, int orderNumber, InputStream stream, int streamLength, String storageDesc)
- throws SQLException
- {
-
- if (insertValue == null)
- insertValue = dbConnection.prepareStatement(INSERT_VALUE);
- else
- insertValue.clearParameters();
-
- if (stream == null)
- {
- // [PN] store vd reference to external storage etc.
- insertValue.setNull(1, Types.BINARY);
- insertValue.setString(4, storageDesc);
- }
- else
- {
- insertValue.setBinaryStream(1, stream, streamLength);
- insertValue.setNull(4, Types.VARCHAR);
- }
-
- insertValue.setInt(2, orderNumber);
- insertValue.setString(3, cid);
- return insertValue.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteValueData(String cid) throws SQLException
- {
- if (deleteValue == null)
- deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
- else
- deleteValue.clearParameters();
-
- deleteValue.setString(1, cid);
- return deleteValue.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findValuesByPropertyId(String cid) throws SQLException
- {
- if (findValuesByPropertyId == null)
- findValuesByPropertyId = dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
- else
- findValuesByPropertyId.clearParameters();
-
- findValuesByPropertyId.setString(1, cid);
- return findValuesByPropertyId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws SQLException
- {
- if (findValuesStorageDescriptorsByPropertyId == null)
- findValuesStorageDescriptorsByPropertyId =
- dbConnection.prepareStatement(FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID);
- else
- findValuesStorageDescriptorsByPropertyId.clearParameters();
-
- findValuesStorageDescriptorsByPropertyId.setString(1, cid);
- return findValuesStorageDescriptorsByPropertyId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws SQLException
- {
- if (findValueByPropertyIdOrderNumber == null)
- {
- findValueByPropertyIdOrderNumber = dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
- }
- else
- {
- findValueByPropertyIdOrderNumber.clearParameters();
- }
-
- findValueByPropertyIdOrderNumber.setString(1, cid);
- findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
- return findValueByPropertyIdOrderNumber.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int renameNode(NodeData data) throws SQLException
- {
- if (renameNode == null)
- {
- renameNode = dbConnection.prepareStatement(RENAME_NODE);
- }
- else
- {
- renameNode.clearParameters();
- }
-
- renameNode.setString(1, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : getInternalId(data
- .getParentIdentifier()));
- renameNode.setString(2, data.getQPath().getName().getAsString());
- renameNode.setInt(3, data.getPersistedVersion());
- renameNode.setInt(4, data.getQPath().getIndex());
- renameNode.setInt(5, data.getOrderNumber());
- renameNode.setString(6, getInternalId(data.getIdentifier()));
- return renameNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findNodesAndProperties(String lastNodeId, int offset, int limit) throws SQLException
- {
- throw new UnsupportedOperationException(
- "The method findNodesAndProperties is not supported for this type of connection use the complex queries instead");
- }
-
- /**
- * {@inheritDoc}
- */
- protected void deleteLockProperties() throws SQLException
- {
- PreparedStatement removeValuesStatement = null;
- PreparedStatement removeItemsStatement = null;
-
- try
- {
- removeValuesStatement =
- dbConnection
- .prepareStatement("DELETE FROM JCR_SVALUE WHERE PROPERTY_ID "
- + "IN (SELECT ID FROM JCR_SITEM WHERE CONTAINER_NAME = ? AND "
- + "(NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
- removeValuesStatement.setString(1, containerName);
-
- removeItemsStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_SITEM WHERE CONTAINER_NAME = ? AND "
- + "(NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
- removeItemsStatement.setString(1, containerName);
-
- removeValuesStatement.executeUpdate();
- removeItemsStatement.executeUpdate();
- }
- finally
- {
- if (removeValuesStatement != null)
- {
- try
- {
- removeValuesStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
-
- if (removeItemsStatement != null)
- {
- try
- {
- removeItemsStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findNodesCount() throws SQLException
- {
- if (findNodesCount == null)
- {
- findNodesCount = dbConnection.prepareStatement(FIND_NODES_COUNT);
- }
- else
- {
- findNodesCount.clearParameters();
- }
-
- findNodesCount.setString(1, containerName);
-
- return findNodesCount.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- protected void deleteLockProperties(String nodeIdentifier) throws SQLException
- {
- PreparedStatement removeValuesStatement = null;
- PreparedStatement removeItemsStatement = null;
-
- try
- {
- removeValuesStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_SVALUE WHERE PROPERTY_ID IN (SELECT ID FROM JCR_SITEM"
- + " WHERE CONTAINER_NAME = ? AND PARENT_ID=? AND (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
- + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
- removeValuesStatement.setString(1, containerName);
- removeValuesStatement.setString(2, getInternalId(nodeIdentifier));
-
- removeItemsStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_SITEM WHERE CONTAINER_NAME = ? AND PARENT_ID=? AND"
- + " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
- + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
- removeItemsStatement.setString(1, containerName);
- removeItemsStatement.setString(2, getInternalId(nodeIdentifier));
-
- removeValuesStatement.executeUpdate();
- removeItemsStatement.executeUpdate();
- }
- finally
- {
- if (removeValuesStatement != null)
- {
- try
- {
- removeValuesStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
-
- if (removeItemsStatement != null)
- {
- try
- {
- removeItemsStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
- }
- }
-}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/IngresSQLDBInitializer.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.init;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import java.io.IOException;
import java.sql.Connection;
@@ -37,7 +38,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
* @version $Id: IngresSQLDBInitializer.java 34801 2009-07-31 15:44:50Z dkatayev $
*/
-public class IngresSQLDBInitializer extends StorageDBInitializer
+public class IngresSQLDBInitializer extends DBInitializer
{
public IngresSQLDBInitializer(Connection connection, JDBCDataContainerConfig containerConfig) throws IOException
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/OracleDBInitializer.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.init;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import java.io.IOException;
import java.sql.Connection;
@@ -37,7 +38,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
* @version $Id: OracleDBInitializer.java 34801 2009-07-31 15:44:50Z dkatayev $
*/
-public class OracleDBInitializer extends StorageDBInitializer
+public class OracleDBInitializer extends DBInitializer
{
public OracleDBInitializer(Connection connection, JDBCDataContainerConfig containerConfig) throws IOException
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/PgSQLDBInitializer.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/PgSQLDBInitializer.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/PgSQLDBInitializer.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.init;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import java.io.IOException;
import java.sql.Connection;
@@ -35,7 +36,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
* @version $Id: PgSQLDBInitializer.java 34801 2009-07-31 15:44:50Z dkatayev $
*/
-public class PgSQLDBInitializer extends StorageDBInitializer
+public class PgSQLDBInitializer extends DBInitializer
{
public PgSQLDBInitializer(Connection connection, JDBCDataContainerConfig containerConfig) throws IOException
Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/StorageDBInitializer.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/StorageDBInitializer.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/init/StorageDBInitializer.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -1,95 +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.init;
-
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
-import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
-import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
-
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * JCR Storage DB initializer.
- *
- * Created by The eXo Platform SAS 12.03.2007.
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id$
- */
-public class StorageDBInitializer extends DBInitializer
-{
- public StorageDBInitializer(Connection connection, JDBCDataContainerConfig containerConfig) throws IOException
- {
- super(connection, containerConfig);
- }
-
- protected String prepareScripts() throws IOException
- {
- if (containerConfig.dbStructureType == DatabaseStructureType.ISOLATED)
- {
- // Replace the names of Database entities
- String scripts = super.prepareScripts();
-
- return scripts.replace("MITEM", "I" + containerConfig.dbTableSuffix)
- .replace("MVALUE", "V" + containerConfig.dbTableSuffix)
- .replace("MREF", "R" + containerConfig.dbTableSuffix);
- }
- else
- {
- return super.prepareScripts();
- }
-
- }
-
- /**
- * Init root node parent record.
- */
- @Override
- protected void postInit(Connection connection) throws SQLException
- {
- String tableSuffix = "";
- switch (containerConfig.dbStructureType)
- {
- case MULTI :
- tableSuffix = "MITEM";
- break;
- case SINGLE :
- tableSuffix = "SITEM";
- break;
- case ISOLATED :
- tableSuffix = "I" + containerConfig.dbTableSuffix;
- break;
- }
- String select =
- "select * from JCR_" + tableSuffix + " where ID='" + Constants.ROOT_PARENT_UUID + "' and PARENT_ID='"
- + Constants.ROOT_PARENT_UUID + "'";
-
- if (!connection.createStatement().executeQuery(select).next())
- {
- // TODO
- String insert = DBInitializerHelper.getRootNodeInitializeScript(containerConfig);
-
- connection.createStatement().executeUpdate(insert);
- }
- }
-}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -27,19 +27,17 @@
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.init.StorageDBInitializer;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.DB2ConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.DefaultOracleConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.GenericCQConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.HSQLDBConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.MSSQLConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.MySQLConnectionFactory;
-import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.OracleConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.PostgreConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db.SybaseConnectionFactory;
import org.exoplatform.services.jcr.impl.util.io.FileCleanerHolder;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerException;
-import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
import org.exoplatform.services.jdbc.DataSourceProvider;
import org.exoplatform.services.naming.InitialContextInitializer;
@@ -94,20 +92,11 @@
@Override
protected void initDatabase() throws NamingException, RepositoryException, IOException
{
-
- StorageDBInitializer dbInitializer = null;
+ DBInitializer dbInitializer = null;
if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
{
LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is experimental!");
- // sample of connection factory customization
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new DefaultOracleConnectionFactory(getDataSource(), containerConfig);
- }
- else
- {
- this.connFactory = new OracleConnectionFactory(containerConfig);
- }
+ this.connFactory = new DefaultOracleConnectionFactory(getDataSource(), containerConfig);
// a particular db initializer may be configured here too
dbInitializer =
@@ -115,28 +104,11 @@
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLE)
{
-
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new DefaultOracleConnectionFactory(getDataSource(), containerConfig);
- }
- else
- {
- this.connFactory = new DefaultOracleConnectionFactory(containerConfig);
- }
-
+ this.connFactory = new DefaultOracleConnectionFactory(getDataSource(), containerConfig);
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_PGSQL)
{
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new PostgreConnectionFactory(getDataSource(), containerConfig);
- }
- else
- {
- this.connFactory = new PostgreConnectionFactory(containerConfig);
- }
-
+ this.connFactory = new PostgreConnectionFactory(getDataSource(), containerConfig);
dbInitializer =
new PgSQLDBInitializer(this.connFactory.getJdbcConnection(), containerConfig);
}
@@ -152,28 +124,13 @@
+ " if you don't expect any support and performances in read accesses are more important than the consistency"
+ " in your use-case. This dialect is only dedicated to the community.");
}
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new MySQLConnectionFactory(getDataSource(), containerConfig);
- }
- else
- {
- this.connFactory = new MySQLConnectionFactory(containerConfig);
- }
+ this.connFactory = new MySQLConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_MSSQL)
{
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new MSSQLConnectionFactory(getDataSource(), containerConfig);
- }
- else
- {
- this.connFactory = new MSSQLConnectionFactory(containerConfig);
- }
-
+ this.connFactory = new MSSQLConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DERBY)
@@ -183,41 +140,17 @@
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DB2)
{
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new DB2ConnectionFactory(getDataSource(), containerConfig);
- }
- else
- {
- this.connFactory = new DB2ConnectionFactory(containerConfig);
- }
-
+ new DB2ConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DB2V8)
{
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new DB2ConnectionFactory(getDataSource(), containerConfig);
- }
- else
- {
- this.connFactory = new DB2ConnectionFactory(containerConfig);
- }
-
+ new DB2ConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_SYBASE)
{
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new SybaseConnectionFactory(getDataSource(), containerConfig);
- }
- else
- {
- this.connFactory = new SybaseConnectionFactory(containerConfig);
- }
-
+ this.connFactory = new SybaseConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_INGRES)
@@ -229,14 +162,7 @@
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_HSQLDB)
{
- if (containerConfig.dbSourceName != null)
- {
- this.connFactory = new HSQLDBConnectionFactory(getDataSource(), containerConfig);
- }
- else
- {
- this.connFactory = new HSQLDBConnectionFactory(containerConfig);
- }
+ this.connFactory = new HSQLDBConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else
@@ -269,12 +195,6 @@
@Override
protected GenericConnectionFactory defaultConnectionFactory() throws NamingException, RepositoryException
{
- // by default
- if (containerConfig.dbSourceName != null)
- {
- return new GenericCQConnectionFactory(getDataSource(), containerConfig);
- }
-
- return new GenericCQConnectionFactory(containerConfig);
+ return new GenericCQConnectionFactory(getDataSource(), containerConfig);
}
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2ConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2ConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DB2ConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -19,13 +19,10 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
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 java.io.File;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
@@ -49,14 +46,6 @@
private Boolean isReindexingSupport;
/**
- * DB2ConnectionFactory constructor.
- */
- public DB2ConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
- super(containerConfig);
- }
-
- /**
* DB2ConnectionFactory constructor.
*/
public DB2ConnectionFactory(DataSource dataSource, JDBCDataContainerConfig containerConfig)
@@ -72,7 +61,7 @@
{
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new DB2MultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerConfig);
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/DefaultOracleConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -41,15 +41,6 @@
}
/**
- * DefaultOracleConnectionFactory constructor.
- */
- public DefaultOracleConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
-
- super(containerConfig);
- }
-
- /**
* {@inheritDoc}
*/
@Override
@@ -59,7 +50,7 @@
{
if (containerConfig.useQueryHints)
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new OracleMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -18,13 +18,11 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
-import org.exoplatform.commons.utils.ClassLoading;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.GenericConnectionFactory;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import java.sql.Connection;
-import java.sql.DriverManager;
import java.sql.SQLException;
import javax.jcr.RepositoryException;
@@ -50,32 +48,6 @@
}
/**
- * GenericConnectionFactory constructor.
- */
- public GenericCQConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
-
- this(null, containerConfig);
-
- try
- {
- ClassLoading.forName(this.containerConfig.dbDriver, this).newInstance();
- }
- catch (InstantiationException e)
- {
- throw new RepositoryException(e);
- }
- catch (IllegalAccessException e)
- {
- throw new RepositoryException(e);
- }
- catch (ClassNotFoundException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
* {@inheritDoc}
*/
@Override
@@ -93,7 +65,7 @@
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new MultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerConfig);
}
@@ -115,12 +87,7 @@
{
try
{
- Connection conn =
- dbDataSource != null ? dbDataSource.getConnection() : (this.containerConfig.dbUserName != null
- ? DriverManager.getConnection(this.containerConfig.dbUrl, this.containerConfig.dbUserName,
- this.containerConfig.dbPassword) : DriverManager.getConnection(this.containerConfig.dbUrl));
-
- return conn;
+ return dbDataSource.getConnection();
}
catch (SQLException e)
{
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -45,15 +45,6 @@
}
/**
- * HSQLDBConnectionFactory constructor.
- */
- public HSQLDBConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
-
- super(containerConfig);
- }
-
- /**
* {@inheritDoc}
*/
public WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException
@@ -61,7 +52,7 @@
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new HSQLDBMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly,
containerConfig);
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MSSQLConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -38,14 +38,6 @@
{
/**
- * MSSQLConnectionFactory constructor.
- */
- public MSSQLConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
- super(containerConfig);
- }
-
- /**
* MSSQLConnectionFactory constructor.
*/
public MSSQLConnectionFactory(DataSource dbDataSource, JDBCDataContainerConfig containerConfig)
@@ -61,7 +53,7 @@
{
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new MSSQLMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerConfig);
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MySQLConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -38,15 +38,6 @@
{
/**
- * MySQLConnectionFactory constructor.
- */
- public MySQLConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
-
- super(containerConfig);
- }
-
- /**
* MySQLConnectionFactory constructor.
*/
public MySQLConnectionFactory(DataSource dbDataSource, JDBCDataContainerConfig containerConfig)
@@ -64,7 +55,7 @@
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new MySQLMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerConfig);
}
Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OracleConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -1,195 +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.db;
-
-import org.exoplatform.commons.utils.ClassLoading;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.util.Properties;
-
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS
- *
- * 23.03.2007
- *
- * Access Oracle implicit connection caching and pooling stuff using reflection to prevent Maven
- * dependecies on ora drivers from POM.
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id$
- */
-public class OracleConnectionFactory extends DefaultOracleConnectionFactory
-{
-
- public static int CONNCACHE_MAX_LIMIT = 25;
-
- public static int CONNCACHE_MIN_LIMIT = 2;
-
- public static int CONNCACHE_INACTIVITY_TIMEOUT = 3600;
-
- public static int CONNCACHE_ABADONDED_TIMEOUT = 1800;
-
- protected final Object ociDataSource;
-
- /**
- * OracleConnectionFactory constructor. For CLI interface ONLY!
- */
- public OracleConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
-
- // ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
-
- /*
- * ERROR: if no oci in path and oci url requested Error:
- * java.lang.reflect.InvocationTargetException java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- * sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by: java.lang.UnsatisfiedLinkError: no
- * ocijdbc10 in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
- * --------------------------------------------------------------------------- ERROR: if thin
- * url used and trying obtain oci data source java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- * sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by: java.lang.ClassCastException:
- * oracle.jdbc.driver.T4CConnection at
- * oracle.jdbc.pool.OracleOCIConnectionPool.createConnectionPool
- * (OracleOCIConnectionPool.java:893)
- */
-
- super(containerConfig);
-
- Object cds = null;
- try
- {
- Class<?> cdsClass = ClassLoading.loadClass("oracle.jdbc.pool.OracleDataSource", this);
- Constructor<?> cdsConstructor = cdsClass.getConstructor(new Class[]{});
- cds = cdsConstructor.newInstance(new Object[]{});
-
- // set cache properties
- Properties prop = new java.util.Properties();
- prop.setProperty("InitialLimit", String.valueOf(CONNCACHE_MIN_LIMIT));
- prop.setProperty("MinLimit", String.valueOf(CONNCACHE_MIN_LIMIT));
- prop.setProperty("MaxLimit", String.valueOf(CONNCACHE_MAX_LIMIT));
- prop.setProperty("InactivityTimeout", String.valueOf(CONNCACHE_INACTIVITY_TIMEOUT));
- prop.setProperty("AbandonedConnectionTimeout", String.valueOf(CONNCACHE_ABADONDED_TIMEOUT));
-
- Method setURL = cds.getClass().getMethod("setURL", new Class[]{String.class});
- setURL.invoke(cds, new Object[]{this.containerConfig.dbUrl});
-
- Method setUser = cds.getClass().getMethod("setUser", new Class[]{String.class});
- setUser.invoke(cds, new Object[]{this.containerConfig.dbUserName});
-
- Method setPassword = cds.getClass().getMethod("setPassword", new Class[]{String.class});
- setPassword.invoke(cds, new Object[]{this.containerConfig.dbPassword});
-
- Method setConnectionCachingEnabled =
- cds.getClass().getMethod("setConnectionCachingEnabled", new Class[]{boolean.class});
- setConnectionCachingEnabled.invoke(cds, new Object[]{true});
-
- Method setConnectionCacheProperties =
- cds.getClass().getMethod("setConnectionCacheProperties", new Class[]{Properties.class});
- setConnectionCacheProperties.invoke(cds, new Object[]{prop});
-
- Method setConnectionCacheName = cds.getClass().getMethod("setConnectionCacheName", new Class[]{String.class});
- setConnectionCacheName.invoke(cds, new Object[]{"EXOJCR_OCI__" + containerConfig.containerName});
-
- }
- catch (Throwable e)
- {
- cds = null;
- StringBuilder err = new StringBuilder("Oracle OCI connection cache is unavailable due to error ").append(e);
- if (e.getCause() != null)
- {
- err.append(" (").append(e.getCause()).append(")");
- }
- err.append(". Standard JDBC DriverManager will be used for connections opening.");
- if (log.isDebugEnabled())
- {
- log.warn(err, e);
- }
- else
- {
- log.warn(err);
- }
- }
- this.ociDataSource = cds; // actually instance of javax.sql.DataSource
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
- {
- if (ociDataSource != null)
- {
- try
- {
- Connection conn = getCachedConnection();
-
- if (readOnly)
- {
- // set this feature only if it asked
- conn.setReadOnly(true);
- }
-
- return conn;
- }
- catch (Throwable e)
- {
- throw new RepositoryException("Oracle OCI cached connection open error " + e, e);
- }
- }
-
- return super.getJdbcConnection(readOnly);
- }
-
- /**
- * Get CachedConnection.
- *
- * @return
- * @throws NoSuchMethodException
- * @throws IllegalArgumentException
- * @throws IllegalAccessException
- * @throws InvocationTargetException
- */
- protected Connection getCachedConnection() throws NoSuchMethodException, IllegalArgumentException,
- IllegalAccessException, InvocationTargetException
- {
-
- // NOTE: ociDataSource - actually instance of javax.sql.DataSource
- Method getConnection = ociDataSource.getClass().getMethod("getConnection", new Class[]{});
- Connection conn = (Connection)getConnection.invoke(ociDataSource, new Object[]{});
-
- return conn;
- }
-
-}
Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OraclePoolConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OraclePoolConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/OraclePoolConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -1,227 +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.db;
-
-import org.exoplatform.commons.utils.ClassLoading;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.util.Properties;
-
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS
- *
- * 16.03.2007
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id$
- */
-public class OraclePoolConnectionFactory extends GenericCQConnectionFactory
-{
-
- public static int CONNPOOL_MAX_LIMIT = 20;
-
- public static int CONNPOOL_MIN_LIMIT = 2;
-
- public static int CONNPOOL_INCREMENT = 1;
-
- protected final Object ociPool;
-
- /**
- * OraclePoolConnectionFactory constructor. For CLI interface ONLY!
- */
- public OraclePoolConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
-
- // ;D:\Devel\oracle_instantclient_10_2\;C:\oracle\ora92\bin;
-
- /*
- * ERROR: if no oci in path and oci url requested Error:
- * java.lang.reflect.InvocationTargetException java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- * sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by: java.lang.UnsatisfiedLinkError: no
- * ocijdbc10 in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
- * --------------------------------------------------------------------------- ERROR: if thin
- * url used and trying obtain oci data source java.lang.reflect.InvocationTargetException at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
- * sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- * at
- * sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl
- * .java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at
- * ocipool.ConnPoolAppl.main(ConnPoolAppl.java:58) Caused by: java.lang.ClassCastException:
- * oracle.jdbc.driver.T4CConnection at
- * oracle.jdbc.pool.OracleOCIConnectionPool.createConnectionPool
- * (OracleOCIConnectionPool.java:893)
- */
-
- super(containerConfig);
-
- Object cpool = null;
- try
- {
- Class<?> cpoolClass = ClassLoading.loadClass("oracle.jdbc.pool.OracleOCIConnectionPool", this);
- Constructor<?> cpoolConstructor =
- cpoolClass.getConstructor(new Class[]{String.class, String.class, String.class, Properties.class});
-
- cpool =
- cpoolConstructor.newInstance(new Object[]{this.containerConfig.dbUserName, this.containerConfig.dbPassword,
- this.containerConfig.dbUrl, null});
- Method setConnectionCachingEnabled =
- cpool.getClass().getMethod("setConnectionCachingEnabled", new Class[]{boolean.class});
- setConnectionCachingEnabled.invoke(cpool, new Object[]{true});
- }
- catch (Throwable e)
- {
- cpool = null;
- StringBuilder err = new StringBuilder("Oracle OCI connection pool is unavailable due to error ").append(e);
- if (e.getCause() != null)
- {
- err.append(" (").append(e.getCause()).append(")");
- }
- err.append(". Standard JDBC DriverManager will be used for connections opening.");
- if (log.isDebugEnabled())
- {
- log.warn(err, e);
- }
- else
- {
- log.warn(err);
- }
- }
- this.ociPool = cpool;
-
- // configure using CONNPOOL_MAX_LIMIT, CONNPOOL_MIN_LIMIT, CONNPOOL_INCREMENT
- try
- {
- reconfigure();
- displayPoolConfig();
- }
- catch (Throwable e)
- {
- if (log.isDebugEnabled())
- {
- log.warn("Oracle OCI connection pool configuration error " + e, e);
- }
- else
- {
- log.warn("Oracle OCI connection pool configuration error " + e);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Connection getJdbcConnection(boolean readOnly) throws RepositoryException
- {
- if (ociPool != null)
- {
- try
- {
- Connection conn = getPoolConnection();
-
- if (readOnly)
- {
- // set this feature only if it asked
- conn.setReadOnly(true);
- }
-
- return conn;
- }
- catch (Throwable e)
- {
- throw new RepositoryException("Oracle OCI pool connection open error " + e, e);
- }
- }
-
- return super.getJdbcConnection(readOnly);
- }
-
- /**
- * getPoolConnection.
- *
- * @return
- * @throws NoSuchMethodException
- * @throws IllegalArgumentException
- * @throws IllegalAccessException
- * @throws InvocationTargetException
- */
- protected Connection getPoolConnection() throws NoSuchMethodException, IllegalArgumentException,
- IllegalAccessException, InvocationTargetException
- {
- Method getConnection = ociPool.getClass().getMethod("getConnection", new Class[]{});
- return (Connection)getConnection.invoke(ociPool, new Object[]{});
- }
-
- protected void reconfigure() throws NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
- InvocationTargetException, NoSuchFieldException
- {
- if (ociPool != null)
- {
- // Set up the initial pool configuration
- Properties p1 = new Properties();
- String minLimitName = (String)ociPool.getClass().getField("CONNPOOL_MIN_LIMIT").get(null);
- String maxLimitName = (String)ociPool.getClass().getField("CONNPOOL_MAX_LIMIT").get(null);
- String incrName = (String)ociPool.getClass().getField("CONNPOOL_INCREMENT").get(null);
-
- p1.put(minLimitName, Integer.toString(CONNPOOL_MIN_LIMIT));
- p1.put(maxLimitName, Integer.toString(CONNPOOL_MAX_LIMIT));
- p1.put(incrName, Integer.toString(CONNPOOL_INCREMENT));
-
- // Enable the initial configuration
- ociPool.getClass().getMethod("setPoolConfig", new Class[]{Properties.class}).invoke(ociPool, new Object[]{p1});
- }
- }
-
- /**
- * Display the current status of the OracleOCIConnectionPool.
- */
- protected void displayPoolConfig() throws NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
- InvocationTargetException
- {
- if (ociPool != null)
- {
-
- log.info(" =========== Oracle OCI connection pool config =========== ");
-
- log.info(" Min poolsize Limit:\t"
- + ociPool.getClass().getMethod("getMinLimit", new Class[]{}).invoke(ociPool, new Object[]{}));
-
- log.info(" Max poolsize Limit:\t"
- + ociPool.getClass().getMethod("getMaxLimit", new Class[]{}).invoke(ociPool, new Object[]{}));
-
- log.info(" PoolSize:\t\t\t"
- + ociPool.getClass().getMethod("getPoolSize", new Class[]{}).invoke(ociPool, new Object[]{}));
-
- log.info(" ActiveSize:\t\t"
- + ociPool.getClass().getMethod("getActiveSize", new Class[]{}).invoke(ociPool, new Object[]{}));
- }
- }
-
-}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/PostgreConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -34,13 +34,6 @@
*/
public class PostgreConnectionFactory extends GenericCQConnectionFactory
{
- /**
- * PostgreConnectionFactory constructor.
- */
- public PostgreConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
- super(containerConfig);
- }
/**
* PostgreConnectionFactory constructor.
@@ -58,7 +51,7 @@
{
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new PostgreMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerConfig);
}
Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java.orig
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java.orig 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java.orig 2012-03-14 13:28:03 UTC (rev 5863)
@@ -1,1090 +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.db;
-
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-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.core.itemfilters.QPathEntryFilter;
-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;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.List;
-
-/**
- * Single database connection implementation.
- *
- * Created by The eXo Platform SAS 27.04.2006
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
- * Nedonosko</a>
- * @version $Id: SingleDbJDBCConnection.java 20950 2008-10-06 14:23:07Z
- * pnedonosko $
- */
-public class SingleDbJDBCConnection extends CQJDBCStorageConnection
-{
-
- protected static final String FIND_NODES_BY_PARENTID_CQ_QUERY =
- "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from JCR_SITEM I, JCR_SITEM P, JCR_SVALUE V"
- + " where I.I_CLASS=1 and I.CONTAINER_NAME=? and I.PARENT_ID=? and"
- + " P.I_CLASS=2 and P.CONTAINER_NAME=? and P.PARENT_ID=I.ID and"
- + " (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or"
- + " P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or"
- + " P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or"
- + " P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
- + " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
-
- protected static final String FIND_PROPERTIES_BY_PARENTID_CQ_QUERY =
- "select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED, V.ORDER_NUM,"
- + " V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)"
- + " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? order by I.NAME";
-
- protected static final String FIND_ITEM_QPATH_BY_ID_CQ_QUERY =
- "select I.ID, I.PARENT_ID, I.NAME, I.I_INDEX"
- + " from JCR_SITEM I, (SELECT ID, PARENT_ID from JCR_SITEM where ID=?) J"
- + " where I.ID = J.ID or I.ID = J.PARENT_ID";
-
- protected static final String PATTERN_ESCAPE_STRING = "\\"; //valid for HSQL, Sybase, DB2, MSSQL, ORACLE
-
- /**
- * Singledatabase JDBC Connection constructor.
- *
- * @param dbConnection JDBC connection, shoudl be opened before
- * @param readOnly, boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName Workspace Storage Container name (see configuration)
- * @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).
- * @throws SQLException in case of database error
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
- */
- public SingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
- throws SQLException
- {
-
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getInternalId(final String identifier)
- {
- return containerName + identifier;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected String getIdentifier(final String internalId)
- {
-
- if (internalId == null) // possible for root parent
- return null;
-
- return internalId.substring(containerName.length());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void prepareQueries() throws SQLException
- {
-
- JCR_PK_ITEM = "JCR_PK_SITEM";
- JCR_FK_ITEM_PARENT = "JCR_FK_SITEM_PARENT";
- JCR_IDX_ITEM_PARENT = "JCR_IDX_SITEM_PARENT";
- JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_SITEM_PARENT_ID";
- JCR_PK_VALUE = "JCR_PK_SVALUE";
- JCR_FK_VALUE_PROPERTY = "JCR_FK_SVALUE_PROPERTY";
- JCR_IDX_VALUE_PROPERTY = "JCR_IDX_SVALUE_PROPERTY";
- JCR_PK_REF = "JCR_PK_SREF";
- JCR_IDX_REF_PROPERTY = "JCR_IDX_SREF_PROPERTY";
-
- FIND_ITEM_BY_ID = "select * from JCR_SITEM where ID=?";
-
- FIND_ITEM_BY_NAME =
- "select * from JCR_SITEM"
- + " where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
-
- FIND_PROPERTY_BY_NAME =
- "select V.DATA from JCR_SITEM I, JCR_SVALUE V"
- + " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? and I.NAME=? and"
- + " I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
-
- FIND_REFERENCES =
- "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME" + " from JCR_SREF R, JCR_SITEM P"
- + " where R.NODE_ID=? and P.CONTAINER_NAME=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2";
-
- FIND_VALUES_BY_PROPERTYID =
- "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? order by ORDER_NUM";
-
- FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=?";
-
- FIND_VALUE_BY_PROPERTYID_OREDERNUMB =
- "select DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? and ORDER_NUM=?";
-
- FIND_NODES_BY_PARENTID =
- "select * from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
-
- FIND_NODES_BY_PARENTID_CQ = FIND_NODES_BY_PARENTID_CQ_QUERY;
-
- FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
- "select I.NAME, V.DATA, V.ORDER_NUM from JCR_SITEM I, JCR_SVALUE V"
- + " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? 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') and I.ID=V.PROPERTY_ID";
-
- FIND_ITEM_QPATH_BY_ID_CQ = FIND_ITEM_QPATH_BY_ID_CQ_QUERY;
-
- FIND_LAST_ORDER_NUMBER_BY_PARENTID =
- "select count(*), max(N_ORDER_NUM) from JCR_SITEM where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
-
- FIND_NODES_COUNT_BY_PARENTID =
- "select count(ID) from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
-
- FIND_PROPERTIES_BY_PARENTID =
- "select * from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=?" + " order by NAME";
-
- FIND_PROPERTIES_BY_PARENTID_CQ = FIND_PROPERTIES_BY_PARENTID_CQ_QUERY;
- FIND_PROPERTIES_BY_PARENTID_AND_PATTERN_CQ_TEMPLATE =
- "select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE,"
- + " I.P_MULTIVALUED, V.ORDER_NUM, V.DATA, V.STORAGE_DESC"
- + " from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)";
-
- FIND_NODES_BY_PARENTID_AND_PATTERN_CQ_TEMPLATE =
- "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from JCR_SITEM I, JCR_SITEM P, JCR_SVALUE V";
-
- FIND_LOWEST_PROPERTY_VERSIONS =
- "select max(VERSION) as MAX_VERSION, PARENT_ID, NAME, CONTAINER_NAME, I_CLASS, I_INDEX from JCR_SITEM WHERE I_CLASS=2"
- + " GROUP BY PARENT_ID, CONTAINER_NAME, NAME, I_CLASS, I_INDEX HAVING count(VERSION) > 1";
-
- INSERT_NODE =
- "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,?,"
- + I_CLASS_NODE + ",?,?)";
- INSERT_PROPERTY =
- "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, P_TYPE, P_MULTIVALUED)"
- + " VALUES(?,?,?,?,?," + I_CLASS_PROPERTY + ",?,?,?)";
-
- INSERT_VALUE = "insert into JCR_SVALUE(DATA, ORDER_NUM, PROPERTY_ID, STORAGE_DESC) VALUES(?,?,?,?)";
- INSERT_REF = "insert into JCR_SREF(NODE_ID, PROPERTY_ID, ORDER_NUM) VALUES(?,?,?)";
-
- RENAME_NODE = "update JCR_SITEM set PARENT_ID=?, NAME=?, VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
-
- UPDATE_NODE = "update JCR_SITEM set VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
- UPDATE_PROPERTY = "update JCR_SITEM set VERSION=?, P_TYPE=? where ID=?";
-
- DELETE_ITEM = "delete from JCR_SITEM where ID=?";
- DELETE_VALUE = "delete from JCR_SVALUE where PROPERTY_ID=?";
- DELETE_REF = "delete from JCR_SREF where PROPERTY_ID=?";
-
- FIND_NODES_AND_PROPERTIES =
- "select J.*, P.ID AS P_ID, P.NAME AS P_NAME, P.VERSION AS P_VERSION, P.P_TYPE, P.P_MULTIVALUED,"
- + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from JCR_SVALUE V, JCR_SITEM P"
- + " join (select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_INDEX, I.N_ORDER_NUM from JCR_SITEM I"
- + " where I.CONTAINER_NAME=? AND I.I_CLASS=1 AND I.ID > ? order by I.ID LIMIT ? OFFSET ?) J on P.PARENT_ID = J.ID"
- + " where P.I_CLASS=2 and P.CONTAINER_NAME=? and V.PROPERTY_ID=P.ID order by J.ID";
-
- FIND_PROPERTY_BY_ID =
- "select I.P_TYPE, V.STORAGE_DESC from JCR_SITEM I, JCR_SVALUE V where I.ID = ? and V.PROPERTY_ID = I.ID";
- DELETE_VALUE_BY_ORDER_NUM = "delete from JCR_SVALUE where PROPERTY_ID=? and ORDER_NUM >= ?";
- UPDATE_VALUE = "update JCR_SVALUE set DATA=?, STORAGE_DESC=? where PROPERTY_ID=? and ORDER_NUM=?";
-
- FIND_NODES_BY_PARENTID_LAZILY_CQ =
- "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from JCR_SITEM I, JCR_SITEM P, JCR_SVALUE V"
- + " where I.I_CLASS=1 and I.CONTAINER_NAME=? and I.PARENT_ID=? and I.N_ORDER_NUM >= ? and "
- + " I.N_ORDER_NUM <= ? and P.I_CLASS=2 and P.CONTAINER_NAME=? and P.PARENT_ID=I.ID and"
- + " (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or"
- + " P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or"
- + " P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or"
- + " P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')"
- + " and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID";
-
- FIND_ACL_HOLDERS = "select I.PARENT_ID, I.P_TYPE"
- + " from JCR_SITEM I where I.I_CLASS=2 and I.CONTAINER_NAME=?"
- + " and (I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
- + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')";
-
- FIND_NODES_COUNT = "select count(*) from JCR_SITEM I where I.I_CLASS=1 and I.CONTAINER_NAME=?";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addNodeRecord(NodeData data) throws SQLException
- {
- if (insertNode == null)
- insertNode = dbConnection.prepareStatement(INSERT_NODE);
- else
- insertNode.clearParameters();
-
- insertNode.setString(1, getInternalId(data.getIdentifier()));
- // if root then parent identifier equals space string
- insertNode.setString(2, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : getInternalId(data
- .getParentIdentifier()));
- insertNode.setString(3, data.getQPath().getName().getAsString());
- insertNode.setString(4, containerName);
- insertNode.setInt(5, data.getPersistedVersion());
- insertNode.setInt(6, data.getQPath().getIndex());
- insertNode.setInt(7, data.getOrderNumber());
- return insertNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addPropertyRecord(PropertyData data) throws SQLException
- {
- if (insertProperty == null)
- insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
- else
- insertProperty.clearParameters();
-
- insertProperty.setString(1, getInternalId(data.getIdentifier()));
- insertProperty.setString(2, getInternalId(data.getParentIdentifier()));
- insertProperty.setString(3, data.getQPath().getName().getAsString());
- insertProperty.setString(4, containerName);
- insertProperty.setInt(5, data.getPersistedVersion());
- insertProperty.setInt(6, data.getQPath().getIndex());
- insertProperty.setInt(7, data.getType());
- insertProperty.setBoolean(8, data.isMultiValued());
-
- return insertProperty.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addReference(PropertyData data) throws SQLException, IOException
- {
- if (insertReference == null)
- insertReference = dbConnection.prepareStatement(INSERT_REF);
- else
- insertReference.clearParameters();
-
- List<ValueData> values = data.getValues();
- int added = 0;
- for (int i = 0; i < values.size(); i++)
- {
- ValueData vdata = values.get(i);
- String refNodeIdentifier = new String(vdata.getAsByteArray());
-
- insertReference.setString(1, getInternalId(refNodeIdentifier));
- insertReference.setString(2, getInternalId(data.getIdentifier()));
- insertReference.setInt(3, i);
- added += insertReference.executeUpdate();
- }
- return added;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteReference(String propertyCid) throws SQLException
- {
- if (deleteReference == null)
- deleteReference = dbConnection.prepareStatement(DELETE_REF);
- else
- deleteReference.clearParameters();
-
- deleteReference.setString(1, propertyCid);
- return deleteReference.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteItemByIdentifier(String cid) throws SQLException
- {
- if (deleteItem == null)
- deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
- else
- deleteItem.clearParameters();
-
- deleteItem.setString(1, cid);
- return deleteItem.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildNodesByParentIdentifier(String parentCid) throws SQLException
- {
- if (findNodesByParentId == null)
- findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
- else
- findNodesByParentId.clearParameters();
-
- findNodesByParentId.setString(1, containerName);
- findNodesByParentId.setString(2, parentCid);
- return findNodesByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier) throws SQLException
- {
- if (findLastOrderNumberByParentId == null)
- findLastOrderNumberByParentId = dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
- else
- findLastOrderNumberByParentId.clearParameters();
-
- findLastOrderNumberByParentId.setString(1, containerName);
- findLastOrderNumberByParentId.setString(2, parentIdentifier);
- return findLastOrderNumberByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws SQLException
- {
- if (findNodesCountByParentId == null)
- findNodesCountByParentId = dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
- else
- findNodesCountByParentId.clearParameters();
-
- findNodesCountByParentId.setString(1, containerName);
- findNodesCountByParentId.setString(2, parentCid);
- return findNodesCountByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildPropertiesByParentIdentifier(String parentCid) throws SQLException
- {
- if (findPropertiesByParentId == null)
- findPropertiesByParentId = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
- else
- findPropertiesByParentId.clearParameters();
-
- findPropertiesByParentId.setString(1, containerName);
- findPropertiesByParentId.setString(2, parentCid);
- return findPropertiesByParentId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findItemByName(String parentId, String name, int index) throws SQLException
- {
- if (findItemByName == null)
- findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
- else
- findItemByName.clearParameters();
-
- findItemByName.setString(1, containerName);
- findItemByName.setString(2, parentId);
- findItemByName.setString(3, name);
- findItemByName.setInt(4, index);
- return findItemByName.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findPropertyByName(String parentCid, String name) throws SQLException
- {
- if (findPropertyByName == null)
- findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
- else
- findPropertyByName.clearParameters();
-
- findPropertyByName.setString(1, containerName);
- findPropertyByName.setString(2, parentCid);
- findPropertyByName.setString(3, name);
- return findPropertyByName.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findItemByIdentifier(String cid) throws SQLException
- {
- if (findItemById == null)
- findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
- else
- findItemById.clearParameters();
-
- findItemById.setString(1, cid);
- return findItemById.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findReferences(String cid) throws SQLException
- {
- if (findReferences == null)
- findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
- else
- findReferences.clearParameters();
-
- findReferences.setString(1, cid);
- findReferences.setString(2, containerName);
- return findReferences.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int updateNodeByIdentifier(int version, int index, int orderNumb, String cid) throws SQLException
- {
- if (updateNode == null)
- updateNode = dbConnection.prepareStatement(UPDATE_NODE);
- else
- updateNode.clearParameters();
-
- updateNode.setInt(1, version);
- updateNode.setInt(2, index);
- updateNode.setInt(3, orderNumb);
- updateNode.setString(4, cid);
- return updateNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int updatePropertyByIdentifier(int version, int type, String cid) throws SQLException
- {
- if (updateProperty == null)
- updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
- else
- updateProperty.clearParameters();
-
- updateProperty.setInt(1, version);
- updateProperty.setInt(2, type);
- updateProperty.setString(3, cid);
- return updateProperty.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- protected ResultSet findChildNodesByParentIdentifier(String parentCid, int fromOrderNum, int toOrderNum)
- throws SQLException
- {
- if (findNodesByParentIdLazilyCQ == null)
- findNodesByParentIdLazilyCQ = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID_LAZILY_CQ);
- else
- findNodesByParentIdLazilyCQ.clearParameters();
-
- findNodesByParentIdLazilyCQ.setString(1, containerName);
- findNodesByParentIdLazilyCQ.setString(2, parentCid);
- findNodesByParentIdLazilyCQ.setInt(3, fromOrderNum);
- findNodesByParentIdLazilyCQ.setInt(4, toOrderNum);
- findNodesByParentIdLazilyCQ.setString(5, containerName);
-
- return findNodesByParentIdLazilyCQ.executeQuery();
- }
-
- // -------- values processing ------------
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addValueData(String cid, int orderNumber, InputStream stream, int streamLength, String storageDesc)
- throws SQLException
- {
- if (insertValue == null)
- insertValue = dbConnection.prepareStatement(INSERT_VALUE);
- else
- insertValue.clearParameters();
-
- if (stream == null)
- {
- // [PN] store vd reference to external storage etc.
- insertValue.setNull(1, Types.BINARY);
- insertValue.setString(4, storageDesc);
- }
- else
- {
- insertValue.setBinaryStream(1, stream, streamLength);
- insertValue.setNull(4, Types.VARCHAR);
- }
-
- insertValue.setInt(2, orderNumber);
- insertValue.setString(3, cid);
- return insertValue.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteValueData(String cid) throws SQLException
- {
- if (deleteValue == null)
- deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
- else
- deleteValue.clearParameters();
-
- deleteValue.setString(1, cid);
- return deleteValue.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findValuesByPropertyId(String cid) throws SQLException
- {
- if (findValuesByPropertyId == null)
- findValuesByPropertyId = dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
- else
- findValuesByPropertyId.clearParameters();
-
- findValuesByPropertyId.setString(1, cid);
- return findValuesByPropertyId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws SQLException
- {
- if (findValuesStorageDescriptorsByPropertyId == null)
- findValuesStorageDescriptorsByPropertyId =
- dbConnection.prepareStatement(FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID);
- else
- findValuesStorageDescriptorsByPropertyId.clearParameters();
-
- findValuesStorageDescriptorsByPropertyId.setString(1, cid);
- return findValuesStorageDescriptorsByPropertyId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws SQLException
- {
- if (findValueByPropertyIdOrderNumber == null)
- {
- findValueByPropertyIdOrderNumber = dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
- }
- else
- {
- findValueByPropertyIdOrderNumber.clearParameters();
- }
-
- findValueByPropertyIdOrderNumber.setString(1, cid);
- findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
- return findValueByPropertyIdOrderNumber.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int renameNode(NodeData data) throws SQLException
- {
- if (renameNode == null)
- renameNode = dbConnection.prepareStatement(RENAME_NODE);
- else
- renameNode.clearParameters();
-
- renameNode.setString(1, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : getInternalId(data
- .getParentIdentifier()));
- renameNode.setString(2, data.getQPath().getName().getAsString());
- renameNode.setInt(3, data.getPersistedVersion());
- renameNode.setInt(4, data.getQPath().getIndex());
- renameNode.setInt(5, data.getOrderNumber());
- renameNode.setString(6, getInternalId(data.getIdentifier()));
- return renameNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws SQLException
- {
- if (findNodesByParentIdCQ == null)
- findNodesByParentIdCQ = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID_CQ);
- else
- findNodesByParentIdCQ.clearParameters();
-
- findNodesByParentIdCQ.setString(1, containerName);
- findNodesByParentIdCQ.setString(2, parentIdentifier);
- findNodesByParentIdCQ.setString(3, containerName);
- return findNodesByParentIdCQ.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier, List<QPathEntryFilter> pattern)
- throws SQLException
- {
- if (pattern.isEmpty())
- {
- throw new SQLException("Pattern list is empty.");
- }
- else
- {
- if (findNodesByParentIdAndComplexPatternCQ == null)
- {
- findNodesByParentIdAndComplexPatternCQ = dbConnection.createStatement();
- }
- //create query from list
- StringBuilder query = new StringBuilder(FIND_NODES_BY_PARENTID_AND_PATTERN_CQ_TEMPLATE);
- query.append(" where I.I_CLASS=1 and I.CONTAINER_NAME='");
- query.append(containerName);
- query.append("' and I.PARENT_ID='");
- query.append(parentIdentifier);
- query.append("' and ( ");
- appendPattern(query, pattern.get(0).getQPathEntry(), true);
- for (int i = 1; i < pattern.size(); i++)
- {
- query.append(" or ");
- appendPattern(query, pattern.get(i).getQPathEntry(), true);
- }
- query.append(" ) and P.I_CLASS=2 and P.CONTAINER_NAME='");
- query.append(containerName);
- query.append("' and P.PARENT_ID=I.ID and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType'");
- query.append(" or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes'");
- query.append(" or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'");
- query.append(" or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')");
- query.append(" and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID");
-
- return findNodesByParentIdAndComplexPatternCQ.executeQuery(query.toString());
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
- {
- if (findPropertiesByParentIdCQ == null)
- findPropertiesByParentIdCQ = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID_CQ);
- else
- findPropertiesByParentIdCQ.clearParameters();
-
- findPropertiesByParentIdCQ.setString(1, containerName);
- findPropertiesByParentIdCQ.setString(2, parentIdentifier);
- return findPropertiesByParentIdCQ.executeQuery();
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildPropertiesByParentIdentifierCQ(String parentCid, List<QPathEntryFilter> pattern)
- throws SQLException
- {
- if (pattern.isEmpty())
- {
- throw new SQLException("Pattern list is empty.");
- }
- else
- {
- if (findPropertiesByParentIdAndComplexPatternCQ == null)
- {
- findPropertiesByParentIdAndComplexPatternCQ = dbConnection.createStatement();
- }
- //create query from list
- StringBuilder query = new StringBuilder(FIND_PROPERTIES_BY_PARENTID_AND_PATTERN_CQ_TEMPLATE);
- query.append(" where I.I_CLASS=2 and I.CONTAINER_NAME='");
- query.append(containerName);
- query.append("' and I.PARENT_ID='");
- query.append(parentCid);
- query.append("' and ( ");
- appendPattern(query, pattern.get(0).getQPathEntry(), false);
- for (int i = 1; i < pattern.size(); i++)
- {
- query.append(" or ");
- appendPattern(query, pattern.get(i).getQPathEntry(), false);
- }
- query.append(" ) order by I.NAME");
-
- return findPropertiesByParentIdAndComplexPatternCQ.executeQuery(query.toString());
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findNodeMainPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
- {
- if (findNodeMainPropertiesByParentIdentifierCQ == null)
- findNodeMainPropertiesByParentIdentifierCQ =
- dbConnection.prepareStatement(FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ);
- else
- findNodeMainPropertiesByParentIdentifierCQ.clearParameters();
-
- findNodeMainPropertiesByParentIdentifierCQ.setString(1, containerName);
- findNodeMainPropertiesByParentIdentifierCQ.setString(2, parentIdentifier);
- return findNodeMainPropertiesByParentIdentifierCQ.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findItemQPathByIdentifierCQ(String identifier) throws SQLException
- {
- if (findItemQPathByIdentifierCQ == null)
- findItemQPathByIdentifierCQ = dbConnection.prepareStatement(FIND_ITEM_QPATH_BY_ID_CQ);
- else
- findItemQPathByIdentifierCQ.clearParameters();
-
- findItemQPathByIdentifierCQ.setString(1, identifier);
- return findItemQPathByIdentifierCQ.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findNodesAndProperties(String lastNodeId, int offset, int limit) throws SQLException
- {
- if (findNodesAndProperties == null)
- {
- findNodesAndProperties = dbConnection.prepareStatement(FIND_NODES_AND_PROPERTIES);
- }
- else
- {
- findNodesAndProperties.clearParameters();
- }
-
- findNodesAndProperties.setString(1, containerName);
- findNodesAndProperties.setString(2, getInternalId(lastNodeId));
- findNodesAndProperties.setInt(3, limit);
- findNodesAndProperties.setInt(4, offset);
- findNodesAndProperties.setString(5, containerName);
-
- return findNodesAndProperties.executeQuery();
- }
-
- @Override
- protected int deleteValueDataByOrderNum(String id, int orderNum) throws SQLException
- {
- if (deleteValueDataByOrderNum == null)
- deleteValueDataByOrderNum = dbConnection.prepareStatement(DELETE_VALUE_BY_ORDER_NUM);
- else
- deleteValueDataByOrderNum.clearParameters();
-
- deleteValueDataByOrderNum.setString(1, id);
- deleteValueDataByOrderNum.setInt(2, orderNum);
- return deleteValueDataByOrderNum.executeUpdate();
- }
-
- @Override
- protected ResultSet findPropertyById(String id) throws SQLException
- {
- if (findPropertyById == null)
- findPropertyById = dbConnection.prepareStatement(FIND_PROPERTY_BY_ID);
- else
- findPropertyById.clearParameters();
-
- findPropertyById.setString(1, id);
- return findPropertyById.executeQuery();
- }
-
- @Override
- protected int updateValueData(String cid, int orderNumber, InputStream stream, int streamLength, String storageDesc)
- throws SQLException
- {
-
- if (updateValue == null)
- updateValue = dbConnection.prepareStatement(UPDATE_VALUE);
- else
- updateValue.clearParameters();
-
- if (stream == null)
- {
- // [PN] store vd reference to external storage etc.
- updateValue.setNull(1, Types.BINARY);
- updateValue.setString(2, storageDesc);
- }
- else
- {
- updateValue.setBinaryStream(1, stream, streamLength);
- updateValue.setNull(2, Types.VARCHAR);
- }
-
- updateValue.setString(3, cid);
- updateValue.setInt(4, orderNumber);
- return updateValue.executeUpdate();
- }
-
- /**
- * Replace underscore in pattern with escaped symbol. Replace jcr-wildcard '*' with sql-wildcard '%'.
- *
- * @param pattern
- * @return pattern with escaped underscore and fixed wildcard symbols
- */
- protected String fixEscapeSymbols(String pattern)
- {
- char[] chars = pattern.toCharArray();
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < chars.length; i++)
- {
- switch (chars[i])
- {
- case '*' :
- sb.append('%');
- break;
- case '_' :
- case '%' :
- sb.append(getWildcardEscapeSymbold());
- default :
- sb.append(chars[i]);
- }
- }
- return sb.toString();
- }
-
- /**
- * Append pattern expression.
- * Appends String "I.NAME LIKE 'escaped pattern' ESCAPE 'escapeString'" or "I.NAME='pattern'"
- * to String builder sb.
- *
- * @param sb StringBuilder
- * @param indexConstraint
- * @param pattern
- */
- protected void appendPattern(StringBuilder sb, QPathEntry entry, boolean indexConstraint)
- {
- String pattern = entry.getAsString(false);
- sb.append("(I.NAME");
- if (pattern.contains("*"))
- {
- sb.append(" LIKE '");
- sb.append(fixEscapeSymbols(pattern));
- sb.append("' ESCAPE '");
- sb.append(getLikeExpressionEscape());
- sb.append("'");
- }
- else
- {
- sb.append("='");
- sb.append(pattern);
- sb.append("'");
- }
-
- if (indexConstraint && entry.getIndex() != -1)
- {
- sb.append(" and I.I_INDEX=");
- sb.append(entry.getIndex());
- }
- sb.append(")");
- }
-
- protected String getWildcardEscapeSymbold()
- {
- return PATTERN_ESCAPE_STRING;
- }
-
- protected String getLikeExpressionEscape()
- {
- return PATTERN_ESCAPE_STRING;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findACLHolders() throws SQLException
- {
- if (findACLHolders == null)
- {
- findACLHolders = dbConnection.prepareStatement(FIND_ACL_HOLDERS);
- }
- else
- {
- findACLHolders.clearParameters();
- }
-
- findACLHolders.setString(1, containerName);
-
- return findACLHolders.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- protected void deleteLockProperties() throws SQLException
- {
- PreparedStatement removeValuesStatement = null;
- PreparedStatement removeItemsStatement = null;
-
- try
- {
- removeValuesStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_SVALUE WHERE PROPERTY_ID IN (SELECT ID FROM JCR_SITEM"
- + " WHERE CONTAINER_NAME = ? AND (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
- + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
- removeValuesStatement.setString(1, containerName);
-
- removeItemsStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_SITEM WHERE CONTAINER_NAME = ? AND"
- + " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
- + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
- removeItemsStatement.setString(1, containerName);
-
- removeValuesStatement.executeUpdate();
- removeItemsStatement.executeUpdate();
- }
- finally
- {
- if (removeValuesStatement != null)
- {
- try
- {
- removeValuesStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
-
- if (removeItemsStatement != null)
- {
- try
- {
- removeItemsStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findNodesCount() throws SQLException
- {
- if (findNodesCount == null)
- {
- findNodesCount = dbConnection.prepareStatement(FIND_NODES_COUNT);
- }
- else
- {
- findNodesCount.clearParameters();
- }
-
- findNodesCount.setString(1, containerName);
-
- return findNodesCount.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- protected void deleteLockProperties(String nodeIdentifier) throws SQLException
- {
- PreparedStatement removeValuesStatement = null;
- PreparedStatement removeItemsStatement = null;
-
- try
- {
- removeValuesStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_SVALUE WHERE PROPERTY_ID IN (SELECT ID FROM JCR_SITEM"
- + " WHERE CONTAINER_NAME = ? AND PARENT_ID=? AND (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
- + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
- removeValuesStatement.setString(1, containerName);
- removeValuesStatement.setString(2, getInternalId(nodeIdentifier));
-
- removeItemsStatement =
- dbConnection.prepareStatement("DELETE FROM JCR_SITEM WHERE CONTAINER_NAME = ? AND PARENT_ID=? AND"
- + " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
- + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
- removeItemsStatement.setString(1, containerName);
- removeItemsStatement.setString(2, getInternalId(nodeIdentifier));
-
- removeValuesStatement.executeUpdate();
- removeItemsStatement.executeUpdate();
- }
- finally
- {
- if (removeValuesStatement != null)
- {
- try
- {
- removeValuesStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
-
- if (removeItemsStatement != null)
- {
- try
- {
- removeItemsStatement.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close statement", e);
- }
- }
- }
- }
-}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseConnectionFactory.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseConnectionFactory.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SybaseConnectionFactory.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -19,11 +19,8 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import java.io.File;
import java.sql.SQLException;
import javax.jcr.RepositoryException;
@@ -41,14 +38,6 @@
{
/**
- * SybaseConnectionFactory constructor.
- */
- public SybaseConnectionFactory(JDBCDataContainerConfig containerConfig) throws RepositoryException
- {
- super(containerConfig);
- }
-
- /**
* SybaseConnectionFactory constructor.
*/
public SybaseConnectionFactory(DataSource dbDataSource, JDBCDataContainerConfig containerConfig)
@@ -64,7 +53,7 @@
{
try
{
- if (this.containerConfig.dbStructureType.isSimpleTable())
+ if (this.containerConfig.dbStructureType.isMultiDatabase())
{
return new SybaseMultiDbJDBCConnection(getJdbcConnection(readOnly), readOnly, containerConfig);
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -18,15 +18,13 @@
*/
package org.exoplatform.services.jcr.impl.util.jdbc;
-import org.exoplatform.commons.utils.IOUtil;
-import org.exoplatform.commons.utils.PrivilegedFileHelper;
import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.services.database.utils.JDBCUtils;
+import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
@@ -52,17 +50,17 @@
static public String SQL_CREATEVIEW = "^(CREATE(\\s)+VIEW(\\s)+(IF(\\s)+NOT(\\s)+EXISTS(\\s)+)*){1}";
- static public String SQL_OBJECTNAME = "((JCR_[A-Z_]+){1}(\\s*?|(\\(\\))*?)+)+?";
+ static public String SQL_OBJECTNAME = "((JCR_[A-Z_0-9]+){1}(\\s*?|(\\(\\))*?)+)+?";
static public String SQL_CREATEINDEX = "^(CREATE(\\s)+(UNIQUE(\\s)+)*INDEX(\\s)+){1}";
- static public String SQL_ONTABLENAME = "(ON(\\s)+(JCR_[A-Z_]+){1}(\\s*?|(\\(\\))*?)+){1}";
+ static public String SQL_ONTABLENAME = "(ON(\\s)+(JCR_[A-Z_0-9]+){1}(\\s*?|(\\(\\))*?)+){1}";
static public String SQL_CREATESEQUENCE = "^(CREATE(\\s)+SEQUENCE(\\s)+){1}";
static public String SQL_CREATETRIGGER = "^(CREATE(\\s)+(OR(\\s){1}REPLACE(\\s)+)*TRIGGER(\\s)+){1}";
- static public String SQL_TRIGGERNAME = "(([A-Z_]+JCR_[A-Z_]+){1}(\\s*?|(\\(\\))*?)+)+?";
+ static public String SQL_TRIGGERNAME = "(([A-Z_]+JCR_[A-Z_0-9]+){1}(\\s*?|(\\(\\))*?)+)+?";
protected static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.DBInitializer");
@@ -92,7 +90,7 @@
{
this.connection = connection;
this.containerConfig = containerConfig;
- this.script = prepareScripts();
+ this.script = DBInitializerHelper.prepareScripts(containerConfig);
this.creatTablePattern = Pattern.compile(SQL_CREATETABLE, Pattern.CASE_INSENSITIVE);
this.creatViewPattern = Pattern.compile(SQL_CREATEVIEW, Pattern.CASE_INSENSITIVE);
this.dbObjectNamePattern = Pattern.compile(SQL_OBJECTNAME, Pattern.CASE_INSENSITIVE);
@@ -103,11 +101,6 @@
this.dbTriggerNamePattern = Pattern.compile(SQL_TRIGGERNAME, Pattern.CASE_INSENSITIVE);
}
- protected String prepareScripts() throws IOException
- {
- return IOUtil.getStreamContentAsString(PrivilegedFileHelper.getResourceAsStream(containerConfig.initScriptPath));
- }
-
protected boolean isTableExists(final Connection conn, final String tableName) throws SQLException
{
return SecurityHelper.doPrivilegedAction(new PrivilegedAction<Boolean>()
@@ -352,9 +345,18 @@
}
/**
- * Place to perform additional operations in overriden classes.
+ * Init root node parent record.
*/
protected void postInit(Connection connection) throws SQLException
{
+ String select =
+ "select * from " + DBInitializerHelper.getItemTableName(containerConfig) + " where ID='"
+ + Constants.ROOT_PARENT_UUID + "' and PARENT_ID='" + Constants.ROOT_PARENT_UUID + "'";
+
+ if (!connection.createStatement().executeQuery(select).next())
+ {
+ String insert = DBInitializerHelper.getRootNodeInitializeScript(containerConfig);
+ connection.createStatement().executeUpdate(insert);
+ }
}
}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializerHelper.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -18,11 +18,15 @@
import org.exoplatform.commons.utils.IOUtil;
import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.services.database.utils.DialectConstants;
import org.exoplatform.services.database.utils.JDBCUtils;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -44,45 +48,102 @@
protected final static Log LOG = ExoLogger.getLogger("exo.jcr.component.core.DBInitializerHelper");
/**
- * Getting path to initialization by specific dialect and multidb.
+ * Table prefix for all tables used in JCR.
+ */
+ public static final String JCR_TABLE_PREFIX = "JCR_";
+
+ /**
+ * Returns SQL scripts for initialization database for defined {@link JDBCDataContainerConfig}.
+ */
+ public static String prepareScripts(JDBCDataContainerConfig containerConfig) throws IOException
+ {
+ String itemTableSuffix = getItemTableSuffix(containerConfig);
+ String valueTableSuffix = getValueTableSuffix(containerConfig);
+ String refTableSuffix = getRefTableSuffix(containerConfig);
+
+ boolean isolatedDB = containerConfig.dbStructureType == DatabaseStructureType.ISOLATED;
+
+ return prepareScripts(containerConfig.initScriptPath, itemTableSuffix, valueTableSuffix, refTableSuffix, isolatedDB);
+ }
+
+ /**
+ * Returns SQL scripts for initialization database for defined {@link WorkspaceEntry}.
*
- * @param dbDialect
- * String
- * @param multiDb
- * Boolean
- * @return String
- * Path to DB initialization script.
+ * @param wsEntry
+ * workspace configuration
+ * @param dialect
+ * database dialect which is used, since {@link JDBCWorkspaceDataContainer#DB_DIALECT} parameter
+ * can contain {@link DialectConstants#DB_DIALECT_AUTO} value it is necessary to resolve dialect
+ * before based on database connection.
*/
+ public static String prepareScripts(WorkspaceEntry wsEntry, String dialect) throws IOException,
+ RepositoryConfigurationException
+ {
+ String itemTableSuffix = getItemTableSuffix(wsEntry);
+ String valueTableSuffix = getValueTableSuffix(wsEntry);
+ String refTableSuffix = getRefTableSuffix(wsEntry);
+
+ DatabaseStructureType dbType = JDBCWorkspaceDataContainer.getDatabaseType(wsEntry);
+
+ boolean isolatedDB = dbType == DatabaseStructureType.ISOLATED;
+ String initScriptPath = DBInitializerHelper.scriptPath(dialect, dbType.isMultiDatabase());
+
+ return prepareScripts(initScriptPath, itemTableSuffix, valueTableSuffix, refTableSuffix, isolatedDB);
+ }
+
+ /**
+ * Preparing SQL scripts for database initialization.
+ */
+ private static String prepareScripts(String initScriptPath, String itemTableSuffix, String valueTableSuffix,
+ String refTableSuffix, boolean isolatedDB) throws IOException
+ {
+ String scripts = IOUtil.getStreamContentAsString(PrivilegedFileHelper.getResourceAsStream(initScriptPath));
+
+ if (isolatedDB)
+ {
+ scripts =
+ scripts.replace("MITEM", itemTableSuffix).replace("MVALUE", valueTableSuffix)
+ .replace("MREF", refTableSuffix);
+ }
+
+ return scripts;
+ }
+
+ /**
+ * Returns path where SQL scripts for database initialization is stored.
+ */
public static String scriptPath(String dbDialect, boolean multiDb)
{
+ String suffix = multiDb ? "m" : "s";
+
String sqlPath = null;
if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLEOCI))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.ora.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLE))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.ora.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_PGSQL))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.pgsql.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.pgsql.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.mysql.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL_MYISAM))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql-myisam.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.mysql-myisam.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL_UTF8))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql-utf8.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.mysql-utf8.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MYSQL_MYISAM_UTF8))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql-myisam-utf8.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.mysql-myisam-utf8.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_MSSQL))
{
@@ -90,111 +151,163 @@
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_DERBY))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.derby.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.derby.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_DB2))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.db2.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.db2.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_DB2V8))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.db2v8.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.db2v8.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_SYBASE))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sybase.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.sybase.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_INGRES))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ingres.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.ingres.sql";
}
else if (dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_HSQLDB))
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.sql";
}
else
{
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sql";
+ sqlPath = "/conf/storage/jcr-" + suffix + "jdbc.sql";
}
return sqlPath;
}
/**
- * Initialization script for root node.
- *
+ * Initialization script for root node based on {@link JDBCDataContainerConfig}.
*/
public static String getRootNodeInitializeScript(JDBCDataContainerConfig containerConfig)
{
- // no ContainerNamer required
- boolean simpleTable = containerConfig.dbStructureType.isSimpleTable();
+ boolean multiDb = containerConfig.dbStructureType.isMultiDatabase();
+ String itemTableName = getItemTableName(containerConfig);
- return "insert into JCR_" + getTableSuffix(containerConfig) + "(ID, PARENT_ID, NAME, "
- + (simpleTable ? "" : "CONTAINER_NAME, ") + "VERSION, I_CLASS, I_INDEX, N_ORDER_NUM)" + " VALUES('"
- + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_NAME
- + "', " + (simpleTable ? "" : "'" + Constants.ROOT_PARENT_CONAINER_NAME + "', ") + "0, 0, 0, 0)";
+ return getRootNodeInitializeScript(itemTableName, multiDb);
}
/**
* Initialization script for root node.
- *
- * @param multiDb
- * indicates if we have multi-db configuration or not
- * @return SQL script
*/
- @Deprecated
- public static String getRootNodeInitializeScript(boolean multiDb)
+ public static String getRootNodeInitializeScript(String itemTableName, boolean multiDb)
{
- return "insert into JCR_" + (multiDb ? "M" : "S") + "ITEM(ID, PARENT_ID, NAME, "
- + (multiDb ? "" : "CONTAINER_NAME, ") + "VERSION, I_CLASS, I_INDEX, N_ORDER_NUM)" + " VALUES('"
- + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_NAME
- + "', " + (multiDb ? "" : "'" + Constants.ROOT_PARENT_CONAINER_NAME + "', ") + "0, 0, 0, 0)";
+ String singeDbScript =
+ "insert into " + itemTableName + "(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, "
+ + "N_ORDER_NUM) VALUES('" + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_UUID + "', '"
+ + Constants.ROOT_PARENT_NAME + "', '" + Constants.ROOT_PARENT_CONAINER_NAME + "', 0, 0, 0, 0)";
+
+ String multiDbScript =
+ "insert into " + itemTableName + "(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, " + "N_ORDER_NUM) VALUES('"
+ + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_UUID + "', '" + Constants.ROOT_PARENT_NAME
+ + "', 0, 0, 0, 0)";
+
+ return multiDb ? multiDbScript : singeDbScript;
}
- public static String getTableSuffix(JDBCDataContainerConfig containerConfig)
+ public static String getItemTableSuffix(WorkspaceEntry wsConfig) throws RepositoryConfigurationException
{
+ return getTableSuffix(JDBCWorkspaceDataContainer.getDatabaseType(wsConfig),
+ JDBCWorkspaceDataContainer.getDBTableSuffix(wsConfig), "ITEM");
+ }
+
+ public static String getValueTableSuffix(WorkspaceEntry wsConfig) throws RepositoryConfigurationException
+ {
+ return getTableSuffix(JDBCWorkspaceDataContainer.getDatabaseType(wsConfig),
+ JDBCWorkspaceDataContainer.getDBTableSuffix(wsConfig), "VALUE");
+ }
+
+ public static String getRefTableSuffix(WorkspaceEntry wsConfig) throws RepositoryConfigurationException
+ {
+ return getTableSuffix(JDBCWorkspaceDataContainer.getDatabaseType(wsConfig),
+ JDBCWorkspaceDataContainer.getDBTableSuffix(wsConfig), "REF");
+ }
+
+ public static String getItemTableName(WorkspaceEntry wsConfig) throws RepositoryConfigurationException
+ {
+ return JCR_TABLE_PREFIX
+ + getTableSuffix(JDBCWorkspaceDataContainer.getDatabaseType(wsConfig),
+ JDBCWorkspaceDataContainer.getDBTableSuffix(wsConfig), "ITEM");
+ }
+
+ public static String getValueTableName(WorkspaceEntry wsConfig) throws RepositoryConfigurationException
+ {
+ return JCR_TABLE_PREFIX
+ + getTableSuffix(JDBCWorkspaceDataContainer.getDatabaseType(wsConfig),
+ JDBCWorkspaceDataContainer.getDBTableSuffix(wsConfig), "VALUE");
+ }
+
+ public static String getRefTableName(WorkspaceEntry wsConfig) throws RepositoryConfigurationException
+ {
+ return JCR_TABLE_PREFIX
+ + getTableSuffix(JDBCWorkspaceDataContainer.getDatabaseType(wsConfig),
+ JDBCWorkspaceDataContainer.getDBTableSuffix(wsConfig), "REF");
+ }
+
+ public static String getItemTableSuffix(JDBCDataContainerConfig containerConfig)
+ {
+ return getTableSuffix(containerConfig.dbStructureType, containerConfig.dbTableSuffix, "ITEM");
+ }
+
+ public static String getValueTableSuffix(JDBCDataContainerConfig containerConfig)
+ {
+ return getTableSuffix(containerConfig.dbStructureType, containerConfig.dbTableSuffix, "VALUE");
+ }
+
+ public static String getRefTableSuffix(JDBCDataContainerConfig containerConfig)
+ {
+ return getTableSuffix(containerConfig.dbStructureType, containerConfig.dbTableSuffix, "REF");
+ }
+
+ public static String getItemTableName(JDBCDataContainerConfig containerConfig)
+ {
+ return JCR_TABLE_PREFIX + getTableSuffix(containerConfig.dbStructureType, containerConfig.dbTableSuffix, "ITEM");
+ }
+
+ public static String getValueTableName(JDBCDataContainerConfig containerConfig)
+ {
+ return JCR_TABLE_PREFIX + getTableSuffix(containerConfig.dbStructureType, containerConfig.dbTableSuffix, "VALUE");
+ }
+
+ public static String getRefTableName(JDBCDataContainerConfig containerConfig)
+ {
+ return JCR_TABLE_PREFIX + getTableSuffix(containerConfig.dbStructureType, containerConfig.dbTableSuffix, "REF");
+ }
+
+ private static String getTableSuffix(JDBCDataContainerConfig.DatabaseStructureType dbType, String dbTableSuffix,
+ String forTable)
+ {
String tableSuffix = "";
- switch (containerConfig.dbStructureType)
+ switch (dbType)
{
case MULTI :
- tableSuffix = "MITEM";
+ tableSuffix = "M" + forTable;
break;
case SINGLE :
- tableSuffix = "SITEM";
+ tableSuffix = "S" + forTable;
break;
case ISOLATED :
- tableSuffix = "I" + containerConfig.dbTableSuffix;
+ tableSuffix = forTable.substring(0, 1) + dbTableSuffix;
break;
}
return tableSuffix;
}
- public static String getScriptAsString(String dbDialect, boolean multiDb) throws IOException
- {
- String scriptsPath = DBInitializerHelper.scriptPath(dbDialect, multiDb);
- return IOUtil.getStreamContentAsString(PrivilegedFileHelper.getResourceAsStream(scriptsPath));
- }
-
/**
- * Get script for creating object (index, etc...)
- * @throws RepositoryConfigurationException
+ * Returns SQL script for create objects such as index, primary of foreign key.
*/
- public static String getObjectScript(String objectName, boolean multiDb, String dialect)
- throws RepositoryConfigurationException
+ public static String getObjectScript(String objectName, boolean multiDb, String dialect, WorkspaceEntry wsEntry)
+ throws RepositoryConfigurationException, IOException
{
- String scriptsPath = DBInitializerHelper.scriptPath(dialect, multiDb);
- String script;
- try
- {
- script = IOUtil.getStreamContentAsString(PrivilegedFileHelper.getResourceAsStream(scriptsPath));
- }
- catch (IOException e)
- {
- throw new RepositoryConfigurationException("Can not read script file " + scriptsPath, e);
- }
+ String scripts = prepareScripts(wsEntry, dialect);
String sql = null;
- for (String query : JDBCUtils.splitWithSQLDelimiter(script))
+ for (String query : JDBCUtils.splitWithSQLDelimiter(scripts))
{
String q = JDBCUtils.cleanWhitespaces(query);
if (q.contains(objectName))
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSVNodeDataOptimization.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -258,7 +258,7 @@
try
{
DatabaseStructureType databaseType = JDBCWorkspaceDataContainer.getDatabaseType(ws1e);
- return !databaseType.isSingleDatabase();
+ return databaseType.isMultiDatabase();
}
catch (RepositoryConfigurationException e)
{
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestWorkspaceRestore.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.ManageableRepository;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.util.TesterConfigurationHelper;
import java.io.BufferedInputStream;
@@ -57,7 +58,7 @@
super.setUp();
wsEntry = (WorkspaceEntry)session.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
- isDefaultWsMultiDb = "true".equals(wsEntry.getContainer().getParameterValue("multi-db"));
+ isDefaultWsMultiDb = JDBCWorkspaceDataContainer.getDatabaseType(wsEntry).isMultiDatabase();
}
public void testRestore() throws RepositoryConfigurationException, Exception
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -19,7 +19,7 @@
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCConnectionTestBase;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
-import org.exoplatform.services.jcr.impl.storage.jdbc.init.StorageDBInitializer;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import java.sql.SQLException;
import java.sql.Statement;
@@ -43,7 +43,7 @@
containerConfig.initScriptPath = scriptPath;
containerConfig.dbStructureType = multiDB ? DatabaseStructureType.MULTI : DatabaseStructureType.SINGLE;
containerConfig.multiDb = multiDB;
- new StorageDBInitializer(getJNDIConnection(), containerConfig).init();
+ new DBInitializer(getJNDIConnection(), containerConfig).init();
}
@Override
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -19,7 +19,7 @@
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCConnectionTestBase;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCDataContainerConfig.DatabaseStructureType;
-import org.exoplatform.services.jcr.impl.storage.jdbc.init.StorageDBInitializer;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import java.sql.SQLException;
import java.sql.Statement;
@@ -43,7 +43,7 @@
containerConfig.initScriptPath = scriptPath;
containerConfig.dbStructureType = multiDB ? DatabaseStructureType.MULTI : DatabaseStructureType.SINGLE;
containerConfig.multiDb = multiDB;
- new StorageDBInitializer(getJNDIConnection(), containerConfig).init();
+ new DBInitializer(getJNDIConnection(), containerConfig).init();
}
@Override
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/export/ExportWorkspaceSystemViewTest.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -163,7 +163,7 @@
try
{
DatabaseStructureType databaseType = JDBCWorkspaceDataContainer.getDatabaseType(ws1e);
- return !databaseType.isSingleDatabase();
+ return databaseType.isMultiDatabase();
}
catch (RepositoryConfigurationException e)
{
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingRepositorySameConfigRestore.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -91,8 +91,7 @@
// define one common database cleaner for all restores for single db case
DBCleanerTool dbCleaner = null;
- Boolean isMultiDb =
- Boolean.parseBoolean(wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.MULTIDB));
+ Boolean isMultiDb = JDBCWorkspaceDataContainer.getDatabaseType(wsEntry).isMultiDatabase();
if (!isMultiDb)
{
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceSameConfigRestore.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceSameConfigRestore.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistingWorkspaceSameConfigRestore.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -30,6 +30,7 @@
import org.exoplatform.services.jcr.impl.backup.JCRRestore;
import org.exoplatform.services.jcr.impl.backup.rdbms.DataRestoreContext;
import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.impl.util.io.FileCleanerHolder;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -78,7 +79,7 @@
{
ManageableRepository repository = repositoryService.getRepository(repositoryName);
- if (wEntry.getContainer().getParameterBoolean("multi-db") == false)
+ if (!JDBCWorkspaceDataContainer.getDatabaseType(wEntry).isMultiDatabase())
{
for (String wsName : repository.getWorkspaceNames())
{
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/RdbmsWorkspaceInitializer.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/RdbmsWorkspaceInitializer.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/RdbmsWorkspaceInitializer.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -35,6 +35,7 @@
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeManagerImpl;
import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
import org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.impl.util.io.FileCleanerHolder;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -104,7 +105,7 @@
try
{
// set state SUSPENDED to other workspaces if singledb
- if (workspaceEntry.getContainer().getParameterBoolean("multi-db") == false)
+ if (!JDBCWorkspaceDataContainer.getDatabaseType(workspaceEntry).isMultiDatabase())
{
for (WorkspaceEntry we : repositoryEntry.getWorkspaceEntries())
{
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/usecase/TestBackupRestore.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/usecase/TestBackupRestore.java 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/usecase/TestBackupRestore.java 2012-03-14 13:28:03 UTC (rev 5863)
@@ -45,6 +45,7 @@
import org.exoplatform.services.jcr.impl.core.SessionImpl;
import org.exoplatform.services.jcr.impl.core.SessionRegistry;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerHelper;
import java.io.File;
import java.sql.Connection;
@@ -883,7 +884,9 @@
ManageableRepository repository = repositoryService.getRepository(repositoryName);
for (WorkspaceEntry wsEntry : repository.getConfiguration().getWorkspaceEntries())
{
- String multiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB) ? "M" : "S";
+ String itemTableName = DBInitializerHelper.getItemTableName(wsEntry);
+ String valueTableName = DBInitializerHelper.getValueTableName(wsEntry);
+ String refTableName = DBInitializerHelper.getRefTableName(wsEntry);
DataSource ds =
(DataSource)new InitialContext().lookup(wsEntry.getContainer().getParameterValue(
@@ -891,7 +894,7 @@
Connection conn = ds.getConnection();
try
{
- ResultSet result = conn.createStatement().executeQuery("SELECT COUNT(*) FROM JCR_" + multiDb + "ITEM");
+ ResultSet result = conn.createStatement().executeQuery("SELECT COUNT(*) FROM " + itemTableName);
try
{
assertTrue(result.next());
@@ -902,7 +905,7 @@
result.close();
}
- result = conn.createStatement().executeQuery("SELECT COUNT(*) FROM JCR_" + multiDb + "VALUE");
+ result = conn.createStatement().executeQuery("SELECT COUNT(*) FROM " + valueTableName);
try
{
assertTrue(result.next());
@@ -913,7 +916,7 @@
result.close();
}
- result = conn.createStatement().executeQuery("SELECT COUNT(*) FROM JCR_" + multiDb + "REF");
+ result = conn.createStatement().executeQuery("SELECT COUNT(*) FROM " + refTableName);
try
{
assertTrue(result.next());
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config-backup.xml 2012-03-14 13:28:03 UTC (rev 5863)
@@ -29,7 +29,7 @@
<container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr6" />
- <property name="multi-db" value="false" />
+ <property name="db-structure-type" value="single" />
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/db3ws" />
</properties>
@@ -81,7 +81,7 @@
<container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr6" />
- <property name="multi-db" value="false" />
+ <property name="db-structure-type" value="single" />
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/db3ws1" />
</properties>
@@ -140,7 +140,7 @@
<container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr7" />
- <property name="multi-db" value="true" />
+ <property name="db-structure-type" value="isolated" />
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/db4ws" />
</properties>
@@ -192,7 +192,7 @@
<container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr8" />
- <property name="multi-db" value="true" />
+ <property name="db-structure-type" value="isolated" />
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/db4ws1" />
</properties>
Modified: jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.ext/src/test/resources/conf/standalone/test-jcr-ext-config.xml 2012-03-14 13:28:03 UTC (rev 5863)
@@ -321,7 +321,7 @@
<container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr6" />
- <property name="multi-db" value="false" />
+ <property name="db-structure-type" value="single" />
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/db3ws" />
</properties>
@@ -373,7 +373,7 @@
<container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr6" />
- <property name="multi-db" value="false" />
+ <property name="db-structure-type" value="single" />
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/db3ws1" />
</properties>
@@ -432,7 +432,7 @@
<container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr7" />
- <property name="multi-db" value="true" />
+ <property name="db-structure-type" value="isolated" />
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/db4ws" />
</properties>
@@ -484,7 +484,7 @@
<container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr8" />
- <property name="multi-db" value="true" />
+ <property name="db-structure-type" value="isolated" />
<property name="max-buffer-size" value="200k" />
<property name="swap-directory" value="target/temp/swap/db4ws1" />
</properties>
Modified: jcr/branches/1.15.x/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml 2012-03-14 09:31:09 UTC (rev 5862)
+++ jcr/branches/1.15.x/exo.jcr.component.ftp/src/test/resources/conf/standalone/test-jcr-config.xml 2012-03-14 13:28:03 UTC (rev 5863)
@@ -29,8 +29,8 @@
<!-- for system storage -->
<container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
- <property name="sourceName" value="jdbcjcr" />
- <property name="dialect" value="generic" />
+ <property name="source-name" value="jdbcjcr" />
+ <property name="dialect" value="auto" />
<property name="multi-db" value="false" />
<property name="max-buffer-size" value="204800" />
<property name="swap-directory" value="target/temp/swap/ws" />
@@ -68,8 +68,8 @@
<!-- for system storage -->
<container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
<properties>
- <property name="sourceName" value="jdbcjcr" />
- <property name="dialect" value="generic" />
+ <property name="source-name" value="jdbcjcr" />
+ <property name="dialect" value="auto" />
<property name="multi-db" value="false" />
<property name="max-buffer-size" value="204800" />
<property name="swap-directory" value="target/temp/swap/ws2" />
14 years, 1 month
exo-jcr SVN: r5862 - jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2012-03-14 05:31:09 -0400 (Wed, 14 Mar 2012)
New Revision: 5862
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
Log:
EXOJCR-1803 : changing asserts and logging events
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2012-03-14 09:05:40 UTC (rev 5861)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2012-03-14 09:31:09 UTC (rev 5862)
@@ -487,42 +487,61 @@
try
{
- // if "from-coordinator" used along with RPC Service present and
- if (handler.getIndexRecoveryMode().equals(SearchIndex.INDEX_RECOVERY_MODE_FROM_COORDINATOR)
- && handler.getContext().getIndexRecovery() != null && handler.getContext().getRPCService() != null
- && handler.getContext().getRPCService().isCoordinator() == false)
+ // isRecoveryFilterUsed returns true only if LocalIndex strategy used
+ if (handler.getContext().isRecoveryFilterUsed())
{
- LOG.info("Retrieving index from coordinator (" + handler.getContext().getWorkspacePath(true) + ")...");
- indexCreated = recoveryIndexFromCoordinator();
-
- if (indexCreated)
+ // if "from-coordinator" index recovery configured
+ if (SearchIndex.INDEX_RECOVERY_MODE_FROM_COORDINATOR.equals(handler.getIndexRecoveryMode()))
{
- indexNames.read();
- refreshIndexList();
- }
- else
- {
- LOG.info("Index can'b be retrieved from coordinator now, because it is offline. "
- + "Possibly coordinator node performs reindexing now. Switching to local re-indexing.");
- }
- }
+ if (handler.getContext().getIndexRecovery() != null && handler.getContext().getRPCService() != null
+ && !handler.getContext().getRPCService().isCoordinator())
+ {
+ LOG.info("Retrieving index from coordinator (" + handler.getContext().getWorkspacePath(true)
+ + ")...");
+ indexCreated = recoveryIndexFromCoordinator();
- if (!indexCreated)
- {
- if (handler.getIndexRecoveryMode().equals(SearchIndex.INDEX_RECOVERY_MODE_FROM_COORDINATOR))
- {
- if (handler.getContext().getRPCService() == null)
- {
- LOG.error("RPC Service is not configured but required for copying the index "
- + "from coordinator node. Index will be created by re-indexing.");
+ if (indexCreated)
+ {
+ indexNames.read();
+ refreshIndexList();
+ }
+ else
+ {
+ LOG.info("Index can'b be retrieved from coordinator now, because it is offline. "
+ + "Possibly coordinator node performs reindexing now. Switching to local re-indexing.");
+ }
}
- else if (handler.getContext().getRPCService().isCoordinator() == true)
+ else
{
- LOG.info("Copying the index from coordinator configured, but this node is the "
- + "only one in a cluster. Index will be created by re-indexing.");
+ if (handler.getContext().getRPCService() == null)
+ {
+ // logging an event, when RPCService is not configured in clustered mode
+ LOG.error("RPC Service is not configured but required for copying the index "
+ + "from coordinator node. Index will be created by re-indexing.");
+ }
+ else
+ {
+ if (handler.getContext().getIndexRecovery() == null)
+ {
+ // Should never occurs, but logging an event, when RPCService configured, but IndexRecovery
+ // instance is missing
+ LOG.error("Instance of IndexRecovery class is missing for unknown reason. Index will be"
+ + " created by re-indexing.");
+ }
+ if (handler.getContext().getRPCService().isCoordinator())
+ {
+ // logging an event when first node starts
+ LOG.info("Copying the index from coordinator configured, but this node is the "
+ + "only one in a cluster. Index will be created by re-indexing.");
+ }
+ }
}
}
+ }
+ if (!indexCreated)
+ {
+
// traverse and index workspace
executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
14 years, 1 month
exo-jcr SVN: r5861 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2012-03-14 05:05:40 -0400 (Wed, 14 Mar 2012)
New Revision: 5861
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
Log:
EXOJCR-1803 : changing asserts and logging events
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2012-03-13 17:01:38 UTC (rev 5860)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2012-03-14 09:05:40 UTC (rev 5861)
@@ -462,42 +462,60 @@
try
{
- // if "from-coordinator" used along with RPC Service present and
- if (handler.getIndexRecoveryMode().equals(SearchIndex.INDEX_RECOVERY_MODE_FROM_COORDINATOR)
- && handler.getContext().getIndexRecovery() != null && handler.getContext().getRPCService() != null
- && handler.getContext().getRPCService().isCoordinator() == false)
+ // isRecoveryFilterUsed returns true only if LocalIndex strategy used
+ if (handler.getContext().isRecoveryFilterUsed())
{
- log.info("Retrieving index from coordinator (" + handler.getContext().getWorkspacePath(true) + ")...");
- indexCreated = recoveryIndexFromCoordinator();
-
- if (indexCreated)
+ // if "from-coordinator" index recovery configured
+ if (SearchIndex.INDEX_RECOVERY_MODE_FROM_COORDINATOR.equals(handler.getIndexRecoveryMode()))
{
- indexNames.read();
- refreshIndexList();
- }
- else
- {
- log.info("Index can'b be retrieved from coordinator now, because it is offline. "
- + "Possibly coordinator node performs reindexing now. Switching to local re-indexing.");
- }
- }
+ if (handler.getContext().getIndexRecovery() != null && handler.getContext().getRPCService() != null
+ && !handler.getContext().getRPCService().isCoordinator())
+ {
+ log.info("Retrieving index from coordinator (" + handler.getContext().getWorkspacePath(true)
+ + ")...");
+ indexCreated = recoveryIndexFromCoordinator();
- if (!indexCreated)
- {
- if (handler.getIndexRecoveryMode().equals(SearchIndex.INDEX_RECOVERY_MODE_FROM_COORDINATOR))
- {
- if (handler.getContext().getRPCService() == null)
- {
- log.error("RPC Service is not configured but required for copying the index "
- + "from coordinator node. Index will be created by re-indexing.");
+ if (indexCreated)
+ {
+ indexNames.read();
+ refreshIndexList();
+ }
+ else
+ {
+ log.info("Index can'b be retrieved from coordinator now, because it is offline. "
+ + "Possibly coordinator node performs reindexing now. Switching to local re-indexing.");
+ }
}
- else if (handler.getContext().getRPCService().isCoordinator() == true)
+ else
{
- log.info("Copying the index from coordinator configured, but this node is the "
- + "only one in a cluster. Index will be created by re-indexing.");
+ if (handler.getContext().getRPCService() == null)
+ {
+ // logging an event, when RPCService is not configured in clustered mode
+ log.error("RPC Service is not configured but required for copying the index "
+ + "from coordinator node. Index will be created by re-indexing.");
+ }
+ else
+ {
+ if (handler.getContext().getIndexRecovery() == null)
+ {
+ // Should never occurs, but logging an event, when RPCService configured, but IndexRecovery
+ // instance is missing
+ log.error("Instance of IndexRecovery class is missing for unknown reason. Index will be"
+ + " created by re-indexing.");
+ }
+ if (handler.getContext().getRPCService().isCoordinator())
+ {
+ // logging an event when first node starts
+ log.info("Copying the index from coordinator configured, but this node is the "
+ + "only one in a cluster. Index will be created by re-indexing.");
+ }
+ }
}
}
+ }
+ if (!indexCreated)
+ {
// traverse and index workspace
executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
@@ -2591,8 +2609,8 @@
/**
* The maximum length of a AddNode String.
*/
- private static final int ENTRY_LENGTH =
- Long.toString(Long.MAX_VALUE).length() + Action.ADD_NODE.length() + Constants.UUID_FORMATTED_LENGTH + 2;
+ private static final int ENTRY_LENGTH = Long.toString(Long.MAX_VALUE).length() + Action.ADD_NODE.length()
+ + Constants.UUID_FORMATTED_LENGTH + 2;
/**
* The uuid of the node to add.
@@ -2993,8 +3011,8 @@
/**
* The maximum length of a DeleteNode String.
*/
- private static final int ENTRY_LENGTH =
- Long.toString(Long.MAX_VALUE).length() + Action.DELETE_NODE.length() + Constants.UUID_FORMATTED_LENGTH + 2;
+ private static final int ENTRY_LENGTH = Long.toString(Long.MAX_VALUE).length() + Action.DELETE_NODE.length()
+ + Constants.UUID_FORMATTED_LENGTH + 2;
/**
* The uuid of the node to remove.
14 years, 1 month
exo-jcr SVN: r5860 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2012-03-13 13:01:38 -0400 (Tue, 13 Mar 2012)
New Revision: 5860
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
Log:
EXOJCR-1809: The TransactionManager is not properly set in BufferedJBossCache
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2012-03-13 12:28:23 UTC (rev 5859)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2012-03-13 17:01:38 UTC (rev 5860)
@@ -75,15 +75,12 @@
private final long expirationTimeOut;
- private final TransactionManager tm;
-
protected static final Log LOG =
ExoLogger.getLogger("org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.BufferedJBossCache");
public BufferedJBossCache(Cache<Serializable, Object> parentCache, boolean useExpiration, long expirationTimeOut)
{
super();
- this.tm = ((CacheSPI<Serializable, Object>)parentCache).getTransactionManager();
this.parentCache = parentCache;
this.useExpiration = useExpiration;
this.expirationTimeOut = expirationTimeOut;
@@ -131,6 +128,7 @@
*/
private void commitChanges(List<ChangesContainer> containers)
{
+ TransactionManager tm = getTransactionManager();
for (ChangesContainer cacheChange : containers)
{
boolean isTxCreated = false;
14 years, 1 month
exo-jcr SVN: r5859 - jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2012-03-13 08:28:23 -0400 (Tue, 13 Mar 2012)
New Revision: 5859
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/query-handler-config.xml
Log:
EXOJCR-1805 : update documentation
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/query-handler-config.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/query-handler-config.xml 2012-03-13 12:28:14 UTC (rev 5858)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/query-handler-config.xml 2012-03-13 12:28:23 UTC (rev 5859)
@@ -334,8 +334,8 @@
storages, databases and indexes, cluster nodes are synchronized
anytime. But it's an issue when local index strategy used. If new node
joins cluster, having no index it is retrieved or recreated. Node can
- be restarted also and thus index not empty. By default existing index
- is thought to be actual, but can be outdated. JCR offers a mechanism
+ be restarted also and thus index not empty. Usually existing index is
+ thought to be actual, but can be outdated. JCR offers a mechanism
called RecoveryFilters that will automatically retrieve index for the
joining node on startup. This feature is a set of filters that can be
defined via QueryHandler configuration:</para>
@@ -348,11 +348,16 @@
<property name="index-recovery-filter" value="org.exoplatform.services.jcr.impl.core.query.lucene.SystemPropertyRecoveryFilter" />
</programlisting>
- <para>If any one returns fires, the index is re-synchronized. This
- feature uses standard index recovery mode defined by previously
- described parameter (can be "from-indexing" or "from-coordinator"
- (default value))</para>
+ <para>If any one fires, the index is re-synchronized. Please take in
+ account, that DocNumberRecoveryFilter is used in cases when no filter
+ configured. So, if resynchronization should be blocked, or strictly
+ required on start, then ConfigurationPropertyRecoveryFilter can be
+ used.</para>
+ <para>This feature uses standard index recovery mode defined by
+ previously described parameter (can be "from-indexing" or
+ "from-coordinator" (default value))</para>
+
<programlisting language="xml"><property name="index-recovery-mode" value="from-coordinator" />
</programlisting>
14 years, 1 month