Search in sources :

Example 6 with IBundleProject

use of com.liferay.ide.core.IBundleProject in project liferay-ide by liferay.

the class PortalPublishTask method getTasks.

@SuppressWarnings("rawtypes")
public PublishOperation[] getTasks(IServer server, int kind, List modules, List kindList) {
    List<BundlePublishOperation> tasks = new ArrayList<BundlePublishOperation>();
    PortalServerBehavior serverBehavior = (PortalServerBehavior) server.loadAdapter(PortalServerBehavior.class, null);
    if (ListUtil.isNotEmpty(modules)) {
        final int size = modules.size();
        for (int i = 0; i < size; i++) {
            IModule[] module = (IModule[]) modules.get(i);
            Integer deltaKind = (Integer) kindList.get(i);
            boolean needClean = false;
            IModuleResourceDelta[] deltas = ((Server) server).getPublishedResourceDelta(module);
            for (IModuleResourceDelta delta : deltas) {
                final IModuleResource resource = delta.getModuleResource();
                final IFile resourceFile = (IFile) resource.getAdapter(IFile.class);
                if (resourceFile != null && resourceFile.getName().equals("bnd.bnd")) {
                    needClean = true;
                    break;
                }
            }
            switch(kind) {
                case IServer.PUBLISH_FULL:
                case IServer.PUBLISH_INCREMENTAL:
                case IServer.PUBLISH_AUTO:
                    final IProject project = module[0].getProject();
                    switch(deltaKind) {
                        case ServerBehaviourDelegate.ADDED:
                            addOperation(BundlePublishFullAddCleanBuild.class, tasks, server, module);
                            break;
                        case ServerBehaviourDelegate.CHANGED:
                            if (needClean) {
                                addOperation(BundlePublishFullAddCleanBuild.class, tasks, server, module);
                            } else {
                                addOperation(BundlePublishFullAdd.class, tasks, server, module);
                            }
                            break;
                        case ServerBehaviourDelegate.REMOVED:
                            addOperation(BundlePublishFullRemove.class, tasks, server, module);
                            break;
                        case ServerBehaviourDelegate.NO_CHANGE:
                            final IBundleProject bundleProject = LiferayCore.create(IBundleProject.class, project);
                            if (bundleProject != null) {
                                try {
                                    if (isUserRedeploy(serverBehavior, module[0]) || !isDeployed(server, serverBehavior, bundleProject.getSymbolicName())) {
                                        addOperation(BundlePublishFullAddCleanBuild.class, tasks, server, module);
                                    }
                                } catch (CoreException e) {
                                    LiferayServerCore.logError("Unable to get bsn for project " + project.getName(), e);
                                }
                            }
                            break;
                        default:
                            break;
                    }
                    break;
                default:
                    break;
            }
        }
    }
    return tasks.toArray(new PublishOperation[0]);
}
Also used : IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) IModule(org.eclipse.wst.server.core.IModule) IFile(org.eclipse.core.resources.IFile) IServer(org.eclipse.wst.server.core.IServer) Server(org.eclipse.wst.server.core.internal.Server) IBundleProject(com.liferay.ide.core.IBundleProject) ArrayList(java.util.ArrayList) IModuleResourceDelta(org.eclipse.wst.server.core.model.IModuleResourceDelta) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException)

Example 7 with IBundleProject

use of com.liferay.ide.core.IBundleProject in project liferay-ide by liferay.

the class PortalServerBehavior method canRestartModule.

