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, 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.ade.contenteditor.shared; 029 030import org.opencms.acacia.shared.CmsValidationResult; 031import org.opencms.util.CmsPair; 032 033import java.util.List; 034import java.util.Map; 035 036import com.google.gwt.user.client.rpc.IsSerializable; 037 038/** 039 * Stores the editor save result information.<p> 040 */ 041public class CmsSaveResult implements IsSerializable { 042 043 /** If container element settings where changed. */ 044 private boolean m_hasChangedSettings; 045 046 /** If validation warnings caused a save error. */ 047 private boolean m_warningsAsError; 048 049 /** The validation result. */ 050 private CmsValidationResult m_validationResult; 051 052 /** 053 * Map from locale to issues with information to display in the validation result dialog. 054 * It contains already the information to display, localized wrt the workplace locale 055 * and in the correct order. 056 * 057 * The structure is: 058 * { "locale" : 059 * [ 060 * { 061 * first: [ { first: "elementName", second: "elementIdx" } ], 062 * second: "localized error message" 063 * } 064 * ] 065 * 066 */ 067 private Map<String, List<CmsPair<List<CmsPair<String, Integer>>, String>>> m_validationIssueInformation; 068 069 /** 070 * Constructor.<p> 071 * 072 * @param hasChangedSettings if container element settings where changed 073 * @param validationResult the validation result 074 * @param warningsAsError flag, indicating if warnings should be treated as errors 075 * @param issuesToDisplay the issues (warnings or errors) to display, already localized and sorted as needed. 076 */ 077 public CmsSaveResult( 078 boolean hasChangedSettings, 079 CmsValidationResult validationResult, 080 boolean warningsAsError, 081 Map<String, List<CmsPair<List<CmsPair<String, Integer>>, String>>> issuesToDisplay) { 082 083 m_hasChangedSettings = hasChangedSettings; 084 m_validationResult = validationResult; 085 m_warningsAsError = warningsAsError; 086 m_validationIssueInformation = issuesToDisplay; 087 } 088 089 /** 090 * Constructor for serialization only.<p> 091 */ 092 protected CmsSaveResult() { 093 094 } 095 096 /** 097 * Returns the validation issue information to display. 098 * @return the validation issue information to display. 099 */ 100 public Map<String, List<CmsPair<List<CmsPair<String, Integer>>, String>>> getIssueInformation() { 101 102 return m_validationIssueInformation; 103 } 104 105 /** 106 * Returns the validation result.<p> 107 * 108 * @return the validation result 109 */ 110 public CmsValidationResult getValidationResult() { 111 112 return m_validationResult; 113 } 114 115 /** 116 * Returns whether the validation result has errors.<p> 117 * 118 * @return <code>true</code> in case the validation result has errors 119 */ 120 public boolean hasErrors() { 121 122 return (m_validationResult != null) 123 && (m_validationResult.hasErrors() || (m_warningsAsError && m_validationResult.hasWarnings())); 124 } 125 126 /** 127 * Returns whether container element settings where changed.<p> 128 * 129 * @return <ode>true</code> in case container element settings where changed 130 */ 131 public boolean isHasChangedSettings() { 132 133 return m_hasChangedSettings; 134 } 135}