exo-jcr SVN: r3589 - jcr/branches/1.12.x/applications.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-12-01 11:16:32 -0500 (Wed, 01 Dec 2010)
New Revision: 3589
Removed:
jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/
Log:
JCR-1499 : The changes for this issue in JCR 1.12.x was rollback. Will be committed in JCR 1.12.7-GA.
15 years, 6 months
exo-jcr SVN: r3588 - in jcr/trunk/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr and 2 other directories.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-12-01 11:14:41 -0500 (Wed, 01 Dec 2010)
New Revision: 3588
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccessChildNodes.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/lock/TestLockPermissions.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccess.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestUserAccess.java
Log:
EXOJCR-1086: fixed remove permission on child nodes; BaseStandaloneTest now uses system session at tearDown to cleanup nodes.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2010-12-01 15:49:40 UTC (rev 3587)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2010-12-01 16:14:41 UTC (rev 3588)
@@ -1665,58 +1665,78 @@
*/
private void validateAccessPermissions(ItemState changedItem) throws RepositoryException, AccessDeniedException
{
- NodeData parent = (NodeData)getItemData(changedItem.getData().getParentIdentifier());
- if (parent != null)
+ if (changedItem.isDeleted())
{
-
- // Remove propery or node
- if (changedItem.isDeleted())
+ validateRemoveAccessPermission(changedItem);
+ }
+ else
+ {
+ NodeData parent = (NodeData)getItemData(changedItem.getData().getParentIdentifier());
+ if (parent != null)
{
- if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.REMOVE}, session
- .getUserState().getIdentity()))
+ if (changedItem.getData().isNode())
{
- throw new AccessDeniedException("Access denied: REMOVE "
- + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID() + " item owner "
- + parent.getACL().getOwner());
- }
- }
- else if (changedItem.getData().isNode())
- {
- // add node
- if (changedItem.isAdded())
- {
- if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.ADD_NODE}, session
- .getUserState().getIdentity()))
+ // add node
+ if (changedItem.isAdded())
{
- throw new AccessDeniedException("Access denied: ADD_NODE "
- + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID() + " item owner "
- + parent.getACL().getOwner());
+ if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.ADD_NODE}, session
+ .getUserState().getIdentity()))
+ {
+ throw new AccessDeniedException("Access denied: ADD_NODE "
+ + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID()
+ + " item owner " + parent.getACL().getOwner());
+ }
}
+ else if (changedItem.isMixinChanged())
+ {
+ if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.ADD_NODE,
+ PermissionType.SET_PROPERTY}, session.getUserState().getIdentity()))
+ {
+ throw new AccessDeniedException("Access denied: ADD_NODE or SET_PROPERTY"
+ + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID()
+ + " item owner " + parent.getACL().getOwner());
+ }
+ }
+
}
- else if (changedItem.isMixinChanged())
+ else if (changedItem.isAdded() || changedItem.isUpdated())
{
- if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.ADD_NODE,
- PermissionType.SET_PROPERTY}, session.getUserState().getIdentity()))
+ // add or update property
+ if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.SET_PROPERTY}, session
+ .getUserState().getIdentity()))
{
- throw new AccessDeniedException("Access denied: ADD_NODE or SET_PROPERTY"
+ throw new AccessDeniedException("Access denied: SET_PROPERTY "
+ changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID() + " item owner "
+ parent.getACL().getOwner());
}
}
+ } // else - parent not found, deleted in this session or from another
+ }
+ }
- }
- else if (changedItem.isAdded() || changedItem.isUpdated())
+ private void validateRemoveAccessPermission(ItemState changedItem) throws RepositoryException, AccessDeniedException
+ {
+ NodeData nodeData = null;
+ // if changedItem is node - check its ACL, if property - check parent node ACL
+ if (changedItem.isNode())
+ {
+ nodeData = (NodeData)changedItem.getData();
+ }
+ else
+ {
+ nodeData = (NodeData)getItemData(changedItem.getData().getParentIdentifier());
+ if (nodeData == null)
{
- // add or update property
- if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.SET_PROPERTY}, session
- .getUserState().getIdentity()))
- {
- throw new AccessDeniedException("Access denied: SET_PROPERTY "
- + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID() + " item owner "
- + parent.getACL().getOwner());
- }
+ return;
}
- } // else - parent not found, deleted in this session or from another
+ }
+
+ if (!accessManager.hasPermission(nodeData.getACL(), new String[]{PermissionType.REMOVE}, session.getUserState()
+ .getIdentity()))
+ {
+ throw new AccessDeniedException("Access denied: REMOVE " + changedItem.getData().getQPath().getAsString()
+ + " for: " + session.getUserID() + " item owner " + nodeData.getACL().getOwner());
+ }
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java 2010-12-01 15:49:40 UTC (rev 3587)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java 2010-12-01 16:14:41 UTC (rev 3588)
@@ -47,6 +47,7 @@
import javax.jcr.NodeIterator;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import javax.jcr.ValueFactory;
import javax.jcr.Workspace;
@@ -162,10 +163,10 @@
{
if (session != null)
{
+ Session sysSession = repository.getSystemSession(session.getWorkspace().getName());
try
{
- session.refresh(false);
- Node rootNode = session.getRootNode();
+ Node rootNode = sysSession.getRootNode();
if (rootNode.hasNodes())
{
// clean test root
@@ -178,7 +179,7 @@
node.remove();
}
}
- session.save();
+ sysSession.save();
}
}
catch (Exception e)
@@ -187,6 +188,7 @@
}
finally
{
+ sysSession.logout();
session.logout();
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/lock/TestLockPermissions.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/lock/TestLockPermissions.java 2010-12-01 15:49:40 UTC (rev 3587)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/lock/TestLockPermissions.java 2010-12-01 16:14:41 UTC (rev 3588)
@@ -62,14 +62,6 @@
}
}
- @Override
- public void tearDown() throws Exception
- {
- lockedNode.remove();
- session.save();
- super.tearDown();
- }
-
public void testLockAccessDeniedException() throws RepositoryException
{
Session session1 = repository.login(new CredentialsImpl("root", "exo".toCharArray()), "ws");
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccess.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccess.java 2010-12-01 15:49:40 UTC (rev 3587)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccess.java 2010-12-01 16:14:41 UTC (rev 3588)
@@ -754,17 +754,10 @@
{
fail("AccessControlException should not have been thrown ");
}
- try
- {
- testByOwnerNode.remove();
- session1.save();
- fail();
- }
- catch (AccessDeniedException e)
- {
- // fail("AccessControlException should not have been thrown ");
- }
+ //john is node owner so he can remove no matter what permission are assigned to node
+ testByOwnerNode.remove();
+ session1.save();
}
public void testRemoveExoOwnable() throws Exception
Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccessChildNodes.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccessChildNodes.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccessChildNodes.java 2010-12-01 16:14:41 UTC (rev 3588)
@@ -0,0 +1,249 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.access;
+
+import org.exoplatform.services.jcr.BaseStandaloneTest;
+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.impl.core.NodeImpl;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: TestAccessChildNodes.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class TestAccessChildNodes extends BaseStandaloneTest
+{
+
+ @Override
+ public String getRepositoryName()
+ {
+ return "db1";
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ //create nodes with "john" user
+ Session sessJohn = repository.login(new CredentialsImpl("john", "exo".toCharArray()));
+ Node testRoot = sessJohn.getRootNode().addNode("testRoot");
+ testRoot.addMixin("exo:privilegeable");
+ testRoot.setProperty("prop", "value");
+ sessJohn.save();
+ sessJohn.logout();
+ }
+
+ public void tearDown() throws Exception
+ {
+ Session sysSession = this.repository.getSystemSession(session.getWorkspace().getName());
+ if (sysSession.getRootNode().hasNode("testRoot"))
+ {
+ Node testRoot = sysSession.getRootNode().getNode("testRoot");
+ testRoot.remove();
+ sysSession.save();
+ }
+ super.tearDown();
+ }
+
+ /**
+ * Remove the parent and child node with a user that can remove the parent node but not the sub node,
+ * and check that an AccessDeniedException occurs.
+ * @throws Exception
+ */
+ public void testUserCanRemoveParentButCanNotRemoveChild() throws Exception
+ {
+ // login as Mary and create subNode
+ Session sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+ Node testRoot = sessMary.getRootNode().getNode("testRoot");
+ NodeImpl subNode = (NodeImpl)testRoot.addNode("subNode");
+ subNode.addMixin("exo:privilegeable");
+ sessMary.save();
+
+ subNode.setPermission("mary", PermissionType.ALL);
+ subNode.removePermission("john");
+ subNode.removePermission(SystemIdentity.ANY);
+ sessMary.save();
+ sessMary.logout();
+
+ // login as John and try remove subnode
+ Session sessJohn = repository.login(new CredentialsImpl("john", "exo".toCharArray()));
+ try
+ {
+ subNode = (NodeImpl)sessJohn.getRootNode().getNode("testRoot").getNode("subNode");
+ subNode.remove();
+ sessJohn.save();
+ fail("There must be AccessDeniedException");
+ }
+ catch (AccessDeniedException e)
+ {
+ //Ok
+ }
+
+ // try to remove parent node node
+ sessJohn.refresh(false);
+ try
+ {
+ testRoot = sessJohn.getRootNode().getNode("testRoot");
+ testRoot.remove();
+ sessJohn.save();
+ fail("There must be AccessDeniedException");
+ }
+ catch (AccessDeniedException e)
+ {
+ //Ok
+ }
+ finally
+ {
+ sessJohn.logout();
+ }
+
+ // now try with all permissions
+ sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+ testRoot = sessMary.getRootNode().getNode("testRoot");
+ subNode = (NodeImpl)testRoot.getNode("subNode");
+ subNode.setPermission(SystemIdentity.ANY, PermissionType.ALL);
+ sessMary.save();
+ sessMary.logout();
+
+ sessJohn = repository.login(new CredentialsImpl("john", "exo".toCharArray()));
+ testRoot = sessJohn.getRootNode().getNode("testRoot");
+ testRoot.remove();
+ sessJohn.save();
+ sessJohn.logout();
+ }
+
+ /**
+ * Remove the sub node with a user that can remove the sub node (but not the parent node),
+ * and check that the remove operation was successful.
+ * @throws Exception
+ */
+ public void testUserCanNotRemoveParentButCanRemoveChild() throws Exception
+ {
+ // login as Mary and create subNode
+ Session sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+ NodeImpl testRoot = (NodeImpl)sessMary.getRootNode().getNode("testRoot");
+ NodeImpl subNode = (NodeImpl)testRoot.addNode("subNode");
+ subNode.addMixin("exo:privilegeable");
+ sessMary.save();
+
+ //set permissions
+ subNode.setPermission("mary", PermissionType.ALL);
+ subNode.removePermission("john");
+ subNode.removePermission(SystemIdentity.ANY);
+ sessMary.save();
+
+ testRoot.setPermission("john", PermissionType.ALL);
+ testRoot.removePermission("mary");
+ testRoot.setPermission("mary", new String[]{PermissionType.READ});
+ testRoot.removePermission(SystemIdentity.ANY);
+ sessMary.save();
+ sessMary.logout();
+
+ //try to remove parent as Mary - must fail
+ sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+ try
+ {
+ testRoot = (NodeImpl)sessMary.getRootNode().getNode("testRoot");
+ testRoot.remove();
+ sessMary.save();
+ fail("There must be AccessDeniedException");
+ }
+ catch (AccessDeniedException e)
+ {
+ //Ok
+ }
+ sessMary.refresh(false);
+
+ // remove subnode as mary
+ subNode = (NodeImpl)sessMary.getRootNode().getNode("testRoot").getNode("subNode");
+ subNode.remove();
+ sessMary.save();
+ assertFalse(sessMary.getRootNode().getNode("testRoot").hasNode("subNode"));
+ sessMary.logout();
+ }
+
+ /**
+ * Remove the property with a user that cannot remove the parent node, and check that an AccessDeniedException occurs
+ * @throws Exception
+ */
+ public void testRemovePropertyWithoutPermissionOnParent() throws Exception
+ {
+ // login as Mary and set permissions on parent node
+ Session sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+ NodeImpl testRoot = (NodeImpl)sessMary.getRootNode().getNode("testRoot");
+
+ testRoot.removePermission("mary");
+ testRoot.setPermission("mary", new String[]{PermissionType.READ});
+ testRoot.removePermission(SystemIdentity.ANY);
+ sessMary.save();
+ sessMary.logout();
+
+ //try to remove parent's property as Mary - must fail
+ sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+ try
+ {
+ testRoot = (NodeImpl)sessMary.getRootNode().getNode("testRoot");
+ testRoot.getProperty("prop").remove();
+ sessMary.save();
+ fail("There must be AccessDeniedException");
+ }
+ catch (AccessDeniedException e)
+ {
+ //Ok
+ }
+ finally
+ {
+ sessMary.logout();
+ }
+ }
+
+ /**
+ * Remove the property with a user that can remove the parent node, and check that the remove operation was successful.
+ * @throws Exception
+ */
+ public void testRemovePropertyWithPermissionOnParent() throws Exception
+ {
+ // login as Mary and set permissions on parent node
+ Session sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+ NodeImpl testRoot = (NodeImpl)sessMary.getRootNode().getNode("testRoot");
+
+ testRoot.removePermission("mary");
+ testRoot.setPermission("mary", PermissionType.ALL);
+ testRoot.removePermission(SystemIdentity.ANY);
+ sessMary.save();
+ sessMary.logout();
+
+ //try to remove parent's property as Mary - must fail
+ sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+
+ testRoot = (NodeImpl)sessMary.getRootNode().getNode("testRoot");
+ testRoot.getProperty("prop").remove();
+ sessMary.save();
+
+ assertFalse(sessMary.getRootNode().getNode("testRoot").hasProperty("prop"));
+ sessMary.logout();
+ }
+
+}
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestUserAccess.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestUserAccess.java 2010-12-01 15:49:40 UTC (rev 3587)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestUserAccess.java 2010-12-01 16:14:41 UTC (rev 3588)
@@ -54,9 +54,13 @@
@Override
protected void tearDown() throws Exception
{
- root.refresh(false);
- testRoot.remove();
- root.save();
+ Session sysSession = repository.getSystemSession(session.getWorkspace().getName());
+ if (sysSession.getRootNode().hasNode("testUserAccess"))
+ {
+ Node testRoot = sysSession.getRootNode().getNode("testUserAccess");
+ testRoot.remove();
+ sysSession.save();
+ }
super.tearDown();
}
15 years, 6 months
exo-jcr SVN: r3587 - in jcr/branches/1.12.x/applications: exo.jcr.applications.backupconsole.dist and 4 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-12-01 10:49:40 -0500 (Wed, 01 Dec 2010)
New Revision: 3587
Removed:
jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/exobackup.cmd
jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/exobackup.sh
jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/jcrbackup.cmd
jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/jcrbackup.sh
jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/assemblies/binary-assembly.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/assemblies/zip-bundle-assembly.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/doc/readme.txt
jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/resources/log4j.properties
Modified:
jcr/branches/1.12.x/applications/pom.xml
Log:
JCR-1499 : The changes for this issue in JCR 1.12.x was rollback. Will be committed in JCR 1.12.7-GA.
Deleted: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/exobackup.cmd
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/exobackup.cmd 2010-12-01 15:42:53 UTC (rev 3586)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/exobackup.cmd 2010-12-01 15:49:40 UTC (rev 3587)
@@ -1,56 +0,0 @@
-echo off
-if %1 NEQ "-u" goto :help
-set user=%2
-set pass=%3
-set auth=%4
-set host=%5
-SHIFT
-SHIFT
-SHIFT
-SHIFT
-SHIFT
-set comm=%*
-
-if %auth% == "-b" set newarg="http://%user%:%pass%@%host% %comm%"
-if %auth% == "-f" set newarg="http://%host%/portal/rest form POST /portal/login?username=%user%&password=%pass% %comm%"
-
-jcrbackup.cmd %newarg%
-
-exit
-:help
-echo " -u <user> <password> <form_of_authentication> <host:port> <command> "
-echo " "
-echo " <form_of_authentication> : -b - is used for basic authentication "
-echo " -f - is used for form authentication "
-echo " "
-echo " <command> : start <repo[/ws]> <backup_dir> [<incr>] "
-echo " stop <backup_id> "
-echo " status <backup_id> "
-echo " restores <repo[/ws]> "
-echo " restore <repo[/ws]> <backup_id> <pathToConfigFile> "
-echo " list [completed] "
-echo " info "
-echo " drop [force-close-session] <repo[/ws]> "
-echo " help "
-echo " "
-echo " start : start backup of repository or workspace "
-echo " stop : stop backup "
-echo " status : information about the current or completed backup by 'backup_id' "
-echo " restores : information about the last restore on specific repository or workspace "
-echo " restore : restore the repository or workspace from specific backup "
-echo " list : information about the current backups (in progress) "
-echo " list completed : information about the completed (ready to restore) backups "
-echo " info : information about the service backup "
-echo " drop : delete the repository or workspace "
-echo " help : print help information about backup console "
-echo " "
-echo " <repo[/ws]> : /<repository-name>[/<workspace-name>] the repository or workspace "
-echo " <backup_dir> : path to folder for backup on remote server "
-echo " <backup_id> : the identifier for backup "
-echo " <incr> : incremental job period "
-echo " <pathToConfigFile> : path (local) to repository or workspace configuration "
-echo " force-close-session : close opened sessions on repository or workspace "
-
-
-
-
Deleted: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/exobackup.sh
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/exobackup.sh 2010-12-01 15:42:53 UTC (rev 3586)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/exobackup.sh 2010-12-01 15:49:40 UTC (rev 3587)
@@ -1,55 +0,0 @@
-#!/bin/bash
-
-args=("$@")
-
-if [ "$1" != "-u" ]
-then
-echo " -u <user> <password> <form_of_authentication> <host:port> <command> "
-echo " "
-echo " <form_of_authentication> : -b - is used for basic authentication "
-echo " -f - is used for form authentication "
-echo " "
-echo " <command> : start <repo[/ws]> <backup_dir> [<incr>] "
-echo " stop <backup_id> "
-echo " status <backup_id> "
-echo " restores <repo[/ws]> "
-echo " restore <repo[/ws]> <backup_id> <pathToConfigFile> "
-echo " list [completed] "
-echo " info "
-echo " drop [force-close-session] <repo[/ws]> "
-echo " help "
-echo " "
-echo " start : start backup of repository or workspace "
-echo " stop : stop backup "
-echo " status : information about the current or completed backup by 'backup_id' "
-echo " restores : information about the last restore on specific repository or workspace "
-echo " restore : restore the repository or workspace from specific backup "
-echo " list : information about the current backups (in progress) "
-echo " list completed : information about the completed (ready to restore) backups "
-echo " info : information about the service backup "
-echo " drop : delete the repository or workspace "
-echo " help : print help information about backup console "
-echo " "
-echo " <repo[/ws]> : /<repository-name>[/<workspace-name>] the repository or workspace "
-echo " <backup_dir> : path to folder for backup on remote server "
-echo " <backup_id> : the identifier for backup "
-echo " <incr> : incremental job period "
-echo " <pathToConfigFile> : path (local) to repository or workspace configuration "
-echo " force-close-session : close opened sessions on repository or workspace "
-exit 1
-fi
-
-user="$2"
-pass="$3"
-host=${5#*"http://"}
-if [ "$4" = "-f" ]
-then
- newargs="http://$host/portal/rest form POST /portal/login?username=$user&password=$pass ${args[@]:5}"
-else
- if [ "$4" = "-b" ]
- then
- newargs="http://$user:$pass@$host ${args[@]:5}"
- fi
-fi
-
-./jcrbackup.sh $newargs
Deleted: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/jcrbackup.cmd
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/jcrbackup.cmd 2010-12-01 15:42:53 UTC (rev 3586)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/jcrbackup.cmd 2010-12-01 15:49:40 UTC (rev 3587)
@@ -1 +0,0 @@
-java -jar exo.jcr.applications.backupconsole.dist-binary.jar %*
Deleted: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/jcrbackup.sh
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/jcrbackup.sh 2010-12-01 15:42:53 UTC (rev 3586)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/bin/jcrbackup.sh 2010-12-01 15:49:40 UTC (rev 3587)
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-java -jar exo.jcr.applications.backupconsole.dist-binary.jar $*
Deleted: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/pom.xml 2010-12-01 15:42:53 UTC (rev 3586)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/pom.xml 2010-12-01 15:49:40 UTC (rev 3587)
@@ -1,128 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.exoplatform.jcr</groupId>
- <artifactId>jcr-applications-parent</artifactId>
- <version>1.12.6-GA-SNAPSHOT</version>
- </parent>
- <artifactId>exo.jcr.applications.backupconsole.dist</artifactId>
- <name>eXo JCR :: Applications :: Backup Console Binary Distribution</name>
- <properties>
- <childDelegation>true</childDelegation>
- <enforcer.skip>true</enforcer.skip>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.exoplatform.jcr</groupId>
- <artifactId>exo.jcr.applications.backupconsole</artifactId>
- <version>1.12.6-GA-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.jcr</groupId>
- <artifactId>exo.jcr.component.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.jcr</groupId>
- <artifactId>exo.jcr.component.ext</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.ws</groupId>
- <artifactId>exo.ws.commons</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.ws</groupId>
- <artifactId>exo.ws.frameworks.json</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.commons</artifactId>
- </dependency>
- <dependency>
- <groupId>org.exoplatform.kernel</groupId>
- <artifactId>exo.kernel.container</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jibx</groupId>
- <artifactId>jibx-run</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>jsr311-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>runtime</scope>
- </dependency>
- <!-- dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency -->
- </dependencies>
- <build>
- <outputDirectory>target</outputDirectory>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>jar-with-dependensies</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <primaryArtifact>false</primaryArtifact>
- <finalName>${project.artifactId}</finalName>
- <descriptors>
- <descriptor>${basedir}/src/main/assemblies/binary-assembly.xml</descriptor>
- </descriptors>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <classpathPrefix>/</classpathPrefix>
- <mainClass>org.exoplatform.jcr.backupconsole.BackupConsole</mainClass>
- </manifest>
- </archive>
- </configuration>
- </execution>
- <execution>
- <id>bundle</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <appendAssemblyId>false</appendAssemblyId>
- <descriptors>
- <descriptor>${basedir}/src/main/assemblies/zip-bundle-assembly.xml</descriptor>
- </descriptors>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
Deleted: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/assemblies/binary-assembly.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/assemblies/binary-assembly.xml 2010-12-01 15:42:53 UTC (rev 3586)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/assemblies/binary-assembly.xml 2010-12-01 15:49:40 UTC (rev 3587)
@@ -1,73 +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.
-
--->
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>binary</id>
- <formats>
- <format>jar</format>
- </formats>
- <includeBaseDirectory>false</includeBaseDirectory>
- <dependencySets>
- <dependencySet>
- <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
- <outputDirectory>/</outputDirectory>
- <unpack>true</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <scope>compile</scope>
- <useTransitiveDependencies>false</useTransitiveDependencies>
- </dependencySet>
- <dependencySet>
- <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
- <outputDirectory>/</outputDirectory>
- <unpack>true</unpack>
- <scope>test</scope>
- <includes>
- <include>org.slf4j:slf4j-log4j12</include>
- </includes>
- <useTransitiveDependencies>false</useTransitiveDependencies>
- </dependencySet>
- <dependencySet>
- <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
- <outputDirectory>/</outputDirectory>
- <unpack>true</unpack>
- <!-- useTransitiveDependencies>true</useTransitiveDependencies -->
- <!-- useTransitiveFiltering>true</useTransitiveFiltering -->
- <includes>
- <!-- eXo Deserializer deps -->
- <include>picocontainer:picocontainer</include>
- <!-- eXo logging deps -->
- <include>org.slf4j:*</include>
- <include>log4j:log4j</include>
- <include>commons-logging:commons-logging</include>
- <!-- runtime deps of exo.ws.commons -->
- <include>javax.xml.stream:stax-api</include>
- <include>xpp3:xpp3</include>
- </includes>
- </dependencySet>
- </dependencySets>
- <fileSets>
- <fileSet>
- <directory>${basedir}/src/main/resources</directory>
- <outputDirectory>/</outputDirectory>
- </fileSet>
- </fileSets>
-</assembly>
Deleted: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/assemblies/zip-bundle-assembly.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/assemblies/zip-bundle-assembly.xml 2010-12-01 15:42:53 UTC (rev 3586)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/assemblies/zip-bundle-assembly.xml 2010-12-01 15:49:40 UTC (rev 3587)
@@ -1,49 +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.
-
--->
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>bundle</id>
- <formats>
- <format>zip</format>
- </formats>
- <includeBaseDirectory>false</includeBaseDirectory>
- <files>
- <file>
- <source>target/${project.artifactId}-binary.jar</source>
- <destName>${project.artifactId}-binary.jar</destName>
- </file>
- <file>
- <source>${basedir}/src/main/doc/readme.txt</source>
- <destName>readme.txt</destName>
- </file>
- </files>
- <fileSets>
- <fileSet>
- <directory>${basedir}/bin</directory>
- <outputDirectory>/</outputDirectory>
- <includes>
- <include>*.cmd</include>
- <include>*.sh</include>
- </includes>
- </fileSet>
- </fileSets>
-</assembly>
Deleted: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/doc/readme.txt
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/doc/readme.txt 2010-12-01 15:42:53 UTC (rev 3586)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/doc/readme.txt 2010-12-01 15:49:40 UTC (rev 3587)
@@ -1,76 +0,0 @@
-jcrbackup.cmd and jcrbackup.sh - suitable for Standalone and flexible for various authentication ways shell scripts
-
- <url_basic_authentication> | <url_form_authentication> <command>
-
- <url_basic_authentication>: http(s)//login:password@host:port/<context>
- <url_form_authentication> : http(s)//host:port/<context> <form_auth_parm>
-
- <form_auth_part> : form <method> <form_path>
- <method> : POST or GET
- <form_path> : /path/path?<paramName1>=<paramValue1>&<paramName2>=<paramValue2>...
-
- Example of <url_form_authentication> - http://127.0.0.1:8080/portal/rest form POST "/portal/login?username=root&password=gtn"
-
- <command> : start <repo[/ws]> <backup_dir> [<incr>]
- stop <backup_id>
- status <backup_id>
- restores <repo[/ws]>
- restore <repo[/ws]> <backup_id> <pathToConfigFile>
- list [completed]
- info
- drop [force-close-session] <repo[/ws]>
- help
-
- start : start backup of repository or workspace
- stop : stop backup
- status : information about the current or completed backup by 'backup_id'
- restores : information about the last restore on specific repository or workspace
- restore : restore the repository or workspace from specific backup
- list : information about the current backups (in progress)
- list completed : information about the completed (ready to restore) backups
- info : information about the service backup
- drop : delete the repository or workspace
- help : print help information about backup console
-
- <repo[/ws]> : /<repository-name>[/<workspace-name>] the repository or workspace
- <backup_dir> : path to folder for backup on remote server
- <backup_id> : the identifier for backup
- <incr> : incremental job period
- <pathToConfigFile> : path (local) to repository or workspace configuration
- force-close-session : close opened sessions on repository or workspace
-
-
-exobackup.sh and exobackup.cmd - suitable for use with GateIn based products like Platform
-
- -u <user> <password> <form_of_authentication> <host:port> <command>
-
- <form_of_authentication> : -b - is used for basic authentication
- -f - is used for form authentication
-
- <command> : start <repo[/ws]> <backup_dir> [<incr>]
- stop <backup_id>
- status <backup_id>
- restores <repo[/ws]>
- restore <repo[/ws]> <backup_id> <pathToConfigFile>
- list [completed]
- info
- drop [force-close-session] <repo[/ws]>
- help
-
- start : start backup of repository or workspace
- stop : stop backup
- status : information about the current or completed backup by 'backup_id'
- restores : information about the last restore on specific repository or workspace
- restore : restore the repository or workspace from specific backup
- list : information about the current backups (in progress)
- list completed : information about the completed (ready to restore) backups
- info : information about the service backup
- drop : delete the repository or workspace
- help : print help information about backup console
-
- <repo[/ws]> : /<repository-name>[/<workspace-name>] the repository or workspace
- <backup_dir> : path to folder for backup on remote server
- <backup_id> : the identifier for backup
- <incr> : incremental job period
- <pathToConfigFile> : path (local) to repository or workspace configuration
- force-close-session : close opened sessions on repository or workspace
Deleted: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/resources/log4j.properties
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/resources/log4j.properties 2010-12-01 15:42:53 UTC (rev 3586)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/src/main/resources/log4j.properties 2010-12-01 15:49:40 UTC (rev 3587)
@@ -1,25 +0,0 @@
-# Set root logger level to DEBUG and its only appender to A1.
-#log4j.rootLogger=INFO, file
-#log4j.rootLogger=DEBUG, file
-#log4j.rootLogger=DEBUG, stdout, file
-log4j.rootLogger=ERROR, stdout, file
-
-#log4j.logger.org.apache.jackrabbit.test=DEBUG
-#log4j.logger.org.exoplatform=DEBUG
-log4j.logger.org.hibernate=ERROR
-
-# 'stdout' is set to be a ConsoleAppender.
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-
-# 'stdout' uses PatternLayout
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L)\n
-
-# 'file' is set to be a FileAppender.
-log4j.appender.file=org.apache.log4j.FileAppender
-#log4j.appender.file.File=jcr.log
-log4j.appender.file.File=nul
-
-# 'file' uses PatternLayout.
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L)\n
Modified: jcr/branches/1.12.x/applications/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/pom.xml 2010-12-01 15:42:53 UTC (rev 3586)
+++ jcr/branches/1.12.x/applications/pom.xml 2010-12-01 15:49:40 UTC (rev 3587)
@@ -36,7 +36,6 @@
<modules>
<module>exo.jcr.cluster.testclient</module>
<module>exo.jcr.applications.backupconsole</module>
- <module>exo.jcr.applications.backupconsole.dist</module>
<module>exo.jcr.applications.browser</module>
<module>exo.jcr.applications.config</module>
<module>exo.jcr.applications.fckeditor</module>
15 years, 6 months
exo-jcr SVN: r3586 - in jcr/branches/1.12.x: exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl and 2 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-12-01 10:42:53 -0500 (Wed, 01 Dec 2010)
New Revision: 3586
Removed:
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/ExtendedBackupManager.java
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/WorkspaceRestoreException.java
Modified:
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupChainLog.java
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupChainImpl.java
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/RepositoryBackupChainImpl.java
jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java
jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java
jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/exojcr-backup-service.xml
Log:
JCR-1502 : The changes for this issue in JCR 1.12.x was rollback. Will be committed in JCR 1.12.7-GA
Modified: jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupChainLog.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupChainLog.java 2010-12-01 15:00:37 UTC (rev 3585)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupChainLog.java 2010-12-01 15:42:53 UTC (rev 3586)
@@ -18,14 +18,15 @@
*/
package org.exoplatform.services.jcr.ext.backup;
-import java.io.ByteArrayInputStream;
+import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
import java.io.File;
import java.io.FileInputStream;
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.util.ArrayList;
@@ -43,20 +44,6 @@
import javax.xml.stream.XMLStreamWriter;
import javax.xml.stream.events.StartElement;
-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/>
*
@@ -66,11 +53,6 @@
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-";
@@ -97,12 +79,6 @@
private boolean finalized;
- private WorkspaceEntry originalWorkspaceEntry;
-
- private final String versionLog;
-
- private File rootDir;
-
/**
* BackupChainLog constructor.
*
@@ -116,30 +92,24 @@
* 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, WorkspaceEntry wEntry, File rootDir) throws BackupOperationException
+ String backupId) throws BackupOperationException
{
try
{
this.finalized = false;
- this.versionLog = VERSION_LOG_1_1;
this.log = new File(logDir.getCanonicalPath() + File.separator + (PREFIX + backupId + SUFFIX));
- this.rootDir = rootDir;
this.log.createNewFile();
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)
{
@@ -153,10 +123,6 @@
{
throw new BackupOperationException(e);
}
- catch (JsonException e)
- {
- throw new BackupOperationException(e);
- }
}
/**
@@ -178,12 +144,10 @@
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)
{
@@ -214,10 +178,6 @@
{
throw new BackupOperationException(e);
}
- catch (Exception e)
- {
- throw new BackupOperationException(e);
- }
}
/**
@@ -237,7 +197,7 @@
info.setState(job.getState());
info.setURL(job.getStorageURL());
- logWriter.write(info, config);
+ logWriter.write(info);
}
catch (Exception e)
{
@@ -286,33 +246,6 @@
{
finalized = true;
logWriter.writeEndLog();
-
- //copy backup chain log file in into Backupset files itself for portability (e.g. on another server)
- try
- {
- InputStream in = new FileInputStream(log);
-
- File dest = new File(config.getBackupDir() + File.separator + log.getName());
- if (!dest.exists())
- {
- OutputStream out = new FileOutputStream(dest);
-
- byte[] buf = new byte[(int) (log.length())];
- 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);
- }
-
}
/**
@@ -376,17 +309,6 @@
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");
@@ -400,31 +322,15 @@
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(new FileInputStream(this.logFile),
- Constants.DEFAULT_ENCODING);
+ reader = XMLInputFactory.newInstance().createXMLStreamReader(new FileInputStream(this.logFile));
}
- public String getVersionLog()
- {
- return version;
- }
-
- public WorkspaceEntry getOriginalWorkspaceEntry()
- {
- return originalWorkspaceEntry;
- }
-
public BackupConfig getBackupConfig()
{
return config;
@@ -450,7 +356,7 @@
return jobEntries.get(jobEntries.size() - 1).getDate();
}
- public void readLogFile() throws Exception
+ public void readLogFile() throws XMLStreamException, MalformedURLException, ValueFormatException
{
boolean endDocument = false;
@@ -469,14 +375,6 @@
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 :
@@ -486,38 +384,8 @@
}
}
- private WorkspaceEntry readWorkspaceEntry() throws Exception
+ private JobEntryInfo readJobEntryInfo() throws XMLStreamException, MalformedURLException, ValueFormatException
{
- 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;
@@ -538,22 +406,8 @@
info.setState(getState(readContent()));
if (name.equals("url"))
- {
- if (version != null && version.equals(VERSION_LOG_1_1))
- {
- String path =
- readContent().replace("file:",
- "file:" + config.getBackupDir().getCanonicalPath()
- + File.separator);
+ info.setURL(new URL(readContent()));
- info.setURL(new URL(path));
- }
- else
- {
- info.setURL(new URL(readContent()));
- }
- }
-
if (name.equals("date"))
info.setDate(JCRDateFormat.parse(readContent()));
@@ -603,7 +457,7 @@
return type;
}
- private BackupConfig readBackupConfig() throws XMLStreamException, IOException
+ private BackupConfig readBackupConfig() throws XMLStreamException
{
BackupConfig conf = new BackupConfig();
@@ -619,27 +473,8 @@
String name = reader.getLocalName();
if (name.equals("backup-dir"))
- {
- if (version != null && version.equals(VERSION_LOG_1_1))
- {
- String dir = readContent();
- if (dir.equals("."))
- {
- String path = logFile.getParentFile().getCanonicalPath();
+ conf.setBackupDir(new File(readContent()));
- conf.setBackupDir(new File(path));
- }
- else
- {
- conf.setBackupDir(new File(dir));
- }
- }
- else
- {
- conf.setBackupDir(new File(readContent()));
- }
- }
-
if (name.equals("repository"))
conf.setRepository(readContent());
@@ -711,32 +546,15 @@
{
this.logFile = logFile;
- writer =
- XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(this.logFile),
- Constants.DEFAULT_ENCODING);
+ writer = XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(this.logFile));
writer.writeStartDocument();
- writer.writeStartElement("backup-chain-log");
-
- writer.writeStartElement("version-log");
- writer.writeCharacters(versionLog);
- writer.writeEndElement();
-
+ writer.writeStartElement("backup-cain-log");
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, IOException
+ throws XMLStreamException
{
writer.writeStartElement("backup-config");
@@ -751,14 +569,7 @@
if (config.getBackupDir() != null)
{
writer.writeStartElement("backup-dir");
-
- String path =
- (isRootBackupManagerDir(logFile) ? config.getBackupDir().getCanonicalPath() : config
- .getBackupDir().getCanonicalPath()
- .replace(logFile.getParentFile().getCanonicalPath(), ""));
-
-
- writer.writeCharacters(path.equals("") ? "." : path);
+ writer.writeCharacters(config.getBackupDir().getAbsolutePath());
writer.writeEndElement();
}
@@ -789,7 +600,7 @@
writer.flush();
}
- public synchronized void write(JobEntryInfo info, BackupConfig config) throws XMLStreamException, IOException
+ public synchronized void write(JobEntryInfo info) throws XMLStreamException
{
writer.writeStartElement("job-entry-info");
@@ -802,7 +613,7 @@
writer.writeEndElement();
writer.writeStartElement("url");
- writer.writeCharacters(getRelativeUrl(info.getURL(), config.getBackupDir()));
+ writer.writeCharacters(info.getURL().toString());
writer.writeEndElement();
writer.writeStartElement("date");
@@ -814,18 +625,6 @@
writer.flush();
}
- private String getRelativeUrl(URL url, File backupDir) throws IOException
- {
- String str = new File(url.getFile()).getCanonicalPath();
-
- return url.getProtocol() + ":" + str.replace(config.getBackupDir().getCanonicalPath() + File.separator, "");
- }
-
- private boolean isRootBackupManagerDir(File log) throws IOException
- {
- return (log.getCanonicalFile().getParentFile().getCanonicalPath().equals(rootDir.getCanonicalPath()));
- }
-
public synchronized void writeEndLog()
{
try
Deleted: jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/ExtendedBackupManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/ExtendedBackupManager.java 2010-12-01 15:00:37 UTC (rev 3585)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/ExtendedBackupManager.java 2010-12-01 15:42:53 UTC (rev 3586)
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2003-2010 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.ext.backup;
-
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 2010
- *
- * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
- * @version $Id: ExtendedBackupManager.java 3545 2010-11-24 15:35:31Z areshetnyak $
- */
-public interface ExtendedBackupManager
- extends BackupManager
-{
-
- // TODO Will be uncommented after fix issue JCR-1054
- // /**
- // * 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/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java 2010-12-01 15:00:37 UTC (rev 3585)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/RepositoryBackupChainLog.java 2010-12-01 15:42:53 UTC (rev 3586)
@@ -16,19 +16,18 @@
*/
package org.exoplatform.services.jcr.ext.backup;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
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;
@@ -37,19 +36,9 @@
import javax.xml.stream.XMLStreamWriter;
import javax.xml.stream.events.StartElement;
-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.
@@ -74,22 +63,15 @@
{
this.logFile = logFile;
- writer =
- XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(this.logFile),
- Constants.DEFAULT_ENCODING);
+ writer = XMLOutputFactory.newInstance().createXMLStreamWriter(new FileOutputStream(this.logFile));
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
@@ -100,16 +82,14 @@
writer.flush();
}
- public void writeBackupsPath(List<String> wsLogFilePathList, RepositoryBackupConfig config)
- throws XMLStreamException,
- IOException
+ public void writeBackupsPath(List<String> wsLogFilePathList) throws XMLStreamException
{
writer.writeStartElement("workspaces-backup-info");
for (String path : wsLogFilePathList)
{
writer.writeStartElement("url");
- writer.writeCharacters(path.replace(config.getBackupDir().getCanonicalPath() + File.separator, ""));
+ writer.writeCharacters(path);
writer.writeEndElement();
}
@@ -119,7 +99,7 @@
}
public synchronized void write(RepositoryBackupConfig config, String fullBackupType, String incrementalBackupType)
- throws XMLStreamException, IOException
+ throws XMLStreamException
{
writer.writeStartElement("repository-backup-config");
@@ -138,7 +118,7 @@
if (config.getBackupDir() != null)
{
writer.writeStartElement("backup-dir");
- writer.writeCharacters(config.getBackupDir().getCanonicalPath());
+ writer.writeCharacters(config.getBackupDir().getAbsolutePath());
writer.writeEndElement();
}
@@ -179,17 +159,6 @@
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
@@ -200,17 +169,13 @@
private XMLStreamReader reader;
- private String version;
-
public LogReader(File logFile) throws FileNotFoundException, XMLStreamException, FactoryConfigurationError
{
this.logFile = logFile;
- reader =
- XMLInputFactory.newInstance().createXMLStreamReader(new FileInputStream(logFile),
- Constants.DEFAULT_ENCODING);
+ reader = XMLInputFactory.newInstance().createXMLStreamReader(new FileInputStream(logFile));
}
- public void readLogFile() throws UnsupportedEncodingException, Exception
+ public void readLogFile() throws XMLStreamException, MalformedURLException, ValueFormatException
{
boolean endDocument = false;
@@ -241,15 +206,6 @@
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 :
@@ -259,38 +215,8 @@
}
}
- private RepositoryEntry readRepositoryEntry() throws UnsupportedEncodingException, Exception
+ private List<String> readWorkspaceBackupInfo() throws XMLStreamException
{
- 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;
@@ -305,17 +231,7 @@
String name = reader.getLocalName();
if (name.equals("url"))
- {
- if (version != null && version.equals(VERSION_LOG_1_1))
- {
- String path = config.getBackupDir().getCanonicalPath() + File.separator + readContent();
- wsBackupInfo.add(path);
- }
- else
- {
- wsBackupInfo.add(readContent());
- }
- }
+ wsBackupInfo.add(readContent());
break;
@@ -331,7 +247,7 @@
return wsBackupInfo;
}
- private BackupConfig readBackupConfig() throws XMLStreamException, IOException
+ private BackupConfig readBackupConfig() throws XMLStreamException
{
BackupConfig conf = new BackupConfig();
@@ -347,27 +263,8 @@
String name = reader.getLocalName();
if (name.equals("backup-dir"))
- {
- if (version != null && version.equals(VERSION_LOG_1_1))
- {
- String dir = readContent();
- if (dir.equals("."))
- {
- String path = logFile.getParentFile().getCanonicalPath();
+ conf.setBackupDir(new File(readContent()));
- 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()));
@@ -415,19 +312,82 @@
return content;
}
- public String getVersionLog()
+ private JobEntryInfo readJobEntryInfo() throws XMLStreamException, MalformedURLException, ValueFormatException
{
- return version;
+ 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;
}
+
+ 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";
@@ -456,10 +416,6 @@
private String increnetalBackupType;
- private RepositoryEntry originalRepositoryEntry;
-
- private final String versionLog;
-
/**
* @param logDirectory
* @param config
@@ -467,17 +423,15 @@
* @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, RepositoryEntry rEntry) throws BackupOperationException
+ Calendar startTime) throws BackupOperationException
{
try
{
this.finalized = false;
- this.versionLog = VERSION_LOG_1_1;
this.log = new File(logDirectory.getCanonicalPath() + File.separator + (PREFIX + backupId + SUFFIX));
this.log.createNewFile();
this.backupId = backupId;
@@ -485,13 +439,11 @@
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, config);
- logWriter.writeRepositoryEntry(rEntry);
+ logWriter.writeBackupsPath(wsLogFilePathList);
this.workspaceBackupsInfo = wsLogFilePathList;
this.workspaceSystem = systemWorkspace;
@@ -508,10 +460,6 @@
{
throw new BackupOperationException("Can not create backup log ...", e);
}
- catch (JsonException e)
- {
- throw new BackupOperationException("Can not create backup log ...", e);
- }
}
/**
@@ -527,7 +475,6 @@
{
logReader = new LogReader(log);
logReader.readLogFile();
- this.versionLog = logReader.getVersionLog();
}
catch (FileNotFoundException e)
{
@@ -539,16 +486,21 @@
throw new BackupOperationException(
"Can not read RepositoryBackupChainLog from file :" + log.getAbsolutePath(), e);
}
- catch (UnsupportedEncodingException e)
+ catch (FactoryConfigurationError e)
{
throw new BackupOperationException(
"Can not read RepositoryBackupChainLog from file :" + log.getAbsolutePath(), e);
}
- catch (Exception e)
+ catch (MalformedURLException e)
{
throw new BackupOperationException(
"Can not read RepositoryBackupChainLog from file :" + log.getAbsolutePath(), e);
}
+ catch (ValueFormatException e)
+ {
+ throw new BackupOperationException(
+ "Can not read RepositoryBackupChainLog from file :" + log.getAbsolutePath(), e);
+ }
}
/**
@@ -611,33 +563,6 @@
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 = new FileInputStream(log);
-
- File dest = new File(config.getBackupDir() + File.separator + log.getName());
- if (!dest.exists())
- {
- OutputStream out = new FileOutputStream(dest);
-
- byte[] buf = new byte[(int) (log.length())];
- 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);
- }
}
}
@@ -674,15 +599,4 @@
return backupId;
}
- /**
- * Getting original repository configuration
- *
- * @return RepositoryEntry
- * return the original repository configuration
- */
- public RepositoryEntry getOriginalRepositoryEntry()
- {
- return originalRepositoryEntry;
- }
-
}
Deleted: jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/WorkspaceRestoreException.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/WorkspaceRestoreException.java 2010-12-01 15:00:37 UTC (rev 3585)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/WorkspaceRestoreException.java 2010-12-01 15:42:53 UTC (rev 3586)
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2003-2010 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.ext.backup;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 2010
- *
- * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
- * @version $Id: WorkspaceRestoreException.java 3210 2010-09-28 12:01:50Z areshetnyak $
- */
-public class WorkspaceRestoreException
- extends BackupConfigurationException
-{
-
- /**
- * WorkspaceRestoreException constructor.
- *
- * @param message
- * String, the exception message
- */
- public WorkspaceRestoreException(String message)
- {
- super(message);
- }
-
- /**
- * WorkspaceRestoreException constructor.
- *
- * @param message
- * String, the exception message
- * @param e
- * Throwable, the cause exception
- */
- public WorkspaceRestoreException(String message, Throwable e)
- {
- super(message, e);
- }
-}
\ No newline at end of file
Modified: jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupChainImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupChainImpl.java 2010-12-01 15:00:37 UTC (rev 3585)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupChainImpl.java 2010-12-01 15:42:53 UTC (rev 3586)
@@ -18,18 +18,6 @@
*/
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;
@@ -42,6 +30,17 @@
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/>
*
@@ -75,16 +74,12 @@
private Set<BackupJobListener> listeners = new LinkedHashSet<BackupJobListener>();
public BackupChainImpl(BackupConfig config, File logDirectory, ManageableRepository repository,
- String fullBackupType, String incrementalBackupType, String backupId, File rootDir)
- throws BackupOperationException,
+ String fullBackupType, String incrementalBackupType, String backupId) throws BackupOperationException,
BackupConfigurationException
{
this.config = config;
this.jobs = new ArrayList<BackupJob>();
-
- this.chainLog =
- new BackupChainLog(logDirectory, config, fullBackupType, incrementalBackupType, backupId,
- getWorkspaceEntry(config.getWorkspace(), repository), rootDir);
+ this.chainLog = new BackupChainLog(logDirectory, config, fullBackupType, incrementalBackupType, backupId);
this.timeStamp = Calendar.getInstance();
this.backupId = backupId;
@@ -118,29 +113,6 @@
+ "_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/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2010-12-01 15:00:37 UTC (rev 3585)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2010-12-01 15:42:53 UTC (rev 3586)
@@ -66,13 +66,10 @@
import org.exoplatform.services.jcr.ext.backup.BackupJobListener;
import org.exoplatform.services.jcr.ext.backup.BackupManager;
import org.exoplatform.services.jcr.ext.backup.BackupOperationException;
-import org.exoplatform.services.jcr.ext.backup.ExtendedBackupManager;
import org.exoplatform.services.jcr.ext.backup.JobEntryInfo;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChain;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChainLog;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupConfig;
-import org.exoplatform.services.jcr.ext.backup.RepositoryRestoreExeption;
-import org.exoplatform.services.jcr.ext.backup.WorkspaceRestoreException;
import org.exoplatform.services.jcr.ext.common.SessionProvider;
import org.exoplatform.services.jcr.ext.registry.RegistryEntry;
import org.exoplatform.services.jcr.ext.registry.RegistryService;
@@ -101,8 +98,7 @@
* @version $Id: $
*/
-public class BackupManagerImpl
- implements ExtendedBackupManager, Startable
+public class BackupManagerImpl implements BackupManager, Startable
{
protected static Log log = ExoLogger.getLogger("exo.jcr.component.ext.BackupManagerImpl");
@@ -596,7 +592,7 @@
String reposytoryName = (repositoryName == null ? config.getRepository() : repositoryName);
String workspaceName = workspaceEntry.getName();
- // ws should not exists.
+ // ws should be registered not created
if (!workspaceAlreadyExist(reposytoryName, workspaceName))
{
@@ -643,7 +639,7 @@
}
}
else
- throw new BackupConfigurationException("Workspace \"" + workspaceName + "\" should not exists.");
+ throw new BackupConfigurationException("Workspace should exists " + workspaceName);
}
private boolean workspaceAlreadyExist(String repository, String workspace) throws RepositoryException,
@@ -684,8 +680,8 @@
validateBackupConfig(config);
BackupChain bchain =
- new BackupChainImpl(config, logsDirectory, repoService.getRepository(config.getRepository()),
- fullBackupType, incrementalBackupType, IdGenerator.generate(), logsDirectory);
+ new BackupChainImpl(config, logsDirectory, repoService.getRepository(config.getRepository()), fullBackupType,
+ incrementalBackupType, IdGenerator.generate());
bchain.addListener(messagesListener);
bchain.addListener(jobListener);
@@ -1502,7 +1498,7 @@
RepositoryBackupChain repositoryBackupChain =
new RepositoryBackupChainImpl(config, logsDirectory, repository, fullBackupType, incrementalBackupType,
- IdGenerator.generate());
+ IdGenerator.generate());
repositoryBackupChain.startBackup();
@@ -1557,142 +1553,4 @@
}
return null;
}
-
- // TODO Will be uncommented after fix issue JCR-1054
- // /**
- // * {@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);
- //
- // }
-
- // TODO Will be uncommented after fix issue JCR-1054
- // /**
- // * {@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/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/RepositoryBackupChainImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/RepositoryBackupChainImpl.java 2010-12-01 15:00:37 UTC (rev 3585)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/RepositoryBackupChainImpl.java 2010-12-01 15:42:53 UTC (rev 3586)
@@ -68,8 +68,7 @@
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;
@@ -90,8 +89,8 @@
wsBackupConfig.setIncrementalJobPeriod(config.getIncrementalJobPeriod());
BackupChain bchain =
- new BackupChainImpl(wsBackupConfig, config.getBackupDir(), repository, fullBackupType,
- incrementalBackupType, IdGenerator.generate(), logDirectory);
+ new BackupChainImpl(wsBackupConfig, config.getBackupDir(), repository,
+ fullBackupType, incrementalBackupType, IdGenerator.generate());
wsLogFilePathList.add(bchain.getLogFilePath());
workspaceBackups.add(bchain);
@@ -104,8 +103,7 @@
repository.getConfiguration().getSystemWorkspaceName(),
wsLogFilePathList,
this.repositoryBackupId,
- startTime,
- repository.getConfiguration());
+ startTime);
state = INITIALIZED;
}
Modified: jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java 2010-12-01 15:00:37 UTC (rev 3585)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/AbstractBackupTestCase.java 2010-12-01 15:42:53 UTC (rev 3586)
@@ -52,8 +52,7 @@
* @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,24 +63,7 @@
protected BackupManager backup;
- // TODO Will be uncommented after fix issue JCR-1054
- // /**
- // * 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
+ class LogFilter implements FileFilter
{
public boolean accept(File pathname)
@@ -112,7 +94,7 @@
ws1TestRoot = ws1Session.getRootNode().addNode("backupTest");
ws1Session.save();
addContent(ws1TestRoot, 1, 10, 1);
-
+
}
else
{
@@ -124,7 +106,7 @@
}
// ws2
- ws2Session = (SessionImpl) repository.login(credentials, "ws2");
+ ws2Session = (SessionImpl)repository.login(credentials, "ws2");
}
@Override
@@ -133,24 +115,17 @@
for (String wsName : repository.getWorkspaceNames())
{
- try
+ if ("ws1".equals(wsName))
{
- 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();
- }
+ ws1Session = (SessionImpl) repository.login(credentials, "ws1");
+ ws1Session.getRootNode().getNode("backupTest").remove();
+ ws1Session.save();
}
- catch (PathNotFoundException e)
+ else
{
- //skip
+ SessionImpl ws = (SessionImpl)repository.login(credentials, wsName);
+ ws.getRootNode().getNode("backupTest").remove();
+ ws.save();
}
}
@@ -159,13 +134,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());
@@ -198,49 +173,45 @@
}
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);
@@ -269,7 +240,7 @@
if (newp.getName().equals("source-name"))
newp.setValue(sourceName);
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");
@@ -277,19 +248,18 @@
}
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);
@@ -304,12 +274,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)
@@ -328,8 +298,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++)
{
Modified: jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java 2010-12-01 15:00:37 UTC (rev 3585)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/TestBackupManager.java 2010-12-01 15:42:53 UTC (rev 3586)
@@ -18,6 +18,14 @@
*/
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.SessionImpl;
+
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -28,15 +36,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.SessionImpl;
-
-
/**
* Created by The eXo Platform SAS.
* Author : Peter Nedonosko peter.nedonosko(a)exoplatform.com.ua
@@ -49,74 +48,74 @@
{
public void testFullBackupRestore() throws Exception
- {
- // backup
- File backDir = new File("target/backup/ws1");
- backDir.mkdirs();
+ {
+ // 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);
+ BackupConfig config = new BackupConfig();
+ config.setRepository(repository.getName());
+ config.setWorkspace("ws1");
+ config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
- config.setBackupDir(backDir);
+ config.setBackupDir(backDir);
- backup.startBackup(config);
+ backup.startBackup(config);
- BackupChain bch = backup.findBackup(repository.getName(), "ws1");
+ BackupChain bch = backup.findBackup(repository.getName(), "ws1");
- // wait till full backup will be stopped
- while (bch.getFullBackupState() != BackupJob.FINISHED)
- {
- Thread.yield();
- Thread.sleep(50);
- }
+ // wait till full backup will be stopped
+ while (bch.getFullBackupState() != BackupJob.FINISHED)
+ {
+ Thread.yield();
+ Thread.sleep(50);
+ }
- // stop fullBackup
+ // stop fullBackup
- if (bch != null)
- backup.stopBackup(bch);
- else
- fail("Can't get fullBackup chain");
+ if (bch != null)
+ backup.stopBackup(bch);
+ else
+ fail("Can't get fullBackup chain");
- // restore
- RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
- WorkspaceEntry ws1back = makeWorkspaceEntry("ws1back", "jdbcjcr_backup_only_use_1");
+ // restore
+ RepositoryEntry re = (RepositoryEntry)ws1Session.getContainer().getComponentInstanceOfType(RepositoryEntry.class);
+ WorkspaceEntry ws1back = makeWorkspaceEntry("ws1back", "jdbcjcr_backup_only_use_1");
- // BackupChainLog bchLog = new BackupChainLog(backDir, rconfig);
- File backLog = new File(bch.getLogFilePath());
- if (backLog.exists())
- {
- BackupChainLog bchLog = new BackupChainLog(backLog);
+ // BackupChainLog bchLog = new BackupChainLog(backDir, rconfig);
+ File backLog = new File(bch.getLogFilePath());
+ if (backLog.exists())
+ {
+ BackupChainLog bchLog = new BackupChainLog(backLog);
- assertNotNull(bchLog.getStartedTime());
- assertNotNull(bchLog.getFinishedTime());
+ assertNotNull(bchLog.getStartedTime());
+ assertNotNull(bchLog.getFinishedTime());
- backup.restore(bchLog, re.getName(), ws1back, false);
+ backup.restore(bchLog, re.getName(), ws1back, false);
- // check
- SessionImpl back1 = null;
- try
- {
- 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());
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail(e.getMessage());
- }
- finally
- {
- if (back1 != null)
- back1.logout();
- }
+ // check
+ SessionImpl back1 = null;
+ try
+ {
+ 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());
}
- else
- fail("There are no backup files in " + backDir.getAbsolutePath());
+ 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 testIncrementalBackupRestore() throws Exception
{
@@ -1222,288 +1221,4 @@
else
fail("There are no backup files in " + backDir.getAbsolutePath());
}
-
- // TODO Will be uncommented after fix issue JCR-1054
- /*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());
- }*/
}
Modified: jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/exojcr-backup-service.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/exojcr-backup-service.xml 2010-12-01 15:00:37 UTC (rev 3585)
+++ jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/backup/exojcr-backup-service.xml 2010-12-01 15:42:53 UTC (rev 3586)
@@ -473,55 +473,5 @@
reinitialization, the task will have new time values for the backup
operation cycle as the chainPeriod and incrementalPeriod will be applied
again. That behaviour may be changed in the future.</para>
-
- <para></para>
-
- <section>
- <title>Restore a workspace or a repository using original
- configuration</title>
-
- <para>The Backup manager allows you to restore a repository or a
- workspace using the original configuration stored into the backup
- log:</para>
-
- <programlisting> /**
- * 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;</programlisting>
- </section>
-
- <section>
- <title>Backup set portability</title>
-
- <para>The Backup log is stored during the Backup operation into two
- different locations: backup-dir directory of BackupService to support
- interactive operations via Backup API (e.g. console) and backup set
- files for portability (e.g. on another server).</para>
- </section>
</section>
</chapter>
15 years, 6 months
exo-jcr SVN: r3585 - 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: sergiykarpenko
Date: 2010-12-01 10:00:37 -0500 (Wed, 01 Dec 2010)
New Revision: 3585
Added:
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccessChildNodes.java
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccess.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestUserAccess.java
Log:
JCR-1533: fixed remove permission on child nodes
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2010-12-01 14:59:21 UTC (rev 3584)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2010-12-01 15:00:37 UTC (rev 3585)
@@ -1542,58 +1542,78 @@
*/
private void validateAccessPermissions(ItemState changedItem) throws RepositoryException, AccessDeniedException
{
- NodeData parent = (NodeData)getItemData(changedItem.getData().getParentIdentifier());
- if (parent != null)
+ if (changedItem.isDeleted())
{
-
- // Remove propery or node
- if (changedItem.isDeleted())
+ validateRemoveAccessPermission(changedItem);
+ }
+ else
+ {
+ NodeData parent = (NodeData)getItemData(changedItem.getData().getParentIdentifier());
+ if (parent != null)
{
- if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.REMOVE}, session
- .getUserState().getIdentity()))
+ if (changedItem.getData().isNode())
{
- throw new AccessDeniedException("Access denied: REMOVE "
- + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID() + " item owner "
- + parent.getACL().getOwner());
- }
- }
- else if (changedItem.getData().isNode())
- {
- // add node
- if (changedItem.isAdded())
- {
- if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.ADD_NODE}, session
- .getUserState().getIdentity()))
+ // add node
+ if (changedItem.isAdded())
{
- throw new AccessDeniedException("Access denied: ADD_NODE "
- + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID() + " item owner "
- + parent.getACL().getOwner());
+ if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.ADD_NODE}, session
+ .getUserState().getIdentity()))
+ {
+ throw new AccessDeniedException("Access denied: ADD_NODE "
+ + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID()
+ + " item owner " + parent.getACL().getOwner());
+ }
}
+ else if (changedItem.isMixinChanged())
+ {
+ if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.ADD_NODE,
+ PermissionType.SET_PROPERTY}, session.getUserState().getIdentity()))
+ {
+ throw new AccessDeniedException("Access denied: ADD_NODE or SET_PROPERTY"
+ + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID()
+ + " item owner " + parent.getACL().getOwner());
+ }
+ }
+
}
- else if (changedItem.isMixinChanged())
+ else if (changedItem.isAdded() || changedItem.isUpdated())
{
- if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.ADD_NODE,
- PermissionType.SET_PROPERTY}, session.getUserState().getIdentity()))
+ // add or update property
+ if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.SET_PROPERTY}, session
+ .getUserState().getIdentity()))
{
- throw new AccessDeniedException("Access denied: ADD_NODE or SET_PROPERTY"
+ throw new AccessDeniedException("Access denied: SET_PROPERTY "
+ changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID() + " item owner "
+ parent.getACL().getOwner());
}
}
+ } // else - parent not found, deleted in this session or from another
+ }
+ }
- }
- else if (changedItem.isAdded() || changedItem.isUpdated())
+ private void validateRemoveAccessPermission(ItemState changedItem) throws RepositoryException, AccessDeniedException
+ {
+ NodeData nodeData = null;
+ // if changedItem is node - check its ACL, if property - check parent node ACL
+ if (changedItem.isNode())
+ {
+ nodeData = (NodeData)changedItem.getData();
+ }
+ else
+ {
+ nodeData = (NodeData)getItemData(changedItem.getData().getParentIdentifier());
+ if (nodeData == null)
{
- // add or update property
- if (!accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.SET_PROPERTY}, session
- .getUserState().getIdentity()))
- {
- throw new AccessDeniedException("Access denied: SET_PROPERTY "
- + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID() + " item owner "
- + parent.getACL().getOwner());
- }
+ return;
}
- } // else - parent not found, deleted in this session or from another
+ }
+
+ if (!accessManager.hasPermission(nodeData.getACL(), new String[]{PermissionType.REMOVE}, session.getUserState()
+ .getIdentity()))
+ {
+ throw new AccessDeniedException("Access denied: REMOVE " + changedItem.getData().getQPath().getAsString()
+ + " for: " + session.getUserID() + " item owner " + nodeData.getACL().getOwner());
+ }
}
/**
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccess.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccess.java 2010-12-01 14:59:21 UTC (rev 3584)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccess.java 2010-12-01 15:00:37 UTC (rev 3585)
@@ -741,17 +741,10 @@
{
fail("AccessControlException should not have been thrown ");
}
- try
- {
- testByOwnerNode.remove();
- session1.save();
- fail();
- }
- catch (AccessDeniedException e)
- {
- // fail("AccessControlException should not have been thrown ");
- }
+ //john is node owner so he can remove no matter what permission are assigned to node
+ testByOwnerNode.remove();
+ session1.save();
}
public void testRemoveExoOwnable() throws Exception
Added: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccessChildNodes.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccessChildNodes.java (rev 0)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestAccessChildNodes.java 2010-12-01 15:00:37 UTC (rev 3585)
@@ -0,0 +1,249 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.access;
+
+import org.exoplatform.services.jcr.BaseStandaloneTest;
+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.impl.core.NodeImpl;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: TestAccessChildNodes.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class TestAccessChildNodes extends BaseStandaloneTest
+{
+
+ @Override
+ public String getRepositoryName()
+ {
+ return "db1";
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ //create nodes with "john" user
+ Session sessJohn = repository.login(new CredentialsImpl("john", "exo".toCharArray()));
+ Node testRoot = sessJohn.getRootNode().addNode("testRoot");
+ testRoot.addMixin("exo:privilegeable");
+ testRoot.setProperty("prop", "value");
+ sessJohn.save();
+ sessJohn.logout();
+ }
+
+ public void tearDown() throws Exception
+ {
+ Session sysSession = this.repository.getSystemSession(session.getWorkspace().getName());
+ if (sysSession.getRootNode().hasNode("testRoot"))
+ {
+ Node testRoot = sysSession.getRootNode().getNode("testRoot");
+ testRoot.remove();
+ sysSession.save();
+ }
+ super.tearDown();
+ }
+
+ /**
+ * Remove the parent and child node with a user that can remove the parent node but not the sub node,
+ * and check that an AccessDeniedException occurs.
+ * @throws Exception
+ */
+ public void testUserCanRemoveParentButCanNotRemoveChild() throws Exception
+ {
+ // login as Mary and create subNode
+ Session sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+ Node testRoot = sessMary.getRootNode().getNode("testRoot");
+ NodeImpl subNode = (NodeImpl)testRoot.addNode("subNode");
+ subNode.addMixin("exo:privilegeable");
+ sessMary.save();
+
+ subNode.setPermission("mary", PermissionType.ALL);
+ subNode.removePermission("john");
+ subNode.removePermission(SystemIdentity.ANY);
+ sessMary.save();
+ sessMary.logout();
+
+ // login as John and try remove subnode
+ Session sessJohn = repository.login(new CredentialsImpl("john", "exo".toCharArray()));
+ try
+ {
+ subNode = (NodeImpl)sessJohn.getRootNode().getNode("testRoot").getNode("subNode");
+ subNode.remove();
+ sessJohn.save();
+ fail("There must be AccessDeniedException");
+ }
+ catch (AccessDeniedException e)
+ {
+ //Ok
+ }
+
+ // try to remove parent node node
+ sessJohn.refresh(false);
+ try
+ {
+ testRoot = sessJohn.getRootNode().getNode("testRoot");
+ testRoot.remove();
+ sessJohn.save();
+ fail("There must be AccessDeniedException");
+ }
+ catch (AccessDeniedException e)
+ {
+ //Ok
+ }
+ finally
+ {
+ sessJohn.logout();
+ }
+
+ // now try with all permissions
+ sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+ testRoot = sessMary.getRootNode().getNode("testRoot");
+ subNode = (NodeImpl)testRoot.getNode("subNode");
+ subNode.setPermission(SystemIdentity.ANY, PermissionType.ALL);
+ sessMary.save();
+ sessMary.logout();
+
+ sessJohn = repository.login(new CredentialsImpl("john", "exo".toCharArray()));
+ testRoot = sessJohn.getRootNode().getNode("testRoot");
+ testRoot.remove();
+ sessJohn.save();
+ sessJohn.logout();
+ }
+
+ /**
+ * Remove the sub node with a user that can remove the sub node (but not the parent node),
+ * and check that the remove operation was successful.
+ * @throws Exception
+ */
+ public void testUserCanNotRemoveParentButCanRemoveChild() throws Exception
+ {
+ // login as Mary and create subNode
+ Session sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+ NodeImpl testRoot = (NodeImpl)sessMary.getRootNode().getNode("testRoot");
+ NodeImpl subNode = (NodeImpl)testRoot.addNode("subNode");
+ subNode.addMixin("exo:privilegeable");
+ sessMary.save();
+
+ //set permissions
+ subNode.setPermission("mary", PermissionType.ALL);
+ subNode.removePermission("john");
+ subNode.removePermission(SystemIdentity.ANY);
+ sessMary.save();
+
+ testRoot.setPermission("john", PermissionType.ALL);
+ testRoot.removePermission("mary");
+ testRoot.setPermission("mary", new String[]{PermissionType.READ});
+ testRoot.removePermission(SystemIdentity.ANY);
+ sessMary.save();
+ sessMary.logout();
+
+ //try to remove parent as Mary - must fail
+ sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+ try
+ {
+ testRoot = (NodeImpl)sessMary.getRootNode().getNode("testRoot");
+ testRoot.remove();
+ sessMary.save();
+ fail("There must be AccessDeniedException");
+ }
+ catch (AccessDeniedException e)
+ {
+ //Ok
+ }
+ sessMary.refresh(false);
+
+ // remove subnode as mary
+ subNode = (NodeImpl)sessMary.getRootNode().getNode("testRoot").getNode("subNode");
+ subNode.remove();
+ sessMary.save();
+ assertFalse(sessMary.getRootNode().getNode("testRoot").hasNode("subNode"));
+ sessMary.logout();
+ }
+
+ /**
+ * Remove the property with a user that cannot remove the parent node, and check that an AccessDeniedException occurs
+ * @throws Exception
+ */
+ public void testRemovePropertyWithoutPermissionOnParent() throws Exception
+ {
+ // login as Mary and set permissions on parent node
+ Session sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+ NodeImpl testRoot = (NodeImpl)sessMary.getRootNode().getNode("testRoot");
+
+ testRoot.removePermission("mary");
+ testRoot.setPermission("mary", new String[]{PermissionType.READ});
+ testRoot.removePermission(SystemIdentity.ANY);
+ sessMary.save();
+ sessMary.logout();
+
+ //try to remove parent's property as Mary - must fail
+ sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+ try
+ {
+ testRoot = (NodeImpl)sessMary.getRootNode().getNode("testRoot");
+ testRoot.getProperty("prop").remove();
+ sessMary.save();
+ fail("There must be AccessDeniedException");
+ }
+ catch (AccessDeniedException e)
+ {
+ //Ok
+ }
+ finally
+ {
+ sessMary.logout();
+ }
+ }
+
+ /**
+ * Remove the property with a user that can remove the parent node, and check that the remove operation was successful.
+ * @throws Exception
+ */
+ public void testRemovePropertyWithPermissionOnParent() throws Exception
+ {
+ // login as Mary and set permissions on parent node
+ Session sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+ NodeImpl testRoot = (NodeImpl)sessMary.getRootNode().getNode("testRoot");
+
+ testRoot.removePermission("mary");
+ testRoot.setPermission("mary", PermissionType.ALL);
+ testRoot.removePermission(SystemIdentity.ANY);
+ sessMary.save();
+ sessMary.logout();
+
+ //try to remove parent's property as Mary - must fail
+ sessMary = repository.login(new CredentialsImpl("mary", "exo".toCharArray()));
+
+ testRoot = (NodeImpl)sessMary.getRootNode().getNode("testRoot");
+ testRoot.getProperty("prop").remove();
+ sessMary.save();
+
+ assertFalse(sessMary.getRootNode().getNode("testRoot").hasProperty("prop"));
+ sessMary.logout();
+ }
+
+}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestUserAccess.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestUserAccess.java 2010-12-01 14:59:21 UTC (rev 3584)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestUserAccess.java 2010-12-01 15:00:37 UTC (rev 3585)
@@ -54,9 +54,13 @@
@Override
protected void tearDown() throws Exception
{
- root.refresh(false);
- testRoot.remove();
- root.save();
+ Session sysSession = repository.getSystemSession(session.getWorkspace().getName());
+ if (sysSession.getRootNode().hasNode("testUserAccess"))
+ {
+ Node testRoot = sysSession.getRootNode().getNode("testUserAccess");
+ testRoot.remove();
+ sysSession.save();
+ }
super.tearDown();
}
15 years, 6 months
exo-jcr SVN: r3584 - jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-12-01 09:59:21 -0500 (Wed, 01 Dec 2010)
New Revision: 3584
Modified:
jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
Log:
JCR-1530 : Problem with "Wrong Content-Type header for files over a certain size" was fixed.
Modified: jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2010-12-01 14:17:07 UTC (rev 3583)
+++ jcr/branches/1.12.x/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2010-12-01 14:59:21 UTC (rev 3584)
@@ -18,6 +18,27 @@
*/
package org.exoplatform.services.jcr.webdav.command;
+import java.io.InputStream;
+import java.net.URI;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.xml.transform.stream.StreamSource;
+
import org.exoplatform.common.http.HTTPStatus;
import org.exoplatform.common.util.HierarchicalProperty;
import org.exoplatform.services.jcr.webdav.Range;
@@ -39,27 +60,6 @@
import org.exoplatform.services.rest.ext.provider.XSLTStreamingOutput;
import org.exoplatform.services.rest.impl.header.MediaTypeHelper;
-import java.io.InputStream;
-import java.net.URI;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.transform.stream.StreamSource;
-
/**
* Created by The eXo Platform SAS Author : <a
* href="gavrikvetal(a)gmail.com">Vitaly Guly</a>.
@@ -193,7 +193,7 @@
return Response.status(HTTPStatus.PARTIAL).header(HttpHeaders.CONTENT_LENGTH,
Long.toString(returnedContentLength)).header(ExtHttpHeaders.ACCEPT_RANGES, "bytes").header(
ExtHttpHeaders.CONTENTRANGE, "bytes " + start + "-" + end + "/" + contentLength).entity(
- rangedInputStream).build();
+ rangedInputStream).type(contentType).build();
}
// multipart byte ranges as byte:0-100,80-150,210-300
@@ -210,7 +210,7 @@
new MultipartByterangesEntity(resource, ranges, contentType, contentLength);
return Response.status(HTTPStatus.PARTIAL).header(ExtHttpHeaders.ACCEPT_RANGES, "bytes").entity(
- mByterangesEntity).build();
+ mByterangesEntity).type(ExtHttpHeaders.MULTIPART_BYTERANGES + WebDavConst.BOUNDARY).build();
}
else
{
15 years, 6 months
exo-jcr SVN: r3583 - jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-12-01 09:17:07 -0500 (Wed, 01 Dec 2010)
New Revision: 3583
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
Log:
EXOJCR-1085 : Problem with "Wrong Content-Type header for files over a certain size" was fixed.
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2010-12-01 11:51:18 UTC (rev 3582)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/GetCommand.java 2010-12-01 14:17:07 UTC (rev 3583)
@@ -18,6 +18,27 @@
*/
package org.exoplatform.services.jcr.webdav.command;
+import java.io.InputStream;
+import java.net.URI;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.xml.transform.stream.StreamSource;
+
import org.exoplatform.common.http.HTTPStatus;
import org.exoplatform.common.util.HierarchicalProperty;
import org.exoplatform.services.jcr.webdav.Range;
@@ -39,27 +60,6 @@
import org.exoplatform.services.rest.ext.provider.XSLTStreamingOutput;
import org.exoplatform.services.rest.impl.header.MediaTypeHelper;
-import java.io.InputStream;
-import java.net.URI;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.transform.stream.StreamSource;
-
/**
* Created by The eXo Platform SAS Author : <a
* href="gavrikvetal(a)gmail.com">Vitaly Guly</a>.
@@ -194,7 +194,7 @@
return Response.status(HTTPStatus.PARTIAL).header(HttpHeaders.CONTENT_LENGTH,
Long.toString(returnedContentLength)).header(ExtHttpHeaders.ACCEPT_RANGES, "bytes").header(
ExtHttpHeaders.CONTENTRANGE, "bytes " + start + "-" + end + "/" + contentLength).entity(
- rangedInputStream).build();
+ rangedInputStream).type(contentType).build();
}
// multipart byte ranges as byte:0-100,80-150,210-300
@@ -211,7 +211,7 @@
new MultipartByterangesEntity(resource, ranges, contentType, contentLength);
return Response.status(HTTPStatus.PARTIAL).header(ExtHttpHeaders.ACCEPT_RANGES, "bytes").entity(
- mByterangesEntity).build();
+ mByterangesEntity).type(ExtHttpHeaders.MULTIPART_BYTERANGES + WebDavConst.BOUNDARY).build();
}
else
{
15 years, 6 months
exo-jcr SVN: r3582 - jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2010-12-01 06:51:18 -0500 (Wed, 01 Dec 2010)
New Revision: 3582
Modified:
jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml
Log:
JCR-1525: modified to add source jar file containing docbook files
Modified: jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml 2010-12-01 11:48:27 UTC (rev 3581)
+++ jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml 2010-12-01 11:51:18 UTC (rev 3582)
@@ -122,6 +122,25 @@
</configuration>
</plugin>
</plugins>
+ <resources>
+ <resource>
+ <directory>src/main/</directory>
+ <includes>
+ <include>resources/**/*.gif</include>
+ <include>resources/**/*.jpg</include>
+ <include>resources/**/*.JPG</include>
+ <include>resources/**/*.png</include>
+ <include>resources/**/*.svg</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/</directory>
+ <includes>
+ <include>docbook/en-US/**/*.xml</include>
+ <include>docbook/en-US/**/*.ent</include>
+ </includes>
+ </resource>
+ </resources>
</build>
</project>
15 years, 6 months
exo-jcr SVN: r3581 - jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2010-12-01 06:48:27 -0500 (Wed, 01 Dec 2010)
New Revision: 3581
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml
Log:
EXOJCR-1072: modified to add source jar containing docbook files
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml 2010-12-01 09:41:11 UTC (rev 3580)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml 2010-12-01 11:48:27 UTC (rev 3581)
@@ -122,6 +122,25 @@
</configuration>
</plugin>
</plugins>
+ <resources>
+ <resource>
+ <directory>src/main/</directory>
+ <includes>
+ <include>resources/**/*.gif</include>
+ <include>resources/**/*.jpg</include>
+ <include>resources/**/*.JPG</include>
+ <include>resources/**/*.png</include>
+ <include>resources/**/*.svg</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/</directory>
+ <includes>
+ <include>docbook/en-US/**/*.xml</include>
+ <include>docbook/en-US/**/*.ent</include>
+ </includes>
+ </resource>
+ </resources>
</build>
</project>
15 years, 6 months
exo-jcr SVN: r3580 - in jcr/trunk/exo.jcr.component.webdav/src: test/java/org/exoplatform/services/jcr/webdav/utils and 1 other directory.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2010-12-01 04:41:11 -0500 (Wed, 01 Dec 2010)
New Revision: 3580
Modified:
jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/utils/TestUtils.java
Log:
EXOJCR-1058: modified token in if header parsing
Modified: jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2010-12-01 07:14:26 UTC (rev 3579)
+++ jcr/trunk/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/WebDavServiceImpl.java 2010-12-01 09:41:11 UTC (rev 3580)
@@ -575,6 +575,10 @@
if (lockTokenHeader != null)
{
lockTokenHeader = lockTokenHeader.substring(1, lockTokenHeader.length() - 1);
+ if (lockTokenHeader.contains(WebDavConst.Lock.OPAQUE_LOCK_TOKEN))
+ {
+ lockTokenHeader = lockTokenHeader.split(":")[1];
+ }
}
return new DeleteCommand().delete(session, path(repoPath), lockTokenHeader);
}
@@ -1374,7 +1378,7 @@
{
lockTokenHeader = lockTokenHeader.substring(1, lockTokenHeader.length() - 1);
- if (lockTokenHeader.contains("opaquelocktoken"))
+ if (lockTokenHeader.contains(WebDavConst.Lock.OPAQUE_LOCK_TOKEN))
{
lockTokenHeader = lockTokenHeader.split(":")[1];
}
@@ -1386,6 +1390,10 @@
{
String headerLockToken = ifHeader.substring(ifHeader.indexOf("("));
headerLockToken = headerLockToken.substring(2, headerLockToken.length() - 2);
+ if (headerLockToken.contains(WebDavConst.Lock.OPAQUE_LOCK_TOKEN))
+ {
+ headerLockToken = headerLockToken.split(":")[1];
+ }
lockTokens.add(headerLockToken);
}
Modified: jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/utils/TestUtils.java
===================================================================
--- jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/utils/TestUtils.java 2010-12-01 07:14:26 UTC (rev 3579)
+++ jcr/trunk/exo.jcr.component.webdav/src/test/java/org/exoplatform/services/jcr/webdav/utils/TestUtils.java 2010-12-01 09:41:11 UTC (rev 3580)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.webdav.utils;
import org.exoplatform.common.http.client.HTTPConnection;
+import org.exoplatform.services.jcr.webdav.WebDavConst;
import org.exoplatform.services.jcr.webdav.WebDavConstants.WebDav;
import org.exoplatform.services.jcr.webdav.util.TextUtil;
import org.w3c.dom.Document;
@@ -192,7 +193,7 @@
session.save();
String tok = lock.getLockToken();
// System.out.println("TestUtils.lockNode()" + tok);
- return "<" + tok + ">";
+ return "<" + WebDavConst.Lock.OPAQUE_LOCK_TOKEN + ":" + tok + ">";
}
public static void find(Session session, String queryString) throws InvalidQueryException, RepositoryException
15 years, 6 months