Package org.opencms.ade.contenteditor
Class CmsContentService
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
-
- com.google.gwt.user.server.rpc.RemoteServiceServlet
-
- org.opencms.gwt.CmsGwtService
-
- org.opencms.ade.contenteditor.CmsContentService
-
- All Implemented Interfaces:
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
,I_CmsContentService
public class CmsContentService extends CmsGwtService implements I_CmsContentService
Service to provide entity persistence within OpenCms.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ATTR_EDITOR_SAVING
Request context attribute to mark a writeFile() triggered by the user saving in the content editor.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
Constructors Constructor Description CmsContentService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CmsContentDefinition
callEditorChangeHandlers(java.lang.String entityId, CmsEntity editedLocaleEntity, java.util.Collection<java.lang.String> skipPaths, java.util.Collection<java.lang.String> changedScopes)
Calls the editor change handlers.void
copyLocale(java.util.Collection<java.lang.String> locales, CmsEntity sourceLocale)
Copies the given source locale to the target locales.protected java.lang.String
decodeNewLink(java.lang.String newLink)
Decodes the newlink request parameter if possible.static java.lang.String
defaultCreateResourceToEdit(CmsObject cms, java.lang.String newLink, java.util.Locale locale, java.lang.String referenceSitePath, java.lang.String modelFileSitePath, java.lang.String mode, java.lang.String postCreateHandler)
Creates a new resource to edit, delegating to an edit handler if edit handler data is passed in.static java.lang.String
getAttributeName(java.lang.String elementName, java.lang.String parentType)
Returns the entity attribute name to use for this element.static java.lang.String
getAttributeName(I_CmsXmlContentValue contentValue)
Returns the entity attribute name representing the given content value.CmsObject
getCmsObject()
Returns the current cms context.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
getRdfaAttributes(I_CmsXmlDocument document, java.util.Locale contentLocale, java.lang.String elementPath)
Returns the RDF annotations required for in line editing.static java.lang.String
getRdfaAttributes(I_CmsXmlContentValue value)
Returns the RDF annotations required for in line editing.static java.lang.String
getRdfaAttributes(I_CmsXmlContentValue parentValue, java.lang.String childNames)
Returns the RDF annotations required for in line editing.static java.lang.String
getTypeUri(CmsXmlContentDefinition xmlContentDefinition)
Returns the type URI.CmsContentDefinition
loadContentDefinition(java.lang.String entityId)
Loads the content definition for a given entity.CmsContentDefinition
loadDefinition(java.lang.String entityId, java.lang.String clientId, CmsEntity editedLocaleEntity, java.util.Collection<java.lang.String> skipPaths, java.util.Map<java.lang.String,java.lang.String> settingPresets)
Loads the content definition for a given entity.CmsContentDefinition
loadInitialDefinition(java.lang.String entityId, java.lang.String clientId, java.lang.String newLink, CmsUUID modelFileId, java.lang.String editContext, java.lang.String mainLocale, java.lang.String mode, java.lang.String postCreateHandler, CmsEditHandlerData editHandlerDataForNew, java.util.Map<java.lang.String,java.lang.String> settingPresets, java.lang.String editorStylesheet)
Loads the content definition for a given entity.CmsContentDefinition
loadNewDefinition(java.lang.String entityId, java.lang.String clientId, CmsEntity editedLocaleEntity, java.util.Collection<java.lang.String> skipPaths, java.util.Map<java.lang.String,java.lang.String> settingPresets)
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 CmsEntity
readEntity(CmsXmlContent content, org.dom4j.Element element, java.util.Locale locale, java.lang.String entityId, java.lang.String parentPath, java.lang.String typeName, CmsContentTypeVisitor visitor, boolean includeInvisible, CmsEntity editedLocalEntity)
Parses the element into an entity.protected java.util.Map<java.lang.String,CmsType>
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.CmsSaveResult
saveAndDeleteEntities(CmsEntity lastEditedEntity, java.lang.String clientId, java.util.List<java.lang.String> deletedEntities, java.util.Collection<java.lang.String> skipPaths, java.lang.String lastEditedLocale, boolean clearOnSuccess)
Saves and deletes the given entities.CmsValidationResult
saveEntities(java.util.List<CmsEntity> entities)
Saves the given entities and returns a validation result in case of invalid entities.CmsValidationResult
saveEntity(CmsEntity entity)
Saves the given entity and returns a validation result in case of invalid entities.java.lang.String
saveValue(java.lang.String contentId, java.lang.String contentPath, java.lang.String localeString, java.lang.String newValue)
Saves a value in an existing XML content.protected void
synchronizeLocaleIndependentFields(CmsFile file, CmsXmlContent content, java.util.Collection<java.lang.String> skipPaths, java.util.Collection<CmsEntity> entities, java.util.Locale lastEdited)
Synchronizes the locale independent fields.protected void
transferInvisibleValues(CmsEntity original, CmsEntity target, CmsContentTypeVisitor visitor)
Transfers values marked as invisible from the original entity to the target entity.CmsEntityHtml
updateEntityHtml(CmsEntity entity, java.lang.String contextUri, java.lang.String htmlContextInfo)
Retrieves the updated entity HTML representation.CmsValidationResult
validateEntity(CmsEntity changedEntity)
Validates the given entity and returns maps of error and warning messages in case of invalid attributes.-
Methods inherited from class org.opencms.gwt.CmsGwtService
checkPermissions, clearThreadStorage, doGetSerializationPolicy, doUnexpectedFailure, ensureLock, ensureLock, ensureLock, ensureLock, ensureSession, error, getPropertiesByName, getRequest, getResponse, isBroadcastCall, log, log, logError, service, setBroadcastPoll, setCms, setContext, setRequest, setResponse, tryUnlock
-
Methods inherited from class com.google.gwt.user.server.rpc.RemoteServiceServlet
checkPermutationStrongName, getCodeServerPolicyUrl, getRequestModuleBasePath, getSerializationPolicy, init, loadPolicyFromCodeServer, onAfterResponseSerialized, onBeforeRequestDeserialized, processCall, 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
-
-
-
-
Field Detail
-
ATTR_EDITOR_SAVING
public static final java.lang.String ATTR_EDITOR_SAVING
Request context attribute to mark a writeFile() triggered by the user saving in the content editor.- See Also:
- Constant Field Values
-
LOG
protected static final org.apache.commons.logging.Log LOG
The logger for this class.
-
-
Constructor Detail
-
CmsContentService
public CmsContentService()
-
-
Method Detail
-
defaultCreateResourceToEdit
public static java.lang.String defaultCreateResourceToEdit(CmsObject cms, java.lang.String newLink, java.util.Locale locale, java.lang.String referenceSitePath, java.lang.String modelFileSitePath, java.lang.String mode, java.lang.String postCreateHandler) throws CmsException
Creates a new resource to edit, delegating to an edit handler if edit handler data is passed in.- Parameters:
cms
- The CmsObject of the current request context.newLink
- A string, specifying where which new content should be created.locale
- The locale for which thereferenceSitePath
- site path of the currently edited content.modelFileSitePath
- site path of the model filemode
- optional creation modepostCreateHandler
- optional class name of anI_CmsCollectorPostCreateHandler
which is invoked after the content has been created.- Returns:
- The site-path of the newly created resource.
- Throws:
CmsException
- if something goes wrong
-
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 nameparentType
- 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
-
getRdfaAttributes
public static java.lang.String getRdfaAttributes(I_CmsXmlContentValue value)
Returns the RDF annotations required for in line editing.- Parameters:
value
- the XML content value- Returns:
- the RDFA
-
getRdfaAttributes
public static java.lang.String getRdfaAttributes(I_CmsXmlContentValue parentValue, java.lang.String childNames)
Returns the RDF annotations required for in line editing.- Parameters:
parentValue
- the parent XML content valuechildNames
- the child attribute names separated by '|'- Returns:
- the RDFA
-
getRdfaAttributes
public static java.lang.String getRdfaAttributes(I_CmsXmlDocument document, java.util.Locale contentLocale, java.lang.String elementPath)
Returns the RDF annotations required for in line editing.- Parameters:
document
- the parent XML documentcontentLocale
- the content localeelementPath
- the element xpath to get the RDF annotation for- Returns:
- the RDFA
-
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
-
callEditorChangeHandlers
public CmsContentDefinition callEditorChangeHandlers(java.lang.String entityId, CmsEntity editedLocaleEntity, java.util.Collection<java.lang.String> skipPaths, java.util.Collection<java.lang.String> changedScopes) throws CmsRpcException
Description copied from interface:I_CmsContentService
Calls the editor change handlers.- Specified by:
callEditorChangeHandlers
in interfaceI_CmsContentService
- Parameters:
entityId
- the edited entity ideditedLocaleEntity
- the edited entityskipPaths
- the locale synchronization value paths to skipchangedScopes
- the changed content value paths- Returns:
- the changed content
- Throws:
CmsRpcException
- in case anything goes wrong- See Also:
I_CmsContentService.callEditorChangeHandlers(java.lang.String, org.opencms.acacia.shared.CmsEntity, java.util.Collection, java.util.Collection)
-
copyLocale
public void copyLocale(java.util.Collection<java.lang.String> locales, CmsEntity sourceLocale) throws CmsRpcException
Description copied from interface:I_CmsContentService
Copies the given source locale to the target locales.- Specified by:
copyLocale
in interfaceI_CmsContentService
- Parameters:
locales
- the target localessourceLocale
- the source locale- Throws:
CmsRpcException
- if something goes wrong- See Also:
I_CmsContentService.copyLocale(java.util.Collection, org.opencms.acacia.shared.CmsEntity)
-
getCmsObject
public CmsObject getCmsObject()
Description copied from class:CmsGwtService
Returns the current cms context.- Overrides:
getCmsObject
in classCmsGwtService
- Returns:
- the current cms context
- See Also:
CmsGwtService.getCmsObject()
-
loadContentDefinition
public CmsContentDefinition loadContentDefinition(java.lang.String entityId) throws CmsRpcException
Description copied from interface:I_CmsContentService
Loads the content definition for a given entity.- Specified by:
loadContentDefinition
in interfaceI_CmsContentService
- Parameters:
entityId
- the entity id/URI- Returns:
- the content type definition
- Throws:
CmsRpcException
- See Also:
I_CmsContentService.loadContentDefinition(java.lang.String)
-
loadDefinition
public CmsContentDefinition loadDefinition(java.lang.String entityId, java.lang.String clientId, CmsEntity editedLocaleEntity, java.util.Collection<java.lang.String> skipPaths, java.util.Map<java.lang.String,java.lang.String> settingPresets) throws CmsRpcException
Description copied from interface:I_CmsContentService
Loads the content definition for a given entity.- Specified by:
loadDefinition
in interfaceI_CmsContentService
- Parameters:
entityId
- the entity id/URIclientId
- the container element client id if availableeditedLocaleEntity
- the edited locale entityskipPaths
- the paths to skip during locale synchronizationsettingPresets
- the presets for container element settings- Returns:
- the content definition
- Throws:
CmsRpcException
- See Also:
I_CmsContentService.loadDefinition(java.lang.String, java.lang.String, org.opencms.acacia.shared.CmsEntity, java.util.Collection, java.util.Map)
-
loadInitialDefinition
public CmsContentDefinition loadInitialDefinition(java.lang.String entityId, java.lang.String clientId, java.lang.String newLink, CmsUUID modelFileId, java.lang.String editContext, java.lang.String mainLocale, java.lang.String mode, java.lang.String postCreateHandler, CmsEditHandlerData editHandlerDataForNew, java.util.Map<java.lang.String,java.lang.String> settingPresets, java.lang.String editorStylesheet) throws CmsRpcException
Description copied from interface:I_CmsContentService
Loads the content definition for a given entity.- Specified by:
loadInitialDefinition
in interfaceI_CmsContentService
- Parameters:
entityId
- the entity id/URIclientId
- the container element client id if availablenewLink
- the new linkmodelFileId
- the optional model file ideditContext
- the container page currently being edited (may be null)mainLocale
- the main language to copy in case the element language node does not exist yetmode
- the content creation modepostCreateHandler
- the post-create handler class nameeditHandlerDataForNew
- the edit handler data, if an edit handler is used for creating a new element; null otherwisesettingPresets
- the presets for container element settingseditorStylesheet
- the path of the editor style sheet (may be null)- Returns:
- the content definition
- Throws:
CmsRpcException
- if something goes wrong processing the request- See Also:
I_CmsContentService.loadInitialDefinition(java.lang.String, java.lang.String, java.lang.String, org.opencms.util.CmsUUID, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.opencms.ade.contenteditor.shared.CmsEditHandlerData, java.util.Map, java.lang.String)
-
loadNewDefinition
public CmsContentDefinition loadNewDefinition(java.lang.String entityId, java.lang.String clientId, CmsEntity editedLocaleEntity, java.util.Collection<java.lang.String> skipPaths, java.util.Map<java.lang.String,java.lang.String> settingPresets) 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 interfaceI_CmsContentService
- Parameters:
entityId
- the entity id/URIclientId
- the container element client id if availableeditedLocaleEntity
- the edited locale entityskipPaths
- the paths to skip during locale synchronizationsettingPresets
- the presets for container element settings- Returns:
- the content definition
- Throws:
CmsRpcException
- if something goes wrong processing the request- See Also:
I_CmsContentService.loadNewDefinition(java.lang.String, java.lang.String, org.opencms.acacia.shared.CmsEntity, java.util.Collection, java.util.Map)
-
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 interfaceI_CmsContentService
- Returns:
- the content definition
- Throws:
CmsRpcException
- if something goes wrong- See Also:
I_CmsContentService.prefetch()
-
saveAndDeleteEntities
public CmsSaveResult saveAndDeleteEntities(CmsEntity lastEditedEntity, java.lang.String clientId, java.util.List<java.lang.String> deletedEntities, java.util.Collection<java.lang.String> skipPaths, java.lang.String lastEditedLocale, boolean clearOnSuccess) throws CmsRpcException
Description copied from interface:I_CmsContentService
Saves and deletes the given entities. Returns the editor save result information.- Specified by:
saveAndDeleteEntities
in interfaceI_CmsContentService
- Parameters:
lastEditedEntity
- the last edited entityclientId
- the container element client id if availabledeletedEntities
- the entity id's to deleteskipPaths
- the paths to skip during locale synchronizationlastEditedLocale
- the last edited localeclearOnSuccess
-true
to unlock resource after saving- Returns:
- the editor save result information
- Throws:
CmsRpcException
- if something goes wrong processing the request- See Also:
I_CmsContentService.saveAndDeleteEntities(org.opencms.acacia.shared.CmsEntity, java.lang.String, java.util.List, java.util.Collection, java.lang.String, boolean)
-
saveEntities
public CmsValidationResult saveEntities(java.util.List<CmsEntity> entities)
Description copied from interface:I_CmsContentService
Saves the given entities and returns a validation result in case of invalid entities.Invalid entities will not be saved.
- Specified by:
saveEntities
in interfaceI_CmsContentService
- Parameters:
entities
- the entities to save- Returns:
- the validation result in case of invalid entities
- See Also:
I_CmsContentService.saveEntities(java.util.List)
-
saveEntity
public CmsValidationResult saveEntity(CmsEntity entity)
Description copied from interface:I_CmsContentService
Saves the given entity and returns a validation result in case of invalid entities.Invalid entities will not be saved.
- Specified by:
saveEntity
in interfaceI_CmsContentService
- Parameters:
entity
- the entity to save- Returns:
- the validation result in case of invalid entities
- See Also:
I_CmsContentService.saveEntity(org.opencms.acacia.shared.CmsEntity)
-
saveValue
public java.lang.String saveValue(java.lang.String contentId, java.lang.String contentPath, java.lang.String localeString, java.lang.String newValue) throws CmsRpcException
Description copied from interface:I_CmsContentService
Saves a value in an existing XML content.- Specified by:
saveValue
in interfaceI_CmsContentService
- Parameters:
contentId
- the structure id of the contentcontentPath
- the xpath of the value to setlocaleString
- the locale in which to set the valuenewValue
- the value to set- Returns:
- not used
- Throws:
CmsRpcException
- if something goes wrong- See Also:
I_CmsContentService.saveValue(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
-
updateEntityHtml
public CmsEntityHtml updateEntityHtml(CmsEntity entity, java.lang.String contextUri, java.lang.String htmlContextInfo) throws java.lang.Exception
Description copied from interface:I_CmsContentService
Retrieves the updated entity HTML representation.The entity data will be validated but not persisted on the server.
- Specified by:
updateEntityHtml
in interfaceI_CmsContentService
- Parameters:
entity
- the entitycontextUri
- the context URIhtmlContextInfo
- information about the HTML context- Returns:
- the HTML representation including the validation result
- Throws:
java.lang.Exception
- if something goes wrong processing the request- See Also:
I_CmsContentService.updateEntityHtml(org.opencms.acacia.shared.CmsEntity, java.lang.String, java.lang.String)
-
validateEntity
public CmsValidationResult validateEntity(CmsEntity changedEntity) throws CmsRpcException
Description copied from interface:I_CmsContentService
Validates the given entity and returns maps of error and warning messages in case of invalid attributes.- Specified by:
validateEntity
in interfaceI_CmsContentService
- Parameters:
changedEntity
- the entity to validate- Returns:
- the validation result
- Throws:
CmsRpcException
- See Also:
I_CmsContentService.validateEntity(org.opencms.acacia.shared.CmsEntity)
-
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 CmsObjectfile
- the file which is to be checked- Returns:
- the encoding for the file
-
readEntity
protected CmsEntity readEntity(CmsXmlContent content, org.dom4j.Element element, java.util.Locale locale, java.lang.String entityId, java.lang.String parentPath, java.lang.String typeName, CmsContentTypeVisitor visitor, boolean includeInvisible, CmsEntity editedLocalEntity)
Parses the element into an entity.- Parameters:
content
- the entity contentelement
- the current elementlocale
- the content localeentityId
- the entity idparentPath
- the parent pathtypeName
- the entity type namevisitor
- the content type visitorincludeInvisible
- include invisible attributeseditedLocalEntity
- the edited locale entity- Returns:
- the entity
-
readTypes
protected java.util.Map<java.lang.String,CmsType> 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 definitionlocale
- the messages locale- Returns:
- the types of the given content definition
-
synchronizeLocaleIndependentFields
protected void synchronizeLocaleIndependentFields(CmsFile file, CmsXmlContent content, java.util.Collection<java.lang.String> skipPaths, java.util.Collection<CmsEntity> entities, java.util.Locale lastEdited) throws CmsXmlException
Synchronizes the locale independent fields.- Parameters:
file
- the content filecontent
- the XML contentskipPaths
- the paths to skip during locale synchronizationentities
- the edited entitieslastEdited
- the last edited locale- Throws:
CmsXmlException
- if something goes wrong
-
transferInvisibleValues
protected void transferInvisibleValues(CmsEntity original, CmsEntity target, CmsContentTypeVisitor visitor)
Transfers values marked as invisible from the original entity to the target entity.- Parameters:
original
- the original entitytarget
- the target entiyvisitor
- the type visitor holding the content type configuration
-
-