-
Improvement
-
Resolution: Not an issue
-
Major
-
None
-
5.4.5
-
-
Empty show more show less
-
Basel 48
-
5
When using a info.magnolia.ui.form.field.definition.LinkFieldDefinition with Multivaluetransformer, the data is saved correctly but an exception is thrown when retrieving it
(see the [ in the uuid Caused by: java.lang.IllegalArgumentException: [d14950fc-7fc2-4631-92f1-b6f60a1fe40a at org.apache.jackrabbit.core.id.NodeId.<init>(NodeId.java:129) at org.apache.jackrabbit.core.id.NodeId.valueOf(NodeId.java:52) at org.apache.jackrabbit.core.SessionImpl.getNodeByIdentifier(SessionImpl.java:1098) ... 123 more
OUTCOME
---------------
After some debugging it seems that the issue is not due to the transformer, rather to the lack in our UserManager of a method to save a property as multivalued and User to support such properties.
Regarding the original issue (where the cause was initially thought to be a bug in Multivaluetransformer), a LinkedList object with property values is simply turned into its String representation at PropertyUtil.createValue(Object, ValueFactory) at line #331. This looks like a JCR multivalued property [foo, bar] but it's not (it's a string), hence the failure when retrieving the value.
Whilst it is easy to workaround the limitation of not having a User API allowing to save a multivalued property, an error occurs once one tries to edit/update a User with such a property.
ERROR info.magnolia.cms.security.MgnlUserManager : Could not retrieve user with name: tina javax.jcr.ValueFormatException: property /admin/tina/companies is a multi-valued property, so it's values can only be retrieved as an array at org.apache.jackrabbit.core.PropertyImpl.internalGetValue(PropertyImpl.java:483) at org.apache.jackrabbit.core.PropertyImpl.getValue(PropertyImpl.java:510) at org.apache.jackrabbit.core.PropertyImpl.getString(PropertyImpl.java:520) at info.magnolia.cms.security.MgnlUserManager.newUserInstance(MgnlUserManager.java:576)
this is eventually due to User (in our case implemented by MgnlUser) not supporting multivalued properties.
PROPOSAL
----------------
Besides having User setProperty(User user, String propertyName, String propertyValue), we'd need UserManager should have a User setProperty(User user, String propertyName, String[] multivalued) as well.
User should have a String[] getMultivaluedProperty(String propertyName) method or similar. Implementations of User should be able to store and return both simple String and String[] (multivalued) props.
- mentioned in
-
Page Loading...