Class FriendlyURLManager

java.lang.Object
com.jalios.jcms.friendlyurl.FriendlyURLManager

public class FriendlyURLManager extends Object
  • Method Details

    • getInstance

      public static FriendlyURLManager getInstance()
    • initAfterStoreLoad

      public void initAfterStoreLoad()
    • generateFriendlyURL

      public String generateFriendlyURL(Category cat, String lang)
      Build and return a friendly url that can be added later to the friendly urls Servlet Filter.
      This method does not check for availabilty of the built friendlyURL.
      Parameters:
      cat - the Category to build a url for
      lang - the lang in which to build a url
      Returns:
      a friendlyURL
    • generateFriendlyURL

      public String generateFriendlyURL(Publication pub, String lang)
      Build and return a friendly url that can be added later to the friendly urls Servlet Filter.
      This method do not check for availabilty of the built friendly url.
      Parameters:
      pub - the Publication to build a url for
      lang - the lang in which to build a url
      Returns:
      a friendly url or null if the url could not be build in the given language
    • buildCleanURL

      public String buildCleanURL(String str)
      Method to clean the given string to have a proper URL.
      Convert to CamelCase (keeping '/' separator)
      Parameters:
      str - the string to clean
      Returns:
      the cleaned string
    • isFriendlyURLAvailable

      public boolean isFriendlyURLAvailable(String id, String friendlyURL)
      Check if the given friendly URL is available, that is either :
      • the Friendly URL is not in the Friendly URLs of the servlet
      • or else the Friendly URL is already there with the same data

      Instance method, to be used by rpc call in doEditCommonPubAttribute.
      Parameters:
      id - the id of the data associated with the friendly url
      friendlyURL - the friendlyURL for which to check availability
      Returns:
      true if available, false otherwise
    • isFriendlyURLAvailableWrapper

      public static boolean isFriendlyURLAvailableWrapper(String id, String friendlyURL)
    • isFriendlyURLValid

      public boolean isFriendlyURLValid(String friendlyURL)
      Check if the given friendly url is valid.
      Instance method, to be used by rpc call in doEditCommonPubAttribute.
      Parameters:
      friendlyURL - the friendly url to check
      Returns:
      true if friendly URL is a valid one, false otherwise
    • isFriendlyURLAvailable

      public boolean isFriendlyURLAvailable(Data data, String friendlyURL)
      Check if the given friendly URL is available, that is either :
      • the Friendly URL is not in the Friendly URLs of the servlet
      • or else the Friendly URL is already there with the same data
      Parameters:
      data - the data associated with the friendly url
      friendlyURL - the friendlyURL for which to check availability
      Returns:
      true if available, false otherwise
    • getFriendlyURLSet

      public Set<String> getFriendlyURLSet(Data data)
      Return a set of friendly urls associated with the given data
      Parameters:
      data - the data of which to retrieve friendly urls
      Returns:
      a Set of String
    • getDataFromFriendlyURL

      public Data getDataFromFriendlyURL(String friendlyURL)
      Return the data associated with the given friendly URL.
      Parameters:
      friendlyURL - the friendly URL to test
      Returns:
      the associated Data or null.
    • updateFriendlyURLs

      public void updateFriendlyURLs(Publication pub)
      Add the friendly URL of the given publication.
      Parameters:
      pub - the publication
      Since:
      jcms-10.0.0
    • updateFriendlyURLs

      public void updateFriendlyURLs(Category cat)
      Add the friendly URL of the given category.
      Parameters:
      cat - the category
      Since:
      jcms-10.0.0
    • addFriendlyURL

      public boolean addFriendlyURL(Data data, String friendlyURL)
      Add the given friendlyURLSet to the friendly urls of the servlet.
      Check the friendly url is available.
      Parameters:
      data - the data associated with the friendly url
      friendlyURL - the friendly url
      Returns:
      true if the friendlyURL was added or was already there, false otherwise.
    • removeDataFriendlyURL

      public boolean removeDataFriendlyURL(Data data)
      Remove the given data and all its associated friendly url.
      Parameters:
      data - the data to remove from the servlet.
      Returns:
      true if the data was removed, false if it was not there.
    • removeDataFriendlyURL

      public boolean removeDataFriendlyURL(String dataId)
      Remove the given data and all its associated friendly url.
      Parameters:
      dataId - the data id to remove from the servlet.
      Returns:
      true if the data was removed, false if it was not there.
    • removeFriendlyURL

      public boolean removeFriendlyURL(String friendlyURL)
      Remove the given friendly url.
      Parameters:
      friendlyURL - the friendly url to remove
      Returns:
      true if the friendly url was removed, false if it was not there.
    • getFriendlyURLToDataMap

      public Map<String,String> getFriendlyURLToDataMap()
      Returns:
      a copy of the HashMap associating FriendlyURL with a Data
    • getDataToFriendlyURLSetMap

      public Map<String,Set<String>> getDataToFriendlyURLSetMap()
      Returns:
      a copy of the HashMap associating Data with a FriendlyURL Set