001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/importexport/CmsExportParameters.java,v $
003: * Date : $Date: 2008-02-27 12:05:48 $
004: * Version: $Revision: 1.3 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.importexport;
033:
034: import org.opencms.main.CmsIllegalArgumentException;
035: import org.opencms.util.CmsStringUtil;
036:
037: import java.util.Collections;
038: import java.util.List;
039:
040: import org.dom4j.Element;
041:
042: /**
043: * Export parameters.<p>
044: *
045: * @author Michael Moossen
046: *
047: * @version $Revision: 1.3 $
048: *
049: * @since 7.0.4
050: */
051: public class CmsExportParameters {
052:
053: /** Only resources modified after this time stamp will be exported. */
054: private long m_contentAge;
055:
056: /** If the account data should be exported. */
057: private boolean m_exportAccountData = false;
058:
059: /** If the project data should be exported. */
060: private boolean m_exportProjectData = false;
061:
062: /** If the resource data should be exported. */
063: private boolean m_exportResourceData = true;
064:
065: /** If the system folder should be included in the export.*/
066: private boolean m_includeSystemFolder = true;
067:
068: /** If unchanged files should be included in the export.*/
069: private boolean m_includeUnchangedResources = true;
070:
071: /** If set, only resources belonging to the current project will be exported. */
072: private boolean m_inProject = false;
073:
074: /** The module informations if to export a module. */
075: private Element m_moduleInfo = null;
076:
077: /** The file path, should be a zip file. */
078: private String m_path;
079:
080: /** If the resources should be recursively exported. */
081: private boolean m_recursive = true;
082:
083: /** The resources to export.*/
084: private List m_resources;
085:
086: /** If set, the manifest.xml file will be generated with dtd info. */
087: private boolean m_xmlValidation;
088:
089: /**
090: * Constructor.<p>
091: */
092: public CmsExportParameters() {
093:
094: // empty constructor for the database export dialog
095: }
096:
097: /**
098: * Constructor.<p>
099: *
100: * @param exportFile the zip file to export to
101: * @param moduleElement module informations in a Node for module export
102: * @param exportResourceData if the resource data has also to be exported
103: * @param exportUserdata if the account data has also to be exported
104: * @param exportProjectData if the project data has also to be exported
105: * @param resourcesToExport the paths of folders and files to export
106: * @param includeSystem if <code>true</code>, the system folder is included
107: * @param includeUnchanged <code>true</code>, if unchanged files should be included
108: * @param contentAge export contents changed after this date/time
109: * @param recursive recursive flag
110: * @param inProject if only resources in the current project are exported
111: */
112: public CmsExportParameters(String exportFile,
113: Element moduleElement, boolean exportResourceData,
114: boolean exportUserdata, boolean exportProjectData,
115: List resourcesToExport, boolean includeSystem,
116: boolean includeUnchanged, long contentAge,
117: boolean recursive, boolean inProject) {
118:
119: setPath(exportFile);
120: setResources(resourcesToExport);
121: setIncludeSystemFolder(includeSystem);
122: setIncludeUnchangedResources(includeUnchanged);
123: setModuleInfo(moduleElement);
124: setExportAccountData(exportUserdata);
125: setContentAge(contentAge);
126: setRecursive(recursive);
127: setExportResourceData(exportResourceData);
128: setExportProjectData(exportProjectData);
129: setInProject(inProject);
130: }
131:
132: /**
133: * Returns the content Age.<p>
134: *
135: * @return the content Age
136: */
137: public long getContentAge() {
138:
139: return m_contentAge;
140: }
141:
142: /**
143: * Returns the module informations if to export a module.<p>
144: *
145: * @return the module informations if to export a module
146: */
147: public Element getModuleInfo() {
148:
149: return m_moduleInfo;
150: }
151:
152: /**
153: * Returns the file path, should be a zip file.<p>
154: *
155: * @return the file path
156: */
157: public String getPath() {
158:
159: return m_path;
160: }
161:
162: /**
163: * Returns the resources.<p>
164: *
165: * @return the resources
166: */
167: public List getResources() {
168:
169: if (m_resources == null) {
170: return Collections.EMPTY_LIST;
171: }
172: return m_resources;
173: }
174:
175: /**
176: * Checks if to export account data.<p>
177: *
178: * @return <code>true</code>, if to export account data
179: */
180: public boolean isExportAccountData() {
181:
182: return m_exportAccountData;
183: }
184:
185: /**
186: * Checks if to export project data.<p>
187: *
188: * @return <code>true</code>, if to export project data
189: */
190: public boolean isExportProjectData() {
191:
192: return m_exportProjectData;
193: }
194:
195: /**
196: * Checks if to export resource data.<p>
197: *
198: * @return <code>true</code>, if to export resource data
199: */
200: public boolean isExportResourceData() {
201:
202: return m_exportResourceData;
203: }
204:
205: /**
206: * Checks if to include the /system/ Folder.<p>
207: *
208: * @return <code>true</code>, if to include the /system/ Folder
209: */
210: public boolean isIncludeSystemFolder() {
211:
212: return m_includeSystemFolder;
213: }
214:
215: /**
216: * Checks if to include unchanged resources.<p>
217: *
218: * @return <code>true</code>, if to include unchanged resources
219: */
220: public boolean isIncludeUnchangedResources() {
221:
222: return m_includeUnchangedResources;
223: }
224:
225: /**
226: * Checks if to include only resources in the current project.<p>
227: *
228: * @return <code>true</code>, if to include only resources in the current project
229: */
230: public boolean isInProject() {
231:
232: return m_inProject;
233: }
234:
235: /**
236: * Checks if to recurse the resources to export.<p>
237: *
238: * @return <code>true</code>, if to recurse the resources to export
239: */
240: public boolean isRecursive() {
241:
242: return m_recursive;
243: }
244:
245: /**
246: * Checks if the manifest.xml file will be generated with dtd info.<p>
247: *
248: * @return the xml validation flag
249: */
250: public boolean isXmlValidation() {
251:
252: return m_xmlValidation;
253: }
254:
255: /**
256: * Sets the content Age.<p>
257: *
258: * @param contentAge the content Age to set
259: */
260: public void setContentAge(long contentAge) {
261:
262: if (contentAge < 0) {
263: String ageString = Long.toString(contentAge);
264: throw new CmsIllegalArgumentException(Messages.get()
265: .container(Messages.ERR_BAD_CONTENT_AGE_1,
266: ageString));
267: }
268: m_contentAge = contentAge;
269: }
270:
271: /**
272: * Sets if to export account data.<p>
273: *
274: * @param exportAccountData the flag to set
275: */
276: public void setExportAccountData(boolean exportAccountData) {
277:
278: m_exportAccountData = exportAccountData;
279: }
280:
281: /**
282: * Sets if to export project data.<p>
283: *
284: * @param exportProjectData the flag to set
285: */
286: public void setExportProjectData(boolean exportProjectData) {
287:
288: m_exportProjectData = exportProjectData;
289: }
290:
291: /**
292: * Sets if to export resource data.<p>
293: *
294: * @param exportResourceData the flag to set
295: */
296: public void setExportResourceData(boolean exportResourceData) {
297:
298: m_exportResourceData = exportResourceData;
299: }
300:
301: /**
302: * Sets if to include the /system/ Folder.<p>
303: *
304: * @param includeSystemFolder the flag to set
305: */
306: public void setIncludeSystemFolder(boolean includeSystemFolder) {
307:
308: m_includeSystemFolder = includeSystemFolder;
309: }
310:
311: /**
312: * Sets if to include unchanged resources.<p>
313: *
314: * @param includeUnchangedResources the flag to set
315: */
316: public void setIncludeUnchangedResources(
317: boolean includeUnchangedResources) {
318:
319: m_includeUnchangedResources = includeUnchangedResources;
320: }
321:
322: /**
323: * Sets if to only include files in the current project.<p>
324: *
325: * @param inProject the flag to set
326: */
327: public void setInProject(boolean inProject) {
328:
329: m_inProject = inProject;
330: }
331:
332: /**
333: * Sets the module informations if to export a module.<p>
334: *
335: * @param moduleInfo the module info node to set
336: */
337: public void setModuleInfo(Element moduleInfo) {
338:
339: m_moduleInfo = moduleInfo;
340: }
341:
342: /**
343: * Sets the file path, should be a zip file.<p>
344: *
345: * @param path the file path
346: */
347: public void setPath(String path) {
348:
349: if (CmsStringUtil.isEmpty(path) || !path.trim().equals(path)) {
350: throw new CmsIllegalArgumentException(Messages.get()
351: .container(Messages.ERR_BAD_FILE_NAME_1, path));
352: }
353: m_path = path;
354: // ensure the export file name ends with ".zip"
355: if (!m_path.toLowerCase().endsWith(".zip")) {
356: m_path += ".zip";
357: }
358: }
359:
360: /**
361: * Sets the recursive flag.<p>
362: *
363: * @param recursive the flag to set
364: */
365: public void setRecursive(boolean recursive) {
366:
367: m_recursive = recursive;
368: }
369:
370: /**
371: * Sets the resources.<p>
372: *
373: * @param resources the resources to set
374: */
375: public void setResources(List resources) {
376:
377: m_resources = resources;
378: }
379:
380: /**
381: * Sets the xml validation flag. If set, the manifest.xml file will be generated with dtd info.<p>
382: *
383: * @param xmlValidation the xml validation flag to set
384: */
385: public void setXmlValidation(boolean xmlValidation) {
386:
387: m_xmlValidation = xmlValidation;
388: }
389: }
|