All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ow2.petals.ant.task.DeployServiceAssemblyTask Maven / Gradle / Ivy

There is a newer version: 2.9.0
Show newest version
/**
 * Copyright (c) 2005-2012 EBM WebSourcing, 2012-2016 Linagora
 * 
 * This program/library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or (at your
 * option) any later version.
 * 
 * This program/library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program/library; If not, see http://www.gnu.org/licenses/
 * for the GNU Lesser General Public License version 2.1.
 */
package org.ow2.petals.ant.task;

import java.net.URL;
import java.util.regex.Matcher;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.LogLevel;
import org.ow2.petals.ant.AbstractInstallerAntTask;

/**
 * Ant task : jbi-deploy-service-assembly.
 * 

* This task deploys a service assembly into the JBI environment. *

* * @author ddesjardins - EBM WebSourcing * @author Christophe Hamerling - EBM WebSourcing * @author Christophe DENEUX - Linagora */ public class DeployServiceAssemblyTask extends AbstractInstallerAntTask { /** * Fail on component error */ protected boolean failOnComponentError = false; /** * Creates a new instance of {@link DeployServiceAssemblyTask} * */ public DeployServiceAssemblyTask() { super(); } @Override public void doTask() throws Exception { final URL fileURL = this.validateFileParameter(); final String serviceAssemblyReport = this.getJMXClient().getDeploymentServiceClient().deploy(fileURL); boolean isSUfailed = false; final Matcher suMatcher = DeployServiceAssemblyTask.suResultpattern.matcher(serviceAssemblyReport); while (suMatcher.find()) { isSUfailed = true; this.log("Failed to deploy SU '" + suMatcher.group(1) + "':\n" + suMatcher.group(2), LogLevel.WARN.getLevel()); } final boolean isTaskFailed = isSUfailed && this.failOnComponentError; if (isTaskFailed) { throw new BuildException("Failed to deploy Service Assembly '" + fileURL.toString() + "'"); } else { final Matcher saMatcher = DeployServiceAssemblyTask.saNamepattern.matcher(serviceAssemblyReport); if (saMatcher.find()) { if ("success".equalsIgnoreCase(saMatcher.group(1))) { if (isSUfailed) { this.log("Service assembly '" + saMatcher.group(2) + "' deployed with some SU deployment in failure", LogLevel.WARN.getLevel()); } else { this.log("Service Assembly '" + saMatcher.group(2) + "' deployed"); } } else { this.log("Failed to deploy Service Assembly '" + saMatcher.group(2) + "'", LogLevel.ERR.getLevel()); } } } } /** * @param failOnComponentError * the failOnComponentError to set */ public void setFailOnComponentError(final boolean failOnComponentError) { this.failOnComponentError = failOnComponentError; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy