Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

The Resources in LiveCycle Server can't be updated! How does the API work?

Avatar

Former Community Member

Hello,

I'm trying to update XDP resources on Adobe LiveCycle Server ES8.2, my references are the 2 links below:

http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/wwhe lp/wwhimpl/common/html/wwhelp.htm?context=sdkHelp&file=000178.html

http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/javadoc/c om/adobe/repository/bindings/ResourceRepository.html#updateResource%28 %29

and my code snap is below

---------------------------------------------------------------------- -------------------------------------------------------

ResourceRepositoryClient repositoryClient = new ResourceRepositoryClient(
                    serviceClientFactory);

String resourceURI = "/Forms/test.xdp";
Document doc = repositoryClient.readResourceContent(resourceURI);

String xmlString = readDocument(doc).toString();

//locate the Text content by the variable name "content_test"

int fromIndex = xmlString.indexOf("content_test");
fromIndex = xmlString.indexOf("</draw>", fromIndex);

//insert the value content "Hello Adobe LiveCycle"
StringBuffer sbf = new StringBuffer(512);
sbf.append("<value>");
sbf.append("Hello Adobe LiveCycle");
sbf.append("</value>");


sbf.append(xmlString.substring(fromIndex));


Document dataDocument = new Document(sbf.toString().getBytes());
Resource resource = repositoryClient.readResource(resourceURI);
ResourceContent resourceContent = resource.getContent();

//set the updated document into the resource
resourceContent.setDataDocument(dataDocument);
resource.setContent(resourceContent);

//update the resource
repositoryClient.updateResource(resourceURI, resource, true);

---------------------------------------------------------------------- -------------------------------------------------------

The code above tries to load a XDP form template from LiveCycle repository, there is an empty Text area named "content_test" on the XDP form template. What I want to do is to insert a value content into the XDP and then update the resource on LiveCycle server. The result is only the version of the XDP on server is increaced, but the XDP form seems to be cleard totally, all of the objects on the XDP form are lost, sounds like I created a new XDP. I tried the "writeResource" API and I only got a empty XDP form as well. Is there any parameters or properties or preconditions I ignored in the implementation? Please help me to sort out the things. Any of your suggetions will be very appreciated!

1 Reply

Avatar

Former Community Member

Hey Dazhi,

Where you able to resolve the issue?
Because here's the thing, when I saw this query and the details, this looks similar to a situation that I had encountered earlier. This Java API for LC is used primarily for "Writing a resource in the repositry and I see that you are already able to achieve that sucessfully.    I reckon without the UpdateProperties method, it won't be updating the content of the resource of the XDP.
Hence, related to the update on the XDP content, there might be a possibility using the updateProperties () method in the Java API, (String resourceUri, properties), because this adds and updates the properties of a resource. This is effectively a resource update, and, as such, this method is subjected to the rules laid out in updateResource(). You will find multiple Resource methods () depending upon the implementation you require.

The Most important of the Pre-conditions include that the properties and its elements must not be null. I am not sure looking at your API Code Excerpt, but it looks like this should include the UpdateProperties () method.

Also, wanted to know whether, while executing the API, are you getting this particular ALC-REP-030-000 exception either on the eclipse console or on the Server, or anything related to ALC-REP?

Cheers!!
Pushkar