org.apache.lenya.cms.publication
Class PublicationFactory

java.lang.Object
  extended by org.apache.lenya.cms.publication.PublicationFactory

public final class PublicationFactory
extends java.lang.Object

Factory for creating publication objects.


Method Summary
static boolean existsPublication(java.lang.String id, java.lang.String servletContextPath)
          Checks if a publication with a certain ID exists in a certain context.
protected static java.lang.String generateKey(java.lang.String publicationId, java.lang.String servletContextPath)
          Generates a key to cache a publication.
static Publication getPublication(java.util.Map objectModel)
          Creates a new publication.
static Publication getPublication(org.apache.cocoon.environment.Request request, org.apache.cocoon.environment.Context context)
          Creates a new publication based on a request and a context.
static Publication getPublication(org.apache.excalibur.source.SourceResolver resolver, org.apache.cocoon.environment.Request request)
          Creates a publication using a source resolver and a request.
static Publication getPublication(java.lang.String webappUrl, java.io.File servletContext)
          Creates a publication from a webapp URL and a servlet context directory.
static Publication getPublication(java.lang.String id, java.lang.String servletContextPath)
          Create a new publication with the given publication-id and servlet context path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getPublication

public static Publication getPublication(java.util.Map objectModel)
                                  throws PublicationException
Creates a new publication. The publication ID is resolved from the request URI. The servlet context path is resolved from the context object.

Parameters:
objectModel - The object model of the Cocoon component.
Returns:
a Publication
Throws:
PublicationException - if there was a problem creating the publication.

getPublication

public static Publication getPublication(java.lang.String id,
                                         java.lang.String servletContextPath)
                                  throws PublicationException
Create a new publication with the given publication-id and servlet context path. These publications are cached and reused for similar requests.

Parameters:
id - the publication id
servletContextPath - the servlet context path of the publication
Returns:
a Publication
Throws:
PublicationException - if there was a problem creating the publication.

generateKey

protected static java.lang.String generateKey(java.lang.String publicationId,
                                              java.lang.String servletContextPath)
                                       throws PublicationException
Generates a key to cache a publication. The cache key is constructed using the canonical servlet context path and the publication ID.

Parameters:
publicationId - The publication ID.
servletContextPath - The servlet context path.
Returns:
A cache key.
Throws:
PublicationException - when the servlet context does not exist.

getPublication

public static Publication getPublication(org.apache.cocoon.environment.Request request,
                                         org.apache.cocoon.environment.Context context)
                                  throws PublicationException
Creates a new publication based on a request and a context.

Parameters:
request - A request.
context - A context.
Returns:
A publication.
Throws:
PublicationException - if there was a problem creating the publication.

getPublication

public static Publication getPublication(java.lang.String webappUrl,
                                         java.io.File servletContext)
                                  throws PublicationException
Creates a publication from a webapp URL and a servlet context directory.

Parameters:
webappUrl - The URL within the web application (without context prefix)
servletContext - The Lenya servlet context directory
Returns:
A publication
Throws:
PublicationException - when something went wrong

existsPublication

public static boolean existsPublication(java.lang.String id,
                                        java.lang.String servletContextPath)
Checks if a publication with a certain ID exists in a certain context.

Parameters:
id - The publication ID.
servletContextPath - The webapp context path.
Returns:
true if the publication exists, false otherwise.

getPublication

public static Publication getPublication(org.apache.excalibur.source.SourceResolver resolver,
                                         org.apache.cocoon.environment.Request request)
                                  throws PublicationException
Creates a publication using a source resolver and a request.

Parameters:
resolver - The source resolver.
request - The request.
Returns:
A publication.
Throws:
PublicationException - when something went wrong.


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.