org.opencms.ade.contenteditor
Class CmsContentService

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
                      extended by org.opencms.ade.contenteditor.CmsContentService
All Implemented Interfaces:
com.alkacon.acacia.shared.rpc.I_ContentService, com.google.gwt.user.client.rpc.RemoteService, com.google.gwt.user.server.rpc.SerializationPolicyProvider, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, I_CmsContentService

public class CmsContentService
extends CmsGwtService
implements I_CmsContentService

Service to provide entity persistence within OpenCms.

See Also:
Serialized Form

Field Summary
protected static org.apache.commons.logging.Log LOG
          The logger for this class.
 
Fields inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
perThreadRequest, perThreadResponse
 
Fields inherited from interface org.opencms.ade.contenteditor.shared.rpc.I_CmsContentService
DICT_CONTENT_DEFINITION, PARAM_BACKLINK
 
Constructor Summary
CmsContentService()
           
 
Method Summary
protected  java.lang.String decodeNewLink(java.lang.String newLink)
          Decodes the newlink request parameter if possible.
static java.lang.String getAttributeName(I_CmsXmlContentValue contentValue)
          Returns the entity attribute name representing the given content value.
static java.lang.String getAttributeName(java.lang.String elementName, java.lang.String parentType)
          Returns the entity attribute name to use for this element.
protected  java.lang.String getElementName(java.lang.String attributeName)
          Returns the element name to the given element.
static java.lang.String getEntityId(I_CmsXmlContentValue contentValue)
          Returns the entity id to the given content value.
protected  java.lang.String getFileEncoding(CmsObject cms, CmsResource file)
          Helper method to determine the encoding of the given file in the VFS, which must be set using the "content-encoding" property.
static java.lang.String getTypeUri(CmsXmlContentDefinition xmlContentDefinition)
          Returns the type URI.
 com.alkacon.acacia.shared.ContentDefinition loadContentDefinition(java.lang.String entityId)
           
 CmsContentDefinition loadDefinition(java.lang.String entityId)
          Loads the content definition for a given entity.
 CmsContentDefinition loadDefinition(java.lang.String entityId, java.lang.String newLink, CmsUUID modelFileId, java.lang.String editContext)
          Loads the content definition for a given entity.
 CmsContentDefinition loadNewDefinition(java.lang.String entityId)
          Loads new entity definition.
 CmsContentDefinition prefetch()
          Returns the content definition of the resource requested through parameter 'resource'.
static CmsContentDefinition prefetch(javax.servlet.http.HttpServletRequest request)
          Fetches the initial content definition.
protected  com.alkacon.acacia.shared.Entity readEntity(CmsXmlContent content, org.dom4j.Element element, java.util.Locale locale, java.lang.String entityId, java.lang.String parentPath, java.lang.String typeName, java.util.Map<java.lang.String,com.alkacon.vie.shared.I_Type> registeredTypes)
          Parses the element into an entity.
protected  java.util.Map<java.lang.String,com.alkacon.vie.shared.I_Type> readTypes(CmsXmlContentDefinition xmlContentDefinition, java.util.Locale locale)
          Reads the types from the given content definition and adds the to the map of already registered types if necessary.
 com.alkacon.acacia.shared.ValidationResult saveAndDeleteEntities(java.util.List<com.alkacon.acacia.shared.Entity> changedEntities, java.util.List<java.lang.String> deletedEntities, boolean clearOnSuccess)
          Saves and deletes the given entities.
 com.alkacon.acacia.shared.ValidationResult saveEntities(java.util.List<com.alkacon.acacia.shared.Entity> entities)
           
 com.alkacon.acacia.shared.ValidationResult saveEntity(com.alkacon.acacia.shared.Entity entity)
           
 com.alkacon.acacia.shared.ValidationResult validateEntities(java.util.List<com.alkacon.acacia.shared.Entity> changedEntities)
           
 
