Source Code Cross Referenced for CmsXmlContentRepairDialog.java in  » Content-Management-System » opencms » org » opencms » workplace » tools » content » 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 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/content/CmsXmlContentRepairDialog.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:36 $
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;
033:
034:        import org.opencms.file.types.CmsResourceTypeXmlContent;
035:        import org.opencms.file.types.I_CmsResourceType;
036:        import org.opencms.jsp.CmsJspActionElement;
037:        import org.opencms.main.CmsIllegalArgumentException;
038:        import org.opencms.main.OpenCms;
039:        import org.opencms.util.CmsStringUtil;
040:        import org.opencms.widgets.CmsCheckboxWidget;
041:        import org.opencms.widgets.CmsSelectWidget;
042:        import org.opencms.widgets.CmsSelectWidgetOption;
043:        import org.opencms.widgets.CmsVfsFileWidget;
044:        import org.opencms.workplace.CmsWidgetDialog;
045:        import org.opencms.workplace.CmsWidgetDialogParameter;
046:        import org.opencms.workplace.CmsWorkplaceSettings;
047:        import org.opencms.workplace.threads.CmsXmlContentRepairSettings;
048:        import org.opencms.workplace.tools.CmsToolDialog;
049:        import org.opencms.workplace.tools.CmsToolManager;
050:
051:        import java.io.IOException;
052:        import java.util.ArrayList;
053:        import java.util.Collections;
054:        import java.util.HashMap;
055:        import java.util.Iterator;
056:        import java.util.List;
057:        import java.util.Map;
058:
059:        import javax.servlet.ServletException;
060:        import javax.servlet.http.HttpServletRequest;
061:        import javax.servlet.http.HttpServletResponse;
062:        import javax.servlet.jsp.PageContext;
063:
064:        /**
065:         * Widget dialog that sets the settings to repair XML contents where the XSD was changed below a given VFS folder.<p>
066:         * 
067:         * @author Andreas Zahner
068:         * 
069:         * @version $Revision: 1.5 $
070:         * 
071:         * @since 6.2.0
072:         */
073:        public class CmsXmlContentRepairDialog extends CmsWidgetDialog {
074:
075:            /** Localized message keys prefix. */
076:            public static final String KEY_PREFIX = "xmlcontentrepair";
077:
078:            /** Defines which pages are valid for this dialog. */
079:            public static final String[] PAGES = { "page1" };
080:
081:            /** The name of the generic xmlcontent resource type. */
082:            protected static final String TYPE_XMLCONTENT = "xmlcontent";
083:
084:            /** The repair JSP report workplace URI. */
085:            protected static final String XMLCONTENTREPAIR_ACTION_REPORT = PATH_WORKPLACE
086:                    + "admin/contenttools/reports/xmlcontentrepair.jsp";
087:
088:            /** The settings object that is edited on this dialog. */
089:            private CmsXmlContentRepairSettings m_settings;
090:
091:            /**
092:             * Public constructor with JSP action element.
093:             * <p>
094:             * 
095:             * @param jsp an initialized JSP action element
096:             */
097:            public CmsXmlContentRepairDialog(CmsJspActionElement jsp) {
098:
099:                super (jsp);
100:            }
101:
102:            /**
103:             * Public constructor with JSP variables.
104:             * <p>
105:             * 
106:             * @param context the JSP page context
107:             * @param req the JSP request
108:             * @param res the JSP response
109:             */
110:            public CmsXmlContentRepairDialog(PageContext context,
111:                    HttpServletRequest req, HttpServletResponse res) {
112:
113:                this (new CmsJspActionElement(context, req, res));
114:            }
115:
116:            /**
117:             * @see org.opencms.workplace.CmsWidgetDialog#actionCommit()
118:             */
119:            public void actionCommit() throws IOException, ServletException {
120:
121:                List errors = new ArrayList();
122:                setDialogObject(m_settings);
123:
124:                try {
125:                    Map params = new HashMap();
126:                    // set style to display report in correct layout
127:                    params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
128:                    // set close link to get back to overview after finishing the import
129:                    params.put(PARAM_CLOSELINK, CmsToolManager.linkForToolPath(
130:                            getJsp(), "/contenttools"));
131:                    // redirect to the report output JSP
132:                    getToolManager().jspForwardPage(this ,
133:                            XMLCONTENTREPAIR_ACTION_REPORT, params);
134:                } catch (CmsIllegalArgumentException e) {
135:                    errors.add(e);
136:                }
137:                // set the list of errors to display when saving failed
138:                setCommitErrors(errors);
139:            }
140:
141:            /**
142:             * @see org.opencms.workplace.CmsWidgetDialog#createDialogHtml(java.lang.String)
143:             */
144:            protected String createDialogHtml(String dialog) {
145:
146:                StringBuffer result = new StringBuffer(2048);
147:
148:                // create table
149:                result.append(createWidgetTableStart());
150:
151:                // show error header once if there were validation errors
152:                result.append(createWidgetErrorHeader());
153:
154:                // create export file name block
155:                result
156:                        .append(createWidgetBlockStart(Messages
157:                                .get()
158:                                .getBundle(getLocale())
159:                                .key(
160:                                        Messages.GUI_XMLCONTENTREPAIR_DIALOG_BLOCK_SETTINGS_0)));
161:                result.append(createDialogRowsHtml(0, 3));
162:                result.append(createWidgetBlockEnd());
163:
164:                // close table
165:                result.append(createWidgetTableEnd());
166:
167:                return result.toString();
168:            }
169:
170:            /**
171:             * @see org.opencms.workplace.CmsWidgetDialog#defineWidgets()
172:             */
173:            protected void defineWidgets() {
174:
175:                // initialize the settings object to use for the dialog
176:                initSettingsObject();
177:
178:                // set localized key prefix
179:                setKeyPrefix(KEY_PREFIX);
180:                // add the widgets to show
181:                addWidget(new CmsWidgetDialogParameter(m_settings, "vfsFolder",
182:                        "/", PAGES[0], new CmsVfsFileWidget(false, getCms()
183:                                .getRequestContext().getSiteRoot()), 1, 1));
184:
185:                addWidget(new CmsWidgetDialogParameter(m_settings,
186:                        "includeSubFolders", PAGES[0],
187:                        new CmsCheckboxWidget("")));
188:
189:                addWidget(new CmsWidgetDialogParameter(m_settings, "force",
190:                        PAGES[0], new CmsCheckboxWidget("")));
191:
192:                addWidget(new CmsWidgetDialogParameter(m_settings,
193:                        "resourceType", PAGES[0], new CmsSelectWidget(
194:                                getXmlContentResourceTypes())));
195:            }
196:
197:            /**
198:             * @see org.opencms.workplace.CmsWidgetDialog#getPageArray()
199:             */
200:            protected String[] getPageArray() {
201:
202:                return PAGES;
203:            }
204:
205:            /**
206:             * @see org.opencms.workplace.CmsWorkplace#initMessages()
207:             */
208:            protected void initMessages() {
209:
210:                // add specific dialog resource bundle
211:                addMessages(Messages.get().getBundleName());
212:                // add default resource bundles
213:                super .initMessages();
214:            }
215:
216:            /**
217:             * Initializes the settings object to work with depending on the dialog state and request parameters.<p>
218:             */
219:            protected void initSettingsObject() {
220:
221:                Object o;
222:                if (CmsStringUtil.isEmpty(getParamAction())) {
223:                    o = new CmsXmlContentRepairSettings(getCms());
224:                } else {
225:                    // this is not the initial call, get the settings object from session
226:                    o = getDialogObject();
227:                }
228:
229:                if (o == null) {
230:                    // create a new settings object
231:                    m_settings = new CmsXmlContentRepairSettings(getCms());
232:                } else {
233:                    // reuse settings object stored in session
234:                    m_settings = (CmsXmlContentRepairSettings) o;
235:                }
236:
237:            }
238:
239:            /**
240:             * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings,
241:             *      javax.servlet.http.HttpServletRequest)
242:             */
243:            protected void initWorkplaceRequestValues(
244:                    CmsWorkplaceSettings settings, HttpServletRequest request) {
245:
246:                // initialize parameters and dialog actions in super implementation
247:                super .initWorkplaceRequestValues(settings, request);
248:
249:                // save the current state of the settings (may be changed because of the widget values)
250:                setDialogObject(m_settings);
251:            }
252:
253:            /**
254:             * Returns the selector widget options to build a XML content resource type selector widget.<p>
255:             * 
256:             * @return the selector widget options to build a XML content resource type selector widget
257:             */
258:            private List getXmlContentResourceTypes() {
259:
260:                // get all available resource types and filter XML content resource types
261:                List resTypes = OpenCms.getResourceManager().getResourceTypes();
262:                Iterator i = resTypes.iterator();
263:                List resTypeNames = new ArrayList(resTypes.size());
264:                while (i.hasNext()) {
265:                    I_CmsResourceType resType = (I_CmsResourceType) i.next();
266:                    if (!(resType instanceof  CmsResourceTypeXmlContent)) {
267:                        // this is not XML content resource type, skip it
268:                        continue;
269:                    }
270:                    if (!resType.getTypeName().equals(TYPE_XMLCONTENT)) {
271:                        resTypeNames.add(resType.getTypeName());
272:                    }
273:                }
274:
275:                // create the selector options
276:                List result = new ArrayList(resTypeNames.size() + 2);
277:                // add empty "please select" option to selector
278:                result
279:                        .add(new CmsSelectWidgetOption(
280:                                "",
281:                                true,
282:                                key(Messages.GUI_XMLCONTENTREPAIR_DIALOG_RESTYPE_SELECT_0)));
283:
284:                // sort the resource type names alphabetically
285:                Collections.sort(resTypeNames);
286:                i = resTypeNames.iterator();
287:                while (i.hasNext()) {
288:                    // add all resource type names to the selector
289:                    String resTypeName = (String) i.next();
290:                    result.add(new CmsSelectWidgetOption(resTypeName));
291:                }
292:
293:                // add option for generic XML content without "own" resource types at the end
294:                result
295:                        .add(new CmsSelectWidgetOption(
296:                                TYPE_XMLCONTENT,
297:                                false,
298:                                key(Messages.GUI_XMLCONTENTREPAIR_DIALOG_RESTYPE_GENERIC_0)));
299:
300:                return result;
301:            }
302:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.