exo-jcr SVN: r3751 - in jcr/branches/1.12.x/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/impl/access and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-12-30 03:36:44 -0500 (Thu, 30 Dec 2010)
New Revision: 3751
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataRestoreVisitor.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestPermissions.java
Log:
JCR-1529: Node restore result depends on cache eviction
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataRestoreVisitor.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataRestoreVisitor.java 2010-12-29 08:29:37 UTC (rev 3750)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataRestoreVisitor.java 2010-12-30 08:36:44 UTC (rev 3751)
@@ -18,6 +18,9 @@
*/
package org.exoplatform.services.jcr.impl.core.version;
+import org.exoplatform.services.jcr.access.AccessControlEntry;
+import org.exoplatform.services.jcr.access.AccessControlList;
+import org.exoplatform.services.jcr.access.SystemIdentity;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
@@ -320,7 +323,10 @@
(PropertyData)dataManager.getItemData(frozen, new QPathEntry(Constants.JCR_FROZENMIXINTYPES, 0),
ItemType.PROPERTY);
+ AccessControlList acl = parentData.getACL();
InternalQName[] mixins = null;
+ String owner = null;
+
if (frozenMixinTypes != null)
{
try
@@ -331,6 +337,29 @@
{
ValueData mvd = mvs.get(i);
mixins[i] = InternalQName.parse(new String(mvd.getAsByteArray()));
+
+ if (mixins[i].equals(Constants.EXO_PRIVILEGEABLE))
+ {
+ PropertyData aclData =
+ (PropertyData)dataManager.getItemData(frozen, new QPathEntry(Constants.EXO_PERMISSIONS, 0),
+ ItemType.PROPERTY);
+
+ acl = new AccessControlList();
+ acl.removePermissions(SystemIdentity.ANY);
+
+ for (ValueData value : aclData.getValues())
+ {
+ acl.addPermissions(new String(value.getAsByteArray(), Constants.DEFAULT_ENCODING));
+ }
+ }
+ else if (mixins[i].equals(Constants.EXO_OWNEABLE))
+ {
+ PropertyData ownerData =
+ (PropertyData)dataManager.getItemData(frozen, new QPathEntry(Constants.EXO_OWNER, 0),
+ ItemType.PROPERTY);
+
+ owner = new String(ownerData.getValues().get(0).getAsByteArray(), Constants.DEFAULT_ENCODING);
+ }
}
}
catch (IllegalNameException e)
@@ -350,6 +379,9 @@
}
}
+ // set new owner if exists
+ acl.setOwner(owner != null ? owner : parentData.getACL().getOwner());
+
InternalQName ptName = null;
try
{
@@ -374,7 +406,7 @@
// create restored version of the node
NodeData restoredData =
new TransientNodeData(nodePath, fidentifier, (existing != null ? existing.getPersistedVersion() : -1), ptName,
- mixins == null ? new InternalQName[0] : mixins, 0, parentData.getIdentifier(), parentData.getACL());
+ mixins == null ? new InternalQName[0] : mixins, 0, parentData.getIdentifier(), acl);
changes.add(ItemState.createAddedState(restoredData));
@@ -589,10 +621,32 @@
}
}
+ boolean isPrivilegeable =
+ nodeTypeDataManager.isNodeType(Constants.EXO_PRIVILEGEABLE, frozen.getPrimaryTypeName(),
+ frozen.getMixinTypeNames());
+
+ boolean isOwneable =
+ nodeTypeDataManager.isNodeType(Constants.EXO_OWNEABLE, frozen.getPrimaryTypeName(),
+ frozen.getMixinTypeNames());
+
+ AccessControlList acl = currentNode().getACL();
+ if (isPrivilegeable || isOwneable)
+ {
+ acl = new AccessControlList();
+ acl.removePermissions(SystemIdentity.ANY);
+
+ for (AccessControlEntry entry : (isPrivilegeable ? frozen.getACL() : currentNode().getACL())
+ .getPermissionEntries())
+ {
+ acl.addPermissions(entry.getIdentity(), new String[]{entry.getPermission()});
+ }
+
+ acl.setOwner(isOwneable ? frozen.getACL().getOwner() : currentNode().getACL().getOwner());
+ }
+
NodeData restoredData =
new TransientNodeData(restoredPath, jcrUuid, frozen.getPersistedVersion(), frozen.getPrimaryTypeName(),
- frozen.getMixinTypeNames(), frozen.getOrderNumber(), currentNode().getIdentifier(), // parent
- frozen.getACL());
+ frozen.getMixinTypeNames(), frozen.getOrderNumber(), currentNode().getIdentifier(), acl);
changes.add(ItemState.createAddedState(restoredData));
pushCurrent(restoredData);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestPermissions.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestPermissions.java 2010-12-29 08:29:37 UTC (rev 3750)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestPermissions.java 2010-12-30 08:36:44 UTC (rev 3751)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.access.PermissionType;
import org.exoplatform.services.jcr.access.SystemIdentity;
import org.exoplatform.services.jcr.core.CredentialsImpl;
+import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
@@ -296,4 +297,258 @@
}
}
}
+
+ /**
+ * Test restore of exo:privilegeable.
+ */
+ public void testPrivilegeable() throws Exception
+ {
+ final String TESTNODE_NAME = "testRestorePrivilegeable";
+ final String CHILD_TESTNODE_NAME1 = "childTestRestorePrivilegeable1";
+ final String CHILD_TESTNODE_NAME2 = "childTestRestorePrivilegeable2";
+ final String CHILD_TESTNODE_NAME3 = "childTestRestorePrivilegeable3";
+ final String CHILD_TESTNODE_NAME4 = "childTestRestorePrivilegeable4";
+
+ Credentials johnCredentials = new CredentialsImpl("john", "exo".toCharArray());
+ SessionImpl johnSession = (SessionImpl)repositoryService.getRepository("db2").login(johnCredentials, "ws1");
+
+ Credentials anonCredentials = new CredentialsImpl(SystemIdentity.ANONIM, "".toCharArray());
+ SessionImpl anonSession = (SessionImpl)repositoryService.getRepository("db2").login(anonCredentials, "ws1");
+
+ NodeImpl node = (NodeImpl)sessionWS1.getRootNode().addNode(TESTNODE_NAME);
+ node.addMixin("exo:privilegeable");
+ node.addMixin("exo:owneable");
+ node.addMixin("mix:versionable");
+ node.setPermission("*:/platform/administrators", PermissionType.ALL);
+ node.setPermission("mary",
+ new String[]{PermissionType.READ, PermissionType.SET_PROPERTY, PermissionType.ADD_NODE});
+ node.removePermission(SystemIdentity.ANY);
+ sessionWS1.save();
+
+ // child node exo:privilegeable & exo:owneable
+ NodeImpl childNode1 = (NodeImpl)node.addNode(CHILD_TESTNODE_NAME1);
+ childNode1.addMixin("exo:privilegeable");
+ childNode1.addMixin("exo:owneable");
+ childNode1.setPermission("*:/platform/administrators", PermissionType.ALL);
+ childNode1.setPermission("mary", new String[]{PermissionType.READ, PermissionType.SET_PROPERTY});
+ childNode1.removePermission(SystemIdentity.ANY);
+ sessionWS1.save();
+
+ // child node all inherited from parent
+ NodeImpl childNode2 = (NodeImpl)node.addNode(CHILD_TESTNODE_NAME2);
+ sessionWS1.save();
+
+ // child node exo:owneable
+ node = (NodeImpl)johnSession.getRootNode().getNode(TESTNODE_NAME);
+ NodeImpl childNode3 = (NodeImpl)node.addNode(CHILD_TESTNODE_NAME3);
+ childNode3.addMixin("exo:owneable");
+ johnSession.save();
+
+ node = (NodeImpl)sessionWS1.getRootNode().getNode(TESTNODE_NAME);
+
+ // child node exo:privilegeable
+ NodeImpl childNode4 = (NodeImpl)node.addNode(CHILD_TESTNODE_NAME4);
+ childNode4.addMixin("exo:privilegeable");
+ childNode4.setPermission("*:/platform/administrators", PermissionType.ALL);
+ childNode4.setPermission("mary", new String[]{PermissionType.READ, PermissionType.SET_PROPERTY});
+ childNode4.removePermission(SystemIdentity.ANY);
+ sessionWS1.save();
+
+ // check what we have
+ NodeImpl marysNode = (NodeImpl)sessionMaryWS1.getRootNode().getNode(TESTNODE_NAME);
+ assertTrue(marysNode.hasPermission(PermissionType.READ));
+ assertTrue(marysNode.hasPermission(PermissionType.SET_PROPERTY));
+ assertTrue(marysNode.hasPermission(PermissionType.ADD_NODE));
+ assertFalse(marysNode.hasPermission(PermissionType.REMOVE));
+ assertEquals(((NodeData)marysNode.getData()).getACL().getOwner(), "admin");
+
+ NodeImpl marysChildNode1 = (NodeImpl)marysNode.getNode(CHILD_TESTNODE_NAME1);
+ assertTrue(marysChildNode1.hasPermission(PermissionType.READ));
+ assertTrue(marysChildNode1.hasPermission(PermissionType.SET_PROPERTY));
+ assertFalse(marysChildNode1.hasPermission(PermissionType.ADD_NODE));
+ assertEquals(((NodeData)marysChildNode1.getData()).getACL().getOwner(), "admin");
+
+ NodeImpl marysChildNode2 = (NodeImpl)marysNode.getNode(CHILD_TESTNODE_NAME2);
+ assertTrue(marysNode.hasPermission(PermissionType.READ));
+ assertTrue(marysNode.hasPermission(PermissionType.SET_PROPERTY));
+ assertTrue(marysNode.hasPermission(PermissionType.ADD_NODE));
+ assertFalse(marysNode.hasPermission(PermissionType.REMOVE));;
+ assertEquals(((NodeData)marysChildNode2.getData()).getACL().getOwner(), "admin");
+
+ NodeImpl marysChildNode3 = (NodeImpl)marysNode.getNode(CHILD_TESTNODE_NAME3);
+ assertTrue(marysChildNode3.hasPermission(PermissionType.READ));
+ assertTrue(marysChildNode3.hasPermission(PermissionType.SET_PROPERTY));
+ assertTrue(marysChildNode3.hasPermission(PermissionType.ADD_NODE));
+ assertFalse(marysChildNode3.hasPermission(PermissionType.REMOVE));
+ assertEquals(((NodeData)marysChildNode3.getData()).getACL().getOwner(), "john");
+
+ NodeImpl marysChildNode4 = (NodeImpl)marysNode.getNode(CHILD_TESTNODE_NAME4);
+ assertTrue(marysChildNode4.hasPermission(PermissionType.READ));
+ assertTrue(marysChildNode4.hasPermission(PermissionType.SET_PROPERTY));
+ assertFalse(marysChildNode4.hasPermission(PermissionType.REMOVE));;
+ assertEquals(((NodeData)marysChildNode2.getData()).getACL().getOwner(), "admin");
+
+ // for __anonim
+ try
+ {
+ anonSession.getRootNode().getNode(TESTNODE_NAME);
+ }
+ catch (AccessDeniedException e)
+ {
+ // ok
+ }
+
+ // v1
+ node.checkin();
+ node.checkout();
+
+ try
+ {
+ // restore v1
+ node.restore("1", true);
+ }
+ catch (AccessDeniedException e)
+ {
+ fail("Restore should succeed");
+ }
+
+ // check what we have after restore
+ marysNode = (NodeImpl)sessionMaryWS1.getRootNode().getNode(TESTNODE_NAME);
+ assertTrue(marysNode.hasPermission(PermissionType.READ));
+ assertTrue(marysNode.hasPermission(PermissionType.SET_PROPERTY));
+ assertTrue(marysNode.hasPermission(PermissionType.ADD_NODE));
+ assertFalse(marysNode.hasPermission(PermissionType.REMOVE));
+ assertEquals(((NodeData)marysNode.getData()).getACL().getOwner(), "admin");
+
+ marysChildNode1 = (NodeImpl)marysNode.getNode(CHILD_TESTNODE_NAME1);
+ assertTrue(marysChildNode1.hasPermission(PermissionType.READ));
+ assertTrue(marysChildNode1.hasPermission(PermissionType.SET_PROPERTY));
+ assertFalse(marysChildNode1.hasPermission(PermissionType.ADD_NODE));
+ assertEquals(((NodeData)marysChildNode1.getData()).getACL().getOwner(), "admin");
+
+ marysChildNode2 = (NodeImpl)marysNode.getNode(CHILD_TESTNODE_NAME2);
+ assertTrue(marysNode.hasPermission(PermissionType.READ));
+ assertTrue(marysNode.hasPermission(PermissionType.SET_PROPERTY));
+ assertTrue(marysNode.hasPermission(PermissionType.ADD_NODE));
+ assertFalse(marysNode.hasPermission(PermissionType.REMOVE));
+ assertEquals(((NodeData)marysChildNode2.getData()).getACL().getOwner(), "admin");;
+
+ marysChildNode3 = (NodeImpl)marysNode.getNode(CHILD_TESTNODE_NAME3);
+ assertTrue(marysChildNode3.hasPermission(PermissionType.READ));
+ assertTrue(marysChildNode3.hasPermission(PermissionType.SET_PROPERTY));
+ assertTrue(marysChildNode3.hasPermission(PermissionType.ADD_NODE));
+ assertFalse(marysChildNode3.hasPermission(PermissionType.REMOVE));
+ assertEquals(((NodeData)marysChildNode3.getData()).getACL().getOwner(), "john");
+
+ marysChildNode4 = (NodeImpl)marysNode.getNode(CHILD_TESTNODE_NAME4);
+ assertTrue(marysChildNode4.hasPermission(PermissionType.READ));
+ assertTrue(marysChildNode4.hasPermission(PermissionType.SET_PROPERTY));
+ assertFalse(marysChildNode4.hasPermission(PermissionType.REMOVE));;
+ assertEquals(((NodeData)marysChildNode2.getData()).getACL().getOwner(), "admin");
+
+ // for __anonim
+ try
+ {
+ anonSession.getRootNode().getNode(TESTNODE_NAME);
+ }
+ catch (AccessDeniedException e)
+ {
+ // ok
+ }
+ finally
+ {
+ anonSession.logout();
+ }
+
+ johnSession.logout();
+ }
+
+ /**
+ * Test restore of exo:privilegeable.
+ */
+ public void testPrivilegeable2() throws Exception
+ {
+ final String TESTNODE_NAME = "testRestorePrivilegeable2";
+
+ NodeImpl node = (NodeImpl)sessionWS1.getRootNode().addNode(TESTNODE_NAME);
+ node.addMixin("exo:privilegeable");
+ node.addMixin("mix:versionable");
+ node.setPermission("*:/platform/administrators", PermissionType.ALL);
+ node.setPermission("mary",
+ new String[]{PermissionType.READ, PermissionType.SET_PROPERTY, PermissionType.ADD_NODE});
+ node.removePermission(SystemIdentity.ANY);
+ sessionWS1.save();
+
+ // check what we have
+ NodeImpl marysNode = (NodeImpl)sessionMaryWS1.getRootNode().getNode(TESTNODE_NAME);
+ assertTrue(marysNode.hasPermission(PermissionType.READ));
+ assertTrue(marysNode.hasPermission(PermissionType.SET_PROPERTY));
+ assertTrue(marysNode.hasPermission(PermissionType.ADD_NODE));
+ assertFalse(marysNode.hasPermission(PermissionType.REMOVE));
+ assertEquals(((NodeData)marysNode.getData()).getACL().getOwner(), SystemIdentity.SYSTEM);
+
+ // v1
+ node.checkin();
+ node.checkout();
+
+ try
+ {
+ // restore v1
+ node.restore("1", true);
+ }
+ catch (AccessDeniedException e)
+ {
+ fail("Restore should succeed");
+ }
+
+ // check what we have after restore
+ marysNode = (NodeImpl)sessionMaryWS1.getRootNode().getNode(TESTNODE_NAME);
+ assertTrue(marysNode.hasPermission(PermissionType.READ));
+ assertTrue(marysNode.hasPermission(PermissionType.SET_PROPERTY));
+ assertTrue(marysNode.hasPermission(PermissionType.ADD_NODE));
+ assertFalse(marysNode.hasPermission(PermissionType.REMOVE));
+ assertEquals(((NodeData)marysNode.getData()).getACL().getOwner(), SystemIdentity.SYSTEM);
+ }
+
+ /**
+ * Test restore of exo:privilegeable.
+ */
+ public void testPrivilegeable3() throws Exception
+ {
+ final String TESTNODE_NAME = "testRestorePrivilegeable3";
+
+ NodeImpl node = (NodeImpl)sessionWS1.getRootNode().addNode(TESTNODE_NAME);
+ node.addMixin("exo:owneable");
+ node.addMixin("mix:versionable");
+ sessionWS1.save();
+
+ // check what we have
+ NodeImpl marysNode = (NodeImpl)sessionMaryWS1.getRootNode().getNode(TESTNODE_NAME);
+ assertEquals(marysNode.getACL().getPermissionsSize(), 4);
+ assertEquals(marysNode.getACL().getPermissions(SystemIdentity.ANY).size(), 4);
+ assertEquals(marysNode.getACL().getPermissions("mary").size(), 0);
+ assertEquals(((NodeData)marysNode.getData()).getACL().getOwner(), "admin");
+
+ // v1
+ node.checkin();
+ node.checkout();
+
+ try
+ {
+ // restore v1
+ node.restore("1", true);
+ }
+ catch (AccessDeniedException e)
+ {
+ fail("Restore should succeed");
+ }
+
+ // check what we have after restore
+ marysNode = (NodeImpl)sessionMaryWS1.getRootNode().getNode(TESTNODE_NAME);
+ assertEquals(marysNode.getACL().getPermissionsSize(), 4);
+ assertEquals(marysNode.getACL().getPermissions(SystemIdentity.ANY).size(), 4);
+ assertEquals(marysNode.getACL().getPermissions("mary").size(), 0);
+ assertEquals(((NodeData)marysNode.getData()).getACL().getOwner(), "admin");
+ }
+
}
13 years, 4 months
exo-jcr SVN: r3750 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-12-29 03:29:37 -0500 (Wed, 29 Dec 2010)
New Revision: 3750
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java
Log:
EXOJCR-1078: remove locking tables
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java 2010-12-29 08:03:14 UTC (rev 3749)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/rdbms/FullBackupJob.java 2010-12-29 08:29:37 UTC (rev 3750)
@@ -49,7 +49,6 @@
import java.net.URL;
import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
-import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
@@ -137,6 +136,7 @@
*/
public static final int DB_DIALECT_PGSQL = DBConstants.DB_DIALECT_PGSQL.hashCode();
+
/**
* {@inheritDoc}
*/
@@ -266,40 +266,43 @@
backupInfoWriter.setValueTableName(scripts[1][0]);
backupInfoWriter.setRefTableName(scripts[2][0]);
- // Lock tables
- ResultSet rs = null;
- try
- {
- DatabaseMetaData metaData = jdbcConn.getMetaData();
- rs = metaData.getTables(null, null, "%", new String[]{"TABLE"});
- lockStatemnt = jdbcConn.createStatement();
- int dialect = DialectDetecter.detect(metaData).hashCode();
+ // TODO set workspace waiting
- if (dialect == DB_DIALECT_HSQLDB)
- {
- while (rs.next())
- {
- lockStatemnt.execute("SET TABLE " + rs.getString("TABLE_NAME") + " READONLY TRUE");
- }
- }
- else if (dialect == DB_DIALECT_MYSQL || dialect == DB_DIALECT_MYSQL_UTF8)
- {
- String lock = "";
- while (rs.next())
- {
- lock += rs.getString("TABLE_NAME") + " READ,";
- }
- lockStatemnt.execute("LOCK TABLES " + lock.substring(0, lock.length() - 1));
- }
- }
- finally
- {
- if (rs != null)
- {
- rs.close();
- }
- }
+ // Lock tables
+ // ResultSet rs = null;
+ // try
+ // {
+ // DatabaseMetaData metaData = jdbcConn.getMetaData();
+ //
+ // rs = metaData.getTables(null, null, "%", new String[]{"TABLE"});
+ // lockStatemnt = jdbcConn.createStatement();
+ // int dialect = DialectDetecter.detect(metaData).hashCode();
+ //
+ // if (dialect == DB_DIALECT_HSQLDB)
+ // {
+ // while (rs.next())
+ // {
+ // lockStatemnt.execute("SET TABLE " + rs.getString("TABLE_NAME") + " READONLY TRUE");
+ // }
+ // }
+ // else if (dialect == DB_DIALECT_MYSQL || dialect == DB_DIALECT_MYSQL_UTF8)
+ // {
+ // String lock = "";
+ // while (rs.next())
+ // {
+ // lock += rs.getString("TABLE_NAME") + " READ,";
+ // }
+ // lockStatemnt.execute("LOCK TABLES " + lock.substring(0, lock.length() - 1));
+ // }
+ // }
+ // finally
+ // {
+ // if (rs != null)
+ // {
+ // rs.close();
+ // }
+ // }
// dump JCR data
for (String script[] : scripts)
@@ -325,6 +328,9 @@
// write backup information
backupInfoWriter.write();
+
+ // TODO set workspace waiting
+
}
catch (RepositoryConfigurationException e)
{
@@ -363,42 +369,42 @@
try
{
// unlock tables
- if (lockStatemnt != null)
- {
- ResultSet rs = null;
- try
- {
- DatabaseMetaData metaData = jdbcConn.getMetaData();
- int dialect = DialectDetecter.detect(metaData).hashCode();
+ // if (lockStatemnt != null)
+ // {
+ // ResultSet rs = null;
+ // try
+ // {
+ // DatabaseMetaData metaData = jdbcConn.getMetaData();
+ // int dialect = DialectDetecter.detect(metaData).hashCode();
+ //
+ // if (dialect == DB_DIALECT_HSQLDB)
+ // {
+ // rs = metaData.getTables(null, null, "%", new String[]{"TABLE"});
+ // while (rs.next())
+ // {
+ // String tableName = rs.getString("TABLE_NAME");
+ // lockStatemnt.execute("SET TABLE " + tableName + " READONLY FALSE");
+ // }
+ // }
+ // else
+ // {
+ // lockStatemnt.execute("UNLOCK TABLES");
+ // }
+ // }
+ // finally
+ // {
+ // if (rs != null)
+ // {
+ // rs.close();
+ // }
+ //
+ // if (lockStatemnt != null)
+ // {
+ // lockStatemnt.close();
+ // }
+ // }
+ // }
- if (dialect == DB_DIALECT_HSQLDB)
- {
- rs = metaData.getTables(null, null, "%", new String[]{"TABLE"});
- while (rs.next())
- {
- String tableName = rs.getString("TABLE_NAME");
- lockStatemnt.execute("SET TABLE " + tableName + " READONLY FALSE");
- }
- }
- else
- {
- lockStatemnt.execute("UNLOCK TABLES");
- }
- }
- finally
- {
- if (rs != null)
- {
- rs.close();
- }
-
- if (lockStatemnt != null)
- {
- lockStatemnt.close();
- }
- }
- }
-
jdbcConn.close();
}
catch (SQLException e)
@@ -656,6 +662,7 @@
if (out != null)
{
+ out.flush();
out.closeEntry();
out.close();
}
13 years, 4 months
exo-jcr SVN: r3749 - in jcr/branches/1.12.x/exo.jcr.component.core: src/test/resources/conf/standalone/cluster and 1 other directory.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-12-29 03:03:14 -0500 (Wed, 29 Dec 2010)
New Revision: 3749
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/pom.xml
jcr/branches/1.12.x/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-configuration.xml
Log:
JCR-1502 : The data source "testdbcleaner" was add in cluster configuration. The test TestWorkapceREstore was added in excludes in profile "run-all".
Modified: jcr/branches/1.12.x/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/pom.xml 2010-12-28 18:47:59 UTC (rev 3748)
+++ jcr/branches/1.12.x/exo.jcr.component.core/pom.xml 2010-12-29 08:03:14 UTC (rev 3749)
@@ -675,6 +675,7 @@
<exclude>org/exoplatform/services/jcr/**/api/**/TestVersionRestore.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestWorkspaceManagement.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestRepositoryManagement.java</exclude>
+ <exclude>org/exoplatform/services/jcr/**/impl/**/TestWorkspaceRestore.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestSaveConfiguration.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/ValueStoragePluginTest.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestSessionCleaner.java</exclude>
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-configuration.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-configuration.xml 2010-12-28 18:47:59 UTC (rev 3748)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/resources/conf/standalone/cluster/test-configuration.xml 2010-12-29 08:03:14 UTC (rev 3749)
@@ -577,6 +577,33 @@
<property name="password" value=""/>
</properties-param>
</init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>testdbcleaner</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/testdbcleaner"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
</component-plugin>
<component-plugin>
<name>bind.jcr</name>
13 years, 4 months
exo-jcr SVN: r3748 - jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-12-28 13:47:59 -0500 (Tue, 28 Dec 2010)
New Revision: 3748
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml
Log:
EXOJCR-1129: doc of the ISPN implementation of eXo Cache has been added
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml 2010-12-28 16:31:16 UTC (rev 3747)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/kernel/cache.xml 2010-12-28 18:47:59 UTC (rev 3748)
@@ -300,7 +300,7 @@
<title>Understanding a cache creator</title>
<para>The factory for jboss cache, delegates the cache creation to
- <envar>ExoCacheCreator</envar> that is defines as
+ <envar>ExoCacheCreator</envar> that is defined as
below:<programlisting>package org.exoplatform.services.cache.impl.jboss;
...
public interface ExoCacheCreator {
@@ -1146,4 +1146,453 @@
</section>
</section>
</section>
+
+ <section>
+ <title>eXo Cache based on Infinispan</title>
+
+ <section>
+ <title>Configure the ExoCacheFactory</title>
+
+ <para>When you add the related jar file in your classpath, the eXo
+ service container will use the default configuration provided in the
+ library itself but of course you can still redefined the configuration
+ if you wish as you can do with any components.</para>
+
+ <para>The default configuration of the factory is:<programlisting><configuration>
+ <component>
+ <key>org.exoplatform.services.cache.ExoCacheFactory</key>
+ <type>org.exoplatform.services.cache.impl.infinispan.ExoCacheFactoryImpl</type>
+ <init-params>
+ <value-param>
+ <name>cache.config.template</name>
+ <value>jar:/conf/portal/cache-configuration-template.xml</value>
+ </value-param>
+ </init-params>
+ </component>
+</configuration></programlisting></para>
+
+ <para>As you can see the factory requires one single parameter which is
+ <emphasis>cache.config.template</emphasis>, this parameter allows you to
+ define the location of the default configuration template of your
+ infinispan. In the default configuration, we ask the eXo container to
+ get the file shipped into the jar at
+ <emphasis>/conf/portal/cache-configuration-template.xml</emphasis>.</para>
+
+ <para>The default configuration template aims to be the skeleton from
+ which we will create any type of infinispan cache instance, thus it must
+ be very generic. <note>
+ <para>All the cache instances that will rely on this cache
+ configuration will share the same
+ <envar>EmbeddedCacheManager.</envar></para>
+ </note></para>
+ </section>
+
+ <section>
+ <title>Add specific configuration for a cache</title>
+
+ <para>If for a given reason, you need to use a specific configuration
+ for a cache, you can register one thanks to an "<emphasis>external
+ plugin</emphasis>", see an example below:<programlisting><configuration>
+ ...
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.cache.ExoCacheFactory</target-component>
+ <component-plugin>
+ <name>addConfig</name>
+ <set-method>addConfig</set-method>
+ <type>org.exoplatform.services.cache.impl.infinispan.ExoCacheFactoryConfigPlugin</type>
+ <description>add Custom Configurations</description>
+ <init-params>
+ <value-param>
+ <name>myCustomCache</name>
+ <value>jar:/conf/portal/custom-cache-configuration.xml</value>
+ </value-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+ ...
+</configuration></programlisting></para>
+
+ <para>In the example above, I call the method
+ <emphasis>addConfig(ExoCacheFactoryConfigPlugin plugin)</emphasis> on
+ the current implementation of <envar>ExoCacheFactory</envar> which is
+ actually the infinispan implementation.</para>
+
+ <para>In the <emphasis>init-params</emphasis> block, you can define a
+ set of <emphasis>value-param</emphasis> blocks and for each
+ <emphasis>value-param</emphasis>, we expect the name of cache that needs
+ a specific configuration as name and the location of your custom
+ configuration as <emphasis>value</emphasis>.</para>
+
+ <para>In this example, we indicates to the factory that we would like
+ that the cache <emphasis>myCustomCache</emphasis> use the configuration
+ available at
+ <emphasis>jar:/conf/portal/custom-cache-configuration.xml</emphasis>.</para>
+
+ <note>
+ <para>All the cache instances that will rely on the cache
+ configuration located at the same location will share the same
+ <envar>EmbeddedCacheManager</envar>.</para>
+ </note>
+ </section>
+
+ <section>
+ <title>Add a cache creator</title>
+
+ <section>
+ <title>Understanding a cache creator</title>
+
+ <para>The factory for infinispan, delegates the cache creation to
+ <envar>ExoCacheCreator</envar> that is defined as
+ below:<programlisting>package org.exoplatform.services.cache.impl.infinispan;
+...
+public interface ExoCacheCreator {
+
+ /**
+ * Creates an eXo cache according to the given configuration {@link org.exoplatform.services.cache.ExoCacheConfig}
+ * @param config the configuration of the cache to apply
+ * @param cacheConfig the configuration of the infinispan cache
+ * @param cacheGetter a {@link Callable} instance from which we can get the cache
+ * @exception ExoCacheInitException if an exception happens while initializing the cache
+ */
+ public ExoCache<Serializable, Object> create(ExoCacheConfig config, Configuration cacheConfig, Callable<Cache<Serializable, Object>> cacheGetter) throws ExoCacheInitException;
+
+ /**
+ * Returns the type of {@link org.exoplatform.services.cache.ExoCacheConfig} expected by the creator
+ * @return the expected type
+ */
+ public Class<? extends ExoCacheConfig> getExpectedConfigType();
+
+ /**
+ * Returns a set of all the implementations expected by the creator. This is mainly used to be backward compatible
+ * @return the expected by the creator
+ */
+ public Set<String> getExpectedImplementations();
+}</programlisting></para>
+
+ <para>The <envar>ExoCacheCreator</envar> allows you to define any kind
+ of infinispan cache instance that you would like to have. It has been
+ designed to give you the ability to have your own type of
+ configuration and to always be backward compatible.</para>
+
+ <para>In an <envar>ExoCacheCreator</envar>, you need to implement 3
+ methods which are:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><emphasis>create</emphasis> - this method is used to create
+ a new <envar>ExoCache</envar> from the
+ <envar>ExoCacheConfig</envar>, an inifinispan cache configuration
+ and a Callable object to allow you to get the cache
+ instance.</para>
+ </listitem>
+
+ <listitem>
+ <para><emphasis>getExpectedConfigType</emphasis> - this method is
+ used to indicate the factory the subtype of
+ <envar>ExoCacheConfig</envar> supported by the creator.</para>
+ </listitem>
+
+ <listitem>
+ <para><emphasis>getExpectedImplementation</emphasis>s - this
+ method is used to indicate the factory the values of the field
+ <emphasis>implementation</emphasis> of
+ <envar>ExoCacheConfig</envar> that is supported by the creator.
+ This is used for backward compatibility, in other words you can
+ still configure your cache with an instance of
+ <envar>ExoCacheConfig</envar>.</para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Register a cache creator</title>
+
+ <para>You can register any cache creator you want thanks to an
+ <emphasis>"external plugin"</emphasis>, see an example
+ below:<programlisting> <external-component-plugins>
+ <target-component>org.exoplatform.services.cache.ExoCacheFactory</target-component>
+ <component-plugin>
+ <name>addCreator</name>
+ <set-method>addCreator</set-method>
+ <type>org.exoplatform.services.cache.impl.infinispan.ExoCacheCreatorPlugin</type>
+ <description>add Exo Cache Creator</description>
+ <init-params>
+ <object-param>
+ <name>Test</name>
+ <description>The cache creator for testing purpose</description>
+ <object type="org.exoplatform.services.cache.impl.infinispan.TestExoCacheCreator"></object>
+ </object-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins></programlisting></para>
+
+ <para>In the example above, I call the method
+ <emphasis>addCreator(ExoCacheCreatorPlugin plugin)</emphasis> on the
+ current implementation of <envar>ExoCacheFactory</envar> which is
+ actually the infinispan implementation.</para>
+
+ <para>In the <emphasis>init-params</emphasis> block, you can define a
+ set of <emphasis>object-param</emphasis> blocks and for each
+ <emphasis>object-param</emphasis>, we expect any object definition of
+ type <envar>ExoCacheCreator</envar>.</para>
+
+ <para>In this example, we register the cache creator related to the
+ eviction policy <emphasis>Test</emphasis>.</para>
+ </section>
+
+ <section>
+ <title>The cache creators available</title>
+
+ <para>By default, no cache creator are defined, so you need to define
+ them yourself by adding them in your configuration files.</para>
+
+ <section>
+ <title>Generic Cache Creator</title>
+
+ <para>This is the generic cache creator that allows you to use any
+ eviction strategies defined by default in Infinispan.</para>
+
+ <programlisting>..
+<object-param>
+ <name>GENERIC</name>
+ <description>The generic cache creator</description>
+ <object type="org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheCreator">
+ <field name="implementations">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>NONE</string>
+ </value>
+ <value>
+ <string>FIFO</string>
+ </value>
+ <value>
+ <string>LRU</string>
+ </value>
+ <value>
+ <string>UNORDERED</string>
+ </value>
+ <value>
+ <string>LIRS</string>
+ </value>
+ </collection>
+ </field>
+ <field name="defaultStrategy"><string>${my-value}</string></field>
+ <field name="defaultMaxIdle"><long>${my-value}</long></field>
+ <field name="defaultWakeUpInterval"><long>${my-value}</long></field>
+ </object>
+</object-param>
+...</programlisting>
+
+ <table>
+ <title>Fields description</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>implementations</entry>
+
+ <entry>This is the list of all the
+ <emphasis>implementations</emphasis> supported by the cache
+ creator. Actualy, it is a subset of the full list of the
+ eviction strategies supported by infinispan to which you
+ want to give access to. In the configuraton above, you have
+ the full list of all the eviction strategies currently
+ supported by infinispan 4.1. This field is used to manage
+ the backward compatibility.</entry>
+ </row>
+
+ <row>
+ <entry>defaultStrategy</entry>
+
+ <entry>This is the name of the default eviction strategy to
+ use. By default the value is <emphasis>LRU</emphasis>. This
+ value is only use when we define a cache of this type with
+ the old configuration.</entry>
+ </row>
+
+ <row>
+ <entry>defaultMaxIdle</entry>
+
+ <entry>This is the default value of the field
+ <emphasis>maxIdle</emphasis> described in the section
+ dedicated to this cache type. By default the value is
+ <emphasis>-1</emphasis>.This value is only use when we
+ define a cache of this type with the old
+ configuration.</entry>
+ </row>
+
+ <row>
+ <entry>defaultWakeUpInterval</entry>
+
+ <entry>his is the default value of the field
+ <emphasis>wakeUpInterval</emphasis> described in the section
+ dedicated to this cache type. By default the value is
+ <emphasis>5000</emphasis>.This value is only use when we
+ define a cache of this type with the old
+ configuration</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+ </section>
+ </section>
+
+ <section>
+ <title>Define an infinispan cache instance</title>
+
+ <section>
+ <title>How to define a distributed or a local cache?</title>
+
+ <para>Actually, if you use a custom configuration for your cache as
+ described in a previous section, we will use the cache mode define in
+ your configuration file.</para>
+
+ <para>In case, you decide to use the default configuration template,
+ we use the field <emphasis>distributed</emphasis> of your
+ <envar>ExoCacheConfig</envar> to decide. In other words, if the value
+ of this field is false (the default value), the cache will be a local
+ cache otherwise it will be the cache mode defined in your default
+ configuration template that should be distributed.</para>
+ </section>
+
+ <section>
+ <title>How to define an infinispan cache instance</title>
+
+ <para>All the eviction strategies proposed by default in infinispan
+ rely on the generic cache creator.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>New configuration</para>
+
+ <para><programlisting>...
+ <object-param>
+ <name>myCache</name>
+ <description>My cache configuration</description>
+ <object type="org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheConfig">
+ <field name="name"><string>myCacheName</string></field>
+ <field name="strategy"><int>${my-value}</int></field>
+ <field name="maxEntries"><long>${my-value}</long></field>
+ <field name="lifespan"><long>${my-value}</long></field>
+ <field name="maxIdle"><long>${my-value}</long></field>
+ <field name="wakeUpInterval"><long>${my-value}</long></field>
+ </object>
+ </object-param>
+...</programlisting><table>
+ <title>Fields description</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>strategy</entry>
+
+ <entry>The name of the strategy to use such as
+ 'UNORDERED', 'FIFO', 'LRU', 'LIRS' and 'NONE' (to
+ disable eviction).</entry>
+ </row>
+
+ <row>
+ <entry>maxEntries</entry>
+
+ <entry>Maximum number of entries in a cache instance. If
+ selected value is not a power of two the actual value
+ will default to the least power of two larger than
+ selected value. -1 means no limit which is also the
+ default value.</entry>
+ </row>
+
+ <row>
+ <entry>lifespan</entry>
+
+ <entry>Maximum lifespan of a cache entry, after which
+ the entry is expired cluster-wide, in milliseconds. -1
+ means the entries never expire which is also the default
+ value.</entry>
+ </row>
+
+ <row>
+ <entry>maxIdle</entry>
+
+ <entry>Maximum idle time a cache entry will be
+ maintained in the cache, in milliseconds. If the idle
+ time is exceeded, the entry will be expired
+ cluster-wide. -1 means the entries never expire which is
+ also the default value.</entry>
+ </row>
+
+ <row>
+ <entry>wakeUpInterval</entry>
+
+ <entry>Interval between subsequent eviction runs, in
+ milliseconds. If you wish to disable the periodic
+ eviction process altogether, set wakeupInterval to -1.
+ The default value is 5000.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </listitem>
+
+ <listitem>
+ <para>Old configuration</para>
+
+ <programlisting>...
+ <object-param>
+ <name>myCache</name>
+ <description>My cache configuration</description>
+ <field name="name"><string>lru-with-old-config</string></field>
+ <field name="maxSize"><int>${my-value}</int></field>
+ <field name="liveTime"><long>${my-value}</long></field>
+ <field name="implementation"><string>${my-value}</string></field>
+ </object>
+ </object-param>
+...</programlisting>
+
+ <table>
+ <title>Fields description</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>maxSize</entry>
+
+ <entry>Maximum number of entries in a cache instance. If
+ selected value is not a power of two the actual value will
+ default to the least power of two larger than selected
+ value. -1 means no limit which is also the default
+ value.</entry>
+ </row>
+
+ <row>
+ <entry>liveTime</entry>
+
+ <entry>Maximum lifespan of a cache entry, after which the
+ entry is expired cluster-wide, in milliseconds. -1 means
+ the entries never expire which is also the default
+ value.</entry>
+ </row>
+
+ <row>
+ <entry>implementation</entry>
+
+ <entry>The name of the implementation to use the expected
+ value is one of the eviction strategies defined in the
+ field <emphasis>implementations</emphasis> of the generic
+ cache creator.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para><note>
+ <para>For the fields <emphasis>maxIdle</emphasis> and
+ <emphasis>wakeUpInterval</emphasis> needed by infinispan, we
+ will use the default values provided by the creator.</para>
+ </note></para>
+ </listitem>
+ </itemizedlist>
+ </section>
+ </section>
+ </section>
</chapter>
13 years, 4 months
exo-jcr SVN: r3747 - in kernel/trunk/exo.kernel.component.common/src: main/java/org/exoplatform/services/rpc/impl and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-12-28 11:31:16 -0500 (Tue, 28 Dec 2010)
New Revision: 3747
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/RPCService.java
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java
kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java
Log:
EXOJCR-1128: revert: RPCService support execute command by identifier
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/RPCService.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/RPCService.java 2010-12-28 15:54:28 UTC (rev 3746)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/RPCService.java 2010-12-28 16:31:16 UTC (rev 3747)
@@ -106,76 +106,6 @@
SecurityException;
/**
- * Executes a command on all the cluster nodes. This method is equivalent to the other method of the
- * same type but with the default timeout. The command must be registered first otherwise an
- * {@link RPCException} will be thrown.
- *
- * @param commandId The commandId to execute on each cluster node
- * @param synchronous if true, sets group request mode to {@link org.jgroups.blocks.GroupRequest#GET_ALL},
- * and if false sets it to {@link org.jgroups.blocks.GroupRequest#GET_NONE}.
- * @param args an array of {@link Serializable} objects corresponding to parameters of the command
- * to execute remotely
- * @return a list of responses from all the members of the cluster. If we met an exception on a given node,
- * the RPCException will be the corresponding response of this particular node
- * @throws RPCException in the event of problems.
- * @throws SecurityException if the {@link SecurityManager} is installed and the call method
- * doesn't have the {@link RuntimePermission} <code>ACCESS_RPC_SERVICE_PERMISSION</code>
- */
- List<Object> executeCommandOnAllNodes(String commandId, boolean synchronous, Serializable... args)
- throws RPCException, SecurityException;
-
- /**
- * Executes a command synchronously on all the cluster nodes. The command must be registered first otherwise an
- * {@link RPCException} will be thrown.
- *
- * @param commandId The commandId to execute on each cluster node
- * @param timeout a timeout after which to throw a replication exception.
- * @param args an array of {@link Serializable} objects corresponding to parameters of the command
- * to execute remotely
- * @return a list of responses from all the members of the cluster. If we met an exception on a given node,
- * the RPCException will be the corresponding response of this particular node
- * @throws RPCException in the event of problems.
- * @throws SecurityException if the {@link SecurityManager} is installed and the call method
- * doesn't have the {@link RuntimePermission} <code>ACCESS_RPC_SERVICE_PERMISSION</code>
- */
- List<Object> executeCommandOnAllNodes(String commandId, long timeout, Serializable... args) throws RPCException,
- SecurityException;
-
- /**
- * Executes a command on the coordinator only. This method is equivalent to the other method of the
- * same type but with the default timeout. The command must be registered first otherwise an
- * {@link RPCException} will be thrown.
- *
- * @param commandId The commandId to execute on the coordinator node
- * @param synchronous if true, sets group request mode to {@link org.jgroups.blocks.GroupRequest#GET_ALL},
- * and if false sets it to {@link org.jgroups.blocks.GroupRequest#GET_NONE}.
- * @param args an array of {@link Serializable} objects corresponding to parameters of the command
- * to execute remotely
- * @return the response of the coordinator.
- * @throws RPCException in the event of problems.
- * @throws SecurityException if the {@link SecurityManager} is installed and the call method
- * doesn't have the {@link RuntimePermission} <code>ACCESS_RPC_SERVICE_PERMISSION</code>
- */
- Object executeCommandOnCoordinator(String commandId, boolean synchronous, Serializable... args) throws RPCException,
- SecurityException;
-
- /**
- * Executes a command synchronously on the coordinator only. The command must be registered first otherwise an
- * {@link RPCException} will be thrown.
- *
- * @param commandId The commandId to execute on the coordinator node
- * @param timeout a timeout after which to throw a replication exception.
- * @param args an array of {@link Serializable} objects corresponding to parameters of the command
- * to execute remotely
- * @return the response of the coordinator.
- * @throws RPCException in the event of problems.
- * @throws SecurityException if the {@link SecurityManager} is installed and the call method
- * doesn't have the {@link RuntimePermission} <code>ACCESS_RPC_SERVICE_PERMISSION</code>
- */
- Object executeCommandOnCoordinator(String commandId, long timeout, Serializable... args) throws RPCException,
- SecurityException;
-
- /**
* Register a new {@link RemoteCommand} instance, it will be mapped to its id. If a command with the
* same Id has already been registered, a warning will be printed into the log file and the new
* command will replace the old one.
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java 2010-12-28 15:54:28 UTC (rev 3746)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java 2010-12-28 16:31:16 UTC (rev 3747)
@@ -478,66 +478,6 @@
/**
* {@inheritDoc}
*/
- public List<Object> executeCommandOnAllNodes(String commandId, boolean synchronous, Serializable... args)
- throws RPCException, SecurityException
- {
- RemoteCommand command = commands.get(commandId);
- if (command == null)
- {
- throw new RPCException("Command " + commandId + " unkown, please register your command first");
- }
-
- return executeCommandOnAllNodes(command, synchronous, args);
- }
-
- /**
- * {@inheritDoc}
- */
- public List<Object> executeCommandOnAllNodes(String commandId, long timeout, Serializable... args)
- throws RPCException, SecurityException
- {
- RemoteCommand command = commands.get(commandId);
- if (command == null)
- {
- throw new RPCException("Command " + commandId + " unkown, please register your command first");
- }
-
- return executeCommandOnAllNodes(command, timeout, args);
- }
-
- /**
- * {@inheritDoc}
- */
- public Object executeCommandOnCoordinator(String commandId, boolean synchronous, Serializable... args)
- throws RPCException, SecurityException
- {
- RemoteCommand command = commands.get(commandId);
- if (command == null)
- {
- throw new RPCException("Command " + commandId + " unkown, please register your command first");
- }
-
- return executeCommandOnCoordinator(command, synchronous, args);
- }
-
- /**
- * {@inheritDoc}
- */
- public Object executeCommandOnCoordinator(String commandId, long timeout, Serializable... args) throws RPCException,
- SecurityException
- {
- RemoteCommand command = commands.get(commandId);
- if (command == null)
- {
- throw new RPCException("Command " + commandId + " unkown, please register your command first");
- }
-
- return executeCommandOnCoordinator(command, timeout, args);
- }
-
- /**
- * {@inheritDoc}
- */
public Object handle(Message msg)
{
String commandId = null;
@@ -1034,5 +974,4 @@
super(message);
}
}
-
}
Modified: kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java 2010-12-28 15:54:28 UTC (rev 3746)
+++ kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java 2010-12-28 16:31:16 UTC (rev 3747)
@@ -50,7 +50,6 @@
private PortalContainer container;
private ConfigurationManager configManager;
- @Override
public void setUp() throws Exception
{
container = PortalContainer.getInstance();
@@ -1064,58 +1063,6 @@
}
}
- public void testCallCommandsById() throws Exception
- {
- InitParams params = new InitParams();
- ValueParam paramConf = new ValueParam();
- paramConf.setName(RPCServiceImpl.PARAM_JGROUPS_CONFIG);
- paramConf.setValue("jar:/conf/portal/udp.xml");
- params.addParameter(paramConf);
- RPCServiceImpl service = null;
- try
- {
- service = new RPCServiceImpl(container.getContext(), params, configManager);
- RemoteCommand dummy = new RemoteCommand()
- {
-
- public String getId()
- {
- return "dummy";
- }
-
- public String execute(Serializable[] args) throws Throwable
- {
- return "OK";
- }
- };
- service.registerCommand(dummy);
- service.start();
-
- Object o = service.executeCommandOnCoordinator("dummy", true);
- assertEquals("OK", o);
-
- List<Object> result = service.executeCommandOnAllNodes("dummy", true);
- assertNotNull(result);
- assertTrue(result.size() == 1);
- assertEquals(result.get(0), "OK");
-
- o = service.executeCommandOnCoordinator("dummy", RPCServiceImpl.DEFAULT_TIMEOUT);
- assertEquals("OK", o);
-
- result = service.executeCommandOnAllNodes("dummy", RPCServiceImpl.DEFAULT_TIMEOUT);
- assertNotNull(result);
- assertTrue(result.size() == 1);
- assertEquals(result.get(0), "OK");
- }
- finally
- {
- if (service != null)
- {
- service.stop();
- }
- }
- }
-
public static class MyService
{
private int value = 0;
13 years, 4 months
exo-jcr SVN: r3746 - in kernel/trunk/exo.kernel.component.common/src: main/java/org/exoplatform/services/rpc/impl and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-12-28 10:54:28 -0500 (Tue, 28 Dec 2010)
New Revision: 3746
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/RPCService.java
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java
kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java
Log:
EXOJCR-1128: RPCService support execute command by identifier
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/RPCService.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/RPCService.java 2010-12-28 13:19:39 UTC (rev 3745)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/RPCService.java 2010-12-28 15:54:28 UTC (rev 3746)
@@ -106,6 +106,76 @@
SecurityException;
/**
+ * Executes a command on all the cluster nodes. This method is equivalent to the other method of the
+ * same type but with the default timeout. The command must be registered first otherwise an
+ * {@link RPCException} will be thrown.
+ *
+ * @param commandId The commandId to execute on each cluster node
+ * @param synchronous if true, sets group request mode to {@link org.jgroups.blocks.GroupRequest#GET_ALL},
+ * and if false sets it to {@link org.jgroups.blocks.GroupRequest#GET_NONE}.
+ * @param args an array of {@link Serializable} objects corresponding to parameters of the command
+ * to execute remotely
+ * @return a list of responses from all the members of the cluster. If we met an exception on a given node,
+ * the RPCException will be the corresponding response of this particular node
+ * @throws RPCException in the event of problems.
+ * @throws SecurityException if the {@link SecurityManager} is installed and the call method
+ * doesn't have the {@link RuntimePermission} <code>ACCESS_RPC_SERVICE_PERMISSION</code>
+ */
+ List<Object> executeCommandOnAllNodes(String commandId, boolean synchronous, Serializable... args)
+ throws RPCException, SecurityException;
+
+ /**
+ * Executes a command synchronously on all the cluster nodes. The command must be registered first otherwise an
+ * {@link RPCException} will be thrown.
+ *
+ * @param commandId The commandId to execute on each cluster node
+ * @param timeout a timeout after which to throw a replication exception.
+ * @param args an array of {@link Serializable} objects corresponding to parameters of the command
+ * to execute remotely
+ * @return a list of responses from all the members of the cluster. If we met an exception on a given node,
+ * the RPCException will be the corresponding response of this particular node
+ * @throws RPCException in the event of problems.
+ * @throws SecurityException if the {@link SecurityManager} is installed and the call method
+ * doesn't have the {@link RuntimePermission} <code>ACCESS_RPC_SERVICE_PERMISSION</code>
+ */
+ List<Object> executeCommandOnAllNodes(String commandId, long timeout, Serializable... args) throws RPCException,
+ SecurityException;
+
+ /**
+ * Executes a command on the coordinator only. This method is equivalent to the other method of the
+ * same type but with the default timeout. The command must be registered first otherwise an
+ * {@link RPCException} will be thrown.
+ *
+ * @param commandId The commandId to execute on the coordinator node
+ * @param synchronous if true, sets group request mode to {@link org.jgroups.blocks.GroupRequest#GET_ALL},
+ * and if false sets it to {@link org.jgroups.blocks.GroupRequest#GET_NONE}.
+ * @param args an array of {@link Serializable} objects corresponding to parameters of the command
+ * to execute remotely
+ * @return the response of the coordinator.
+ * @throws RPCException in the event of problems.
+ * @throws SecurityException if the {@link SecurityManager} is installed and the call method
+ * doesn't have the {@link RuntimePermission} <code>ACCESS_RPC_SERVICE_PERMISSION</code>
+ */
+ Object executeCommandOnCoordinator(String commandId, boolean synchronous, Serializable... args) throws RPCException,
+ SecurityException;
+
+ /**
+ * Executes a command synchronously on the coordinator only. The command must be registered first otherwise an
+ * {@link RPCException} will be thrown.
+ *
+ * @param commandId The commandId to execute on the coordinator node
+ * @param timeout a timeout after which to throw a replication exception.
+ * @param args an array of {@link Serializable} objects corresponding to parameters of the command
+ * to execute remotely
+ * @return the response of the coordinator.
+ * @throws RPCException in the event of problems.
+ * @throws SecurityException if the {@link SecurityManager} is installed and the call method
+ * doesn't have the {@link RuntimePermission} <code>ACCESS_RPC_SERVICE_PERMISSION</code>
+ */
+ Object executeCommandOnCoordinator(String commandId, long timeout, Serializable... args) throws RPCException,
+ SecurityException;
+
+ /**
* Register a new {@link RemoteCommand} instance, it will be mapped to its id. If a command with the
* same Id has already been registered, a warning will be printed into the log file and the new
* command will replace the old one.
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java 2010-12-28 13:19:39 UTC (rev 3745)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java 2010-12-28 15:54:28 UTC (rev 3746)
@@ -478,6 +478,66 @@
/**
* {@inheritDoc}
*/
+ public List<Object> executeCommandOnAllNodes(String commandId, boolean synchronous, Serializable... args)
+ throws RPCException, SecurityException
+ {
+ RemoteCommand command = commands.get(commandId);
+ if (command == null)
+ {
+ throw new RPCException("Command " + commandId + " unkown, please register your command first");
+ }
+
+ return executeCommandOnAllNodes(command, synchronous, args);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<Object> executeCommandOnAllNodes(String commandId, long timeout, Serializable... args)
+ throws RPCException, SecurityException
+ {
+ RemoteCommand command = commands.get(commandId);
+ if (command == null)
+ {
+ throw new RPCException("Command " + commandId + " unkown, please register your command first");
+ }
+
+ return executeCommandOnAllNodes(command, timeout, args);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object executeCommandOnCoordinator(String commandId, boolean synchronous, Serializable... args)
+ throws RPCException, SecurityException
+ {
+ RemoteCommand command = commands.get(commandId);
+ if (command == null)
+ {
+ throw new RPCException("Command " + commandId + " unkown, please register your command first");
+ }
+
+ return executeCommandOnCoordinator(command, synchronous, args);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object executeCommandOnCoordinator(String commandId, long timeout, Serializable... args) throws RPCException,
+ SecurityException
+ {
+ RemoteCommand command = commands.get(commandId);
+ if (command == null)
+ {
+ throw new RPCException("Command " + commandId + " unkown, please register your command first");
+ }
+
+ return executeCommandOnCoordinator(command, timeout, args);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Object handle(Message msg)
{
String commandId = null;
@@ -974,4 +1034,5 @@
super(message);
}
}
+
}
Modified: kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java 2010-12-28 13:19:39 UTC (rev 3745)
+++ kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java 2010-12-28 15:54:28 UTC (rev 3746)
@@ -50,6 +50,7 @@
private PortalContainer container;
private ConfigurationManager configManager;
+ @Override
public void setUp() throws Exception
{
container = PortalContainer.getInstance();
@@ -1063,6 +1064,58 @@
}
}
+ public void testCallCommandsById() throws Exception
+ {
+ InitParams params = new InitParams();
+ ValueParam paramConf = new ValueParam();
+ paramConf.setName(RPCServiceImpl.PARAM_JGROUPS_CONFIG);
+ paramConf.setValue("jar:/conf/portal/udp.xml");
+ params.addParameter(paramConf);
+ RPCServiceImpl service = null;
+ try
+ {
+ service = new RPCServiceImpl(container.getContext(), params, configManager);
+ RemoteCommand dummy = new RemoteCommand()
+ {
+
+ public String getId()
+ {
+ return "dummy";
+ }
+
+ public String execute(Serializable[] args) throws Throwable
+ {
+ return "OK";
+ }
+ };
+ service.registerCommand(dummy);
+ service.start();
+
+ Object o = service.executeCommandOnCoordinator("dummy", true);
+ assertEquals("OK", o);
+
+ List<Object> result = service.executeCommandOnAllNodes("dummy", true);
+ assertNotNull(result);
+ assertTrue(result.size() == 1);
+ assertEquals(result.get(0), "OK");
+
+ o = service.executeCommandOnCoordinator("dummy", RPCServiceImpl.DEFAULT_TIMEOUT);
+ assertEquals("OK", o);
+
+ result = service.executeCommandOnAllNodes("dummy", RPCServiceImpl.DEFAULT_TIMEOUT);
+ assertNotNull(result);
+ assertTrue(result.size() == 1);
+ assertEquals(result.get(0), "OK");
+ }
+ finally
+ {
+ if (service != null)
+ {
+ service.stop();
+ }
+ }
+ }
+
public static class MyService
{
private int value = 0;
13 years, 4 months
exo-jcr SVN: r3745 - in jcr/branches/1.12.x/exo.jcr.component.core: src/test/resources/conf/standalone and 1 other directory.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-12-28 08:19:39 -0500 (Tue, 28 Dec 2010)
New Revision: 3745
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/pom.xml
jcr/branches/1.12.x/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml
Log:
JCR-1502 : The data source "testDbCleaner" was added in single db configuration for test. The TestWorkspaceRestore was added in excludes.
Modified: jcr/branches/1.12.x/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/pom.xml 2010-12-28 11:18:13 UTC (rev 3744)
+++ jcr/branches/1.12.x/exo.jcr.component.core/pom.xml 2010-12-28 13:19:39 UTC (rev 3745)
@@ -406,6 +406,7 @@
<exclude>org/exoplatform/services/jcr/**/api/**/TestVersionRestore.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestWorkspaceManagement.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestRepositoryManagement.java</exclude>
+ <exclude>org/exoplatform/services/jcr/**/impl/**/TestWorkspaceRestore.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestSaveConfiguration.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/ValueStoragePluginTest.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestSessionCleaner.java</exclude>
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml 2010-12-28 11:18:13 UTC (rev 3744)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration-sjdbc.xml 2010-12-28 13:19:39 UTC (rev 3745)
@@ -418,6 +418,33 @@
</init-params>
</component-plugin>
<component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>testdbcleaner</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/testdbcleaner"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
<name>bind.jcr</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.services.naming.BindReferencePlugin</type>
13 years, 4 months
exo-jcr SVN: r3744 - core/branches/2.3.x/packaging/module/src/main/javascript.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-12-28 06:18:13 -0500 (Tue, 28 Dec 2010)
New Revision: 3744
Modified:
core/branches/2.3.x/packaging/module/src/main/javascript/core.packaging.module.js
Log:
COR-218: Dependency added in the js file
Modified: core/branches/2.3.x/packaging/module/src/main/javascript/core.packaging.module.js
===================================================================
--- core/branches/2.3.x/packaging/module/src/main/javascript/core.packaging.module.js 2010-12-28 11:17:20 UTC (rev 3743)
+++ core/branches/2.3.x/packaging/module/src/main/javascript/core.packaging.module.js 2010-12-28 11:18:13 UTC (rev 3744)
@@ -46,6 +46,7 @@
addDependency(new Project("org.apache.poi", "poi", "jar", "3.6")).
addDependency(new Project("org.apache.poi", "poi-scratchpad", "jar", "3.6")).
addDependency(new Project("org.apache.poi", "poi-ooxml", "jar", "3.6")).
+ addDependency(new Project("org.apache.poi", "poi-ooxml-schemas", "jar", "3.6")).
addDependency(new Project("org.apache.xmlbeans", "xmlbeans", "jar", "2.3.0"));
module.component.organization =
13 years, 4 months
exo-jcr SVN: r3743 - core/trunk/packaging/module/src/main/javascript.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-12-28 06:17:20 -0500 (Tue, 28 Dec 2010)
New Revision: 3743
Modified:
core/trunk/packaging/module/src/main/javascript/core.packaging.module.js
Log:
EXOJCR-1114: Dependency added in the js file
Modified: core/trunk/packaging/module/src/main/javascript/core.packaging.module.js
===================================================================
--- core/trunk/packaging/module/src/main/javascript/core.packaging.module.js 2010-12-28 09:47:21 UTC (rev 3742)
+++ core/trunk/packaging/module/src/main/javascript/core.packaging.module.js 2010-12-28 11:17:20 UTC (rev 3743)
@@ -45,7 +45,8 @@
addDependency(new Project("html-parser", "html-parser", "jar", "1.6")).
addDependency(new Project("org.apache.poi", "poi", "jar", "3.6")).
addDependency(new Project("org.apache.poi", "poi-scratchpad", "jar", "3.6")).
- addDependency(new Project("org.apache.poi", "poi-ooxml", "jar", "3.6")).
+ addDependency(new Project("org.apache.poi", "poi-ooxml", "jar", "3.6")).
+ addDependency(new Project("org.apache.poi", "poi-ooxml-schemas", "jar", "3.6")).
addDependency(new Project("org.apache.xmlbeans", "xmlbeans", "jar", "2.3.0"));
module.component.organization =
13 years, 4 months
exo-jcr SVN: r3742 - jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-12-28 04:47:21 -0500 (Tue, 28 Dec 2010)
New Revision: 3742
Modified:
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java
Log:
JCR-1502 : Fix problem with HTTPBackupAgentTest.
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java 2010-12-28 09:30:56 UTC (rev 3741)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java 2010-12-28 09:47:21 UTC (rev 3742)
@@ -36,6 +36,7 @@
import org.exoplatform.services.jcr.ext.backup.ExtendedBackupManager;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChain;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChainLog;
+import org.exoplatform.services.jcr.ext.backup.impl.JobRepositoryRestore;
import org.exoplatform.services.jcr.ext.backup.impl.JobWorkspaceRestore;
import org.exoplatform.services.jcr.ext.backup.server.bean.BackupConfigBean;
import org.exoplatform.services.jcr.ext.backup.server.bean.response.BackupServiceInfoBean;
@@ -898,7 +899,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitWorkspaceRestore("db6", "ws3");
// Get restore info to workspace /db6/ws3
{
@@ -1049,7 +1050,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitWorkspaceRestore("db6", "ws3");
// Get restore info to workspace /db6/ws3
{
@@ -1168,7 +1169,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitWorkspaceRestore("db6", "ws3");
// Get restore info to workspace /db6/ws3
{
@@ -1260,7 +1261,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitWorkspaceRestore("db6", "ws2");
// Get restore info to workspace /db6/ws2
{
@@ -1354,7 +1355,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitWorkspaceRestore("db6", "ws2");
// Get restore info to workspace /db6/ws2
{
@@ -1481,7 +1482,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitWorkspaceRestore("db6", "ws3");
// Get restore info to workspace /db6/ws3
{
@@ -1583,7 +1584,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitWorkspaceRestore("db6", "ws2");
// Get restore info to workspace /db6/ws2
{
@@ -1686,7 +1687,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitWorkspaceRestore("db6", "ws2");
// Get restore info to workspace /db6/ws2
{
@@ -1815,7 +1816,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitWorkspaceRestore("db6", "ws3");
// Get restore info to workspace /db6/ws3
{
@@ -1950,7 +1951,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitRepositoryRestore("db6backup");
// Get restore info
{
@@ -2120,7 +2121,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitRepositoryRestore("db6backup");
// Get restore info
{
@@ -2257,7 +2258,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitRepositoryRestore("db6backup");
// Get restore info
{
@@ -2349,7 +2350,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitRepositoryRestore("db6");
// Get restore info
{
@@ -2441,7 +2442,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitRepositoryRestore("db6");
// Get restore info
{
@@ -2589,7 +2590,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitRepositoryRestore("db6backup");
// Get restore info
{
@@ -2736,7 +2737,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitRepositoryRestore("db6backup");
// Get restore info
{
@@ -2837,7 +2838,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitRepositoryRestore("db6");
// Get restore info
{
@@ -2939,7 +2940,7 @@
assertEquals(200, cres.getStatus());
}
- Thread.sleep(2000);
+ waitRepositoryRestore("db6");
// Get restore info
{
@@ -3089,4 +3090,71 @@
{
return (ExtendedBackupManager) container.getComponentInstanceOfType(BackupManager.class);
}
+
+ protected void waitWorkspaceRestore(String repoName, String wsName) throws Exception
+ {
+ boolean wait = true;
+
+ while (wait)
+ {
+
+ // Get restore info to workspace /<repoName>/<wsName>
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
+ + HTTPBackupAgent.Constants.OperationType.CURRENT_RESTORE_INFO_ON_WS + "/" + repoName + "/"
+ + wsName), new URI(""), null, new InputHeadersMap(headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(200, cres.getStatus());
+
+ DetailedInfo info = (DetailedInfo) getObject(DetailedInfo.class, responseWriter.getBody());
+
+ if (info.getState().intValue() == JobWorkspaceRestore.RESTORE_SUCCESSFUL
+ || info.getState().intValue() == JobWorkspaceRestore.RESTORE_FAIL)
+ {
+ wait = false;
+ }
+ else
+ {
+ Thread.sleep(500);
+ }
+ }
+ }
+
+ protected void waitRepositoryRestore(String repoName) throws Exception
+ {
+ boolean wait = true;
+
+ while (wait)
+ {
+ // Get restore info
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
+ + HTTPBackupAgent.Constants.OperationType.CURRENT_RESTORE_INFO_ON_REPOSITORY + "/"
+ + repoName), new URI(""), null, new InputHeadersMap(headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(200, cres.getStatus());
+
+ DetailedInfo info = (DetailedInfo) getObject(DetailedInfo.class, responseWriter.getBody());
+
+ if (info.getState().intValue() == JobRepositoryRestore.REPOSITORY_RESTORE_SUCCESSFUL
+ || info.getState().intValue() == JobRepositoryRestore.REPOSITORY_RESTORE_FAIL)
+ {
+ wait = false;
+ }
+ else
+ {
+ Thread.sleep(500);
+ }
+ }
+ }
}
13 years, 4 months