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.file.history;
029
030import org.opencms.security.CmsPrincipal;
031import org.opencms.security.I_CmsPrincipal;
032import org.opencms.util.CmsUUID;
033
034import java.util.Locale;
035
036/**
037 * Describes an OpenCms historical principal entry.<p>
038 *
039 * @since 6.9.1
040 */
041public class CmsHistoryPrincipal extends CmsPrincipal implements Cloneable {
042
043    /** The date the principal was deleted. */
044    private long m_dateDeleted;
045
046    /** The email address of this deleted user, if this principal is a user. */
047    private String m_email;
048
049    /** The type of this deleted principal. */
050    private String m_type;
051
052    /** The id of user that deleted this principal. */
053    private CmsUUID m_userDeleted;
054
055    /**
056     * Default constructor.<p>
057     *
058     * @param id the unique id of this principal
059     * @param name the fully qualified name
060     * @param description the description
061     * @param type the principal type
062     * @param email the email address
063     * @param userDeleted the id of user that deleted this principal
064     * @param dateDeleted the date the principal was deleted
065     */
066    public CmsHistoryPrincipal(
067        CmsUUID id,
068        String name,
069        String description,
070        String email,
071        String type,
072        CmsUUID userDeleted,
073        long dateDeleted) {
074
075        m_id = id;
076        m_name = name;
077        m_description = description;
078        m_email = email;
079        m_type = type;
080        m_dateDeleted = dateDeleted;
081        m_userDeleted = userDeleted;
082    }
083
084    /**
085     * @see org.opencms.security.I_CmsPrincipal#checkName(java.lang.String)
086     */
087    public void checkName(String name) {
088
089        // noop
090    }
091
092    /**
093     * @see java.lang.Object#clone()
094     */
095    @Override
096    public Object clone() {
097
098        return new CmsHistoryPrincipal(
099            getId(),
100            getName(),
101            getDescription(),
102            getEmail(),
103            getType(),
104            m_userDeleted,
105            m_dateDeleted);
106    }
107
108    /**
109     * Returns the date the user was deleted.
110     *
111     * @return the date the user was deleted
112     */
113    public long getDateDeleted() {
114
115        return m_dateDeleted;
116    }
117
118    /**
119     * @see org.opencms.security.I_CmsPrincipal#getDescription(java.util.Locale)
120     */
121    public String getDescription(Locale locale) {
122
123        return "";
124    }
125
126    /**
127     * Returns the email address of this deleted user, if this principal is a user.<p>
128     *
129     * @return the email address of this deleted user
130     */
131    public String getEmail() {
132
133        return m_email;
134    }
135
136    /**
137     * Returns the principal type.<p>
138     *
139     * @return the principal type
140     */
141    public String getType() {
142
143        return m_type;
144    }
145
146    /**
147     * Returns the id of user that deleted this user.
148     *
149     * @return the id of user that deleted this user
150     */
151    public CmsUUID getUserDeleted() {
152
153        return m_userDeleted;
154    }
155
156    /**
157     * @see org.opencms.security.CmsPrincipal#isGroup()
158     */
159    @Override
160    public boolean isGroup() {
161
162        return m_type.equals(I_CmsPrincipal.PRINCIPAL_GROUP);
163    }
164
165    /**
166     * @see org.opencms.security.CmsPrincipal#isUser()
167     */
168    @Override
169    public boolean isUser() {
170
171        return m_type.equals(I_CmsPrincipal.PRINCIPAL_USER);
172    }
173}