Author: dkuleshov
Date: 2011-09-20 10:43:26 -0400 (Tue, 20 Sep 2011)
New Revision: 4932
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/AbstractNodeTypeRepository.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeRepository.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/nodetype/TestNodeTypeRegistration.java
Log:
EXOJCR-1516: fixed unregistration of node type, now it is also removed from persister
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/AbstractNodeTypeRepository.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/AbstractNodeTypeRepository.java 2011-09-20
10:52:45 UTC (rev 4931)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/AbstractNodeTypeRepository.java 2011-09-20
14:43:26 UTC (rev 4932)
@@ -155,6 +155,15 @@
}
/**
+ * {@inheritDoc}
+ */
+ public void unregisterNodeType(NodeTypeData nodeType) throws RepositoryException
+ {
+ nodeTypeDataPersister.removeNodeType(nodeType);
+ removeNodeType(nodeType);
+ }
+
+ /**
* @see org.picocontainer.Startable#start()
*/
public void start()
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java 2011-09-20
10:52:45 UTC (rev 4931)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java 2011-09-20
14:43:26 UTC (rev 4932)
@@ -884,7 +884,7 @@
throw new RepositoryException(message);
}
- this.nodeTypeRepository.removeNodeType(nodeType);
+ this.nodeTypeRepository.unregisterNodeType(nodeType);
}
/**
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeRepository.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeRepository.java 2011-09-20
10:52:45 UTC (rev 4931)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeRepository.java 2011-09-20
14:43:26 UTC (rev 4932)
@@ -124,6 +124,13 @@
void removeNodeType(NodeTypeData nodeType);
/**
+ * @param nodeTypeName
+ * @param nodeType
+ * @exception RepositoryException
+ */
+ void unregisterNodeType(NodeTypeData nodeType) throws RepositoryException;
+
+ /**
* Write node types to stream
*
* @param os output stream
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/nodetype/TestNodeTypeRegistration.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/nodetype/TestNodeTypeRegistration.java 2011-09-20
10:52:45 UTC (rev 4931)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/nodetype/TestNodeTypeRegistration.java 2011-09-20
14:43:26 UTC (rev 4932)
@@ -23,6 +23,10 @@
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeValue;
import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionValue;
+import org.exoplatform.services.jcr.dataflow.DataManager;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import
org.exoplatform.services.jcr.impl.core.nodetype.registration.JCRNodeTypeDataPersister;
+import
org.exoplatform.services.jcr.impl.core.nodetype.registration.NodeTypeDataPersister;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -38,6 +42,7 @@
import javax.jcr.RepositoryException;
import javax.jcr.ValueFormatException;
import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
/**
* Created by The eXo Platform SAS.
@@ -1490,4 +1495,44 @@
l1.addNode("l3", "myNodeTypes");
session.save();
}
+
+ public void testNodeTypePersistedUnregistration() throws Exception
+ {
+ NodeTypeValue testNtv = new NodeTypeValue();
+ testNtv.setName("testingNodeType");
+
+ List<NodeTypeValue> list = new ArrayList<NodeTypeValue>();
+ list.add(testNtv);
+
+ InternalQName testingNodeTypeName = new InternalQName("",
"testingNodeType");
+
+ NodeTypeDataPersister nodeTypeDataPersister =
+ new
JCRNodeTypeDataPersister((DataManager)session.getTransientNodesManager().getTransactManager(),
true);
+ nodeTypeDataPersister.start();
+
+
+ nodeTypeManager.registerNodeTypes(list, ExtendedNodeTypeManager.FAIL_IF_EXISTS);
+ assertNotNull(nodeTypeDataPersister.getNodeType(testingNodeTypeName));
+ assertNotNull(nodeTypeManager.getNodeType("testingNodeType"));
+
+ nodeTypeManager.unregisterNodeType("testingNodeType");
+ try
+ {
+ nodeTypeManager.getNodeType("testingNodeType");
+ fail();
+ }
+ catch (NoSuchNodeTypeException e)
+ {
+ // ok
+ }
+ try
+ {
+ nodeTypeDataPersister.getNodeType(testingNodeTypeName);
+ fail();
+ }
+ catch (RepositoryException e)
+ {
+ // ok
+ }
+ }
}
Show replies by date