Project

General

Profile

« Previous | Next » 

Revision 4321

Added by daigle almost 16 years ago

Fix bug where skin configs don't read backup properties correctly for checkboxes.

View differences:

lib/admin/skins-configuration.jsp
130 130
%>
131 131
				<div class="form-row"> 
132 132
					<img class="question-mark" src="style/images/question-mark.gif" 
133
						 alt="<%= metaDataProperty.getDescription() %>" 
134 133
						 onClick="helpWindow('<%= request.getContextPath() %>','<%= metaDataProperty.getHelpFile() %>')""/>
135 134
					<div class="textinput-label"><label for="<%= metaDataProperty.getKey() %>" title="<%= metaDataProperty.getDescription() %>"><%= metaDataProperty.getLabel() %></label>  		
136 135
					<select class="textinput" name="<%= skinName %>.<%= metaDataProperty.getKey() %>">
......
156 155
%>	
157 156
				<div class="form-row">
158 157
					<img class="question-mark" src="style/images/question-mark.gif" 
159
						 alt="<%= metaDataProperty.getDescription() %>" 
160 158
						 onClick="helpWindow('<%= request.getContextPath() %>','<%= metaDataProperty.getHelpFile() %>')"/>
161 159
					<div class="textinput-label"><label for="<%= metaDataProperty.getKey() %>" title="<%= metaDataProperty.getDescription() %>"><%= metaDataProperty.getLabel() %></label></div>
162 160
					<input class="textinput" id="<%= skinName %>.<%= metaDataProperty.getKey() %>" name="<%= skinName %>.<%= metaDataProperty.getKey() %>" 	             		    	    	           		    	             			
163
							type="<%= fieldType %>"
164
							alt="<%= metaDataProperty.getDescription() %>"/> 
161
							type="<%= fieldType %>"/> 
165 162
				</div>
