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.file.CmsObject; 031import org.opencms.file.CmsProject; 032import org.opencms.main.CmsException; 033import org.opencms.security.CmsPrincipal; 034import org.opencms.util.CmsUUID; 035 036import java.util.List; 037 038/** 039 * Describes an OpenCms historical project entry.<p> 040 * 041 * @since 6.9.1 042 */ 043public class CmsHistoryProject extends CmsProject { 044 045 /** The publishing date of this project. */ 046 private long m_datePublished; 047 048 /** The resources belonging to the project. */ 049 private List<String> m_projectResources; 050 051 /** The publish tag of the published project. */ 052 private int m_publishTag; 053 054 /** The user id of the publisher. */ 055 private CmsUUID m_userPublished; 056 057 /** 058 * Creates a new CmsHistoryProject.<p> 059 * 060 * @param publishTag the version id for this historical project 061 * @param projectId the id to use for this project 062 * @param name the name for this project 063 * @param description the description for this project 064 * @param ownerId the owner id for this project 065 * @param groupId the group id for this project 066 * @param managerGroupId the manager group id for this project 067 * @param dateCreated the creation date of this project 068 * @param type the type of this project 069 * @param datePublished the date this backup project was published 070 * @param userPublished the id of the user who published 071 * @param projectResources a list of resources that are the project "view" 072 */ 073 public CmsHistoryProject( 074 int publishTag, 075 CmsUUID projectId, 076 String name, 077 String description, 078 CmsUUID ownerId, 079 CmsUUID groupId, 080 CmsUUID managerGroupId, 081 long dateCreated, 082 CmsProjectType type, 083 long datePublished, 084 CmsUUID userPublished, 085 List<String> projectResources) { 086 087 super(projectId, name, description, ownerId, groupId, managerGroupId, 0, dateCreated, type); 088 089 m_publishTag = publishTag; 090 m_datePublished = datePublished; 091 m_userPublished = userPublished; 092 m_projectResources = projectResources; 093 } 094 095 /** 096 * @see org.opencms.file.CmsProject#clone() 097 */ 098 @Override 099 public Object clone() { 100 101 return new CmsHistoryProject( 102 m_publishTag, 103 getUuid(), 104 getName(), 105 getDescription(), 106 getOwnerId(), 107 getGroupId(), 108 getManagerGroupId(), 109 getDateCreated(), 110 getType(), 111 m_datePublished, 112 m_userPublished, 113 m_projectResources); 114 } 115 116 /** 117 * @see java.lang.Object#equals(java.lang.Object) 118 */ 119 @Override 120 public boolean equals(Object obj) { 121 122 if (obj == this) { 123 return true; 124 } 125 if (obj instanceof CmsHistoryProject) { 126 return ((CmsHistoryProject)obj).getUuid().equals(getUuid()); 127 } 128 return false; 129 } 130 131 /** 132 * Returns the project manager group name.<p> 133 * 134 * @param cms the current cms context 135 * 136 * @return the projects manager group name 137 */ 138 public String getGroupManagersName(CmsObject cms) { 139 140 try { 141 return CmsPrincipal.readPrincipalIncludingHistory(cms, getManagerGroupId()).getName(); 142 } catch (CmsException e) { 143 return getManagerGroupId().toString(); 144 } 145 } 146 147 /** 148 * Returns the projects user group name.<p> 149 * 150 * @param cms the current cms context 151 * 152 * @return the projects user group name 153 */ 154 public String getGroupUsersName(CmsObject cms) { 155 156 try { 157 return CmsPrincipal.readPrincipalIncludingHistory(cms, getGroupId()).getName(); 158 } catch (CmsException e) { 159 return getGroupId().toString(); 160 } 161 } 162 163 /** 164 * Returns the owner name.<p> 165 * 166 * @param cms the current cms context 167 * 168 * @return the owner name 169 */ 170 public String getOwnerName(CmsObject cms) { 171 172 try { 173 return CmsPrincipal.readPrincipalIncludingHistory(cms, getOwnerId()).getName(); 174 } catch (CmsException e) { 175 return getOwnerId().toString(); 176 } 177 } 178 179 /** 180 * Returns the project resources (i.e. the "view" of the project).<p> 181 * 182 * @return the project resources 183 */ 184 public List<String> getProjectResources() { 185 186 return m_projectResources; 187 } 188 189 /** 190 * Returns the id of the user that published this project.<p> 191 * 192 * @return the id of the user that published this project 193 */ 194 public CmsUUID getPublishedBy() { 195 196 return m_userPublished; 197 } 198 199 /** 200 * Returns the publishers name.<p> 201 * 202 * @param cms the current cms context 203 * 204 * @return the publishers name 205 */ 206 public String getPublishedByName(CmsObject cms) { 207 208 try { 209 return CmsPrincipal.readPrincipalIncludingHistory(cms, getPublishedBy()).getName(); 210 } catch (CmsException e) { 211 return getPublishedBy().toString(); 212 } 213 } 214 215 /** 216 * Returns the publishing date of this project.<p> 217 * 218 * @return the publishing date of this project 219 */ 220 public long getPublishingDate() { 221 222 return m_datePublished; 223 } 224 225 /** 226 * Returns the publish tag.<p> 227 * 228 * @return the publish tag 229 */ 230 public int getPublishTag() { 231 232 return m_publishTag; 233 } 234 235 /** 236 * @see java.lang.Object#hashCode() 237 */ 238 @Override 239 public int hashCode() { 240 241 return (Long.valueOf(m_datePublished)).hashCode(); 242 } 243 244 /** 245 * Sets the projectResources.<p> 246 * 247 * @param projectResources the projectResources to set 248 */ 249 public void setProjectResources(List<String> projectResources) { 250 251 m_projectResources = projectResources; 252 } 253}