Author: sergiykarpenko
Date: 2010-08-16 11:05:10 -0400 (Mon, 16 Aug 2010)
New Revision: 2918
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
Log:
EXOJCR-898: Apply fixes for Incorrect jcr:system node's permission initialization in
ScratchWorkspaceInitializer
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2010-08-16
08:29:40 UTC (rev 2917)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2010-08-16
15:05:10 UTC (rev 2918)
@@ -33,6 +33,7 @@
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
@@ -42,6 +43,7 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.dataflow.ValueDataConvertor;
import org.exoplatform.services.jcr.impl.util.NodeDataReader;
+import org.exoplatform.services.jcr.util.IdGenerator;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -343,16 +345,16 @@
private void initStorage(NodeData nsSystem, boolean addACL) throws
RepositoryException
{
PlainChangesLog changesLog = new PlainChangesLogImpl();
- TransientNodeData exoNamespaces;
+ TransientNodeData exoNamespaces =
+ new TransientNodeData(QPath.makeChildPath(nsSystem.getQPath(),
Constants.EXO_NAMESPACES), IdGenerator
+ .generate(), -1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
nsSystem.getIdentifier(), nsSystem
+ .getACL());
if (addACL)
{
- AccessControlList acl = new AccessControlList();
+ AccessControlList acl = exoNamespaces.getACL();
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE,
Constants.EXO_PRIVILEGEABLE};
- exoNamespaces =
- TransientNodeData.createNodeData(nsSystem, Constants.EXO_NAMESPACES,
Constants.NT_UNSTRUCTURED, mixins);
-
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(exoNamespaces,
Constants.JCR_PRIMARYTYPE, PropertyType.NAME,
false, new TransientValueData(exoNamespaces.getPrimaryTypeName()));
@@ -389,9 +391,6 @@
}
else
{
- exoNamespaces =
- TransientNodeData.createNodeData(nsSystem, Constants.EXO_NAMESPACES,
Constants.NT_UNSTRUCTURED);
-
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(exoNamespaces,
Constants.JCR_PRIMARYTYPE, PropertyType.NAME,
false, new TransientValueData(exoNamespaces.getPrimaryTypeName()));
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java 2010-08-16
08:29:40 UTC (rev 2917)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java 2010-08-16
15:05:10 UTC (rev 2918)
@@ -76,8 +76,6 @@
private final String accessControlType;
- // private final NamespaceDataPersister nsPersister;
-
private final String rootPermissions;
private final InternalQName rootNodeType;
@@ -139,9 +137,6 @@
: Constants.NT_UNSTRUCTURED;
this.dataManager = dataManager;
- // this.nsPersister = nsPersister;
- // this.ntRegistry = ntRegistry;
-
}
public NodeData initWorkspace() throws RepositoryException
@@ -269,17 +264,16 @@
boolean addACL = !accessControlType.equals(AccessControlPolicy.DISABLE);
PlainChangesLog changesLog = new PlainChangesLogImpl();
- TransientNodeData jcrSystem;
+ TransientNodeData jcrSystem =
+ new TransientNodeData(QPath.makeChildPath(root.getQPath(),
Constants.JCR_SYSTEM), Constants.SYSTEM_UUID, -1,
+ Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, root.getIdentifier(),
root.getACL());
+
if (addACL)
{
- AccessControlList acl = new AccessControlList();
+ AccessControlList acl = jcrSystem.getACL();
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE,
Constants.EXO_PRIVILEGEABLE};
- jcrSystem =
- TransientNodeData.createNodeData(root, Constants.JCR_SYSTEM,
Constants.NT_UNSTRUCTURED, mixins,
- Constants.SYSTEM_UUID);
-
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(jcrSystem,
Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
new TransientValueData(jcrSystem.getPrimaryTypeName()));
@@ -316,10 +310,6 @@
}
else
{
- jcrSystem =
- TransientNodeData.createNodeData(root, Constants.JCR_SYSTEM,
Constants.NT_UNSTRUCTURED,
- Constants.SYSTEM_UUID);
-
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(jcrSystem,
Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
new TransientValueData(jcrSystem.getPrimaryTypeName()));
@@ -340,15 +330,6 @@
dataManager.save(new TransactionChangesLog(changesLog));
- //nsPersister.initStorage(jcrSystem, addACL,
NamespaceRegistryImpl.DEF_NAMESPACES);
- // nodeTypes save
- // changesLog = new PlainChangesLogImpl();
- // changesLog.addAll(ntPersister.initNodetypesRoot(jcrSystem,
- // addACL).getAllStates());
- //
changesLog.addAll(ntPersister.initStorage(nodeTypeDataManager.getAllNodeTypes()).getAllStates());
- // ntPersister.saveChanges(changesLog);
-
- // nodeTypeDataManager.initDefaultNodeTypes(addACL);
return jcrSystem;
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2010-08-16
08:29:40 UTC (rev 2917)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2010-08-16
15:05:10 UTC (rev 2918)
@@ -38,6 +38,7 @@
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
@@ -147,19 +148,17 @@
public NodeData initNodetypesRoot(NodeData nsSystem, boolean addACL) throws
RepositoryException
{
PlainChangesLog changesLog = new PlainChangesLogImpl();
- TransientNodeData jcrNodetypes;
-
+ TransientNodeData jcrNodetypes =
+ new TransientNodeData(QPath.makeChildPath(nsSystem.getQPath(),
Constants.JCR_NODETYPES),
+ Constants.NODETYPESROOT_UUID, -1, Constants.NT_UNSTRUCTURED, new
InternalQName[0], 0, nsSystem
+ .getIdentifier(), nsSystem.getACL());
long start = System.currentTimeMillis();
if (addACL)
{
- AccessControlList acl = new AccessControlList();
+ AccessControlList acl = jcrNodetypes.getACL();
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE,
Constants.EXO_PRIVILEGEABLE};
- jcrNodetypes =
- TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES,
Constants.NT_UNSTRUCTURED, mixins,
- Constants.NODETYPESROOT_UUID);
-
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(jcrNodetypes,
Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
new TransientValueData(jcrNodetypes.getPrimaryTypeName()));
@@ -196,10 +195,6 @@
}
else
{
- jcrNodetypes =
- TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES,
Constants.NT_UNSTRUCTURED,
- Constants.NODETYPESROOT_UUID);
-
TransientPropertyData primaryType =
TransientPropertyData.createPropertyData(jcrNodetypes,
Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
new TransientValueData(jcrNodetypes.getPrimaryTypeName()));
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java
(rev 0)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java 2010-08-16
15:05:10 UTC (rev 2918)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.access;
+
+import org.exoplatform.services.jcr.BaseStandaloneTest;
+import org.exoplatform.services.jcr.core.CredentialsImpl;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+
+/**
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy
Bazko</a>
+ * @version $Id: TestRemoveSysteNode.java 111 2010-11-11 11:11:11Z tolusha $
+ *
+ */
+public class TestRemoveNodeTypeNode extends BaseStandaloneTest {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getRepositoryName() {
+ return null;
+ }
+
+ public void testRemove() throws Exception {
+ Repository repository = repositoryService.getRepository("db1tck");
+ Credentials credentials = new CredentialsImpl("demo",
"exo".toCharArray());
+ Session session = repository.login(credentials, "ws");
+
+ Node node = session.getRootNode()
+ .getNode("jcr:system")
+ .getNode("jcr:nodetypes")
+ .getNode("nt:base");
+ try {
+ node.remove();
+ session.save();
+
+ fail("Exception should be thrown.");
+ } catch (AccessDeniedException e) {
+ }
+ }
+}