001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/database/CmsRemovePubLocksDialog.java,v $
003: * Date : $Date: 2008-02-27 12:05:51 $
004: * Version: $Revision: 1.2 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.workplace.tools.database;
033:
034: import org.opencms.jsp.CmsJspActionElement;
035: import org.opencms.util.CmsStringUtil;
036: import org.opencms.widgets.CmsDisplayWidget;
037: import org.opencms.widgets.CmsVfsFileWidget;
038: import org.opencms.workplace.CmsDialog;
039: import org.opencms.workplace.CmsWidgetDialog;
040: import org.opencms.workplace.CmsWidgetDialogParameter;
041: import org.opencms.workplace.CmsWorkplaceSettings;
042: import org.opencms.workplace.tools.CmsToolDialog;
043:
044: import java.util.ArrayList;
045: import java.util.HashMap;
046: import java.util.List;
047: import java.util.Map;
048:
049: import javax.servlet.http.HttpServletRequest;
050: import javax.servlet.http.HttpServletResponse;
051: import javax.servlet.jsp.PageContext;
052:
053: /**
054: * Dialog to remove old publish locks.<p>
055: *
056: * @author Michael Moossen
057: *
058: * @version $Revision: 1.2 $
059: *
060: * @since 7.0.2
061: */
062: public class CmsRemovePubLocksDialog extends CmsWidgetDialog {
063:
064: /** The dialog type. */
065: public static final String DIALOG_TYPE = "dbpublocks";
066:
067: /** Defines which pages are valid for this dialog. */
068: public static final String[] PAGES = { "page1" };
069:
070: /** The notice text. */
071: private String m_notice;
072:
073: /** the resources to unlock. */
074: private List m_resources;
075:
076: /**
077: * Public constructor with JSP action element.<p>
078: *
079: * @param jsp an initialized JSP action element
080: */
081: public CmsRemovePubLocksDialog(CmsJspActionElement jsp) {
082:
083: super (jsp);
084: }
085:
086: /**
087: * Public constructor with JSP variables.<p>
088: *
089: * @param context the JSP page context
090: * @param req the JSP request
091: * @param res the JSP response
092: */
093: public CmsRemovePubLocksDialog(PageContext context,
094: HttpServletRequest req, HttpServletResponse res) {
095:
096: this (new CmsJspActionElement(context, req, res));
097: }
098:
099: /**
100: * @see org.opencms.workplace.tools.modules.CmsModulesEditBase#actionCommit()
101: */
102: public void actionCommit() {
103:
104: try {
105: // forward to the report page
106: Map params = new HashMap();
107: params.put(CmsRemovePubLocksReport.PARAM_RESOURCES,
108: CmsStringUtil.collectionAsString(m_resources, ","));
109: params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
110: getToolManager()
111: .jspForwardPage(
112: this ,
113: "/system/workplace/admin/database/publishlocksreport.jsp",
114: params);
115: } catch (Exception e) {
116: addCommitError(e);
117: }
118: }
119:
120: /**
121: * Returns the notice text.<p>
122: *
123: * @return the notice text
124: */
125: public String getNotice() {
126:
127: if (m_notice == null) {
128: m_notice = key(Messages.GUI_DB_PUBLOCKS_NOTICE_0);
129: }
130: return m_notice;
131: }
132:
133: /**
134: * Returns the resources.<p>
135: *
136: * @return the resources
137: */
138: public List getResources() {
139:
140: return m_resources;
141: }
142:
143: /**
144: * Sets the notice text.<p>
145: *
146: * @param notice the notice text to set
147: */
148: public void setNotice(String notice) {
149:
150: m_notice = notice;
151: }
152:
153: /**
154: * Sets the resources.<p>
155: *
156: * @param resources the resources to set
157: */
158: public void setResources(List resources) {
159:
160: m_resources = resources;
161: }
162:
163: /**
164: * Creates the dialog HTML for all defined widgets of the named dialog (page).<p>
165: *
166: * @param dialog the dialog (page) to get the HTML for
167: * @return the dialog HTML for all defined widgets of the named dialog (page)
168: */
169: protected String createDialogHtml(String dialog) {
170:
171: StringBuffer result = new StringBuffer(1024);
172:
173: // create table
174: result.append(createWidgetTableStart());
175:
176: // show error header once if there were validation errors
177: result.append(createWidgetErrorHeader());
178:
179: if (dialog.equals(PAGES[0])) {
180: result.append(dialogBlockStart(null));
181: result.append(createWidgetTableStart());
182: result.append(createDialogRowsHtml(0, 1));
183: result.append(createWidgetTableEnd());
184: result.append(dialogBlockEnd());
185: }
186: // close table
187: result.append(createWidgetTableEnd());
188:
189: return result.toString();
190: }
191:
192: /**
193: * Creates the list of widgets for this dialog.<p>
194: */
195: protected void defineWidgets() {
196:
197: initObject();
198: addWidget(new CmsWidgetDialogParameter(this , "notice",
199: PAGES[0], new CmsDisplayWidget()));
200: addWidget(new CmsWidgetDialogParameter(this , "resources",
201: PAGES[0], new CmsVfsFileWidget()));
202: }
203:
204: /**
205: * @see org.opencms.workplace.CmsWidgetDialog#getPageArray()
206: */
207: protected String[] getPageArray() {
208:
209: return PAGES;
210: }
211:
212: /**
213: * Initializes the session object.<p>
214: */
215: protected void initObject() {
216:
217: Object o;
218:
219: if (CmsStringUtil.isEmpty(getParamAction())
220: || CmsDialog.DIALOG_INITIAL.equals(getParamAction())) {
221: // this is the initial dialog call
222: o = new ArrayList();
223: ((List) o).add("/");
224: } else {
225: // this is not the initial call, get module from session
226: o = getDialogObject();
227: }
228:
229: if (!(o instanceof List)) {
230: m_resources = new ArrayList();
231: m_resources.add("/");
232: } else {
233: // reuse object stored in session
234: m_resources = (List) o;
235: }
236: }
237:
238: /**
239: * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
240: */
241: protected void initWorkplaceRequestValues(
242: CmsWorkplaceSettings settings, HttpServletRequest request) {
243:
244: // set the dialog type
245: setParamDialogtype(DIALOG_TYPE);
246:
247: super .initWorkplaceRequestValues(settings, request);
248:
249: // save the current state of the module (may be changed because of the widget values)
250: setDialogObject(m_resources);
251: }
252: }
|