Class DomainDefinition


  • public class DomainDefinition
    extends java.lang.Object
    Utility class for handling update of domain from the domain jsp page.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.String EDIT_DOMAIN_JSP  
      protected static org.slf4j.Logger log  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void CreateDomainDefinitionListInRequest​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.jsp.PageContext pageContext, I18n I18N)
      Create the domain definition list for the jsp page.
      static java.util.List<java.lang.String> createDomains​(java.lang.String... domains)
      Creates domains with default attributes.
      static java.lang.String createDomainUrlWithFlippedShowConfigurations​(javax.servlet.ServletRequest request)
      Creates a url based on the supplied request where all the parameters are the same, except the ShowUnusedConfigurations boolean, which is flipped.
      static java.lang.String createDomainUrlWithFlippedShowSeeds​(javax.servlet.ServletRequest request)
      Creates a url based on the supplied request where all the parameters are the same, except the ShowUnusedSeedLists boolean, which is flipped.
      static java.util.List<java.lang.String> getDomains​(javax.servlet.jsp.PageContext context, I18n i18n, java.lang.String searchQuery, java.lang.String searchType)
      Search for domains matching the following criteria.
      static java.util.List<SeedList> getSeedLists​(java.util.List<DomainConfiguration> configurations)
      Returns the seed lists associated with the supplied configurations.
      static java.util.List<DomainConfiguration> getUsedConfiguration​(Domain domain, java.util.Locale locale)
      Returns the list of domain configurations which are either used in a concrete harvest or is a 'default configuration'.
      static java.lang.String makeDomainLink​(java.lang.String domain)
      Creates a link to the domain edit page.
      static void processRequest​(javax.servlet.jsp.PageContext context, I18n i18n)
      Extracts all required parameters from the request, checks for any inconsistencies, and passes the requisite data to the updateDomain method for processing.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • processRequest

        public static void processRequest​(javax.servlet.jsp.PageContext context,
                                          I18n i18n)
        Extracts all required parameters from the request, checks for any inconsistencies, and passes the requisite data to the updateDomain method for processing.

        For reference, the parameters for this page look something like http://localhost:8076/HarvestDefinition/Definitions-edit-domain.jsp? update=1&name=netarkivet.dk&default=defaultconfig&configName=&order_xml=& load=&maxObjects=&urlListName=&seedList=+&passwordName=&passwordDomain=& passwordRealm=&userName=&password=& crawlertraps=%2Fcgi-bin%2F*%0D%0A%2Ftrap%2F*%0D%0A

        update: This method throws an exception if update is not set

        name: must be the name of a known domain

        comments: optional user-entered comments about the domain

        default: the defaultconfig is set to this value. Must be non-null and a known configuration of this domain.

        crawlertraps: a newline-separated list of urls to be ignored. May be empty or null

        alias: If set, this domain is an alias of the set domain renewAlias: If set, the alias date should be renewed

        Parameters:
        context - The context of this request
        i18n - I18n information
        Throws:
        IOFailure - on updateerrors in the DAO
        ForwardedToErrorPage - if domain is not found, if the edition is out-of-date, or if parameters are missing or invalid
      • createDomains

        public static java.util.List<java.lang.String> createDomains​(java.lang.String... domains)
        Creates domains with default attributes.
        Parameters:
        domains - a list of domain names
        Returns:
        List of the non-empty domain names that were not legal domain names or already exist.
      • makeDomainLink

        public static java.lang.String makeDomainLink​(java.lang.String domain)
        Creates a link to the domain edit page.
        Parameters:
        domain - The domain to show with a link
        Returns:
        HTML code with the link and the domain name shown
      • createDomainUrlWithFlippedShowConfigurations

        public static java.lang.String createDomainUrlWithFlippedShowConfigurations​(javax.servlet.ServletRequest request)
        Creates a url based on the supplied request where all the parameters are the same, except the ShowUnusedConfigurations boolean, which is flipped.
        Parameters:
        request - The original 'create domain' request to based the new url on.
        Returns:
        The new url with the ShowUnusedConfigurations boolean switched.
      • createDomainUrlWithFlippedShowSeeds

        public static java.lang.String createDomainUrlWithFlippedShowSeeds​(javax.servlet.ServletRequest request)
        Creates a url based on the supplied request where all the parameters are the same, except the ShowUnusedSeedLists boolean, which is flipped.
        Parameters:
        request - The original 'create domain' request to based the new url on.
        Returns:
        The new url with the ShowUnusedSeedLists boolean switched.
      • getDomains

        public static java.util.List<java.lang.String> getDomains​(javax.servlet.jsp.PageContext context,
                                                                  I18n i18n,
                                                                  java.lang.String searchQuery,
                                                                  java.lang.String searchType)
        Search for domains matching the following criteria. TODO Should we allow more than one criteria? TODO use Enum instead for searchType
        Parameters:
        context - the context of the JSP page calling
        i18n - The translation properties file used
        searchQuery - The given searchQuery for searching for among the domains.
        searchType - The given searchCriteria
        Returns:
        the set of domain-names matching the given criteria.
      • getUsedConfiguration

        public static java.util.List<DomainConfigurationgetUsedConfiguration​(Domain domain,
                                                                               java.util.Locale locale)
        Returns the list of domain configurations which are either used in a concrete harvest or is a 'default configuration'.

        The list is sorted alphabetically by name according to the supplied locale.

        Parameters:
        domain - The domain to find the used configurations for.
        locale - The locale to base the sorting on
        Returns:
        A sorted list of used configurations for the supplied domain.
      • getSeedLists

        public static java.util.List<SeedListgetSeedLists​(java.util.List<DomainConfiguration> configurations)
        Returns the seed lists associated with the supplied configurations.
        Parameters:
        configurations - The configurations to find seed lists for
        Returns:
        The seed lists used in the supplied configurations.
      • CreateDomainDefinitionListInRequest

        public static void CreateDomainDefinitionListInRequest​(javax.servlet.http.HttpServletRequest request,
                                                               javax.servlet.http.HttpServletResponse response,
                                                               javax.servlet.jsp.PageContext pageContext,
                                                               I18n I18N)
                                                        throws ArgumentNotValid,
                                                               ForwardedToErrorPage,
                                                               javax.servlet.ServletException,
                                                               java.io.IOException
        Create the domain definition list for the jsp page. Code has been moved from the jsp to here to avoid compile errors at runtime in correlation with the upgrade to java 1.8 and introduction of embedded tomcat to handle jsp pages. This was previously done via jetty 6.
        Parameters:
        pageContext - the current JSP context
        request - the JSP request
        response - the JSP response
        I18N - internationalization object.
        Throws:
        ForwardedToErrorPage - if an unknown bitarchive or update type is posted, or one of the two required parameters are missing.
        ArgumentNotValid - If the context is null.
        javax.servlet.ServletException
        java.io.IOException