org.sakaiproject.component.legacy.content
Class BaseContentService.BaseResourceEdit

java.lang.Object
  extended byorg.sakaiproject.component.legacy.content.BaseContentService.BaseResourceEdit
All Implemented Interfaces:
ContentResource, ContentResourceEdit, Edit, Entity, EventListener, SessionBindingListener
Enclosing class:
BaseContentService

public class BaseContentService.BaseResourceEdit
extends Object
implements ContentResourceEdit, SessionBindingListener

ContentResource implementation


Field Summary
protected  boolean m_active
          Active flag.
protected  byte[] m_body
          The body.
protected  boolean m_bodyUpdated
          When true, someone changed the body content with setContent()
protected  int m_contentLength
          The content length of the body, consult only if the body is missing (null)
protected  String m_contentType
          The content type.
protected  String m_event
          The event code for this edit.
protected  String m_filePath
          The file system path, post root, for file system stored body binary.
protected  String m_id
          The resource id.
protected  boolean m_isRemoved
          When true, the collection has been removed.
protected  ResourcePropertiesEdit m_properties
          The properties.
 
Fields inherited from interface org.sakaiproject.service.legacy.entity.Entity
SEPARATOR
 
Constructor Summary
BaseContentService.BaseResourceEdit(ContentResource other)
          Construct as a copy of another
BaseContentService.BaseResourceEdit(Element el)
          Construct from information in XML in a DOM element.
BaseContentService.BaseResourceEdit(String id)
          Construct.
 
Method Summary
protected  void activate()
          Enable editing.
protected  void closeEdit()
          Close the edit object - it cannot be used after this.
protected  void finalize()
          Clean up.
protected  String getAlternateReferenceRoot(String rootProperty)
          Compute an alternate root for a reference, based on the value of the specified property.
 byte[] getContent()
          Access the content bytes of the resource.
 int getContentLength()
          Access the content byte length.
 String getContentType()
          Access the resource MIME type.
protected  String getEvent()
          Access the event code for this edit.
 String getId()
          Access the id of the resource.
 ResourceProperties getProperties()
          Access the resource's properties.
 ResourcePropertiesEdit getPropertiesEdit()
          Access the resource's properties for modification
 String getReference()
          Access the internal reference which can be used to access the entity from within the system.
 String getReference(String rootProperty)
          Access the alternate internal reference which can be used to access the entity from within the system.
 String getUrl()
          Access the URL which can be used to access the entity.
 String getUrl(String rootProperty)
          Access the alternate URL which can be used to access the entity.
 boolean isActiveEdit()
          Check to see if the edit is still active, or has already been closed.
protected  boolean requiresCopyrightAgreement()
           
protected  void set(ContentResource other)
          Take all values from this object.
 void setContent(byte[] content)
          Set the resource content.
 void setContentLength(int length)
          Set the content byte length.
 void setContentType(String type)
          Set the resource MIME type.
protected  void setEvent(String event)
          Set the event code for this edit.
protected  void setFilePath(Time time)
          Set the file path for this resource
protected  void setRemoved()
          Set the resource as removed.
 InputStream streamContent()
          Access the content as a stream.
 Element toXml(Document doc, Stack stack)
          Serialize the resource into XML, adding an element to the doc under the top of the stack element.
 void valueBound(SessionBindingEvent event)
          SessionBindingListener implementation
 void valueUnbound(SessionBindingEvent event)
          Notifies the object that it is being unbound from a session.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_id

protected String m_id
The resource id.


m_contentType

protected String m_contentType
The content type.


m_body

protected byte[] m_body
The body. May be missing - not yet read (null)


m_contentLength

protected int m_contentLength
The content length of the body, consult only if the body is missing (null)


m_properties

protected ResourcePropertiesEdit m_properties
The properties.


m_event

protected String m_event
The event code for this edit.


m_active

protected boolean m_active
Active flag.


m_isRemoved

protected boolean m_isRemoved
When true, the collection has been removed.


m_bodyUpdated

protected boolean m_bodyUpdated
When true, someone changed the body content with setContent()


m_filePath

protected String m_filePath
The file system path, post root, for file system stored body binary.

Constructor Detail

BaseContentService.BaseResourceEdit

public BaseContentService.BaseResourceEdit(String id)
Construct.

Parameters:
id - The local resource id.

BaseContentService.BaseResourceEdit

public BaseContentService.BaseResourceEdit(ContentResource other)
Construct as a copy of another

Parameters:
other - The other to copy.

BaseContentService.BaseResourceEdit

public BaseContentService.BaseResourceEdit(Element el)
Construct from information in XML in a DOM element.

Parameters:
el - The XML DOM element.
Method Detail

setFilePath

protected void setFilePath(Time time)
Set the file path for this resource

Parameters:
time - The time on which to based the path.

set

protected void set(ContentResource other)
Take all values from this object.


