use of org.wso2.carbon.bpel.core.ode.integration.jmx.Processes in project carbon-business-process by wso2.
the class BPMNDataPublisher method configDataPublishing.
/**
* Configure for data publishing to DAS for analytics
*
* @param receiverURLSet Analytics receiver's url
* @param username Analytics server's username
* @param password Analytics server's password
* @param authURLSet Analytics Auth URL set
* @param type Bpmn Analytics Publisher Type
* @param asyncDataPublishingEnabled is async Data Publishing Enabled
* @param genericAnalyticsEnabled is generic Analytics Enabled
* @param kpiAnalyticsEnabled is KPI Analytics Enabled
* @throws DataEndpointAuthenticationException
* @throws DataEndpointAgentConfigurationException
* @throws TransportException
* @throws DataEndpointException
* @throws DataEndpointConfigurationException
*/
void configDataPublishing(String receiverURLSet, String username, String password, String authURLSet, String type, boolean asyncDataPublishingEnabled, boolean genericAnalyticsEnabled, boolean kpiAnalyticsEnabled) throws DataEndpointAuthenticationException, DataEndpointAgentConfigurationException, TransportException, DataEndpointException, DataEndpointConfigurationException {
if (receiverURLSet != null && username != null && password != null) {
// Configure data publisher to be used by all data publishing listeners
if (log.isDebugEnabled()) {
log.debug("Creating BPMN analytics data publisher with Receiver URL: " + receiverURLSet + ", Auth URL: " + authURLSet + " and Data publisher type: " + type);
}
dataPublisher = new DataPublisher(type, receiverURLSet, authURLSet, username, password);
BPMNAnalyticsHolder.getInstance().setAsyncDataPublishingEnabled(asyncDataPublishingEnabled);
BPMNEngineService engineService = BPMNAnalyticsHolder.getInstance().getBpmnEngineService();
// Attach data publishing listeners to all existing processes
if (log.isDebugEnabled()) {
log.debug("Attaching data publishing listeners to already deployed processes...");
}
RepositoryService repositoryService = engineService.getProcessEngine().getRepositoryService();
List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().list();
for (ProcessDefinition processDefinition : processDefinitions) {
// Process definition returned by the query does not contain all details such as task definitions.
// And it is also not the actual process definition, but a copy of it, so attaching listners to
// them is useless. Therefore, we have to fetch the complete process definition from the repository
// again.
ProcessDefinition completeProcessDefinition = repositoryService.getProcessDefinition(processDefinition.getId());
if (completeProcessDefinition instanceof ProcessDefinitionEntity) {
ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) completeProcessDefinition;
if (genericAnalyticsEnabled) {
processDefinitionEntity.addExecutionListener(PvmEvent.EVENTNAME_END, new ProcessTerminationListener());
}
if (kpiAnalyticsEnabled) {
processDefinitionEntity.addExecutionListener(PvmEvent.EVENTNAME_END, new ProcessTerminationKPIListener());
}
Map<String, TaskDefinition> tasks = processDefinitionEntity.getTaskDefinitions();
List<ActivityImpl> activities = processDefinitionEntity.getActivities();
for (ActivityImpl activity : activities) {
if (activity.getProperty("type").toString().equalsIgnoreCase("usertask")) {
tasks.get(activity.getId()).addTaskListener(TaskListener.EVENTNAME_COMPLETE, new TaskCompletionListener());
}
// We are publishing analytics data of service tasks in process termination ATM.
// else if(activity.getProperty("type").toString().equalsIgnoreCase("servicetask")){
// activity.addExecutionListener(PvmEvent.EVENTNAME_END,new
// ServiceTaskCompletionListener());
// }
}
}
}
// Configure parse handlers, which attaches data publishing listeners to new processes
if (log.isDebugEnabled()) {
log.debug("Associating parse handlers for processes and tasks, so that data publishing listeners " + "will be attached to new processes.");
}
ProcessEngineConfigurationImpl engineConfig = (ProcessEngineConfigurationImpl) engineService.getProcessEngine().getProcessEngineConfiguration();
if (engineConfig.getPostBpmnParseHandlers() == null) {
engineConfig.setPostBpmnParseHandlers(new ArrayList<BpmnParseHandler>());
}
if (genericAnalyticsEnabled) {
engineConfig.getPostBpmnParseHandlers().add(new ProcessParseHandler());
engineConfig.getPostBpmnParseHandlers().add(new TaskParseHandler());
engineConfig.getBpmnDeployer().getBpmnParser().getBpmnParserHandlers().addHandler(new ProcessParseHandler());
engineConfig.getBpmnDeployer().getBpmnParser().getBpmnParserHandlers().addHandler(new TaskParseHandler());
}
if (kpiAnalyticsEnabled) {
engineConfig.getPostBpmnParseHandlers().add(new ProcessKPIParseHandler());
engineConfig.getBpmnDeployer().getBpmnParser().getBpmnParserHandlers().addHandler(new ProcessKPIParseHandler());
}
} else {
log.warn("Required fields for data publisher are not configured. Receiver URLs, username and password " + "are mandatory. Data publishing will not be enabled.");
}
}
use of org.wso2.carbon.bpel.core.ode.integration.jmx.Processes in project carbon-business-process by wso2.
the class TenantProcessStoreImpl method undeploy.
/**
* Undeploying BPEL package.
*
* @param bpelPackageName Name of the BPEL package which going to be undeployed
*/
public void undeploy(String bpelPackageName) throws RegistryException, BPELUIException {
if (log.isDebugEnabled()) {
log.debug("Un-deploying BPEL package " + bpelPackageName + " ....");
}
if (!repository.isExistingBPELPackage(bpelPackageName)) {
// This can be a situation where we un-deploy the archive through management console,
// so that, the archive is deleted from the repo. As a result this method get invoked.
// to handle this case we just log the message but does not throw an exception.
final String warningMsg = "Cannot find BPEL package with name " + bpelPackageName + " in the repository. If the bpel package is un-deployed through the management" + " console or if this node is a member of a cluster, please ignore this warning.";
if (isConfigRegistryReadOnly()) {
// This is for the deployment synchronizer scenarios where package un-deployment on a worker node
// has to remove the deployed bpel package from the memory and remove associated services
handleUndeployOnSlaveNode(bpelPackageName);
} else {
log.warn(warningMsg);
}
return;
}
if (repository.isExistingBPELPackage(bpelPackageName) && isConfigRegistryReadOnly()) {
log.warn("This node seems to be a slave, since the configuration registry is in read-only mode, hence " + "processes cannot be directly undeployed from this node. Please undeploy the process in Master " + "node first.");
return;
}
List<String> versionsOfThePackage;
try {
versionsOfThePackage = repository.getAllVersionsForPackage(bpelPackageName);
} catch (RegistryException re) {
String errMessage = "Cannot get all versions of the package " + bpelPackageName + " from registry.";
log.error(errMessage);
throw re;
}
// check the instance count to be deleted
long instanceCount = getInstanceCountForPackage(versionsOfThePackage);
if (instanceCount > BPELServerImpl.getInstance().getBpelServerConfiguration().getBpelInstanceDeletionLimit()) {
throw new BPELUIException("Instance deletion limit reached.");
}
for (String nameWithVersion : versionsOfThePackage) {
parentProcessStore.deleteDeploymentUnitDataFromDB(nameWithVersion);
Utils.deleteInstances(getProcessesInPackage(nameWithVersion));
// location for extracted BPEL package
String bpelPackageLocation = parentProcessStore.getLocalDeploymentUnitRepo().getAbsolutePath() + File.separator + tenantId + File.separator + nameWithVersion;
File bpelPackage = new File(bpelPackageLocation);
// removing extracted bpel package at repository/bpel/0/
deleteBpelPackageFromRepo(bpelPackage);
for (QName pid : getProcessesInPackage(nameWithVersion)) {
ProcessConfigurationImpl processConf = (ProcessConfigurationImpl) getProcessConfiguration(pid);
// This property is read when we removing the axis service for this process.
// So that we can decide whether we should persist service QOS configs
processConf.setUndeploying(true);
}
}
try {
repository.handleBPELPackageUndeploy(bpelPackageName);
} catch (RegistryException re) {
String errMessage = "Cannot update the BPEL package repository for undeployment of" + "package " + bpelPackageName + ".";
log.error(errMessage);
throw re;
}
updateLocalInstanceWithUndeployment(bpelPackageName, versionsOfThePackage);
// We should use the deployment synchronizer, instead of the code below.
// parentProcessStore.sendProcessDeploymentNotificationsToCluster(
// new BPELPackageUndeployedCommand(versionsOfThePackage, bpelPackageName, tenantId),
// configurationContext);
}
use of org.wso2.carbon.bpel.core.ode.integration.jmx.Processes in project carbon-business-process by wso2.
the class SVGGenerateServlet method processRequest.
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* Handles the HTTP process request which creates the SVG graph for a bpel process
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Log log = LogFactory.getLog(SVGGenerateServlet.class);
HttpSession session = request.getSession(true);
// Get the bpel process id
String pid = CharacterEncoder.getSafeText(request.getParameter("pid"));
ServletConfig config = getServletConfig();
String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
ConfigurationContext configContext = (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
String processDef = null;
ProcessManagementServiceClient client = null;
SVGInterface svg = null;
String svgStr = null;
ServletOutputStream sos = null;
sos = response.getOutputStream();
try {
client = new ProcessManagementServiceClient(cookie, backendServerURL, configContext, request.getLocale());
// Gets the bpel process definition needed to create the SVG from the processId
processDef = client.getProcessInfo(QName.valueOf(pid)).getDefinitionInfo().getDefinition().getExtraElement().toString();
BPELInterface bpel = new BPELImpl();
// Converts the bpel process definition to an omElement which is how the AXIS2 Object Model (AXIOM)
// represents an XML document
OMElement bpelStr = bpel.load(processDef);
/**
* Process the OmElement containing the bpel process definition
* Process the subactivites of the bpel process by iterating through the omElement
*/
bpel.processBpelString(bpelStr);
// Create a new instance of the LayoutManager for the bpel process
LayoutManager layoutManager = BPEL2SVGFactory.getInstance().getLayoutManager();
// Set the layout of the SVG to vertical
layoutManager.setVerticalLayout(true);
// Get the root activity i.e. the Process Activity
layoutManager.layoutSVG(bpel.getRootActivity());
svg = new SVGImpl();
// Set the root activity of the SVG i.e. the Process Activity
svg.setRootActivity(bpel.getRootActivity());
// Set the content type of the HTTP response as "image/svg+xml"
response.setContentType("image/svg+xml");
// Get the SVG graph created for the process as a SVG string
svgStr = svg.generateSVGString();
// Checks whether the SVG string generated contains a value
if (svgStr != null) {
// stream to write binary data into the response
sos.write(svgStr.getBytes(Charset.defaultCharset()));
sos.flush();
sos.close();
}
} catch (ProcessManagementException e) {
log.error("SVG Generation Error", e);
String errorSVG = "<svg version=\"1.1\"\n" + " xmlns=\"http://www.w3.org/2000/svg\"><text y=\"50\">Could not display SVG</text></svg>";
sos.write(errorSVG.getBytes(Charset.defaultCharset()));
sos.flush();
sos.close();
}
}
use of org.wso2.carbon.bpel.core.ode.integration.jmx.Processes in project carbon-business-process by wso2.
the class ActivityImpl method processSubActivities.
/**
* Get the subactivites in the bpel process
* Processes the subActivities each one separately, if the activity name matches any of the element tags
* then the constructor of that activity implementation is invoked
*
* @param omElement process definition of the bpel process
* @return activity
*/
public ActivityInterface processSubActivities(OMElement omElement) {
ActivityInterface endActivity = null;
// Checks whether omElement contains a value
if (omElement != null) {
ActivityInterface activity = null;
Iterator iterator = omElement.getChildElements();
// Iterates through the subActivities
while (iterator.hasNext()) {
OMElement tmpElement = (OMElement) iterator.next();
if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ASSIGN_START_TAG) && isIncludeAssigns()) {
activity = new AssignImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.EMPTY_START_TAG)) {
activity = new EmptyImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.CATCHALL_START_TAG)) {
activity = new CatchAllImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.CATCH_START_TAG)) {
activity = new CatchImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.COMPENSATESCOPE_START_TAG)) {
activity = new CompensateScopeImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.COMPENSATE_START_TAG)) {
activity = new CompensateImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.COMPENSATIONHANDLER_START_TAG)) {
activity = new CompensationHandlerImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ELSEIF_START_TAG)) {
activity = new ElseIfImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ELSE_START_TAG)) {
activity = new ElseImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.EVENTHANDLER_START_TAG)) {
activity = new EventHandlerImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.EXIT_START_TAG)) {
activity = new ExitImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.FAULTHANDLER_START_TAG)) {
activity = new FaultHandlerImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.FLOW_START_TAG)) {
activity = new FlowImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.FOREACH_START_TAG)) {
activity = new ForEachImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.IF_START_TAG)) {
activity = new IfImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.INVOKE_START_TAG)) {
activity = new InvokeImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ONALARM_START_TAG)) {
activity = new OnAlarmImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ONEVENT_START_TAG)) {
activity = new OnEventImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.ONMESSAGE_START_TAG)) {
activity = new OnMessageImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.PICK_START_TAG)) {
activity = new PickImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.PROCESS_START_TAG)) {
activity = new ProcessImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.RECEIVE_START_TAG)) {
activity = new ReceiveImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.REPEATUNTIL_START_TAG)) {
activity = new RepeatUntilImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.REPLY_START_TAG)) {
activity = new ReplyImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.RETHROW_START_TAG)) {
activity = new ReThrowImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.SCOPE_START_TAG)) {
activity = new ScopeImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.SEQUENCE_START_TAG)) {
activity = new SequenceImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.SOURCE_START_TAG)) {
// source
activity = new SourceImpl(tmpElement, this);
if (activity.getAttributes().get(0).getAttribute().equals("linkName")) {
if (links.containsKey(activity.getAttributes().get(0).getValue())) {
// if a entry for the particular link name already exists
links.get(activity.getAttributes().get(0).getValue()).setSource(this.parent);
} else {
// if the link name doesnot exist i.e. if the link is a new link
// Create a new Link object
Link link = new Link();
// Set the source(Start activity) as the parent activity
link.setSource(this.parent);
links.put(activity.getAttributes().get(0).getValue(), link);
}
// Add the parent activity of the activity to the source-list
sources.add(this.parent);
}
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.SOURCES_START_TAG)) {
activity = new SourcesImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.TARGET_START_TAG)) {
// target;
activity = new TargetImpl(tmpElement, this);
if (activity.getAttributes().get(0).getAttribute().equals("linkName")) {
if (links.containsKey(activity.getAttributes().get(0).getValue())) {
// if a entry for the particular link name already exists
links.get(activity.getAttributes().get(0).getValue()).setTarget(this.parent);
} else {
// if the link name doesnot exist i.e. if the link is a new link
// Create a new Link object
Link link = new Link();
// Set the target(End activity) as the parent activity
link.setTarget(this.parent);
links.put(activity.getAttributes().get(0).getValue(), link);
}
// Add the parent activity of the activity to the target-list
targets.add(this.parent);
}
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.TARGETS_START_TAG)) {
activity = new TargetsImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.TERMINATIONHANDLER_START_TAG)) {
activity = new TerminationHandlerImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.THROW_START_TAG)) {
activity = new ThrowImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.WAIT_START_TAG)) {
activity = new WaitImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(BPEL2SVGFactory.WHILE_START_TAG)) {
activity = new WhileImpl(tmpElement, this);
} else if (tmpElement.getLocalName().equals(getEndTag())) {
break;
} else {
continue;
}
// Set the link properties i.e. the link name, source of the link and the target of the link
activity.setLinkProperties(links, sources, targets);
// Add the activity to the subActivities list
subActivities.add(activity);
// Checks if the activity has any child activities
if (tmpElement.getChildElements().hasNext()) {
// The child activities are processed again by invoking the same method recursively
ActivityInterface replyActivity = activity.processSubActivities(tmpElement);
if (replyActivity != null) {
subActivities.add(replyActivity);
}
}
if (tmpElement.getLocalName().equals(BPEL2SVGFactory.PROCESS_START_TAG)) {
break;
}
}
}
return endActivity;
}
use of org.wso2.carbon.bpel.core.ode.integration.jmx.Processes in project carbon-business-process by wso2.
the class PNGGenarateServlet method processRequest.
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Log log = LogFactory.getLog(PNGGenarateServlet.class);
HttpSession session = request.getSession(true);
String pid = CharacterEncoder.getSafeText(request.getParameter("pid"));
ServletConfig config = getServletConfig();
String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
ConfigurationContext configContext = (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
String processDef;
ProcessManagementServiceClient client;
SVGInterface svg;
String svgStr;
try {
client = new ProcessManagementServiceClient(cookie, backendServerURL, configContext, request.getLocale());
// Gets the bpel process definition needed to create the SVG from the processId
processDef = client.getProcessInfo(QName.valueOf(pid)).getDefinitionInfo().getDefinition().getExtraElement().toString();
BPELInterface bpel = new BPELImpl();
// Converts the bpel process definition to an omElement which is how the AXIS2 Object Model (AXIOM)
// represents an XML document
OMElement bpelStr = bpel.load(processDef);
/**
* Process the OmElement containing the bpel process definition
* Process the subactivites of the bpel process by iterating through the omElement
*/
bpel.processBpelString(bpelStr);
// Create a new instance of the LayoutManager for the bpel process
LayoutManager layoutManager = BPEL2SVGFactory.getInstance().getLayoutManager();
// Set the layout of the SVG to vertical
layoutManager.setVerticalLayout(true);
// Get the root activity i.e. the Process Activity
layoutManager.layoutSVG(bpel.getRootActivity());
svg = new SVGImpl();
// Set the root activity of the SVG i.e. the Process Activity
svg.setRootActivity(bpel.getRootActivity());
// Set the content type of the HTTP response as "image/png"
response.setContentType("image/png");
// Create an instance of ServletOutputStream to write the output
ServletOutputStream sos = response.getOutputStream();
// Convert the image as a byte array of a PNG
byte[] pngBytes = svg.toPNGBytes();
// stream to write binary data into the response
sos.write(pngBytes);
sos.flush();
sos.close();
} catch (ProcessManagementException e) {
log.error("PNG Generation Error", e);
}
}
Aggregations