/** * Checks if the supplied properties are valid * * @param userEngineUrl * @return * @throws DeploymentException */ private boolean checkProperties(final ParameterType<String> userEngineUrl) throws DeploymentException { if (!userEngineUrl.hasValue()) { throw new DeploymentException("Invalid parameter " + yawlEngineUrl.getName()); } try { new URL(userEngineUrl.getValue()); } catch (MalformedURLException e) { throw new DeploymentException("Invalid URL: ", e); } return true; }
/* * (non-Javadoc) * * @see org.apromore.plugin.deployment.DeploymentPlugin#deployProcess(org.apromore.cpf.CanonicalProcessType, org.apromore.anf.AnnotationsType) */ @Override public PluginResult deployProcess( final CanonicalProcessType canonicalProcess, final AnnotationsType annotation, final PluginRequest request) throws DeploymentException, PluginPropertyNotFoundException { ParameterType<String> userEngineUrl = request.getRequestParameter(yawlEngineUrl); ParameterType<String> userUsername = request.getRequestParameter(yawlEngineUsername); ParameterType<String> userPassword = request.getRequestParameter(yawlEnginePassword); ParameterType<Boolean> doAutoLaunch = request.getRequestParameter(autoLaunch); checkProperties(userEngineUrl); PluginResultImpl pluginResult = newPluginResult(); YAWLEngineClient yawlEngineClient = engineClientFactory.newInstance( userEngineUrl.getValue(), userUsername.getValue(), userPassword.getValue()); Node connectResponse = yawlEngineClient.connectToYAWL(); if (connectResponse.getNodeName().equals("failure")) { throw new DeploymentException( "Could not connect to YAWL engine. Reason: " + connectResponse.getTextContent()); } else { try { String sessionHandle = connectResponse.getTextContent(); if (sessionHandle != null) { String yawlSpec = deCanoniseYAWL(canonicalProcess, annotation); Node uploadResponse = yawlEngineClient.uploadYAWLSpecification(yawlSpec, sessionHandle); if (uploadResponse.getNodeName().equals("failure")) { pluginResult.addPluginMessage( "Failure deploying process {0}", canonicalProcess.getName()); if (uploadResponse.getChildNodes().getLength() > 0) { Node reasonNode = uploadResponse.getChildNodes().item(0); for (int i = 0; i < reasonNode.getChildNodes().getLength(); i++) { convertToPluginMessage(pluginResult, reasonNode.getChildNodes().item(i)); } } } else { if (uploadResponse.getTextContent().isEmpty()) { pluginResult.addPluginMessage( "Process {0} successfully deployed.", canonicalProcess.getName(), uploadResponse.getTextContent()); if (doAutoLaunch.getValue()) { doAutoLaunch(); } } else { pluginResult.addPluginMessage( "YAWL Engine message: {0}", uploadResponse.getTextContent()); } } } else { throw new DeploymentException( "Could not connect to YAWL engine. Invalid Session Handle returned!"); } } catch (CanoniserException e) { throw new DeploymentException("Could not deCanonise to YAWL", e); } } return pluginResult; }