It's all about the answers!

Ask a question

What's the best way to deploy a BIRT report template over 100 project areas?


Guido Schneider (3.4k1384111) | asked Mar 24 '14, 4:00 p.m.
Unfortunatly BIRT templates are not inherited from a parent project area (at least it was not until 4.0.5 as much as I know).
Since 4.0.3 you can load report resources from other project areas, but this means still opening of each project area and deploy the resources. When you have 100+ PA's thats quite boring.

Is there a way to deploy a report template (or replace a built-in template to deploy a patch) from one central place to ALL project areas?

Comments
Lukas Steiger commented May 15 '14, 2:53 a.m.

The code below does the same as the 'provided by application' in Jazz. Using the Java API, is there also a way to select a project area to deploy from instead of 'provided by application'?

Accepted answer


permanent link
sam detweiler (12.5k6189201) | answered Mar 24 '14, 4:06 p.m.
edited Mar 24 '14, 4:09 p.m.
 here is code I wrote just last week to deploy report resources.. same as the UI does. (well, I deploy all avalable,)
takes repo url, userid, password and project. 
this does ONE project area.. to do a lot (all) use the routine
public static List<iprojectarea> getProjectArea(ITeamRepository repo, 
            IProgressMonitor monitor, String projectAreaName) 

from this post 
https://jazz.net/forum/questions/142728/auto-backup-of-process-configuration-xml-source

to get a list of ALL the projects on the repository  (projectname='*')
then lop thru the projects and then loop thru their reports..

note that the user executing this MUST have permission to deploy report resources, or you will a false 
'operation canceled' exception, instead of 'permission denied'


package com.sd.tools;

import java.net.URI;
import java.util.List;

import com.ibm.team.process.client.IProcessClientService;
import com.ibm.team.process.common.IProcessArea;
import com.ibm.team.process.common.IProcessAreaHandle;
import com.ibm.team.process.common.IProjectArea;
import com.ibm.team.reports.client.IReportManager;
import com.ibm.team.reports.common.IReportDescriptor;
import com.ibm.team.repository.client.ITeamRepository;
import com.ibm.team.repository.client.TeamPlatform;
import com.ibm.team.repository.client.ITeamRepository.ILoginHandler;
import com.ibm.team.repository.client.ITeamRepository.ILoginHandler.ILoginInfo;
import com.ibm.team.repository.common.TeamRepositoryException;

public class AddReportResources
{
private static boolean debug = true;
private static final int master_connection_timeout = 24 * 60 * 60;
private static ITeamRepository productionServer = null;
private static IProcessClientService prodprocessClient = null;


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;
if (debug)
System.out.println("starting up\n");
TeamPlatform.startup();
if (debug)
System.out.println("platform started\n");

try
{
result = run(args);
}
catch (Exception x)
{
x.printStackTrace();
result = false;
}
finally
{
TeamPlatform.shutdown();
}

if (!result)
System.exit(1);
}

private static boolean run(String[] args) throws TeamRepositoryException {
boolean rc = false;
if (debug)
System.out.println("run started\n");
if (args.length < 4)
{
System.out
.println("Usage: AddReportResources <repositoryuri> <userid> <password> <projectarea>");
return false;
}

// get all the user passed arguments

String productionURI = args[0];
String produserId = args[1];
String prodpassword = args[2];
String prodprojectAreaName = args[3];

try
{
productionServer = TeamPlatform.getTeamRepositoryService().getTeamRepository(productionURI);

if (debug)
System.out.println("logging in\n");
productionServer.registerLoginHandler(new LoginHandler(produserId, prodpassword));

productionServer.setConnectionTimeout(master_connection_timeout);

productionServer.login(null);

if (debug)
System.out.println("logged in\n");

            prodprocessClient = (IProcessClientService) productionServer
                    .getClientLibrary(IProcessClientService.class);

URI produri = URI.create(prodprojectAreaName.replaceAll(" ", "%20"));
IProjectArea iprja_prod = (IProjectArea) prodprocessClient.findProcessArea(produri, null, null);
if (iprja_prod != null)
{
iprja_prod=(IProjectArea) iprja_prod.getWorkingCopy();
IReportManager irptMgr = ((IReportManager) productionServer.getClientLibrary(IReportManager.class));
System.out.println("repository server name="+productionServer.getName());
List<IReportDescriptor> missingreports = irptMgr.fetchMissingSharedReportDescriptors(
(IProcessAreaHandle) iprja_prod.getItemHandle(), null);
System.out.println("there are "+missingreports.size()+" missing report definitions");
for (IReportDescriptor report : missingreports)
{

try
{
if(debug)
System.out.println("adding resport='"+report.getId()+"'");
report = (IReportDescriptor) report.getWorkingCopy();
irptMgr.saveReportDescriptor(report, null);
}
catch (Exception e)
{
System.out.println("cause="  +e.getClass().toString());
System.out.println("adding report resporce failed for report="+report.getName()+ " exception="+e.getMessage());
e.printStackTrace();
return(false);
}
}
}
else
System.out.println("Project area not found = '"+prodprojectAreaName+"'");
}
catch (Exception ex)
{
System.out.println("utility startup failed exception="+ex.getMessage());
}
return rc;
}

}

Guido Schneider selected this answer as the correct answer

Comments

Your answer


Register or to post your answer.