01: /**
02: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
03: *
04: * Permission is hereby granted, free of charge, to any person obtaining a copy
05: * of this software and associated documentation files (the "Software"), to deal
06: * in the Software without restriction, including without limitation the rights
07: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
08: * copies of the Software, and to permit persons to whom the Software is
09: * furnished to do so, subject to the following conditions:
10: *
11: * The above copyright notice and this permission notice shall be included in
12: * all copies or substantial portions of the Software.
13: *
14: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20: * SOFTWARE.
21: */package com.liferay.portal.tools;
22:
23: import com.liferay.util.ant.Wsdl2JavaTask;
24:
25: import java.io.File;
26:
27: import java.util.Iterator;
28:
29: import org.dom4j.Document;
30: import org.dom4j.Element;
31: import org.dom4j.io.SAXReader;
32:
33: /**
34: * <a href="PortalClientBuilder.java.html"><b><i>View Source</i></b></a>
35: *
36: * @author Brian Wing Shun Chan
37: *
38: */
39: public class PortalClientBuilder {
40:
41: public static void main(String[] args) {
42: if (args.length == 4) {
43: new PortalClientBuilder(args[0], args[1], args[2], args[3]);
44: } else {
45: throw new IllegalArgumentException();
46: }
47: }
48:
49: public PortalClientBuilder(String fileName, String outputDir,
50: String mappingFile, String url) {
51:
52: try {
53: SAXReader reader = new SAXReader();
54:
55: Document doc = reader.read(new File(fileName));
56:
57: Element root = doc.getRootElement();
58:
59: Iterator itr = root.elements("service").iterator();
60:
61: while (itr.hasNext()) {
62: Element service = (Element) itr.next();
63:
64: String name = service.attributeValue("name");
65:
66: if (name.startsWith("Portal_")
67: || name.startsWith("Portlet_")) {
68: Wsdl2JavaTask.generateJava(url + "/" + name
69: + "?wsdl", outputDir, mappingFile);
70: }
71: }
72: } catch (Exception e) {
73: e.printStackTrace();
74: }
75:
76: File testNamespace = new File(outputDir + "/com/liferay/portal");
77:
78: if (testNamespace.exists()) {
79: throw new RuntimeException("Please update " + mappingFile
80: + " to namespace "
81: + "com.liferay.portal to com.liferay.client.portal");
82: }
83: }
84:
85: }
|