001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)DeployHelper.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.engine.xslt.util;
030:
031: import com.sun.jbi.engine.xslt.TEResources;
032: import com.sun.jbi.engine.xslt.TransformationEngineContext;
033: import com.sun.jbi.engine.xslt.util.ServiceListValidator;
034:
035: import java.io.File;
036:
037: import java.util.logging.Logger;
038:
039: import javax.jbi.component.ComponentContext;
040: import com.sun.jbi.common.management.ComponentMessageHolder;
041: import javax.jbi.management.DeploymentException;
042: import com.sun.jbi.common.management.ManagementMessageBuilder;
043: import com.sun.jbi.common.Util;
044:
045: import org.w3c.dom.Document;
046: import javax.xml.namespace.QName;
047: import org.w3c.dom.NamedNodeMap;
048: import org.w3c.dom.Node;
049: import org.w3c.dom.NodeList;
050:
051: import javax.xml.parsers.DocumentBuilderFactory;
052: import javax.xml.parsers.DocumentBuilder;
053:
054: /**
055: * This class is a Helper clas to do deployment.
056: *
057: * @author Sun Microsystems, Inc.
058: */
059: public class DeployHelper extends UtilBase implements TEResources {
060: /**
061: * Binding Context object.
062: */
063: private ComponentContext mContext;
064:
065: /**
066: * Logger object.
067: */
068: private Logger mLogger;
069:
070: /**
071: *
072: */
073: private ManagementMessageBuilder mBuildManagementMessage;
074:
075: /**
076: *
077: */
078: private ServiceManager mServiceManager;
079:
080: /**
081: * Application Sub assembly of deployment.
082: */
083: private String mServiceUnitID;
084:
085: /**
086: * Path of the sub assembly.
087: */
088: private String mServiceUnitPath;
089:
090: /**
091: * Status.
092: */
093: private String mStatus = "";
094:
095: /**
096: * Name of the Stylesheet to be used.
097: */
098: private String mStyleSheet;
099:
100: /**
101: * Wsdl file name.
102: */
103: private String mWsdlFile;
104:
105: /**
106: * Name of the Service config XMl file.
107: */
108: private String mXmlConfigFile;
109:
110: /**
111: * Helper class for i18n.
112: */
113: private StringTranslator mTranslator;
114:
115: /**
116: * Service Unit Descriptor file
117: */
118: private String mSUDescriptor;
119:
120: /**
121: * Service Unit Descriptor schema file
122: */
123: private String mSUDSchema;
124:
125: /**
126: * Service Unit Descriptor reader
127: */
128: private SUDescriptorReader mSUDescriptorReader;
129:
130: /**
131: * Array of ConfigBean holding the services defined in artifact
132: */
133: private ConfigBean[] mServicelist;
134:
135: /**
136: * Deployment File Name
137: */
138: private String mDeployFileName;
139:
140: /**
141: * Deployment Type (specified in SU jbi.xml "wsdl_20", "wsdl_11", "xml"
142: */
143: private String mDeploymentType;
144:
145: /**
146: * Creates a new DeployHelper object.
147: *
148: * @param suID application sub assembly Id.
149: * @param suPath RESOLVER
150: * @param context binding context.
151: */
152: public DeployHelper(String suID, String suPath,
153: ComponentContext context) {
154: String xsltFile;
155: setValid(true);
156: mServiceUnitID = suID;
157: mContext = context;
158: mServiceUnitPath = suPath;
159:
160: mSUDescriptor = suPath + File.separatorChar + "META-INF"
161: + File.separatorChar + ConfigData.SU_DESCRIPTOR;
162: mSUDSchema = TransformationEngineContext.getInstance()
163: .getContext().getInstallRoot()
164: + File.separatorChar + ConfigData.JBI_SCHEMA_FILE;
165:
166: mLogger = TransformationEngineContext.getInstance().getLogger(
167: "");
168:
169: mTranslator = new StringTranslator("com.sun.jbi.engine.xslt",
170: this .getClass().getClassLoader());
171:
172: /*mXmlConfigFile =
173: mServiceUnitPath + File.separatorChar + ConfigData.CONFIG_FILE_NAME;
174:
175: mWsdlFile =
176: mServiceUnitPath + File.separatorChar + ConfigData.WSDL_FILE_NAME;*/
177:
178: xsltFile = getStyleSheetName();
179:
180: if (xsltFile != null) {
181: mStyleSheet = mServiceUnitPath + File.separatorChar
182: + xsltFile;
183: mLogger.finer("Stylesheet used: " + mStyleSheet);
184: } else {
185: mLogger.finer("No Stylesheet found in : "
186: + mServiceUnitPath + " Fatal Error.");
187: setValid(false);
188: setError("No Stylesheet found in : " + mServiceUnitPath
189: + " Fatal Error.");
190: }
191:
192: mServiceManager = ServiceManager.getInstance();
193:
194: try {
195: mBuildManagementMessage = Util
196: .createManagementMessageBuilder();
197:
198: mLogger.finer(mTranslator
199: .getString(TEResources.BLD_MGMT_MSG_OBJ)
200: + mBuildManagementMessage);
201: } catch (Exception e) {
202: mLogger
203: .severe(mTranslator
204: .getString(TEResources.CANNOT_CREATE_MANAGEMENT_BUILDER));
205:
206: //throw e;
207: setValid(false);
208: }
209: }
210:
211: /**
212: * Gets the status object.
213: *
214: * @return status string.
215: */
216: public String getStatusMessage() {
217: return mStatus;
218: }
219:
220: /**
221: * Method which does the actual deployment.
222: */
223: public void doDeploy() throws DeploymentException {
224: String retMsg = null;
225:
226: // Read the SU jbi.xml and read the XSLT specific service
227: // extensions described under "TEServiceExtns" element
228: // type can be "xml" or "wsdl_20" or "wsdl_11"
229: // If the SU jbi.xml is not proper or missing, fail the deployment
230:
231: if ((mSUDescriptor != null)
232: && (new File(mSUDescriptor)).exists()) {
233: doSUDescriptorParsing();
234: }
235:
236: if (!isValid()) {
237: mLogger.severe("Error parsing Service Unit Descriptor.");
238:
239: throw new DeploymentException(createExceptionMessage(
240: mContext.getComponentName(), "deploy", "FAILED",
241: "TESE_L224", mServiceUnitID, mTranslator
242: .getString("TE_SU_DD_PARSE_FAILURE")
243: + ": " + getError(), null));
244: }
245:
246: // doSUDescriptorParsing will validate the SU DD (jbi.xml) and
247: // load the extensions into memory.
248: // Get all TE specific service extensions from SUDescriptorReader
249:
250: if (mSUDescriptorReader == null) {
251: mLogger.severe("SUDecriptorReader Null.");
252: }
253: mDeploymentType = mSUDescriptorReader
254: .getExtensionAttribute("type");
255: if (mDeploymentType.equals("xml")) {
256: mLogger.finer("Doing XML deployment.");
257: retMsg = doXMLDeploy();
258:
259: if (retMsg != null) {
260: mLogger.finer("doXMLDeploy returned: " + retMsg);
261: throw new DeploymentException(createExceptionMessage(
262: mContext.getComponentName(), "deploy",
263: "FAILED", "TESE_L233", mServiceUnitID, retMsg,
264: null));
265: }
266: } else if (mDeploymentType.equals("wsdl_20")) {
267: mDeployFileName = mSUDescriptorReader
268: .getExtensionAttribute("file-name");
269: // throw a deployment exception if any of these extension elements are null.
270: if ((mDeployFileName == null) || (mDeploymentType == null)) {
271: throw new DeploymentException(
272: createExceptionMessage(
273: mContext.getComponentName(),
274: "deploy",
275: "FAILED",
276: "TESE_L253",
277: mServiceUnitID,
278: mTranslator
279: .getString("TE_INVALID_ARTIFACT_EXTENSION_ELEMENT_ATTRIBUTES"),
280: null));
281: }
282:
283: // Check if the deployFile exists for this type
284: mDeployFileName = mServiceUnitPath + File.separatorChar
285: + mDeployFileName;
286:
287: if (!new File(mDeployFileName).exists()) {
288: throw new DeploymentException(createExceptionMessage(
289: mContext.getComponentName(), "deploy",
290: "FAILED", "TESE_L253", mServiceUnitID,
291: mTranslator.getString("TE_NO_ARTIFACT"), null));
292: }
293:
294: mLogger.finer("Doing WSDL 2.0 deployment.");
295: retMsg = doWSDL20Deploy();
296:
297: if (retMsg != null) {
298: mLogger.finer("doWSDL20Deploy returned: " + retMsg);
299: throw new DeploymentException(createExceptionMessage(
300: mContext.getComponentName(), "deploy",
301: "FAILED", "TESE_L218", mServiceUnitID, retMsg,
302: null));
303: }
304: } else if (mDeploymentType.equals("wsdl_11")) {
305: mDeployFileName = mSUDescriptorReader
306: .getExtensionAttribute("file-name");
307: // throw a deployment exception if any of these extension elements are null.
308: if ((mDeployFileName == null) || (mDeploymentType == null)) {
309: throw new DeploymentException(
310: createExceptionMessage(
311: mContext.getComponentName(),
312: "deploy",
313: "FAILED",
314: "TESE_L309",
315: mServiceUnitID,
316: mTranslator
317: .getString("TE_INVALID_ARTIFACT_EXTENSION_ELEMENT_ATTRIBUTES"),
318: null));
319: }
320:
321: // Check if the deployFile exists for this type
322: mDeployFileName = mServiceUnitPath + File.separatorChar
323: + mDeployFileName;
324:
325: if (!new File(mDeployFileName).exists()) {
326: throw new DeploymentException(createExceptionMessage(
327: mContext.getComponentName(), "deploy",
328: "FAILED", "TESE_L321", mServiceUnitID,
329: mTranslator.getString("TE_NO_ARTIFACT"), null));
330: }
331:
332: mLogger.info("Doing WSDL 1.1 deployment.");
333: retMsg = doWSDL11Deploy();
334: if (retMsg != null) {
335: mLogger.finer("doWSDL11Deploy returned: " + retMsg);
336: throw new DeploymentException(createExceptionMessage(
337: mContext.getComponentName(), "deploy",
338: "FAILED", "TESE_L334", mServiceUnitID, retMsg,
339: null));
340: }
341: } else {
342: setError(mTranslator.getString(TEResources.TE_NO_ARTIFACT));
343: setValid(false);
344: throw new DeploymentException(createExceptionMessage(
345: mContext.getComponentName(), "deploy", "FAILED",
346: "TESE_L309", mServiceUnitID, mTranslator
347: .getString("TE_NO_ARTIFACT"), null));
348: }
349: }
350:
351: /**
352: * Sets the status message.
353: *
354: * @param status status message.
355: */
356: private void setStatusMessage(String status) {
357: mStatus = status;
358: }
359:
360: /**
361: * DOCUMENT ME!
362: *
363: * @return NOT YET DOCUMENTED
364: */
365: private String getStyleSheetName() {
366: String[] xsltFileList;
367: String xsltFileName = null;
368:
369: try {
370: mLogger.finer("Getting Listing for directory: "
371: + mServiceUnitPath);
372: xsltFileList = (new File(mServiceUnitPath)).list();
373:
374: for (int i = 0; i < xsltFileList.length; i++) {
375: mLogger.finer("File List Entry: " + xsltFileList[i]);
376:
377: if (xsltFileList[i].endsWith("xsl")
378: || xsltFileList[i].endsWith("xslt")) {
379: xsltFileName = xsltFileList[i];
380:
381: break;
382: }
383: }
384: } catch (Exception e) {
385: ;
386: }
387:
388: return xsltFileName;
389: }
390:
391: /**
392: * helper method to create XML exception string.
393: *
394: * @param compid Component id.
395: * @param oper operation like deploy or undeploy
396: * @param status success r failure
397: * @param loctoken some failure string token like SEQ_300001
398: * @param locparam parameters for error message.
399: * @param locmessage error message.
400: * @param exObj stack trace of exception.
401: *
402: * @return XML string.
403: */
404: private String createExceptionMessage(String compid, String oper,
405: String status, String loctoken, String locparam,
406: String locmessage, Throwable exObj) {
407: String retMsg = null;
408:
409: String[] locParams = new String[1];
410: locParams[0] = locparam;
411:
412: ComponentMessageHolder msgMap = new ComponentMessageHolder(
413: "EXCEPTION_MSG");
414:
415: msgMap.setComponentName(compid);
416: msgMap.setTaskName(oper);
417: msgMap.setTaskResult(status);
418: msgMap.setLocToken(1, loctoken);
419: msgMap.setLocParam(1, locParams);
420: msgMap.setLocMessage(1, locmessage);
421: msgMap.setExceptionObject(exObj);
422:
423: try {
424: retMsg = mBuildManagementMessage
425: .buildComponentMessage(msgMap);
426: } catch (Exception e) {
427: mLogger.severe(mTranslator
428: .getString(TEResources.CANNOT_CREATE_MGMT_XML_MSG)
429: + e.getMessage());
430: }
431:
432: return retMsg;
433: }
434:
435: private String doWSDL11Deploy() {
436: String retMsg = null;
437:
438: try {
439: WSDL11FileReader wsdl11Reader = new WSDL11FileReader(
440: mDeployFileName);
441: if (!wsdl11Reader.isValid()) {
442: retMsg = createExceptionMessage(mContext
443: .getComponentName(), "deploy", "FAILED", "",
444: "", wsdl11Reader.getError(), null);
445: return retMsg;
446: }
447:
448: ConfigBean[] cbList = mSUDescriptorReader.loadServices();
449: if (cbList != null) {
450: QName sname = new QName((String) cbList[0].getValue(
451: ConfigData.SERVICE_NAMESPACE).elementAt(0),
452: (String) cbList[0].getValue(
453: ConfigData.SERVICENAME_LOCALPART)
454: .elementAt(0));
455: if (wsdl11Reader.isServiceDefined(sname)) {
456: mServicelist = wsdl11Reader.extractEndpoints(sname);
457: if (mServicelist == null) {
458: mLogger.severe(wsdl11Reader.getError());
459: retMsg = createExceptionMessage(mContext
460: .getComponentName(), "deploy",
461: "FAILED", "", "",
462: "Check the Deployment wsdl file."
463: + " No service specified.",
464: null);
465:
466: return retMsg;
467: }
468:
469: //Read SU jbi.xml and populate mServiceList with Service extensions
470: mSUDescriptorReader
471: .populateServiceInformation(mServicelist[0]);
472:
473: // Set the deployment type in the ConfigBean
474: mServicelist[0]
475: .setValue(ConfigData.DEPLOYMENT_TYPE,
476: mDeploymentType);
477:
478: printServiceList();
479:
480: if ((retMsg = nonxml(mServicelist[0])) != null) {
481: mLogger.finer("nonxml returned: " + retMsg);
482:
483: return retMsg;
484: }
485:
486: for (int i = 0; i < mServicelist.length; i++) {
487: mServicelist[i].setValue(mTranslator
488: .getString(TEResources.XSLTFILE),
489: mStyleSheet);
490: }
491:
492: mServiceManager.createServices(mServiceUnitID,
493: mServicelist);
494: } else {
495: retMsg = createExceptionMessage(
496: mContext.getComponentName(),
497: "deploy",
498: "FAILED",
499: "",
500: "",
501: mTranslator
502: .getString(TE_INCONSISTENT_PROVIDER_DATA),
503: null);
504: return retMsg;
505: }
506: } else {
507: retMsg = createExceptionMessage(mContext
508: .getComponentName(), "deploy", "FAILED", "",
509: "", mSUDescriptorReader.getError(), null);
510: return retMsg;
511: }
512: } catch (Exception e) {
513: mLogger
514: .severe(mTranslator
515: .getString(TEResources.TE_INCONSISTENT_PROVIDER_DATA)
516: + mServiceUnitID);
517:
518: retMsg = createExceptionMessage(
519: mContext.getComponentName(),
520: "deploy",
521: "FAILED",
522: "",
523: "",
524: mTranslator
525: .getString(TEResources.TE_INCONSISTENT_PROVIDER_DATA)
526: + mServiceUnitID, e);
527:
528: return retMsg;
529: }
530:
531: return retMsg;
532: }
533:
534: /**
535: * DOCUMENT ME!
536: *
537: * @return NOT YET DOCUMENTED
538: */
539: private String doWSDL20Deploy() {
540: String retMsg = null;
541:
542: WSDLFileValidator validator = new WSDLFileValidator(
543: mServiceUnitPath, mDeployFileName);
544: validator.validate();
545:
546: if (!validator.isValid()) {
547: Exception e = validator.getException();
548:
549: if (e != null) {
550: retMsg = createExceptionMessage(mContext
551: .getComponentName(), "deploy", "FAILED", "",
552: "", e.getMessage(), e);
553:
554: return retMsg;
555:
556: //e.printStackTrace();
557: }
558: }
559:
560: if (validator.isValid()) {
561: // This WSDL 2.0 document will not have XSLT specific extension
562: // attributes like service-id etc. They will be mentioned in
563: // the SU jbi.xml (private to TE)
564: WSDLFileReader reader = new WSDLFileReader();
565: reader.init(validator.getDocument());
566:
567: if (!reader.isValid()) {
568: Exception e = reader.getException();
569:
570: if (e != null) {
571: retMsg = createExceptionMessage(mContext
572: .getComponentName(), "deploy", "FAILED",
573: "", "", e.getMessage(), e);
574:
575: return retMsg;
576:
577: //e.printStackTrace();
578: }
579: }
580:
581: try {
582: mServicelist = reader.getServices();
583:
584: if (mServicelist == null) {
585: mLogger.severe(reader.getError());
586: retMsg = createExceptionMessage(mContext
587: .getComponentName(), "deploy", "FAILED",
588: "", "",
589: "Check the Deployment config file (service.wsdl)."
590: + " No service specified.", null);
591:
592: return retMsg;
593: }
594:
595: //Read SU jbi.xml and populate mServiceList with Service extensions
596: mSUDescriptorReader
597: .populateServiceInformation(mServicelist[0]);
598:
599: // Set the deployment type in the ConfigBean
600: mServicelist[0].setValue(ConfigData.DEPLOYMENT_TYPE,
601: mDeploymentType);
602:
603: printServiceList();
604:
605: if ((retMsg = nonxml(mServicelist[0])) != null) {
606: mLogger.finer("nonxml returned: " + retMsg);
607:
608: return retMsg;
609: }
610:
611: for (int i = 0; i < mServicelist.length; i++) {
612: mServicelist[i].setValue(mTranslator
613: .getString(TEResources.XSLTFILE),
614: mStyleSheet);
615: }
616:
617: mServiceManager.createServices(mServiceUnitID,
618: mServicelist);
619: } catch (Exception de) {
620: mLogger
621: .severe(mTranslator
622: .getString(TEResources.CAN_NOT_START_DEPLOYMENT)
623: + mServiceUnitID);
624:
625: retMsg = createExceptionMessage(
626: mContext.getComponentName(),
627: "deploy",
628: "FAILED",
629: "",
630: "",
631: mTranslator
632: .getString(TEResources.CAN_NOT_START_DEPLOYMENT)
633: + mServiceUnitID, de);
634:
635: return retMsg;
636: }
637: }
638:
639: //end if (validator.isValid()
640: return retMsg;
641: }
642:
643: /**
644: * Perform deployment of configuration XML file.
645: *
646: * @return NOT YET DOCUMENTED
647: */
648: private String doXMLDeploy() {
649: String retMsg = null;
650:
651: try {
652: mServicelist = mSUDescriptorReader.loadServices();
653:
654: if (mServicelist == null) {
655: mLogger.severe(mSUDescriptorReader.getError());
656: retMsg = createExceptionMessage(mContext
657: .getComponentName(), "deploy", "FAILED", "",
658: "", "Check the Deployment artifact file."
659: + " No service specified.", null);
660:
661: return retMsg;
662: }
663:
664: if ((retMsg = nonxml(mServicelist[0])) != null) {
665: return retMsg;
666: }
667:
668: for (int i = 0; i < mServicelist.length; i++) {
669: mServicelist[i].setValue(mTranslator
670: .getString(TEResources.XSLTFILE), mStyleSheet);
671: }
672:
673: mSUDescriptorReader
674: .populateServiceInformation(mServicelist[0]);
675: // Set the deployment type in the ConfigBean
676: mServicelist[0].setValue(ConfigData.DEPLOYMENT_TYPE,
677: mDeploymentType);
678:
679: mServiceManager
680: .createServices(mServiceUnitID, mServicelist);
681: } catch (Exception de) {
682: mLogger.severe(mTranslator
683: .getString(TEResources.CAN_NOT_START_DEPLOYMENT)
684: + mServiceUnitID);
685: retMsg = createExceptionMessage(
686: mContext.getComponentName(),
687: "deploy",
688: "FAILED",
689: "",
690: "",
691: mTranslator
692: .getString(TEResources.CAN_NOT_START_DEPLOYMENT)
693: + mServiceUnitID, null);
694:
695: return retMsg;
696: }
697:
698: return retMsg;
699: }
700:
701: /**
702: * DOCUMENT ME!
703: *
704: * @param bean NOT YET DOCUMENTED
705: *
706: * @return NOT YET DOCUMENTED
707: */
708: private String nonxml(ConfigBean bean) {
709: String retMsg = null;
710:
711: //Check for non-xml case
712: if ((bean.getValue(ConfigData.COLUMN_HEADERS) != null)
713: && (bean.getValue(ConfigData.COLUMN_HEADER) == null)) {
714: retMsg = "COLUMN_HEADERS specified but COLUMN_HEADER elements are missing.";
715:
716: return retMsg;
717: }
718:
719: if ((bean.getValue(ConfigData.COLUMN_HEADERS) == null)
720: && (bean.getValue(ConfigData.COLUMN_HEADER) != null)) {
721: retMsg = "COLUMN_HEADERS Not Found But COLUMN_HEADER elements "
722: + "are specified. Error ... Check.";
723:
724: return retMsg;
725: }
726:
727: if ((bean.getValue(ConfigData.COLUMN_HEADER) != null)
728: && (bean.getValue(ConfigData.FIRST_ROW_COL_HEADERS) != null)) {
729: retMsg = "Both COLUMN_HEADER and FIRST_ROW_COL_HEADERS elements "
730: + "are specified. Only one should be present.";
731:
732: return retMsg;
733: }
734:
735: mLogger.finer("nonxml returning: " + retMsg);
736:
737: return retMsg;
738: }
739:
740: /**
741: * DOCUMENT ME!
742: *
743: */
744: private void printServiceList() {
745: try {
746: for (int i = 0; i < mServicelist.length; i++) {
747: mLogger.finer(ConfigData.SERVICE_NAMESPACE
748: + " = "
749: + mServicelist[i].getValue(
750: ConfigData.SERVICE_NAMESPACE)
751: .elementAt(0));
752: mLogger.finer(ConfigData.ENDPOINT
753: + " = "
754: + mServicelist[i].getValue(ConfigData.ENDPOINT)
755: .elementAt(0));
756: mLogger.finer(ConfigData.SERVICEID
757: + " = "
758: + mServicelist[i]
759: .getValue(ConfigData.SERVICEID)
760: .elementAt(0));
761: mLogger.finer(ConfigData.CREATE_CACHE
762: + " = "
763: + mServicelist[i].getValue(
764: ConfigData.CREATE_CACHE).elementAt(0));
765:
766: if (mServicelist[i].getValue(
767: ConfigData.COLUMN_SEPARATOR).elementAt(0) != null) {
768: mLogger.finer(ConfigData.COLUMN_SEPARATOR
769: + " = "
770: + mServicelist[i].getValue(
771: ConfigData.COLUMN_SEPARATOR)
772: .elementAt(0));
773: }
774:
775: if (mServicelist[i].getValue(ConfigData.COLUMN_HEADER) != null) {
776: for (int k = 0; k < (mServicelist[i]
777: .getValue(ConfigData.COLUMN_HEADER)).size(); k++) {
778: mLogger.finer(ConfigData.COLUMN_HEADER
779: + " = "
780: + mServicelist[i].getValue(
781: ConfigData.COLUMN_HEADER)
782: .elementAt(k));
783: }
784: }
785: }
786:
787: //end for
788: } catch (Exception e) {
789: ;
790: }
791: }
792:
793: /**
794: * Parses the deployment descriptor jbi.xml.
795: */
796: private void doSUDescriptorParsing() {
797: mLogger.finer("mSUDSchema: " + mSUDSchema);
798: mLogger.finer("mSUDescriptor: " + mSUDescriptor);
799:
800: ServiceListValidator validator = new ServiceListValidator(
801: mSUDSchema, mSUDescriptor);
802: validator.validate();
803: //getDocument will return null if validate is not called before.
804: Document d = validator.getDocument();
805:
806: if ((!validator.isValid()) || (d == null)) {
807: mLogger.severe(mTranslator.getString(TE_INVALID_DD,
808: mSUDescriptorReader));
809: setError(mTranslator.getString(TE_INVALID_DD,
810: mSUDescriptorReader)
811: + " " + validator.getError());
812: setValid(false);
813: }
814:
815: /**
816: * Match service names in artifacts file ( endpoints.xml)
817: * and the DD. Every endpoint in the the DD file should
818: * be present in the artifacts file.
819: * We dont care if the artifacts file has more endpoints. Those
820: * will be ignored.
821: * The condition is the DD XML file should be a sub-set
822: * of artifacts file. The spec does not govern this logic so it is upto
823: * the component to decide how to veryify consistence between
824: * DD and its artifacts.
825: */
826:
827: /**
828: * A valid question that arises here is why are we having 2 XML
829: * files to decorate an endpoint.
830: * The artifacts XML file is the older form which was used when the
831: * spec did not accomodate any DD for an SU.
832: * So that is still around.
833: * Any component specific decoration for the endpoints can be done
834: * through the DD jbi.xml also. And that would be the correct way to
835: * do it.
836: * We dont do it that way because there are other modules that might
837: * depend on the endpoints.xml file, so to maintain their functionality
838: * the older endpoints.xml file is still used to decorate endpoints.
839: */
840:
841: mSUDescriptorReader = new SUDescriptorReader();
842: mLogger.finer("Created mSUDescriptorReader: ");
843:
844: mSUDescriptorReader.init(d);
845: if (!mSUDescriptorReader.isValid()) {
846: mLogger.severe(mTranslator.getString(TE_INVALID_DD,
847: ConfigData.SU_DESCRIPTOR));
848: setError(mTranslator.getString(TE_INVALID_DD,
849: ConfigData.SU_DESCRIPTOR)
850: + " " + mSUDescriptorReader.getError());
851: setValid(false);
852: }
853:
854: mSUDescriptorReader.check();
855: if (!mSUDescriptorReader.isValid()) {
856: mLogger.severe(mTranslator.getString(TE_INVALID_DD,
857: ConfigData.SU_DESCRIPTOR));
858: setError(mTranslator.getString(TE_INVALID_DD,
859: ConfigData.SU_DESCRIPTOR)
860: + " " + mSUDescriptorReader.getError());
861: setValid(false);
862: }
863:
864: /*if (mSUDescriptorReader.getConsumerCount() != 0)
865: {
866: setError(mTranslator.getString(TE_INCONSISTENT_CONSUMER_DATA));
867: }
868:
869: if (mSUDescriptorReader.getProviderCount() != 1)
870: {
871: setError(mTranslator.getString(TE_INCONSISTENT_PROVIDER_DATA));
872: } */
873:
874: /*for(int ii=0; ii<mServicelist.length; ii++)
875: {
876: QName sername = new QName ((String)mServicelist[ii].getValue(ConfigData.SERVICE_NAMESPACE).elementAt(0),
877: (String)mServicelist[ii].getValue(ConfigData.SERVICENAME_LOCALPART).elementAt(0) );
878:
879: String epname = (String)mServicelist[ii].getValue(ConfigData.ENDPOINT).elementAt(0);
880: if (!mSUDescriptorReader.isPresent(sername, epname))
881: {
882: setError(mTranslator.getString(TE_INCONSISTENT_DATA));
883: setValid(false);
884: break;
885: }
886: }*/
887: }
888: }
|