Author: sergiykarpenko
Date: 2010-08-17 02:50:57 -0400 (Tue, 17 Aug 2010)
New Revision: 2919
Added:
jcr/branches/1.12.x/patch/
jcr/branches/1.12.x/patch/EXOJCR-898/
jcr/branches/1.12.x/patch/EXOJCR-898/EXOJCR-898.patch
Log:
EXOJCR-898: patch proposed
Added: jcr/branches/1.12.x/patch/EXOJCR-898/EXOJCR-898.patch
===================================================================
--- jcr/branches/1.12.x/patch/EXOJCR-898/EXOJCR-898.patch (rev 0)
+++ jcr/branches/1.12.x/patch/EXOJCR-898/EXOJCR-898.patch 2010-08-17 06:50:57 UTC (rev
2919)
@@ -0,0 +1,240 @@
+Index: src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
+===================================================================
+---
src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java (revision
2918)
++++
src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java (working
copy)
+@@ -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()));
+Index:
src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
+===================================================================
+---
src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java (revision
2918)
++++
src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java (working
copy)
+@@ -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()));
+Index:
src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
+===================================================================
+---
src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java (revision
2918)
++++
src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java (working
copy)
+@@ -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;
+ }
+
+Index:
src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java
+===================================================================
+---
src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java (revision
0)
++++
src/test/java/org/exoplatform/services/jcr/impl/access/TestRemoveNodeTypeNode.java (revision
0)
+@@ -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) {
++ }
++ }
++}