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: *
022: * $Id: CBRComponent.java 7094 2007-04-26 07:40:09Z lzheng $
023: */
024: package com.bostechcorp.cbesb.common.sa.component;
025:
026: import java.util.List;
027:
028: import javax.wsdl.WSDLException;
029:
030: import com.bostechcorp.cbesb.common.i18n.Message;
031: import com.bostechcorp.cbesb.common.i18n.Messages;
032: import com.bostechcorp.cbesb.common.sa.service.EndPoint;
033: import com.bostechcorp.cbesb.common.sa.service.PropertiesKey;
034: import com.bostechcorp.cbesb.common.util.generators.AbstractComponentDOMWsdlXMLGenerator;
035: import com.bostechcorp.cbesb.common.util.generators.CbrComponentDOMWsdlXMLGenerator;
036: import com.bostechcorp.cbesb.common.util.generators.CbrRoutesXMLGenerator;
037: import com.bostechcorp.cbesb.common.util.generators.wsdl.generators.AbstractWsdlGenaretor;
038: import com.bostechcorp.cbesb.common.util.generators.wsdl.generators.CbrWsdlGenerator;
039:
040: public class CBRComponent extends AbstractComponent {
041: //private final String ns="xmlns:cbr='http://cbesb.bostechcorp.com/wsdl/cbr/1.0'";
042: //private final String routingRuleNs="xmlns=\"http://cbesb.bostechcorp.com/cbr/routingrules/1.0\"";
043:
044: public CBRComponent() {
045: super ();
046:
047: }
048:
049: public String getComponentName() {
050: return "ChainBuilderESB-SE-CBR";
051: }
052:
053: public AbstractComponentDOMWsdlXMLGenerator getWSDLGenerator(
054: String path) {
055: CbrComponentDOMWsdlXMLGenerator wsdlXMLGenerator = new CbrComponentDOMWsdlXMLGenerator(
056: path);
057: return wsdlXMLGenerator;
058: }
059:
060: @Override
061: public void generateWSDL(String path, String saName)
062: throws Exception {
063: for (int i = 0; i < getEndPointList().size(); i++) {
064: EndPoint endPoint = this .endPointList.get(i);
065: AbstractWsdlGenaretor generator = getWsdlGenerator(path,
066: saName, endPoint);
067: generator.writeToFile();
068: generateRoutingRulesFile(path, endPoint, saName);
069: }
070: }
071:
072: protected void generateRoutingRulesFile(String path,
073: EndPoint endPoint, String saName) {
074: CbrRoutesXMLGenerator routesXMLGenerator = new CbrRoutesXMLGenerator(
075: path, saName);
076: routesXMLGenerator.setRoutingRules(endPoint);
077: routesXMLGenerator.write();
078:
079: }
080:
081: @Override
082: public void validateBase(List<String> list) {
083: for (int i = 0; i < getEndPointList().size(); i++) {
084: EndPoint endPoint = getEndPointList().get(i);
085: if (endPoint.getName() == null
086: || "".equals(endPoint.getName())) {
087: list.add(new Message(
088: Messages.FLOWEDITOR_MISSING_ENDPOINTNAME,
089: getName()).getMessage());
090: }
091: if ("fixed".equals(endPoint.getSettings().getProperty(
092: PropertiesKey.CBR_WSDL_TRXID_TYPE))) {
093: if (endPoint.getSettings().getProperty(
094: PropertiesKey.CBR_WSDL_FIXED_OFFSET) == null
095: || ""
096: .equals(endPoint
097: .getSettings()
098: .getProperty(
099: PropertiesKey.CBR_WSDL_FIXED_OFFSET))) {
100: list.add(new Message(
101: Messages.CBRCOMPONENT_MISSING_FIXEDOFFSET,
102: getName()).getMessage());
103: }
104: if (endPoint.getSettings().getProperty(
105: PropertiesKey.CBR_WSDL_FIXED_LENGTH) == null
106: || ""
107: .equals(endPoint
108: .getSettings()
109: .getProperty(
110: PropertiesKey.CBR_WSDL_FIXED_LENGTH))) {
111: list.add(new Message(
112: Messages.CBRCOMPONENT_MISSING_FIXEDLENGTH,
113: getName()).getMessage());
114: }
115: }
116: if ("csv".equals(endPoint.getSettings().getProperty(
117: PropertiesKey.CBR_WSDL_TRXID_TYPE))) {
118: if (endPoint.getSettings().getProperty(
119: PropertiesKey.CBR_WSDL_CSV_DELIMITER) == null
120: || ""
121: .equals(endPoint
122: .getSettings()
123: .getProperty(
124: PropertiesKey.CBR_WSDL_CSV_DELIMITER))) {
125: list.add(new Message(
126: Messages.CBRCOMPONENT_MISSING_DELIMITER,
127: getName()).getMessage());
128: }
129: if (endPoint.getSettings().getProperty(
130: PropertiesKey.CBR_WSDL_CSV_INDEX) == null
131: || ""
132: .equals(endPoint
133: .getSettings()
134: .getProperty(
135: PropertiesKey.CBR_WSDL_CSV_INDEX))) {
136: list.add(new Message(
137: Messages.CBRCOMPONENT_MISSING_INDEX,
138: getName()).getMessage());
139: }
140: }
141: if ("script".equals(endPoint.getSettings().getProperty(
142: PropertiesKey.CBR_WSDL_TRXID_TYPE))) {
143: if (endPoint.getSettings().getProperty(
144: PropertiesKey.CBR_WSDL_SCRIPT_SCRIPTENGINE) == null
145: || ""
146: .equals(endPoint
147: .getSettings()
148: .getProperty(
149: PropertiesKey.CBR_WSDL_SCRIPT_SCRIPTENGINE))) {
150: list.add(new Message(
151: Messages.CBRCOMPONENT_MISSING_SCRIPTENGINE,
152: getName()).getMessage());
153: }
154:
155: if (endPoint.getSettings().getProperty(
156: PropertiesKey.CBR_WSDL_SCRIPT_SCRIPTCLASS) == null
157: || ""
158: .equals(endPoint
159: .getSettings()
160: .getProperty(
161: PropertiesKey.CBR_WSDL_SCRIPT_SCRIPTCLASS))) {
162: list.add(new Message(
163: Messages.CBRCOMPONENT_MISSING_SCRIPTCLASS,
164: getName()).getMessage());
165: }
166: }
167: }
168: }
169:
170: @Override
171: protected AbstractWsdlGenaretor getWsdlGenerator(String path,
172: String saName, EndPoint ep) throws WSDLException {
173: return new CbrWsdlGenerator(path, saName, getName(), this
174: .getComponentType(), ep);
175: }
176:
177: }
|