01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.vfny.geoserver.action.data;
06:
07: import org.apache.struts.action.ActionForm;
08: import org.apache.struts.action.ActionForward;
09: import org.apache.struts.action.ActionMapping;
10: import org.apache.struts.util.MessageResources;
11: import org.vfny.geoserver.action.ConfigAction;
12: import org.vfny.geoserver.action.HTMLEncoder;
13: import org.vfny.geoserver.config.CoverageStoreConfig;
14: import org.vfny.geoserver.config.DataConfig;
15: import org.vfny.geoserver.form.data.CoverageStoresSelectForm;
16: import org.vfny.geoserver.global.UserContainer;
17: import java.io.IOException;
18: import java.util.Locale;
19: import javax.servlet.ServletException;
20: import javax.servlet.http.HttpServletRequest;
21: import javax.servlet.http.HttpServletResponse;
22:
23: /**
24: * Select a Format for editing.
25: *
26: * @author User, Refractions Research, Inc.
27: * @author dmzwiers
28: * @author $Author: Alessio Fabiani (alessio.fabiani@gmail.com) $ (last
29: * modification)
30: * @author $Author: Simone Giannecchini (simboss1@gmail.com) $ (last
31: * modification)
32: * @version $Id: CoverageStoresSelectAction.java,v 1.12 2004/02/25 21:51:11
33: * dmzwiers Exp $
34: */
35: public final class CoverageStoresSelectAction extends ConfigAction {
36: public ActionForward execute(ActionMapping mapping,
37: ActionForm incomingForm, UserContainer user,
38: HttpServletRequest request, HttpServletResponse response)
39: throws IOException, ServletException {
40: CoverageStoresSelectForm form = (CoverageStoresSelectForm) incomingForm;
41: String buttonAction = form.getButtonAction();
42:
43: DataConfig dataConfig = (DataConfig) getDataConfig();
44: CoverageStoreConfig dfConfig = null;
45: Locale locale = (Locale) request.getLocale();
46: MessageResources messages = getResources(request);
47:
48: String editLabel = HTMLEncoder.decode(messages.getMessage(
49: locale, "label.edit"));
50: String deleteLabel = HTMLEncoder.decode(messages.getMessage(
51: locale, "label.delete"));
52:
53: if (editLabel.equals(buttonAction)) {
54: dfConfig = (CoverageStoreConfig) dataConfig
55: .getDataFormat(form.getSelectedDataFormatId());
56:
57: getUserContainer(request).setDataFormatConfig(dfConfig);
58:
59: return mapping.findForward("config.data.format.editor");
60: } else if (deleteLabel.equals(buttonAction)) {
61: dataConfig.removeDataFormat(form.getSelectedDataFormatId());
62: getUserContainer(request).setDataFormatConfig(null);
63:
64: form.reset(mapping, request);
65:
66: return mapping.findForward("config.data.format");
67: }
68:
69: throw new ServletException(new StringBuffer("Action '").append(
70: buttonAction).append("'must be '").append(editLabel)
71: .append("' or '").append(deleteLabel).append("'")
72: .toString());
73: }
74: }
|