Package org.ametys.cms.content.autosave
Class ContentBackupClientInteraction
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.cms.content.autosave.ContentBackupClientInteraction
-
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
public class ContentBackupClientInteraction extends AbstractLogEnabled implements Serviceable, Component
Component for manipulating auto-backup on contents
-
-
Field Summary
Fields Modifier and Type Field Description private static String
__AUTOSAVE_NODETYPE
private CurrentUserProvider
_currentUserProvider
private JSONUtils
_jsonUtils
private AmetysObjectResolver
_resolver
-
Constructor Summary
Constructors Constructor Description ContentBackupClientInteraction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Object
_decodeValue(String value)
private String
_encodeValue(Object value)
Map<String,Object>
deleteContentBackup(String contentId)
Delete an automatic backup for a content.protected Map<String,Object>
getBackupData(ModelAwareDataHolder dataHolder)
Retrieves the content backup informationMap<String,Object>
getContentBackup(String contentId)
Get the content backup informationprotected ModelAwareJCRAmetysObject
getContentNode(String contentId, boolean createNew)
Get the storage node for a content in the automatic backup space, or create it if it doesn't exist.protected ModifiableTraversableAmetysObject
getOrCreateTempRoot()
Get the temporary backup root, or create it if it doesn't exist.protected List<Map<String,Object>>
getRepeatersBackupData(ModelAwareDataHolder dataHolder)
Retrieves the repeaters backup informationprotected List<Map<String,Object>>
getValuesBackupData(ModelAwareDataHolder dataHolder, String valuesRepeaterPath)
Retrieves the values backup informationprotected void
removeAllRepeaterEntries(ModifiableModelAwareDataHolder dataHolder)
Remove all the repeater entries of a given data holder.void
service(ServiceManager manager)
Map<String,Object>
setContentBackup(String contentId, Map<String,Object> values, Map<String,Object> invalidValues, String comments, Collection<Map<String,String>> repeaters)
Store an automatic backup for a content.protected void
storeRepeaters(ModifiableModelAwareDataHolder dataHolder, Collection<Map<String,String>> repeaters)
Store the repeater item counts to be able to re-initialize themprotected void
storeValues(ModifiableModelAwareDataHolder dataHolder, String valuesRepeaterPath, Map<String,Object> values)
Store the attribute values-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
__AUTOSAVE_NODETYPE
private static final String __AUTOSAVE_NODETYPE
- See Also:
- Constant Field Values
-
_resolver
private AmetysObjectResolver _resolver
-
_currentUserProvider
private CurrentUserProvider _currentUserProvider
-
_jsonUtils
private JSONUtils _jsonUtils
-
-
Constructor Detail
-
ContentBackupClientInteraction
public ContentBackupClientInteraction()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getContentBackup
public Map<String,Object> getContentBackup(String contentId)
Get the content backup information- Parameters:
contentId
- The content id- Returns:
- The saved data
-
getBackupData
protected Map<String,Object> getBackupData(ModelAwareDataHolder dataHolder)
Retrieves the content backup information- Parameters:
dataHolder
- the content backup data holder- Returns:
- the content backup information
-
getValuesBackupData
protected List<Map<String,Object>> getValuesBackupData(ModelAwareDataHolder dataHolder, String valuesRepeaterPath)
Retrieves the values backup information- Parameters:
dataHolder
- the content backup data holdervaluesRepeaterPath
- the path of the values attribute- Returns:
- the values backup information
-
_decodeValue
private Object _decodeValue(String value)
-
getRepeatersBackupData
protected List<Map<String,Object>> getRepeatersBackupData(ModelAwareDataHolder dataHolder)
Retrieves the repeaters backup information- Parameters:
dataHolder
- the content backup data holder- Returns:
- the repeaters backup information
-
deleteContentBackup
public Map<String,Object> deleteContentBackup(String contentId)
Delete an automatic backup for a content.- Parameters:
contentId
- The content id- Returns:
- A empty map
-
setContentBackup
public Map<String,Object> setContentBackup(String contentId, Map<String,Object> values, Map<String,Object> invalidValues, String comments, Collection<Map<String,String>> repeaters)
Store an automatic backup for a content.- Parameters:
contentId
- The content idvalues
- The valid values to storeinvalidValues
- The invalid values to storecomments
- The comments as JSON stringrepeaters
- The repeaters to store- Returns:
- A empty Map
-
storeValues
protected void storeValues(ModifiableModelAwareDataHolder dataHolder, String valuesRepeaterPath, Map<String,Object> values)
Store the attribute values- Parameters:
dataHolder
- the content backup data holdervaluesRepeaterPath
- the path of the values attributevalues
- the values to store, as a Map of values, indexed by name.
-
_encodeValue
private String _encodeValue(Object value)
-
storeRepeaters
protected void storeRepeaters(ModifiableModelAwareDataHolder dataHolder, Collection<Map<String,String>> repeaters)
Store the repeater item counts to be able to re-initialize them- Parameters:
dataHolder
- the content backup data holderrepeaters
- the repeaters data
-
removeAllRepeaterEntries
protected void removeAllRepeaterEntries(ModifiableModelAwareDataHolder dataHolder)
Remove all the repeater entries of a given data holder.- Parameters:
dataHolder
- the data holder to clear.
-
getContentNode
protected ModelAwareJCRAmetysObject getContentNode(String contentId, boolean createNew)
Get the storage node for a content in the automatic backup space, or create it if it doesn't exist.- Parameters:
contentId
- the content ID.createNew
-true
to create automatically the node when missing.- Returns:
- the content backup storage node.
-
getOrCreateTempRoot
protected ModifiableTraversableAmetysObject getOrCreateTempRoot()
Get the temporary backup root, or create it if it doesn't exist.- Returns:
- the temporary backup root.
-
-