jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Soto <lexs...@gmail.com>
Subject Unable to set mixin-defined property on nt:folder node
Date Mon, 19 Dec 2011 20:57:07 GMT
Hi:

I have defined a mixin data type.  I can't seem to be able to set a value for a property defined
in this mixin.  My nodes have primary type "nt:folder".  See sample code below: 

<raw>
	session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
	try {
		NamespaceRegistry registry = session.getWorkspace().getNamespaceRegistry();

		List<String> list = Arrays.asList(registry.getPrefixes());
		if (!list.contains("my")) {
			registry.registerNamespace("my", "http://test.com/friend");
		}

		NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();

		NodeTypeTemplate nodeType = manager.createNodeTypeTemplate();
		nodeType.setMixin(true);
		nodeType.setName("my:friendly");
		nodeType.setQueryable(true);
		nodeType.setDeclaredSuperTypeNames(new String[]{"mix:referenceable"});

		PropertyDefinitionTemplate propertyDef = manager.createPropertyDefinitionTemplate();
		propertyDef.setName("my:IsFriendOf");
		propertyDef.setMultiple(true);
		propertyDef.setRequiredType(PropertyType.REFERENCE);
		propertyDef.setOnParentVersion(OnParentVersionAction.COPY);
		propertyDef.setProtected(false);

		nodeType.getPropertyDefinitionTemplates().add(propertyDef);
		manager.registerNodeType(nodeType, true);

		final Node rootNode = session.getRootNode();
		Node joe = null;
		if (rootNode.hasNode("joe")) {
			joe = rootNode.getNode("joe");
		} else {
			joe = rootNode.addNode("joe", "nt:folder");
			joe.addMixin("my:friendly");
		}

		Node jane = null;
		if (rootNode.hasNode("jane")) {
			jane = rootNode.getNode("jane");
		} else {
			jane = rootNode.addNode("jane", "nt:folder");
			jane.addMixin("my:friendly");
		}

		joe.setProperty("my:IsFriendOf", jane);
		session.save();
	} finally {
		session.logout();
	}
</raw>

When I run the above code I get this exception:

<raw>
javax.jcr.nodetype.ConstraintViolationException: no matching property definition found for
{http://test.com/friend}IsFriendOf
	at org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicablePropertyDef(EffectiveNodeType.java:782)
	at org.apache.jackrabbit.core.NodeImpl.getApplicablePropertyDefinition(NodeImpl.java:836)
	at org.apache.jackrabbit.core.NodeImpl.getOrCreateProperty(NodeImpl.java:399)
	at org.apache.jackrabbit.core.NodeImpl$SetPropertyOperation.perform(NodeImpl.java:2013)
	at org.apache.jackrabbit.core.NodeImpl$SetPropertyOperation.perform(NodeImpl.java:1960)
	at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:216)
	at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:1882)
	at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:1939)
	at com.cht.member.MemberAuthorizationServiceBean.multiValueRefOnFolder(MemberAuthorizationServiceBean.java:132)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.sun.ejb.containers.interceptors.BeanCallbackInterceptor.intercept(InterceptorManager.java:1009)
	at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:65)
	at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:113)
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCallback(SystemInterceptorProxy.java:138)
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.init(SystemInterceptorProxy.java:120)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:964)
	at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:65)
	at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:393)
	at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:376)
	at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:526)
	... 26 more
</raw>

My environment is:

1- GlassFish Server Open Source Edition 3.1.1 (build 12)
2- Repository is JackRabbit 2.3.4

Any help?

Thanks
 

Mime
  • Unnamed multipart/alternative (inline, 7-Bit, 0 bytes)
View raw message