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
008: * it under the terms of the GNU General Public License as published by
009: * the Free Software Foundation; either version 2 of the License, or
010: * (at your option) 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
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc.,59 Temple Place, Suite 330, Boston, MA 02111-1307
020: * USA
021: *
022: *
023: * $Id: FtpInputDeserializer.java 9392 2007-09-30 01:59:18Z lzheng $
024: */
025: package com.bostechcorp.cbesb.runtime.component.ftp.wsdl;
026:
027: import javax.wsdl.Definition;
028: import javax.wsdl.WSDLException;
029: import javax.wsdl.extensions.ExtensibilityElement;
030: import javax.wsdl.extensions.ExtensionDeserializer;
031: import javax.wsdl.extensions.ExtensionRegistry;
032: import javax.xml.namespace.QName;
033:
034: import org.apache.commons.logging.Log;
035: import org.apache.commons.logging.LogFactory;
036: import org.w3c.dom.Element;
037: import org.w3c.dom.NamedNodeMap;
038:
039: import com.bostechcorp.cbesb.common.util.macro.MacroUtil;
040: import com.bostechcorp.cbesb.runtime.component.util.wsdl.BaseCommonAttributeDeserializer;
041: import com.ibm.wsdl.util.xml.DOMUtils;
042:
043: /**
044: * @author j.zhang
045: * @version 1.0.0
046: */
047: public class FtpInputDeserializer extends
048: BaseCommonAttributeDeserializer implements
049: ExtensionDeserializer {
050:
051: protected final transient Log logger = LogFactory
052: .getLog(getClass());
053:
054: public ExtensibilityElement unmarshall(Class parentType,
055: QName elementType, Element el, Definition def,
056: ExtensionRegistry extReg) throws WSDLException {
057: logger.debug("");
058: logger.debug("FtpInputDeserializer");
059: logger.debug(" " + el.getNodeName());
060: logger.debug(" Attributes:");
061: NamedNodeMap attrMap = el.getAttributes();
062: for (int i = 0; i < attrMap.getLength(); i++) {
063: logger.debug(" attr[" + i + "]="
064: + attrMap.item(i).getNodeName() + ", "
065: + attrMap.item(i).getNodeValue());
066: }
067:
068: FtpInput ftpAddress = (FtpInput) super .unmarshall(parentType,
069: elementType, el, def, extReg);
070: // ftpAddress.setDefaultMep(DOMUtils.getAttribute(el, FtpInputExtension.FTP_HOST));
071: ftpAddress.setFtpHost(MacroUtil.resolveUserMacro(DOMUtils
072: .getAttribute(el, FtpInputExtension.FTP_HOST)));
073: ftpAddress.setFtpUser(MacroUtil.resolveUserMacro(DOMUtils
074: .getAttribute(el, FtpInputExtension.FTP_USER)));
075: ftpAddress.setFtpPassword(MacroUtil.resolveUserMacro(DOMUtils
076: .getAttribute(el, FtpInputExtension.FTP_PASSWORD)));
077: ftpAddress.setCmdFile(DOMUtils.getAttribute(el,
078: FtpInputExtension.CMD_FILE));
079: ftpAddress.setFtpConnectMode(DOMUtils.getAttribute(el,
080: FtpInputExtension.FTP_CONNECT_MODE));
081: ftpAddress.setFtpTransferMode(DOMUtils.getAttribute(el,
082: FtpInputExtension.FTP_TRANSFER_MODE));
083: ftpAddress.setSourceDir(MacroUtil.resolveUserMacro(DOMUtils
084: .getAttribute(el, FtpInputExtension.SOURCE_DIR)));
085: ftpAddress.setTransferDir(DOMUtils.getAttribute(el,
086: FtpInputExtension.TRANSFER_DIR));
087: ftpAddress.setStageDir(MacroUtil.resolveUserMacro(DOMUtils
088: .getAttribute(el, FtpInputExtension.STAGE_DIR)));
089: ftpAddress.setArchiveDir(MacroUtil.resolveUserMacro(DOMUtils
090: .getAttribute(el, FtpInputExtension.ARCHIVE_DIR)));
091: ftpAddress.setHoldDir(MacroUtil.resolveUserMacro(DOMUtils
092: .getAttribute(el, FtpInputExtension.HOLD_DIR)));
093: ftpAddress.setScanInterval(DOMUtils.getAttribute(el,
094: FtpInputExtension.SCAN_INTERVAL));
095: ftpAddress.setSchedule(DOMUtils.getAttribute(el,
096: FtpInputExtension.SCHEDULE));
097: String schedSvc = DOMUtils.getAttribute(el,
098: FtpInputExtension.SCHEDULER_SERVICE);
099: if (schedSvc != null && !schedSvc.equals("")) {
100: QName schedulerServiceQN = DOMUtils.getQName(schedSvc, el,
101: def);
102: ftpAddress.setSchedulerService(schedulerServiceQN);
103: } else {
104: ftpAddress.setSchedulerService(null);
105: }
106: ftpAddress.setSchedulerEndpoint(DOMUtils.getAttribute(el,
107: FtpInputExtension.SCHEDULER_ENDPOINT));
108: ftpAddress.setHold(DOMUtils.getAttribute(el,
109: FtpInputExtension.HOLD));
110: ftpAddress.setFilePattern(DOMUtils.getAttribute(el,
111: FtpInputExtension.FILE_PATTERN));
112: ftpAddress.setFilePattern(DOMUtils.getAttribute(el,
113: FtpInputExtension.MATCH_MODE));
114: ftpAddress.setTwoPass(DOMUtils.getAttribute(el,
115: FtpInputExtension.TWO_PASS));
116: ftpAddress.setTwoPassInterval(DOMUtils.getAttribute(el,
117: FtpInputExtension.TWO_PASS_INTERVAL));
118: ftpAddress.setFileCompleteAction(DOMUtils.getAttribute(el,
119: FtpInputExtension.FILE_COMPLETE_ACTION));
120: ftpAddress.setRecordsPerMessage(DOMUtils.getAttribute(el,
121: FtpInputExtension.RECORDS_PER_MESSAGE));
122: ftpAddress.setReadStyle(DOMUtils.getAttribute(el,
123: FtpInputExtension.READ_STYLE));
124: ftpAddress.setRecordType(DOMUtils.getAttribute(el,
125: FtpInputExtension.RECORD_TYPE));
126: ftpAddress.setCharset(DOMUtils.getAttribute(el,
127: FtpInputExtension.CHARSET));
128: ftpAddress.setArchiveFilePattern(DOMUtils.getAttribute(el,
129: FtpInputExtension.ARCHIVE_FILE_PATTERN));
130: ftpAddress.setReplyFtpHost(MacroUtil.resolveUserMacro(DOMUtils
131: .getAttribute(el, FtpInputExtension.REPLY_FTP_HOST)));
132: ftpAddress.setReplyFtpUser(MacroUtil.resolveUserMacro(DOMUtils
133: .getAttribute(el, FtpInputExtension.REPLY_FTP_USER)));
134: ftpAddress.setReplyFtpPassword(MacroUtil
135: .resolveUserMacro(DOMUtils.getAttribute(el,
136: FtpInputExtension.REPLY_FTP_PASSWORD)));
137: ftpAddress.setReplyFtpConnectMode(DOMUtils.getAttribute(el,
138: FtpInputExtension.REPLY_FTP_CONNECT_MODE));
139: ftpAddress.setReplyFtpTransferMode(DOMUtils.getAttribute(el,
140: FtpInputExtension.REPLY_FTP_TRANSFER_MODE));
141: ftpAddress.setReplyDir(MacroUtil.resolveUserMacro(DOMUtils
142: .getAttribute(el, FtpInputExtension.REPLY_DIR)));
143: ftpAddress.setReplyCharset(DOMUtils.getAttribute(el,
144: FtpInputExtension.REPLY_CHARSET));
145: ftpAddress.setReplyWriteStyle(DOMUtils.getAttribute(el,
146: FtpInputExtension.REPLY_WRITE_STYLE));
147: ftpAddress.setReplyFilePattern(DOMUtils.getAttribute(el,
148: FtpInputExtension.REPLY_FILE_PATTERN));
149:
150: return ftpAddress;
151: }
152: }
|