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.synchronize;
029
030import org.opencms.util.CmsDateUtil;
031
032import java.io.Serializable;
033
034/**
035 * Defines the CmsSynchronizeList object, used to store synchronisation data
036 * required to synchronize the VFS and the server FS.<p>
037 *
038 * @since 6.0.0
039 */
040public class CmsSynchronizeList implements Serializable {
041
042    /** Serial version UID required for safe serialization. */
043    private static final long serialVersionUID = -4460686435282590290L;
044
045    /**
046     * Last modification data of this resource in the FS.
047     */
048    private long m_modifiedFs;
049
050    /**
051     * Last modification date of this resouce in the VFS.
052     */
053    private long m_modifiedVfs;
054
055    /**
056     * Name of the resource stored in the sync list.
057     */
058    private String m_resName;
059
060    /**
061     * Name of the translated resource stored in the sync list.
062     * Its nescessary to translate the resource name, since the server FS does
063     * allow different
064     * naming conventions than the VFS.
065     */
066    private String m_transResName;
067
068    /**
069     * Constructor, creates a new CmsSynchronizeList object.
070     *
071     * @param resName The name of the resource
072     * @param transResName The name of the resource
073     * @param modifiedVfs last modification date in the Vfs
074     * @param modifiedFs last modification date in the Fs
075     */
076    public CmsSynchronizeList(String resName, String transResName, long modifiedVfs, long modifiedFs) {
077
078        m_resName = resName;
079        m_transResName = transResName;
080        m_modifiedVfs = modifiedVfs;
081        m_modifiedFs = modifiedFs;
082    }
083
084    /**
085     * Returns a format description of the sync-list file on the server FS.<p>
086     *
087     * @return format description
088     */
089    public static String getFormatDescription() {
090
091        String output = "[original filename FS]:[translated filename VFS]";
092        output += ":[timestamp VFS]:[timestamp  FS]";
093        output += ":[VFS=readable timestamp VFS]:[FS=readable timestamp FS]";
094        return output;
095    }
096
097    /**
098     * Returns the last modification date in the Fs.
099     * @return last modification date in the Fs
100     */
101    public long getModifiedFs() {
102
103        return m_modifiedFs;
104    }
105
106    /**
107     * Returns the last modification date in the Vfs.
108     * @return last modification date in the Vfs
109     */
110    public long getModifiedVfs() {
111
112        return m_modifiedVfs;
113    }
114
115    /**
116     * Returns the name of the resource.
117     * @return name of the resource
118     */
119    public String getResName() {
120
121        return m_resName;
122    }
123
124    /**
125     * Returns the translated name of the resource.
126     * @return name of the resource
127     */
128    public String getTransResName() {
129
130        return m_transResName;
131    }
132
133    /**
134     * Returns a string-representation for this object. <p>
135     *
136     * This is used to create the sync list entries in the server FS
137     *
138     * @return string-representation for this object.
139     */
140    @Override
141    public String toString() {
142
143        String output = m_resName + ":" + m_transResName + ":" + m_modifiedVfs + ":" + m_modifiedFs;
144        output += ":VFS=" + CmsDateUtil.getDateTimeShort(m_modifiedVfs);
145        output += ":FS=" + CmsDateUtil.getDateTimeShort(m_modifiedFs);
146        return output;
147    }
148
149}