166 163
<%
167 164
					if (metaDataProperty.getDescription() != null) {
......
177 174
						 onClick="helpWindow('<%= request.getContextPath() %>','<%= metaDataProperty.getHelpFile() %>')"/>
178 175
					<input class="checkradio" id="<%= skinName %>.<%= metaDataProperty.getKey() %>" name="<%= skinName %>.<%= metaDataProperty.getKey() %>" 	             		    	    	           		    	             			
179 176
						   type="<%= fieldType %>"
180
						   alt="<%= metaDataProperty.getDescription() %>"/> 
177
<%
178
					if (skinProperties.get(metaDataProperty.getKey()).equals("true")) {
179
%>
180
							checked="yes"
181
<%		
182
					}   
183
%>
184
						   /> 
181 185
					<label class="checkradio-label" for="<%= metaDataProperty.getKey() %>" title="<%= metaDataProperty.getDescription() %>"><%= metaDataProperty.getLabel() %></label>
182 186
				</div>
183 187
<%
......
190 194
%>
191 195
				<div class="form-row">
192 196
					<img class="question-mark" src="style/images/question-mark.gif" 
193
						 alt="<%= metaDataProperty.getDescription() %>"
194 197
						 onClick="helpWindow('<%= request.getContextPath() %>','<%= metaDataProperty.getHelpFile() %>')"/>
195 198
					<label class="textinput-label" for="<%= metaDataProperty.getKey() %>" title="<%= metaDataProperty.getDescription() %>"><%= metaDataProperty.getLabel() %></label>
196 199
					<input class="textinput" id="<%= skinName %>.<%= metaDataProperty.getKey() %>" name="<%= skinName %>.<%= metaDataProperty.getKey() %>" 
197 200
							value="<%= skinProperties.get(metaDataProperty.getKey()) %>"	             		    	    	           		    	             			
198
							type="<%= fieldType %>	"           			
199
							alt="<%= metaDataProperty.getDescription() %>"/>	
201
							type="<%= fieldType %>"/>	
200 202
				</div>  
201 203
<%
202 204
					if (metaDataProperty.getDescription() != null) {
src/edu/ucsb/nceas/metacat/service/SkinPropertyService.java
133 133
				skinMetaDataMap.put(skinName, skinMetaData);
134 134

  
135 135
				String backupPropertyFilePath = 
136
					BACKUP_DIR + FileUtil.getFS() + skinName + ".properties.metadata.xml";
136
					BACKUP_DIR + FileUtil.getFS() + skinName + ".properties.backup";
137 137
				SortedProperties skinBackupProperties = 
138 138
					new SortedProperties(backupPropertyFilePath);
139 139
				skinBackupProperties.load();
......
333 333
				+ skinName + FileUtil.getFS() + skinName + ".properties.metadata.xml";
334 334
		
335 335
		String backupPropertyFilePath = 
336
			BACKUP_DIR + FileUtil.getFS() + skinName + ".properties.metadata.xml";
336
			BACKUP_DIR + FileUtil.getFS() + skinName + ".properties.backup";
337 337

  
338 338
		// Use the metadata to extract configurable properties from the 
339 339
		// overall properties list, and store those properties.
......
403 403
	 */
404 404
	public static void checkAndSetProperty(HttpServletRequest request, String skinName, String propertyName) 
405 405
			throws GeneralPropertyException {
406
		String value = SkinPropertyService.getProperty(skinName, propertyName);
407 406
		String newValue = request.getParameter(skinName + "." + propertyName);
408
		if (newValue != null && !newValue.equals(value)) {
407
		checkAndSetProperty(newValue, skinName, propertyName); 
408
	}
409
	
410
	/**
411
	 * Check user input against existing value
412
	 * and update the metacat property file with that new value if it has
413
	 * changed from the value that was originally set.
414
	 * 
415
	 * @param newValue
416
	 *            the value that was returned by the form
417
	 * @param skinname
418
	 *            the skin that we are checking
419
	 * @param propertyName
420
	 *            the name of the property to be checked and set
421
	 */
422
	public static void checkAndSetProperty(String newValue, String skinName, String propertyName) 
423
			throws GeneralPropertyException {
424
		String oldValue = SkinPropertyService.getProperty(skinName, propertyName);
425
		if (newValue != null && !newValue.equals(oldValue)) {
409 426
			SkinPropertyService.setPropertyNoPersist(skinName, propertyName, newValue);
410 427
		}
411 428
	}
src/edu/ucsb/nceas/metacat/admin/SkinsAdmin.java
28 28

  
29 29
import java.io.IOException;
30 30
import java.util.HashMap;
31
import java.util.Set;
31 32
import java.util.Vector;
32 33

  
33 34
import javax.servlet.ServletException;
......
41 42
import edu.ucsb.nceas.metacat.util.RequestUtil;
42 43
import edu.ucsb.nceas.metacat.util.SkinUtil;
43 44
import edu.ucsb.nceas.utilities.FileUtil;
45
import edu.ucsb.nceas.utilities.MetaDataProperty;
44 46
import edu.ucsb.nceas.utilities.PropertiesMetaData;
45 47
import edu.ucsb.nceas.utilities.GeneralPropertyException;
46 48
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
......
170 172
				// For each skin property, check if it is changed and save it
171 173
				Vector<String> skinNames = SkinUtil.getSkinNames();
172 174
				for (String skinName : skinNames) {
173
					Vector<String> propertyNames = SkinPropertyService
174
							.getPropertyNames(skinName);
175
					for (String propertyName : propertyNames) {
176
						SkinPropertyService.checkAndSetProperty(request, skinName,
177
								propertyName);
175
					PropertiesMetaData skinMetaData = 
176
						SkinPropertyService.getMetaData(skinName);
177
					Set<String> metaDataKeySet = skinMetaData.getKeys();
178
					for (String metaDataKey : metaDataKeySet) {
179
						MetaDataProperty metaDataProperty = 
180
							skinMetaData.getProperties().get(metaDataKey);
181
						String fieldType = metaDataProperty.getFieldType();
182
						String newValue = request.getParameter(skinName + "." + metaDataKey);
183
						if (fieldType != null && fieldType.equals("checkbox")) {
184
							if (newValue != null && newValue.equals("on")) {
185
								SkinPropertyService.checkAndSetProperty("true", skinName, metaDataKey);
186
							} else {
187
								SkinPropertyService.checkAndSetProperty("false", skinName, metaDataKey);
188
							}								
189
						} else {		
190
							SkinPropertyService.checkAndSetProperty(request, skinName, metaDataKey);
191
						}
178 192
					}
179 193

  
180 194
					// we need to write the options from memory to the

Also available in: Unified diff