View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/ebxml/infomodel/AuditableEventImpl.java,v 1.13 2003/08/13 04:03:28 farrukh_najmi Exp $ 3 * 4 */ 5 6 package com.sun.xml.registry.ebxml.infomodel; 7 8 import javax.xml.registry.*; 9 import javax.xml.registry.infomodel.*; 10 import java.sql.Timestamp; 11 import java.io.*; 12 13 import com.sun.xml.registry.ebxml.LifeCycleManagerImpl; 14 import org.oasis.ebxml.registry.bindings.rim.AuditableEventType; 15 import org.oasis.ebxml.registry.bindings.rim.types.EventTypeType; 16 17 /*** 18 * Class Declaration for Class1 19 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 20 */ 21 public class AuditableEventImpl extends RegistryObjectImpl 22 implements AuditableEvent 23 { 24 private RegistryObjectRef userRef = null; 25 private Timestamp timestamp = null; 26 private int eventType = AuditableEvent.EVENT_TYPE_CREATED; 27 private RegistryObjectRef registryObjectRef = null; 28 29 /*** 30 * ??eeg Looks like JAXR allows this to be created using 31 * LCM.createObject() and server allows such an object to be saved, but 32 * I'm not sure why anyone would want to do that. 33 */ 34 public AuditableEventImpl(LifeCycleManagerImpl lcm) 35 throws JAXRException 36 { 37 super(lcm); 38 } 39 40 public AuditableEventImpl(LifeCycleManagerImpl lcm, AuditableEventType ebAE) 41 throws JAXRException 42 { 43 super(lcm, ebAE); 44 45 // Set the eventType 46 EventTypeType ebEventType = ebAE.getEventType(); 47 if (ebEventType == EventTypeType.CREATED) { 48 eventType = AuditableEvent.EVENT_TYPE_CREATED; 49 } else if (ebEventType == EventTypeType.DELETED) { 50 eventType = AuditableEvent.EVENT_TYPE_DELETED; 51 } else if (ebEventType == EventTypeType.DEPRECATED) { 52 eventType = AuditableEvent.EVENT_TYPE_DEPRECATED; 53 } else if (ebEventType == EventTypeType.UPDATED) { 54 eventType = AuditableEvent.EVENT_TYPE_UPDATED; 55 } else if (ebEventType == EventTypeType.VERSIONED) { 56 eventType = AuditableEvent.EVENT_TYPE_VERSIONED; 57 } 58 59 registryObjectRef = new RegistryObjectRef( 60 lcm, ebAE.getRegistryObject()); 61 timestamp = new Timestamp((ebAE.getTimestamp()).getTime()); 62 userRef = new RegistryObjectRef(lcm, ebAE.getUser()); 63 } 64 65 public String toXML() throws JAXRException { 66 org.oasis.ebxml.registry.bindings.rim.RegistryObjectType ebObj = toBindingObject(); 67 StringWriter sw = new StringWriter(); 68 try { 69 ebObj.marshal(sw); 70 } catch (org.exolab.castor.xml.MarshalException x) { 71 throw new JAXRException(x); 72 } catch (org.exolab.castor.xml.ValidationException x) { 73 throw new JAXRException(x); 74 } 75 return sw.toString(); 76 } 77 78 //Possible addition to JAXR 2.0?? 79 public RegistryObjectRef getUserRef() throws JAXRException { 80 return userRef; 81 } 82 83 public User getUser() throws JAXRException { 84 User user = null; 85 if (userRef != null) { 86 user = (User)userRef.getRegistryObject("User"); 87 } 88 89 return user; 90 } 91 92 public Timestamp getTimestamp() throws JAXRException { 93 return timestamp; 94 } 95 96 public int getEventType() throws JAXRException { 97 return eventType; 98 } 99 100 public RegistryObject getRegistryObject() throws JAXRException { 101 RegistryObject ro = null; 102 if (registryObjectRef != null) { 103 ro = registryObjectRef.getRegistryObject("RegistryObject"); 104 } 105 106 return ro; 107 } 108 109 /*** 110 * This method takes this JAXR infomodel object and returns an 111 * equivalent binding object for it. Note it does the reverse of one 112 * of the constructors above. 113 */ 114 public org.oasis.ebxml.registry.bindings.rim.AuditableEvent toBindingObject() throws JAXRException 115 { 116 org.oasis.ebxml.registry.bindings.rim.AuditableEvent ebOrg = 117 new org.oasis.ebxml.registry.bindings.rim.AuditableEvent(); 118 119 setBindingObject(ebOrg); 120 121 return ebOrg; 122 } 123 124 protected void setBindingObject(AuditableEventType ebOrg) 125 throws JAXRException 126 { 127 super.setBindingObject(ebOrg); 128 } 129 }

This page was automatically generated by Maven