It's all about the answers!

Ask a question

File Metadata - Java API


VK L (8177129159) | asked Apr 24 '15, 5:41 a.m.
edited May 04 '15, 8:03 a.m.
Hi All,
Is it possible to set metadata info like creation date, check-in/deliver date using Java API - while importing files via Java API. This is to keep the metadata info intact while migrating files from another tool, for example.
Please advise.

Comments
Surya Tripathi commented May 08 '15, 8:25 p.m.

 I think you can use com.ibm.team.filesystem.common.IFileItem.setFileTimestamp() to set file time stamp and 

com.ibm.team.scm.common.internal.ChangeSet.setLastUpdatedDate() to set change set time stamp.

One answer



permanent link
K M (38324247) | answered May 20 '15, 2:37 p.m.
IFileContentManager contentManager = FileSystemCore.getContentManager(repo); 

storecontent lets you set encoding and line feed

IFileContent newcontent = contentManager.storeContent(content.getCharacterEncoding(),content.getLineDelimiter(),
                    new VersionedContentManagerByteArrayInputStreamPovider(FileUtils.readFileToByteArray(tmpfile)),null, MONITOR); 

IFileItem should let you set the date

// Get Working copy
                file = (IFileItem) file.getWorkingCopy();
                file.setContent(storedContent);
                file.setFileTimestamp(new Date());
     

Your answer


Register or to post your answer.