1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.deploy.auto;
16  
17  import com.liferay.portal.deploy.DeployUtil;
18  import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
19  import com.liferay.portal.kernel.log.Log;
20  import com.liferay.portal.kernel.log.LogFactoryUtil;
21  import com.liferay.portal.kernel.util.PropsKeys;
22  import com.liferay.portal.kernel.util.ServerDetector;
23  import com.liferay.portal.kernel.util.StringPool;
24  import com.liferay.portal.tools.deploy.ThemeDeployer;
25  import com.liferay.portal.util.PrefsPropsUtil;
26  import com.liferay.portal.util.PropsValues;
27  
28  import java.util.ArrayList;
29  import java.util.List;
30  
31  /**
32   * <a href="ThemeAutoDeployer.java.html"><b><i>View Source</i></b></a>
33   *
34   * @author Ivica Cardic
35   * @author Brian Wing Shun Chan
36   */
37  public class ThemeAutoDeployer extends ThemeDeployer implements AutoDeployer {
38  
39      public ThemeAutoDeployer() {
40          try {
41              baseDir = PrefsPropsUtil.getString(
42                  PropsKeys.AUTO_DEPLOY_DEPLOY_DIR,
43                  PropsValues.AUTO_DEPLOY_DEPLOY_DIR);
44              destDir = DeployUtil.getAutoDeployDestDir();
45              appServerType = ServerDetector.getServerId();
46              themeTaglibDTD = DeployUtil.getResourcePath("liferay-theme.tld");
47              utilTaglibDTD = DeployUtil.getResourcePath("liferay-util.tld");
48              unpackWar = PrefsPropsUtil.getBoolean(
49                  PropsKeys.AUTO_DEPLOY_UNPACK_WAR,
50                  PropsValues.AUTO_DEPLOY_UNPACK_WAR);
51              filePattern = StringPool.BLANK;
52              jbossPrefix = PrefsPropsUtil.getString(
53                  PropsKeys.AUTO_DEPLOY_JBOSS_PREFIX,
54                  PropsValues.AUTO_DEPLOY_JBOSS_PREFIX);
55              tomcatLibDir = PrefsPropsUtil.getString(
56                  PropsKeys.AUTO_DEPLOY_TOMCAT_LIB_DIR,
57                  PropsValues.AUTO_DEPLOY_TOMCAT_LIB_DIR);
58  
59              List<String> jars = new ArrayList<String>();
60  
61              addExtJar(jars, "ext-util-java.jar");
62              addExtJar(jars, "ext-util-taglib.jar");
63              addRequiredJar(jars, "util-java.jar");
64              addRequiredJar(jars, "util-taglib.jar");
65  
66              this.jars = jars;
67  
68              checkArguments();
69          }
70          catch (Exception e) {
71              _log.error(e);
72          }
73      }
74  
75      public void autoDeploy(String file) throws AutoDeployException {
76          List<String> wars = new ArrayList<String>();
77  
78          wars.add(file);
79  
80          this.wars = wars;
81  
82          try {
83              deploy();
84          }
85          catch (Exception e) {
86              throw new AutoDeployException(e);
87          }
88      }
89  
90      private static Log _log = LogFactoryUtil.getLog(ThemeAutoDeployer.class);
91  
92  }