org.opencms.gwt
Class CmsGwtService

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
              extended by com.google.gwt.user.server.rpc.RemoteServiceServlet
                  extended by org.opencms.gwt.CmsGwtService
All Implemented Interfaces:
com.google.gwt.user.server.rpc.SerializationPolicyProvider, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
CmsContainerpageService, CmsCoreService, CmsGalleryService, CmsLogService, CmsPreviewService, CmsPublishService, CmsUploadService, CmsVfsService, CmsVfsSitemapService

public class CmsGwtService
extends com.google.gwt.user.server.rpc.RemoteServiceServlet

Wrapper for GWT services served through OpenCms.

Since:
8.0.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
perThreadRequest, perThreadResponse
 
Constructor Summary
CmsGwtService()
          Constructor.
 
Method Summary
 void checkPermissions(CmsObject cms)
          Checks the permissions of the current user to match the required security level.
protected  com.google.gwt.user.server.rpc.SerializationPolicy doGetSerializationPolicy(javax.servlet.http.HttpServletRequest request, java.lang.String moduleBaseURL, java.lang.String strongName)
          We do not want that the server goes to fetch files from the servlet context.
protected  void doUnexpectedFailure(java.lang.Throwable e)
           
protected  CmsLock ensureLock(CmsResource resource)
          Locks the given resource with a temporary, if not already locked by the current user.
protected  CmsLock ensureLock(CmsUUID structureId)
          Locks the given resource with a temporary, if not already locked by the current user.
protected  CmsLock ensureLock(java.lang.String sitepath)
          Locks the given resource with a temporary, if not already locked by the current user.
protected  void ensureSession()
          Ensures that the user session is still valid.
 void error(java.lang.Throwable t)
          Logs and re-throws the given exception for RPC responses.
 CmsObject getCmsObject()
          Returns the current cms context.
protected  java.util.Map<java.lang.String,CmsProperty> getPropertiesByName(java.util.List<CmsProperty> properties)
          Converts a list of properties to a map.
 javax.servlet.http.HttpServletRequest getRequest()
          Returns the current request.
 javax.servlet.http.HttpServletResponse getResponse()
          Returns the current response.
 void log(java.lang.String msg)
           
 void log(java.lang.String message, java.lang.Throwable t)
           
 void logError(java.lang.Throwable t)
          Logs the given exception.
 void service(javax.servlet.ServletRequest arg0, javax.servlet.ServletResponse arg1)
           
 void setCms(CmsObject cms)
          Sets the current cms context.
 void setContext(CmsGwtServiceContext context)
          Sets the service context.
 void setRequest(javax.servlet.http.HttpServletRequest request)
          Sets the current request.
protected  void tryUnlock(CmsResource resource)
          Tries to unlock a resource.
 
Methods inherited from class com.google.gwt.user.server.rpc.RemoteServiceServlet
checkPermutationStrongName, getSerializationPolicy, onAfterResponseSerialized, onBeforeRequestDeserialized, processCall, processPost, shouldCompressResponse
 
Methods inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
doPost, getPermutationStrongName, getThreadLocalRequest, getThreadLocalResponse, onAfterRequestDeserialized, readContent
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsGwtService

public CmsGwtService()
Constructor.

Method Detail

checkPermissions

public void checkPermissions(CmsObject cms)
                      throws CmsRoleViolationException
Checks the permissions of the current user to match the required security level.

Note that the current request and response are not available yet.

Override if needed.

Parameters:
cms - the current cms object
Throws:
CmsRoleViolationException - if the security level can not be satisfied

error

public void error(java.lang.Throwable t)
           throws CmsRpcException
Logs and re-throws the given exception for RPC responses.

Parameters:
t - the exception
Throws:
CmsRpcException - the converted exception

getCmsObject

public CmsObject getCmsObject()
Returns the current cms context.

Returns:
the current cms context

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Returns the current request.

Returns:
the current request
See Also:
AbstractRemoteServiceServlet.getThreadLocalRequest()

getResponse

public javax.servlet.http.HttpServletResponse getResponse()
Returns the current response.

Returns:
the current response
See Also:
AbstractRemoteServiceServlet.getThreadLocalResponse()

log

public void log(java.lang.String msg)
Overrides:
log in class javax.servlet.GenericServlet
See Also:
GenericServlet.log(java.lang.String)

log

public void log(java.lang.String message,
                java.lang.Throwable t)
Overrides:
log in class javax.servlet.GenericServlet
See Also:
GenericServlet.log(java.lang.String, java.lang.Throwable)

logError

public void logError(java.lang.Throwable t)
Logs the given exception.

Parameters:
t - the exception to log

service

public void service(javax.servlet.ServletRequest arg0,
                    javax.servlet.ServletResponse arg1)
             throws javax.servlet.ServletException,
                    java.io.IOException
Specified by:
service in interface javax.servlet.Servlet
Overrides:
service in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException
See Also:
HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)

setCms

public void setCms(CmsObject cms)
Sets the current cms context.

Parameters:
cms - the current cms context to set

setContext

public void setContext(CmsGwtServiceContext context)
Sets the service context.

Parameters:
context - the new service context

setRequest

public void setRequest(javax.servlet.http.HttpServletRequest request)
Sets the current request.

Parameters:
request - the request to set

doGetSerializationPolicy

protected com.google.gwt.user.server.rpc.SerializationPolicy doGetSerializationPolicy(javax.servlet.http.HttpServletRequest request,
                                                                                      java.lang.String moduleBaseURL,
                                                                                      java.lang.String strongName)
We do not want that the server goes to fetch files from the servlet context.

Overrides:
doGetSerializationPolicy in class com.google.gwt.user.server.rpc.RemoteServiceServlet
See Also:
RemoteServiceServlet.doGetSerializationPolicy(javax.servlet.http.HttpServletRequest, java.lang.String, java.lang.String)

doUnexpectedFailure

protected void doUnexpectedFailure(java.lang.Throwable e)
Overrides:
doUnexpectedFailure in class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
See Also:
AbstractRemoteServiceServlet.doUnexpectedFailure(java.lang.Throwable)

ensureLock

protected CmsLock ensureLock(CmsResource resource)
                      throws CmsException
Locks the given resource with a temporary, if not already locked by the current user. Will throw an exception if the resource could not be locked for the current user.

Parameters:
resource - the resource to lock
Returns:
the assigned lock
Throws:
CmsException - if the resource could not be locked

ensureLock

protected CmsLock ensureLock(CmsUUID structureId)
                      throws CmsException
Locks the given resource with a temporary, if not already locked by the current user. Will throw an exception if the resource could not be locked for the current user.

Parameters:
structureId - the structure id of the resource
Returns:
the assigned lock
Throws:
CmsException - if something goes wrong

ensureLock

protected CmsLock ensureLock(java.lang.String sitepath)
                      throws CmsException
Locks the given resource with a temporary, if not already locked by the current user. Will throw an exception if the resource could not be locked for the current user.

Parameters:
sitepath - the site-path of the resource to lock
Returns:
the assigned lock
Throws:
CmsException - if the resource could not be locked

ensureSession

protected void ensureSession()
                      throws CmsException
Ensures that the user session is still valid.

Throws:
CmsException - if the current user is the guest user

getPropertiesByName

protected java.util.Map<java.lang.String,CmsProperty> getPropertiesByName(java.util.List<CmsProperty> properties)
Converts a list of properties to a map.

Parameters:
properties - the list of properties
Returns:
a map from property names to properties

tryUnlock

protected void tryUnlock(CmsResource resource)
Tries to unlock a resource.

Parameters:
resource - the resource to unlock