@Override
public boolean canRestartModule(IModule[] modules) {
    for (IModule module : modules) {
        IProject project = module.getProject();
        if (project == null) {
            return false;
        }
        final IBundleProject bundleProject = LiferayCore.create(IBundleProject.class, project);
        if (bundleProject != null && !bundleProject.isFragmentBundle()) {
            return true;
        }
    }
    return false;
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IBundleProject(com.liferay.ide.core.IBundleProject) IProject(org.eclipse.core.resources.IProject)

Example 8 with IBundleProject

use of com.liferay.ide.core.IBundleProject 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 9 with IBundleProject

use of com.liferay.ide.core.IBundleProject in project liferay-ide by liferay.

the class BundlePublishFullRemove method execute.

@Override
public void execute(IProgressMonitor monitor, IAdaptable info) throws CoreException {
    for (IModule module : modules) {
        IProject project = module.getProject();
        if (project == null) {
            continue;
        }
        IStatus status = Status.OK_STATUS;
        final IBundleProject bundleProject = LiferayCore.create(IBundleProject.class, project);
        if (bundleProject != null) {
            final String symbolicName = bundleProject.getSymbolicName();
            if (this.server.getServerState() == IServer.STATE_STARTED) {
                monitor.subTask("Remotely undeploying " + module.getName() + " from Liferay module framework...");
                status = remoteUninstall(bundleProject, symbolicName, monitor);
            }
            if (status != null && status.isOK()) {
                this.portalServerBehavior.setModulePublishState2(new IModule[] { module }, IServer.PUBLISH_STATE_NONE);
                project.deleteMarkers(LiferayServerCore.BUNDLE_OUTPUT_ERROR_MARKER_TYPE, false, 0);
            }
        } else {
            status = LiferayServerCore.error("Could not get module publisher for project " + module.getProject().getName());
        }
        if (!status.isOK()) {
            throw new CoreException(status);
        }
    }
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IStatus(org.eclipse.core.runtime.IStatus) IBundleProject(com.liferay.ide.core.IBundleProject) CoreException(org.eclipse.core.runtime.CoreException) IProject(org.eclipse.core.resources.IProject)

Example 10 with IBundleProject

use of com.liferay.ide.core.IBundleProject in project liferay-ide by liferay.

the class MavenModuleProjectTests method testProjectTemplateServiceBuilder.

@Test
public void testProjectTemplateServiceBuilder() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("service-builder-test");
    op.setProjectProvider("maven-module");
    op.setProjectTemplateName("service-builder");
    op.setPackageName("com.liferay.test");
    IProject parent = create(op);
    assertTrue(parent != null && parent.exists());
    IProject api = CoreUtil.getProject("service-builder-test-api");
    assertTrue(api != null && api.exists());
    IProject service = CoreUtil.getProject("service-builder-test-service");
    assertTrue(service != null && service.exists());
    IProjectBuilder builder = LiferayCore.create(IProjectBuilder.class, service);
    builder.buildService(monitor);
    api.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
    service.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
    IBundleProject apiBundle = LiferayCore.create(IBundleProject.class, api);
    assertNotNull(apiBundle);
    IPath apiOutput = apiBundle.getOutputBundle(true, monitor);
    assertNotNull(apiOutput);
    assertTrue(apiOutput.toFile().exists());
    assertEquals("service-builder-test-api-1.0.0.jar", apiOutput.lastSegment());
    IBundleProject serviceBundle = LiferayCore.create(IBundleProject.class, service);
    IPath serviceOutput = serviceBundle.getOutputBundle(true, monitor);
    assertNotNull(serviceOutput);
    assertTrue(serviceOutput.toFile().exists());
    assertEquals("service-builder-test-service-1.0.0.jar", serviceOutput.lastSegment());
}
Also used : IBundleProject(com.liferay.ide.core.IBundleProject) IPath(org.eclipse.core.runtime.IPath) NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) IProjectBuilder(com.liferay.ide.project.core.IProjectBuilder) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Aggregations

IBundleProject (com.liferay.ide.core.IBundleProject)18 IProject (org.eclipse.core.resources.IProject)11 IPath (org.eclipse.core.runtime.IPath)8 Test (org.junit.Test)7 IModule (org.eclipse.wst.server.core.IModule)6 NewLiferayModuleProjectOp (com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp)5 CoreException (org.eclipse.core.runtime.CoreException)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 ArrayList (java.util.ArrayList)3 IOException (java.io.IOException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 IServer (org.eclipse.wst.server.core.IServer)2 IModuleResource (org.eclipse.wst.server.core.model.IModuleResource)2 ILiferayProject (com.liferay.ide.core.ILiferayProject)1 LiferayGradleProject (com.liferay.ide.gradle.core.LiferayGradleProject)1 IProjectBuilder (com.liferay.ide.project.core.IProjectBuilder)1 PluginsSDKBundleProject (com.liferay.ide.project.core.PluginsSDKBundleProject)1 SDK (com.liferay.ide.sdk.core.SDK)1 GogoBundleDeployer (com.liferay.ide.server.core.gogo.GogoBundleDeployer)1