001/*
002 * #%L
003 * Netarchivesuite - harvester
004 * %%
005 * Copyright (C) 2005 - 2014 The Royal Danish Library, the Danish State and University Library,
006 *             the National Library of France and the Austrian National Library.
007 * %%
008 * This program is free software: you can redistribute it and/or modify
009 * it under the terms of the GNU Lesser General Public License as
010 * published by the Free Software Foundation, either version 2.1 of the
011 * License, or (at your option) any later version.
012 * 
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Lesser Public License for more details.
017 * 
018 * You should have received a copy of the GNU General Lesser Public
019 * License along with this program.  If not, see
020 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
021 * #L%
022 */
023
024package dk.netarkivet.viewerproxy.webinterface;
025
026import javax.servlet.http.HttpServletRequest;
027
028import dk.netarkivet.common.webinterface.SiteSection;
029import dk.netarkivet.viewerproxy.Constants;
030
031/**
032 * Site section that creates the menu for QA.
033 */
034public class QASiteSection extends SiteSection {
035    /** The amount of pages visible in the QA menu. */
036    private static final int PAGES_VISIBLE_IN_MENU = 1;
037
038    /**
039     * Create a QA SiteSection object.
040     * <p>
041     * This initialises the SiteSection object with the pages that exists in QA.
042     */
043    public QASiteSection() {
044        super("sitesection;qa", "QA", PAGES_VISIBLE_IN_MENU, new String[][] {
045                {"status", "pagetitle;qa.status"},
046                // Pages below is not visible in the menu
047                {"getreports", "pagetitle;qa.get.reports"}, {"getfiles", "pagetitle;qa.get.files"},
048                {"crawlloglines", "pagetitle;qa.crawllog.lines.for.domain"},
049                {"searchcrawllog", "pagetitle;qa.crawllog.lines.matching.regexp"}}, "QA", Constants.TRANSLATIONS_BUNDLE);
050    }
051
052    /**
053     * Create a return-url for the QA pages that takes one.
054     * <p>
055     * The current implementation is hokey, but trying to go through URL objects is a mess.
056     *
057     * @param request The request that we have been called with.
058     * @return A URL object that leads to the QA-status page on the same machine as the request came from.
059     */
060    public static String createQAReturnURL(HttpServletRequest request) {
061        return request.getRequestURL().toString().replaceAll("/[^/]*\\.jsp.*$", "/QA-status.jsp");
062    }
063
064    /** No initialisation necessary in this site section. */
065    public void initialize() {
066    }
067
068    /** No cleanup necessary in this site section. */
069    public void close() {
070    }
071}