001: /**
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: * FtpWsdlGenerator
022: * LPS
023: * Sep 18, 2007
024: */package com.bostechcorp.cbesb.common.util.generators.wsdl.generators;
025:
026: import javax.wsdl.WSDLException;
027:
028: import com.bostechcorp.cbesb.common.sa.service.EndPoint;
029: import com.bostechcorp.cbesb.common.util.generators.wsdl.extensions.ConfigExtension;
030: import com.bostechcorp.cbesb.common.util.generators.wsdl.extensions.ConfigExtensionRegistry;
031: import com.bostechcorp.cbesb.common.util.generators.wsdl.extensions.CustomTagExtension;
032: import com.bostechcorp.cbesb.common.util.macro.MacroUtil;
033:
034: /**
035: *
036: */
037: public class FtpWsdlGenerator extends
038: ScheduleableComponentWsdlGenerator {
039:
040: private static final String INPUT_TAG = "input";
041: private static final String OUTPUT_TAG = "output";
042: private static final String FTP_HOST = "ftpHost";
043: private static final String FTP_USER = "ftpUser";
044: private static final String FTP_PASSWORD = "ftpPassword";
045: private static final String SOURCE_DIR = "sourceDir";
046: private static final String STAGE_DIR = "stageDir";
047: private static final String ARCHIVE_DIR = "archiveDir";
048: private static final String HOLD_DIR = "holdDir";
049: private static final String REPLY_FTP_HOST = "replyFtpHost";
050: private static final String REPLY_FTP_USER = "replyFtpUser";
051: private static final String REPLY_FTP_PASSWORD = "replyFtpPassword";
052: private static final String REPLY_DIR = "replyDir";
053: private static final String DEST_DIR = "destDir";
054:
055: /**
056: * @param path
057: * @param saNAme
058: * @param suName
059: * @param suType
060: * @param endpoint
061: * @param b
062: * @throws WSDLException
063: */
064: public FtpWsdlGenerator(String path, String saNAme, String suName,
065: String suType, EndPoint endpoint, boolean b)
066: throws WSDLException {
067: super (path, saNAme, suName, suType, endpoint, b);
068: }
069:
070: protected void handleRegistry(ConfigExtensionRegistry cer) {
071: cer.customTagRegister(getRegistrationTag());
072:
073: }
074:
075: /**
076: * overwrite this method to
077: * @param properiesRoot
078: */
079: @Override
080: protected CustomTagExtension setConfigElement(String properiesRoot) {
081: CustomTagExtension config = new CustomTagExtension(
082: getRegistrationTag());
083: config
084: .addAttributes(endpointSettingsToAttributes(properiesRoot));
085: config.addAttribute("role", endpoint.getRole());
086: handleMacro(config);
087: port.addExtensibilityElement(config);
088: return config;
089: }
090:
091: /* (non-Javadoc)
092: * @see com.bostechcorp.cbesb.common.util.generators.wsdl.generators.AbstractWsdlGenaretor#getConsumerTag()
093: */
094: @Override
095: protected String getConsumerTag() {
096: return this .INPUT_TAG;
097: }
098:
099: /* (non-Javadoc)
100: * @see com.bostechcorp.cbesb.common.util.generators.wsdl.generators.AbstractWsdlGenaretor#getProviderTag()
101: */
102: @Override
103: protected String getProviderTag() {
104: return this .OUTPUT_TAG;
105: }
106:
107: public void handleMacro(CustomTagExtension config) {
108: String ftpHostProperty = config.getAttributes().getProperty(
109: FTP_HOST);
110: if (ftpHostProperty != null) {
111: String result = MacroUtil.resolveBuiltinMacro(
112: ftpHostProperty, saName);
113: config.getAttributes().setProperty(FTP_HOST, result);
114: }
115: String ftpUserProperty = config.getAttributes().getProperty(
116: FTP_USER);
117: if (ftpUserProperty != null) {
118: String result = MacroUtil.resolveBuiltinMacro(
119: ftpUserProperty, saName);
120: config.getAttributes().setProperty(FTP_USER, result);
121: }
122: String ftpPasswordProperty = config.getAttributes()
123: .getProperty(FTP_PASSWORD);
124: if (ftpPasswordProperty != null) {
125: String result = MacroUtil.resolveBuiltinMacro(
126: ftpPasswordProperty, saName);
127: config.getAttributes().setProperty(FTP_PASSWORD, result);
128: }
129: String sourceDirProperty = config.getAttributes().getProperty(
130: SOURCE_DIR);
131: if (sourceDirProperty != null) {
132: String result = MacroUtil.resolveBuiltinMacro(
133: sourceDirProperty, saName);
134: config.getAttributes().setProperty(SOURCE_DIR, result);
135: }
136: String stageDirProperty = config.getAttributes().getProperty(
137: STAGE_DIR);
138: if (stageDirProperty != null) {
139: String result = MacroUtil.resolveBuiltinMacro(
140: stageDirProperty, saName);
141: config.getAttributes().setProperty(STAGE_DIR, result);
142: }
143: String archiveDirProperty = config.getAttributes().getProperty(
144: ARCHIVE_DIR);
145: if (archiveDirProperty != null) {
146: String result = MacroUtil.resolveBuiltinMacro(
147: archiveDirProperty, saName);
148: config.getAttributes().setProperty(ARCHIVE_DIR, result);
149: }
150: String holdDirProperty = config.getAttributes().getProperty(
151: HOLD_DIR);
152: if (holdDirProperty != null) {
153: String result = MacroUtil.resolveBuiltinMacro(
154: holdDirProperty, saName);
155: config.getAttributes().setProperty(HOLD_DIR, result);
156: }
157: String replyFtpHostProperty = config.getAttributes()
158: .getProperty(REPLY_FTP_HOST);
159: if (replyFtpHostProperty != null) {
160: String result = MacroUtil.resolveBuiltinMacro(
161: replyFtpHostProperty, saName);
162: config.getAttributes().setProperty(REPLY_FTP_HOST, result);
163: }
164: String replyFtpUserProperty = config.getAttributes()
165: .getProperty(REPLY_FTP_USER);
166: if (replyFtpUserProperty != null) {
167: String result = MacroUtil.resolveBuiltinMacro(
168: replyFtpUserProperty, saName);
169: config.getAttributes().setProperty(REPLY_FTP_USER, result);
170: }
171: String replyFtpPasswordProperty = config.getAttributes()
172: .getProperty(REPLY_FTP_PASSWORD);
173: if (replyFtpPasswordProperty != null) {
174: String result = MacroUtil.resolveBuiltinMacro(
175: replyFtpPasswordProperty, saName);
176: config.getAttributes().setProperty(REPLY_FTP_PASSWORD,
177: result);
178: }
179: String replyDirProperty = config.getAttributes().getProperty(
180: REPLY_DIR);
181: if (replyDirProperty != null) {
182: String result = MacroUtil.resolveBuiltinMacro(
183: replyDirProperty, saName);
184: config.getAttributes().setProperty(REPLY_DIR, result);
185: }
186: String destDirProperty = config.getAttributes().getProperty(
187: DEST_DIR);
188: if (destDirProperty != null) {
189: String result = MacroUtil.resolveBuiltinMacro(
190: destDirProperty, saName);
191: config.getAttributes().setProperty(DEST_DIR, result);
192: }
193: }
194: }
|