Source Code Cross Referenced for CmsContentCheckDialog.java in  » Content-Management-System » opencms » org » opencms » workplace » tools » content » check » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » opencms » org.opencms.workplace.tools.content.check 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/content/check/CmsContentCheckDialog.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:41 $
004:         * Version: $Revision: 1.5 $
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.content.check;
033:
034:        import org.opencms.jsp.CmsJspActionElement;
035:        import org.opencms.main.CmsIllegalArgumentException;
036:        import org.opencms.util.CmsStringUtil;
037:        import org.opencms.widgets.CmsCheckboxWidget;
038:        import org.opencms.widgets.CmsVfsFileWidget;
039:        import org.opencms.workplace.CmsDialog;
040:        import org.opencms.workplace.CmsWidgetDialog;
041:        import org.opencms.workplace.CmsWidgetDialogParameter;
042:        import org.opencms.workplace.CmsWorkplaceSettings;
043:        import org.opencms.workplace.tools.CmsToolDialog;
044:        import org.opencms.workplace.tools.database.CmsDatabaseExportReport;
045:
046:        import java.util.ArrayList;
047:        import java.util.HashMap;
048:        import java.util.Iterator;
049:        import java.util.List;
050:        import java.util.Map;
051:
052:        import javax.servlet.http.HttpServletRequest;
053:        import javax.servlet.http.HttpServletResponse;
054:        import javax.servlet.jsp.PageContext;
055:
056:        /**
057:         * Dialog for selecting the content checks.<p> 
058:         *
059:         * @author  Michael Emmerich
060:         * 
061:         * @version $Revision: 1.5 $ 
062:         * 
063:         * @since 6.1.2 
064:         */
065:        public class CmsContentCheckDialog extends CmsWidgetDialog {
066:
067:            /** The dialog type. */
068:            public static final String DIALOG_TYPE = "contentcheck";
069:
070:            /** Defines which pages are valid for this dialog. */
071:            public static final String[] PAGES = { "page1" };
072:
073:            /** The content check JSP report workplace URI. */
074:            protected static final String CONTENT_CHECK_REPORT = PATH_WORKPLACE
075:                    + "admin/contenttools/check/report.jsp";
076:
077:            /** The content check JSP result workplace URI. */
078:            protected static final String CONTENT_CHECK_RESULT = PATH_WORKPLACE
079:                    + "admin/contenttools/check/result.jsp";
080:
081:            /** The Content Check object. */
082:            private CmsContentCheck m_contentCheck;
083:
084:            /**
085:             * Public constructor with JSP action element.<p>
086:             * 
087:             * @param jsp an initialized JSP action element
088:             */
089:            public CmsContentCheckDialog(CmsJspActionElement jsp) {
090:
091:                super (jsp);
092:
093:            }
094:
095:            /**
096:             * Public constructor with JSP variables.<p>
097:             * 
098:             * @param context the JSP page context
099:             * @param req the JSP request
100:             * @param res the JSP response
101:             */
102:            public CmsContentCheckDialog(PageContext context,
103:                    HttpServletRequest req, HttpServletResponse res) {
104:
105:                this (new CmsJspActionElement(context, req, res));
106:            }
107:
108:            /**
109:             * @see org.opencms.workplace.CmsWidgetDialog#actionCommit()
110:             */
111:            public void actionCommit() {
112:
113:                List errors = new ArrayList();
114:                try {
115:                    // check if there are any vfs paths entered
116:                    List paths = m_contentCheck.getPaths();
117:                    if (paths.size() == 0) {
118:                        throw new CmsIllegalArgumentException(Messages.get()
119:                                .container(Messages.ERR_NO_VFSPATH_0));
120:                    } else {
121:                        Iterator i = paths.iterator();
122:                        while (i.hasNext()) {
123:                            String path = (String) i.next();
124:                            if (!getCms().existsResource(path)) {
125:                                throw new CmsIllegalArgumentException(Messages
126:                                        .get().container(
127:                                                Messages.ERR_NO_VFSPATH_0));
128:                            }
129:                        }
130:                    }
131:
132:                    // check if there is at least one test activated
133:                    boolean isActive = false;
134:                    List plugins = m_contentCheck.getPlugins();
135:                    Iterator i = plugins.iterator();
136:                    while (i.hasNext()) {
137:                        I_CmsContentCheck plugin = (I_CmsContentCheck) i.next();
138:                        if (plugin.isActive()) {
139:                            isActive = true;
140:                        }
141:                    }
142:                    if (!isActive) {
143:                        throw new CmsIllegalArgumentException(Messages.get()
144:                                .container(Messages.ERR_NO_TEST_0));
145:                    }
146:
147:                    // if there was no error, store the content check object in the session and forward it to the
148:                    // check thread
149:                    setDialogObject(m_contentCheck);
150:                    Map params = new HashMap();
151:                    // set the name of this class to get dialog object in report
152:                    params.put(CmsDatabaseExportReport.PARAM_CLASSNAME, this 
153:                            .getClass().getName());
154:                    // set style to display report in correct layout
155:                    params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
156:                    // set close link to get back to overview after finishing the import
157:                    params.put(PARAM_CLOSELINK, getJsp().link(
158:                            CONTENT_CHECK_RESULT));
159:                    //params.put(PARAM_CLOSELINK, CmsToolManager.linkForToolPath(getJsp(), "/contenttools"));
160:                    getToolManager().jspForwardPage(this , CONTENT_CHECK_REPORT,
161:                            params);
162:
163:                } catch (Throwable t) {
164:                    errors.add(t);
165:                }
166:                // set the list of errors to display when saving failed
167:                setCommitErrors(errors);
168:            }
169:
170:            /**
171:             * Creates the dialog HTML for all defined widgets of the named dialog (page).<p>  
172:             * 
173:             * @param dialog the dialog (page) to get the HTML for
174:             * @return the dialog HTML for all defined widgets of the named dialog (page)
175:             */
176:            protected String createDialogHtml(String dialog) {
177:
178:                StringBuffer result = new StringBuffer(1024);
179:
180:                // create table
181:                result.append(createWidgetTableStart());
182:
183:                // show error header once if there were validation errors
184:                result.append(createWidgetErrorHeader());
185:
186:                if (dialog.equals(PAGES[0])) {
187:                    result.append(dialogBlockStart(key("label.vfsresources")));
188:                    result.append(createWidgetTableStart());
189:                    result.append(createDialogRowsHtml(0, 0));
190:                    result.append(createWidgetTableEnd());
191:                    result.append(dialogBlockEnd());
192:                    result.append(dialogBlockStart(key("label.contentcheck")));
193:                    result.append(createWidgetTableStart());
194:                    result.append(createDialogRowsHtml(1, m_contentCheck
195:                            .getPluginsCount()));
196:                    result.append(createWidgetTableEnd());
197:                    result.append(dialogBlockEnd());
198:                }
199:
200:                // close table
201:                result.append(createWidgetTableEnd());
202:
203:                return result.toString();
204:            }
205:
206:            /**
207:             * @see org.opencms.workplace.CmsWidgetDialog#defineWidgets()
208:             */
209:            protected void defineWidgets() {
210:
211:                initContentCheck();
212:                addWidget(new CmsWidgetDialogParameter(m_contentCheck, "paths",
213:                        PAGES[0], new CmsVfsFileWidget()));
214:                // get a list of all plugins and build a widget for each plugin
215:                List plugins = m_contentCheck.getPlugins();
216:                for (int i = 0; i < plugins.size(); i++) {
217:                    I_CmsContentCheck plugin = (I_CmsContentCheck) plugins
218:                            .get(i);
219:                    addWidget(new CmsWidgetDialogParameter(plugin,
220:                            I_CmsContentCheck.PARAMETER, plugin
221:                                    .getDialogParameterName(), PAGES[0],
222:                            new CmsCheckboxWidget()));
223:                }
224:
225:            }
226:
227:            /**
228:             * @see org.opencms.workplace.CmsWidgetDialog#getPageArray()
229:             */
230:            protected String[] getPageArray() {
231:
232:                return new String[] { "page1" };
233:            }
234:
235:            /**
236:             * Initializes the content check object or takes an exiting one which is stored in the sesstion.<p>
237:             */
238:            protected void initContentCheck() {
239:
240:                Object o;
241:                if (CmsStringUtil.isEmpty(getParamAction())
242:                        || CmsDialog.DIALOG_INITIAL.equals(getParamAction())) {
243:                    // this is the initial dialog call
244:                    o = null;
245:                } else {
246:                    // this is not the initial call, get module from session
247:                    o = getDialogObject();
248:                }
249:
250:                if (!(o instanceof  CmsContentCheck)) {
251:                    // create a new content check object
252:                    m_contentCheck = new CmsContentCheck(getCms());
253:
254:                } else {
255:                    // reuse content check object stored in session
256:                    m_contentCheck = (CmsContentCheck) o;
257:                }
258:            }
259:
260:            /**
261:             * @see org.opencms.workplace.CmsWorkplace#initMessages()
262:             */
263:            protected void initMessages() {
264:
265:                // add specific dialog resource bundle
266:                addMessages(org.opencms.workplace.tools.content.Messages.get()
267:                        .getBundleName());
268:                addMessages("org.opencms.workplace.workplace");
269:                addMessages(Messages.get().getBundleName());
270:
271:                // now add the additional message bundles for each plugin
272:                CmsContentCheck dummy = new CmsContentCheck(getCms());
273:                List plugins = dummy.getPlugins();
274:                Iterator i = plugins.iterator();
275:                while (i.hasNext()) {
276:                    I_CmsContentCheck plugin = (I_CmsContentCheck) i.next();
277:                    List bundles = plugin.getMessageBundles();
278:                    Iterator j = bundles.iterator();
279:                    while (j.hasNext()) {
280:                        String bundle = (String) j.next();
281:                        addMessages(bundle);
282:                    }
283:                }
284:
285:                // add default resource bundles
286:                super .initMessages();
287:            }
288:
289:            /**
290:             * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
291:             */
292:            protected void initWorkplaceRequestValues(
293:                    CmsWorkplaceSettings settings, HttpServletRequest request) {
294:
295:                // set the dialog type
296:                setParamDialogtype(DIALOG_TYPE);
297:
298:                super .initWorkplaceRequestValues(settings, request);
299:
300:                // save the current state of the content check object (may be changed because of the widget values)
301:                setDialogObject(m_contentCheck);
302:            }
303:
304:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.