1 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.GetPublisherAssertions; 23 import org.apache.juddi.util.xml.XMLUtils; 24 import org.w3c.dom.Element ; 25 26 29 public class GetPublisherAssertionsHandler extends AbstractHandler 30 { 31 public static final String TAG_NAME = "get_publisherAssertions"; 32 33 private HandlerMaker maker = null; 34 35 protected GetPublisherAssertionsHandler(HandlerMaker maker) 36 { 37 this.maker = maker; 38 } 39 40 public RegistryObject unmarshal(Element element) 41 { 42 GetPublisherAssertions obj = new GetPublisherAssertions(); 43 Vector nodeList = null; 44 AbstractHandler handler = null; 45 46 String generic = element.getAttribute("generic"); 48 if ((generic != null && (generic.trim().length() > 0))) 49 obj.setGeneric(generic); 50 51 54 nodeList = XMLUtils.getChildElementsByTagName(element,AuthInfoHandler.TAG_NAME); 56 if (nodeList.size() > 0) 57 { 58 handler = maker.lookup(AuthInfoHandler.TAG_NAME); 59 obj.setAuthInfo((AuthInfo)handler.unmarshal((Element )nodeList.elementAt(0))); 60 } 61 62 return obj; 63 } 64 65 public void marshal(RegistryObject object,Element parent) 66 { 67 GetPublisherAssertions request = (GetPublisherAssertions)object; 68 Element element = parent.getOwnerDocument().createElementNS(null,TAG_NAME); 69 AbstractHandler handler = null; 70 71 String generic = request.getGeneric(); 72 if (generic != null) 73 element.setAttribute("generic",generic); 74 75 AuthInfo authInfo = request.getAuthInfo(); 76 if (authInfo != null) 77 { 78 handler = maker.lookup(AuthInfoHandler.TAG_NAME); 79 handler.marshal(authInfo,element); 80 } 81 82 parent.appendChild(element); 83 } 84 85 86 87 88 89 90 91 public static void main(String args[]) 92 throws Exception 93 { 94 HandlerMaker maker = HandlerMaker.getInstance(); 95 AbstractHandler handler = maker.lookup(GetPublisherAssertionsHandler.TAG_NAME); 96 97 Element parent = XMLUtils.newRootElement(); 98 Element child = null; 99 100 AuthInfo authInfo = new AuthInfo(); 101 authInfo.setValue("6f157513-844e-4a95-a856-d257e6ba9726"); 102 103 GetPublisherAssertions service = new GetPublisherAssertions(); 104 service.setAuthInfo(authInfo); 105 106 System.out.println(); 107 108 RegistryObject regObject = service; 109 handler.marshal(regObject,parent); 110 child = (Element )parent.getFirstChild(); 111 parent.removeChild(child); 112 XMLUtils.writeXML(child,System.out); 113 114 System.out.println(); 115 116 regObject = handler.unmarshal(child); 117 handler.marshal(regObject,parent); 118 child = (Element )parent.getFirstChild(); 119 parent.removeChild(child); 120 XMLUtils.writeXML(child,System.out); 121 } 122 } | Popular Tags |