001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://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 GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://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.workplace.tools.history; 029 030import org.opencms.main.OpenCms; 031 032/** 033 * Bean to store the entries made by the user in the History Settings form in the 034 * administration view.<p> 035 * 036 * @since 6.9.1 037 */ 038public class CmsHistorySettings { 039 040 /** Constant for the deleted resources history mode: disabled. */ 041 public static final int MODE_DELETED_HISTORY_DISABLED = 0; 042 043 /** Constant for the deleted resources history mode: keep without versions. */ 044 public static final int MODE_DELETED_HISTORY_KEEP_NO_VERSIONS = 1; 045 046 /** Constant for the deleted resources history mode: keep with versions. */ 047 public static final int MODE_DELETED_HISTORY_KEEP_WITH_VERSIONS = 2; 048 049 /** The mode how the deleted resource history is kept. */ 050 private int m_mode; 051 052 /** Number of versions to keep. */ 053 private int m_versions; 054 055 /** 056 * Default constructor initializing values.<p> 057 */ 058 public CmsHistorySettings() { 059 060 m_versions = OpenCms.getSystemInfo().getHistoryVersions(); 061 062 int versionsDeleted = OpenCms.getSystemInfo().getHistoryVersionsAfterDeletion(); 063 if (versionsDeleted == 0) { 064 m_mode = MODE_DELETED_HISTORY_DISABLED; 065 } else if (versionsDeleted == 1) { 066 m_mode = MODE_DELETED_HISTORY_KEEP_NO_VERSIONS; 067 } else if ((versionsDeleted > 1) || (versionsDeleted == -1)) { 068 m_mode = MODE_DELETED_HISTORY_KEEP_WITH_VERSIONS; 069 } else { 070 m_mode = MODE_DELETED_HISTORY_DISABLED; 071 } 072 } 073 074 /** 075 * Returns the mode how the deleted resource history is kept.<p> 076 * 077 * @return the mode how the deleted resource history is kept 078 */ 079 public int getMode() { 080 081 return m_mode; 082 } 083 084 /** 085 * Returns the number of versions to keep.<p> 086 * 087 * @return the number of versions to keep 088 */ 089 public int getVersions() { 090 091 return m_versions; 092 } 093 094 /** 095 * Sets the how the deleted resource history is kept.<p> 096 * 097 * @param mode the mode how the deleted resource history is kept 098 */ 099 public void setMode(int mode) { 100 101 m_mode = mode; 102 } 103 104 /** 105 * Sets the number of versions to keep.<p> 106 * 107 * @param versions the number of versions to keep 108 */ 109 public void setVersions(int versions) { 110 111 m_versions = versions; 112 } 113}