Dekoh platform API

dekoh.portal.fwk.share
Class RequestContext

java.lang.Object
  extended by dekoh.portal.fwk.share.RequestContext
Direct Known Subclasses:
LocalRequestContext

public class RequestContext
extends Object

A RequestContext is sandboxed way for templates to only access the entities that requested in the current URL.

An instance of RequestContext is made after incoming request passes all the security rules. The scope of the RequestContext is HttpServletRequest scope. The instance is available against key RequestContext.REQUEST_CONTEXT_ATTRIBUTE.

Since:
Nov 16, 2006
See Also:
DekohAccessController, ShareFilter

Field Summary
protected  String contextPath
           
static String DIO_ID_PARAMETER_KEY
          Key against which the owner that has installed Dekoh locally will be set in Butterfly header.
protected  DIOEntityManager em
           
protected  HttpServletRequest request
           
static String REQUEST_CONTEXT_ATTRIBUTE
          Key against which an instance of RequestContext will be available in Request scope.
 
Constructor Summary
protected RequestContext(HttpServletRequest request, DIOEntityManager requestScopeEntityManager, DIOEntityManagerFactory dioemf)
           
  RequestContext(HttpServletRequest request, DIOEntityManager requestScopeEntityManager, DIOEntityManagerFactory dioemf, String contextPath)
           
 
Method Summary
protected  void checkAccessControl()
           
protected  void checkAccessControl(AccessPath accessPath)
           
 AccessPath createAccessPath(String numberTrain)
           
protected  DioCollectionQueryInterface createDioCollectionQueryInterface(DIOEntityManager em)
           
protected  MailTemplateObject createMailTemplateObject(ShareMetadata metadata)
           
static RequestContext createRequestContext(HttpServletRequest request, DIOEntityManager requestLocalEntityManager, DIOEntityManagerFactory factory, String contextpath)
           
static RequestContext createRequestContext(HttpServletRequest request, DIOEntityManager requestLocalEntityManager, DIOEntityManagerFactory factory, String contextPath, Class sqiImplClass, Class lrcImplClass)
           
static RequestContext createRequestContext(HttpServletRequest request, DIOEntityManager requestLocalEntityManager, DIOEntityManagerFactory factory, String contextPath, Class rcImplClass, Class sqiImplClass, Class lrcImplClass)
           
static RequestContext createRequestContext(HttpServletRequest request, DIOEntityManagerFactory factory, String contextpath)
           
protected  ResizeImageCache createResizeImageCache()
           
 ShareQueryInterface createShareQueryInterface(AccessPath accessPath)
           
 ShareQueryInterface createShareQueryInterface(AccessPath accessPath, String contextPath)
           
 List findMostRecentComments(int numComments)
           
 String getAccessOptionUri(HttpServletRequest request, String accessOptionString)
           
 AccessPath getAccessPath()
           
 AccessPath getAccessPathForComment(Comment comment)
           
 List getAllCommentsForDigitalObject(Integer dioId)
           
 Buddy getBuddy()
          This method returns the buddy who is accessing the current collection.
protected  Comment getCommentOrThrowException(String commentId, DIOEntityManager localEm)
           
 String getContextPath()
           
 Page getDigitalObjectPage(DioCollection dioCollection, Class cls, int pageNumber, int pageSize)
           
 DigitalObject getDio(Class entityClass, int id)
           
 DioCollectionQueryInterface getDioCollectionQueryInterface()
           
 int getDioId()
           
 DioQueryInterface getDioQueryInterface()
           
protected  File getImageCacheDir()
           
 Set getIncomingUserAliases()
           
 ResizeImageCache getOrCreateResizeImageCache()
           
 String getOwnerName()
           
protected  String getOwnerUserName(HttpServletRequest request)
           
 String getQueryParams()
           
static RequestContext getRequestContext(HttpServletRequest request)
          Gets instance of this class set on the given servlet's request context.
protected  ResizeImageCache getResizeImageCacheInContext()
           
 ShareQueryInterface getShareQueryInterface()
           
 boolean isAnonymousAccess()
           
 boolean isLocalRequest()
           
static boolean isRemoteAccess(HttpServletRequest req)
           
 Comment postNewComment(String comment, AccessPath accessPath, String dioId)
          Adds new comment to a dioId.
 void recordBuddyVisit(Share share, Buddy buddy)
           
 Comment replyToComment(String comment, String commentId)
          Post Reply to comment.
 void setDioCollectionQueryInterface(DioCollectionQueryInterface dioCollectionQueryInterface)
           
 void setDioQueryInterface(DioQueryInterface dioQueryInterface)
           
protected  void setResizeImageCacheInContext(ResizeImageCache resizeImageCache)
           
 void setShareQueryInterface(ShareQueryInterface shareQueryInterface)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST_CONTEXT_ATTRIBUTE

public static final String REQUEST_CONTEXT_ATTRIBUTE
Key against which an instance of RequestContext will be available in Request scope.

See Also:
Constant Field Values

DIO_ID_PARAMETER_KEY

public static final String DIO_ID_PARAMETER_KEY
Key against which the owner that has installed Dekoh locally will be set in Butterfly header.

See Also:
Constant Field Values

em

protected DIOEntityManager em

contextPath

protected String contextPath

request

protected final HttpServletRequest request
Constructor Detail

RequestContext

protected RequestContext(HttpServletRequest request,
                         DIOEntityManager requestScopeEntityManager,
                         DIOEntityManagerFactory dioemf)

RequestContext

public RequestContext(HttpServletRequest request,
                      DIOEntityManager requestScopeEntityManager,
                      DIOEntityManagerFactory dioemf,
                      String contextPath)
