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: * $Id: FTPConversion.java 7718 2007-06-04 09:36:40Z jzhang $
023: *
024: */
025: package com.bostechcorp.cbesb.ui.util.version;
026:
027: import org.jdom.Element;
028:
029: /**
030: *
031: */
032: public class FTPConversion {
033:
034: public static void convert(Element element, Element ftp) {
035: Element ftpWSDLDocument = element.getChild("ftpWSDLDocument");
036:
037: Element newConsumerCCSL;
038: if (ftpWSDLDocument.getChild("ftpConsumerCCSL") == null) {
039: newConsumerCCSL = ConversionUtil.convertCCSL(
040: ConversionUtil.CONSUMER, element, "consumerCCSL");
041: } else {
042: newConsumerCCSL = ConversionUtil.createCCSL(
043: ConversionUtil.CONSUMER, ftpWSDLDocument
044: .getChild("ftpConsumerCCSL"));
045: }
046: Element newProviderCCSL;
047: if (ftpWSDLDocument.getChild("ftpProviderCCSL") == null) {
048: newProviderCCSL = ConversionUtil.convertCCSL(
049: ConversionUtil.PROVIDER, element, "providerCCSL");
050: } else {
051: newProviderCCSL = ConversionUtil.createCCSL(
052: ConversionUtil.PROVIDER, ftpWSDLDocument
053: .getChild("ftpProviderCCSL"));
054: }
055: ftp.addContent(newConsumerCCSL);
056: ftp.addContent(newProviderCCSL);
057: // old base
058: Element ftpBase = ftpWSDLDocument.getChild("ftpBase");
059: Element ftpRead = ftpBase.getChild("ftpRead");
060: Element ftpReply = ftpRead.getChild("ftpReply");
061: Element ftpReadReply = ftpReply.getChild("ftpReadReply");
062: Element ftpCompletion = ftpRead.getChild("ftpCompletion");
063: Element ftpHold = ftpRead.getChild("ftpHold");
064: Element ftpTwoPassMode = ftpRead.getChild("ftpTwoPassMode");
065: Element ftpWrite = ftpBase.getChild("ftpWrite");
066: Element ftpWriteCompletion = ftpWrite
067: .getChild("ftpWriteCompletion");
068: // new base
069: Element newFtpBase = new Element("ftpBase");
070: Element newFtpConsumer = new Element("ftpConsumer");
071: Element newFtpReply = new Element("ftpReply");
072: Element newFtpAuthentication = new Element("ftpAuthentication");
073: Element newConsumerFileCompletion = new Element(
074: "fileCompletion");
075: Element newScheduler = new Element("Scheduler");
076: Element newFtpProvider = new Element("ftpProvider");
077: Element newProviderFileCompletion = new Element(
078: "fileCompletion");
079:
080: if (ftpWSDLDocument.getAttributeValue("mode") != null) {
081: ftp.setAttribute("role", "provider");
082: }
083: if (ftpWSDLDocument.getAttributeValue("scriptMode") != null) {
084: ftp.setAttribute("scriptMode", "script");
085: }
086: if (ftpHold.getAttributeValue("enabled") != null) {
087: newFtpConsumer.setAttribute("holdEnabled", "true");
088: newFtpConsumer.setAttribute("holdDirectory", ftpHold
089: .getAttributeValue("holdDirectory"));
090: }
091: if (ftpTwoPassMode.getAttributeValue("enabled") != null) {
092: newFtpConsumer.setAttribute("twoPassModeIntevalEnabled",
093: "true");
094: newFtpConsumer.setAttribute("twoPassModeInterval",
095: ftpTwoPassMode.getAttributeValue("interval"));
096: } else {
097: newFtpConsumer.setAttribute("twoPassModeIntevalEnabled",
098: "false");
099: }
100: ConversionUtil.convertAttribute(ftpRead, newFtpConsumer);
101: ConversionUtil.convertAttribute(ftpReply, newFtpReply);
102: ConversionUtil.convertAttribute(ftpReadReply,
103: newFtpAuthentication);
104: ConversionUtil.convertAttribute(ftpCompletion,
105: newConsumerFileCompletion);
106: ConversionUtil.convertAttribute(ftpWrite, newFtpProvider);
107: ConversionUtil.convertAttribute(ftpWriteCompletion,
108: newProviderFileCompletion);
109: newFtpConsumer.addContent(newConsumerFileCompletion);
110: newFtpConsumer.addContent(newScheduler);
111: newFtpReply.addContent(newFtpAuthentication);
112: newFtpConsumer.addContent(newFtpReply);
113: newFtpBase.addContent(newFtpConsumer);
114: newFtpProvider.addContent(newProviderFileCompletion);
115: newFtpBase.addContent(newFtpProvider);
116: ftp.addContent(newFtpBase);
117: }
118: }
|