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]);
}
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;
}
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);
}
}
}
}
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);
}
}
}
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());
}
Aggregations