Bug 785052 - REST Interface - Topics can't be created that have relationships
Summary: REST Interface - Topics can't be created that have relationships
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: PressGang CCMS
Classification: Community
Component: REST-API
Version: 1.x
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Matthew Casperson
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-01-27 04:24 UTC by Lee Newson
Modified: 2014-08-04 22:26 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-01-31 01:25:35 UTC


Attachments (Terms of Use)
Basic java class to demonstrate the problem. (2.71 KB, text/x-java)
2012-01-27 04:24 UTC, Lee Newson
no flags Details

Description Lee Newson 2012-01-27 04:24:08 UTC
Created attachment 557786 [details]
Basic java class to demonstrate the problem.

There appears to be a bug in the create functions for topics. It has to do with attempting to persist relationships before the new topic is persisted and given a database ID.

The problem lies in the createOrUdpateEntity -> syncDBEntityWithRESTEntity functions for topics. It calls the createOrUpdateEntity which in turn ends up calling the syncDBEntityWithRESTEntity function. After the function completes the topic entity is persisted and given an ID. Before that though, in the syncDBEntityWithRESTEntity function it attempts to pull an ID from the passed REST entity object and create relationships using that ID. However in most new topic instances an ID won't exist and needs to be created when persisting the data and therefore throws an exception.

I've attached a Test case to further demonstrate the problem.

Comment 1 Matthew Casperson 2012-01-31 01:02:10 UTC
Fixed in 201201131-1100

The relationship was being added from the established topic to the new one, and since the new one was not persisted there was no ID, which was causing the exception.

Now the relationship is created backwards from the new topic, which means that by the topic is persisted before the collections are processed, and therefor the ID is present.


Note You need to log in before you can comment on or make changes to this bug.