On 31/05/2012 14:03, Bob Lannoy wrote:
> Hi,
>
> I was trying to create an attribute (pwreset boolean attribute) for a
> user when it's not present but I can't do it.
> I guess the assumption is that the user always has the necessary
> attributes on creation because there is no
> userMod.addAttributeToBeAdded?
>
> What I tried is this:
>         UAttr attribute = user.getAttribute("pwreset");
>         if (attribute == null){
>             UserMod userMod=new UserMod();
>             AttributeMod attributeMod=new AttributeMod();
>             attributeMod.setSchema("pwreset");
>             attributeMod.addValueToBeAdded("true");
>             userMod.addAttributeToBeUpdated(attributeMod);
>             userDataBinder.update(user, userMod);
>         }
>
> This gives me JPA errors:
> InvalidStateException: Encountered unmanaged object
> "org.apache.syncope.core.persistence.beans.user.UAttrValue@4f4db965"
> in life cycle state  unmanaged while cascading persistence via field
> "org.apache.syncope.core.persistence.beans.user.UAttr.values<element:class
> org.apache.syncope.core.persistence.beans.user.UAttrValue>" during
> flush.  However, this field does not allow cascade persist. You cannot
> flush unmanaged objects or graphs that have persistent associations to
> unmanaged objects.

Hi Bob,
I'm still trying to find enough time to give you a proper response about
workflow: in the meanwhile, I'd suggest to try to avoid to go so
low-level in you customization (playing with userDataBinder is quite
difficult and not documented at all).

When customizing or extending REST controller methods, always try to
resolve calling one of existing controller methods before or after your
actual code.

Regards.

-- 
Francesco Chicchiriccò

ASF Member, Apache Cocoon PMC and Apache Syncope PPMC Member
http://people.apache.org/~ilgrosso/

Reply via email to