Class LinkDAO
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.plugins.linkdirectory.link.LinkDAO
- All Implemented Interfaces:
Component
,Contextualizable
,LogEnabled
,Serviceable
DAO for manipulating
Link
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected DefaultLink
_createLink
(String name, ModifiableTraversableAmetysObject rootNode) Create the link object.protected boolean
_urlExists
(String url, String internalUrl, String siteName, String language) Test if a link with the specified url or internal url exists in the directory.protected boolean
_urlExistsForUser
(String url, String internalUrl, String siteName, String language, UserIdentity user) Test if a link with the specified url or internal url exists in the directory for the given user.void
contextualize
(Context context) Convert a link to JSON objectcreateLink
(Map<String, Object> parameters) Create a new linkcreateUserLink
(Map<String, Object> parameters) Create a new user linkdeleteLinks
(List<String> ids) Delete one or multiples linksReturns the list of providers of dynamic information as json objectGet the JSON object representing a linkgetLinkColor
(DefaultLink link) Retrieves the color of the link.Get links infosboolean
isInternalURLAllowed
(String siteName) Determines if the restriction IP parameter is not emptyMove a link in the listvoid
service
(ServiceManager manager) updateLink
(Map<String, Object> parameters) Updates a linkMethods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
ROLE
Avalon Role
-
-
Constructor Details
-
LinkDAO
public LinkDAO()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
createLink
Create a new link- Parameters:
parameters
- a map of the following parameters for the link : siteName, language, url, title, content, url-alternative, picture, picture#type, picture-alternative, themes, grant-any-user, fousers, fogroups- Returns:
- The new link id
-
createUserLink
Create a new user link- Parameters:
parameters
- a map of the following parameters for the link : siteName, language, url, title, content, url-alternative, picture, picture#type, picture-alternative- Returns:
- The new link id
-
updateLink
Updates a link- Parameters:
parameters
- a map of the following parameters for the link : siteName, language, id, url, title, content, url-alternative, picture, picture#type, picture-alternative, themes, grant-any-user, fousers, fogroups- Returns:
- the update link
-
deleteLinks
Delete one or multiples links- Parameters:
ids
- a list of links' ids- Returns:
- true if all the links were deleted, false if at least one link could not be delete.
-
moveLink
Move a link in the list- Parameters:
id
- the link idrole
- the move action- Returns:
- the moved link in JSON
- Throws:
javax.jcr.RepositoryException
- if a repository error occurs.
-
getLink
Get the JSON object representing a link- Parameters:
id
- the id of link- Returns:
- the link as JSON object
-
isInternalURLAllowed
Determines if the restriction IP parameter is not empty- Parameters:
siteName
- the site name- Returns:
- true if the restriction IP parameter is not empty
-
getDynamicInformationProviders
Returns the list of providers of dynamic information as json object- Returns:
- the providers of dynamic information
-
convertLink2JsonObject
Convert a link to JSON object- Parameters:
link
- the link- Returns:
- the link as JSON object
-
getLinks
Get links infos- Parameters:
linkIds
- the link id- Returns:
- the link infos
-
_urlExists
protected boolean _urlExists(String url, String internalUrl, String siteName, String language) throws AmetysRepositoryException Test if a link with the specified url or internal url exists in the directory.- Parameters:
url
- the url to test.internalUrl
- the internal url to testsiteName
- the site name.language
- the language.- Returns:
- true if the link exists.
- Throws:
AmetysRepositoryException
- if a repository error occurs.
-
_urlExistsForUser
protected boolean _urlExistsForUser(String url, String internalUrl, String siteName, String language, UserIdentity user) throws AmetysRepositoryException Test if a link with the specified url or internal url exists in the directory for the given user.- Parameters:
url
- the url to test.internalUrl
- the internal url to testsiteName
- the site name.language
- the language.user
- The user identity- Returns:
- true if the link exists for the given user.
- Throws:
AmetysRepositoryException
- if a repository error occurs.
-
_createLink
Create the link object.- Parameters:
name
- the desired link name.rootNode
- the links root node.- Returns:
- the created Link.
-
getLinkColor
Retrieves the color of the link. If there is no color configured on the link, the default site color- Parameters:
link
- the link- Returns:
- the color of the link
-