View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/ebxml/infomodel/SpecificationLinkImpl.java,v 1.15 2003/07/23 01:14:51 farrukh_najmi Exp $ 3 * 4 * 5 */ 6 7 package com.sun.xml.registry.ebxml.infomodel; 8 9 import javax.xml.registry.*; 10 import javax.xml.registry.infomodel.*; 11 import java.util.*; 12 import java.io.*; 13 14 import com.sun.xml.registry.ebxml.LifeCycleManagerImpl; 15 import javax.xml.registry.infomodel.ServiceBinding.*; 16 17 import org.oasis.ebxml.registry.bindings.rim.ServiceBindingType; 18 import org.oasis.ebxml.registry.bindings.rim.SpecificationLinkType; 19 import org.oasis.ebxml.registry.bindings.rim.ObjectRef; 20 21 /*** 22 * Class Declaration for Class1 23 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 24 */ 25 public class SpecificationLinkImpl extends RegistryObjectImpl 26 implements SpecificationLink 27 { 28 private RegistryObjectRef specificationObjectRef = null; 29 private InternationalString usageDescription = null; 30 private ArrayList usageParams = new ArrayList(); 31 private RegistryObjectRef bindingRef = null; 32 33 public SpecificationLinkImpl(LifeCycleManagerImpl lcm) 34 throws JAXRException 35 { 36 super(lcm); 37 } 38 39 public SpecificationLinkImpl(LifeCycleManagerImpl lcm, SpecificationLinkType ebSpecLink) 40 throws JAXRException 41 { 42 super(lcm, ebSpecLink); 43 44 45 //In version 2.1 there is no servicebinding on specLink du to a spec bug. 46 //SO instead of a lazy fetck we will fetch up front 47 //bindingRef = new RegistryObjectRef(lcm, ebSpecLink.getServiceBinding()); 48 49 if (ebSpecLink.getSpecificationObject() != null) { 50 specificationObjectRef = new RegistryObjectRef(lcm, ebSpecLink.getSpecificationObject()); 51 } 52 53 if (ebSpecLink.getUsageDescription() != null) { 54 usageDescription = new InternationalStringImpl( 55 lcm, ebSpecLink.getUsageDescription()); 56 } 57 58 String[] usageParamsArr = ebSpecLink.getUsageParameter(); 59 for (int i = 0; i < usageParamsArr.length; i++) { 60 usageParams.add(usageParamsArr[i]); 61 } 62 } 63 64 public String toXML() throws JAXRException { 65 org.oasis.ebxml.registry.bindings.rim.RegistryObjectType ebObj = toBindingObject(); 66 StringWriter sw = new StringWriter(); 67 try { 68 ebObj.marshal(sw); 69 } catch (org.exolab.castor.xml.MarshalException x) { 70 throw new JAXRException(x); 71 } catch (org.exolab.castor.xml.ValidationException x) { 72 throw new JAXRException(x); 73 } 74 return sw.toString(); 75 } 76 77 public RegistryObject getSpecificationObject() throws JAXRException { 78 RegistryObject specificationObject = null; 79 if (specificationObjectRef != null) { 80 specificationObject = specificationObjectRef.getRegistryObject("RegistryObject"); 81 } 82 83 return specificationObject; 84 } 85 86 public void setSpecificationObject(RegistryObject specificationObject) throws JAXRException { 87 specificationObjectRef = new RegistryObjectRef(lcm, specificationObject); 88 setModified(true); 89 } 90 91 public InternationalString getUsageDescription() throws JAXRException { 92 if (usageDescription == null) { 93 usageDescription = lcm.createInternationalString(); 94 } 95 return usageDescription; 96 } 97 98 public void setUsageDescription(InternationalString desc) throws JAXRException { 99 usageDescription = desc; 100 setModified(true); 101 } 102 103 public Collection getUsageParameters() throws JAXRException { 104 return usageParams; 105 } 106 107 public void setUsageParameters(Collection par1) throws JAXRException { 108 usageParams.clear(); 109 usageParams.addAll(par1); 110 setModified(true); 111 } 112 113 //??JAXR 2.0 114 public RegistryObjectRef getServiceBindingRef() throws JAXRException { 115 return bindingRef; 116 } 117 118 public ServiceBinding getServiceBinding() throws JAXRException { 119 ServiceBinding binding = null; 120 if (bindingRef != null) { 121 binding = (ServiceBinding)bindingRef.getRegistryObject("ServiceBinding"); 122 } else { 123 if (!isNew()) { 124 //Do a query to get the parent ServiceBinding from server 125 //??? 126 throw new JAXRException("Unfinished code. Contact dev team."); 127 } 128 } 129 130 return binding; 131 } 132 133 /*** 134 * Internal method to set the sourceObject 135 */ 136 void setServiceBindingInternal(ServiceBinding binding) throws JAXRException { 137 bindingRef = new RegistryObjectRef(lcm, binding); 138 setModified(true); 139 } 140 141 142 /*** 143 * Not to be used by clients. Expected to be used only by ServiceBindingImpl. 144 */ 145 void setServiceBinding(ServiceBinding _binding) throws JAXRException { 146 RegistryObjectRef serviceBindingRef = getServiceBindingRef(); 147 if (serviceBindingRef != null) { 148 if (!(_binding.getKey().getId().equals(serviceBindingRef.getId()))) { 149 if (!(_binding instanceof ServiceBindingImpl)) { 150 throw new InvalidRequestException("Expected ServiceBindingImpl, got " + _binding); 151 } 152 setServiceBindingInternal(_binding); 153 } 154 } 155 } 156 157 /*** 158 * This method takes this JAXR infomodel object and returns an 159 * equivalent binding object for it. Note it does the reverse of one 160 * of the constructors above. 161 */ 162 public org.oasis.ebxml.registry.bindings.rim.SpecificationLink toBindingObject() throws JAXRException { 163 org.oasis.ebxml.registry.bindings.rim.SpecificationLink ebSpecLink = 164 new org.oasis.ebxml.registry.bindings.rim.SpecificationLink(); 165 166 setBindingObject(ebSpecLink); 167 168 return ebSpecLink; 169 } 170 171 protected void setBindingObject(org.oasis.ebxml.registry.bindings.rim.SpecificationLinkType ebSpecLink) throws JAXRException { 172 super.setBindingObject(ebSpecLink); 173 174 //private ArrayList usageParams = new ArrayList(); 175 176 /* 177 * Version 2.1 does not have serviceBinding attribute on SpecificationLink 178 if (binding != null) { 179 org.oasis.ebxml.registry.bindings.rim.ObjectRef ebServiceBindingRef = 180 new org.oasis.ebxml.registry.bindings.rim.ObjectRef(); 181 ebServiceBindingRef.setId(binding.getKey().getId()); 182 ebSpecLink.setServiceBinding(ebServiceBindingRef); 183 } 184 */ 185 186 if (specificationObjectRef != null) { 187 org.oasis.ebxml.registry.bindings.rim.ObjectRef ebSpecObjectRef = 188 new org.oasis.ebxml.registry.bindings.rim.ObjectRef(); 189 ebSpecObjectRef.setId(specificationObjectRef.getId()); 190 ebSpecLink.setSpecificationObject(ebSpecObjectRef); 191 } 192 193 org.oasis.ebxml.registry.bindings.rim.UsageDescription ebUsageDesc = 194 new org.oasis.ebxml.registry.bindings.rim.UsageDescription(); 195 ((InternationalStringImpl)getUsageDescription()).setBindingObject(ebUsageDesc); 196 ebSpecLink.setUsageDescription(ebUsageDesc); 197 198 Iterator iter = getUsageParameters().iterator(); 199 while (iter.hasNext()) { 200 String usageParam = (String)iter.next(); 201 ebSpecLink.addUsageParameter(usageParam); 202 } 203 204 } 205 206 /*** 207 * Used by LifeCycleManagerImpl.saveObjects 208 * 209 */ 210 public HashSet getRegistryObjectRefs() { 211 HashSet refs = new HashSet(); 212 213 //refs.addAll(super.getRegistryObjectRefs()); 214 215 if (specificationObjectRef != null) { 216 refs.add(specificationObjectRef); 217 } 218 219 return refs; 220 } 221 222 }

This page was automatically generated by Maven