1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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  }