KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > request > SetPublisherAssertions


1 /*
2  * The source code contained herein is licensed under the IBM Public License
3  * Version 1.0, which has been approved by the Open Source Initiative.
4  * Copyright (C) 2001, Hewlett-Packard Company
5  * All Rights Reserved.
6  *
7  */

8
9 package org.uddi4j.request;
10
11 import java.util.Vector JavaDoc;
12
13 import org.uddi4j.UDDIElement;
14 import org.uddi4j.UDDIException;
15 import org.uddi4j.datatype.assertion.PublisherAssertion;
16 import org.uddi4j.util.AuthInfo;
17 import org.w3c.dom.Element JavaDoc;
18 import org.w3c.dom.NodeList JavaDoc;
19
20 /**
21  * Represents the set_publisherAssertions element within the UDDI version 2.0 schema.
22  * This class contains the following types of methods:
23  *
24  * <ul>
25  * <li>A constructor that passes the required fields.
26  * <li>A Constructor that will instantiate the object from an appropriate XML
27  * DOM element.
28  * <li>Get/set methods for each attribute that this element can contain.
29  * <li>A get/setVector method is provided for sets of attributes.
30  * <li>A SaveToXML method that serializes this class within a passed in
31  * element.
32  * </ul>
33  *
34  * Typically, this class is used to construct parameters for, or interpret
35  * responses from, methods in the UDDIProxy class.
36  *
37  * <p><b>Element description:</b>
38  * <p>This message is used to manage all of the tracked relationship assertions
39  * associated with an individual publisher account. The full set of assertions
40  * associated with a publisher is effectively replaced whenever this message is used.
41  * When this message is processed, the UDDI registry examines the publisher assertions
42  * for a given publisher account. It examines the assertions that were active prior to
43  * this API call and adds any new assertions that were not present to the assertions
44  * of the publisher account. Consequently, new relationships may be activated
45  * (e.g., status changed to complete), and existing relationships may be deactivated.
46  *
47  * @author Ravi Trivedi (ravi_trivedi@hp.com)
48  * @author Ozzy (ozzy@hursley.ibm.com)
49  */

50 public class SetPublisherAssertions extends UDDIElement {
51
52    public static final String JavaDoc UDDI_TAG = "set_publisherAssertions";
53    protected Element base = null;
54
55    AuthInfo authInfo = null;
56    Vector JavaDoc pubAssertion = new Vector JavaDoc();
57
58    /**
59     * Default constructor.
60     * Avoid using the default constructor for validation. It does not validate
61     * required fields. Instead, use the required fields constructor to perform
62     * validation.
63     */

64    public SetPublisherAssertions() {
65    }
66
67    /**
68     * Construct the object from a DOM tree. Used by
69     * UDDIProxy to construct an object from a received UDDI
70     * message.
71     *
72     * @param base Element with the name appropriate for this class.
73     *
74     * @exception UDDIException Thrown if DOM tree contains a SOAP fault
75     * or a disposition report indicating a UDDI error.
76     */

77    public SetPublisherAssertions(Element base) throws UDDIException {
78         // Check if it is a fault. Throws an exception if it is.
79
super(base);
80         NodeList JavaDoc nl = null;
81         nl = getChildElementsByTagName(base, AuthInfo.UDDI_TAG);
82         if (nl.getLength() > 0) {
83              authInfo = new AuthInfo((Element)nl.item(0));
84         }
85         nl = getChildElementsByTagName(base, PublisherAssertion.UDDI_TAG);
86
87         for (int i=0; i < nl.getLength(); i++) {
88           pubAssertion.addElement(new PublisherAssertion((Element)nl.item(i)));
89        }
90    }
91
92    /**
93     * Construct the object with required fields.
94     *
95     * @param authInfo String
96     * @param pubAssertVector Vector
97     */

98    public SetPublisherAssertions(String JavaDoc authInfo, Vector JavaDoc pubAssertVector) {
99       this.authInfo = new AuthInfo();
100       this.authInfo.setText(authInfo);
101       this.pubAssertion = pubAssertVector;
102    }
103
104    public void setPublisherAssertionVector(Vector JavaDoc pubAssertVector ) {
105       this.pubAssertion = pubAssertVector;
106    }
107
108    public Vector JavaDoc getPublisherAssertionVector() {
109       return this.pubAssertion;
110    }
111
112    public AuthInfo getAuthInfo() {
113       return this.authInfo;
114    }
115
116    public void setAuthInfo(AuthInfo s) {
117       this.authInfo = s;
118    }
119
120    public String JavaDoc getAuthInfoString() {
121       if(authInfo!=null)
122         return this.authInfo.getText();
123       else
124         return null;
125    }
126
127    public void setAuthInfo(String JavaDoc s) {
128       authInfo = new AuthInfo();
129       authInfo.setText(s);
130    }
131
132    /**
133     * Save an object to the DOM tree. Used to serialize an object
134     * to a DOM tree, usually to send a UDDI message.
135     *
136     * <BR>Used by UDDIProxy.
137     *
138     * @param parent Object will serialize as a child element under the
139     * passed in parent element.
140     */

141    public void saveToXML(Element parent) {
142        base = parent.getOwnerDocument().createElement(UDDI_TAG);
143         // Save attributes.
144
base.setAttribute("generic", UDDIElement.GENERIC);
145         base.setAttribute("xmlns", UDDIElement.XMLNS);
146        if (authInfo!=null) {
147             authInfo.saveToXML(base);
148        }
149        if (pubAssertion!=null) {
150          for (int i=0; i < pubAssertion.size(); i++) {
151             ((PublisherAssertion)(pubAssertion.elementAt(i))).saveToXML(base);
152          }
153        }
154        parent.appendChild(base);
155    }
156 }
157
Popular Tags