use of org.eclipse.jst.server.core.IWebModule 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.IWebModule in project webtools.servertools by eclipse.
the class AntPublisher method guessContextRoot.
private String guessContextRoot(IModule module) {
String moduleName = guessModuleName(module);
String contextRoot = moduleName;
if ("jst.web".equals(getModuleTypeId())) {
// $NON-NLS-1$
IWebModule webModule = (IWebModule) getModule()[0].loadAdapter(IWebModule.class, null);
if (webModule != null) {
contextRoot = webModule.getContextRoot();
if (contextRoot == null || contextRoot.length() == 0) {
contextRoot = moduleName;
}
}
}
return contextRoot;
}
use of org.eclipse.jst.server.core.IWebModule in project webtools.servertools by eclipse.
the class AntPublisher method guessModuleName.
private String guessModuleName(IModule module) {
String deployName = ServerUtil.getModuleDisplayName(module);
if ("jst.web".equals(getModuleTypeId())) {
// $NON-NLS-1$
IWebModule webModule = (IWebModule) getModule()[0].loadAdapter(IWebModule.class, null);
if (webModule == null) {
return deployName;
}
String contextRoot = webModule.getURI(module);
deployName = contextRoot.substring(0, contextRoot.lastIndexOf('.'));
}
return deployName;
}
use of org.eclipse.jst.server.core.IWebModule in project webtools.servertools by eclipse.
the class GenericServer method getModuleRootURL.
/* (non-Javadoc)
* @see org.eclipse.wtp.server.core.model.IURLProvider#getModuleRootURL(org.eclipse.wtp.server.core.model.IModule)
*/
public URL getModuleRootURL(IModule module) {
try {
if (module == null || module.loadAdapter(IWebModule.class, null) == null)
return null;
IWebModule webModule = (IWebModule) module.loadAdapter(IWebModule.class, null);
String host = getServer().getHost();
// $NON-NLS-1$
String url = "http://" + host;
int port = 0;
port = getHttpPort();
// $NON-NLS-1$
port = ServerUtil.getMonitoredPort(getServer(), port, "web");
if (port != 80)
// $NON-NLS-1$
url += ":" + port;
String ctxRoot = webModule.getContextRoot();
if (!ctxRoot.startsWith("/")) {
// $NON-NLS-1$
url += '/';
}
url += webModule.getContextRoot();
if (// $NON-NLS-1$
!url.endsWith("/"))
// $NON-NLS-1$
url += "/";
return new URL(url);
} catch (Exception e) {
// $NON-NLS-1$
Trace.trace("Could not get root URL", e);
return null;
}
}
use of org.eclipse.jst.server.core.IWebModule in project webtools.servertools by eclipse.
the class J2EEUtil method getWebModules.
/**
* Returns the web modules that the utility module is contained within.
*
* @param module a utility module
* @param monitor a progress monitor, or <code>null</code> if progress
* reporting and cancellation are not desired
* @return a possibly empty array of web modules
*/
public static IModule[] getWebModules(IModule module, IProgressMonitor monitor) {
if (shouldUseCache()) {
List<IModule> list = webCache.get(module);
if (list == null)
return EMPTY_LIST;
return list.toArray(new IModule[list.size()]);
}
List<IModule> list = new ArrayList<IModule>();
IModule[] modules = ServerUtil.getModules(WEB_MODULE);
if (modules != null) {
for (IModule module2 : modules) {
IWebModule web = (IWebModule) module2.loadAdapter(IWebModule.class, monitor);
if (web != null) {
IModule[] modules2 = web.getModules();
if (modules2 != null) {
for (IModule m : modules2) {
if (module.equals(m))
list.add(module2);
}
}
}
}
}
return list.toArray(new IModule[list.size()]);
}
Aggregations