1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.juddi.handler;
17
18 import java.util.Vector;
19
20 import org.apache.juddi.datatype.RegistryObject;
21 import org.apache.juddi.datatype.request.AuthInfo;
22 import org.apache.juddi.datatype.request.GetAssertionStatusReport;
23 import org.apache.juddi.datatype.response.CompletionStatus;
24 import org.apache.juddi.util.xml.XMLUtils;
25 import org.w3c.dom.Element;
26
27 /***
28 * @author Steve Viens (sviens@apache.org)
29 */
30 public class GetAssertionStatusReportHandler extends AbstractHandler
31 {
32 public static final String TAG_NAME = "get_assertionStatusReport";
33
34 private HandlerMaker maker = null;
35
36 protected GetAssertionStatusReportHandler(HandlerMaker maker)
37 {
38 this.maker = maker;
39 }
40
41 public RegistryObject unmarshal(Element element)
42 {
43 GetAssertionStatusReport obj = new GetAssertionStatusReport();
44 Vector nodeList = null;
45 AbstractHandler handler = null;
46
47
48 String generic = element.getAttribute("generic");
49 if ((generic != null && (generic.trim().length() > 0)))
50 obj.setGeneric(generic);
51
52
53
54
55
56 nodeList = XMLUtils.getChildElementsByTagName(element,AuthInfoHandler.TAG_NAME);
57 if (nodeList.size() > 0)
58 {
59 handler = maker.lookup(AuthInfoHandler.TAG_NAME);
60 obj.setAuthInfo((AuthInfo)handler.unmarshal((Element)nodeList.elementAt(0)));
61 }
62
63 nodeList = XMLUtils.getChildElementsByTagName(element,CompletionStatusHandler.TAG_NAME);
64 if (nodeList.size() > 0)
65 {
66 handler = maker.lookup(CompletionStatusHandler.TAG_NAME);
67 obj.setCompletionStatus((CompletionStatus)handler.unmarshal((Element)nodeList.elementAt(0)));
68 }
69
70 return obj;
71 }
72
73 public void marshal(RegistryObject object,Element parent)
74 {
75 GetAssertionStatusReport request = (GetAssertionStatusReport)object;
76 String generic = request.getGeneric();
77 generic = getGeneric(generic);
78 String namespace = getUDDINamespace(generic);
79 Element element = parent.getOwnerDocument().createElementNS(namespace,TAG_NAME);
80 AbstractHandler handler = null;
81
82 element.setAttribute("generic",generic);
83
84 AuthInfo authInfo = request.getAuthInfo();
85 if (authInfo != null)
86 {
87 handler = maker.lookup(AuthInfoHandler.TAG_NAME);
88 handler.marshal(authInfo,element);
89 }
90
91 String status = request.getCompletionStatus();
92 if (status != null)
93 {
94 handler = maker.lookup(CompletionStatusHandler.TAG_NAME);
95 handler.marshal(new CompletionStatus(status),element);
96 }
97
98 parent.appendChild(element);
99 }
100
101
102 /****************************************************************************/
103 /****************************** TEST DRIVER *********************************/
104 /****************************************************************************/
105
106
107 public static void main(String args[])
108 throws Exception
109 {
110 HandlerMaker maker = HandlerMaker.getInstance();
111 AbstractHandler handler = maker.lookup(GetAssertionStatusReportHandler.TAG_NAME);
112
113 Element parent = XMLUtils.newRootElement();
114 Element child = null;
115
116 AuthInfo authInfo = new AuthInfo();
117 authInfo.setValue("6f157513-844e-4a95-a856-d257e6ba9726");
118
119 GetAssertionStatusReport service = new GetAssertionStatusReport();
120 service.setAuthInfo(authInfo);
121 service.setCompletionStatus(CompletionStatus.COMPLETE);
122
123 System.out.println();
124
125 RegistryObject regObject = service;
126 handler.marshal(regObject,parent);
127 child = (Element)parent.getFirstChild();
128 parent.removeChild(child);
129 XMLUtils.writeXML(child,System.out);
130
131 System.out.println();
132
133 regObject = handler.unmarshal(child);
134 handler.marshal(regObject,parent);
135 child = (Element)parent.getFirstChild();
136 parent.removeChild(child);
137 XMLUtils.writeXML(child,System.out);
138 }
139 }