Search in sources :

Example 36 with ServerInstance

use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance in project webtools.servertools by eclipse.

the class XmlTestCase method testServerInstance1.

/**
 * Test behavior of ServerInstance
 */
public void testServerInstance1() {
    Server server = getXml40Server("serverxml.test1");
    assertNotNull(server);
    ServerInstance si = new ServerInstance(server, "nonexistent_service", null);
    assertNull(si.getService());
    assertEquals("Service \"nonexistent_service\" was not found.", si.getStatus().getMessage());
    si = new ServerInstance(server, null, null);
    assertNotNull(si.getService());
    assertEquals("Service", si.getService().getName());
    si = new ServerInstance(server, "Service", null);
    assertNotNull(si.getService());
    assertNull(si.getEngine());
    assertEquals("Engine element not found under Service \"Service\".", si.getStatus().getMessage());
}
Also used : Server(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server) ServerInstance(org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)

Example 37 with ServerInstance

use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance in project webtools.servertools by eclipse.

the class Tomcat40TestConfiguration method verifyPublishedModule.

protected void verifyPublishedModule(IPath baseDir, IModule module) throws Exception {
    Tomcat40TestConfiguration config = new Tomcat40TestConfiguration(null);
    config.load(baseDir.append("conf"), null);
    ServerInstance serverInstance = config.getServerInstance();
    Context context = serverInstance.getContext(module.getName());
    String deployDir = getTomcatServer().getDeployDirectory();
    if ("webapps".equals(deployDir)) {
        assertEquals(module.getName(), context.getDocBase());
    } else {
        assertEquals(getTomcatServerBehaviour().getModuleDeployDirectory(module).toOSString(), context.getDocBase());
    }
    verifyPublishedModuleFiles(module);
}
Also used : Context(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context) ServerInstance(org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)

Example 38 with ServerInstance

use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance in project webtools.servertools by eclipse.

the class Tomcat55TestConfiguration method verifyPublishedModule.

protected void verifyPublishedModule(IPath baseDir, IModule module) throws Exception {
    Tomcat55TestConfiguration config = new Tomcat55TestConfiguration(null);
    config.load(baseDir.append("conf"), null);
    ServerInstance serverInstance = config.getServerInstance();
    Context context = serverInstance.getContext(module.getName());
    String deployDir = getTomcatServer().getDeployDirectory();
    if ("webapps".equals(deployDir)) {
        assertEquals(module.getName(), context.getDocBase());
    } else {
        assertEquals(getTomcatServerBehaviour().getModuleDeployDirectory(module).toOSString(), context.getDocBase());
    }
    verifyPublishedModuleFiles(module);
}
Also used : Context(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context) ServerInstance(org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)

Example 39 with ServerInstance

use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance in project webtools.servertools by eclipse.

the class Tomcat60TestConfiguration method verifyPublishedModule.

protected void verifyPublishedModule(IPath baseDir, IModule module) throws Exception {
    Tomcat60TestConfiguration config = new Tomcat60TestConfiguration(null);
    config.load(baseDir.append("conf"), null);
    ServerInstance serverInstance = config.getServerInstance();
    Context context = serverInstance.getContext(module.getName());
    String deployDir = getTomcatServer().getDeployDirectory();
    if ("webapps".equals(deployDir)) {
        assertEquals(module.getName(), context.getDocBase());
    } else {
        assertEquals(getTomcatServerBehaviour().getModuleDeployDirectory(module).toOSString(), context.getDocBase());
    }
    verifyPublishedModuleFiles(module);
}
Also used : Context(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context) ServerInstance(org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)

Example 40 with ServerInstance

use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance in project liferay-ide by liferay.

the class LiferayTomcatUtil method ensurePortalIDEPropertiesExists.

