/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.portal.deploy.auto; import com.liferay.portal.deploy.DeployUtil; import com.liferay.portal.kernel.deploy.auto.AutoDeployException; import com.liferay.portal.kernel.deploy.auto.AutoDeployer; import com.liferay.portal.kernel.deploy.auto.context.AutoDeploymentContext; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.util.PropsKeys; import com.liferay.portal.kernel.util.ServerDetector; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.tools.deploy.ThemeDeployer; import com.liferay.portal.util.PrefsPropsUtil; import com.liferay.portal.util.PropsValues; import java.io.File; import java.util.ArrayList; import java.util.List; /** * @author Ivica Cardic * @author Brian Wing Shun Chan */ public class ThemeAutoDeployer extends ThemeDeployer implements AutoDeployer { public ThemeAutoDeployer() { try { baseDir = PrefsPropsUtil.getString( PropsKeys.AUTO_DEPLOY_DEPLOY_DIR, PropsValues.AUTO_DEPLOY_DEPLOY_DIR); destDir = DeployUtil.getAutoDeployDestDir(); appServerType = ServerDetector.getServerId(); themeTaglibDTD = DeployUtil.getResourcePath("liferay-theme.tld"); utilTaglibDTD = DeployUtil.getResourcePath("liferay-util.tld"); unpackWar = PrefsPropsUtil.getBoolean( PropsKeys.AUTO_DEPLOY_UNPACK_WAR, PropsValues.AUTO_DEPLOY_UNPACK_WAR); filePattern = StringPool.BLANK; jbossPrefix = PrefsPropsUtil.getString( PropsKeys.AUTO_DEPLOY_JBOSS_PREFIX, PropsValues.AUTO_DEPLOY_JBOSS_PREFIX); tomcatLibDir = PrefsPropsUtil.getString( PropsKeys.AUTO_DEPLOY_TOMCAT_LIB_DIR, PropsValues.AUTO_DEPLOY_TOMCAT_LIB_DIR); wildflyPrefix = PrefsPropsUtil.getString( PropsKeys.AUTO_DEPLOY_WILDFLY_PREFIX, PropsValues.AUTO_DEPLOY_WILDFLY_PREFIX); List<String> jars = new ArrayList<>(); addExtJar(jars, "ext-util-bridges.jar"); addExtJar(jars, "ext-util-java.jar"); addExtJar(jars, "ext-util-taglib.jar"); addRequiredJar(jars, "util-bridges.jar"); addRequiredJar(jars, "util-java.jar"); addRequiredJar(jars, "util-taglib.jar"); this.jars = jars; checkArguments(); } catch (Exception e) { _log.error(e, e); } } @Override public int autoDeploy(AutoDeploymentContext autoDeploymentContext) throws AutoDeployException { File file = autoDeploymentContext.getFile(); if (file.isDirectory()) { try { if (_log.isInfoEnabled()) { _log.info("Modifying themes for " + file.getPath()); } deployDirectory( file, autoDeploymentContext.getContext(), false, autoDeploymentContext.getPluginPackage()); if (_log.isInfoEnabled()) { _log.info( "Themes for " + file.getPath() + " modified successfully"); } return AutoDeployer.CODE_DEFAULT; } catch (Exception e) { throw new AutoDeployException(e); } } else { return super.autoDeploy(autoDeploymentContext); } } private static final Log _log = LogFactoryUtil.getLog( ThemeAutoDeployer.class); }