Search in sources :

Example 1 with GogoBundleDeployer

use of com.liferay.ide.server.core.gogo.GogoBundleDeployer in project liferay-ide by liferay.

the class PortalServerBehavior method startOrStopModules.

private void startOrStopModules(IModule[] modules, String action, IProgressMonitor monitor) {
    for (IModule module : modules) {
        IProject project = module.getProject();
        if (project == null) {
            continue;
        }
        final IBundleProject bundleProject = LiferayCore.create(IBundleProject.class, project);
        if (bundleProject != null) {
            try {
                final String symbolicName = bundleProject.getSymbolicName();
                GogoBundleDeployer helper = new GogoBundleDeployer();
                long bundleId = helper.getBundleId(symbolicName);
                if (bundleId > 0) {
                    if (action.equals("start")) {
                        String error = helper.start(bundleId);
                        if (error == null) {
                            setModuleState(new IModule[] { module }, IServer.STATE_STARTED);
                        } else {
                            LiferayServerCore.logError("Unable to start this bundle");
                        }
                    } else if (action.equals("stop")) {
                        String error = helper.stop(bundleId);
                        if (error == null) {
                            setModuleState(new IModule[] { module }, IServer.STATE_STOPPED);
                        } else {
                            LiferayServerCore.logError("Unable to stop this bundle");
                        }
                    }
                }
            } catch (Exception e) {
                LiferayServerCore.logError("Unable to " + action + " module", e);
            }
        }
    }
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IBundleProject(com.liferay.ide.core.IBundleProject) GogoBundleDeployer(com.liferay.ide.server.core.gogo.GogoBundleDeployer) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException)

Example 2 with GogoBundleDeployer

use of com.liferay.ide.server.core.gogo.GogoBundleDeployer in project liferay-ide by liferay.

the class BundlePublishFullAdd method remoteDeploy.

private IStatus remoteDeploy(String bsn, IPath output) {
    IStatus retval = null;
    if (FileUtil.exists(output)) {
        GogoBundleDeployer bundleDeployer = null;
        try {
            bundleDeployer = createBundleDeployer();
            BundleDTO deployed = bundleDeployer.deploy(bsn, output.toFile(), getBundleUrl(output.toFile(), bsn));
            if (deployed instanceof BundleDTOWithStatus) {
                BundleDTOWithStatus withStatus = (BundleDTOWithStatus) deployed;
                retval = LiferayServerCore.error("Problem with deploying bundle: " + withStatus._status);
            } else {
                retval = new Status(IStatus.OK, LiferayServerCore.PLUGIN_ID, (int) deployed.id, null, null);
            }
        } catch (Exception e) {
            retval = LiferayServerCore.error("Unable to deploy bundle remotely " + output.toPortableString(), e);
        }
    } else {
        retval = LiferayServerCore.error("Unable to deploy bundle remotely " + output.toPortableString());
    }
    return retval;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus) GogoBundleDeployer(com.liferay.ide.server.core.gogo.GogoBundleDeployer) BundleDTO(org.osgi.framework.dto.BundleDTO) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException)

Example 3 with GogoBundleDeployer

use of com.liferay.ide.server.core.gogo.GogoBundleDeployer in project liferay-ide by liferay.

the class ServiceCommand method execute.

public ServiceContainer execute() throws Exception {
    GogoBundleDeployer bundleDeployer = null;
    ServiceContainer result;
    if (_server == null) {
        return _getServiceFromTargetPlatform();
    }
    PortalServerBehavior serverBehavior = (PortalServerBehavior) _server.loadAdapter(PortalServerBehavior.class, null);
    bundleDeployer = serverBehavior.createBundleDeployer();
    if (bundleDeployer == null) {
        return _getServiceFromTargetPlatform();
    }
    if (_serviceName == null) {
        String[] services = _getServices(bundleDeployer);
        result = new ServiceContainer(Arrays.asList(services));
    } else {
        String[] serviceBundle = _getServiceBundle(_serviceName, bundleDeployer);
        result = new ServiceContainer(serviceBundle[0], serviceBundle[1], serviceBundle[2]);
    }
    return result;
}
Also used : PortalServerBehavior(com.liferay.ide.server.core.portal.PortalServerBehavior) GogoBundleDeployer(com.liferay.ide.server.core.gogo.GogoBundleDeployer)

Example 4 with GogoBundleDeployer

use of com.liferay.ide.server.core.gogo.GogoBundleDeployer in project liferay-ide by liferay.

the class BundlePublishFullRemove method remoteUninstall.

private IStatus remoteUninstall(IBundleProject bundleProject, String symbolicName, IProgressMonitor monitor) throws CoreException {
    // TODO we should get bsn first and try use the bsn to uninstall
    IStatus retval = null;
    IPath outputJar = bundleProject.getOutputBundlePath();
    GogoBundleDeployer bundleDeployer = null;
    try {
        bundleDeployer = createBundleDeployer();
        String error = bundleDeployer.uninstall(bundleProject, outputJar);
        if (error == null) {
            retval = Status.OK_STATUS;
        } else {
            retval = LiferayServerCore.error("Unable to uninstall bundle " + error);
        }
    } catch (Exception e) {
        retval = LiferayServerCore.error("Unable to uninstall bundle " + symbolicName, e);
    }
    if (retval == null) {
        retval = Status.OK_STATUS;
    }
    return retval;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) GogoBundleDeployer(com.liferay.ide.server.core.gogo.GogoBundleDeployer) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

GogoBundleDeployer (com.liferay.ide.server.core.gogo.GogoBundleDeployer)4 CoreException (org.eclipse.core.runtime.CoreException)3 IOException (java.io.IOException)2 IStatus (org.eclipse.core.runtime.IStatus)2 IBundleProject (com.liferay.ide.core.IBundleProject)1 PortalServerBehavior (com.liferay.ide.server.core.portal.PortalServerBehavior)1 MalformedURLException (java.net.MalformedURLException)1 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 Status (org.eclipse.core.runtime.Status)1 IModule (org.eclipse.wst.server.core.IModule)1 BundleDTO (org.osgi.framework.dto.BundleDTO)1