Package org.ametys.plugins.frontedition
Class AmetysFrontEditionHelper
java.lang.Object
org.ametys.plugins.frontedition.AmetysFrontEditionHelper
- All Implemented Interfaces:
Contextualizable
,LogEnabled
,Serviceable
public class AmetysFrontEditionHelper
extends Object
implements Serviceable, Contextualizable, LogEnabled
Helper for preparing the Ametys Edition
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
contextualize
(Context context) void
enableLogging
(Logger logger) static NodeList
Returns the ids of the pages tagged with the specified tag in default workspacestatic NodeList
findPagesIdsByTagInDefaultWorkspace
(String tag, boolean checkReadAccess) Returns the ids of the pages tagged with the specified tag in default workspacestatic NodeList
findPagesIdsByTagInDefaultWorkspace
(String sitename, String lang, String tag) Returns the ids of the pages tagged with the specified tag in default workspacestatic NodeList
findPagesIdsByTagInDefaultWorkspace
(String sitename, String lang, String tag, boolean checkReadAccess) Returns the ids of the pages tagged with the specified tag in default workspacestatic String
getContentStatus
(String contentId) check if a content is published ot notstatic String
getContentStatus
(Content content) check if a content is published ot notstatic String
getContentToolbarConfig
(String contentId, String zoneItemId, String restrictedActions, String jsonStepConfig, String locale, boolean editionModeOnly) Get the toolbar configuration for content: retrieve user rights, available workflow actions, content current step and status historystatic long
getContentWorkflowId
(String contentId) Get the workflow step id of a contentstatic long
getContentWorkflowId
(Content content) Get the workflow step id of a contentstatic String
getModifiableContents
(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 String
getPageStatus
(String pageId) Get the status (validated/draft) of all contents in a pagestatic String
getPageToolbarConfig
(String pageId, String addContentsConfigAsJson, boolean editionModeOnly) Get the toolbar configuration for page: retrieve the user rights, the parent and page positiongetRightsForContent
(Content content) Get a map of chosen rights for a contentgetUnmodifiableAttributes
(Content content, List<Integer> actionIds, boolean checkEditionMode) Get path of unmodifiable attributes.static String
getWorkflowName
(String workflowName, int actionId) Get the name of a workflow actionstatic long
getZoneItemPosition
(String zoneItemId) Get the position of this zoneItem in the zone, or -1 if not foundstatic long
getZoneItemPosition
(ZoneItem zoneItem) Get the position of this zoneItem in its parent zone, or -1 if not foundstatic long
getZoneSize
(String zoneName, String pageId) Return the size of a zonestatic long
getZoneSize
(Zone zone) Return the size of a zonestatic boolean
Check if the current user has the Front_Edition_Access_Right rightstatic boolean
hasFrontEditionRight
(String rightId, String objectId) Deprecated.Use the version with three argumentsstatic 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 objectstatic boolean
hasFrontEditionRight
(String rightId, AmetysObject ao, boolean editionModeOnly) Check if current user has right on Ametys object for front edition Checks : * Rendering context == front * Edition mode * Front_Edition_Access_Right on current page * RightId available on objectstatic boolean
hasWorkflowRight
(int actionId, String contentId, boolean checkEditionMode) Check if the current workflow action is available on this contentstatic boolean
hasWorkflowRight
(List<Integer> actionIds, String contentId, boolean checkEditionMode) Check if a list of workflow actions are available on this contentstatic boolean
hasWorkflowRight
(List<Integer> actionIds, Content content, boolean checkEditionMode) Check if a list of workflow actions are available on this contentstatic boolean
isContentLive
(String contentId) check if a content is published ot notstatic boolean
isContentLive
(Content content) check if a content is published ot notstatic boolean
isPageModifiable
(String pageId) Test if a page is modifiablestatic String
prepareCSSFiles
(String locale, String theme) Prepare a hashcode for css filesstatic String
prepareJSFiles
(String locale, String theme) Prepare a hashcode for js filesvoid
service
(ServiceManager manager)
-
Field Details
-
FRONT_EDITION_RIGHT_ID
The right's id from front-edition access- See Also:
-
-
Constructor Details
-
AmetysFrontEditionHelper
public AmetysFrontEditionHelper()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
enableLogging
- Specified by:
enableLogging
in interfaceLogEnabled
-
prepareJSFiles
Prepare a hashcode for js files- Parameters:
locale
- The language code to usetheme
- The url for the theme- Returns:
- The new hashcode to read the minimified concatened file
-
prepareCSSFiles
Prepare a hashcode for css files- Parameters:
locale
- The language code to usetheme
- The url for the theme- Returns:
- The new hashcode to read the minimified concatened file
-
hasFrontEditionRight
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(String rightId, AmetysObject ao, boolean editionModeOnly) Check if current user has right on Ametys object for front edition 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)ao
- The ametys object check. Cannot be nulleditionModeOnly
- Check if the user is in edition mode- Returns:
- true if all is OK, false if at least one is false
-
hasFrontEditionRight
Check if the current user has the Front_Edition_Access_Right right- Returns:
- true if right granted
-
hasWorkflowRight
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
-
getPageToolbarConfig
public static String getPageToolbarConfig(String pageId, String addContentsConfigAsJson, boolean editionModeOnly) throws UnknownAmetysObjectException, AmetysRepositoryException, javax.jcr.RepositoryException Get the toolbar configuration for page: retrieve the user rights, the parent and page position- Parameters:
pageId
- The page idaddContentsConfigAsJson
- The items configuration for adding contents as JSON stringeditionModeOnly
- true to check edition mode- Returns:
- the user's rights, parent and page position
- Throws:
UnknownAmetysObjectException
- if content is unknownAmetysRepositoryException
- if an error occurredjavax.jcr.RepositoryException
- if an error occurred
-
getContentToolbarConfig
public static String getContentToolbarConfig(String contentId, String zoneItemId, String restrictedActions, String jsonStepConfig, String locale, boolean editionModeOnly) throws UnknownAmetysObjectException, AmetysRepositoryException, javax.jcr.RepositoryException Get the toolbar configuration for content: retrieve user rights, available workflow actions, content current step and status history- Parameters:
contentId
- The content idzoneItemId
- The zone item idrestrictedActions
- The actions ids to retrieve. Set to null or empty to get all available workflow actions with no restrictionjsonStepConfig
- The step configurationlocale
- the locale for translationeditionModeOnly
- true to check edition mode- Returns:
- the user's rights, available workflow actions and content current step
- Throws:
UnknownAmetysObjectException
- if content is unknownAmetysRepositoryException
- if an error occurredjavax.jcr.RepositoryException
- if an error occurred
-
getModifiableContents
public static String getModifiableContents(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, ....}
-
getUnmodifiableAttributes
public static List<String> getUnmodifiableAttributes(Content content, List<Integer> actionIds, boolean checkEditionMode) Get path of unmodifiable attributes. Check if content can be modified and the restrictions on attributes- Parameters:
content
- the contentactionIds
- the workflow action ids to checkcheckEditionMode
- to check edition mode- Returns:
- the list with the path of unmodifiable attributes (regarding of restrictions) or null if the content cannot be modified
-
getRightsForContent
Get a map of chosen rights for a content- Parameters:
content
- the content- Returns:
- the chosen rights for a content
-
getWorkflowName
Get the name of a workflow action- Parameters:
workflowName
- workflow nameactionId
- action id in the workflow- Returns:
- name of the workflow action
-
getPageStatus
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
Get the workflow step id of a content- Parameters:
contentId
- id of the content- Returns:
- the step Id
-
getContentWorkflowId
Get the workflow step id of a content- Parameters:
content
- content- Returns:
- the step Id
-
getContentStatus
check if a content is published ot not- Parameters:
contentId
- id of the content- Returns:
- "validated" or "draft", "" if not found
-
getContentStatus
check if a content is published ot not- Parameters:
content
- content- Returns:
- "validated" or "draft"
-
isContentLive
check if a content is published ot not- Parameters:
contentId
- id of the content- Returns:
- true if validated
-
isContentLive
check if a content is published ot not- Parameters:
content
- content- Returns:
- true if validated
-
getZoneItemPosition
public static long getZoneItemPosition(String zoneItemId) throws UnknownAmetysObjectException, AmetysRepositoryException Get the position of this zoneItem in the zone, or -1 if not found- Parameters:
zoneItemId
- zoneitem to search- Returns:
- zero based position, -1 if not found
- Throws:
UnknownAmetysObjectException
- If zone item is not foundAmetysRepositoryException
- If an error occurred
-
getZoneItemPosition
Get the position of this zoneItem in its parent zone, or -1 if not found- Parameters:
zoneItem
- zoneitem- Returns:
- zero based position, -1 if not found
-
getZoneSize
Return the size of a zone- Parameters:
zoneName
- zone namepageId
- page Id- Returns:
- size of the zone (-1 if not found)
-
getZoneSize
Return the size of a zone- Parameters:
zone
- the zone- Returns:
- size of the zone or -1 is zone is null
-
isPageModifiable
Test if a page is modifiable- Parameters:
pageId
- id of the page to check- Returns:
- true if the page is modifiable, false otherwise
-
findPagesIdsByTagInDefaultWorkspace
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
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
-