Sunday, January 21, 2007

How to install and use the BpelConsole undeploy extension

Thanks to Michel Christianen for given me the input for this article.

Note: While this article is changing code in the original files of the product, there is no guarantee of support provided.

During development you deploy and undeploy process to the BPEL PM. Sometimes you want undeploy more than one process. This article describes a solutions that adds an option in the BPEL console to undeploy all the BPEL processes at onces.

Make a copy the of the files; bulkUpdateProcess.jsp and doBulkUpdateProcess.jsp.
These files are located in the directory

$ORACLE_HOME/j2ee/oc4j_soa/applications/orabpel/console

Add the following code in the the file bulkUpdateProcess.jsp.
Add the code after the label:

<label for="processStateOff">
<%= I18nUtil.getString("off", locale)%>
</label>



<p>
<b>Process Undeploy:</b><br>
Using this option all the selected processes
can be undeployed at once.
<br> The default for undeployment is <i><b>none
</b></i>, but you can enable this bulk undeployment
<br> by setting this value to <i><b>all
</b></i>.<br> Note that if this option is selected,
the other bulk update options (Process Lifecycle/State)
are ignored. <p>
<input type="radio" id="processDeployOff"
name="processDeploy" value="none" checked>
<label for="processDeployOff">None</label>
<input type="radio" id="processDeploy"
name="processDeploy" value="all">
<label for="processDeploy">All </label>

Replace the the code in the the file dobulkUpdateProcess.jsp.
The code can be found at the end of the article.

When you navigate to the BpelConsole after you have installed the undeploy extension files, you can now use the new feature. Select the BpelProcesses you want to undeploy or use the ‘Check_all’ option and press the ‘Bulk update’ button.


Now you see at the bottom of the page the new ‘Process Undeploy’ option which you can use to undeploy all the selected processes.

The doBulkUpdateProcess.jsp is here:

<%@page contentType="text/html; charset=UTF-8" %>
<%@page errorPage="reportError.jsp" %>
<%@page import="com.oracle.bpel.client.*" %>
<%@page import="com.oracle.bpel.client.ServerException" %>
<%@page import="com.oracle.bpel.client.util.*" %>
<%@page import="com.collaxa.cube.util.BuildInfo" %>
<%@page import="com.collaxa.cube.fe.util.ServletUtils" %>
<%@page import="com.collaxa.common.util.*" %>
<%@page import="com.collaxa.cube.rm.suitcase.*" %>
<%@page import="java.text.*" %>
<%@page import="java.util.*" %>
<%@include file="initI18n.jspf" %>

<%
int n0 = 0, n1 = 0;
Locator l = ServletUtils.getLocatorWithoutUrlRewrite(request, response);
request.setAttribute( "tab", "BPEL Processes" );

IBPELDomainHandle domain = l.lookupDomain();

String processIds = request.getParameter( "processIds" );
ArrayList list0 = CXStringUtils.split( processIds, ' ' );
n0 = list0.size();
ArrayList list1 = new ArrayList();
Iterator li = list0.iterator();

