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
-
-
Field Summary
Fields Modifier and Type Field Description private Context_cocoonContextprivate LinkDirectoryColorsComponent_colorComponentprivate Context_contextprivate CurrentUserProvider_currentUserProviderprivate DirectoryHelper_directoryHelperprivate DynamicInformationProviderExtensionPoint_dynamicInfoExtensionPointprivate JSONUtils_jsonUtilsprivate ObservationManager_observationManagerprivate ProfileAssignmentStorageExtensionPoint_profileAssignmentStorageEPprivate AmetysObjectResolver_resolverprivate RightManager_rightManagerprivate SiteManager_siteManagerprivate UploadManager_uploadManagerstatic StringROLEAvalon Role
-
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.private void_moveDown(DefaultLink link)Move link after its followingprivate void_moveFirst(DefaultLink link)Move link the first positionprivate void_moveLast(DefaultLink link)Move link to the last position.private void_moveUp(DefaultLink link)Move link before its precedingprivate void_setAccess(Link link, UserIdentity user)Set access to the linkprivate void_setLinkValues(Link link, Map<String,Object> values)private void_setPicture(Link link, String valueAsStr)private void_setThemes(Link link, List<String> themes)private void_setValues(Link link, Map<String,Object> values)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.voidcontextualize(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 linkStringgetLinkColor(DefaultLink link)Retrieves the color of the link.List<Map<String,Object>>getLinks(List<String> linkIds)Get links infosbooleanisInternalURLAllowed(String siteName)Determines if the restriction IP parameter is not emptyMap<String,Object>moveLink(String id, String role)Move a link in the listvoidservice(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
-
-
-
-
Field Detail
-
_resolver
private AmetysObjectResolver _resolver
-
_observationManager
private ObservationManager _observationManager
-
_siteManager
private SiteManager _siteManager
-
_currentUserProvider
private CurrentUserProvider _currentUserProvider
-
_uploadManager
private UploadManager _uploadManager
-
_rightManager
private RightManager _rightManager
-
_profileAssignmentStorageEP
private ProfileAssignmentStorageExtensionPoint _profileAssignmentStorageEP
-
_jsonUtils
private JSONUtils _jsonUtils
-
_directoryHelper
private DirectoryHelper _directoryHelper
-
_cocoonContext
private Context _cocoonContext
-
_dynamicInfoExtensionPoint
private DynamicInformationProviderExtensionPoint _dynamicInfoExtensionPoint
-
_colorComponent
private LinkDirectoryColorsComponent _colorComponent
-
-
Constructor Detail
-
LinkDAO
public LinkDAO()
-
-
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
-
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
-
_setValues
private void _setValues(Link link, Map<String,Object> values)
-
_setLinkValues
private void _setLinkValues(Link link, Map<String,Object> values)
-
_setThemes
private void _setThemes(Link link, List<String> themes)
-
_setPicture
private void _setPicture(Link link, String valueAsStr)
-
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.
-
_moveFirst
private void _moveFirst(DefaultLink link) throws RepositoryException
Move link the first position- Parameters:
link- the link to move- Throws:
RepositoryException- if an error occurs while exploring the repository
-
_moveDown
private void _moveDown(DefaultLink link) throws RepositoryException
Move link after its following- Parameters:
link- the link to move down- Throws:
RepositoryException- if an error occurs while exploring the repository
-
_moveUp
private void _moveUp(DefaultLink link) throws RepositoryException
Move link before its preceding- Parameters:
link- the link to move up- Throws:
RepositoryException- if an error occurs while exploring the repository
-
_moveLast
private void _moveLast(DefaultLink link) throws RepositoryException
Move link to the last position.- Parameters:
link- the link to move up- Throws:
RepositoryException- if an error occurs while exploring the repository
-
_setAccess
private void _setAccess(Link link, UserIdentity user)
Set access to the link- Parameters:
link- the linkuser- the user to set access. Can be null, in this case, we set anonymous right
-
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
-
-