Method Detail

getRequestContext

public static RequestContext getRequestContext(HttpServletRequest request)
Gets instance of this class set on the given servlet's request context.

Parameters:
request -
Returns:
an instance

createRequestContext

public static RequestContext createRequestContext(HttpServletRequest request,
                                                  DIOEntityManager requestLocalEntityManager,
                                                  DIOEntityManagerFactory factory,
                                                  String contextPath,
                                                  Class sqiImplClass,
                                                  Class lrcImplClass)

createRequestContext

public static RequestContext createRequestContext(HttpServletRequest request,
                                                  DIOEntityManager requestLocalEntityManager,
                                                  DIOEntityManagerFactory factory,
                                                  String contextPath,
                                                  Class rcImplClass,
                                                  Class sqiImplClass,
                                                  Class lrcImplClass)

createResizeImageCache

protected ResizeImageCache createResizeImageCache()

getOrCreateResizeImageCache

public ResizeImageCache getOrCreateResizeImageCache()

getResizeImageCacheInContext

protected ResizeImageCache getResizeImageCacheInContext()

setResizeImageCacheInContext

protected void setResizeImageCacheInContext(ResizeImageCache resizeImageCache)

createRequestContext

public static RequestContext createRequestContext(HttpServletRequest request,
                                                  DIOEntityManager requestLocalEntityManager,
                                                  DIOEntityManagerFactory factory,
                                                  String contextpath)

createRequestContext

public static RequestContext createRequestContext(HttpServletRequest request,
                                                  DIOEntityManagerFactory factory,
                                                  String contextpath)

checkAccessControl

protected void checkAccessControl(AccessPath accessPath)

createDioCollectionQueryInterface

protected DioCollectionQueryInterface createDioCollectionQueryInterface(DIOEntityManager em)

checkAccessControl

protected void checkAccessControl()

createMailTemplateObject

protected MailTemplateObject createMailTemplateObject(ShareMetadata metadata)

setShareQueryInterface

public void setShareQueryInterface(ShareQueryInterface shareQueryInterface)

getShareQueryInterface

public ShareQueryInterface getShareQueryInterface()

createShareQueryInterface

public ShareQueryInterface createShareQueryInterface(AccessPath accessPath)
                                              throws IllegalURLException,
                                                     AccessDeniedException
Throws:
IllegalURLException
AccessDeniedException

createShareQueryInterface

public ShareQueryInterface createShareQueryInterface(AccessPath accessPath,
                                                     String contextPath)
                                              throws IllegalURLException,
                                                     AccessDeniedException
Throws:
IllegalURLException
AccessDeniedException

setDioCollectionQueryInterface

public void setDioCollectionQueryInterface(DioCollectionQueryInterface dioCollectionQueryInterface)

getDioCollectionQueryInterface

public DioCollectionQueryInterface getDioCollectionQueryInterface()

setDioQueryInterface

public void setDioQueryInterface(DioQueryInterface dioQueryInterface)

getDioQueryInterface

public DioQueryInterface getDioQueryInterface()

getImageCacheDir

protected File getImageCacheDir()

createAccessPath

public AccessPath createAccessPath(String numberTrain)
                            throws IllegalURLException,
                                   AccessDeniedException
Throws:
IllegalURLException
AccessDeniedException

isLocalRequest

public boolean isLocalRequest()

getOwnerUserName

protected String getOwnerUserName(HttpServletRequest request)

isRemoteAccess

public static boolean isRemoteAccess(HttpServletRequest req)

getAccessPath

public AccessPath getAccessPath()

getContextPath

public String getContextPath()

getAccessOptionUri

public String getAccessOptionUri(HttpServletRequest request,
                                 String accessOptionString)

getQueryParams

public String getQueryParams()

getOwnerName

public String getOwnerName()

getDioId

public int getDioId()

getAllCommentsForDigitalObject

public List getAllCommentsForDigitalObject(Integer dioId)

getDio

public DigitalObject getDio(Class entityClass,
                            int id)

replyToComment

public Comment replyToComment(String comment,
                              String commentId)
Post Reply to comment.

Parameters:
comment - - comment text
commentId - - reply to comment
Returns:
return added reply comment.
Throws:
IllegalArgumentException
javax.ejb.NoSuchEntityException

getCommentOrThrowException

protected final Comment getCommentOrThrowException(String commentId,
                                                   DIOEntityManager localEm)
Parameters:
commentId -
localEm -
Returns:
Throws:
NoSuchEntityException

postNewComment

public Comment postNewComment(String comment,
                              AccessPath accessPath,
                              String dioId)
Adds new comment to a dioId.

Parameters:
comment -
accessPath -
dioId -
Returns:
Throws:
IllegalArgumentException - if this is a local user.

getBuddy

public Buddy getBuddy()
This method returns the buddy who is accessing the current collection. for requests which are made through DWR and have no currentPath, this method will return the first incoming user contect, who may not be a buddy for a given share. so use this api with caution.

Returns:

isAnonymousAccess

public boolean isAnonymousAccess()

findMostRecentComments

public List findMostRecentComments(int numComments)

getDigitalObjectPage

public Page getDigitalObjectPage(DioCollection dioCollection,
                                 Class cls,
                                 int pageNumber,
                                 int pageSize)

getIncomingUserAliases

public Set getIncomingUserAliases()
Returns:

recordBuddyVisit

public void recordBuddyVisit(Share share,
                             Buddy buddy)

getAccessPathForComment

public AccessPath getAccessPathForComment(Comment comment)

Dekoh platform API

© 2009 Pramati Technologies - Dekoh - Portal for Developers