Search in sources :

Example 1 with IWebModule

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);
}
Also used : IJ2EEModule(org.eclipse.jst.server.core.IJ2EEModule) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IWebModule(org.eclipse.jst.server.core.IWebModule) Properties(java.util.Properties)

Example 2 with IWebModule

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;
}
Also used : IWebModule(org.eclipse.jst.server.core.IWebModule)

Example 3 with IWebModule

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;
}
Also used : IWebModule(org.eclipse.jst.server.core.IWebModule)

Example 4 with IWebModule

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;
    }
}
Also used : IWebModule(org.eclipse.jst.server.core.IWebModule) URL(java.net.URL) CoreException(org.eclipse.core.runtime.CoreException)

Example 5 with IWebModule

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()]);
}
Also used : IModule(org.eclipse.wst.server.core.IModule) ArrayList(java.util.ArrayList) IWebModule(org.eclipse.jst.server.core.IWebModule)

Aggregations

IWebModule (org.eclipse.jst.server.core.IWebModule)16 IJ2EEModule (org.eclipse.jst.server.core.IJ2EEModule)6 IModule (org.eclipse.wst.server.core.IModule)6 ArrayList (java.util.ArrayList)5 List (java.util.List)4 CoreException (org.eclipse.core.runtime.CoreException)4 Properties (java.util.Properties)3 IStatus (org.eclipse.core.runtime.IStatus)3 IOException (java.io.IOException)2 URL (java.net.URL)2 Status (org.eclipse.core.runtime.Status)2 WebModule (org.eclipse.jst.server.tomcat.core.internal.WebModule)2 IStaticWeb (org.eclipse.wst.server.core.util.IStaticWeb)2 File (java.io.File)1 IPath (org.eclipse.core.runtime.IPath)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)1 IEnterpriseApplication (org.eclipse.jst.server.core.IEnterpriseApplication)1 IMemento (org.eclipse.jst.server.preview.adapter.internal.IMemento)1 XMLMemento (org.eclipse.jst.server.preview.adapter.internal.XMLMemento)1