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;
}
Aggregations