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.config.DataConfig;
13: import org.vfny.geoserver.config.DataStoreConfig;
14: import org.vfny.geoserver.form.data.DataDataStoresSelectForm;
15: import org.vfny.geoserver.global.UserContainer;
16: import java.io.IOException;
17: import java.util.Locale;
18: import javax.servlet.ServletException;
19: import javax.servlet.http.HttpServletRequest;
20: import javax.servlet.http.HttpServletResponse;
21:
22: /**
23: * Select a DataStore for editing.
24: *
25: * @author User, Refractions Research, Inc.
26: * @author $Author: dmzwiers $ (last modification)
27: * @version $Id: DataDataStoresSelectAction.java 6326 2007-03-15 18:36:40Z jdeolive $
28: */
29: public class DataDataStoresSelectAction extends ConfigAction {
30: public ActionForward execute(ActionMapping mapping,
31: ActionForm incomingForm, UserContainer user,
32: HttpServletRequest request, HttpServletResponse response)
33: throws IOException, ServletException {
34: DataDataStoresSelectForm form = (DataDataStoresSelectForm) incomingForm;
35:
36: String buttonAction = form.getButtonAction();
37:
38: DataConfig dataConfig = (DataConfig) getDataConfig();
39: DataStoreConfig dsConfig = null;
40:
41: Locale locale = (Locale) request.getLocale();
42:
43: //MessageResources messages = servlet.getResources();
44: MessageResources messages = getResources(request);
45:
46: String editLabel = messages.getMessage(locale, "label.edit");
47: String deleteLabel = messages
48: .getMessage(locale, "label.delete");
49:
50: if (editLabel.equals(buttonAction)) {
51: dsConfig = (DataStoreConfig) dataConfig.getDataStore(form
52: .getSelectedDataStoreId());
53:
54: getUserContainer(request).setDataStoreConfig(dsConfig);
55:
56: return mapping.findForward("config.data.store.editor");
57: } else if (deleteLabel.equals(buttonAction)) {
58: dataConfig.removeDataStore(form.getSelectedDataStoreId());
59: getUserContainer(request).setDataStoreConfig(null);
60:
61: form.reset(mapping, request);
62:
63: return mapping.findForward("config.data.store");
64: }
65:
66: throw new ServletException("Action '" + buttonAction
67: + "'must be '" + editLabel + "' or '" + deleteLabel
68: + "'");
69: }
70: }
|