use of org.eclipse.jst.server.core.IJ2EEModule in project liferay-ide by liferay.
the class LiferayPublishOperation method execute.
/**
* @see PublishOperation#execute(IProgressMonitor, IAdaptable)
*/
public void execute(IProgressMonitor monitor, IAdaptable info) throws CoreException {
List status = new ArrayList();
// If parent web module
if (module.length == 1) {
if (!ServerUtil.isExtProject(module[0].getProject())) {
publishDir(module[0], status, monitor);
}
} else // Else a child module
{
Properties p = server.loadModulePublishLocations();
// Try to determine the URI for the child module
IWebModule webModule = (IWebModule) module[0].loadAdapter(IWebModule.class, monitor);
String childURI = null;
if (webModule != null) {
childURI = webModule.getURI(module[1]);
}
// Try to determine if child is binary
IJ2EEModule childModule = (IJ2EEModule) module[1].loadAdapter(IJ2EEModule.class, monitor);
boolean isBinary = false;
if (childModule != null) {
isBinary = childModule.isBinary();
}
if (isBinary) {
publishArchiveModule(childURI, p, status, monitor);
} else {
publishJar(childURI, p, status, monitor);
}
server.saveModulePublishLocations(p);
}
throwException(status);
server.setModulePublishState2(module, IServer.PUBLISH_STATE_NONE);
}
use of org.eclipse.jst.server.core.IJ2EEModule in project webtools.servertools by eclipse.
the class EarModuleAssembler method assemble.
public IPath assemble(IProgressMonitor monitor) throws CoreException {
// copy ear root to the temporary assembly directory
IPath parent = fAssembleRoot;
final IModule[] rootMod = { fModule };
boolean shouldCopy = (IServer.PUBLISH_STATE_NONE != fServer.getServer().getModulePublishState(rootMod));
if (shouldCopy)
copyModule(fModule, monitor);
IEnterpriseApplication earModule = (IEnterpriseApplication) fModule.loadAdapter(IEnterpriseApplication.class, monitor);
IModule[] childModules = earModule.getModules();
for (int i = 0; i < childModules.length; i++) {
IModule module = childModules[i];
String uri = earModule.getURI(module);
if (uri == null) {
// The bad memories of WTP 1.0
// $NON-NLS-1$
IStatus status = new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, "unable to assemble module null uri", null);
throw new CoreException(status);
}
IJ2EEModule jeeModule = (IJ2EEModule) module.loadAdapter(IJ2EEModule.class, monitor);
if (jeeModule != null && jeeModule.isBinary()) {
// Binary module
// just copy
ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
IModuleResource[] resources = pm.members();
publishHelper.publishToPath(resources, parent.append(uri), monitor);
// done! no need to go further
continue;
}
if (shouldRepack(module)) {
packModule(module, uri, parent);
}
}
return parent;
}
use of org.eclipse.jst.server.core.IJ2EEModule in project webtools.servertools by eclipse.
the class TomcatServerBehaviour method publishModule.
/*
* Publishes the given module to the server.
*/
protected void publishModule(int kind, int deltaKind, IModule[] moduleTree, IProgressMonitor monitor) throws CoreException {
if (getServer().getServerState() != IServer.STATE_STOPPED) {
if (deltaKind == ServerBehaviourDelegate.ADDED || deltaKind == ServerBehaviourDelegate.REMOVED)
setServerRestartState(true);
}
if (getTomcatServer().isTestEnvironment())
return;
Properties p = loadModulePublishLocations();
PublishHelper helper = new PublishHelper(getRuntimeBaseDirectory().append("temp").toFile());
// If parent web module
if (moduleTree.length == 1) {
publishDir(deltaKind, p, moduleTree, helper, monitor);
} else // Else a child module
{
// Try to determine the URI for the child module
IWebModule webModule = (IWebModule) moduleTree[0].loadAdapter(IWebModule.class, monitor);
String childURI = null;
if (webModule != null) {
childURI = webModule.getURI(moduleTree[1]);
}
// Try to determine if child is binary
IJ2EEModule childModule = (IJ2EEModule) moduleTree[1].loadAdapter(IJ2EEModule.class, monitor);
boolean isBinary = false;
if (childModule != null) {
isBinary = childModule.isBinary();
}
if (isBinary) {
publishArchiveModule(childURI, kind, deltaKind, p, moduleTree, helper, monitor);
} else {
publishJar(childURI, kind, deltaKind, p, moduleTree, helper, monitor);
}
}
setModulePublishState(moduleTree, IServer.PUBLISH_STATE_NONE);
saveModulePublishLocations(p);
}
use of org.eclipse.jst.server.core.IJ2EEModule in project webtools.servertools by eclipse.
the class TomcatServerBehaviour method publishDir.
/**
* Publish a web module.
*
* @param deltaKind
* @param p
* @param module
* @param monitor
* @throws CoreException
*/
private void publishDir(int deltaKind, Properties p, IModule[] module, PublishHelper helper, IProgressMonitor monitor) throws CoreException {
List<IStatus> status = new ArrayList<IStatus>();
// Remove if requested or if previously published and are now serving without publishing
if (deltaKind == REMOVED || getTomcatServer().isServeModulesWithoutPublish()) {
String publishPath = (String) p.get(module[0].getId());
if (publishPath != null) {
try {
File f = new File(publishPath);
if (f.exists()) {
IStatus[] stat = PublishHelper.deleteDirectory(f, monitor);
PublishOperation2.addArrayToList(status, stat);
}
} catch (Exception e) {
throw new CoreException(new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishCouldNotRemoveModule, module[0].getName()), e));
}
p.remove(module[0].getId());
}
} else {
IPath path = getModuleDeployDirectory(module[0]);
IModuleResource[] mr = getResources(module);
IPath[] jarPaths = null;
IWebModule webModule = (IWebModule) module[0].loadAdapter(IWebModule.class, monitor);
IModule[] childModules = getServer().getChildModules(module, monitor);
if (childModules != null && childModules.length > 0) {
jarPaths = new IPath[childModules.length];
for (int i = 0; i < childModules.length; i++) {
if (webModule != null) {
jarPaths[i] = new Path(webModule.getURI(childModules[i]));
} else {
IJ2EEModule childModule = (IJ2EEModule) childModules[i].loadAdapter(IJ2EEModule.class, monitor);
if (childModule != null && childModule.isBinary()) {
jarPaths[i] = new Path("WEB-INF/lib").append(childModules[i].getName());
} else {
jarPaths[i] = new Path("WEB-INF/lib").append(childModules[i].getName() + ".jar");
}
}
}
}
IStatus[] stat = helper.publishSmart(mr, path, jarPaths, monitor);
PublishOperation2.addArrayToList(status, stat);
p.put(module[0].getId(), path.toOSString());
}
PublishOperation2.throwException(status);
}
use of org.eclipse.jst.server.core.IJ2EEModule in project webtools.servertools by eclipse.
the class WarModuleAssembler method assemble.
public IPath assemble(IProgressMonitor monitor) throws CoreException {
IPath parent = copyModule(fModule, monitor);
IWebModule webModule = (IWebModule) fModule.loadAdapter(IWebModule.class, monitor);
IModule[] childModules = webModule.getModules();
for (int i = 0; i < childModules.length; i++) {
IModule module = childModules[i];
String uri = webModule.getURI(module);
if (uri == null) {
// The bad memories of WTP 1.0
// $NON-NLS-1$
IStatus status = new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, "unable to assemble module null uri", null);
throw new CoreException(status);
}
IJ2EEModule jeeModule = (IJ2EEModule) module.loadAdapter(IJ2EEModule.class, monitor);
if (jeeModule != null && jeeModule.isBinary()) {
// Binary module
ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
IModuleResource[] resources = pm.members();
publishHelper.publishToPath(resources, parent.append(uri), monitor);
} else {
// Project module
packModule(module, uri, parent);
}
}
return parent;
}
Aggregations