Auto backup of process configuration XML source
Hi,
We're working with process inheritance model, where the process configuration is maintained in a "Master Project Area" and the actual projects work on consuming project areas, which use the process from the Master PA. To have a "recovery plan" from any unintentional changes to the process configuration on the consuming project areas (one must remember that any minor changes in the consuming PA results in broken inheritance), we need a method to backup the XML process configuration source of the consuming projects automatically (best preferred solution). To develop this, we need a method to retrive this XML process configuration source fo a patricular Project Area. regards Madhan |
Accepted answer
my code (I can get it for all project areas at once, or just one by name)
static String keyname = "com.ibm.team.internal.process.compiled.xml"; // get the project area IProjectArea ip = projectList.get(i); System.out.println("\nproject name = " + ip.getName()); // get the process data @SuppressWarnings("unchecked") Map<Object, Object> pd = ip.getProcessData(); // get the content Manager IContentManager icm = repo.contentManager(); // get the process config content object IContent processSource = (IContent) pd.get(keyname); if (processSource != null) { System.out.println("have xml source"); saveXMLSource(ip, processSource, icm, sPm); } . . // save the process source for the project private static void saveXMLSource(IProjectArea ip, IContent ic, IContentManager icm, SysoutProgressMonitor sPm) { // make an output stream for the content manager OutputStream os = new ByteArrayOutputStream(); // get the content of the content object. try { icm.retrieveContent(ic, os, sPm); // write xml content to file // project name + data name FileOutputStream fo = new FileOutputStream(ip.getName() + "." + keyname); // write fo.write(os.toString().getBytes(), 0, os.toString().length()); // close fo.close(); } catch (Exception e) { e.printStackTrace(); } } Madhan Babu selected this answer as the correct answer
Comments Perfect!
Madhan Babu
commented Feb 19 '14, 9:44 a.m.
Is it also possible to fetch via code (plain Java API) the History entries of a Project Area? Reason: I want to run a scheduled executable which checks into the History of the Project Area and notify (via Email) when there is an entry for "Process Configuration" change.
sam detweiler
commented Feb 19 '14, 10:09 a.m.
I have not looked into how to do this..
my 'assumption' is that the versioned xml is stored in the same
Map<object, Object=""> pd = ip.getProcessData(); map..
I would dump out the map keys and see what is there..
Hi Madhan/Sam,
I am a beginner in java programming; could you please help me with the following:
I also need to access the 'process config source' file for automation purposes and using your suggestions in this post, I am trying to setup a project. I also referred to this link as well: https://jazz.net/forum/questions/111579/get-process-configuration-source-via-api
I am writing my questions first for the code I have so far; I will post the code below the questions:
In the IProjectArea ip = (IProjectArea)(repo.itemManager().fetchCompleteItem(iparenthandle, IItemManager.DEFAULT, myProgressMonitor)); I don't understand the purpose of iparenthandle variable. I'm not sure how to initialize it.
Next, in the 'get the process data' part, I have Map<string, Object = "Project Name I want to access"> pd = ip.getProcessData(); First, what do I need to put with 'string' since I am getting an error? Second, does the 'Object' get the name of the project I want to get the information for? Third, what does 'pd' stand for?
Next, is the 'keyname' specific to the project? How do I get the keyname?
Finally, when writing the content of the file, is the file stored on my local directory?
I have marked your suggested code with the comment: "your suggested code" Any help would be great! Thanks in advance.
Here is what I have so far:
public class SignIn {
private static String userID = "username";
private static String password = "pass";
private static String repoUri = "my repo";
static String keyname = "com.ibm.team.internal.process.compiled.xml";
public static void main(String[] args){
IProgressMonitor myProgressMonitor = new SysoutProgressMonitor(); // cannot use IProgressMonitor() because it is an interface and interface cannot be instantiated.
TeamPlatform.startup(); // Starts the RTC platform
try{
/Do all the work with RTC server here. /
// Login to the repo using the provided credentials
ITeamRepository repo = TeamPlatform.getTeamRepositoryService().getTeamRepository(repoUri);
repo.registerLoginHandler(new ILoginHandler2(){
public ILoginInfo2 challenge(ITeamRepository repo){
return new UsernameAndPasswordLoginInfo(userID, password);
}
});
myProgressMonitor.subTask("Contacting " + repo.getRepositoryURI() + "...");
repo.login(myProgressMonitor);
myProgressMonitor.subTask("connected");
/ Connecting to a specific project and getting the process config source file content /
/your suggested code for getting the data/
IItemHandle iparenthandle;
IProjectArea ip = (IProjectArea)(repo.itemManager().fetchCompleteItem(iparenthandle, IItemManager.DEFAULT, myProgressMonitor));
System.out.println("Project name = " + ip.getName());
//getting the process data
Map<String, Object = "Transmissions (RTC Scrum)"> pd = ip.getProcessData();
// get the process config content object
IContentManager icm = repo.contentManager();
IContent processSource = (IContent) pd.get(keyname);
if(processSource != null){
System.out.println("have xml source");
saveXMLSource(ip, processSource, icm, myProgressMonitor);
}
//end of: Connecting to a specific project and getting the process config source file content
//Do all of the work with myserver here.
repo.logout();
} catch (TeamRepositoryException e){
/ Handling repository exceptions such as login problems here. /
System.out.println("Unable to login: " + e.getLocalizedMessage());
}finally{
TeamPlatform.shutdown();
}
}
//your suggested code for saving the content
// saving the process config source content of the project
private static void saveXMLSource(IProjectArea ip, IContent ic, IContentManager icm, IProgressMonitor myProgressMonitor){
//making an output stream for the content manager
OutputStream os = new ByteArrayOutputStream();
// getting the content of the content object
try{
icm.retrieveContent(ic, os, myProgressMonitor);
//write the xml content to a file with project name and data name
FileOutputStream fos = new FileOutputStream(ip.getName() + "." + keyname);
//write
fos.write(os.toString().getBytes(), 0, os.toString().length());
//close
fos.close();
}catch (Exception e) {
e.printStackTrace();
}
}
}
|
3 other answers
There is no need to backup the process spec XML manually as it is completely auditable.
In Eclipse client open the project area editor, switch to process spec XML tab.
Right click will get you you show history option.
This will list you all the changes that has happened to this XML.
Also you can select 2 versions and say compare to see what has changed.
On the web client as well there is a new tab called the History which shows what all changes had been done.
Comments
Madhan Babu
commented Feb 25 '14, 11:38 a.m.
The hint regarding the history view Eclipse client was helpfull..
I am happy with the availability of all versions of the process configuration in the Eclipse client..
|
I design everything to be run from the commandline.. (export a runnable jar file)
java -jar runnable_jar repo userid password project-name (or * for all)
in eclipse this is a run configuration with parameters
repo userid password project-name (or * for all)
Comments Thanks! I have it working, now it got to : if (processSource != null) { System.out.println("have xml source"); ....}
I don't think it executed the saveXMLSource method; how should I check if the saveXMLSource method went through or not; where would it save the XML file content?
in a file called
project_area_name.com.ibm.team.internal.process.compiled.xml
FileOutputStream fo = new FileOutputStream(ip.getName() + "."
+ keyname); Thanks a bunch for all your help so far!
I have couple more things to ask. First, what is the purpose of the keyname? Is that the object where the config source file is saved?
Second, now that I have made the changes to the xml file, how can I publish it back to the project?
sam detweiler
commented Mar 31 '14, 2:48 p.m.
the keyname is the string IBM uses to store the value in the process area data map table
|
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.