Methods inherited from class org.opencms.gwt.CmsGwtService
checkPermissions, clearThreadStorage, doGetSerializationPolicy, doUnexpectedFailure, ensureLock, ensureLock, ensureLock, ensureSession, error, getCmsObject, getPropertiesByName, getRequest, getResponse, log, log, logError, service, setCms, setContext, setRequest, setResponse, tryUnlock
 
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
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG
The logger for this class.

Constructor Detail

CmsContentService

public CmsContentService()
Method Detail

getAttributeName

public static java.lang.String getAttributeName(I_CmsXmlContentValue contentValue)
Returns the entity attribute name representing the given content value.

Parameters:
contentValue - the content value
Returns:
the attribute name

getAttributeName

public static java.lang.String getAttributeName(java.lang.String elementName,
                                                java.lang.String parentType)
Returns the entity attribute name to use for this element.

Parameters:
elementName - the element name
parentType - the parent type
Returns:
the attribute name

getEntityId

public static java.lang.String getEntityId(I_CmsXmlContentValue contentValue)
Returns the entity id to the given content value.

Parameters:
contentValue - the content value
Returns:
the entity id

getTypeUri

public static java.lang.String getTypeUri(CmsXmlContentDefinition xmlContentDefinition)
Returns the type URI.

Parameters:
xmlContentDefinition - the type content definition
Returns:
the type URI

prefetch

public static CmsContentDefinition prefetch(javax.servlet.http.HttpServletRequest request)
                                     throws CmsRpcException
Fetches the initial content definition.

Parameters:
request - the current request
Returns:
the initial content definition
Throws:
CmsRpcException - if something goes wrong

loadContentDefinition

public com.alkacon.acacia.shared.ContentDefinition loadContentDefinition(java.lang.String entityId)
                                                                  throws CmsRpcException
Specified by:
loadContentDefinition in interface com.alkacon.acacia.shared.rpc.I_ContentService
Throws:
CmsRpcException
See Also:
I_ContentService.loadContentDefinition(java.lang.String)

loadDefinition

public CmsContentDefinition loadDefinition(java.lang.String entityId)
                                    throws CmsRpcException
Description copied from interface: I_CmsContentService
Loads the content definition for a given entity.

Specified by:
loadDefinition in interface I_CmsContentService
Parameters:
entityId - the entity id/URI
Returns:
the content definition
Throws:
CmsRpcException
See Also:
I_CmsContentService.loadDefinition(java.lang.String)

loadDefinition

public CmsContentDefinition loadDefinition(java.lang.String entityId,
                                           java.lang.String newLink,
                                           CmsUUID modelFileId,
                                           java.lang.String editContext)
                                    throws CmsRpcException
Description copied from interface: I_CmsContentService
Loads the content definition for a given entity.

Specified by:
loadDefinition in interface I_CmsContentService
Parameters:
entityId - the entity id/URI
newLink - the new link
modelFileId - the optional model file id
editContext - the container page currently being edited (may be null)
Returns:
the content definition
Throws:
CmsRpcException - if something goes wrong processing the request
See Also:
I_CmsContentService.loadDefinition(java.lang.String, java.lang.String, org.opencms.util.CmsUUID, java.lang.String)

loadNewDefinition

public CmsContentDefinition loadNewDefinition(java.lang.String entityId)
                                       throws CmsRpcException
Description copied from interface: I_CmsContentService
Loads new entity definition.

This will load the entity representation of a new locale node.

Specified by:
loadNewDefinition in interface I_CmsContentService
Parameters:
entityId - the entity id/URI
Returns:
the content definition
Throws:
CmsRpcException - if something goes wrong processing the request
See Also:
I_CmsContentService.loadNewDefinition(java.lang.String)

prefetch

public CmsContentDefinition prefetch()
                              throws CmsRpcException
Description copied from interface: I_CmsContentService
Returns the content definition of the resource requested through parameter 'resource'.