finalize

protected void finalize()
Clean up.


getUrl

public String getUrl()
Description copied from interface: Entity
Access the URL which can be used to access the entity.

Specified by:
getUrl in interface Entity
Returns:
The URL which can be used to access the entity.

getReference

public String getReference()
Description copied from interface: Entity
Access the internal reference which can be used to access the entity from within the system.

Specified by:
getReference in interface Entity
Returns:
The the internal reference which can be used to access the entity from within the system.

getUrl

public String getUrl(String rootProperty)
Description copied from interface: Entity
Access the alternate URL which can be used to access the entity.

Specified by:
getUrl in interface Entity
Parameters:
rootProperty - The name of the entity property whose value controls which alternate reference URL is requested. If null, the native 'raw' URL is requested.
Returns:
The alternate URL which can be used to access the entity.

getReference

public String getReference(String rootProperty)
Description copied from interface: Entity
Access the alternate internal reference which can be used to access the entity from within the system.

Specified by:
getReference in interface Entity
Parameters:
rootProperty - The name of the entity property whose value controls which alternate reference is requested. If null, the native 'raw' reference is requested.
Returns:
The the alternate internal reference which can be used to access the entity from within the system.

getAlternateReferenceRoot

protected String getAlternateReferenceRoot(String rootProperty)
Compute an alternate root for a reference, based on the value of the specified property.

Parameters:
rootProperty - The property name.
Returns:
The alternate root, or "" if there is none.

requiresCopyrightAgreement

protected boolean requiresCopyrightAgreement()

getId

public String getId()
Access the id of the resource.

Specified by:
getId in interface Entity
Returns:
The id.

getContentLength

public int getContentLength()
Access the content byte length.

Specified by:
getContentLength in interface ContentResource
Returns:
The content byte length.

getContentType

public String getContentType()
Access the resource MIME type.

Specified by:
getContentType in interface ContentResource
Returns:
The resource MIME type.

getContent

public byte[] getContent()
                  throws ServerOverloadException
Access the content bytes of the resource.

Specified by:
getContent in interface ContentResource
Returns:
An array containing the bytes of the resource's content.
Throws:
ServerOverloadException - if server is configured to store resource body in filesystem and error occurs trying to read from filesystem.

streamContent

public InputStream streamContent()
                          throws ServerOverloadException
Access the content as a stream. Please close the stream when done as it may be holding valuable system resources.

Specified by:
streamContent in interface ContentResource
Returns:
an InputStream through which the bytes of the resource can be read.
Throws:
ServerOverloadException - if the server cannot produce the content stream at this time.

getProperties

public ResourceProperties getProperties()
Access the resource's properties.

Specified by:
getProperties in interface Entity
Returns:
The resource's properties.

setRemoved

protected void setRemoved()
Set the resource as removed.


setContentLength

public void setContentLength(int length)
Set the content byte length.

Specified by:
setContentLength in interface ContentResourceEdit
Parameters:
length - The content byte length.

setContentType

public void setContentType(String type)
Set the resource MIME type.

Specified by:
setContentType in interface ContentResourceEdit
Parameters:
type - The resource MIME type.

setContent

public void setContent(byte[] content)
Set the resource content.

Specified by:
setContent in interface ContentResourceEdit
Parameters:
content - An array containing the bytes of the resource's content.

toXml

public Element toXml(Document doc,
                     Stack stack)
Serialize the resource into XML, adding an element to the doc under the top of the stack element.

Specified by:
toXml in interface Entity
Parameters:
doc - The DOM doc to contain the XML (or null for a string return).
stack - The DOM elements, the top of which is the containing element of the new "resource" element.
Returns:
The newly added element.

getEvent

protected String getEvent()
Access the event code for this edit.

Returns:
The event code for this edit.

setEvent

protected void setEvent(String event)
Set the event code for this edit.

Parameters:
event - The event code for this edit.

getPropertiesEdit

public ResourcePropertiesEdit getPropertiesEdit()
Access the resource's properties for modification

Specified by:
getPropertiesEdit in interface Edit
Returns:
The resource's properties.

activate

protected void activate()
Enable editing.


isActiveEdit

public boolean isActiveEdit()
Check to see if the edit is still active, or has already been closed.

Specified by:
isActiveEdit in interface Edit
Returns:
true if the edit is active, false if it's been closed.

closeEdit

protected void closeEdit()
Close the edit object - it cannot be used after this.


valueBound

public void valueBound(SessionBindingEvent event)
SessionBindingListener implementation

Specified by:
valueBound in interface SessionBindingListener
Parameters:
event - the event that identifies the session

valueUnbound

public void valueUnbound(SessionBindingEvent event)
Description copied from interface: SessionBindingListener
Notifies the object that it is being unbound from a session.

Specified by:
valueUnbound in interface SessionBindingListener
Parameters:
event - the event that identifies the session