View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/ebxml/infomodel/ExtrinsicObjectImpl.java,v 1.23 2003/08/21 06:17:56 farrukh_najmi Exp $ 3 * 4 * 5 */ 6 7 package com.sun.xml.registry.ebxml.infomodel; 8 9 import java.io.*; 10 11 import javax.xml.registry.*; 12 import javax.xml.registry.infomodel.*; 13 14 import com.sun.xml.registry.ebxml.LifeCycleManagerImpl; 15 import com.sun.xml.registry.ebxml.RegistryServiceImpl; 16 import com.sun.xml.registry.ebxml.util.*; 17 18 import org.oasis.ebxml.registry.bindings.rim.ExtrinsicObjectType; 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 ExtrinsicObjectImpl extends RegistryEntryImpl 26 implements ExtrinsicObject 27 { 28 private String mimeType = null; 29 private boolean opaque = false; 30 private javax.activation.DataHandler repositoryItem = null; 31 32 public ExtrinsicObjectImpl(LifeCycleManagerImpl lcm) 33 throws JAXRException { 34 super(lcm); 35 } 36 37 public ExtrinsicObjectImpl(LifeCycleManagerImpl lcm, 38 ExtrinsicObjectType ebExtrinsicObj) 39 throws JAXRException 40 { 41 super(lcm, ebExtrinsicObj); 42 43 mimeType = ebExtrinsicObj.getMimeType(); 44 opaque = ebExtrinsicObj.getIsOpaque(); 45 } 46 47 public Concept getObjectType() throws JAXRException { 48 Concept objectType = super.getObjectType(); 49 50 if (objectType == null) { 51 if (objectType == null) { 52 objectType = bqm.findConceptByPath("/urn:uuid:3188a449-18ac-41fb-be9f-99a1adca02cb/RegistryObject/RegistryEntry/ExtrinsicObject"); 53 if (objectType != null) { 54 setObjectType(objectType); 55 } 56 } 57 } 58 return objectType; 59 } 60 61 /*** 62 * Set the ObjectType of this ExtrinsicObject's repository item. This 63 * needs to be added to the JAXR 2.0 as an ExtrinsicObject method. 64 * 65 * @param objectTypeStr The ObjectType enumeration value as a String 66 */ 67 public void setObjectType(String objectTypeStr) throws JAXRException { 68 if (objectTypeStr == null) { 69 throw i18nUtil.newJAXRException("null.ObjectType"); 70 } 71 this.objectTypeStr = objectTypeStr; 72 setModified(true); 73 } 74 75 /*** 76 * Set the ObjectType of this ExtrinsicObject's repository item. This 77 * needs to be added to the JAXR 2.0 as an ExtrinsicObject method. 78 * 79 * @param objectTypeThe ObjectType enumeration value as a Concept 80 */ 81 public void setObjectType(Concept objectType) throws JAXRException { 82 this.objectType = objectType; 83 this.objectTypeStr = objectType.getKey().getId(); 84 setModified(true); 85 } 86 87 88 public String toXML() throws JAXRException { 89 org.oasis.ebxml.registry.bindings.rim.RegistryObjectType ebObj = toBindingObject(); 90 StringWriter sw = new StringWriter(); 91 try { 92 ebObj.marshal(sw); 93 } catch (org.exolab.castor.xml.MarshalException x) { 94 throw new JAXRException(x); 95 } catch (org.exolab.castor.xml.ValidationException x) { 96 throw new JAXRException(x); 97 } 98 return sw.toString(); 99 } 100 101 public String getMimeType() throws JAXRException { 102 // Return the mimeType if we know it else ask the repositoryItem 103 if (mimeType == null && repositoryItem != null) { 104 mimeType = repositoryItem.getContentType(); 105 } 106 return mimeType; 107 } 108 109 public void setMimeType(String par1) throws JAXRException { 110 mimeType = par1; 111 setModified(true); 112 } 113 114 public boolean isOpaque() throws JAXRException { 115 return opaque; 116 } 117 118 public void setOpaque(boolean par1) throws JAXRException { 119 opaque = par1; 120 setModified(true); 121 } 122 123 public String getContentURI() throws JAXRException { 124 //?? This will be removed from JAXR API 125 return null; 126 } 127 128 public javax.activation.DataHandler getRepositoryItem() 129 throws UnsupportedCapabilityException, JAXRException 130 { 131 if (repositoryItem != null) { 132 return repositoryItem; 133 } 134 else if (!isNew()) { 135 136 // Execute a getContentRequest to obtain RepositoryItem from server 137 String gcr = 138 BindingUtil.getInstance().toGetContentRequest(this.getId()); 139 RegistryServiceImpl regService = 140 (RegistryServiceImpl)lcm.getRegistryService(); 141 regService.getSoapMessenger().sendSoapRequest(gcr); 142 143 // At this point, server should have returned the RepositoryItem to 144 // us if one exists. It is also possible to have an 145 // ExtrinsicObject without a repository item (RI) if only the RI 146 // was removed but not the ExtrinsicObject. 147 } 148 149 return repositoryItem; 150 } 151 152 public void setRepositoryItem(javax.activation.DataHandler dataHandler) 153 throws javax.xml.registry.UnsupportedCapabilityException, 154 javax.xml.registry.JAXRException 155 { 156 this.repositoryItem = dataHandler; 157 } 158 159 public org.oasis.ebxml.registry.bindings.rim.ExtrinsicObject 160 toBindingObject() throws JAXRException 161 { 162 org.oasis.ebxml.registry.bindings.rim.ExtrinsicObject ebExtrinsicObj = 163 new org.oasis.ebxml.registry.bindings.rim.ExtrinsicObject(); 164 165 setBindingObject(ebExtrinsicObj); 166 167 return ebExtrinsicObj; 168 } 169 170 protected void setBindingObject(org.oasis.ebxml.registry.bindings.rim.ExtrinsicObjectType ebExtrinsicObj) throws JAXRException { 171 super.setBindingObject(ebExtrinsicObj); 172 173 ebExtrinsicObj.setMimeType(mimeType); 174 ebExtrinsicObj.setIsOpaque(isOpaque()); 175 176 if (objectType != null) { 177 ebExtrinsicObj.setObjectType(objectType.getKey().getId()); 178 } 179 } 180 }

This page was automatically generated by Maven