[exo-jcr-commits] exo-jcr SVN: r5324 - in jcr/trunk: exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/registry and 3 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Dec 13 11:18:26 EST 2011
Author: tolusha
Date: 2011-12-13 11:18:25 -0500 (Tue, 13 Dec 2011)
New Revision: 5324
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RegistryService.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/registry/RegistryTest.java
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/test/nodetypes-ext-test.xml
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/concepts/jcr-registry-service.xml
Log:
EXOJCR-1673: allow to add additional mixins to nodes of RegistryService
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RegistryService.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RegistryService.java 2011-12-12 15:20:42 UTC (rev 5323)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RegistryService.java 2011-12-13 16:18:25 UTC (rev 5324)
@@ -110,6 +110,8 @@
protected final RepositoryService repositoryService;
+ protected final String[] mixinNames;
+
// TODO temporary flag to have start() run once
protected boolean started = false;
@@ -128,10 +130,25 @@
this.repositoryService = repositoryService;
this.regWorkspaces = new HashMap<String, String>();
if (params == null)
+ {
throw new RepositoryConfigurationException("Init parameters expected");
+ }
+
this.props = params.getPropertiesParam("locations");
if (props == null)
+ {
throw new RepositoryConfigurationException("Property parameters 'locations' expected");
+ }
+
+ ValueParam mixinValue = params.getValueParam("mixin-names");
+ if (mixinValue != null)
+ {
+ this.mixinNames = mixinValue.getValue().split(",");
+ }
+ else
+ {
+ this.mixinNames = new String[0];
+ }
}
/**
@@ -405,69 +422,124 @@
ManageableRepository rep = repositoryService.getRepository(repName);
final Session sysSession = rep.getSystemSession(regWorkspaces.get(repName));
- if (sysSession.getRootNode().hasNode(EXO_REGISTRY) && replace)
- sysSession.getRootNode().getNode(EXO_REGISTRY).remove();
-
- if (!sysSession.getRootNode().hasNode(EXO_REGISTRY))
+ try
{
- Node rootNode = sysSession.getRootNode().addNode(EXO_REGISTRY, EXO_REGISTRY_NT);
- rootNode.addNode(EXO_SERVICES, EXO_REGISTRYGROUP_NT);
- rootNode.addNode(EXO_APPLICATIONS, EXO_REGISTRYGROUP_NT);
- rootNode.addNode(EXO_USERS, EXO_REGISTRYGROUP_NT);
- rootNode.addNode(EXO_GROUPS, EXO_REGISTRYGROUP_NT);
+ if (sysSession.getRootNode().hasNode(EXO_REGISTRY) && replace)
+ {
+ sysSession.getRootNode().getNode(EXO_REGISTRY).remove();
+ }
- Set<String> appNames = appConfigurations.keySet();
- final String fullPath = "/" + EXO_REGISTRY + "/" + entryLocation;
- for (String appName : appNames)
+ Node rootNode;
+ Node servicesNode;
+ Node applicationsNode;
+ Node usersNode;
+ Node groupsNode;
+
+ if (!sysSession.getRootNode().hasNode(EXO_REGISTRY))
{
- final String xml = appConfigurations.get(appName);
- try
+ rootNode = sysSession.getRootNode().addNode(EXO_REGISTRY, EXO_REGISTRY_NT);
+ servicesNode = rootNode.addNode(EXO_SERVICES, EXO_REGISTRYGROUP_NT);
+ applicationsNode = rootNode.addNode(EXO_APPLICATIONS, EXO_REGISTRYGROUP_NT);
+ usersNode = rootNode.addNode(EXO_USERS, EXO_REGISTRYGROUP_NT);
+ groupsNode = rootNode.addNode(EXO_GROUPS, EXO_REGISTRYGROUP_NT);
+
+ Set<String> appNames = appConfigurations.keySet();
+ final String fullPath = "/" + EXO_REGISTRY + "/" + entryLocation;
+ for (String appName : appNames)
{
- SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
+ final String xml = appConfigurations.get(appName);
+ try
{
- public Void run() throws Exception
+ SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
{
- DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes());
- Document document = builder.parse(stream);
- RegistryEntry entry = new RegistryEntry(document);
- sysSession.importXML(fullPath, entry.getAsInputStream(), IMPORT_UUID_CREATE_NEW);
- return null;
- }
- });
- }
- catch (PrivilegedActionException pae)
- {
- Throwable cause = pae.getCause();
- if (cause instanceof ParserConfigurationException)
- {
- log.error(cause.getLocalizedMessage(), cause);
+ public Void run() throws Exception
+ {
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes());
+ Document document = builder.parse(stream);
+ RegistryEntry entry = new RegistryEntry(document);
+ sysSession.importXML(fullPath, entry.getAsInputStream(), IMPORT_UUID_CREATE_NEW);
+ return null;
+ }
+ });
}
- else if (cause instanceof IOException)
+ catch (PrivilegedActionException pae)
{
- log.error(cause.getLocalizedMessage(), cause);
+ Throwable cause = pae.getCause();
+ if (cause instanceof ParserConfigurationException)
+ {
+ log.error(cause.getLocalizedMessage(), cause);
+ }
+ else if (cause instanceof IOException)
+ {
+ log.error(cause.getLocalizedMessage(), cause);
+ }
+ else if (cause instanceof SAXException)
+ {
+ log.error(cause.getLocalizedMessage(), cause);
+ }
+ else if (cause instanceof TransformerException)
+ {
+ log.error(cause.getLocalizedMessage(), cause);
+ }
+ else if (cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
}
- else if (cause instanceof SAXException)
- {
- log.error(cause.getLocalizedMessage(), cause);
- }
- else if (cause instanceof TransformerException)
- {
- log.error(cause.getLocalizedMessage(), cause);
- }
- else if (cause instanceof RuntimeException)
- {
- throw (RuntimeException)cause;
- }
- else
- {
- throw new RuntimeException(cause);
- }
}
+ sysSession.save();
}
- sysSession.save();
+ else
+ {
+ rootNode = sysSession.getRootNode().getNode(EXO_REGISTRY);
+ servicesNode = rootNode.getNode(EXO_SERVICES);
+ applicationsNode = rootNode.getNode(EXO_APPLICATIONS);
+ usersNode = rootNode.getNode(EXO_USERS);
+ groupsNode = rootNode.getNode(EXO_GROUPS);
+ }
+
+ for (String mixin : mixinNames)
+ {
+ if (rootNode.canAddMixin(mixin))
+ {
+ rootNode.addMixin(mixin);
+ }
+
+ if (servicesNode.canAddMixin(mixin))
+ {
+ servicesNode.addMixin(mixin);
+ }
+
+ if (applicationsNode.canAddMixin(mixin))
+ {
+ applicationsNode.addMixin(mixin);
+ }
+
+ if (usersNode.canAddMixin(mixin))
+ {
+ usersNode.addMixin(mixin);
+ }
+
+ if (groupsNode.canAddMixin(mixin))
+ {
+ groupsNode.addMixin(mixin);
+ }
+ }
+
+ if (sysSession.hasPendingChanges())
+ {
+ sysSession.save();
+ }
}
- sysSession.logout();
+ finally
+ {
+ sysSession.logout();
+ }
}
}
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/registry/RegistryTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/registry/RegistryTest.java 2011-12-12 15:20:42 UTC (rev 5323)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/registry/RegistryTest.java 2011-12-13 16:18:25 UTC (rev 5324)
@@ -27,6 +27,7 @@
import java.io.ByteArrayInputStream;
+import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
import javax.xml.parsers.DocumentBuilder;
@@ -69,14 +70,28 @@
RegistryService regService = (RegistryService)container.getComponentInstanceOfType(RegistryService.class);
assertNotNull(regService);
- assertNotNull(regService.getRegistry(sessionProviderService.getSessionProvider(null)).getNode());
- assertTrue(regService.getRegistry(sessionProviderService.getSessionProvider(null)).getNode().hasNode(
- RegistryService.EXO_SERVICES));
- assertTrue(regService.getRegistry(sessionProviderService.getSessionProvider(null)).getNode().hasNode(
- RegistryService.EXO_APPLICATIONS));
- assertTrue(regService.getRegistry(sessionProviderService.getSessionProvider(null)).getNode().hasNode(
- RegistryService.EXO_USERS));
+ Node regNodes = regService.getRegistry(sessionProviderService.getSessionProvider(null)).getNode();
+ assertNotNull(regNodes);
+ assertTrue(regNodes.hasNode(RegistryService.EXO_SERVICES));
+ assertTrue(regNodes.hasNode(RegistryService.EXO_APPLICATIONS));
+ assertTrue(regNodes.hasNode(RegistryService.EXO_USERS));
+
+ assertTrue(regNodes.getNode(RegistryService.EXO_REGISTRY).isNodeType("exo:testFirstHideable")
+ && regNodes.getNode(RegistryService.EXO_REGISTRY).isNodeType("exo:testSecondHideable"));
+
+ assertTrue(regNodes.getNode(RegistryService.EXO_USERS).isNodeType("exo:testFirstHideable")
+ && regNodes.getNode(RegistryService.EXO_USERS).isNodeType("exo:testSecondHideable"));
+
+ assertTrue(regNodes.getNode(RegistryService.EXO_GROUPS).isNodeType("exo:testFirstHideable")
+ && regNodes.getNode(RegistryService.EXO_GROUPS).isNodeType("exo:testSecondHideable"));
+
+ assertTrue(regNodes.getNode(RegistryService.EXO_SERVICES).isNodeType("exo:testFirstHideable")
+ && regNodes.getNode(RegistryService.EXO_SERVICES).isNodeType("exo:testSecondHideable"));
+
+ assertTrue(regNodes.getNode(RegistryService.EXO_APPLICATIONS).isNodeType("exo:testFirstHideable")
+ && regNodes.getNode(RegistryService.EXO_APPLICATIONS).isNodeType("exo:testSecondHideable"));
+
session.getWorkspace().getNodeTypeManager().getNodeType("exo:registry");
session.getWorkspace().getNodeTypeManager().getNodeType("exo:registryEntry");
session.getWorkspace().getNodeTypeManager().getNodeType("exo:registryGroup");
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2011-12-12 15:20:42 UTC (rev 5323)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration.xml 2011-12-13 16:18:25 UTC (rev 5324)
@@ -181,6 +181,10 @@
</component-plugin>
</component-plugins>
<init-params>
+ <value-param>
+ <name>mixin-names</name>
+ <value>exo:testFirstHideable,exo:testSecondHideable</value>
+ </value-param>
<properties-param>
<name>locations</name>
<property name="db1" value="ws2" />
Modified: jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/test/nodetypes-ext-test.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/test/nodetypes-ext-test.xml 2011-12-12 15:20:42 UTC (rev 5323)
+++ jcr/trunk/exo.jcr.component.ext/src/test/resources/conf/test/nodetypes-ext-test.xml 2011-12-13 16:18:25 UTC (rev 5324)
@@ -45,5 +45,10 @@
</childNodeDefinition>
</childNodeDefinitions>
</nodeType>
-
+
+ <nodeType name="exo:testFirstHideable" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
+ </nodeType>
+
+ <nodeType name="exo:testSecondHideable" isMixin="true" hasOrderableChildNodes="false" primaryItemName="">
+ </nodeType>
</nodeTypes>
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/concepts/jcr-registry-service.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/concepts/jcr-registry-service.xml 2011-12-12 15:20:42 UTC (rev 5323)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/concepts/jcr-registry-service.xml 2011-12-13 16:18:25 UTC (rev 5324)
@@ -122,18 +122,26 @@
<section>
<title>Configuration</title>
- <para>RegistryService has only one optional properties parameter <emphasis
- role="bold">locations</emphasis>. It is used to mention where exo:registry
- is placed for each repository. The name of each property is interpreted as
- a repository name and its value as a workspace name (a system workspace by
- default).</para>
+ <para>RegistryService has two optional params: value parameter <emphasis
+ role="bold">mixin-names</emphasis> and properties parameter <emphasis
+ role="bold">locations</emphasis>. The mixin-names is used for adding
+ additional mixins to nodes exo:registry, exo:applications, exo:services,
+ exo:users and exo:groups of RegistryService. This allows the top level
+ applications to manage these nodes in special way. Locations is used to
+ mention where exo:registry is placed for each repository. The name of each
+ property is interpreted as a repository name and its value as a workspace
+ name (a system workspace by default).</para>
<programlisting language="xml"><component>
<type>org.exoplatform.services.jcr.ext.registry.RegistryService</type>
<init-params>
- <properties-param>
+ <value-param>
+ <name>mixin-names</name>
+ <value>exo:hideable</value>
+ </value-param>
+ <properties-param>
<name>locations</name>
- <property name="db1" value="ws2"/>
+ <property name="db1" value="ws2"/>
</properties-param>
</init-params>
</component></programlisting>
More information about the exo-jcr-commits
mailing list