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.upgrade.v4_3_0.util;
16  
17  import com.liferay.portal.kernel.upgrade.util.BaseUpgradeColumnImpl;
18  import com.liferay.portal.kernel.upgrade.util.UpgradeColumn;
19  import com.liferay.portal.kernel.util.StringUtil;
20  
21  /**
22   * <a href="JournalTemplateXSLUpgradeColumnImpl.java.html"><b><i>View Source</i>
23   * </b></a>
24   *
25   * @author Brian Wing Shun Chan
26   */
27  public class JournalTemplateXSLUpgradeColumnImpl extends BaseUpgradeColumnImpl {
28  
29      public JournalTemplateXSLUpgradeColumnImpl(UpgradeColumn templateIdColumn) {
30          super("xsl");
31  
32          _templateIdColumn = templateIdColumn;
33      }
34  
35      public Object getNewValue(Object oldValue) throws Exception {
36          String xsl = (String)oldValue;
37  
38          return formatXSL(xsl);
39      }
40  
41      protected String formatXSL(String xsl) throws Exception {
42          /*if (xsl.indexOf("\\n") != -1) {
43              xsl = StringUtil.replace(
44                  xsl, new String[] {"\\n", "\\r"}, new String[] {"\n", "\r"});
45          }*/
46  
47          String templateId = (String)_templateIdColumn.getOldValue();
48  
49          if (templateId.equals("BASIC-BANNER")) {
50  
51              // 4.3 defaults to XHTML 1.0 Transitional and requires stricter CSS
52  
53              xsl = StringUtil.replace(
54                  xsl,
55                  "background-repeat: no-repeat; width: 520; height: 175;",
56                  "background-repeat: no-repeat; width: 520px; height: 175px;");
57          }
58  
59          return xsl;
60      }
61  
62      private UpgradeColumn _templateIdColumn;
63  
64  }