Class DomainDefinition


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

      • log

        protected static final org.slf4j.Logger log
    • 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 List<String> createDomains​(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 String makeDomainLink​(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 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 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 List<String> getDomains​(javax.servlet.jsp.PageContext context,
                                              I18n i18n,
                                              String searchQuery,
                                              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 List<DomainConfiguration> getUsedConfiguration​(Domain domain,
                                                                     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 List<SeedList> getSeedLists​(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,
                                                               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
        IOException