Search in sources :

Example 66 with Server

use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server 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

CoreException (org.eclipse.core.runtime.CoreException)48 ServerInstance (org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)32 Factory (org.eclipse.jst.server.tomcat.core.internal.xml.Factory)26 IStatus (org.eclipse.core.runtime.IStatus)25 Status (org.eclipse.core.runtime.Status)24 FileInputStream (java.io.FileInputStream)23 Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)23 Context (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context)22 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)22 InputStream (java.io.InputStream)19 ByteArrayInputStream (java.io.ByteArrayInputStream)18 ArrayList (java.util.ArrayList)18 InputSource (org.xml.sax.InputSource)18 IFile (org.eclipse.core.resources.IFile)17 Server (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server)15 File (java.io.File)13 IPath (org.eclipse.core.runtime.IPath)9 ServerPort (org.eclipse.wst.server.core.ServerPort)9 FileNotFoundException (java.io.FileNotFoundException)6 IOException (java.io.IOException)6