001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (C) Alkacon Software (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, 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.gwt.shared.alias; 029 030import org.opencms.util.CmsUUID; 031 032import com.google.gwt.user.client.rpc.IsSerializable; 033 034/** 035 * A bean representing a row of the alias table.<p> 036 */ 037public class CmsAliasTableRow implements IsSerializable { 038 039 /** The alias path error. */ 040 private String m_aliasError; 041 042 /** The alias path. */ 043 private String m_aliasPath; 044 045 /** Flag which indicates whether this row is changed. */ 046 private boolean m_isChanged; 047 048 /** Flag which indicates whether this row is edited. */ 049 private boolean m_isEdited; 050 051 /** The internal key of the alias table row. */ 052 private String m_key; 053 054 /** The alias mode. */ 055 private CmsAliasMode m_mode; 056 057 /** The original structure id of the alias. */ 058 private CmsUUID m_originalStructureId; 059 060 /** The path error message. */ 061 private String m_pathError; 062 063 /** The resource path. */ 064 private String m_resourcePath; 065 066 /** The structure id of the alias target. */ 067 private CmsUUID m_structureId; 068 069 /** 070 * Default constructor.<p> 071 */ 072 public CmsAliasTableRow() { 073 074 // do nothing 075 } 076 077 /** 078 * Clears validation errors.<p> 079 */ 080 public void clearErrors() { 081 082 if ((getAliasError() != null) || (getPathError() != null)) { 083 // ensure rows with errors are updated correctly 084 m_isChanged = true; 085 } 086 m_pathError = null; 087 m_aliasError = null; 088 } 089 090 /** 091 * Copies this object.<p> 092 * 093 * @return a copy of the alias row 094 */ 095 public CmsAliasTableRow copy() { 096 097 CmsAliasTableRow result = new CmsAliasTableRow(); 098 result.setKey(m_key); 099 result.setResourcePath(m_resourcePath); 100 result.setStructureId(m_structureId); 101 result.setChanged(m_isChanged); 102 result.setMode(m_mode); 103 result.setPathError(m_pathError); 104 result.setAliasError(m_aliasError); 105 result.setAliasPath(m_aliasPath); 106 result.setEdited(m_isEdited); 107 result.setOriginalStructureId(m_originalStructureId); 108 109 return result; 110 } 111 112 /** 113 * Changes the alias path.<p> 114 * 115 * @param newPath the new alias path 116 */ 117 public void editAliasPath(String newPath) { 118 119 m_aliasPath = newPath; 120 m_isChanged = true; 121 } 122 123 /** 124 * Changes the resource path.<p> 125 * 126 * @param newPath the new resource path 127 */ 128 public void editResourcePath(String newPath) { 129 130 m_resourcePath = newPath; 131 m_structureId = null; 132 m_isChanged = true; 133 } 134 135 /** 136 * @see java.lang.Object#equals(java.lang.Object) 137 */ 138 @Override 139 public boolean equals(Object other) { 140 141 return (other != null) 142 && (other instanceof CmsAliasTableRow) 143 && ((CmsAliasTableRow)other).getKey().equals(getKey()); 144 } 145 146 /** 147 * Gets the alias path error message.<p> 148 * 149 * @return the alias path error message 150 */ 151 public String getAliasError() { 152 153 return m_aliasError; 154 } 155 156 /** 157 * Gets the resource path error message.<p> 158 * 159 * @return the resource path error message 160 */ 161 public String getAliasPath() { 162 163 return m_aliasPath; 164 } 165 166 /** 167 * Gets the internal key for the row.<p> 168 * 169 * This key is artificially generated, it has no significance for the alias itself but is only used 170 * during editing to keep track of rows.<p> 171 * 172 * @return the internal key 173 */ 174 public String getKey() { 175 176 return m_key; 177 } 178 179 /** 180 * Gets the alias mode.<p> 181 * 182 * @return the alias mode 183 */ 184 public CmsAliasMode getMode() { 185 186 return m_mode; 187 } 188 189 /** 190 * Gets the original structure id.<p> 191 * 192 * @return the original structure id 193 */ 194 public CmsUUID getOriginalStructureId() { 195 196 return m_originalStructureId; 197 } 198 199 /** 200 * Gets the resource path error message.<p> 201 * 202 * @return the resource path error message 203 */ 204 public String getPathError() { 205 206 return m_pathError; 207 } 208 209 /** 210 * Gets the resource path.<p> 211 * 212 * @return the resource path 213 */ 214 public String getResourcePath() { 215 216 return m_resourcePath; 217 } 218 219 /** 220 * Gets the structure id.<p> 221 * 222 * @return the structure id 223 */ 224 public CmsUUID getStructureId() { 225 226 return m_structureId; 227 } 228 229 /** 230 * Checks whether any validation errors have been set.<p> 231 * 232 * @return true if any validation errors have been set 233 */ 234 public boolean hasErrors() { 235 236 return (m_pathError != null) || (m_aliasError != null); 237 } 238 239 /** 240 * @see java.lang.Object#hashCode() 241 */ 242 @Override 243 public int hashCode() { 244 245 return m_key.hashCode(); 246 } 247 248 /** 249 * Checks whether this row is changed.<p> 250 * 251 * @return true if this row is changed 252 */ 253 public boolean isChanged() { 254 255 return m_isChanged; 256 } 257 258 /** 259 * Checks whether this row is edited.<p> 260 * 261 * @return true if this row is edited 262 */ 263 public boolean isEdited() { 264 265 return m_isEdited; 266 } 267 268 /** 269 * Sets the alias error message.<p> 270 * 271 * @param aliasError the alias error message 272 */ 273 public void setAliasError(String aliasError) { 274 275 m_isChanged = true; 276 m_aliasError = aliasError; 277 } 278 279 /** 280 * Sets the alias path.<p> 281 * 282 * @param aliasPath the new alias path 283 */ 284 public void setAliasPath(String aliasPath) { 285 286 m_aliasPath = aliasPath; 287 } 288 289 /** 290 * Sets the 'changed' flag.<p> 291 * 292 * @param isChanged the new value of the 'changed' flag 293 */ 294 public void setChanged(boolean isChanged) { 295 296 m_isChanged = isChanged; 297 } 298 299 /** 300 * Sets the 'edited' flag.<p> 301 * 302 * @param isEdited the new value of the 'edited' flag 303 */ 304 public void setEdited(boolean isEdited) { 305 306 m_isEdited = isEdited; 307 } 308 309 /** 310 * Sets the internal key.<p> 311 * 312 * @param key the internal key 313 */ 314 public void setKey(String key) { 315 316 m_key = key; 317 } 318 319 /** 320 * Sets the alias mode.<p> 321 * 322 * @param mode the new alias mode 323 */ 324 public void setMode(CmsAliasMode mode) { 325 326 m_mode = mode; 327 } 328 329 /** 330 * Sets the original structure id.<p> 331 * 332 * @param originalStructureId the original structure id value 333 */ 334 public void setOriginalStructureId(CmsUUID originalStructureId) { 335 336 m_originalStructureId = originalStructureId; 337 } 338 339 /** 340 * Sets the resource path error message.<p> 341 * 342 * @param pathError the resource path error message 343 */ 344 public void setPathError(String pathError) { 345 346 m_isChanged = true; 347 m_pathError = pathError; 348 } 349 350 /** 351 * Sets the resource path.<p> 352 * 353 * @param resourcePath the resource path 354 */ 355 public void setResourcePath(String resourcePath) { 356 357 m_resourcePath = resourcePath; 358 } 359 360 /** 361 * Sets the structure id.<p> 362 * 363 * @param structureId the structure id 364 */ 365 public void setStructureId(CmsUUID structureId) { 366 367 m_structureId = structureId; 368 } 369 370 /** 371 * Updates this bean with data from another instance.<p> 372 * 373 * @param updateRow the bean which the data should be updated from 374 */ 375 public void update(CmsAliasTableRow updateRow) { 376 377 m_aliasError = updateRow.m_aliasError; 378 m_aliasPath = updateRow.m_aliasPath; 379 m_mode = updateRow.m_mode; 380 m_pathError = updateRow.m_pathError; 381 m_resourcePath = updateRow.m_resourcePath; 382 m_structureId = updateRow.m_structureId; 383 m_isEdited = updateRow.m_isEdited; 384 m_originalStructureId = updateRow.m_originalStructureId; 385 } 386 387}