Bug 785052

Summary: REST Interface - Topics can't be created that have relationships
Product: [Community] PressGang CCMS Reporter: Lee Newson <lnewson>
Component: REST-APIAssignee: Matthew Casperson <mcaspers>
Status: CLOSED WORKSFORME QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 1.xCC: cbredesen, topic-tool-list
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-01-31 01:25:35 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
Basic java class to demonstrate the problem. none

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.