1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.tools.deploy;
18
19 import org.jdom.Document;
20
21 /***
22 * @author Nicolas Dutertry
23 * @version $Id: JetspeedWebApplicationRewriterFactory.java 516881 2007-03-11 10:34:21Z ate $
24 */
25 public class JetspeedWebApplicationRewriterFactory {
26
27 /***
28 * Returns an instance of JetspeedWebApplicationRewriter.
29 *
30 * @param doc
31 * @return JetspeedWebApplicationRewriter
32 * @throws Exception
33 */
34 public JetspeedWebApplicationRewriter getInstance(Document doc) throws Exception
35 {
36 return getInstance(doc, null, null);
37 }
38
39 /***
40 * Returns an instance of JetspeedWebApplicationRewriter.
41 *
42 * @param doc
43 * @return JetspeedWebApplicationRewriter
44 * @throws Exception
45 */
46 public JetspeedWebApplicationRewriter getInstance(Document doc, String portletApplication) throws Exception
47 {
48 return getInstance(doc, portletApplication, null);
49 }
50
51 /***
52 * Returns an instance of JetspeedWebApplicationRewriter.
53 *
54 * @param doc
55 * @param portletApplication
56 * @param forcedVersion
57 * @return JetspeedWebApplicationRewriter
58 * @throws Exception
59 */
60 public JetspeedWebApplicationRewriter getInstance(Document doc, String portletApplication, String forcedVersion) throws Exception
61 {
62 String version = forcedVersion;
63 if(version == null)
64 {
65 version = doc.getRootElement().getAttributeValue("version", "2.3");
66 }
67
68 try
69 {
70
71 Double.parseDouble(version);
72 }
73 catch(NumberFormatException e)
74 {
75 throw new Exception("Unable to create JetspeedWebApplicationRewriter for version " + version, e);
76 }
77
78 if(version.equals("2.3"))
79 {
80 return new JetspeedWebApplicationRewriter2_3(doc, portletApplication);
81 }
82 else if(version.compareTo("2.4") >= 0)
83 {
84 return new JetspeedWebApplicationRewriter2_4(doc, portletApplication);
85 }
86 else
87 {
88 throw new Exception("Unable to create JetspeedWebApplicationRewriter for version " + version);
89 }
90 }
91 }