Class LinkDAO
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.plugins.linkdirectory.link.LinkDAO
-
- All Implemented Interfaces:
Component
,Contextualizable
,LogEnabled
,Serviceable
public class LinkDAO extends AbstractLogEnabled implements Serviceable, Component, Contextualizable
DAO for manipulatingLink
-
-
Constructor Summary
Constructors Constructor Description LinkDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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)
Map<String,Object>
convertLink2JsonObject(DefaultLink link)
Convert a link to JSON objectMap<String,Object>
createLink(Map<String,Object> parameters)
Create a new linkMap<String,Object>
createUserLink(Map<String,Object> parameters)
Create a new user linkList<String>
deleteLinks(List<String> ids)
Delete one or multiples linksList<Map<String,Object>>
getDynamicInformationProviders()
Returns the list of providers of dynamic information as json objectMap<String,Object>
getLink(String id)
Get the JSON object representing a linkString
getLinkColor(DefaultLink link)
Retrieves the color of the link.List<Map<String,Object>>
getLinks(List<String> linkIds)
Get links infosboolean
isInternalURLAllowed(String siteName)
Determines if the restriction IP parameter is not emptyMap<String,Object>
moveLink(String id, String role)
Move a link in the listvoid
service(ServiceManager manager)
Map<String,Object>
updateLink(Map<String,Object> parameters)
Updates a link-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Constructor Detail
-
LinkDAO
public LinkDAO()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
createLink
public Map<String,Object> createLink(Map<String,Object> parameters)
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
public Map<String,Object> createUserLink(Map<String,Object> parameters)
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
public Map<String,Object> updateLink(Map<String,Object> parameters)
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
public List<String> deleteLinks(List<String> ids)
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
public Map<String,Object> moveLink(String id, String role) throws RepositoryException
Move a link in the list- Parameters:
id
- the link idrole
- the move action- Returns:
- the moved link in JSON
- Throws:
RepositoryException
- if a repository error occurs.
-
getLink
public Map<String,Object> getLink(String id)
Get the JSON object representing a link- Parameters:
id
- the id of link- Returns:
- the link as JSON object
-
isInternalURLAllowed
public boolean isInternalURLAllowed(String siteName)
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
public List<Map<String,Object>> getDynamicInformationProviders()
Returns the list of providers of dynamic information as json object- Returns:
- the providers of dynamic information
-
convertLink2JsonObject
public Map<String,Object> convertLink2JsonObject(DefaultLink link)
Convert a link to JSON object- Parameters:
link
- the link- Returns:
- the link as JSON object
-
getLinks
public List<Map<String,Object>> getLinks(List<String> linkIds)
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
protected DefaultLink _createLink(String name, ModifiableTraversableAmetysObject rootNode)
Create the link object.- Parameters:
name
- the desired link name.rootNode
- the links root node.- Returns:
- the created Link.
-
getLinkColor
public String getLinkColor(DefaultLink link)
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
-
-