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 Details

    • ROLE

      public static final String ROLE
      Avalon Role
  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager manager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • contextualize

      public void contextualize(Context context) throws ContextException
      Specified by:
      contextualize in interface Contextualizable
      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
    • isUserLink

      public boolean isUserLink(DefaultLink link)
      Indicate if a link is a user link
      Parameters:
      link - the link
      Returns:
      true if the link is a user link
    • 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 javax.jcr.RepositoryException
      Move a link in the list
      Parameters:
      id - the link id
      role - the move action
      Returns:
      the moved link in JSON
      Throws:
      javax.jcr.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

      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

      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 test
      siteName - 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 test
      siteName - 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