org.activemath.webapp.ws
Class BookListResource

java.lang.Object
  extended by org.activemath.webapp.ws.BookListResource
All Implemented Interfaces:
EventListener, ActivemathEventListener, ResourceHandler

public class BookListResource
extends Object
implements ResourceHandler, ActivemathEventListener

Simple wrapper of the ContentManager to represent itself as resource for web-services that can use it to create links into ActiveMath. Used into Moodle book-page-presentation menu. TODO: refactor this class as a generic class "content-descripting-resource" which has a similar lifecycle than, e.g., an RSS feed on content changes, or a map of some sort about the content: it gets reset at every content change (or so) but is otherwise highly static hence is stored on disk and delivered from there.


Method Summary
static BookListResource getInstance()
           
 int getLength()
          To populate the Content-Length header.
 String getMimeTypeChosen(Iterator acceptedMimeType)
          Chooses the appropriate mime-type from the list provided.
 long getModificationDate()
          To be returned to answer such queries as HTTP HEAD queries.
 void onActivemathEvent(ActivemathEvent event)
          Handle an Activemath event.
 void outputRepresentation(OutputStream response, String mimeTypes)
          Outputs content a descriptive state representation in the mime-type it recognizes as appropriate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getModificationDate

public long getModificationDate()
Description copied from interface: ResourceHandler
To be returned to answer such queries as HTTP HEAD queries.

Specified by:
getModificationDate in interface ResourceHandler
Returns:
the expected last-modification date or -1 if it is not known in which case, one assumes it was modified instantenously

getInstance

public static BookListResource getInstance()

outputRepresentation

public void outputRepresentation(OutputStream response,
                                 String mimeTypes)
                          throws IOException
Description copied from interface: ResourceHandler
Outputs content a descriptive state representation in the mime-type it recognizes as appropriate.

Specified by:
outputRepresentation in interface ResourceHandler
Parameters:
response - the response to output to, the content-length, content-type and other headers should first be set.
mimeTypes - the list of mime-types as received by the Accept-Type http header.
Throws:
IOException

getMimeTypeChosen

public String getMimeTypeChosen(Iterator acceptedMimeType)
Description copied from interface: ResourceHandler
Chooses the appropriate mime-type from the list provided. This call is expected to be followed by a call to ResourceHandler.outputRepresentation(java.io.OutputStream, java.lang.String).

Specified by:
getMimeTypeChosen in interface ResourceHandler
Parameters:
acceptedMimeType - an iterator of mime-types (such as text/plain possbly followed by a semicolon with a quality value)
Returns:
the chosen mime-type

getLength

public int getLength()
Description copied from interface: ResourceHandler
To populate the Content-Length header.

Specified by:
getLength in interface ResourceHandler
Returns:
the length if known or -1 if unknown

onActivemathEvent

public void onActivemathEvent(ActivemathEvent event)
Description copied from interface: ActivemathEventListener
Handle an Activemath event.

This method must return as quickly as possible and must not block the calling thread for long.

Specified by:
onActivemathEvent in interface ActivemathEventListener
Parameters:
event - the event to respond to