Package org.ametys.plugins.frontedition
Class AmetysFrontEditionHelper
- java.lang.Object
-
- org.ametys.plugins.frontedition.AmetysFrontEditionHelper
-
- All Implemented Interfaces:
Contextualizable,Serviceable
public class AmetysFrontEditionHelper extends Object implements Serviceable, Contextualizable
Helper for preparing the Ametys Edition
-
-
Field Summary
Fields Modifier and Type Field Description private static AmetysObjectResolver_ametysObjectResolverprivate static ContentWorkflowHelper_contentWorkflowHelperprivate static Context_contextprivate static HashCache_hashCacheprivate static JSONUtils_jsonUtilsprivate static PageHelper_pageHelperprivate static RichTextConfigurationExtensionPoint_richTextConfigurationExtensionPointprivate static RightManager_rightManagerprivate static SiteManager_siteManagerprivate static WorkflowHelper_workflowHelperstatic StringFRONT_EDITION_RIGHT_IDThe right's id from front-edition access
-
Constructor Summary
Constructors Constructor Description AmetysFrontEditionHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private static void_addRichTextConfigurationFiles(Map<String,Map<String,String>> files, Map<String,String> filesInfos, String locale, boolean rtlMode, boolean scripts)private static List<ClientSideElement.ScriptFile>_getRichTextConfigurationFiles(boolean scripts, Map<String,Object> contextParameters)voidcontextualize(Context context)static NodeListfindPagesIdsByTagInDefaultWorkspace(String tag)Returns the ids of the pages tagged with the specified tag in default workspacestatic NodeListfindPagesIdsByTagInDefaultWorkspace(String tag, boolean checkReadAccess)Returns the ids of the pages tagged with the specified tag in default workspacestatic NodeListfindPagesIdsByTagInDefaultWorkspace(String sitename, String lang, String tag)Returns the ids of the pages tagged with the specified tag in default workspacestatic NodeListfindPagesIdsByTagInDefaultWorkspace(String sitename, String lang, String tag, boolean checkReadAccess)Returns the ids of the pages tagged with the specified tag in default workspacestatic StringgetContentModifiables(int actionId, String inputPageId, boolean checkEditionMode)Get a string representing a json map of the contentIds with true/false if they can/can't be modifiedstatic StringgetContentStatus(String contentId)check if a content is published ot notstatic StringgetContentStatus(Content content)check if a content is published ot notstatic longgetContentWorkflowId(String contentId)Get the workflow step id of a contentstatic longgetContentWorkflowId(Content content)Get the workflow step id of a contentstatic StringgetPageStatus(String pageId)Get the status (validated/draft) of all contents in a pagestatic StringgetWorkflowName(String workflowName, int actionId)Get the name of a workflow actionstatic longgetZoneItemPosition(String zoneItemId, String pageId)Get the position of this zoneItem in the zone, or -1 if not foundstatic longgetZoneSize(String zoneName, String pageId)Return the size of a zonestatic booleanhasFrontEditionRight()Check if the current user has the Front_Edition_Access_Right rightstatic booleanhasFrontEditionRight(String rightId, String objectId)Deprecated.Use the version with three argumentsstatic booleanhasFrontEditionRight(String rightId, String objectId, boolean editionModeOnly)Check if we can display the front edition button for a specific right Checks : * Rendering context == front * Edition mode * Front_Edition_Access_Right on current page * RightId available on objectstatic booleanhasWorkflowRight(int actionId, String contentId, boolean checkEditionMode)Check if the current workflow action is available on this contentstatic booleanhasWorkflowRight(List<Integer> actionIds, String contentId, boolean checkEditionMode)Check if a list of workflow actions are available on this contentstatic booleanhasWorkflowRight(List<Integer> actionIds, Content content, boolean checkEditionMode)Check if a list of workflow actions are available on this contentstatic booleanisContentLive(String contentId)check if a content is published ot notstatic booleanisContentLive(Content content)check if a content is published ot notstatic booleanisPageModifiable(String pageId)Test if a page is modifiablestatic StringprepareCSSFiles(String locale, boolean rtlMode, String theme)Prepare a hashcode for css filesstatic StringprepareJSFiles(String locale, boolean rtlMode, String theme)Prepare a hashcode for js filesvoidservice(ServiceManager manager)
-
-
-
Field Detail
-
FRONT_EDITION_RIGHT_ID
public static final String FRONT_EDITION_RIGHT_ID
The right's id from front-edition access- See Also:
- Constant Field Values
-
_ametysObjectResolver
private static AmetysObjectResolver _ametysObjectResolver
-
_hashCache
private static HashCache _hashCache
-
_richTextConfigurationExtensionPoint
private static RichTextConfigurationExtensionPoint _richTextConfigurationExtensionPoint
-
_rightManager
private static RightManager _rightManager
-
_contentWorkflowHelper
private static ContentWorkflowHelper _contentWorkflowHelper
-
_pageHelper
private static PageHelper _pageHelper
-
_workflowHelper
private static WorkflowHelper _workflowHelper
-
_jsonUtils
private static JSONUtils _jsonUtils
-
_siteManager
private static SiteManager _siteManager
-
-
Constructor Detail
-
AmetysFrontEditionHelper
public AmetysFrontEditionHelper()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
prepareJSFiles
public static String prepareJSFiles(String locale, boolean rtlMode, String theme)
Prepare a hashcode for js files- Parameters:
locale- The language code to usertlMode- Is for right-to-left language?theme- The url for the theme- Returns:
- The new hashcode to read the minimified concatened file
-
prepareCSSFiles
public static String prepareCSSFiles(String locale, boolean rtlMode, String theme)
Prepare a hashcode for css files- Parameters:
locale- The language code to usertlMode- Is for right-to-left language?theme- The url for the theme- Returns:
- The new hashcode to read the minimified concatened file
-
_getRichTextConfigurationFiles
private static List<ClientSideElement.ScriptFile> _getRichTextConfigurationFiles(boolean scripts, Map<String,Object> contextParameters)
-
_addRichTextConfigurationFiles
private static void _addRichTextConfigurationFiles(Map<String,Map<String,String>> files, Map<String,String> filesInfos, String locale, boolean rtlMode, boolean scripts)
-
hasFrontEditionRight
@Deprecated public static boolean hasFrontEditionRight(String rightId, String objectId)
Deprecated.Use the version with three argumentsCheck if we can display the front edition button for a specific right Checks : * Rendering context == front * Edition mode * Front_Edition_Access_Right on current page * RightId available on object- Parameters:
rightId- right to check (can be null)objectId- id of page/content to check. Can be null or empty to get the current page- Returns:
- true if all is OK, false if at least one is false
-
hasFrontEditionRight
public static boolean hasFrontEditionRight(String rightId, String objectId, boolean editionModeOnly)
Check if we can display the front edition button for a specific right Checks : * Rendering context == front * Edition mode * Front_Edition_Access_Right on current page * RightId available on object- Parameters:
rightId- right to check (can be null)objectId- id of page/content to check. Can be null or empty to get the current pageeditionModeOnly- Check if the user is in edition mode- Returns:
- true if all is OK, false if at least one is false
-
hasFrontEditionRight
public static boolean hasFrontEditionRight()
Check if the current user has the Front_Edition_Access_Right right- Returns:
- true if right granted
-
hasWorkflowRight
public static boolean hasWorkflowRight(int actionId, String contentId, boolean checkEditionMode)
Check if the current workflow action is available on this content- Parameters:
actionId- action to checkcontentId- content to checkcheckEditionMode- check also if we are in edition mode- Returns:
- true if right is granted
-
hasWorkflowRight
public static boolean hasWorkflowRight(List<Integer> actionIds, String contentId, boolean checkEditionMode)
Check if a list of workflow actions are available on this content- Parameters:
actionIds- list of action idscontentId- id of the content to checkcheckEditionMode- check also if we are in edition mode- Returns:
- true if all actions are available
-
hasWorkflowRight
public static boolean hasWorkflowRight(List<Integer> actionIds, Content content, boolean checkEditionMode)
Check if a list of workflow actions are available on this content- Parameters:
actionIds- list of action idscontent- content to checkcheckEditionMode- check also if we are in edition mode- Returns:
- true if all actions are available
-
getContentModifiables
public static String getContentModifiables(int actionId, String inputPageId, boolean checkEditionMode)
Get a string representing a json map of the contentIds with true/false if they can/can't be modified- Parameters:
actionId- action to checkinputPageId- page (can be null)checkEditionMode- check also if we are in edition mode- Returns:
- {contentId : true/false, ....}
-
getWorkflowName
public static String getWorkflowName(String workflowName, int actionId)
Get the name of a workflow action- Parameters:
workflowName- workflow nameactionId- action id in the workflow- Returns:
- name of the workflow action
-
getPageStatus
public static String getPageStatus(String pageId)
Get the status (validated/draft) of all contents in a page- Parameters:
pageId- id of the page to check- Returns:
- "" if not a page, "draft" if all contents are drafts, "validated" if all contents are validated, and "mixed" if there are both
-
getContentWorkflowId
public static long getContentWorkflowId(String contentId)
Get the workflow step id of a content- Parameters:
contentId- id of the content- Returns:
- the step Id
-
getContentWorkflowId
public static long getContentWorkflowId(Content content)
Get the workflow step id of a content- Parameters:
content- content- Returns:
- the step Id
-
getContentStatus
public static String getContentStatus(String contentId)
check if a content is published ot not- Parameters:
contentId- id of the content- Returns:
- "validated" or "draft", "" if not found
-
getContentStatus
public static String getContentStatus(Content content)
check if a content is published ot not- Parameters:
content- content- Returns:
- "validated" or "draft"
-
isContentLive
public static boolean isContentLive(String contentId)
check if a content is published ot not- Parameters:
contentId- id of the content- Returns:
- true if validated
-
isContentLive
public static boolean isContentLive(Content content)
check if a content is published ot not- Parameters:
content- content- Returns:
- true if validated
-
getZoneItemPosition
public static long getZoneItemPosition(String zoneItemId, String pageId) throws UnknownAmetysObjectException, AmetysRepositoryException, RepositoryException
Get the position of this zoneItem in the zone, or -1 if not found- Parameters:
zoneItemId- zoneitem to searchpageId- page id- Returns:
- zero based position, -1 if not found
- Throws:
UnknownAmetysObjectException- If an error occurredAmetysRepositoryException- If an error occurredRepositoryException- If an error occurred
-
getZoneSize
public static long getZoneSize(String zoneName, String pageId)
Return the size of a zone- Parameters:
zoneName- zone namepageId- page Id- Returns:
- size of the zone (-1 if not found)
-
isPageModifiable
public static boolean isPageModifiable(String pageId)
Test if a page is modifiable- Parameters:
pageId- id of the page to check- Returns:
- true if the page is modifiable, false otherwise
-
findPagesIdsByTagInDefaultWorkspace
public static NodeList findPagesIdsByTagInDefaultWorkspace(String tag)
Returns the ids of the pages tagged with the specified tag in default workspace- Parameters:
tag- The tag id- Returns:
- Array of pages ids
-
findPagesIdsByTagInDefaultWorkspace
public static NodeList findPagesIdsByTagInDefaultWorkspace(String tag, boolean checkReadAccess)
Returns the ids of the pages tagged with the specified tag in default workspace- Parameters:
tag- The tag idcheckReadAccess- true to return only pages with read access for current user- Returns:
- Array of pages ids
-
findPagesIdsByTagInDefaultWorkspace
public static NodeList findPagesIdsByTagInDefaultWorkspace(String sitename, String lang, String tag)
Returns the ids of the pages tagged with the specified tag in default workspace- Parameters:
sitename- The site idlang- The language codetag- The tag id- Returns:
- Array of pages ids
-
findPagesIdsByTagInDefaultWorkspace
public static NodeList findPagesIdsByTagInDefaultWorkspace(String sitename, String lang, String tag, boolean checkReadAccess)
Returns the ids of the pages tagged with the specified tag in default workspace- Parameters:
sitename- The site idlang- The language codetag- The tag idcheckReadAccess- true to return only pages with read access for current user- Returns:
- Array of pages ids
-
-