try {
String undeployMode = request.getParameter( "processDeploy" );
if (undeployMode.equalsIgnoreCase("all")) {
for( int size = list0.size(); size > 0; size-- )
{
list1.clear();
CXStringUtils.split( (String) li.next(), '~', list1 );
BPELProcessId pid = new BPELProcessId(domain.getDomainId(),
(String)list1.get(0), (String)list1.get(1));
domain.undeployProcess(pid);
n1++;
}
}
else {
int lifecycle = -1;
String processMode = request.getParameter( "processMode" );
if( ! CXStringUtils.isEmpty( processMode ) )
{
lifecycle = "open".equalsIgnoreCase( processMode )
? IBPELProcessConstants.LIFECYCLE_ACTIVE
: IBPELProcessConstants.LIFECYCLE_RETIRED;
}
int state = -1;
String processState = request.getParameter( "processState" );
if( ! CXStringUtils.isEmpty( processState ) )
{
state = "on".equalsIgnoreCase( processState )
? IBPELProcessConstants.STATE_ON
: IBPELProcessConstants.STATE_OFF;
}
for( int size = list0.size(); size > 0; size-- )
{
list1.clear();
CXStringUtils.split( (String) li.next(), '~', list1 );
BPELProcessHandle process = (BPELProcessHandle)
l.lookupProcess( (String) list1.get( 0 ),
(String) list1.get( 1 ) );
BPELProcessMetaData ri = process.getMetaData();

int i = 0;
if( lifecycle != -1 )
{
if( ( ri.isLifecycleActive() &&
lifecycle == IBPELProcessConstants.LIFECYCLE_RETIRED ) ||
( ! ri.isLifecycleActive() &&
lifecycle == IBPELProcessConstants.LIFECYCLE_ACTIVE ) )

{
ri.setLifecycle( lifecycle );
i++;
}
}
if( state != -1 )
{
if( ( ri.isStateOn() &&
state == IBPELProcessConstants.STATE_OFF ) ||
( ! ri.isStateOn() &&
state == IBPELProcessConstants.STATE_ON ) )
{
ri.setState( state );
i++;
}
}
if( i > 0 )
process.updateMetaData( ri );

n1++;
}
}
}
catch( Exception e )
{
e.printStackTrace();
}
%>

<html lang="en-US">
<style type="text/css">
<!--
.title {
font-size: 16px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
.note {
font-size: 12px;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style>
<head>
<title><%= I18nUtil.getString("title", BuildInfo.getVersion(), locale)%></title>
<jsp:include page="ngIncludes.jsp" />
</head>
<body bgcolor="#FFFFFF">
<form action="processes.jsp" method="get">

<table summary="" class="DefaultTable" cellspacing="0" cellpadding="0">
<tr height="20">
<td class="TabPane" colspan="2">
<jsp:include page="ngTabs.jsp" />
</td>
</tr>
<tr>
<td colspan="2" class="IViewerInstanceInfoPane">
<table summary="" class="DefaultTable" cellpadding="0" cellspacing="0">
<tr>
<td valign="middle" style="padding-left:15px"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="IViewerTabControl">
<div class="IViewerTabPadding"><img src="images/iviewer/blank.gif" alt="" border="0" width="1" /></div>
</td>
<td class="IViewerRightPane">

<table summary="" class="DefaultTable" cellspacing="0" cellpadding="0" width="100%" height="100%">
<tr>
<td colspan="2" class="SViewerToolViewWrapper">
<div align="center" style="padding:10px">
<table width="80%" align="center" border="0" cellspacing="10" cellpadding="0" bgcolor="#f0f0f0">
<tr>
<td>
<b><label class="title"><%= I18nUtil.getString("bulk_update_processes_complete", locale)%></label></b>
<p>
<label class="note">
<%= n1 == 1 ? I18nUtil.getString("one_process_updated",
Integer.toString(n1), l.getDomainId(), locale) :
I18nUtil.getString("many_process_updated",
Integer.toString(n1), l.getDomainId(), locale) %>
<%
if( n0 > 0 && n0 != n1 )
{
String mesg = "";
if(n0 == 1 && ((n1 - n0) == 1) )
mesg = I18nUtil.getString("one_process_one_error",
Integer.toString(n0), Integer.toString((n1 - n0)), locale);
if(n0 != 1 && ((n1 - n0) == 1) )
mesg = I18nUtil.getString("many_process_one_error",
Integer.toString(n0), Integer.toString((n1 - n0)), locale);
if(n0 == 1 && ((n1 - n0) != 1) )
mesg = I18nUtil.getString("one_process_many_error",
Integer.toString(n0), Integer.toString((n1 - n0)), locale);
if(n0 != 1 && ((n1 - n0) != 1) )
mesg = I18nUtil.getString("many_process_many_error",
Integer.toString(n0), Integer.toString((n1 - n0)), locale);
%>
<%= mesg%>
<%
}
%>
</label>
<p>
<div style="text-align:right">
<input type="submit" name="home" value='<%= I18nUtil.getString("back_to_processes", locale)%>' />
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="FooterPane" colspan="2">
<jsp:include page="ngFooter.jsp" />
</td>
</tr>
</table>
</form>
</body>
</html>

Post a Comment