Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upload a new version for a document already in ECM 1

Status
Not open for further replies.

Dhanya1

Programmer
Nov 17, 2017
4
US
Hi All,

I am trying to implement versioning for ECM documents using OpenText livelink Java api.
I upload a document(w1.txt) to ECM successfully using 'contentServiceClient.uploadContent(new DataHandler(new FileDataSource(filePath)))'

I checked the document in the ECM server, and versioning is enabled for this document. Also I could add new versions of this document(w1.txt) directly from the ECM server.

Also I am able to get the NodeVersionInfo() and VersionNum() of this document correctly from java.

But, when I upload the next version of the document (by the same file name to the same location) from the Java, I am getting "DocMan.DuplicateName : An item with the name 'w1.txt' already exists."

I tried to pass along the version indicator in the SOAP header as below:

String versionContextID = docManClient.addVersionContext(docManClient.getNodeByName(parentID, fileName).getID(), null);

// Create a SOAP header
SOAPHeader header = MessageFactory.newInstance().createMessage().getSOAPPart().getEnvelope().getHeader();


// Add the Version ContextID SOAP header element
SOAPHeaderElement verContextIDElement = header.addHeaderElement(new QName(CORE_NAMESPACE, "versionContextID"));
verContextIDElement.addTextNode(versionContextID);

List<Header> headers = new ArrayList<Header>();
headers.add(Headers.create(verContextIDElement));

((WSBindingProvider) contentServiceClient).setOutboundHeaders(headers);

But this didn't solve the problem, still getting 'Duplicate item' error (I am adding other headers like 'OTAuthentication' and 'AuthenticationToken', in the same above manner which are working well)
Appreciate if somebody throws some light on this.

Thanks,
Dhanya
 
Please take a look at a C# sample I have in Java the only changes are the soap headers you will see how a version is being added you can play with it in SOAPUI and make your code. You will get a context from the server and you will upload it to this context.A context is nothing but a cached mechanism in livelink,on first upload the context is usually given the same dataid in livelink but a string.
Oh I thought i had written that in java but actually it is in java perhaps reading that will help


BTW an Item with the same name exists is when a NodeCheck is done to not allow duplicates,so your code is somehow reaching livelink as a call to create
a new node not a version.What you have to do is first make sure you get the existing node,check its subtype to see if it is a 144 and then
do that addversioncontext.I sueect your code is almost correct but missing something very trivial

One more thing I would do is to find if the first node is actually a subtype=144 or 145 if you don't know take the node's dataid and run
select Name,DataID,SubType from DTree where DataID=<Your DataID>

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
Thank you appnair for the advice. It is working now, the change made is, added the versionContextID as 'contextID' and not as versionContext.

Dhanya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top