On 19/03/2017 20:49, vladz wrote:
While registering the new user, I'd like to be able to save additional data.
In the default installation, there was a 'plainAttrs' schema entry for
'email', which I replaced by lastname and firstname, both defined as String
types, not required, no validation, no integrity checks.

When I try to add user with these values set as "plainAttrs": [], the user
saves just fine.  When I add data there, as:

   "plainAttrs": [
       {
           "schema":"firstname",
           "values":["Test"]
       },
       {
           "schema":"lastname",
           "values":["Last"]
       }
   ]

it fails to save, the following error found in core-persistence.log:

14:16:39.348 WARN
org.apache.syncope.core.persistence.jpa.validation.entity.EntityValidationListener
- Bean validation errors found:
[ConstraintViolationImpl{rootBean=JPAUser[null], propertyPath='plainAttrs',
message='InvalidPlainAttr;lastname not allowed for this instance',
leafBean=JPAUser[null], value=JPAUser[null]}]

and core-rest.log contains more details:

15:35:35.729 ERROR
org.apache.syncope.core.rest.cxf.RestServiceExceptionMapper - Exception
thrown
org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException:
JPAUser [InvalidPlainAttr]
        at
org.apache.syncope.core.persistence.jpa.validation.entity.EntityValidationListener.validate(EntityValidationListener.java:71)
~[syncope-core-persistence-jpa-2.0.2.jar:2.0.2]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[?:1.8.0_66]
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[?:1.8.0_66]
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[?:1.8.0_66]
        at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_66]
        at
org.apache.openjpa.event.BeanLifecycleCallbacks.makeCallback(BeanLifecycleCallbacks.java:85)
~[openjpa-kernel-2.4.2.jar:2.4.2]


Then configuration for Plain Attrs looks like this:

(select id, `mandatoryCondition`, multivalue, readonly, type,
uniqueConstraint, validatorClass from PlainSchema where id like '%name')

id      mandatoryCondition      multivalue      readonly        type    
uniqueConstraint
validatorClass
firstname       false   0       0       String  0       NULL
lastname        false   0       0       String  0       NULL

Why am I not able to save these 2 attributes during self-registration?

Hi,
short answer: from Admin Console, go to Configuration > Types > AnyTypesClasses, edit 'BaseUser' and add 'firstname' and 'lastname' there.

Long answer: invest some time in understanding how the type management works in Syncope:
https://syncope.apache.org/docs/reference-guide.html#type-management

HTH
Regards.

--
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Member at The Apache Software Foundation
Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
http://home.apache.org/~ilgrosso/

Reply via email to