exo-jcr SVN: r3548 - in jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf: portal and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-11-25 03:16:45 -0500 (Thu, 25 Nov 2010)
New Revision: 3548
Modified:
jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/custom-commands.xml
jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/portal/configuration.xml
Log:
JCR-1524: fix
Modified: jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/custom-commands.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/custom-commands.xml 2010-11-25 07:55:08 UTC (rev 3547)
+++ jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/custom-commands.xml 2010-11-25 08:16:45 UTC (rev 3548)
@@ -40,45 +40,3 @@
<command name="CreateFolder" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.CreateFolderCommand" />
</catalog>
-<!--
-
- 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.
-
--->
-<catalog>
- <command name="addNode" className="org.exoplatform.frameworks.jcr.command.core.AddNodeCommand" />
- <command name="save" className="org.exoplatform.frameworks.jcr.command.core.SaveCommand" />
- <command name="filterNodesByTypes" className="org.exoplatform.frameworks.jcr.command.ext.FilterNodesByTypesCommand" />
- <command name="addResourceFile" className="org.exoplatform.frameworks.jcr.command.ext.AddResourceFileCommand" />
- <command name="displayResource" className="org.exoplatform.frameworks.jcr.command.web.DisplayResourceCommand" />
- <command name="getNode" className="org.exoplatform.frameworks.jcr.command.core.GetNodeCommand" />
-
-
- <!-- chain name="displayResource">
- <command id="1" className="org.exoplatform.frameworks.jcr.command.core.GetNodeCommand" />
- <command id="2" className="org.exoplatform.frameworks.jcr.command.web.DisplayResourceCommand" />
- </chain -->
-
- <!-- FCKEditor -->
- <command name="GetFolders" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.GetFoldersOrFilesCommand" />
- <command name="GetFiles" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.GetFoldersOrFilesCommand" />
- <command name="GetFoldersAndFiles" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.GetFoldersOrFilesCommand" />
- <command name="FileUpload" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.UploadFileCommand" />
- <command name="CreateFolder" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.CreateFolderCommand" />
-
-</catalog>
Modified: jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/portal/configuration.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/portal/configuration.xml 2010-11-25 07:55:08 UTC (rev 3547)
+++ jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/portal/configuration.xml 2010-11-25 08:16:45 UTC (rev 3548)
@@ -38,43 +38,3 @@
</external-component-plugins>
</configuration>
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- Copyright (C) 2009 eXo Platform SAS.
-
- This is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- This software is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this software; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
-
- <external-component-plugins>
- <target-component>org.exoplatform.services.command.impl.CommandService</target-component>
- <component-plugin>
- <name>config.catalog</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
- <init-params>
- <value-param>
- <name>config-file</name>
- <value>jar:/conf/custom-commands.xml</value>
- </value-param>
- </init-params>
- </component-plugin>
- </external-component-plugins>
-
-</configuration>
13 years, 5 months
exo-jcr SVN: r3547 - in core/trunk/exo.core.component.database/src: test/java/org/exoplatform/services/database and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-11-25 02:55:08 -0500 (Thu, 25 Nov 2010)
New Revision: 3547
Modified:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java
Log:
EXOJCR-929: get database connection info without db creation
Modified: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2010-11-25 07:29:52 UTC (rev 3546)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2010-11-25 07:55:08 UTC (rev 3547)
@@ -261,22 +261,70 @@
}
}
- // try to solve database url connection depending on specific database
- String dbUrl = serverUrl;
- if (dbProductName.startsWith("Microsoft SQL Server"))
+ return constructDBConnectionInfo(dbName, dbProductName);
+ }
+
+ /**
+ * Get database connection info.
+ *
+ * @param dbName
+ * new database name
+ * @throws DBCreatorException
+ * if any error occurs
+ */
+ public DBConnectionInfo getDBConnectionInfo(String dbName) throws DBCreatorException
+ {
+ Connection conn = null;
+ try
{
- dbUrl = dbUrl + (dbUrl.endsWith(";") ? "" : ";") + "databaseName=" + dbName + ";";
+ Class.forName(driver);
+
+ conn = SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Connection>()
+ {
+ public Connection run() throws Exception
+ {
+ return DriverManager.getConnection(serverUrl, adminName, adminPwd);
+ }
+ });
}
- else if (dbProductName.equals("Oracle"))
+ catch (SQLException e)
{
- // do nothing
+ throw new DBCreatorException("Can't establish the JDBC connection to database " + serverUrl, e);
}
- else
+ catch (ClassNotFoundException e)
{
- dbUrl = dbUrl + (dbUrl.endsWith("/") ? "" : "/") + dbName;
+ throw new DBCreatorException("Can't load the JDBC driver " + driver, e);
}
- return new DBConnectionInfo(driver, dbUrl, dbUserName, dbPassword);
+ String dbProductName;
+ try
+ {
+ final Connection connection = conn;
+ dbProductName = SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<String>()
+ {
+ public String run() throws Exception
+ {
+ return connection.getMetaData().getDatabaseProductName();
+ }
+ });
+ }
+ catch (SQLException e)
+ {
+ throw new DBCreatorException("Can't resolve database product name ", e);
+ }
+ finally
+ {
+ try
+ {
+ conn.close();
+ }
+ catch (SQLException e)
+ {
+ throw new DBCreatorException("Can't close connection", e);
+ }
+ }
+
+ return constructDBConnectionInfo(dbName, dbProductName);
}
/**
@@ -308,6 +356,34 @@
}
/**
+ * Construct database url connection depending on specific database.
+ *
+ * @param dbName
+ * database name
+ * @param dbProductName
+ * database product name
+ * @return DBConnectionInfo
+ */
+ private DBConnectionInfo constructDBConnectionInfo(String dbName, String dbProductName)
+ {
+ String dbUrl = serverUrl;
+ if (dbProductName.startsWith("Microsoft SQL Server"))
+ {
+ dbUrl = dbUrl + (dbUrl.endsWith(";") ? "" : ";") + "databaseName=" + dbName + ";";
+ }
+ else if (dbProductName.equals("Oracle"))
+ {
+ // do nothing
+ }
+ else
+ {
+ dbUrl = dbUrl + (dbUrl.endsWith("/") ? "" : "/") + dbName;
+ }
+
+ return new DBConnectionInfo(driver, dbUrl, dbUserName, dbPassword);
+ }
+
+ /**
* Executes DDL script with autocommit mode set true. Actually need for MSSQL and Sybase database servers.
* After execution "create database" command newly created database not available for "use" command and
* therefore you can't create user inside.
Modified: core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java
===================================================================
--- core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java 2010-11-25 07:29:52 UTC (rev 3546)
+++ core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java 2010-11-25 07:55:08 UTC (rev 3547)
@@ -56,7 +56,13 @@
assertNotNull(dbCreator);
DBConnectionInfo dbInfo = dbCreator.createDatabase("testdb");
+ DBConnectionInfo dbInfo1 = dbCreator.getDBConnectionInfo("testdb");
+ assertEquals(dbInfo.getDriver(), dbInfo1.getDriver());
+ assertEquals(dbInfo.getPassword(), dbInfo1.getPassword());
+ assertEquals(dbInfo.getUrl(), dbInfo1.getUrl());
+ assertEquals(dbInfo.getUsername(), dbInfo1.getUsername());
+
Map<String, String> refAddr = new HashMap<String, String>();
refAddr.put("driverClassName", dbInfo.getDriver());
refAddr.put("url", dbInfo.getUrl());
13 years, 5 months
exo-jcr SVN: r3546 - jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-11-25 02:29:52 -0500 (Thu, 25 Nov 2010)
New Revision: 3546
Modified:
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java
Log:
JCR-1502: fix tests
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java 2010-11-24 15:35:31 UTC (rev 3545)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java 2010-11-25 07:29:52 UTC (rev 3546)
@@ -18,6 +18,15 @@
*/
package org.exoplatform.services.jcr.ext.backup;
+import org.apache.commons.collections.map.HashedMap;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+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.core.SessionImpl;
+
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -28,15 +37,6 @@
import javax.jcr.RepositoryException;
import javax.jcr.lock.Lock;
-import org.apache.commons.collections.map.HashedMap;
-import org.exoplatform.services.jcr.config.RepositoryEntry;
-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.core.SessionImpl;
-
/**
* Created by The eXo Platform SAS.
* Author : Peter Nedonosko peter.nedonosko(a)exoplatform.com.ua
@@ -81,8 +81,7 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1back = makeWorkspaceEntry("ws1back", "jdbcjcr_backup_only_use_1");
// BackupChainLog bchLog = new BackupChainLog(backDir, rconfig);
@@ -100,10 +99,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) repository.login(credentials, "ws1back");
+ back1 = (SessionImpl)repository.login(credentials, "ws1back");
Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
- .getProperty("exo:data").getString());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -160,8 +159,7 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1back = makeWorkspaceEntry("ws1back.incr", "jdbcjcr_backup_only_use_2");
File backLog = new File(bch.getLogFilePath());
@@ -178,16 +176,16 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) repository.login(credentials, ws1back.getName());
+ back1 = (SessionImpl)repository.login(credentials, ws1back.getName());
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());
+ .getProperty("exo:data").getString());
assertEquals("Restored content should be same", "property #5", ws1backTestRoot.getNode("node #5")
- .getProperty("exo:extraData").getString());
+ .getProperty("exo:extraData").getString());
assertFalse("Proeprty should be removed", ws1backTestRoot.getNode("node #5").hasProperty("exo:data"));
}
@@ -255,7 +253,7 @@
ws1TestRoot.addNode("node_102").setProperty("exo:data", new FileInputStream(tempf));
ws1TestRoot.save(); // log here via listener
- ws1TestRoot.getNode("node_2").setProperty("exo:data", (InputStream) null); // remove property
+ ws1TestRoot.getNode("node_2").setProperty("exo:data", (InputStream)null); // remove property
ws1TestRoot.getNode("node_3").setProperty("exo:data", new ByteArrayInputStream("aaa".getBytes())); // set
// aaa
// bytes
@@ -266,7 +264,7 @@
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.getNode("node_5").getPath() + "/node #53");
ws1TestRoot.save(); // log here via listener
ws1TestRoot.getNode("node_6").addMixin("mix:referenceable");
@@ -274,8 +272,8 @@
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
+ ws1TestRoot.getSession().getWorkspace()
+ .move(ws1TestRoot.getNode("node_6").getPath(), ws1TestRoot.getPath() + "/node_4"); // in place of
// 4 removed
// stop all
@@ -285,8 +283,7 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1back = makeWorkspaceEntry("ws1back.incr2", "jdbcjcr_backup_only_use_3");
File backLog = new File(bch.getLogFilePath());
@@ -303,12 +300,12 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) repository.login(credentials, ws1back.getName());
+ back1 = (SessionImpl)repository.login(credentials, ws1back.getName());
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"));
+ .hasProperty("node #53/exo:extraData"));
assertTrue("Node should exists", ws1backTestRoot.hasNode("node_7"));
assertTrue("Property should exists", ws1backTestRoot.hasProperty("node_5/exo:data"));
@@ -316,20 +313,20 @@
assertTrue("Node should exists", ws1backTestRoot.hasNode("node_102"));
compareStream(new FileInputStream(tempf), ws1backTestRoot.getNode("node_5").getProperty("exo:data")
- .getStream());
+ .getStream());
compareStream(new FileInputStream(tempf), ws1backTestRoot.getNode("node_1").getProperty("exo:extraData")
- .getStream());
+ .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());
+ 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());
+ assertEquals("Node should be mix:referenceable and UUID should be " + id6, id6,
+ ws1backTestRoot.getNode("node_4").getUUID());
}
catch (Exception e)
{
@@ -348,9 +345,9 @@
public void testFullBackupRestoreAsync() throws Exception
{
- SessionImpl sessionWS1 = (SessionImpl) repository.login(credentials, "ws1");
- sessionWS1.getRootNode().addNode("backupTest").addNode("node_5").setProperty("exo:data",
- "Restored content should be same");
+ SessionImpl sessionWS1 = (SessionImpl)repository.login(credentials, "ws1");
+ sessionWS1.getRootNode().addNode("backupTest").addNode("node_5")
+ .setProperty("exo:data", "Restored content should be same");
sessionWS1.save();
// backup
@@ -396,22 +393,22 @@
backup.restore(bchLog, repository.getName(), ws1back, true);
while (backup.getLastRestore(repository.getName(), ws1back.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_SUCCESSFUL
- && backup.getLastRestore(repository.getName(), ws1back.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
+ && backup.getLastRestore(repository.getName(), ws1back.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
{
Thread.sleep(50);
}
if (backup.getLastRestore(repository.getName(), ws1back.getName()).getStateRestore() == JobWorkspaceRestore.RESTORE_FAIL)
- throw (Exception) backup.getLastRestore(repository.getName(), ws1back.getName()).getRestoreException();
+ throw (Exception)backup.getLastRestore(repository.getName(), ws1back.getName()).getRestoreException();
// check
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) repository.login(credentials, "ws1back5");
+ back1 = (SessionImpl)repository.login(credentials, "ws1back5");
Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
- .getProperty("exo:data").getString());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -494,7 +491,7 @@
final BackupChain bch = backup.startBackup(config);
- Thread.sleep(20000);
+ Thread.sleep(30000);
assertTrue(bch.isFinished());
@@ -506,10 +503,10 @@
public void testTwoRestores() throws Exception
{
{
- SessionImpl sessionWS1 = (SessionImpl) repository.login(credentials, "ws3");
+ SessionImpl sessionWS1 = (SessionImpl)repository.login(credentials, "ws3");
- sessionWS1.getRootNode().addNode("asdasdasda", "nt:unstructured").setProperty("data",
- new FileInputStream(createBLOBTempFile(1024)));
+ sessionWS1.getRootNode().addNode("asdasdasda", "nt:unstructured")
+ .setProperty("data", new FileInputStream(createBLOBTempFile(1024)));
sessionWS1.save();
// 1-st backup
@@ -542,12 +539,12 @@
backup.restore(bchLog, repository.getName(), ws1_restore_1, false);
// check
- SessionImpl back1 = (SessionImpl) repository.login(credentials, "ws1_restore_1");
+ SessionImpl back1 = (SessionImpl)repository.login(credentials, "ws1_restore_1");
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.getRootNode().addNode("gdfgrghfhf", "nt:unstructured")
+ .setProperty("data", new FileInputStream(createBLOBTempFile(1024)));
back1.save();
}
else
@@ -585,7 +582,7 @@
backup.restore(bchLog, repository.getName(), ws1_restore_2, false);
// check
- SessionImpl back2 = (SessionImpl) repository.login(credentials, "ws1_restore_2");
+ SessionImpl back2 = (SessionImpl)repository.login(credentials, "ws1_restore_2");
assertNotNull(back2.getRootNode().getNode("gdfgrghfhf").getProperty("data"));
}
else
@@ -700,8 +697,7 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1back = makeWorkspaceEntry("ws1backt", "jdbcjcr_backup_only_use_8_NOT_EXIST");
File backLog = new File(bch.getLogFilePath());
@@ -727,10 +723,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) repository.login(credentials, "ws1back");
+ back1 = (SessionImpl)repository.login(credentials, "ws1back");
Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
- .getProperty("exo:data").getString());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -775,12 +771,11 @@
backup.stopBackup(bch);
// restore
- RepositoryEntry re =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
String newRepositoryName = "repo_restored_1";
RepositoryEntry newRepositoryEntry =
- makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_1", null);
+ makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_1", null);
File backLog = new File(bch.getLogFilePath());
if (backLog.exists())
@@ -791,8 +786,8 @@
assertNotNull(bchLog.getFinishedTime());
backup.restore(bchLog, newRepositoryEntry, false);
- assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(
- newRepositoryEntry.getName()).getStateRestore());
+ assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL,
+ backup.getLastRepositoryRestore(newRepositoryEntry.getName()).getStateRestore());
// check
ManageableRepository restoredRepository = repositoryService.getRepository(newRepositoryName);
@@ -802,10 +797,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -852,12 +847,11 @@
backup.stopBackup(bch);
// restore
- RepositoryEntry re =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
String newRepositoryName = "repo_restored_4";
RepositoryEntry newRepositoryEntry =
- makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_4", null);
+ makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_4", null);
File backLog = new File(bch.getLogFilePath());
if (backLog.exists())
@@ -877,10 +871,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) repository.login(credentials, wsName);
+ back1 = (SessionImpl)repository.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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -899,7 +893,7 @@
}
public void testRepositoryFullBackupAsynchronusRestore() throws Exception
- {
+ {
// backup
File backDir = new File("target/backup");
backDir.mkdirs();
@@ -926,12 +920,11 @@
backup.stopBackup(bch);
// restore
- RepositoryEntry re =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
String newRepositoryName = "repo_restored_2";
RepositoryEntry newRepositoryEntry =
- makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_2", null);
+ makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_2", null);
File backLog = new File(bch.getLogFilePath());
if (backLog.exists())
@@ -946,7 +939,7 @@
JobRepositoryRestore job = backup.getLastRepositoryRestore(newRepositoryName);
while (job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL
- || job.getStateRestore() == JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
+ || job.getStateRestore() == JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
{
Thread.yield();
Thread.sleep(50);
@@ -960,10 +953,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -979,7 +972,7 @@
}
else
fail("There are no backup files in " + backDir.getAbsolutePath());
- }
+ }
public void testRepositoryFullBackupAsynchronusRestoreWorkspaceMapping() throws Exception
{
@@ -1006,15 +999,14 @@
// stop fullBackup
- backup.stopBackup(bch);
+ backup.stopBackup(bch);
// restore
- RepositoryEntry re =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
String newRepositoryName = "repo_restored_3";
RepositoryEntry newRepositoryEntry =
- makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_3", null);
+ makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_3", null);
// create workspace mappingS
Map<String, String> workspaceMapping = new HashedMap();
@@ -1049,7 +1041,7 @@
JobRepositoryRestore job = backup.getLastRepositoryRestore(newRepositoryName);
while (job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL
- || job.getStateRestore() == JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
+ || job.getStateRestore() == JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
{
Thread.yield();
Thread.sleep(50);
@@ -1063,10 +1055,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) restoredRepository.login(credentials, workspaceMapping.get(wsName));
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1099,7 +1091,7 @@
final RepositoryBackupChain bch = backup.startBackup(config);
- Thread.sleep(20000);
+ Thread.sleep(30000);
assertTrue(bch.isFinished());
@@ -1109,14 +1101,13 @@
}
public void testRepositoryRestoreFail() throws Exception
- {
+ {
// restore
- RepositoryEntry re =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
String newRepositoryName = "repo_restored_5";
RepositoryEntry newRepositoryEntry =
- makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_5", null);
+ makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_5", null);
//create broken system workspaceEntry
newRepositoryEntry.getWorkspaceEntries().get(0).getQueryHandler().setType("gg");
@@ -1135,10 +1126,10 @@
// ok.
}
- // check
+ // check
- try
- {
+ try
+ {
ManageableRepository restoredRepository = repositoryService.getRepository(newRepositoryName);
fail("The repository " + newRepositoryName + "shoulde not exists.");
}
@@ -1194,8 +1185,7 @@
ws1Session.getRootNode().save();
// restore
- RepositoryEntry re =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1back = makeWorkspaceEntry("ws1back.incr737", "jdbcjcr25");
File backLog = new File(bch.getLogFilePath());
@@ -1212,7 +1202,7 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) repository.login(credentials, ws1back.getName());
+ back1 = (SessionImpl)repository.login(credentials, ws1back.getName());
Node node_101 = back1.getRootNode().getNode("node_101");
assertNotNull(node_101);
@@ -1272,8 +1262,7 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1 = null;
for (WorkspaceEntry we : re.getWorkspaceEntries())
{
@@ -1298,10 +1287,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) repository.login(credentials, "ws1");
+ back1 = (SessionImpl)repository.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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1350,8 +1339,7 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1 = null;
for (WorkspaceEntry we : re.getWorkspaceEntries())
{
@@ -1373,7 +1361,7 @@
backup.restoreExistingWorkspace(bchLog, re.getName(), ws1, true);
while (backup.getLastRestore(repository.getName(), ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_SUCCESSFUL
- && backup.getLastRestore(repository.getName(), ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
+ && backup.getLastRestore(repository.getName(), ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
{
Thread.sleep(50);
}
@@ -1382,10 +1370,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) repository.login(credentials, "ws1");
+ back1 = (SessionImpl)repository.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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1434,8 +1422,7 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1 = null;
for (WorkspaceEntry we : re.getWorkspaceEntries())
{
@@ -1457,7 +1444,7 @@
backup.restoreExistingWorkspace(bchLog.getBackupId(), re.getName(), ws1, true);
while (backup.getLastRestore(repository.getName(), ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_SUCCESSFUL
- && backup.getLastRestore(repository.getName(), ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
+ && backup.getLastRestore(repository.getName(), ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
{
Thread.sleep(50);
}
@@ -1466,10 +1453,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) repository.login(credentials, "ws1");
+ back1 = (SessionImpl)repository.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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1488,19 +1475,33 @@
public void testExistedRepositoryRestore() throws Exception
{
+ RepositoryImpl repositoryDB8 = (RepositoryImpl)repositoryService.getRepository("db8");
+
+ for (String wsName : repositoryDB8.getWorkspaceNames())
+ {
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, wsName);
+
+ Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
+ sessionWS.getRootNode().save();
+ addContent(wsTestRoot, 1, 10, 1);
+ sessionWS.getRootNode().save();
+ }
+
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, WS_NAME);
+
// backup
File backDir = new File("target/backup");
backDir.mkdirs();
RepositoryBackupConfig config = new RepositoryBackupConfig();
- config.setRepository(repository.getName());
+ config.setRepository(repositoryDB8.getName());
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
config.setBackupDir(backDir);
backup.startBackup(config);
- RepositoryBackupChain bch = backup.findRepositoryBackup(repository.getName());
+ RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryDB8.getName());
// wait till full backup will be stopped
while (bch.getState() != RepositoryBackupChain.FINISHED)
@@ -1515,7 +1516,7 @@
// restore
RepositoryEntry baseRE =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ (RepositoryEntry)sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
RepositoryEntry re = makeRepositoryEntry(baseRE.getName(), baseRE, null, null);
File backLog = new File(bch.getLogFilePath());
@@ -1529,7 +1530,7 @@
backup.restoreExistingRepository(bchLog, re, false);
assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(re.getName())
- .getStateRestore());
+ .getStateRestore());
// check
ManageableRepository restoredRepository = repositoryService.getRepository(re.getName());
@@ -1539,10 +1540,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1562,11 +1563,11 @@
public void testExistedRepositoryRestoreMultiDB() throws Exception
{
- RepositoryImpl repositoryDB7 = (RepositoryImpl) repositoryService.getRepository("db7");
+ RepositoryImpl repositoryDB7 = (RepositoryImpl)repositoryService.getRepository("db7");
for (String wsName : repositoryDB7.getWorkspaceNames())
{
- SessionImpl sessionWS = (SessionImpl) repositoryDB7.login(credentials, wsName);
+ SessionImpl sessionWS = (SessionImpl)repositoryDB7.login(credentials, wsName);
Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
sessionWS.getRootNode().save();
@@ -1574,7 +1575,7 @@
sessionWS.getRootNode().save();
}
- SessionImpl sessionWS = (SessionImpl) repositoryDB7.login(credentials, WS_NAME);
+ SessionImpl sessionWS = (SessionImpl)repositoryDB7.login(credentials, WS_NAME);
// backup
File backDir = new File("target/backup");
@@ -1603,7 +1604,7 @@
// restore
RepositoryEntry baseRE =
- (RepositoryEntry) sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ (RepositoryEntry)sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
RepositoryEntry re = makeRepositoryEntry(baseRE.getName(), baseRE, null, null);
File backLog = new File(bch.getLogFilePath());
@@ -1617,7 +1618,7 @@
backup.restoreExistingRepository(bchLog, re, false);
assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(re.getName())
- .getStateRestore());
+ .getStateRestore());
// check
ManageableRepository restoredRepository = repositoryService.getRepository(re.getName());
@@ -1627,10 +1628,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1650,19 +1651,33 @@
public void testExistedRepositoryRestoreAsync() throws Exception
{
+ RepositoryImpl repositoryDB8 = (RepositoryImpl)repositoryService.getRepository("db8");
+
+ for (String wsName : repositoryDB8.getWorkspaceNames())
+ {
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, wsName);
+
+ Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
+ sessionWS.getRootNode().save();
+ addContent(wsTestRoot, 1, 10, 1);
+ sessionWS.getRootNode().save();
+ }
+
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, WS_NAME);
+
// backup
File backDir = new File("target/backup");
backDir.mkdirs();
RepositoryBackupConfig config = new RepositoryBackupConfig();
- config.setRepository(repository.getName());
+ config.setRepository(repositoryDB8.getName());
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
config.setBackupDir(backDir);
backup.startBackup(config);
- RepositoryBackupChain bch = backup.findRepositoryBackup(repository.getName());
+ RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryDB8.getName());
// wait till full backup will be stopped
while (bch.getState() != RepositoryBackupChain.FINISHED)
@@ -1677,7 +1692,7 @@
// restore
RepositoryEntry baseRE =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ (RepositoryEntry)sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
RepositoryEntry re = makeRepositoryEntry(baseRE.getName(), baseRE, null, null);
File backLog = new File(bch.getLogFilePath());
@@ -1693,13 +1708,13 @@
JobRepositoryRestore job = backup.getLastRepositoryRestore(re.getName());
while (job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL
- && job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
+ && job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
{
Thread.sleep(50);
}
assertEquals(JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(re.getName())
- .getStateRestore());
+ .getStateRestore());
// check
ManageableRepository restoredRepository = repositoryService.getRepository(re.getName());
@@ -1709,10 +1724,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1732,26 +1747,40 @@
public void testExistedRepositoryRestoreAsync2() throws Exception
{
+ RepositoryImpl repositoryDB8 = (RepositoryImpl)repositoryService.getRepository("db8");
+
+ for (String wsName : repositoryDB8.getWorkspaceNames())
+ {
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, wsName);
+
+ Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
+ sessionWS.getRootNode().save();
+ addContent(wsTestRoot, 1, 10, 1);
+ sessionWS.getRootNode().save();
+ }
+
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, WS_NAME);
+
// backup
File backDir = new File("target/backup");
backDir.mkdirs();
RepositoryBackupConfig config = new RepositoryBackupConfig();
- config.setRepository(repository.getName());
+ config.setRepository(repositoryDB8.getName());
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
config.setBackupDir(backDir);
backup.startBackup(config);
- RepositoryBackupChain bch = backup.findRepositoryBackup(repository.getName());
+ RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryDB8.getName());
// wait till full backup will be stopped
while (bch.getState() != RepositoryBackupChain.FINISHED)
- {
+ {
Thread.yield();
Thread.sleep(50);
- }
+ }
// stop fullBackup
@@ -1759,12 +1788,12 @@
// restore
RepositoryEntry baseRE =
- (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ (RepositoryEntry)sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
RepositoryEntry re = makeRepositoryEntry(baseRE.getName(), baseRE, null, null);
File backLog = new File(bch.getLogFilePath());
if (backLog.exists())
- {
+ {
RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
assertNotNull(bchLog.getStartedTime());
@@ -1775,13 +1804,13 @@
JobRepositoryRestore job = backup.getLastRepositoryRestore(re.getName());
while (job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL
- && job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
+ && job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
{
Thread.sleep(50);
}
assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(re.getName())
- .getStateRestore());
+ .getStateRestore());
// check
ManageableRepository restoredRepository = repositoryService.getRepository(re.getName());
@@ -1791,10 +1820,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1807,16 +1836,16 @@
back1.logout();
}
}
- }
+ }
else
fail("There are no backup files in " + backDir.getAbsolutePath());
- }
+ }
public void testExistedWorkspaceRestoreMultiDB() throws Exception
- {
- RepositoryImpl repositoryDB7 = (RepositoryImpl) repositoryService.getRepository("db7");
+ {
+ RepositoryImpl repositoryDB7 = (RepositoryImpl)repositoryService.getRepository("db7");
- SessionImpl sessionWS = (SessionImpl) repositoryDB7.login(credentials, "ws1");
+ SessionImpl sessionWS = (SessionImpl)repositoryDB7.login(credentials, "ws1");
Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
sessionWS.getRootNode().save();
@@ -1853,7 +1882,7 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re = (RepositoryEntry) sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry)sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1 = null;
for (WorkspaceEntry we : re.getWorkspaceEntries())
{
@@ -1878,10 +1907,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) repositoryDB7.login(credentials, "ws1");
+ back1 = (SessionImpl)repositoryDB7.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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1896,10 +1925,10 @@
}
else
fail("There are no backup files in " + backDir.getAbsolutePath());
- }
+ }
public void testExistedWorkspaceRestoreWithConfig() throws Exception
- {
+ {
// backup
File backDir = new File("target/backup/ws1");
backDir.mkdirs();
@@ -1932,7 +1961,7 @@
File backLog = new File(bch.getLogFilePath());
if (backLog.exists())
- {
+ {
BackupChainLog bchLog = new BackupChainLog(backLog);
assertNotNull(bchLog.getStartedTime());
@@ -1941,37 +1970,51 @@
backup.restoreExistingWorkspace(bchLog.getBackupId(), false);
// check
- SessionImpl back1 = null;
- try
- {
- back1 = (SessionImpl) repository.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());
+ SessionImpl back1 = null;
+ try
+ {
+ back1 = (SessionImpl)repository.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();
+ }
}
- 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 testExistedRepositoryRestoreWithConfig() throws Exception
{
+ RepositoryImpl repositoryDB8 = (RepositoryImpl)repositoryService.getRepository("db8");
+
+ for (String wsName : repositoryDB8.getWorkspaceNames())
+ {
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, wsName);
+
+ Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
+ sessionWS.getRootNode().save();
+ addContent(wsTestRoot, 1, 10, 1);
+ sessionWS.getRootNode().save();
+ }
+
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, WS_NAME);
+
// backup
File backDir = new File("target/backup/db1");
backDir.mkdirs();
RepositoryBackupConfig config = new RepositoryBackupConfig();
- String repoName = repository.getName();
+ String repoName = repositoryDB8.getName();
config.setRepository(repoName);
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
@@ -1979,7 +2022,7 @@
backup.startBackup(config);
- RepositoryBackupChain bch = backup.findRepositoryBackup(repository.getName());
+ RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryDB8.getName());
// wait till full backup will be stopped
while (bch.getState() != RepositoryBackupChain.FINISHED)
@@ -2006,7 +2049,7 @@
backup.restoreExistingRepository(bchLog.getBackupId(), false);
assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(repoName)
- .getStateRestore());
+ .getStateRestore());
// check
ManageableRepository restoredRepository = repositoryService.getRepository(repoName);
@@ -2016,10 +2059,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -2086,10 +2129,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) repository.login(credentials, "ws1");
+ back1 = (SessionImpl)repository.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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -2108,12 +2151,26 @@
public void testRepositoryRestoreWithConfig() throws Exception
{
+ RepositoryImpl repositoryDB8 = (RepositoryImpl)repositoryService.getRepository("db8");
+
+ for (String wsName : repositoryDB8.getWorkspaceNames())
+ {
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, wsName);
+
+ Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
+ sessionWS.getRootNode().save();
+ addContent(wsTestRoot, 1, 10, 1);
+ sessionWS.getRootNode().save();
+ }
+
+ SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, WS_NAME);
+
// backup
File backDir = new File("target/backup");
backDir.mkdirs();
RepositoryBackupConfig config = new RepositoryBackupConfig();
- String repoName = repository.getName();
+ String repoName = repositoryDB8.getName();
config.setRepository(repoName);
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
@@ -2121,7 +2178,7 @@
backup.startBackup(config);
- RepositoryBackupChain bch = backup.findRepositoryBackup(repository.getName());
+ RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryDB8.getName());
// wait till full backup will be stopped
while (bch.getState() != RepositoryBackupChain.FINISHED)
@@ -2136,7 +2193,7 @@
//TODO
super.tearDown();
- removeRepositoryFully(repository.getName());
+ removeRepositoryFully(repositoryDB8.getName());
// restore
File backLog = new File(bch.getLogFilePath());
@@ -2150,7 +2207,7 @@
backup.restoreRepository(bchLog.getBackupId(), false);
assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(repoName)
- .getStateRestore());
+ .getStateRestore());
// check
ManageableRepository restoredRepository = repositoryService.getRepository(repoName);
@@ -2160,10 +2217,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl) restoredRepository.login(credentials, wsName);
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
13 years, 5 months
exo-jcr SVN: r3545 - in jcr/trunk/exo.jcr.component.ext/src: main/java/org/exoplatform/services/jcr/ext/backup/impl and 1 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-11-24 10:35:31 -0500 (Wed, 24 Nov 2010)
New Revision: 3545
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupChainLog.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/ExtendedBackupManager.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupChainImpl.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestore.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/RepositoryBackupChainImpl.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java
Log:
EXOJCR-1075 : Changes for "The JCR backupset should be fully independent" was committed.
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupChainLog.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupChainLog.java 2010-11-24 15:30:57 UTC (rev 3544)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupChainLog.java 2010-11-24 15:35:31 UTC (rev 3545)
@@ -18,16 +18,13 @@
*/
package org.exoplatform.services.jcr.ext.backup;
-import org.exoplatform.commons.utils.PrivilegedFileHelper;
-import org.exoplatform.commons.utils.SecurityHelper;
-import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.PrivilegedActionException;
@@ -47,6 +44,22 @@
import javax.xml.stream.XMLStreamWriter;
import javax.xml.stream.events.StartElement;
+import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.commons.utils.SecurityHelper;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.ws.frameworks.json.JsonHandler;
+import org.exoplatform.ws.frameworks.json.JsonParser;
+import org.exoplatform.ws.frameworks.json.impl.BeanBuilder;
+import org.exoplatform.ws.frameworks.json.impl.JsonDefaultHandler;
+import org.exoplatform.ws.frameworks.json.impl.JsonException;
+import org.exoplatform.ws.frameworks.json.impl.JsonGeneratorImpl;
+import org.exoplatform.ws.frameworks.json.impl.JsonParserImpl;
+import org.exoplatform.ws.frameworks.json.value.JsonValue;
+
/**
* Created by The eXo Platform SARL .<br/>
*
@@ -56,6 +69,11 @@
public class BackupChainLog
{
+ /**
+ * Start for 1.1 version log will be stored relative paths.
+ */
+ protected static String VERSION_LOG_1_1 = "1.1";
+
protected static Log logger = ExoLogger.getLogger("exo.jcr.component.ext.BackupChainLog");
public static final String PREFIX = "backup-";
@@ -82,6 +100,12 @@
private boolean finalized;
+ private WorkspaceEntry originalWorkspaceEntry;
+
+ private final String versionLog;
+
+ private File rootDir;
+
/**
* BackupChainLog constructor.
*
@@ -95,25 +119,30 @@
* Sting, FQN for incremental backup
* @param backupId
* String, the identifier of backup
+ * @param wEntry
+ * original workspace config
* @throws BackupOperationException
* will be generate the exception BackupOperationException
*/
public BackupChainLog(File logDir, BackupConfig config, String fullBackupType, String incrementalBackupType,
- String backupId) throws BackupOperationException
+ String backupId, WorkspaceEntry wEntry, File rootDir) throws BackupOperationException
{
try
{
this.finalized = false;
- this.log =
- new File(PrivilegedFileHelper.getCanonicalPath(logDir) + File.separator + (PREFIX + backupId + SUFFIX));
+ this.versionLog = VERSION_LOG_1_1;
+ this.log = new File(PrivilegedFileHelper.getCanonicalPath(logDir) + File.separator + (PREFIX + backupId + SUFFIX));
PrivilegedFileHelper.createNewFile(this.log);
+ this.rootDir = rootDir;
this.backupId = backupId;
this.config = config;
this.jobEntries = new ArrayList<JobEntryInfo>();
+ this.originalWorkspaceEntry = wEntry;
// write config info here
logWriter = new LogWriter(log);
logWriter.write(config, fullBackupType, incrementalBackupType);
+ logWriter.writeWorkspaceEntry(originalWorkspaceEntry);
}
catch (IOException e)
{
@@ -127,6 +156,10 @@
{
throw new BackupOperationException(e);
}
+ catch (JsonException e)
+ {
+ throw new BackupOperationException(e);
+ }
}
/**
@@ -148,10 +181,12 @@
logReader.readLogFile();
logReader.jobEntrysNormalize();
+ this.versionLog = logReader.getVersionLog();
this.config = logReader.getBackupConfig();
this.startedTime = logReader.getBeginTime();
this.finishedTime = logReader.getEndTime();
this.jobEntries = logReader.getJobEntryInfoNormalizeList();
+ this.originalWorkspaceEntry = logReader.getOriginalWorkspaceEntry();
for (JobEntryInfo info : jobEntries)
{
@@ -182,6 +217,10 @@
{
throw new BackupOperationException(e);
}
+ catch (Exception e)
+ {
+ throw new BackupOperationException(e);
+ }
}
/**
@@ -201,7 +240,7 @@
info.setState(job.getState());
info.setURL(job.getStorageURL());
- logWriter.write(info);
+ logWriter.write(info, config);
}
catch (Exception e)
{
@@ -250,6 +289,33 @@
{
finalized = true;
logWriter.writeEndLog();
+
+ //copy backup chain log file in into Backupset files itself for portability (e.g. on another server)
+ try
+ {
+ InputStream in = PrivilegedFileHelper.fileInputStream(log);
+
+ File dest = new File(config.getBackupDir() + File.separator + log.getName());
+ if (!PrivilegedFileHelper.exists(dest))
+ {
+ OutputStream out = PrivilegedFileHelper.fileOutputStream(dest);
+
+ byte[] buf = new byte[(int) (PrivilegedFileHelper.length(log))];
+ in.read(buf);
+
+ String sConfig = new String(buf, Constants.DEFAULT_ENCODING);
+ sConfig = sConfig.replaceAll("<backup-dir>.+</backup-dir>", "<backup-dir>.</backup-dir>");
+
+ out.write(sConfig.getBytes(Constants.DEFAULT_ENCODING));
+ in.close();
+ out.close();
+ }
+ }
+ catch (Exception e)
+ {
+ logger.error("Can't write log", e);
+ }
+
}
/**
@@ -313,6 +379,17 @@
return finishedTime;
}
+ /**
+ * Getting original workspace configuration
+ *
+ * @return WorkspaceEntry
+ * return the original workspace configuration
+ */
+ public WorkspaceEntry getOriginalWorkspaceEntry()
+ {
+ return originalWorkspaceEntry;
+ }
+
private class LogReader
{
protected Log logger = ExoLogger.getLogger("exo.jcr.component.ext.LogReader");
@@ -326,16 +403,30 @@
private List<JobEntryInfo> jobEntries;
private List<JobEntryInfo> jobEntriesNormalize;
+
+ private WorkspaceEntry originalWorkspaceEntry;
+
+ private String version;
public LogReader(File logFile) throws FileNotFoundException, XMLStreamException, FactoryConfigurationError
{
this.logFile = logFile;
jobEntries = new ArrayList<JobEntryInfo>();
- reader =
- XMLInputFactory.newInstance().createXMLStreamReader(PrivilegedFileHelper.fileInputStream(this.logFile));
+ reader = XMLInputFactory.newInstance().createXMLStreamReader(
+ PrivilegedFileHelper.fileInputStream(this.logFile), Constants.DEFAULT_ENCODING);
}
+ public String getVersionLog()
+ {
+ return version;
+ }
+
+ public WorkspaceEntry getOriginalWorkspaceEntry()
+ {
+ return originalWorkspaceEntry;
+ }
+
public BackupConfig getBackupConfig()
{
return config;
@@ -361,7 +452,7 @@
return jobEntries.get(jobEntries.size() - 1).getDate();
}
- public void readLogFile() throws XMLStreamException, MalformedURLException, ValueFormatException
+ public void readLogFile() throws Exception
{
boolean endDocument = false;
@@ -380,6 +471,14 @@
if (name.equals("job-entry-info"))
jobEntries.add(readJobEntryInfo());
+ if (name.equals("original-workspace-config"))
+ this.originalWorkspaceEntry = readWorkspaceEntry();
+
+ if (name.equals("version-log"))
+ {
+ this.version = readContent();
+ }
+
break;
case StartElement.END_DOCUMENT :
@@ -389,8 +488,38 @@
}
}
- private JobEntryInfo readJobEntryInfo() throws XMLStreamException, MalformedURLException, ValueFormatException
+ private WorkspaceEntry readWorkspaceEntry() throws Exception
{
+ String jsonRepositoryEntry = reader.getElementText();
+
+ return (WorkspaceEntry) (getObject(WorkspaceEntry.class, jsonRepositoryEntry
+ .getBytes(Constants.DEFAULT_ENCODING)));
+ }
+
+ /**
+ * Will be created the Object from JSON binary data.
+ *
+ * @param cl
+ * Class
+ * @param data
+ * binary data (JSON)
+ * @return Object
+ * @throws Exception
+ * will be generated Exception
+ */
+ private Object getObject(Class cl, byte[] data) throws Exception
+ {
+ JsonHandler jsonHandler = new JsonDefaultHandler();
+ JsonParser jsonParser = new JsonParserImpl();
+ InputStream inputStream = new ByteArrayInputStream(data);
+ jsonParser.parse(inputStream, jsonHandler);
+ JsonValue jsonValue = jsonHandler.getJsonObject();
+
+ return new BeanBuilder().createObject(cl, jsonValue);
+ }
+
+ private JobEntryInfo readJobEntryInfo() throws XMLStreamException, ValueFormatException, IOException
+ {
JobEntryInfo info = new JobEntryInfo();
boolean endJobEntryInfo = false;
@@ -411,8 +540,22 @@
info.setState(getState(readContent()));
if (name.equals("url"))
- info.setURL(new URL(readContent()));
+ {
+ if (version != null && version.equals(VERSION_LOG_1_1))
+ {
+ String path =
+ readContent().replace("file:",
+ "file:" + PrivilegedFileHelper.getCanonicalPath(config.getBackupDir())
+ + File.separator);
+ info.setURL(new URL(path));
+ }
+ else
+ {
+ info.setURL(new URL(readContent()));
+ }
+ }
+
if (name.equals("date"))
info.setDate(JCRDateFormat.parse(readContent()));
@@ -462,7 +605,7 @@
return type;
}
- private BackupConfig readBackupConfig() throws XMLStreamException
+ private BackupConfig readBackupConfig() throws XMLStreamException, IOException
{
BackupConfig conf = new BackupConfig();
@@ -478,8 +621,27 @@
String name = reader.getLocalName();
if (name.equals("backup-dir"))
- conf.setBackupDir(new File(readContent()));
+ {
+ if (version != null && version.equals(VERSION_LOG_1_1))
+ {
+ String dir = readContent();
+ if (dir.equals("."))
+ {
+ String path = logFile.getParentFile().getCanonicalPath();
+ conf.setBackupDir(new File(path));
+ }
+ else
+ {
+ conf.setBackupDir(new File(dir));
+ }
+ }
+ else
+ {
+ conf.setBackupDir(new File(readContent()));
+ }
+ }
+
if (name.equals("repository"))
conf.setRepository(readContent());
@@ -557,7 +719,7 @@
{
public XMLStreamWriter run() throws Exception
{
- return XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(logFile));
+ return XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(logFile), Constants.DEFAULT_ENCODING);
}
});
}
@@ -587,12 +749,27 @@
};
writer.writeStartDocument();
- writer.writeStartElement("backup-cain-log");
+ writer.writeStartElement("backup-chain-log");
+
+ writer.writeStartElement("version-log");
+ writer.writeCharacters(versionLog);
+ writer.writeEndElement();
+
writer.flush();
}
+ public void writeWorkspaceEntry(WorkspaceEntry originalWorkspaceEntry) throws JsonException, XMLStreamException
+ {
+ JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+ JsonValue json = generatorImpl.createJsonObject(originalWorkspaceEntry);
+
+ writer.writeStartElement("original-workspace-config");
+ writer.writeCData(json.toString());
+ writer.writeEndElement();
+ }
+
public synchronized void write(BackupConfig config, String fullBackupType, String incrementalBackupType)
- throws XMLStreamException
+ throws XMLStreamException, IOException
{
writer.writeStartElement("backup-config");
@@ -607,7 +784,13 @@
if (config.getBackupDir() != null)
{
writer.writeStartElement("backup-dir");
- writer.writeCharacters(PrivilegedFileHelper.getAbsolutePath(config.getBackupDir()));
+ String path =
+ (isRootBackupManagerDir(logFile) ? PrivilegedFileHelper.getCanonicalPath(config.getBackupDir())
+ : PrivilegedFileHelper.getCanonicalPath(config.getBackupDir()).replace(
+ PrivilegedFileHelper.getCanonicalPath(logFile.getParentFile()), ""));
+
+
+ writer.writeCharacters(path.equals("") ? "." : path);
writer.writeEndElement();
}
@@ -638,7 +821,7 @@
writer.flush();
}
- public synchronized void write(JobEntryInfo info) throws XMLStreamException
+ public synchronized void write(JobEntryInfo info, BackupConfig config) throws XMLStreamException, IOException
{
writer.writeStartElement("job-entry-info");
@@ -651,7 +834,8 @@
writer.writeEndElement();
writer.writeStartElement("url");
- writer.writeCharacters(info.getURL().toString());
+ writer.writeCharacters(info.getURL().toString().replace(
+ PrivilegedFileHelper.getCanonicalPath(config.getBackupDir()) + File.separator, ""));
writer.writeEndElement();
writer.writeStartElement("date");
@@ -663,6 +847,12 @@
writer.flush();
}
+ private boolean isRootBackupManagerDir(File log) throws IOException
+ {
+ return (PrivilegedFileHelper.getCanonicalPath(log.getParentFile()).equals(PrivilegedFileHelper
+ .getCanonicalPath(rootDir)));
+ }
+
public synchronized void writeEndLog()
{
try
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/ExtendedBackupManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/ExtendedBackupManager.java 2010-11-24 15:30:57 UTC (rev 3544)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/ExtendedBackupManager.java 2010-11-24 15:35:31 UTC (rev 3545)
@@ -103,4 +103,71 @@
void restoreExistingRepository(RepositoryBackupChainLog log, RepositoryEntry repositoryEntry, boolean asynchronous)
throws BackupOperationException, BackupConfigurationException;
+ /**
+ * Restore existing workspace. Previous data will be deleted.
+ * For getting status of workspace restore can use
+ * BackupManager.getLastRestore(String repositoryName, String workspaceName) method
+ * WorkspaceEntry for restore should be contains in BackupChainLog.
+ *
+ * @param workspaceBackupIdentifier
+ * identifier to workspace backup.
+ * @param asynchronous
+ * if 'true' restore will be in asynchronous mode (i.e. in separated thread)
+ * @throws BackupOperationException
+ * if backup operation exception occurred
+ * @throws BackupConfigurationException
+ * if configuration exception occurred
+ */
+ void restoreExistingWorkspace(String workspaceBackupIdentifier, boolean asynchronous)
+ throws BackupOperationException,
+ BackupConfigurationException;
+
+ /**
+ * Restore existing repository. Previous data will be deleted.
+ * For getting status of repository restore can use
+ * BackupManager.getLastRestore(String repositoryName) method.
+ * ReprositoryEntry for restore should be contains in BackupChainLog.
+ *
+ * @param repositoryBackupIdentifier
+ * identifier to repository backup.
+ * @param asynchronous
+ * if 'true' restore will be in asynchronous mode (i.e. in separated thread)
+ * @throws BackupOperationException
+ * if backup operation exception occurred
+ * @throws BackupConfigurationException
+ * if configuration exception occurred
+ */
+ void restoreExistingRepository(String repositoryBackupIdentifier, boolean asynchronous)
+ throws BackupOperationException,
+ BackupConfigurationException;
+
+ /**
+ * WorkspaceEntry for restore should be contains in BackupChainLog.
+ *
+ * @param workspaceBackupIdentifier
+ * identifier to workspace backup.
+ * @param asynchronous
+ * if 'true' restore will be in asynchronous mode (i.e. in separated thread)
+ * @throws BackupOperationException
+ * if backup operation exception occurred
+ * @throws BackupConfigurationException
+ * if configuration exception occurred
+ */
+ void restoreWorkspace(String workspaceBackupIdentifier, boolean asynchronous) throws BackupOperationException,
+ BackupConfigurationException;
+
+ /**
+ * ReprositoryEntry for restore should be contains in BackupChainLog.
+ *
+ * @param repositoryBackupIdentifier
+ * identifier to repository backup.
+ * @param asynchronous
+ * if 'true' restore will be in asynchronous mode (i.e. in separated thread)
+ * @throws BackupOperationException
+ * if backup operation exception occurred
+ * @throws BackupConfigurationException
+ * if configuration exception occurred
+ */
+ void restoreRepository(String repositoryBackupIdentifier, boolean asynchronous) throws BackupOperationException,
+ BackupConfigurationException;
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java 2010-11-24 15:30:57 UTC (rev 3544)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java 2010-11-24 15:35:31 UTC (rev 3545)
@@ -16,25 +16,20 @@
*/
package org.exoplatform.services.jcr.ext.backup;
-import org.exoplatform.commons.utils.PrivilegedFileHelper;
-import org.exoplatform.commons.utils.SecurityHelper;
-import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
-import javax.jcr.ValueFormatException;
import javax.xml.stream.FactoryConfigurationError;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
@@ -43,6 +38,22 @@
import javax.xml.stream.XMLStreamWriter;
import javax.xml.stream.events.StartElement;
+import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.commons.utils.SecurityHelper;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.ws.frameworks.json.JsonHandler;
+import org.exoplatform.ws.frameworks.json.JsonParser;
+import org.exoplatform.ws.frameworks.json.impl.BeanBuilder;
+import org.exoplatform.ws.frameworks.json.impl.JsonDefaultHandler;
+import org.exoplatform.ws.frameworks.json.impl.JsonException;
+import org.exoplatform.ws.frameworks.json.impl.JsonGeneratorImpl;
+import org.exoplatform.ws.frameworks.json.impl.JsonParserImpl;
+import org.exoplatform.ws.frameworks.json.value.JsonValue;
+
/**
* Created by The eXo Platform SAS.
*
@@ -72,7 +83,8 @@
{
public XMLStreamWriter run() throws Exception
{
- return XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(logFile));
+ return XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(logFile),
+ Constants.DEFAULT_ENCODING);
}
});
}
@@ -103,11 +115,16 @@
writer.writeStartDocument();
writer.writeStartElement("repository-backup-chain-log");
- writer.flush();
+ writer.writeStartElement("version-log");
+ writer.writeCharacters(versionLog);
+ writer.writeEndElement();
+
writer.writeStartElement("start-time");
writer.writeCharacters(JCRDateFormat.format(startedTime));
writer.writeEndElement();
+
+ writer.flush();
}
public void writeSystemWorkspaceName(String wsName) throws XMLStreamException
@@ -118,14 +135,17 @@
writer.flush();
}
- public void writeBackupsPath(List<String> wsLogFilePathList) throws XMLStreamException
+ public void writeBackupsPath(List<String> wsLogFilePathList, RepositoryBackupConfig config)
+ throws XMLStreamException,
+ IOException
{
writer.writeStartElement("workspaces-backup-info");
for (String path : wsLogFilePathList)
{
writer.writeStartElement("url");
- writer.writeCharacters(path);
+ writer.writeCharacters(path.replace(PrivilegedFileHelper.getCanonicalPath(config.getBackupDir())
+ + File.separator, ""));
writer.writeEndElement();
}
@@ -135,7 +155,7 @@
}
public synchronized void write(RepositoryBackupConfig config, String fullBackupType, String incrementalBackupType)
- throws XMLStreamException
+ throws XMLStreamException, IOException
{
writer.writeStartElement("repository-backup-config");
@@ -154,7 +174,7 @@
if (config.getBackupDir() != null)
{
writer.writeStartElement("backup-dir");
- writer.writeCharacters(PrivilegedFileHelper.getAbsolutePath(config.getBackupDir()));
+ writer.writeCharacters(PrivilegedFileHelper.getCanonicalPath(config.getBackupDir()));
writer.writeEndElement();
}
@@ -195,6 +215,17 @@
logger.error("Can't write end log", e);
}
}
+
+ public synchronized void writeRepositoryEntry(RepositoryEntry rEntry) throws JsonException, XMLStreamException
+ {
+
+ JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+ JsonValue json = generatorImpl.createJsonObject(rEntry);
+
+ writer.writeStartElement("original-repository-config");
+ writer.writeCData(json.toString());
+ writer.writeEndElement();
+ }
}
private class LogReader
@@ -205,13 +236,15 @@
private XMLStreamReader reader;
+ private String version;
+
public LogReader(File logFile) throws FileNotFoundException, XMLStreamException, FactoryConfigurationError
{
this.logFile = logFile;
- reader = XMLInputFactory.newInstance().createXMLStreamReader(PrivilegedFileHelper.fileInputStream(logFile));
+ reader = XMLInputFactory.newInstance().createXMLStreamReader(PrivilegedFileHelper.fileInputStream(logFile), Constants.DEFAULT_ENCODING);
}
- public void readLogFile() throws XMLStreamException, MalformedURLException, ValueFormatException
+ public void readLogFile() throws UnsupportedEncodingException, Exception
{
boolean endDocument = false;
@@ -242,6 +275,15 @@
if (name.equals("finish-time"))
finishedTime = JCRDateFormat.parse(readContent());
+ if (name.equals("original-repository-config"))
+ originalRepositoryEntry = readRepositoryEntry();
+
+ if (name.equals("version-log"))
+ {
+ this.version = readContent();
+ }
+
+
break;
case StartElement.END_DOCUMENT :
@@ -251,8 +293,38 @@
}
}
- private List<String> readWorkspaceBackupInfo() throws XMLStreamException
+ private RepositoryEntry readRepositoryEntry() throws UnsupportedEncodingException, Exception
{
+ String jsonRepositoryEntry = reader.getElementText();
+
+ return (RepositoryEntry) (getObject(RepositoryEntry.class, jsonRepositoryEntry
+ .getBytes(Constants.DEFAULT_ENCODING)));
+ }
+
+ /**
+ * Will be created the Object from JSON binary data.
+ *
+ * @param cl
+ * Class
+ * @param data
+ * binary data (JSON)
+ * @return Object
+ * @throws Exception
+ * will be generated Exception
+ */
+ private Object getObject(Class cl, byte[] data) throws Exception
+ {
+ JsonHandler jsonHandler = new JsonDefaultHandler();
+ JsonParser jsonParser = new JsonParserImpl();
+ InputStream inputStream = new ByteArrayInputStream(data);
+ jsonParser.parse(inputStream, jsonHandler);
+ JsonValue jsonValue = jsonHandler.getJsonObject();
+
+ return new BeanBuilder().createObject(cl, jsonValue);
+ }
+
+ private List<String> readWorkspaceBackupInfo() throws XMLStreamException, IOException
+ {
List<String> wsBackupInfo = new ArrayList<String>();
boolean endWorkspaceBackupInfo = false;
@@ -267,7 +339,19 @@
String name = reader.getLocalName();
if (name.equals("url"))
- wsBackupInfo.add(readContent());
+ {
+ if (version != null && version.equals(VERSION_LOG_1_1))
+ {
+ String path =
+ PrivilegedFileHelper.getCanonicalPath(config.getBackupDir()) + File.separator
+ + readContent();
+ wsBackupInfo.add(path);
+ }
+ else
+ {
+ wsBackupInfo.add(readContent());
+ }
+ }
break;
@@ -283,7 +367,7 @@
return wsBackupInfo;
}
- private BackupConfig readBackupConfig() throws XMLStreamException
+ private BackupConfig readBackupConfig() throws XMLStreamException, IOException
{
BackupConfig conf = new BackupConfig();
@@ -299,8 +383,27 @@
String name = reader.getLocalName();
if (name.equals("backup-dir"))
- conf.setBackupDir(new File(readContent()));
+ {
+ if (version != null && version.equals(VERSION_LOG_1_1))
+ {
+ String dir = readContent();
+ if (dir.equals("."))
+ {
+ String path = PrivilegedFileHelper.getCanonicalPath(logFile.getParentFile());
+ conf.setBackupDir(new File(path));
+ }
+ else
+ {
+ conf.setBackupDir(new File(dir));
+ }
+ }
+ else
+ {
+ conf.setBackupDir(new File(readContent()));
+ }
+ }
+
if (name.equals("backup-type"))
conf.setBackupType(Integer.valueOf(readContent()));
@@ -348,82 +451,19 @@
return content;
}
- private JobEntryInfo readJobEntryInfo() throws XMLStreamException, MalformedURLException, ValueFormatException
+ public String getVersionLog()
{
- JobEntryInfo info = new JobEntryInfo();
-
- boolean endJobEntryInfo = false;
-
- while (!endJobEntryInfo)
- {
- int eventCode = reader.next();
- switch (eventCode)
- {
-
- case StartElement.START_ELEMENT :
- String name = reader.getLocalName();
-
- if (name.equals("type"))
- info.setType(getType(readContent()));
-
- if (name.equals("state"))
- info.setState(getState(readContent()));
-
- if (name.equals("url"))
- info.setURL(new URL(readContent()));
-
- if (name.equals("date"))
- info.setDate(JCRDateFormat.parse(readContent()));
-
- break;
-
- case StartElement.END_ELEMENT :
- String tagName = reader.getLocalName();
-
- if (tagName.equals("job-entry-info"))
- endJobEntryInfo = true;
- break;
- }
- }
-
- return info;
+ return version;
}
-
- private int getState(String content)
- {
- int state = -1;
-
- if (content.equals("FINISHED"))
- state = BackupJob.FINISHED;
-
- if (content.equals("STARTING"))
- state = BackupJob.STARTING;
-
- if (content.equals("WAITING"))
- state = BackupJob.WAITING;
-
- if (content.equals("WORKING"))
- state = BackupJob.WORKING;
-
- return state;
- }
-
- private int getType(String content)
- {
- int type = -1;
-
- if (content.equals("FULL"))
- type = BackupJob.FULL;
-
- if (content.equals("INCREMENTAL"))
- type = BackupJob.INCREMENTAL;
-
- return type;
- }
}
protected static Log logger = ExoLogger.getLogger("exo.jcr.component.ext.BackupChainLog");
+ /**
+ * Start for 1.1 version log will be stored relative paths.
+ */
+ protected static String VERSION_LOG_1_1 = "1.1";
+
public static final String PREFIX = "repository-backup-";
private static final String SUFFIX = ".xml";
@@ -452,6 +492,10 @@
private String increnetalBackupType;
+ private RepositoryEntry originalRepositoryEntry;
+
+ private final String versionLog;
+
/**
* @param logDirectory
* @param config
@@ -459,29 +503,33 @@
* @param wsLogFilePathList
* @param backupId
* @param startTime
+ * @param rEntry
* @throws BackupOperationException
*/
public RepositoryBackupChainLog(File logDirectory, RepositoryBackupConfig config, String fullBackupType,
String incrementalBackupType, String systemWorkspace, List<String> wsLogFilePathList, String backupId,
- Calendar startTime) throws BackupOperationException
+ Calendar startTime, RepositoryEntry rEntry) throws BackupOperationException
{
try
{
this.finalized = false;
+ this.versionLog = VERSION_LOG_1_1;
this.log =
- new File(PrivilegedFileHelper.getCanonicalPath(logDirectory) + File.separator
- + (PREFIX + backupId + SUFFIX));
+ new File(PrivilegedFileHelper.getCanonicalPath(logDirectory) + File.separator
+ + (PREFIX + backupId + SUFFIX));
PrivilegedFileHelper.createNewFile(this.log);
this.backupId = backupId;
this.config = config;
this.startedTime = Calendar.getInstance();
this.fullBackupType = fullBackupType;
this.increnetalBackupType = incrementalBackupType;
+ this.originalRepositoryEntry = rEntry;
logWriter = new LogWriter(log);
logWriter.write(config, fullBackupType, incrementalBackupType);
logWriter.writeSystemWorkspaceName(systemWorkspace);
- logWriter.writeBackupsPath(wsLogFilePathList);
+ logWriter.writeBackupsPath(wsLogFilePathList, config);
+ logWriter.writeRepositoryEntry(rEntry);
this.workspaceBackupsInfo = wsLogFilePathList;
this.workspaceSystem = systemWorkspace;
@@ -498,6 +546,10 @@
{
throw new BackupOperationException("Can not create backup log ...", e);
}
+ catch (JsonException e)
+ {
+ throw new BackupOperationException("Can not create backup log ...", e);
+ }
}
/**
@@ -513,37 +565,28 @@
{
logReader = new LogReader(log);
logReader.readLogFile();
+ this.versionLog = logReader.getVersionLog();
}
catch (FileNotFoundException e)
{
- throw new BackupOperationException(
-"Can not read RepositoryBackupChainLog from file :"
- + PrivilegedFileHelper.getAbsolutePath(log), e);
+ throw new BackupOperationException("Can not read RepositoryBackupChainLog from file :"
+ + PrivilegedFileHelper.getAbsolutePath(log), e);
}
catch (XMLStreamException e)
{
- throw new BackupOperationException(
-"Can not read RepositoryBackupChainLog from file :"
- + PrivilegedFileHelper.getAbsolutePath(log), e);
+ throw new BackupOperationException("Can not read RepositoryBackupChainLog from file :"
+ + PrivilegedFileHelper.getAbsolutePath(log), e);
}
- catch (FactoryConfigurationError e)
+ catch (UnsupportedEncodingException e)
{
- throw new BackupOperationException(
-"Can not read RepositoryBackupChainLog from file :"
- + PrivilegedFileHelper.getAbsolutePath(log), e);
+ throw new BackupOperationException("Can not read RepositoryBackupChainLog from file :"
+ + PrivilegedFileHelper.getAbsolutePath(log), e);
}
- catch (MalformedURLException e)
+ catch (Exception e)
{
- throw new BackupOperationException(
-"Can not read RepositoryBackupChainLog from file :"
- + PrivilegedFileHelper.getAbsolutePath(log), e);
+ throw new BackupOperationException("Can not read RepositoryBackupChainLog from file :"
+ + PrivilegedFileHelper.getAbsolutePath(log), e);
}
- catch (ValueFormatException e)
- {
- throw new BackupOperationException(
-"Can not read RepositoryBackupChainLog from file :"
- + PrivilegedFileHelper.getAbsolutePath(log), e);
- }
}
/**
@@ -606,6 +649,33 @@
finishedTime = Calendar.getInstance();
finalized = true;
logWriter.writeEndLog();
+
+ //copy backup chain log file in into Backupset files itself for portability (e.g. on another server)
+ try
+ {
+ InputStream in = PrivilegedFileHelper.fileInputStream(log);
+
+ File dest = new File(config.getBackupDir() + File.separator + log.getName());
+ if (!PrivilegedFileHelper.exists(dest))
+ {
+ OutputStream out = PrivilegedFileHelper.fileOutputStream(dest);
+
+ byte[] buf = new byte[(int) (PrivilegedFileHelper.length(log))];
+ in.read(buf);
+
+ String sConfig = new String(buf, Constants.DEFAULT_ENCODING);
+ sConfig = sConfig.replaceAll("<backup-dir>.+</backup-dir>", "<backup-dir>.</backup-dir>");
+
+ out.write(sConfig.getBytes(Constants.DEFAULT_ENCODING));
+
+ in.close();
+ out.close();
+ }
+ }
+ catch (Exception e)
+ {
+ logger.error("Can't write log", e);
+ }
}
}
@@ -642,4 +712,15 @@
return backupId;
}
+ /**
+ * Getting original repository configuration
+ *
+ * @return RepositoryEntry
+ * return the original repository configuration
+ */
+ public RepositoryEntry getOriginalRepositoryEntry()
+ {
+ return originalRepositoryEntry;
+ }
+
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupChainImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupChainImpl.java 2010-11-24 15:30:57 UTC (rev 3544)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupChainImpl.java 2010-11-24 15:35:31 UTC (rev 3545)
@@ -18,6 +18,18 @@
*/
package org.exoplatform.services.jcr.ext.backup.impl;
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.ext.backup.BackupChain;
import org.exoplatform.services.jcr.ext.backup.BackupChainLog;
@@ -30,17 +42,6 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-
/**
* Created by The eXo Platform SARL .<br/>
*
@@ -74,12 +75,16 @@
private Set<BackupJobListener> listeners = new LinkedHashSet<BackupJobListener>();
public BackupChainImpl(BackupConfig config, File logDirectory, ManageableRepository repository,
- String fullBackupType, String incrementalBackupType, String backupId) throws BackupOperationException,
+ String fullBackupType, String incrementalBackupType, String backupId, File rootDir)
+ throws BackupOperationException,
BackupConfigurationException
{
this.config = config;
this.jobs = new ArrayList<BackupJob>();
- this.chainLog = new BackupChainLog(logDirectory, config, fullBackupType, incrementalBackupType, backupId);
+
+ this.chainLog =
+ new BackupChainLog(logDirectory, config, fullBackupType, incrementalBackupType, backupId,
+ getWorkspaceEntry(config.getWorkspace(), repository), rootDir);
this.timeStamp = Calendar.getInstance();
this.backupId = backupId;
@@ -113,6 +118,29 @@
+ "_PeriodTimer_" + new SimpleDateFormat("yyyyMMdd.HHmmss.SSS").format(new Date()), true);
}
+ private WorkspaceEntry getWorkspaceEntry(String workspace, ManageableRepository repository)
+ throws BackupOperationException
+ {
+ WorkspaceEntry wEntry = null;
+
+ for (WorkspaceEntry entry : repository.getConfiguration().getWorkspaceEntries())
+ {
+ if (entry.getName().equals(workspace))
+ {
+ wEntry = entry;
+ break;
+ }
+ }
+
+ if (wEntry == null)
+ {
+ throw new BackupOperationException("Worksapce \"" + workspace + "\" was not exsisted in repository \""
+ + repository.getConfiguration().getName() + "\".");
+ }
+
+ return wEntry;
+ }
+
/**
* Add all listeners to a given job. Used in startBackup() which itself is synchronized.
*
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2010-11-24 15:30:57 UTC (rev 3544)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2010-11-24 15:35:31 UTC (rev 3545)
@@ -18,6 +18,29 @@
*/
package org.exoplatform.services.jcr.ext.backup.impl;
+import java.io.ByteArrayOutputStream;
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.PrintWriter;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.apache.commons.collections.map.HashedMap;
import org.exoplatform.commons.utils.PrivilegedFileHelper;
import org.exoplatform.commons.utils.PrivilegedSystemHelper;
@@ -74,29 +97,6 @@
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-import java.io.ByteArrayOutputStream;
-import java.io.EOFException;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.PrintWriter;
-import java.security.PrivilegedExceptionAction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
/**
* Created by The eXo Platform SAS .<br/>
*
@@ -650,7 +650,7 @@
String reposytoryName = (repositoryName == null ? config.getRepository() : repositoryName);
String workspaceName = workspaceEntry.getName();
- // ws should be registered not created
+ // ws should not exists.
if (!workspaceAlreadyExist(reposytoryName, workspaceName))
{
@@ -697,7 +697,7 @@
}
}
else
- throw new BackupConfigurationException("Workspace should exists " + workspaceName);
+ throw new BackupConfigurationException("Workspace \"" + workspaceName + "\" should not exists.");
}
private boolean workspaceAlreadyExist(String repository, String workspace) throws RepositoryException,
@@ -738,8 +738,8 @@
validateBackupConfig(config);
BackupChain bchain =
- new BackupChainImpl(config, logsDirectory, repoService.getRepository(config.getRepository()), fullBackupType,
- incrementalBackupType, IdGenerator.generate());
+ new BackupChainImpl(config, logsDirectory, repoService.getRepository(config.getRepository()),
+ fullBackupType, incrementalBackupType, IdGenerator.generate(), logsDirectory);
bchain.addListener(messagesListener);
bchain.addListener(jobListener);
@@ -1563,7 +1563,7 @@
RepositoryBackupChain repositoryBackupChain =
new RepositoryBackupChainImpl(config, logsDirectory, repository, fullBackupType, incrementalBackupType,
- IdGenerator.generate());
+ IdGenerator.generate());
repositoryBackupChain.startBackup();
@@ -1782,5 +1782,141 @@
this.restoreExistingWorkspace(backupChainLog, repositoryName, workspaceEntry, asynchronous);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public void restoreExistingRepository(String repositoryBackupIdentifier, boolean asynchronous)
+ throws BackupOperationException, BackupConfigurationException
+ {
+ RepositoryBackupChainLog backupChainLog = null;
+
+ for (RepositoryBackupChainLog chainLog : getRepositoryBackupsLogs())
+ {
+ if (chainLog.getBackupId().equals(repositoryBackupIdentifier))
+ {
+ backupChainLog = chainLog;
+ break;
+ }
+ }
+
+ if (backupChainLog == null)
+ {
+ throw new BackupConfigurationException("Can not founf backup of repository with id \""
+ + repositoryBackupIdentifier + "\"");
+ }
+
+ this.restoreExistingRepository(backupChainLog, backupChainLog.getOriginalRepositoryEntry(), asynchronous);
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void restoreExistingWorkspace(String workspaceBackupIdentifier, boolean asynchronous)
+ throws BackupOperationException, BackupConfigurationException
+ {
+ BackupChainLog backupChainLog = null;
+
+ for (BackupChainLog chainLog : getBackupsLogs())
+ {
+ if (chainLog.getBackupId().equals(workspaceBackupIdentifier))
+ {
+ backupChainLog = chainLog;
+ break;
+ }
+ }
+
+ if (backupChainLog == null)
+ {
+ throw new BackupConfigurationException("Can not founf backup of workspace with id \""
+ + workspaceBackupIdentifier + "\"");
+ }
+
+ this.restoreExistingWorkspace(backupChainLog, backupChainLog.getBackupConfig().getRepository(), backupChainLog
+ .getOriginalWorkspaceEntry(), asynchronous);
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void restoreRepository(String repositoryBackupIdentifier, boolean asynchronous)
+ throws BackupOperationException, BackupConfigurationException
+ {
+ RepositoryBackupChainLog backupChainLog = null;
+
+ for (RepositoryBackupChainLog chainLog : getRepositoryBackupsLogs())
+ {
+ if (chainLog.getBackupId().equals(repositoryBackupIdentifier))
+ {
+ backupChainLog = chainLog;
+ break;
+ }
+ }
+
+ if (backupChainLog == null)
+ {
+ throw new BackupConfigurationException("Can not founf backup of repository with id \""
+ + repositoryBackupIdentifier + "\"");
+ }
+
+ try
+ {
+ this.restore(backupChainLog, backupChainLog.getOriginalRepositoryEntry(), asynchronous);
+ }
+ catch (RepositoryException e)
+ {
+ throw new RepositoryRestoreExeption("Repository \"" + backupChainLog.getOriginalRepositoryEntry().getName()
+ + "\" was not restored", e);
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ throw new RepositoryRestoreExeption("Repository \"" + backupChainLog.getOriginalRepositoryEntry().getName()
+ + "\" was not restored", e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void restoreWorkspace(String workspaceBackupIdentifier, boolean asynchronous)
+ throws BackupOperationException, BackupConfigurationException
+ {
+ BackupChainLog backupChainLog = null;
+
+ for (BackupChainLog chainLog : getBackupsLogs())
+ {
+ if (chainLog.getBackupId().equals(workspaceBackupIdentifier))
+ {
+ backupChainLog = chainLog;
+ break;
+ }
+ }
+
+ if (backupChainLog == null)
+ {
+ throw new BackupConfigurationException("Can not founf backup of workspace with id \""
+ + workspaceBackupIdentifier + "\"");
+ }
+
+ try
+ {
+ this.restore(backupChainLog, backupChainLog.getBackupConfig().getRepository(), backupChainLog
+ .getOriginalWorkspaceEntry(), asynchronous);
+ }
+ catch (RepositoryException e)
+ {
+ throw new WorkspaceRestoreException("Workapce \"" + backupChainLog.getOriginalWorkspaceEntry().getName()
+ + "\" was not restored in repository \"" + backupChainLog.getBackupConfig().getRepository() + "\"", e);
+ }
+ catch (RepositoryConfigurationException e)
+ {
+
+ throw new WorkspaceRestoreException("Workapce \"" + backupChainLog.getOriginalWorkspaceEntry().getName()
+ + "\" was not restored in repository \"" + backupChainLog.getBackupConfig().getRepository() + "\"", e);
+ }
+
+ }
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestore.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestore.java 2010-11-24 15:30:57 UTC (rev 3544)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/JobExistedRepositoryRestore.java 2010-11-24 15:35:31 UTC (rev 3545)
@@ -16,6 +16,11 @@
*/
package org.exoplatform.services.jcr.ext.backup.impl;
+import java.util.ArrayList;
+import java.util.Map;
+
+import javax.jcr.RepositoryException;
+
import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.RepositoryEntry;
@@ -29,10 +34,6 @@
import org.exoplatform.services.jcr.impl.core.SessionRegistry;
import org.exoplatform.services.jcr.impl.util.jdbc.cleaner.DBCleanerService;
-import java.util.Map;
-
-import javax.jcr.RepositoryException;
-
/**
* Created by The eXo Platform SAS.
*
@@ -94,8 +95,12 @@
boolean isDefault =
repositoryService.getDefaultRepository().getConfiguration().getName().equals(repositoryEntry.getName());
+ //Create local copy of WorkspaceEntry for all workspaces
+ ArrayList<WorkspaceEntry> workspaceList = new ArrayList<WorkspaceEntry>();
+ workspaceList.addAll(repositoryEntry.getWorkspaceEntries());
+
//close all session
- for (WorkspaceEntry wEntry : repositoryEntry.getWorkspaceEntries())
+ for (WorkspaceEntry wEntry : workspaceList)
{
forceCloseSession(repositoryEntry.getName(), wEntry.getName());
}
@@ -111,17 +116,19 @@
}
//clean database
- dbCleanerService.cleanRepositoryData(repositoryEntry);
+ RepositoryEntry re = new RepositoryEntry();
+ re.setWorkspaceEntries(workspaceList);
+ dbCleanerService.cleanRepositoryData(re);
//clean index
- for (WorkspaceEntry wEntry : repositoryEntry.getWorkspaceEntries())
+ for (WorkspaceEntry wEntry : workspaceList)
{
indexCleanHelper.removeWorkspaceIndex(wEntry,
repositoryEntry.getSystemWorkspaceName().equals(wEntry.getName()));
}
//clean value storage
- for (WorkspaceEntry wEntry : repositoryEntry.getWorkspaceEntries())
+ for (WorkspaceEntry wEntry : workspaceList)
{
valueStorageCleanHelper.removeWorkspaceValueStorage(wEntry);
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/RepositoryBackupChainImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/RepositoryBackupChainImpl.java 2010-11-24 15:30:57 UTC (rev 3544)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/RepositoryBackupChainImpl.java 2010-11-24 15:35:31 UTC (rev 3545)
@@ -68,7 +68,8 @@
private int state;
public RepositoryBackupChainImpl(RepositoryBackupConfig config, File logDirectory, ManageableRepository repository,
- String fullBackupType, String incrementalBackupType, String repositoryBackupId) throws BackupOperationException,
+ String fullBackupType, String incrementalBackupType, String repositoryBackupId)
+ throws BackupOperationException,
BackupConfigurationException
{
this.config = config;
@@ -89,8 +90,8 @@
wsBackupConfig.setIncrementalJobPeriod(config.getIncrementalJobPeriod());
BackupChain bchain =
- new BackupChainImpl(wsBackupConfig, config.getBackupDir(), repository,
- fullBackupType, incrementalBackupType, IdGenerator.generate());
+ new BackupChainImpl(wsBackupConfig, config.getBackupDir(), repository, fullBackupType,
+ incrementalBackupType, IdGenerator.generate(), logDirectory);
wsLogFilePathList.add(bchain.getLogFilePath());
workspaceBackups.add(bchain);
@@ -103,7 +104,8 @@
repository.getConfiguration().getSystemWorkspaceName(),
wsLogFilePathList,
this.repositoryBackupId,
- startTime);
+ startTime,
+ repository.getConfiguration());
state = INITIALIZED;
}
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java 2010-11-24 15:30:57 UTC (rev 3544)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java 2010-11-24 15:35:31 UTC (rev 3545)
@@ -42,9 +42,16 @@
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.core.WorkspaceContainerFacade;
import org.exoplatform.services.jcr.ext.BaseStandaloneTest;
+import org.exoplatform.services.jcr.ext.backup.impl.IndexCleanHelper;
+import org.exoplatform.services.jcr.ext.backup.impl.ValueStorageCleanHelper;
+import org.exoplatform.services.jcr.impl.RepositoryServiceImpl;
import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.impl.core.SessionRegistry;
+import org.exoplatform.services.jcr.impl.util.jdbc.cleaner.DBCleanerService;
/**
* Created by The eXo Platform SAS Author : Peter Nedonosko peter.nedonosko(a)exoplatform.com.ua
@@ -53,7 +60,8 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
* @version $Id: AbstractBackupTestCase.java 760 2008-02-07 15:08:07Z pnedonosko $
*/
-public class AbstractBackupTestCase extends BaseStandaloneTest
+public class AbstractBackupTestCase
+ extends BaseStandaloneTest
{
protected SessionImpl ws1Session;
@@ -64,7 +72,23 @@
protected ExtendedBackupManager backup;
- class LogFilter implements FileFilter
+ /**
+ * Database cleaner.
+ */
+ private DBCleanerService dbCleanerService = new DBCleanerService();
+
+ /**
+ * Value storage cleaner.
+ */
+ private ValueStorageCleanHelper valueStorageCleanHelper = new ValueStorageCleanHelper();
+
+ /**
+ * Index storage cleaner.
+ */
+ private IndexCleanHelper indexCleanHelper = new IndexCleanHelper();
+
+ class LogFilter
+ implements FileFilter
{
public boolean accept(File pathname)
@@ -80,13 +104,13 @@
// RepositoryContainer rcontainer = (RepositoryContainer)
// container.getComponentInstanceOfType(RepositoryContainer.class);
- backup = (ExtendedBackupManager)container.getComponentInstanceOfType(BackupManager.class);
+ backup = (ExtendedBackupManager) container.getComponentInstanceOfType(BackupManager.class);
if (backup == null)
throw new Exception("There are no BackupManagerImpl in configuration");
// ws1
-
+
for (String wsName : repository.getWorkspaceNames())
{
if ("ws1".equals(wsName))
@@ -95,7 +119,7 @@
ws1TestRoot = ws1Session.getRootNode().addNode("backupTest");
ws1Session.save();
addContent(ws1TestRoot, 1, 10, 1);
-
+
}
else
{
@@ -107,7 +131,7 @@
}
// ws2
- ws2Session = (SessionImpl)repository.login(credentials, "ws2");
+ ws2Session = (SessionImpl) repository.login(credentials, "ws2");
}
@Override
@@ -116,17 +140,24 @@
for (String wsName : repository.getWorkspaceNames())
{
- if ("ws1".equals(wsName))
+ try
{
- ws1Session = (SessionImpl) repository.login(credentials, "ws1");
- ws1Session.getRootNode().getNode("backupTest").remove();
- ws1Session.save();
+ if ("ws1".equals(wsName))
+ {
+ ws1Session = (SessionImpl) repository.login(credentials, "ws1");
+ ws1Session.getRootNode().getNode("backupTest").remove();
+ ws1Session.save();
+ }
+ else
+ {
+ SessionImpl ws = (SessionImpl) repository.login(credentials, wsName);
+ ws.getRootNode().getNode("backupTest").remove();
+ ws.save();
+ }
}
- else
+ catch (PathNotFoundException e)
{
- SessionImpl ws = (SessionImpl)repository.login(credentials, wsName);
- ws.getRootNode().getNode("backupTest").remove();
- ws.save();
+ //skip
}
}
@@ -134,13 +165,13 @@
protected WorkspaceEntry makeWorkspaceEntry(String name, String sourceName)
{
- WorkspaceEntry ws1e = (WorkspaceEntry)ws1Session.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
+ WorkspaceEntry ws1e = (WorkspaceEntry) ws1Session.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
WorkspaceEntry ws1back = new WorkspaceEntry();
ws1back.setName(name);
// RepositoryContainer rcontainer = (RepositoryContainer)
// container.getComponentInstanceOfType(RepositoryContainer.class);
- ws1back.setUniqueName(((RepositoryImpl)ws1Session.getRepository()).getName() + "_" + ws1back.getName()); // EXOMAN
+ ws1back.setUniqueName(((RepositoryImpl) ws1Session.getRepository()).getName() + "_" + ws1back.getName()); // EXOMAN
ws1back.setAccessManager(ws1e.getAccessManager());
ws1back.setCache(ws1e.getCache());
@@ -152,16 +183,17 @@
ArrayList qParams = new ArrayList();
// qParams.add(new SimpleParameterEntry("indexDir", "target" + File.separator+ "temp" +
// File.separator +"index" + name));
- qParams.add(new SimpleParameterEntry(QueryHandlerParams.PARAM_INDEX_DIR, "target" + File.separator + name + System.currentTimeMillis()));
+ qParams.add(new SimpleParameterEntry(QueryHandlerParams.PARAM_INDEX_DIR, "target" + File.separator + name
+ + System.currentTimeMillis()));
QueryHandlerEntry qEntry =
- new QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex", qParams);
+ new QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex", qParams);
ws1back.setQueryHandler(qEntry); // EXOMAN
ArrayList params = new ArrayList();
for (Iterator i = ws1back.getContainer().getParameters().iterator(); i.hasNext();)
{
- SimpleParameterEntry p = (SimpleParameterEntry)i.next();
+ SimpleParameterEntry p = (SimpleParameterEntry) i.next();
SimpleParameterEntry newp = new SimpleParameterEntry(p.getName(), p.getValue());
if (newp.getName().equals("source-name"))
@@ -173,45 +205,49 @@
}
ContainerEntry ce =
- new ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer", params);
+ new ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer", params);
ws1back.setContainer(ce);
return ws1back;
}
-
- protected RepositoryEntry makeRepositoryEntry(String repoName, RepositoryEntry baseRepoEntry, String sourceName, Map<String, String> workspaceMapping)
+
+ protected RepositoryEntry makeRepositoryEntry(String repoName, RepositoryEntry baseRepoEntry, String sourceName,
+ Map<String, String> workspaceMapping)
{
ArrayList<WorkspaceEntry> wsEntries = new ArrayList<WorkspaceEntry>();
-
+
for (WorkspaceEntry wsEntry : baseRepoEntry.getWorkspaceEntries())
{
- String newWorkspaceName = wsEntry.getName();
+ String newWorkspaceName = wsEntry.getName();
if (workspaceMapping != null)
{
newWorkspaceName = workspaceMapping.get(wsEntry.getName());
}
-
+
WorkspaceEntry newWSEntry = makeWorkspaceEntry(wsEntry, newWorkspaceName, repoName, sourceName);
-
+
wsEntries.add(newWSEntry);
}
-
+
RepositoryEntry newRepositoryEntry = new RepositoryEntry();
-
- newRepositoryEntry.setSystemWorkspaceName(workspaceMapping == null ? baseRepoEntry.getSystemWorkspaceName() : workspaceMapping.get(baseRepoEntry.getSystemWorkspaceName()));
+
+ newRepositoryEntry.setSystemWorkspaceName(workspaceMapping == null ? baseRepoEntry.getSystemWorkspaceName()
+ : workspaceMapping.get(baseRepoEntry.getSystemWorkspaceName()));
newRepositoryEntry.setAccessControl(baseRepoEntry.getAccessControl());
newRepositoryEntry.setAuthenticationPolicy(baseRepoEntry.getAuthenticationPolicy());
- newRepositoryEntry.setDefaultWorkspaceName(workspaceMapping == null ? baseRepoEntry.getDefaultWorkspaceName() : workspaceMapping.get(baseRepoEntry.getDefaultWorkspaceName()));
+ newRepositoryEntry.setDefaultWorkspaceName(workspaceMapping == null ? baseRepoEntry.getDefaultWorkspaceName()
+ : workspaceMapping.get(baseRepoEntry.getDefaultWorkspaceName()));
newRepositoryEntry.setName(repoName);
newRepositoryEntry.setSecurityDomain(baseRepoEntry.getSecurityDomain());
newRepositoryEntry.setSessionTimeOut(baseRepoEntry.getSessionTimeOut());
-
+
newRepositoryEntry.setWorkspaceEntries(wsEntries);
-
+
return newRepositoryEntry;
}
-
- protected WorkspaceEntry makeWorkspaceEntry(WorkspaceEntry baseWorkspaceEntry, String wsName, String repoName, String sourceName)
+
+ protected WorkspaceEntry makeWorkspaceEntry(WorkspaceEntry baseWorkspaceEntry, String wsName, String repoName,
+ String sourceName)
{
WorkspaceEntry ws1back = new WorkspaceEntry();
ws1back.setName(wsName);
@@ -227,21 +263,22 @@
if (sourceName != null)
{
ArrayList qParams = new ArrayList();
- qParams.add(new SimpleParameterEntry(QueryHandlerParams.PARAM_INDEX_DIR, "target" + File.separator + repoName + "_" + wsName));
+ qParams.add(new SimpleParameterEntry(QueryHandlerParams.PARAM_INDEX_DIR, "target" + File.separator + repoName
+ + "_" + wsName));
QueryHandlerEntry qEntry =
- new QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex", qParams);
-
- ws1back.setQueryHandler(qEntry);
- }
+ new QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex", qParams);
+
+ ws1back.setQueryHandler(qEntry);
+ }
else
{
ws1back.setQueryHandler(baseWorkspaceEntry.getQueryHandler());
}
-
+
ArrayList params = new ArrayList();
for (Iterator i = ws1back.getContainer().getParameters().iterator(); i.hasNext();)
{
- SimpleParameterEntry p = (SimpleParameterEntry)i.next();
+ SimpleParameterEntry p = (SimpleParameterEntry) i.next();
SimpleParameterEntry newp = new SimpleParameterEntry(p.getName(), p.getValue());
if (newp.getName().equals("source-name"))
@@ -252,7 +289,7 @@
}
}
else if (newp.getName().equals("swap-directory"))
- newp.setValue("target/temp/swap/" + repoName + "_" + wsName);
+ newp.setValue("target/temp/swap/" + repoName + "_" + wsName);
else if (newp.getName().equals("multi-db"))
newp.setValue("false");
@@ -260,18 +297,19 @@
}
ContainerEntry ce =
- new ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer", params);
+ new ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer", params);
ws1back.setContainer(ce);
return ws1back;
}
protected void restoreAndCheck(String workspaceName, String datasourceName, String backupLogFilePath, File backDir,
- int startIndex, int stopIndex) throws RepositoryConfigurationException, RepositoryException,
- BackupOperationException, BackupConfigurationException
+ int startIndex, int stopIndex) throws RepositoryConfigurationException, RepositoryException,
+ BackupOperationException, BackupConfigurationException
{
// restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re =
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1back = makeWorkspaceEntry(workspaceName, datasourceName);
repository.configWorkspace(ws1back);
@@ -286,12 +324,12 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)repository.login(credentials, ws1back.getName());
+ back1 = (SessionImpl) repository.login(credentials, ws1back.getName());
Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
for (int i = startIndex; i < stopIndex; i++)
{
assertEquals("Restored content should be same", "property-" + i, ws1backTestRoot.getNode("node_" + i)
- .getProperty("exo:data").getString());
+ .getProperty("exo:data").getString());
}
}
catch (Exception e)
@@ -310,8 +348,8 @@
}
protected void addContent(Node node, int startIndex, int stopIndex, long sleepTime) throws ValueFormatException,
- VersionException, LockException, ConstraintViolationException, ItemExistsException, PathNotFoundException,
- RepositoryException, InterruptedException
+ VersionException, LockException, ConstraintViolationException, ItemExistsException, PathNotFoundException,
+ RepositoryException, InterruptedException
{
for (int i = startIndex; i <= stopIndex; i++)
{
@@ -333,4 +371,120 @@
Thread.sleep(250);
}
+ protected void removeWorkspaceFully(String repositoryName, String workspaceName) throws Exception
+ {
+ // get current workspace configuration
+ WorkspaceEntry wEntry = null;;
+ for (WorkspaceEntry entry : repositoryService.getRepository(repositoryName).getConfiguration()
+ .getWorkspaceEntries())
+ {
+ if (entry.getName().equals(workspaceName))
+ {
+ wEntry = entry;
+ break;
+ }
+ }
+
+ if (wEntry == null)
+ {
+ throw new WorkspaceRestoreException("Workspace " + workspaceName
+ + " did not found in current repository " + repositoryName + " configuration");
+ }
+
+ boolean isSystem =
+ repositoryService.getRepository(repositoryName).getConfiguration().getSystemWorkspaceName().equals(
+ wEntry.getName());
+
+ //close all session
+ forceCloseSession(repositoryName, wEntry.getName());
+
+ repositoryService.getRepository(repositoryName).removeWorkspace(wEntry.getName());
+
+ //clean database
+ dbCleanerService.cleanWorkspaceData(wEntry);
+
+ //clean index
+ indexCleanHelper.removeWorkspaceIndex(wEntry, isSystem);
+
+ //clean value storage
+ valueStorageCleanHelper.removeWorkspaceValueStorage(wEntry);
+ }
+
+ protected void removeRepositoryFully(String repositoryName) throws Exception
+ {
+ // get current repository configuration
+ RepositoryEntry repositoryEntry = repositoryService.getConfig().getRepositoryConfiguration(repositoryName);
+
+ if (repositoryEntry == null)
+ {
+ throw new RepositoryRestoreExeption("Current repository configuration " + repositoryName + " did not found");
+ }
+
+ boolean isDefault =
+ repositoryService.getDefaultRepository().getConfiguration().getName().equals(repositoryEntry.getName());
+
+ //Create local copy of WorkspaceEntry for all workspaces
+ ArrayList<WorkspaceEntry> workspaceList = new ArrayList<WorkspaceEntry>();
+ workspaceList.addAll(repositoryEntry.getWorkspaceEntries());
+
+ //close all session
+ for (WorkspaceEntry wEntry : workspaceList)
+ {
+ forceCloseSession(repositoryEntry.getName(), wEntry.getName());
+ }
+
+ //remove repository
+ if (isDefault)
+ {
+ ((RepositoryServiceImpl) repositoryService).removeDefaultRepository();
+ }
+ else
+ {
+ repositoryService.removeRepository(repositoryEntry.getName());
+ }
+
+ //clean database
+ RepositoryEntry re = new RepositoryEntry();
+ re.setWorkspaceEntries(workspaceList);
+ dbCleanerService.cleanRepositoryData(re);
+
+ //clean index
+ for (WorkspaceEntry wEntry : workspaceList)
+ {
+ indexCleanHelper.removeWorkspaceIndex(wEntry, repositoryEntry.getSystemWorkspaceName()
+ .equals(wEntry.getName()));
+ }
+
+ //clean value storage
+ for (WorkspaceEntry wEntry : workspaceList)
+ {
+ valueStorageCleanHelper.removeWorkspaceValueStorage(wEntry);
+ }
+
+ }
+
+ /**
+ * forceCloseSession. Close sessions on specific workspace.
+ *
+ * @param repositoryName
+ * repository name
+ * @param workspaceName
+ * workspace name
+ * @return int return the how many sessions was closed
+ * @throws RepositoryConfigurationException
+ * will be generate RepositoryConfigurationException
+ * @throws RepositoryException
+ * will be generate RepositoryException
+ */
+ private int forceCloseSession(String repositoryName, String workspaceName) throws RepositoryException,
+ RepositoryConfigurationException
+ {
+ ManageableRepository mr = repositoryService.getRepository(repositoryName);
+ WorkspaceContainerFacade wc = mr.getWorkspaceContainer(workspaceName);
+
+ SessionRegistry sessionRegistry = (SessionRegistry) wc.getComponent(SessionRegistry.class);
+
+ return sessionRegistry.closeSessions(workspaceName);
+ }
+
}
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java 2010-11-24 15:30:57 UTC (rev 3544)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java 2010-11-24 15:35:31 UTC (rev 3545)
@@ -18,15 +18,6 @@
*/
package org.exoplatform.services.jcr.ext.backup;
-import org.apache.commons.collections.map.HashedMap;
-import org.exoplatform.services.jcr.config.RepositoryEntry;
-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.core.SessionImpl;
-
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -37,6 +28,15 @@
import javax.jcr.RepositoryException;
import javax.jcr.lock.Lock;
+import org.apache.commons.collections.map.HashedMap;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+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.core.SessionImpl;
+
/**
* Created by The eXo Platform SAS.
* Author : Peter Nedonosko peter.nedonosko(a)exoplatform.com.ua
@@ -45,7 +45,8 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
* @version $Id: TestBackupManager.java 760 2008-02-07 15:08:07Z pnedonosko $
*/
-public class TestBackupManager extends AbstractBackupTestCase
+public class TestBackupManager
+ extends AbstractBackupTestCase
{
public void testFullBackupRestore() throws Exception
@@ -80,7 +81,8 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re =
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1back = makeWorkspaceEntry("ws1back", "jdbcjcr_backup_only_use_1");
// BackupChainLog bchLog = new BackupChainLog(backDir, rconfig);
@@ -98,10 +100,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)repository.login(credentials, "ws1back");
+ back1 = (SessionImpl) repository.login(credentials, "ws1back");
Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
- .getProperty("exo:data").getString());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -158,7 +160,8 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re =
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1back = makeWorkspaceEntry("ws1back.incr", "jdbcjcr_backup_only_use_2");
File backLog = new File(bch.getLogFilePath());
@@ -175,16 +178,16 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)repository.login(credentials, ws1back.getName());
+ back1 = (SessionImpl) repository.login(credentials, ws1back.getName());
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());
+ .getProperty("exo:data").getString());
assertEquals("Restored content should be same", "property #5", ws1backTestRoot.getNode("node #5")
- .getProperty("exo:extraData").getString());
+ .getProperty("exo:extraData").getString());
assertFalse("Proeprty should be removed", ws1backTestRoot.getNode("node #5").hasProperty("exo:data"));
}
@@ -204,10 +207,11 @@
}
/**
- * With BLOBs, locks, copy and move
- *
- * @throws Exception
- */
+ * With BLOBs, locks, copy and move
+ *
+ * @throws Exception
+ */
+
public void testIncrementalBackupRestore2() throws Exception
{
// full backup with BLOBs & incremental with BLOBs
@@ -251,7 +255,7 @@
ws1TestRoot.addNode("node_102").setProperty("exo:data", new FileInputStream(tempf));
ws1TestRoot.save(); // log here via listener
- ws1TestRoot.getNode("node_2").setProperty("exo:data", (InputStream)null); // remove property
+ ws1TestRoot.getNode("node_2").setProperty("exo:data", (InputStream) null); // remove property
ws1TestRoot.getNode("node_3").setProperty("exo:data", new ByteArrayInputStream("aaa".getBytes())); // set
// aaa
// bytes
@@ -262,7 +266,7 @@
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.getNode("node_5").getPath() + "/node #53");
ws1TestRoot.save(); // log here via listener
ws1TestRoot.getNode("node_6").addMixin("mix:referenceable");
@@ -270,8 +274,8 @@
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
+ ws1TestRoot.getSession().getWorkspace().move(ws1TestRoot.getNode("node_6").getPath(),
+ ws1TestRoot.getPath() + "/node_4"); // in place of
// 4 removed
// stop all
@@ -281,7 +285,8 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re =
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1back = makeWorkspaceEntry("ws1back.incr2", "jdbcjcr_backup_only_use_3");
File backLog = new File(bch.getLogFilePath());
@@ -298,12 +303,12 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)repository.login(credentials, ws1back.getName());
+ back1 = (SessionImpl) repository.login(credentials, ws1back.getName());
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"));
+ .hasProperty("node #53/exo:extraData"));
assertTrue("Node should exists", ws1backTestRoot.hasNode("node_7"));
assertTrue("Property should exists", ws1backTestRoot.hasProperty("node_5/exo:data"));
@@ -311,20 +316,20 @@
assertTrue("Node should exists", ws1backTestRoot.hasNode("node_102"));
compareStream(new FileInputStream(tempf), ws1backTestRoot.getNode("node_5").getProperty("exo:data")
- .getStream());
+ .getStream());
compareStream(new FileInputStream(tempf), ws1backTestRoot.getNode("node_1").getProperty("exo:extraData")
- .getStream());
+ .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());
+ 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());
+ assertEquals("Node should be mix:referenceable and UUID should be " + id6, id6, ws1backTestRoot.getNode(
+ "node_4").getUUID());
}
catch (Exception e)
{
@@ -343,9 +348,9 @@
public void testFullBackupRestoreAsync() throws Exception
{
- SessionImpl sessionWS1 = (SessionImpl)repository.login(credentials, "ws1");
- sessionWS1.getRootNode().addNode("backupTest").addNode("node_5")
- .setProperty("exo:data", "Restored content should be same");
+ SessionImpl sessionWS1 = (SessionImpl) repository.login(credentials, "ws1");
+ sessionWS1.getRootNode().addNode("backupTest").addNode("node_5").setProperty("exo:data",
+ "Restored content should be same");
sessionWS1.save();
// backup
@@ -391,22 +396,22 @@
backup.restore(bchLog, repository.getName(), ws1back, true);
while (backup.getLastRestore(repository.getName(), ws1back.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_SUCCESSFUL
- && backup.getLastRestore(repository.getName(), ws1back.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
+ && backup.getLastRestore(repository.getName(), ws1back.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
{
Thread.sleep(50);
}
if (backup.getLastRestore(repository.getName(), ws1back.getName()).getStateRestore() == JobWorkspaceRestore.RESTORE_FAIL)
- throw (Exception)backup.getLastRestore(repository.getName(), ws1back.getName()).getRestoreException();
+ throw (Exception) backup.getLastRestore(repository.getName(), ws1back.getName()).getRestoreException();
// check
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)repository.login(credentials, "ws1back5");
+ back1 = (SessionImpl) repository.login(credentials, "ws1back5");
Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
- .getProperty("exo:data").getString());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -501,10 +506,10 @@
public void testTwoRestores() throws Exception
{
{
- SessionImpl sessionWS1 = (SessionImpl)repository.login(credentials, "ws3");
+ SessionImpl sessionWS1 = (SessionImpl) repository.login(credentials, "ws3");
- sessionWS1.getRootNode().addNode("asdasdasda", "nt:unstructured")
- .setProperty("data", new FileInputStream(createBLOBTempFile(1024)));
+ sessionWS1.getRootNode().addNode("asdasdasda", "nt:unstructured").setProperty("data",
+ new FileInputStream(createBLOBTempFile(1024)));
sessionWS1.save();
// 1-st backup
@@ -537,12 +542,12 @@
backup.restore(bchLog, repository.getName(), ws1_restore_1, false);
// check
- SessionImpl back1 = (SessionImpl)repository.login(credentials, "ws1_restore_1");
+ SessionImpl back1 = (SessionImpl) repository.login(credentials, "ws1_restore_1");
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.getRootNode().addNode("gdfgrghfhf", "nt:unstructured").setProperty("data",
+ new FileInputStream(createBLOBTempFile(1024)));
back1.save();
}
else
@@ -580,7 +585,7 @@
backup.restore(bchLog, repository.getName(), ws1_restore_2, false);
// check
- SessionImpl back2 = (SessionImpl)repository.login(credentials, "ws1_restore_2");
+ SessionImpl back2 = (SessionImpl) repository.login(credentials, "ws1_restore_2");
assertNotNull(back2.getRootNode().getNode("gdfgrghfhf").getProperty("data"));
}
else
@@ -695,7 +700,8 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re =
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1back = makeWorkspaceEntry("ws1backt", "jdbcjcr_backup_only_use_8_NOT_EXIST");
File backLog = new File(bch.getLogFilePath());
@@ -721,10 +727,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)repository.login(credentials, "ws1back");
+ back1 = (SessionImpl) repository.login(credentials, "ws1back");
Node ws1backTestRoot = back1.getRootNode().getNode("backupTest");
assertEquals("Restored content should be same", "property-5", ws1backTestRoot.getNode("node_5")
- .getProperty("exo:data").getString());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -769,11 +775,12 @@
backup.stopBackup(bch);
// restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re =
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
String newRepositoryName = "repo_restored_1";
RepositoryEntry newRepositoryEntry =
- makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_1", null);
+ makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_1", null);
File backLog = new File(bch.getLogFilePath());
if (backLog.exists())
@@ -784,8 +791,8 @@
assertNotNull(bchLog.getFinishedTime());
backup.restore(bchLog, newRepositoryEntry, false);
- assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL,
- backup.getLastRepositoryRestore(newRepositoryEntry.getName()).getStateRestore());
+ assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(
+ newRepositoryEntry.getName()).getStateRestore());
// check
ManageableRepository restoredRepository = repositoryService.getRepository(newRepositoryName);
@@ -795,10 +802,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)restoredRepository.login(credentials, wsName);
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -845,11 +852,12 @@
backup.stopBackup(bch);
// restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re =
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
String newRepositoryName = "repo_restored_4";
RepositoryEntry newRepositoryEntry =
- makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_4", null);
+ makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_4", null);
File backLog = new File(bch.getLogFilePath());
if (backLog.exists())
@@ -869,10 +877,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)repository.login(credentials, wsName);
+ back1 = (SessionImpl) repository.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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -918,11 +926,12 @@
backup.stopBackup(bch);
// restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re =
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
String newRepositoryName = "repo_restored_2";
RepositoryEntry newRepositoryEntry =
- makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_2", null);
+ makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_2", null);
File backLog = new File(bch.getLogFilePath());
if (backLog.exists())
@@ -937,7 +946,7 @@
JobRepositoryRestore job = backup.getLastRepositoryRestore(newRepositoryName);
while (job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL
- || job.getStateRestore() == JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
+ || job.getStateRestore() == JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
{
Thread.yield();
Thread.sleep(50);
@@ -951,10 +960,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)restoredRepository.login(credentials, wsName);
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1000,11 +1009,12 @@
backup.stopBackup(bch);
// restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re =
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
String newRepositoryName = "repo_restored_3";
RepositoryEntry newRepositoryEntry =
- makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_3", null);
+ makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_3", null);
// create workspace mappingS
Map<String, String> workspaceMapping = new HashedMap();
@@ -1039,7 +1049,7 @@
JobRepositoryRestore job = backup.getLastRepositoryRestore(newRepositoryName);
while (job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL
- || job.getStateRestore() == JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
+ || job.getStateRestore() == JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
{
Thread.yield();
Thread.sleep(50);
@@ -1053,10 +1063,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)restoredRepository.login(credentials, workspaceMapping.get(wsName));
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1101,11 +1111,12 @@
public void testRepositoryRestoreFail() throws Exception
{
// restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re =
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
String newRepositoryName = "repo_restored_5";
RepositoryEntry newRepositoryEntry =
- makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_5", null);
+ makeRepositoryEntry(newRepositoryName, re, "jdbcjcr_to_repository_restore_5", null);
//create broken system workspaceEntry
newRepositoryEntry.getWorkspaceEntries().get(0).getQueryHandler().setType("gg");
@@ -1183,7 +1194,8 @@
ws1Session.getRootNode().save();
// restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re =
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1back = makeWorkspaceEntry("ws1back.incr737", "jdbcjcr25");
File backLog = new File(bch.getLogFilePath());
@@ -1200,7 +1212,7 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)repository.login(credentials, ws1back.getName());
+ back1 = (SessionImpl) repository.login(credentials, ws1back.getName());
Node node_101 = back1.getRootNode().getNode("node_101");
assertNotNull(node_101);
@@ -1260,7 +1272,8 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re =
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1 = null;
for (WorkspaceEntry we : re.getWorkspaceEntries())
{
@@ -1285,10 +1298,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)repository.login(credentials, "ws1");
+ back1 = (SessionImpl) repository.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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1337,7 +1350,8 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re =
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1 = null;
for (WorkspaceEntry we : re.getWorkspaceEntries())
{
@@ -1359,7 +1373,7 @@
backup.restoreExistingWorkspace(bchLog, re.getName(), ws1, true);
while (backup.getLastRestore(repository.getName(), ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_SUCCESSFUL
- && backup.getLastRestore(repository.getName(), ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
+ && backup.getLastRestore(repository.getName(), ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
{
Thread.sleep(50);
}
@@ -1368,10 +1382,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)repository.login(credentials, "ws1");
+ back1 = (SessionImpl) repository.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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1420,7 +1434,8 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re =
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1 = null;
for (WorkspaceEntry we : re.getWorkspaceEntries())
{
@@ -1442,7 +1457,7 @@
backup.restoreExistingWorkspace(bchLog.getBackupId(), re.getName(), ws1, true);
while (backup.getLastRestore(repository.getName(), ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_SUCCESSFUL
- && backup.getLastRestore(repository.getName(), ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
+ && backup.getLastRestore(repository.getName(), ws1.getName()).getStateRestore() != JobWorkspaceRestore.RESTORE_FAIL)
{
Thread.sleep(50);
}
@@ -1451,10 +1466,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)repository.login(credentials, "ws1");
+ back1 = (SessionImpl) repository.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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1473,33 +1488,19 @@
public void testExistedRepositoryRestore() throws Exception
{
- RepositoryImpl repositoryDB8 = (RepositoryImpl)repositoryService.getRepository("db8");
-
- for (String wsName : repositoryDB8.getWorkspaceNames())
- {
- SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, wsName);
-
- Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
- sessionWS.getRootNode().save();
- addContent(wsTestRoot, 1, 10, 1);
- sessionWS.getRootNode().save();
- }
-
- SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, WS_NAME);
-
// backup
File backDir = new File("target/backup");
backDir.mkdirs();
RepositoryBackupConfig config = new RepositoryBackupConfig();
- config.setRepository(repositoryDB8.getName());
+ config.setRepository(repository.getName());
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
config.setBackupDir(backDir);
backup.startBackup(config);
- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryDB8.getName());
+ RepositoryBackupChain bch = backup.findRepositoryBackup(repository.getName());
// wait till full backup will be stopped
while (bch.getState() != RepositoryBackupChain.FINISHED)
@@ -1514,7 +1515,7 @@
// restore
RepositoryEntry baseRE =
- (RepositoryEntry)sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
RepositoryEntry re = makeRepositoryEntry(baseRE.getName(), baseRE, null, null);
File backLog = new File(bch.getLogFilePath());
@@ -1528,7 +1529,7 @@
backup.restoreExistingRepository(bchLog, re, false);
assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(re.getName())
- .getStateRestore());
+ .getStateRestore());
// check
ManageableRepository restoredRepository = repositoryService.getRepository(re.getName());
@@ -1538,10 +1539,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)restoredRepository.login(credentials, wsName);
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1561,11 +1562,11 @@
public void testExistedRepositoryRestoreMultiDB() throws Exception
{
- RepositoryImpl repositoryDB7 = (RepositoryImpl)repositoryService.getRepository("db7");
+ RepositoryImpl repositoryDB7 = (RepositoryImpl) repositoryService.getRepository("db7");
for (String wsName : repositoryDB7.getWorkspaceNames())
{
- SessionImpl sessionWS = (SessionImpl)repositoryDB7.login(credentials, wsName);
+ SessionImpl sessionWS = (SessionImpl) repositoryDB7.login(credentials, wsName);
Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
sessionWS.getRootNode().save();
@@ -1573,7 +1574,7 @@
sessionWS.getRootNode().save();
}
- SessionImpl sessionWS = (SessionImpl)repositoryDB7.login(credentials, WS_NAME);
+ SessionImpl sessionWS = (SessionImpl) repositoryDB7.login(credentials, WS_NAME);
// backup
File backDir = new File("target/backup");
@@ -1602,7 +1603,7 @@
// restore
RepositoryEntry baseRE =
- (RepositoryEntry)sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ (RepositoryEntry) sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
RepositoryEntry re = makeRepositoryEntry(baseRE.getName(), baseRE, null, null);
File backLog = new File(bch.getLogFilePath());
@@ -1616,7 +1617,7 @@
backup.restoreExistingRepository(bchLog, re, false);
assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(re.getName())
- .getStateRestore());
+ .getStateRestore());
// check
ManageableRepository restoredRepository = repositoryService.getRepository(re.getName());
@@ -1626,10 +1627,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)restoredRepository.login(credentials, wsName);
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1649,33 +1650,19 @@
public void testExistedRepositoryRestoreAsync() throws Exception
{
- RepositoryImpl repositoryDB8 = (RepositoryImpl)repositoryService.getRepository("db8");
-
- for (String wsName : repositoryDB8.getWorkspaceNames())
- {
- SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, wsName);
-
- Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
- sessionWS.getRootNode().save();
- addContent(wsTestRoot, 1, 10, 1);
- sessionWS.getRootNode().save();
- }
-
- SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, "ws1");
-
// backup
File backDir = new File("target/backup");
backDir.mkdirs();
RepositoryBackupConfig config = new RepositoryBackupConfig();
- config.setRepository(repositoryDB8.getName());
+ config.setRepository(repository.getName());
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
config.setBackupDir(backDir);
backup.startBackup(config);
- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryDB8.getName());
+ RepositoryBackupChain bch = backup.findRepositoryBackup(repository.getName());
// wait till full backup will be stopped
while (bch.getState() != RepositoryBackupChain.FINISHED)
@@ -1690,7 +1677,7 @@
// restore
RepositoryEntry baseRE =
- (RepositoryEntry)sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
RepositoryEntry re = makeRepositoryEntry(baseRE.getName(), baseRE, null, null);
File backLog = new File(bch.getLogFilePath());
@@ -1706,13 +1693,13 @@
JobRepositoryRestore job = backup.getLastRepositoryRestore(re.getName());
while (job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL
- && job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
+ && job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
{
Thread.sleep(50);
}
assertEquals(JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(re.getName())
- .getStateRestore());
+ .getStateRestore());
// check
ManageableRepository restoredRepository = repositoryService.getRepository(re.getName());
@@ -1722,10 +1709,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)restoredRepository.login(credentials, wsName);
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1745,34 +1732,19 @@
public void testExistedRepositoryRestoreAsync2() throws Exception
{
- RepositoryImpl repositoryDB8 = (RepositoryImpl)repositoryService.getRepository("db8");
-
- for (String wsName : repositoryDB8.getWorkspaceNames())
- {
- SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, wsName);
-
- Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
- sessionWS.getRootNode().save();
- addContent(wsTestRoot, 1, 10, 1);
- sessionWS.getRootNode().save();
- }
-
- SessionImpl sessionWS = (SessionImpl)repositoryDB8.login(credentials, "ws1");
-
-
// backup
File backDir = new File("target/backup");
backDir.mkdirs();
RepositoryBackupConfig config = new RepositoryBackupConfig();
- config.setRepository(repositoryDB8.getName());
+ config.setRepository(repository.getName());
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
config.setBackupDir(backDir);
backup.startBackup(config);
- RepositoryBackupChain bch = backup.findRepositoryBackup(repositoryDB8.getName());
+ RepositoryBackupChain bch = backup.findRepositoryBackup(repository.getName());
// wait till full backup will be stopped
while (bch.getState() != RepositoryBackupChain.FINISHED)
@@ -1787,7 +1759,7 @@
// restore
RepositoryEntry baseRE =
- (RepositoryEntry)sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ (RepositoryEntry) ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
RepositoryEntry re = makeRepositoryEntry(baseRE.getName(), baseRE, null, null);
File backLog = new File(bch.getLogFilePath());
@@ -1803,13 +1775,13 @@
JobRepositoryRestore job = backup.getLastRepositoryRestore(re.getName());
while (job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL
- && job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
+ && job.getStateRestore() != JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
{
Thread.sleep(50);
}
assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(re.getName())
- .getStateRestore());
+ .getStateRestore());
// check
ManageableRepository restoredRepository = repositoryService.getRepository(re.getName());
@@ -1819,10 +1791,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)restoredRepository.login(credentials, wsName);
+ 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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1842,9 +1814,9 @@
public void testExistedWorkspaceRestoreMultiDB() throws Exception
{
- RepositoryImpl repositoryDB7 = (RepositoryImpl)repositoryService.getRepository("db7");
+ RepositoryImpl repositoryDB7 = (RepositoryImpl) repositoryService.getRepository("db7");
- SessionImpl sessionWS = (SessionImpl)repositoryDB7.login(credentials, "ws1");
+ SessionImpl sessionWS = (SessionImpl) repositoryDB7.login(credentials, "ws1");
Node wsTestRoot = sessionWS.getRootNode().addNode("backupTest");
sessionWS.getRootNode().save();
@@ -1881,7 +1853,7 @@
fail("Can't get fullBackup chain");
// restore
- RepositoryEntry re = (RepositoryEntry)sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ RepositoryEntry re = (RepositoryEntry) sessionWS.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
WorkspaceEntry ws1 = null;
for (WorkspaceEntry we : re.getWorkspaceEntries())
{
@@ -1906,10 +1878,10 @@
SessionImpl back1 = null;
try
{
- back1 = (SessionImpl)repositoryDB7.login(credentials, "ws1");
+ back1 = (SessionImpl) repositoryDB7.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());
+ .getProperty("exo:data").getString());
}
catch (Exception e)
{
@@ -1925,4 +1897,288 @@
else
fail("There are no backup files in " + backDir.getAbsolutePath());
}
+
+ public void testExistedWorkspaceRestoreWithConfig() throws Exception
+ {
+ // backup
+ File backDir = new File("target/backup/ws1");
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+ config.setRepository(repository.getName());
+ config.setWorkspace("ws1");
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+
+ config.setBackupDir(backDir);
+
+ backup.startBackup(config);
+
+ BackupChain bch = backup.findBackup(repository.getName(), "ws1");
+
+ // 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();
+
+ File backLog = new File(bch.getLogFilePath());
+ if (backLog.exists())
+ {
+ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+ assertNotNull(bchLog.getStartedTime());
+ assertNotNull(bchLog.getFinishedTime());
+
+ backup.restoreExistingWorkspace(bchLog.getBackupId(), false);
+
+ // check
+ SessionImpl back1 = null;
+ try
+ {
+ back1 = (SessionImpl) repository.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());
+ }
+
+ public void testExistedRepositoryRestoreWithConfig() throws Exception
+ {
+ // backup
+ File backDir = new File("target/backup/db1");
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+ String repoName = repository.getName();
+ config.setRepository(repoName);
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+
+ config.setBackupDir(backDir);
+
+ backup.startBackup(config);
+
+ RepositoryBackupChain bch = backup.findRepositoryBackup(repository.getName());
+
+ // wait till full backup will be stopped
+ while (bch.getState() != RepositoryBackupChain.FINISHED)
+ {
+ Thread.yield();
+ Thread.sleep(50);
+ }
+
+ // stop fullBackup
+ backup.stopBackup(bch);
+
+ // check
+ super.tearDown();
+
+ // restore
+ File backLog = new File(bch.getLogFilePath());
+ if (backLog.exists())
+ {
+ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+ assertNotNull(bchLog.getStartedTime());
+ assertNotNull(bchLog.getFinishedTime());
+
+ backup.restoreExistingRepository(bchLog.getBackupId(), false);
+
+ assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(repoName)
+ .getStateRestore());
+
+ // check
+ ManageableRepository restoredRepository = repositoryService.getRepository(repoName);
+
+ 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());
+ }
+
+ public void testWorkspaceRestoreWithConfig() throws Exception
+ {
+ // backup
+ File backDir = new File("target/backup/ws1");
+ backDir.mkdirs();
+
+ BackupConfig config = new BackupConfig();
+ config.setRepository(repository.getName());
+ config.setWorkspace("ws1");
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+
+ config.setBackupDir(backDir);
+
+ backup.startBackup(config);
+
+ BackupChain bch = backup.findBackup(repository.getName(), "ws1");
+
+ // 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();
+ removeWorkspaceFully(repository.getName(), "ws1");
+
+ File backLog = new File(bch.getLogFilePath());
+ if (backLog.exists())
+ {
+ BackupChainLog bchLog = new BackupChainLog(backLog);
+
+ assertNotNull(bchLog.getStartedTime());
+ assertNotNull(bchLog.getFinishedTime());
+
+ backup.restoreWorkspace(bchLog.getBackupId(), false);
+
+ // check
+ SessionImpl back1 = null;
+ try
+ {
+ back1 = (SessionImpl) repository.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());
+ }
+
+ public void testRepositoryRestoreWithConfig() throws Exception
+ {
+ // backup
+ File backDir = new File("target/backup");
+ backDir.mkdirs();
+
+ RepositoryBackupConfig config = new RepositoryBackupConfig();
+ String repoName = repository.getName();
+ config.setRepository(repoName);
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
+
+ config.setBackupDir(backDir);
+
+ backup.startBackup(config);
+
+ RepositoryBackupChain bch = backup.findRepositoryBackup(repository.getName());
+
+ // wait till full backup will be stopped
+ while (bch.getState() != RepositoryBackupChain.FINISHED)
+ {
+ Thread.yield();
+ Thread.sleep(50);
+ }
+
+ // stop fullBackup
+
+ backup.stopBackup(bch);
+
+ //TODO
+ super.tearDown();
+ removeRepositoryFully(repository.getName());
+
+ // restore
+ File backLog = new File(bch.getLogFilePath());
+ if (backLog.exists())
+ {
+ RepositoryBackupChainLog bchLog = new RepositoryBackupChainLog(backLog);
+
+ assertNotNull(bchLog.getStartedTime());
+ assertNotNull(bchLog.getFinishedTime());
+
+ backup.restoreRepository(bchLog.getBackupId(), false);
+
+ assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, backup.getLastRepositoryRestore(repoName)
+ .getStateRestore());
+
+ // check
+ ManageableRepository restoredRepository = repositoryService.getRepository(repoName);
+
+ 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());
+ }
+
}
13 years, 5 months
exo-jcr SVN: r3544 - in jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf: standalone and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-11-24 10:30:57 -0500 (Wed, 24 Nov 2010)
New Revision: 3544
Added:
jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/portal/configuration.xml
jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/standalone/test-configuration.xml
jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/standalone/test-multi-configuration.xml
Log:
JCR-1524: Move JCR framework commands list configuration to it right place
Added: jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/portal/configuration.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/portal/configuration.xml (rev 0)
+++ jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/portal/configuration.xml 2010-11-24 15:30:57 UTC (rev 3544)
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.command.impl.CommandService</target-component>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>jar:/conf/custom-commands.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+</configuration>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.command.impl.CommandService</target-component>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>jar:/conf/custom-commands.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+</configuration>
Added: jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/standalone/test-configuration.xml (rev 0)
+++ jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/standalone/test-configuration.xml 2010-11-24 15:30:57 UTC (rev 3544)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration>
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.command.impl.CommandService</target-component>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+</configuration>
Added: jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/standalone/test-multi-configuration.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/standalone/test-multi-configuration.xml (rev 0)
+++ jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/standalone/test-multi-configuration.xml 2010-11-24 15:30:57 UTC (rev 3544)
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration>
+
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.command.impl.CommandService</target-component>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands2.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands3.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+</configuration>
13 years, 5 months
exo-jcr SVN: r3543 - jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-11-24 10:28:02 -0500 (Wed, 24 Nov 2010)
New Revision: 3543
Added:
jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/custom-commands.xml
jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/portal/
jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/standalone/
jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/test-commands.xml
jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/test-commands2.xml
jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/test-commands3.xml
Log:
JCR-1524: Move JCR framework commands list configuration to it right place
Added: jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/custom-commands.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/custom-commands.xml (rev 0)
+++ jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/custom-commands.xml 2010-11-24 15:28:02 UTC (rev 3543)
@@ -0,0 +1,84 @@
+<!--
+
+ 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.
+
+-->
+<catalog>
+ <command name="addNode" className="org.exoplatform.frameworks.jcr.command.core.AddNodeCommand" />
+ <command name="save" className="org.exoplatform.frameworks.jcr.command.core.SaveCommand" />
+ <command name="filterNodesByTypes" className="org.exoplatform.frameworks.jcr.command.ext.FilterNodesByTypesCommand" />
+ <command name="addResourceFile" className="org.exoplatform.frameworks.jcr.command.ext.AddResourceFileCommand" />
+ <command name="displayResource" className="org.exoplatform.frameworks.jcr.command.web.DisplayResourceCommand" />
+ <command name="getNode" className="org.exoplatform.frameworks.jcr.command.core.GetNodeCommand" />
+
+
+ <!-- chain name="displayResource">
+ <command id="1" className="org.exoplatform.frameworks.jcr.command.core.GetNodeCommand" />
+ <command id="2" className="org.exoplatform.frameworks.jcr.command.web.DisplayResourceCommand" />
+ </chain -->
+
+ <!-- FCKEditor -->
+ <command name="GetFolders" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.GetFoldersOrFilesCommand" />
+ <command name="GetFiles" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.GetFoldersOrFilesCommand" />
+ <command name="GetFoldersAndFiles" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.GetFoldersOrFilesCommand" />
+ <command name="FileUpload" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.UploadFileCommand" />
+ <command name="CreateFolder" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.CreateFolderCommand" />
+
+</catalog>
+<!--
+
+ 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.
+
+-->
+<catalog>
+ <command name="addNode" className="org.exoplatform.frameworks.jcr.command.core.AddNodeCommand" />
+ <command name="save" className="org.exoplatform.frameworks.jcr.command.core.SaveCommand" />
+ <command name="filterNodesByTypes" className="org.exoplatform.frameworks.jcr.command.ext.FilterNodesByTypesCommand" />
+ <command name="addResourceFile" className="org.exoplatform.frameworks.jcr.command.ext.AddResourceFileCommand" />
+ <command name="displayResource" className="org.exoplatform.frameworks.jcr.command.web.DisplayResourceCommand" />
+ <command name="getNode" className="org.exoplatform.frameworks.jcr.command.core.GetNodeCommand" />
+
+
+ <!-- chain name="displayResource">
+ <command id="1" className="org.exoplatform.frameworks.jcr.command.core.GetNodeCommand" />
+ <command id="2" className="org.exoplatform.frameworks.jcr.command.web.DisplayResourceCommand" />
+ </chain -->
+
+ <!-- FCKEditor -->
+ <command name="GetFolders" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.GetFoldersOrFilesCommand" />
+ <command name="GetFiles" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.GetFoldersOrFilesCommand" />
+ <command name="GetFoldersAndFiles" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.GetFoldersOrFilesCommand" />
+ <command name="FileUpload" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.UploadFileCommand" />
+ <command name="CreateFolder" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.CreateFolderCommand" />
+
+</catalog>
Added: jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/test-commands.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/test-commands.xml (rev 0)
+++ jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/test-commands.xml 2010-11-24 15:28:02 UTC (rev 3543)
@@ -0,0 +1,32 @@
+<!--
+
+ 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.
+
+-->
+<catalog>
+
+ <!-- Single command "chains" from CatalogBaseTestCase -->
+ <command name="Command1" className="org.exoplatform.services.command.TestCommand1" />
+
+ <!-- Chains with nested commands -->
+ <chain name="Execute2">
+ <command id="1" className="org.exoplatform.services.command.TestCommand1" />
+ <command id="2" className="org.exoplatform.services.command.TestCommand1" />
+ </chain>
+
+</catalog>
Added: jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/test-commands2.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/test-commands2.xml (rev 0)
+++ jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/test-commands2.xml 2010-11-24 15:28:02 UTC (rev 3543)
@@ -0,0 +1,28 @@
+<!--
+
+ 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.
+
+-->
+<catalog>
+
+ <!-- Single command "chains" from CatalogBaseTestCase -->
+ <command name="Command2" className="org.exoplatform.services.command.TestCommand1" />
+
+ <command name="Command3" className="org.exoplatform.services.command.TestCommand1" />
+
+</catalog>
Added: jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/test-commands3.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/test-commands3.xml (rev 0)
+++ jcr/branches/1.12.x/exo.jcr.framework.command/src/main/resources/conf/test-commands3.xml 2010-11-24 15:28:02 UTC (rev 3543)
@@ -0,0 +1,28 @@
+<!--
+
+ 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.
+
+-->
+<catalog name="catalog1">
+
+ <!-- Single command "chains" from CatalogBaseTestCase -->
+ <command name="Command2" className="org.exoplatform.services.command.TestCommand1" />
+
+ <command name="Command3" className="org.exoplatform.services.command.TestCommand1" />
+
+</catalog>
13 years, 5 months
exo-jcr SVN: r3542 - in kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources: conf and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-11-24 10:18:20 -0500 (Wed, 24 Nov 2010)
New Revision: 3542
Added:
kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/
kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/standalone/
kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/standalone/test-configuration.xml
kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/standalone/test-multi-configuration.xml
kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/test-commands.xml
kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/test-commands2.xml
kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/test-commands3.xml
Log:
JCR-1524: Move JCR framework commands list configuration to it right place
Added: kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/standalone/test-configuration.xml (rev 0)
+++ kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/standalone/test-configuration.xml 2010-11-24 15:18:20 UTC (rev 3542)
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration>
+
+ <component>
+ <key>org.exoplatform.services.command.impl.CommandService</key>
+ <type>org.exoplatform.services.command.impl.CommandService</type>
+ <component-plugins>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ </component-plugins>
+ </component>
+
+ <component>
+ <type>org.exoplatform.services.command.action.ActionService</type>
+ </component>
+
+</configuration>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration>
+
+ <component>
+ <key>org.exoplatform.services.command.impl.CommandService</key>
+ <type>org.exoplatform.services.command.impl.CommandService</type>
+ <component-plugins>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ </component-plugins>
+ </component>
+
+ <component>
+ <type>org.exoplatform.services.command.action.ActionService</type>
+ </component>
+
+</configuration>
Added: kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/standalone/test-multi-configuration.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/standalone/test-multi-configuration.xml (rev 0)
+++ kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/standalone/test-multi-configuration.xml 2010-11-24 15:18:20 UTC (rev 3542)
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration>
+
+ <component>
+ <key>org.exoplatform.services.command.impl.CommandService</key>
+ <type>org.exoplatform.services.command.impl.CommandService</type>
+ <component-plugins>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands2.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands3.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ </component-plugins>
+ </component>
+
+</configuration>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+-->
+<configuration>
+
+ <component>
+ <key>org.exoplatform.services.command.impl.CommandService</key>
+ <type>org.exoplatform.services.command.impl.CommandService</type>
+ <component-plugins>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands2.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>config.catalog</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
+ <init-params>
+ <value-param>
+ <name>config-file</name>
+ <value>conf/test-commands3.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ </component-plugins>
+ </component>
+
+</configuration>
Added: kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/test-commands.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/test-commands.xml (rev 0)
+++ kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/test-commands.xml 2010-11-24 15:18:20 UTC (rev 3542)
@@ -0,0 +1,64 @@
+<!--
+
+ 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.
+
+-->
+<catalog>
+
+ <!-- Single command "chains" from CatalogBaseTestCase -->
+ <command name="Command1" className="org.exoplatform.services.command.TestCommand1" />
+
+ <!-- Chains with nested commands -->
+ <chain name="Execute2">
+ <command id="1" className="org.exoplatform.services.command.TestCommand1" />
+ <command id="2" className="org.exoplatform.services.command.TestCommand1" />
+ </chain>
+
+</catalog>
+<!--
+
+ 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.
+
+-->
+<catalog>
+
+ <!-- Single command "chains" from CatalogBaseTestCase -->
+ <command name="Command1" className="org.exoplatform.services.command.TestCommand1" />
+
+ <!-- Chains with nested commands -->
+ <chain name="Execute2">
+ <command id="1" className="org.exoplatform.services.command.TestCommand1" />
+ <command id="2" className="org.exoplatform.services.command.TestCommand1" />
+ </chain>
+
+</catalog>
Added: kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/test-commands2.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/test-commands2.xml (rev 0)
+++ kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/test-commands2.xml 2010-11-24 15:18:20 UTC (rev 3542)
@@ -0,0 +1,56 @@
+<!--
+
+ 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.
+
+-->
+<catalog>
+
+ <!-- Single command "chains" from CatalogBaseTestCase -->
+ <command name="Command2" className="org.exoplatform.services.command.TestCommand1" />
+
+ <command name="Command3" className="org.exoplatform.services.command.TestCommand1" />
+
+</catalog>
+<!--
+
+ 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.
+
+-->
+<catalog>
+
+ <!-- Single command "chains" from CatalogBaseTestCase -->
+ <command name="Command2" className="org.exoplatform.services.command.TestCommand1" />
+
+ <command name="Command3" className="org.exoplatform.services.command.TestCommand1" />
+
+</catalog>
Added: kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/test-commands3.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/test-commands3.xml (rev 0)
+++ kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/conf/test-commands3.xml 2010-11-24 15:18:20 UTC (rev 3542)
@@ -0,0 +1,56 @@
+<!--
+
+ 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.
+
+-->
+<catalog name="catalog1">
+
+ <!-- Single command "chains" from CatalogBaseTestCase -->
+ <command name="Command2" className="org.exoplatform.services.command.TestCommand1" />
+
+ <command name="Command3" className="org.exoplatform.services.command.TestCommand1" />
+
+</catalog>
+<!--
+
+ 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.
+
+-->
+<catalog name="catalog1">
+
+ <!-- Single command "chains" from CatalogBaseTestCase -->
+ <command name="Command2" className="org.exoplatform.services.command.TestCommand1" />
+
+ <command name="Command3" className="org.exoplatform.services.command.TestCommand1" />
+
+</catalog>
13 years, 5 months
exo-jcr SVN: r3541 - in kernel/branches/2.2.x/exo.kernel.component.command/src: main/resources/conf/portal and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-11-24 10:17:46 -0500 (Wed, 24 Nov 2010)
New Revision: 3541
Added:
kernel/branches/2.2.x/exo.kernel.component.command/src/test/resources/
Removed:
kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/custom-commands.xml
kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/standalone/
kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/test-commands.xml
kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/test-commands2.xml
kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/test-commands3.xml
Modified:
kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/portal/configuration.xml
Log:
JCR-1524: Move JCR framework commands list configuration to it right place
Deleted: kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/custom-commands.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/custom-commands.xml 2010-11-24 15:01:51 UTC (rev 3540)
+++ kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/custom-commands.xml 2010-11-24 15:17:46 UTC (rev 3541)
@@ -1,42 +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.
-
--->
-<catalog>
- <command name="addNode" className="org.exoplatform.frameworks.jcr.command.core.AddNodeCommand" />
- <command name="save" className="org.exoplatform.frameworks.jcr.command.core.SaveCommand" />
- <command name="filterNodesByTypes" className="org.exoplatform.frameworks.jcr.command.ext.FilterNodesByTypesCommand" />
- <command name="addResourceFile" className="org.exoplatform.frameworks.jcr.command.ext.AddResourceFileCommand" />
- <command name="displayResource" className="org.exoplatform.frameworks.jcr.command.web.DisplayResourceCommand" />
- <command name="getNode" className="org.exoplatform.frameworks.jcr.command.core.GetNodeCommand" />
-
-
- <!-- chain name="displayResource">
- <command id="1" className="org.exoplatform.frameworks.jcr.command.core.GetNodeCommand" />
- <command id="2" className="org.exoplatform.frameworks.jcr.command.web.DisplayResourceCommand" />
- </chain -->
-
- <!-- FCKEditor -->
- <command name="GetFolders" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.GetFoldersOrFilesCommand" />
- <command name="GetFiles" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.GetFoldersOrFilesCommand" />
- <command name="GetFoldersAndFiles" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.GetFoldersOrFilesCommand" />
- <command name="FileUpload" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.UploadFileCommand" />
- <command name="CreateFolder" className="org.exoplatform.frameworks.jcr.command.web.fckeditor.CreateFolderCommand" />
-
-</catalog>
Modified: kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/portal/configuration.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/portal/configuration.xml 2010-11-24 15:01:51 UTC (rev 3540)
+++ kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/portal/configuration.xml 2010-11-24 15:17:46 UTC (rev 3541)
@@ -25,19 +25,6 @@
<component>
<key>org.exoplatform.services.command.impl.CommandService</key>
<type>org.exoplatform.services.command.impl.CommandService</type>
- <component-plugins>
- <component-plugin>
- <name>config.catalog</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.command.impl.CommonsXMLConfigurationPlugin</type>
- <init-params>
- <value-param>
- <name>config-file</name>
- <value>jar:/conf/custom-commands.xml</value>
- </value-param>
- </init-params>
- </component-plugin>
- </component-plugins>
</component>
</configuration>
Deleted: kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/test-commands.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/test-commands.xml 2010-11-24 15:01:51 UTC (rev 3540)
+++ kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/test-commands.xml 2010-11-24 15:17:46 UTC (rev 3541)
@@ -1,32 +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.
-
--->
-<catalog>
-
- <!-- Single command "chains" from CatalogBaseTestCase -->
- <command name="Command1" className="org.exoplatform.services.command.TestCommand1" />
-
- <!-- Chains with nested commands -->
- <chain name="Execute2">
- <command id="1" className="org.exoplatform.services.command.TestCommand1" />
- <command id="2" className="org.exoplatform.services.command.TestCommand1" />
- </chain>
-
-</catalog>
Deleted: kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/test-commands2.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/test-commands2.xml 2010-11-24 15:01:51 UTC (rev 3540)
+++ kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/test-commands2.xml 2010-11-24 15:17:46 UTC (rev 3541)
@@ -1,28 +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.
-
--->
-<catalog>
-
- <!-- Single command "chains" from CatalogBaseTestCase -->
- <command name="Command2" className="org.exoplatform.services.command.TestCommand1" />
-
- <command name="Command3" className="org.exoplatform.services.command.TestCommand1" />
-
-</catalog>
Deleted: kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/test-commands3.xml
===================================================================
--- kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/test-commands3.xml 2010-11-24 15:01:51 UTC (rev 3540)
+++ kernel/branches/2.2.x/exo.kernel.component.command/src/main/resources/conf/test-commands3.xml 2010-11-24 15:17:46 UTC (rev 3541)
@@ -1,28 +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.
-
--->
-<catalog name="catalog1">
-
- <!-- Single command "chains" from CatalogBaseTestCase -->
- <command name="Command2" className="org.exoplatform.services.command.TestCommand1" />
-
- <command name="Command3" className="org.exoplatform.services.command.TestCommand1" />
-
-</catalog>
13 years, 5 months
exo-jcr SVN: r3540 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-11-24 10:01:51 -0500 (Wed, 24 Nov 2010)
New Revision: 3540
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java
Log:
EXOJCR-1054 : Adding privileged block for DefaultCacheFactory creation, required while updating to Jgroups 2.10.0.GA
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java 2010-11-24 14:11:49 UTC (rev 3539)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java 2010-11-24 15:01:51 UTC (rev 3540)
@@ -25,6 +25,7 @@
import org.exoplatform.services.jcr.config.MappedParametrizedObjectEntry;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.TemplateConfigurationHelper;
+import org.exoplatform.services.jcr.impl.util.PrivilegedCacheHelper;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.jboss.cache.Cache;
@@ -75,8 +76,8 @@
* Keep only one instance of the {@link JChannelFactory} to prevent creating several times the
* same multiplexer stack
*/
- private static final JChannelFactory CHANNEL_FACTORY = SecurityHelper
- .doPriviledgedAction(new PrivilegedAction<JChannelFactory>()
+ private static final JChannelFactory CHANNEL_FACTORY =
+ SecurityHelper.doPriviledgedAction(new PrivilegedAction<JChannelFactory>()
{
public JChannelFactory run()
{
@@ -157,7 +158,14 @@
}
// create cache
- final CacheFactory<K, V> factory = new DefaultCacheFactory<K, V>();
+ final CacheFactory<K, V> factory = SecurityHelper.doPriviledgedAction(new PrivilegedAction<CacheFactory<K, V>>()
+ {
+ public CacheFactory<K, V> run()
+ {
+ return new DefaultCacheFactory<K, V>();
+ }
+ });
+
final InputStream stream = configStream;
PrivilegedAction<Cache<K, V>> action = new PrivilegedAction<Cache<K, V>>()
@@ -260,7 +268,8 @@
{
// The cache is not shareable
// Avoid potential naming collision by changing the cluster name
- cache.getConfiguration().setClusterName(cache.getConfiguration().getClusterName() + rootFqn.toString().replace('/', '-'));
+ cache.getConfiguration().setClusterName(
+ cache.getConfiguration().getClusterName() + rootFqn.toString().replace('/', '-'));
return cache;
}
ExoContainer container = ExoContainerContext.getCurrentContainer();
@@ -294,24 +303,27 @@
{
caches.put(key, cache);
if (log.isInfoEnabled())
- log.info("A new JBoss Cache instance has been registered for the region " + rootFqn + ", a cache of type " + cacheType
- + " and the container " + container.getContext().getName());
+ {
+ log.info("A new JBoss Cache instance has been registered for the region " + rootFqn + ", a cache of type "
+ + cacheType + " and the container " + container.getContext().getName());
+ }
}
addEvictionRegion(rootFqn, cache, cfg);
if (log.isInfoEnabled())
+ {
log.info("The region " + rootFqn + " has been registered for a cache of type " + cacheType
+ " and the container " + container.getContext().getName());
+ }
return cache;
}
/**
* All the known cache types
*/
- public enum CacheType
- {
+ public enum CacheType {
JCR_CACHE, INDEX_CACHE, LOCK_CACHE
}
-
+
/**
* This class is used to make {@link Configuration} being usable as a Key in an HashMap since
* some variables such as <code>jgroupsConfigFile</code> are not managed as expected in the
@@ -321,8 +333,9 @@
private static class ConfigurationKey
{
private final URL jgroupsConfigFile;
+
private final Configuration conf;
-
+
public ConfigurationKey(Configuration initialConf) throws CloneNotSupportedException
{
// Clone it first since it will be modified
@@ -348,26 +361,40 @@
public boolean equals(Object obj)
{
if (this == obj)
+ {
return true;
+ }
if (obj == null)
+ {
return false;
+ }
if (getClass() != obj.getClass())
+ {
return false;
+ }
ConfigurationKey other = (ConfigurationKey)obj;
if (conf == null)
{
if (other.conf != null)
+ {
return false;
+ }
}
else if (!conf.equals(other.conf))
+ {
return false;
+ }
if (jgroupsConfigFile == null)
{
if (other.jgroupsConfigFile != null)
+ {
return false;
+ }
}
else if (!jgroupsConfigFile.equals(other.jgroupsConfigFile))
+ {
return false;
+ }
return true;
}
}
13 years, 5 months
exo-jcr SVN: r3539 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: dataflow/session and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-11-24 09:11:49 -0500 (Wed, 24 Nov 2010)
New Revision: 3539
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
Log:
EXOJCR-1074: Avoid iterating over a List thanks to its iterator when it is possible [Part #2]
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-11-24 14:02:56 UTC (rev 3538)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-11-24 14:11:49 UTC (rev 3539)
@@ -654,8 +654,9 @@
List<NodeData> refNodes = new ArrayList<NodeData>();
- for (ItemState changedItem : changes)
+ for (int i = 0, length = changes.size(); i < length; i++)
{
+ ItemState changedItem = changes.get(i);
if (changedItem.isNode())
{
NodeData refNode = (NodeData)changedItem.getData();
@@ -680,11 +681,13 @@
}
// check ref changes
- for (NodeData refNode : refNodes)
+ for (int i = 0, length = refNodes.size(); i < length; i++)
{
+ NodeData refNode = refNodes.get(i);
List<PropertyData> nodeRefs = dataManager.getReferencesData(refNode.getIdentifier(), true);
- for (PropertyData refProp : nodeRefs)
+ for (int j = 0, length2 = nodeRefs.size(); j < length2; j++)
{
+ PropertyData refProp = nodeRefs.get(j);
// if ref property is deleted in this session
ItemState refState = dataManager.getChangesLog().getItemState(refProp.getIdentifier());
if (refState != null && refState.isDeleted())
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java 2010-11-24 14:02:56 UTC (rev 3538)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java 2010-11-24 14:11:49 UTC (rev 3539)
@@ -85,9 +85,11 @@
public SessionChangesLog(List<ItemState> items, String sessionId)
{
super(items, sessionId);
-
- for (ItemState change : items)
+ for (int i = 0, length = items.size(); i < length; i++)
+ {
+ ItemState change = items.get(i);
addItem(change);
+ }
}
/**
@@ -109,9 +111,11 @@
public PlainChangesLog addAll(List<ItemState> changes)
{
super.addAll(changes);
- for (ItemState change : changes)
+ for (int i = 0, length = changes.size(); i < length; i++)
+ {
+ ItemState change = changes.get(i);
addItem(change);
-
+ }
return this;
}
@@ -200,8 +204,9 @@
private void traverseChangesByIdentifier(String identifier, List<ItemState> changesList)
{
- for (ItemState item : items)
+ for (int i = 0, length = items.size(); i < length; i++)
{
+ ItemState item = items.get(i);
if (item.getData().getIdentifier().equals(identifier))
{
changesList.add(item);
@@ -221,8 +226,9 @@
*/
public void eraseEventFire(String identifier)
{
- for (ItemState item : items)
+ for (int i = 0, length = items.size(); i < length; i++)
{
+ ItemState item = items.get(i);
if (item.getData().getIdentifier().equals(identifier))
{
// erase flag
@@ -242,11 +248,12 @@
public List<ItemState> getDescendantsChanges(QPath rootPath)
{
List<ItemState> list = new ArrayList<ItemState>();
- for (int i = 0; i < items.size(); i++)
+ for (int i = 0, length = items.size(); i < length; i++)
{
- if (items.get(i).isDescendantOf(rootPath))
+ ItemState item = items.get(i);
+ if (item.isDescendantOf(rootPath))
{
- list.add(items.get(i));
+ list.add(item);
}
}
return list;
@@ -261,8 +268,10 @@
public List<ItemState> getItemStates(String itemIdentifier)
{
List<ItemState> states = new ArrayList<ItemState>();
- for (ItemState state : getAllStates())
+ List<ItemState> currentStates = getAllStates();
+ for (int i = 0, length = currentStates.size(); i < length; i++)
{
+ ItemState state = currentStates.get(i);
if (state.getData().getIdentifier().equals(itemIdentifier))
{
states.add(state);
13 years, 5 months