Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to write/upload any file(zip) inside any specific folder of RTC source control (component) in java?

 I have found following code from 1 of the articles but I am not sure how to pass parameters to that method. Basically it requies 'IFileItem' object. I dont know how to create or get that object containing details of the folder of RTC source control where I want to upload my file.

 //method to uploadContentToFile
public static IFileItem uploadContentToFile(IFileItem fileItem,
ITeamRepository repo, String newContent) throws TeamRepositoryException {

IProgressMonitor monitor = new NullProgressMonitor();
IFileItem fileWorkingCopy = (IFileItem) fileItem.getWorkingCopy();

IFileContentManager contentManager = FileSystemCore
.getContentManager(repo);

VersionedContentManagerByteArrayInputStreamPovider inputStream = new VersionedContentManagerByteArrayInputStreamPovider(
newContent.getBytes());

IFileContent uploadedcontent = null;
uploadedcontent = contentManager.storeContent(
IFileContent.ENCODING_UTF_8,
FileLineDelimiter.LINE_DELIMITER_PLATFORM, inputStream, null,
monitor);

fileWorkingCopy.setContent(uploadedcontent);
System.out.println("Loaded new content into file.");
return fileWorkingCopy;
}

//method to applyLock
public static void applyLock(ITeamRepository repo,
IWorkspaceConnection streamConnection,
IComponentHandle componentHandle, IFileItem fileItem,
IProgressMonitor monitor) throws TeamRepositoryException {

IWorkspaceManager wsManager = (IWorkspaceManager) repo
.getClientLibrary(IWorkspaceManager.class);
IVersionableLockOperationFactory lockFactory = wsManager
.lockOperationFactory();
ArrayList<IVersionableLockOperation> lockOperations = new ArrayList<IVersionableLockOperation>();
lockOperations.add(lockFactory.acquire(fileItem, streamConnection,
componentHandle));
wsManager.applyLockOperations(lockOperations, monitor);
}

//method to removeLock
public static void removeLock(ITeamRepository repo,
IWorkspaceConnection streamConnection,
IComponentHandle componentHandle, IFileItem fileItem,
IProgressMonitor monitor) throws TeamRepositoryException {

IWorkspaceManager wsManager = (IWorkspaceManager) repo
.getClientLibrary(IWorkspaceManager.class);
IVersionableLockOperationFactory lockFactory = wsManager
.lockOperationFactory();
ArrayList<IVersionableLockOperation> lockOperations = new ArrayList<IVersionableLockOperation>();
lockOperations.add(lockFactory.release(fileItem, streamConnection,
componentHandle, true));
wsManager.applyLockOperations(lockOperations, monitor);
}

0 votes


Accepted answer

Permanent link

 Take a look at the following link: http://thescmlounge.blogspot.in/ and search for Uploading new content. Follow through with committing the change to a change set.

Vivek Mishra selected this answer as the correct answer

1 vote

Comments

 Also see https://rsjazz.wordpress.com/2013/09/30/delivering-change-sets-and-baselines-to-a-stream-using-the-plain-java-client-libraries/ and make sure to understand which file types, line ending etc. to use for zip  - e.g. look at the values it has in RTC Eclipse. ZIP is not mergeable binary (which is why it normally should not be in SCM).

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,019
× 1,700

Question asked: Oct 11 '17, 8:59 a.m.

Question was seen: 2,475 times

Last updated: Oct 12 '17, 6:49 a.m.

Confirmation Cancel Confirm