On 22/02/2013 16:13, Andrei Shakirin wrote:
Hi Francesco,

+1 for issue.
Find it also quite dangerous, create() should throw exception if entity already exists, 
"409 Conflict" will be corresponded HTTP error code in this case.

Done, thanks for the tip ;-)

Have a nice WE.

-----Original Message-----
From: Francesco Chicchiriccò [mailto:ilgro...@apache.org]
Sent: Freitag, 22. Februar 2013 14:44
To: dev@syncope.apache.org
Subject: Re: [DISCUSS] REST: create turns into update for some entities

I have opened SYNCOPE-323 for this.

Regards.

On 22/02/2013 12:43, Francesco Chicchiriccò wrote:
Hi all,
I have recently found that some REST create requests are treated as
update.

For example, try to create a new schema on the admin console and
provide a name of another existing schema: you won't get any warning;
only, the existing schema definition will be completely replaced by
the newly inserted entry.

After some investigations, I've found that this happens for external
resources, schema, derived schema and virtual schema.
Such entities have in common the fact that the JPA @Id is non-generated.
The way how saving is handled (via EntityManager#merge()) finally
turns an expected create into an update.

I don't find such behavior as correct, hence I would propose to throw
an exception, in the REST create methods for the entities named above,
in case the key of the entity being created is already present.

Do you see any problem with this?

--
Francesco Chicchiriccò

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

Reply via email to