Specified by:
prefetch in interface I_CmsContentService
Returns:
the content definition
Throws:
CmsRpcException - if something goes wrong
See Also:
I_CmsContentService.prefetch()

saveAndDeleteEntities

public com.alkacon.acacia.shared.ValidationResult saveAndDeleteEntities(java.util.List<com.alkacon.acacia.shared.Entity> changedEntities,
                                                                        java.util.List<java.lang.String> deletedEntities,
                                                                        boolean clearOnSuccess)
                                                                 throws CmsRpcException
Description copied from interface: I_CmsContentService
Saves and deletes the given entities. Returns a validation result in case of invalid entities.

Specified by:
saveAndDeleteEntities in interface I_CmsContentService
Parameters:
changedEntities - the changed entities
deletedEntities - the entity id's to delete
clearOnSuccess - true to unlock resource after saving
Returns:
the validation result in case of invalid entities
Throws:
CmsRpcException - if something goes wrong processing the request
See Also:
I_CmsContentService.saveAndDeleteEntities(java.util.List, java.util.List, boolean)

saveEntities

public com.alkacon.acacia.shared.ValidationResult saveEntities(java.util.List<com.alkacon.acacia.shared.Entity> entities)
                                                        throws CmsRpcException
Specified by:
saveEntities in interface com.alkacon.acacia.shared.rpc.I_ContentService
Throws:
CmsRpcException
See Also:
I_ContentService.saveEntities(java.util.List)

saveEntity

public com.alkacon.acacia.shared.ValidationResult saveEntity(com.alkacon.acacia.shared.Entity entity)
                                                      throws CmsRpcException
Specified by:
saveEntity in interface com.alkacon.acacia.shared.rpc.I_ContentService
Throws:
CmsRpcException
See Also:
I_ContentService.saveEntity(com.alkacon.acacia.shared.Entity)

validateEntities

public com.alkacon.acacia.shared.ValidationResult validateEntities(java.util.List<com.alkacon.acacia.shared.Entity> changedEntities)
                                                            throws CmsRpcException
Specified by:
validateEntities in interface com.alkacon.acacia.shared.rpc.I_ContentService
Throws:
CmsRpcException
See Also:
I_ContentService.validateEntities(java.util.List)

decodeNewLink

protected java.lang.String decodeNewLink(java.lang.String newLink)
Decodes the newlink request parameter if possible.

Parameters:
newLink - the parameter to decode
Returns:
the decoded value

getElementName

protected java.lang.String getElementName(java.lang.String attributeName)
Returns the element name to the given element.

Parameters:
attributeName - the attribute name
Returns:
the element name

getFileEncoding

protected java.lang.String getFileEncoding(CmsObject cms,
                                           CmsResource file)
Helper method to determine the encoding of the given file in the VFS, which must be set using the "content-encoding" property.

Parameters:
cms - the CmsObject
file - the file which is to be checked
Returns:
the encoding for the file

readEntity

protected com.alkacon.acacia.shared.Entity readEntity(CmsXmlContent content,
                                                      org.dom4j.Element element,
                                                      java.util.Locale locale,
                                                      java.lang.String entityId,
                                                      java.lang.String parentPath,
                                                      java.lang.String typeName,
                                                      java.util.Map<java.lang.String,com.alkacon.vie.shared.I_Type> registeredTypes)
Parses the element into an entity.

Parameters:
content - the entity content
element - the current element
locale - the content locale
entityId - the entity id
parentPath - the parent path
typeName - the entity type name
registeredTypes - the types used within the entity
Returns:
the entity

readTypes

protected java.util.Map<java.lang.String,com.alkacon.vie.shared.I_Type> readTypes(CmsXmlContentDefinition xmlContentDefinition,
                                                                                  java.util.Locale locale)
Reads the types from the given content definition and adds the to the map of already registered types if necessary.

Parameters:
xmlContentDefinition - the XML content definition
locale - the messages locale
Returns:
the types of the given content definition