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.content.updatexml;
029
030import org.opencms.file.CmsObject;
031import org.opencms.main.CmsIllegalArgumentException;
032
033/**
034 * Bean to hold the settings needed for the operation of converting xml files in
035 * the OpenCms VFS.
036 * <p>
037 *
038 * @since 7.0.5
039 *
040 */
041public final class CmsUpdateXmlSettings {
042
043    /**
044     * Property for the tag-replace contentool to know the files that have been processed before in
045     * case of early terminaton in previous runs.
046     */
047    public static final String PROPERTY_CONTENTOOLS_TAGREPLACE = "contenttools.convertxml";
048
049    /** The boolean value if process files in subfolders, too. */
050    private boolean m_includeSubFolders;
051
052    /** Only count files to transform. */
053    private boolean m_onlyCountFiles;
054
055    /** ResourceType. */
056    private int m_resourceType;
057
058    /** The root of all content files to process. */
059    private String m_vfsFolder;
060
061    /** Xsl file. */
062    private String m_xslFile;
063
064    /**
065     * Bean constructor with cms object for path validation.
066     * <p>
067     *
068     * @param cms used to test the working path for valididty.
069     */
070    public CmsUpdateXmlSettings(CmsObject cms) {
071
072        m_resourceType = 0;
073        m_vfsFolder = "";
074        m_includeSubFolders = false;
075        m_xslFile = "";
076        m_onlyCountFiles = false;
077    }
078
079    /**
080     * Gets if also files in sub folders shall become processed.<p>
081     *
082     * @return if also files in sub folders shall become processed.
083     */
084    public boolean getIncludeSubFolders() {
085
086        return m_includeSubFolders;
087    }
088
089    /**
090     * Gets if only count files to transform.<p>
091     *
092     * @return If only count files to transform.
093     */
094    public boolean getOnlyCountFiles() {
095
096        return m_onlyCountFiles;
097    }
098
099    /**
100     * Gets resource type to transform.<p>
101     *
102     * @return Resource type to transform.
103     */
104    public int getResourceType() {
105
106        return m_resourceType;
107    }
108
109    /**
110     * Returns the path under which files will be processed.
111     * <p>
112     *
113     * @return the path under which files will be processed.
114     */
115    public String getVfsFolder() {
116
117        return m_vfsFolder;
118    }
119
120    /**
121     * Gets path to xsl file.<p>
122     *
123     * @return Path to xsl file.
124     */
125    public String getXslFile() {
126
127        return m_xslFile;
128    }
129
130    /**
131     * Sets value if also process files in sub folders.<p>
132     *
133     * @param subFolders True if process sub folders, too
134     *
135     * @throws CmsIllegalArgumentException if the argument is not valid.
136     */
137    public void setIncludeSubFolders(boolean subFolders) throws CmsIllegalArgumentException {
138
139        m_includeSubFolders = subFolders;
140    }
141
142    /**
143     * Sets if only count files to transform.<p>
144     *
145     * @param countFiles True, if only count files to transform
146     *
147     * @throws CmsIllegalArgumentException if the argument is not valid.
148     */
149    public void setOnlyCountFiles(boolean countFiles) throws CmsIllegalArgumentException {
150
151        m_onlyCountFiles = countFiles;
152    }
153
154    /**
155     * Sets resource type to transform.<p>
156     *
157     * @param resourceType File format to transform
158     *
159     * @throws CmsIllegalArgumentException if the argument is not valid.
160     */
161    public void setResourceType(int resourceType) throws CmsIllegalArgumentException {
162
163        m_resourceType = resourceType;
164    }
165
166    /**
167     * Sets vfs folder to process files in.<p>
168     *
169     * @param vfsFolder The vfs folder to process files in
170     *
171     * @throws CmsIllegalArgumentException if the argument is not valid.
172     */
173    public void setVfsFolder(String vfsFolder) throws CmsIllegalArgumentException {
174
175        m_vfsFolder = vfsFolder;
176    }
177
178    /**
179     * Sets path to xsl file.<p>
180     *
181     * @param xslFile Path to xsl file
182     *
183     * @throws CmsIllegalArgumentException if the argument is not valid.
184     */
185    public void setXslFile(String xslFile) throws CmsIllegalArgumentException {
186
187        m_xslFile = xslFile;
188    }
189}