private static File ensurePortalIDEPropertiesExists(IPath installPath, IPath configPath, IServer currentServer, ILiferayTomcatServer portalServer) {
    // $NON-NLS-1$
    IPath idePropertiesPath = installPath.append("../portal-ide.properties");
    // $NON-NLS-1$
    String hostName = "localhost";
    try {
        ServerInstance server = // $NON-NLS-1$
        TomcatVersionHelper.getCatalinaServerInstance(configPath.append("conf/server.xml"), null, null);
        hostName = server.getHost().getName();
    } catch (Exception e) {
        LiferayTomcatPlugin.logError(e);
    }
    // read portal-developer.properties
    // Properties devProps = new Properties();
    // IPath devPropertiesPath =
    // installPath.append("webapps/ROOT/WEB-INF/classes/portal-developer.properties");
    // if (devPropertiesPath.toFile().exists()) {
    // devProps.load(new FileReader(devPropertiesPath.toFile()));
    // }
    // if (idePropertiesPath.toFile().exists()) {
    // String value =
    // CoreUtil.readPropertyFileValue(idePropertiesPath.toFile(),
    // "auto.deploy.tomcat.conf.dir");
    // if (configPath.append("conf/Catalina/"+hostName).toFile().equals(new
    // File(value))) {
    // return;
    // }
    // }
    Properties props = new Properties();
    if (portalServer != null && portalServer.getServerMode() == ILiferayTomcatConstants.DEVELOPMENT_SERVER_MODE) {
        props.put("include-and-override", "portal-developer.properties");
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    props.put("com.liferay.portal.servlet.filters.etag.ETagFilter", "false");
    // $NON-NLS-1$ //$NON-NLS-2$
    props.put("com.liferay.portal.servlet.filters.header.HeaderFilter", "false");
    // $NON-NLS-1$ //$NON-NLS-2$
    props.put("json.service.auth.token.enabled", "false");
    // $NON-NLS-1$ //$NON-NLS-2$
    props.put("auto.deploy.tomcat.conf.dir", configPath.append("conf/Catalina/" + hostName).toOSString());
    if (currentServer != null && portalServer != null) {
        IPath runtimLocation = currentServer.getRuntime().getLocation();
        String autoDeployDir = portalServer.getAutoDeployDirectory();
        if (!ILiferayTomcatConstants.DEFAULT_AUTO_DEPLOYDIR.equals(autoDeployDir)) {
            IPath autoDeployDirPath = new Path(autoDeployDir);
            if (autoDeployDirPath.isAbsolute() && autoDeployDirPath.toFile().exists()) {
                // $NON-NLS-1$
                props.put("auto.deploy.deploy.dir", portalServer.getAutoDeployDirectory());
            } else {
                File autoDeployDirFile = new File(runtimLocation.toFile(), autoDeployDir);
                if (autoDeployDirFile.exists()) {
                    // $NON-NLS-1$
                    props.put("auto.deploy.deploy.dir", autoDeployDirFile.getPath());
                }
            }
        }
        // $NON-NLS-1$
        props.put("auto.deploy.interval", portalServer.getAutoDeployInterval());
    }
    // props.put( "json.service.public.methods", "*" );
    // $NON-NLS-1$ //$NON-NLS-2$
    props.put("jsonws.web.service.public.methods", "*");
    File file = idePropertiesPath.toFile();
    try {
        props.store(Files.newOutputStream(file.toPath()), null);
    } catch (Exception e) {
        LiferayTomcatPlugin.logError(e);
    }
    return file;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) ServerInstance(org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance) Properties(java.util.Properties) JarFile(java.util.jar.JarFile) File(java.io.File) NoSuchFileException(java.nio.file.NoSuchFileException) CoreException(org.eclipse.core.runtime.CoreException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Aggregations

ServerInstance (org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)38 IStatus (org.eclipse.core.runtime.IStatus)25 Status (org.eclipse.core.runtime.Status)24 Factory (org.eclipse.jst.server.tomcat.core.internal.xml.Factory)24 FileInputStream (java.io.FileInputStream)23 CoreException (org.eclipse.core.runtime.CoreException)21 InputStream (java.io.InputStream)19 ByteArrayInputStream (java.io.ByteArrayInputStream)18 Context (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context)18 InputSource (org.xml.sax.InputSource)18 IFile (org.eclipse.core.resources.IFile)17 File (java.io.File)13 Server (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server)10 IPath (org.eclipse.core.runtime.IPath)9 FileNotFoundException (java.io.FileNotFoundException)6 IOException (java.io.IOException)6 MultiStatus (org.eclipse.core.runtime.MultiStatus)6 Path (org.eclipse.core.runtime.Path)5 SAXException (org.xml.sax.SAXException)5 JarFile (java.util.jar.JarFile)4