001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: https://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: https://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.db;
029
030import org.opencms.configuration.CmsParameterConfiguration;
031import org.opencms.util.CmsStringUtil;
032
033import java.util.Collections;
034import java.util.List;
035
036/**
037 * Configuration parameters for the 'online folder' feature.
038 */
039public class CmsOnlineFolderOptions {
040
041    /** Configuration key for the indexing interval.  */
042    public static final String PARAM_INDEXING_INTERVAL = "indexing-interval";
043
044    /** Configuration key for the flex cache clear delay. */
045    public static final String PARAM_FLEX_CACHE_DELAY = "flex-cache-delay";
046
047    /** The paths which are defined as online folders. */
048    private List<String> m_paths;
049
050    /** Additional parameters. */
051    private CmsParameterConfiguration m_params;
052
053    /**
054     * Creates a new instance.
055     *
056     * @param paths the paths to be used as online folders
057     * @param params additional parameters
058     */
059    public CmsOnlineFolderOptions(List<String> paths, CmsParameterConfiguration params) {
060
061        m_paths = Collections.unmodifiableList(paths);
062        m_params = CmsParameterConfiguration.unmodifiableVersion(params);
063    }
064
065    /**
066     * Gets the duration that has to pass after an instant publish event with no further instant publish events before the Flex cache is cleared.
067     *
068     * @return the flex cache delay
069     */
070    public long getFlexCacheDelay() {
071
072        String delayStr = m_params.getString(PARAM_FLEX_CACHE_DELAY, "5s");
073        return CmsStringUtil.parseDuration(delayStr, 5000);
074
075    }
076
077    /**
078     * Gets the amount of time across which (non-deletion) changes from instant publish events are combined for indexing.
079     *
080     * @return the indexing interval
081     */
082    public long getIndexingInterval() {
083
084        String indexingIntervalStr = m_params.getString(PARAM_INDEXING_INTERVAL, "2s");
085        return CmsStringUtil.parseDuration(indexingIntervalStr, 2000);
086
087    }
088
089    /**
090     * Gets the additional parameters.
091     * @return the additional parameters
092     */
093    public CmsParameterConfiguration getParams() {
094
095        return m_params;
096    }
097
098    /**
099     * Gets the configured paths.
100     *
101     * @return the configured paths
102     */
103    public List<String> getPaths() {
104
105        return m_paths;
106    }
107
108}