01: /**
02: * ChainBuilder ESB
03: * Visual Enterprise Integration
04: *
05: * Copyright (C) 2006 Bostech Corporation
06: *
07: * This program is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU General Public License as published by the
09: * Free Software Foundation; either version 2 of the License, or (at your option)
10: * any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15: * for more details.
16: *
17: * You should have received a copy of the GNU General Public License along with
18: * this program; if not, write to the Free Software Foundation, Inc.,
19: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: *
21: * WwsdlPorting
22: * LPS
23: * Oct 23, 2007
24: */package com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards.httpExtra.io;
25:
26: import java.io.File;
27: import java.util.HashMap;
28: import java.util.Set;
29:
30: import com.bostechcorp.cbesb.common.util.FileUtil;
31: import com.bostechcorp.cbesb.common.util.xfm.impl.XmlFormatModelXSDImpl;
32: import com.bostechcorp.cbesb.common.wsdl.WsdlInfo;
33:
34: /**
35: * @author LPS
36: *
37: */
38: public class WsdlPorting {
39: /**
40: * copy wsdl and recursively all imported/inclunded xsds
41: * @param source
42: * @param destination
43: * @throws Exception
44: */
45: public static void doCopyWsdl(String source, String destination)
46: throws Exception {
47: File s = new File(source);
48: String d = new File(destination).toURI().getPath();
49: FileUtil.copyFile(s, d); // copy wsdl
50: HashMap<String, String> initialMap = new HashMap<String, String>();
51: initialMap = WsdlInfo.extractFilesForCopy(s.toURI().getPath(),
52: d);
53: Set<String> xsdSet = initialMap.keySet();
54: HashMap<String, String> recursionMap = new HashMap<String, String>();
55: for (String xsdAbsolutePath : xsdSet) {
56: // also ger recuresively all xsd interdependent files
57: XmlFormatModelXSDImpl.getRecursiveImportSchemaList(
58: recursionMap, xsdAbsolutePath, d);
59: }
60: initialMap.putAll(recursionMap);
61: FileUtil.copyFiles(initialMap);
62: }
63:
64: /**
65: * copy an xsd and recursively all imported/inclunded xsds
66: * @param source
67: * @param destination
68: * @throws Exception
69: */
70: public static void doCopyXsd(String source, String destination)
71: throws Exception {
72: File s = new File(source);
73: String d = new File(destination).toURI().getPath();
74: //FileUtil.copyFile(s, d); // copy wsdl
75: HashMap<String, String> initialMap = new HashMap<String, String>();
76: XmlFormatModelXSDImpl.getRecursiveImportSchemaList(initialMap,
77: s.getAbsolutePath(), d);
78: FileUtil.copyFiles(initialMap);
79: }
80:
81: // public static void main(String[] args) {
82: // try {
83: // WsdlPorting.doCopyXsd("c:\\staff\\Staff.xsd", "c:\\asd");
84: // } catch (Exception e) {
85: // // TODO Auto-generated catch block
86: // e.printStackTrace();
87: // }
88: // }
89:
90: }
|