It's all about the answers!

Ask a question

Problem in retrieving data of type IContent

Vibha Sinha (1643610) | asked Jul 18 '08, 7:26 a.m.

I have extended the Jazz repository using my own ecore. One of the data items in turn contains an attribute of type IContent. I have exposed get/set on this attribute using ITeamModelledService.

I set the IContent data as follows -

IContentService contentService = getService(IContentService.class);

byte[] notesTextBytes;

notesTextBytes = notes.getBytes(CONTENT_ENCODING_UTF8);
ByteArrayInputStream inputStream = new ByteArrayInputStream(
CONTENT_ENCODING_UTF8, inputStream, notesTextBytes.length);

I am able to retrive this data too. However, when I restart my server, I am no longer able to get this data.

It throws the exception - Content not found

Would really appreciate help

- Vibha

5 answers

permanent link
Martha (Ruby) Andrews (3.0k44251) | answered Jul 18 '08, 4:06 p.m.
Hi Vibha,

Are you associating the IContent reference with an Item and saving the Item? I see this in the javadoc for the IContentManager:

Uploaded content must first be claimed before it can be retrieved from the server. Claiming of uploaded content is
done by embedding the reference to the content {@link IContent} within an item
and then saving the item to the server with this new content reference.

Jazz Team Build Component

permanent link
Vibha Sinha (1643610) | answered Jul 20 '08, 3:38 p.m.
Hello Martha,

Yes I am storing the content and then saving the reference. Code as follows:

final IContent notesContent = parseToIContent(notes);

IRepositoryItemService repositoryItemService = (IRepositoryItemService) getService(IRepositoryItemService.class);
BusinessProcess linkToProcess = getProcessDefinition(process);
if (linkToProcess != null) {
linkToProcess = (BusinessProcess) linkToProcess.getWorkingCopy();
linkToProcess = (BusinessProcess) repositoryItemService.saveItem(linkToProcess);

It I query for the OrganizationNotes, I am able to get them for sometime and then start getting null (especially after server restart)

- Vibha

permanent link
Rafik Jaouani (5.0k16) | answered Jul 21 '08, 11:08 a.m.
Could it be that the transaction that is writing the items and content is being rolled back due to an exception of some sort. Did you query for the items and content within the same transaction (the one that writes) or a separate one?

permanent link
Christof Marti (681) | answered Jul 22 '08, 5:06 a.m.
Does the reference to the IContent have the containment flag set? I seem to remember a similar problem that was caused by an IContent not being contained in the owning item.

Jazz Work Item team

permanent link
Vibha Sinha (1643610) | answered Jul 24 '08, 1:25 a.m.
Hello Christof,

Yep, you were correct in the diagnosis. I had not marked the reference as contained.

Thanks a lot

Your answer

Register or to post your answer.