How Do I Export Process configuration source xml file from commandline
Hi There,
I would like to export the process configuration data xml file from some project area via command line. How to do this? Alternatively, How Can I view version History of Process configuration Data Xml file from command line?
Could Anyone, please help me to understand this question?
Thanks and regards
Saravanan Lakshmanan.
I would like to export the process configuration data xml file from some project area via command line. How to do this? Alternatively, How Can I view version History of Process configuration Data Xml file from command line?
Could Anyone, please help me to understand this question?
Thanks and regards
Saravanan Lakshmanan.
3 answers
I am not aware of an out of the box capability to export the process configuration to a file. You would have to use the API and write your own tool to do that.
Comments
Hi Ralph
Could you please advise me on the API Part. Do I need to download Plain Java API?
Thanks
Saravanan.L
You will most likely use the Plain Java API.
To get started see
https://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/
https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/
Please be aware, that this requires Java skills.
I found this code on my disk:
/*******************************************************************************
* Licensed Materials - Property of IBM
* (c) Copyright IBM Corporation 2014. All Rights Reserved.
*
*
* Note to U.S. Government Users Restricted Rights: Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*******************************************************************************/
package com.ibm.team.js.process.client;
import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import com.ibm.team.process.client.IProcessItemService;
import com.ibm.team.process.common.IProjectArea;
import com.ibm.team.process.common.ProcessContentKeys;
import com.ibm.team.repository.client.IContentManager;
import com.ibm.team.repository.client.ITeamRepository;
import com.ibm.team.repository.client.ITeamRepository.ILoginHandler;
import com.ibm.team.repository.client.ITeamRepository.ILoginHandler.ILoginInfo;
import com.ibm.team.repository.client.TeamPlatform;
import com.ibm.team.repository.common.IContent;
import com.ibm.team.repository.common.TeamRepositoryException;
/**
* Skeleton for a plain-Java client, see
* https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation.
*/
public class ModifyProjectAreaProcessXML {
private static class LoginHandler implements ILoginHandler, ILoginInfo {
private String fUserId;
private String fPassword;
private LoginHandler(String userId, String password) {
fUserId = userId;
fPassword = password;
}
public String getUserId() {
return fUserId;
}
public String getPassword() {
return fPassword;
}
public ILoginInfo challenge(ITeamRepository repository) {
return this;
}
}
public static void main(String[] args) {
boolean result;
TeamPlatform.startup();
try {
result = run(args);
} catch (TeamRepositoryException x) {
x.printStackTrace();
result = false;
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
result = false;
} finally {
TeamPlatform.shutdown();
}
if (!result)
System.exit(1);
}
private static boolean run(String[] args) throws TeamRepositoryException,
UnsupportedEncodingException {
if (args.length != 4) {
System.out
.println("Usage: ProcessSharing ");
return false;
}
String repositoryURI = args[0];
String userId = args[1];
String password = args[2];
String projectAreaName = args[3];
IProgressMonitor monitor = new NullProgressMonitor();
ITeamRepository teamRepository = TeamPlatform
.getTeamRepositoryService().getTeamRepository(repositoryURI);
teamRepository.registerLoginHandler(new LoginHandler(userId, password));
teamRepository.login(monitor);
System.out.println("Logged in as: "
+ teamRepository.loggedInContributor().getName());
IProcessItemService processItemService = (IProcessItemService) teamRepository
.getClientLibrary(IProcessItemService.class);
System.out.println("\nProcessing project area: " + projectAreaName);
URI uri = URI.create(projectAreaName.replaceAll(" ", "%20"));
IProjectArea projectArea = (IProjectArea) processItemService
.findProcessArea(uri, null, monitor);
if (projectArea == null) {
System.out.println("....Error: Project area not found: ");
return false;
}
projectArea = (IProjectArea) projectArea.getWorkingCopy();
modifyProcessXML(projectArea, monitor);
teamRepository.logout();
return true;
}
/**
* @param ip
* @param ic
* @param icm
* @param name
* @param monitor
*/
private static void saveXMLSource(IProjectArea ip, IContent ic,
IContentManager icm, String name, IProgressMonitor monitor) {
// create an output stream for the content manager
OutputStream os = new ByteArrayOutputStream();
// get the content of the content object.
try {
icm.retrieveContent(ic, os, null);
// write xml content to file
// project name + data name
FileOutputStream fo = new FileOutputStream(ip.getName() + name
+ "." + "xml");
// write
fo.write(os.toString().getBytes(), 0, os.toString().length());
// close
fo.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Gets the processXML and tries to replace an element in the process by
* something else and saves it back to the process XML.
*
* @param projectArea
* @param monitor
* @throws TeamRepositoryException
* @throws UnsupportedEncodingException
*/
private static void modifyProcessXML(IProjectArea projectArea,
IProgressMonitor monitor) throws TeamRepositoryException,
UnsupportedEncodingException {
ITeamRepository teamRepository = (ITeamRepository) projectArea
.getOrigin();
Map pd = projectArea.getProcessData();
IContent content = (IContent) pd
.get(ProcessContentKeys.PROCESS_SPECIFICATION_KEY);
if (content != null) {
String processConfig = createStringFromContent(teamRepository,
content, monitor);
String newProcessConfig = processConfig.replace(
"this-is-a-fake-url", "http://localhost/index.html");
IContent newContent = createContentFromString(teamRepository,
newProcessConfig, monitor);
pd.put(ProcessContentKeys.PROCESS_SPECIFICATION_KEY, newContent);
IProcessItemService processItemService = (IProcessItemService) teamRepository
.getClientLibrary(IProcessItemService.class);
processItemService.save(projectArea, monitor);
}
}
/**
* @param repo
* @param content
* @param monitor
* @return
* @throws TeamRepositoryException
* @throws UnsupportedEncodingException
*/
private static String createStringFromContent(ITeamRepository repo,
IContent content, IProgressMonitor monitor)
throws TeamRepositoryException, UnsupportedEncodingException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
repo.contentManager().retrieveContent(content, stream, monitor);
return new String(stream.toByteArray(), content.getCharacterEncoding());
}
/**
* @param teamRepository
* @param content
* @param monitor
* @return
* @throws TeamRepositoryException
*/
private static IContent createContentFromString(
ITeamRepository teamRepository, String content,
IProgressMonitor monitor) throws TeamRepositoryException {
return teamRepository.contentManager().storeContent(
IContent.CONTENT_TYPE_XML, content, monitor);
}
}