001
014
015 package com.liferay.portal.deploy.auto;
016
017 import com.liferay.portal.deploy.DeployUtil;
018 import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
019 import com.liferay.portal.kernel.deploy.auto.AutoDeployer;
020 import com.liferay.portal.kernel.deploy.auto.context.AutoDeploymentContext;
021 import com.liferay.portal.kernel.log.Log;
022 import com.liferay.portal.kernel.log.LogFactoryUtil;
023 import com.liferay.portal.kernel.util.PropsKeys;
024 import com.liferay.portal.kernel.util.ServerDetector;
025 import com.liferay.portal.kernel.util.StringPool;
026 import com.liferay.portal.tools.deploy.ThemeDeployer;
027 import com.liferay.portal.util.PrefsPropsUtil;
028 import com.liferay.portal.util.PropsValues;
029
030 import java.io.File;
031
032 import java.util.ArrayList;
033 import java.util.List;
034
035
039 public class ThemeAutoDeployer extends ThemeDeployer implements AutoDeployer {
040
041 public ThemeAutoDeployer() {
042 try {
043 baseDir = PrefsPropsUtil.getString(
044 PropsKeys.AUTO_DEPLOY_DEPLOY_DIR,
045 PropsValues.AUTO_DEPLOY_DEPLOY_DIR);
046 destDir = DeployUtil.getAutoDeployDestDir();
047 appServerType = ServerDetector.getServerId();
048 themeTaglibDTD = DeployUtil.getResourcePath("liferay-theme.tld");
049 utilTaglibDTD = DeployUtil.getResourcePath("liferay-util.tld");
050 unpackWar = PrefsPropsUtil.getBoolean(
051 PropsKeys.AUTO_DEPLOY_UNPACK_WAR,
052 PropsValues.AUTO_DEPLOY_UNPACK_WAR);
053 filePattern = StringPool.BLANK;
054 jbossPrefix = PrefsPropsUtil.getString(
055 PropsKeys.AUTO_DEPLOY_JBOSS_PREFIX,
056 PropsValues.AUTO_DEPLOY_JBOSS_PREFIX);
057 tomcatLibDir = PrefsPropsUtil.getString(
058 PropsKeys.AUTO_DEPLOY_TOMCAT_LIB_DIR,
059 PropsValues.AUTO_DEPLOY_TOMCAT_LIB_DIR);
060 wildflyPrefix = PrefsPropsUtil.getString(
061 PropsKeys.AUTO_DEPLOY_WILDFLY_PREFIX,
062 PropsValues.AUTO_DEPLOY_WILDFLY_PREFIX);
063
064 List<String> jars = new ArrayList<>();
065
066 addExtJar(jars, "ext-util-bridges.jar");
067 addExtJar(jars, "ext-util-java.jar");
068 addExtJar(jars, "ext-util-taglib.jar");
069 addRequiredJar(jars, "util-bridges.jar");
070 addRequiredJar(jars, "util-java.jar");
071 addRequiredJar(jars, "util-taglib.jar");
072
073 this.jars = jars;
074
075 checkArguments();
076 }
077 catch (Exception e) {
078 _log.error(e, e);
079 }
080 }
081
082 @Override
083 public int autoDeploy(AutoDeploymentContext autoDeploymentContext)
084 throws AutoDeployException {
085
086 File file = autoDeploymentContext.getFile();
087
088 if (file.isDirectory()) {
089 try {
090 if (_log.isInfoEnabled()) {
091 _log.info("Modifying themes for " + file.getPath());
092 }
093
094 deployDirectory(
095 file, autoDeploymentContext.getContext(), false,
096 autoDeploymentContext.getPluginPackage());
097
098 if (_log.isInfoEnabled()) {
099 _log.info(
100 "Themes for " + file.getPath() +
101 " modified successfully");
102 }
103
104 return AutoDeployer.CODE_DEFAULT;
105 }
106 catch (Exception e) {
107 throw new AutoDeployException(e);
108 }
109 }
110 else {
111 return super.autoDeploy(autoDeploymentContext);
112 }
113 }
114
115 private static final Log _log = LogFactoryUtil.getLog(
116 ThemeAutoDeployer.class);
117
118 }