Source Code Cross Referenced for URLPortletCreator.java in  » Portal » stringbeans-3.5 » com » nabhinc » portlet » portletadmin » 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 » Portal » stringbeans 3.5 » com.nabhinc.portlet.portletadmin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * (C) Copyright 2000 - 2005 Nabh Information Systems, Inc. 
003:         * 
004:         * This program is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU General Public License 
006:         * as published by the Free Software Foundation; either version 2
007:         * of the License, or (at your option) any later version.
008:         * 
009:         * This program is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of 
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
012:         * GNU General Public License for more details.
013:         * 
014:         * You should have received a copy of the GNU General Public License
015:         * along with this program; if not, write to the Free Software 
016:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:         * 
018:         */
019:        package com.nabhinc.portlet.portletadmin;
020:
021:        import java.io.IOException;
022:        import java.util.HashMap;
023:        import java.util.Hashtable;
024:
025:        import javax.portlet.ActionRequest;
026:        import javax.portlet.ActionResponse;
027:        import javax.portlet.PortletException;
028:        import javax.servlet.http.HttpServletRequest;
029:        import javax.servlet.http.HttpServletResponse;
030:
031:        import com.nabhinc.core.MimeTypes;
032:        import com.nabhinc.portal.config.PortletType;
033:        import com.nabhinc.portal.container.PortletRequestImpl;
034:        import com.nabhinc.portal.container.PortletResponseImpl;
035:        import com.nabhinc.portal.core.PortalServlet;
036:        import com.nabhinc.portal.core.PortletConfigInfo;
037:        import com.nabhinc.portlet.base.BasePortlet;
038:        import com.nabhinc.portlet.mvcportlet.core.ActionConfig;
039:        import com.nabhinc.portlet.mvcportlet.core.ActionProcessor;
040:        import com.nabhinc.portlet.mvcportlet.core.BaseRequestProcessor;
041:        import com.nabhinc.portlet.url.URLPortlet;
042:        import com.nabhinc.util.StringUtil;
043:
044:        /**
045:         * 
046:         *
047:         * @author Padmanabh Dabke
048:         * (c) 2005 Nabh Information Systems, Inc. All Rights Reserved.
049:         * @since 2.4.1
050:         */
051:        public class URLPortletCreator extends BaseRequestProcessor implements 
052:                ActionProcessor {
053:
054:            /* (non-Javadoc)
055:             * @see com.nabhinc.portlet.mvcportlet.core.ActionProcessor#process(javax.portlet.ActionRequest, javax.portlet.ActionResponse, com.nabhinc.portlet.mvcportlet.core.ActionConfig)
056:             */
057:            public String process(ActionRequest request,
058:                    ActionResponse response, ActionConfig actionConfig)
059:                    throws PortletException, IOException {
060:
061:                boolean isEdit = "true".equals(request.getParameter("edit"));
062:                String portletIndex = request.getParameter("portlet_index");
063:                int pIndex = portletIndex == null ? -1 : Integer
064:                        .parseInt(portletIndex);
065:                String requestType = request.getParameter("request_type");
066:
067:                final String PORTLET_TYPE = "com.nabhinc.portlet.url.URLPortlet";
068:
069:                final String VIEW_MODE = "view";
070:                final String EDIT_MODE = "edit";
071:                final String HELP_MODE = "help";
072:                //HTML mime type is supported by default
073:                boolean isHTMLMimeTypeSupported = true; //rReq.getParameter("html_mime_type") != null;
074:                boolean isHTMLEditSupported = request
075:                        .getParameter("html_edit_mode") != null;
076:                boolean isHTMLHelpSupported = request
077:                        .getParameter("html_help_mode") != null;
078:                boolean isXHTMLMimeTypeSupported = false;
079:                boolean isWMLMimeTypeSupported = false;
080:
081:                String pName = request.getParameter("pname");
082:                String title = request.getParameter("title");
083:                String keywordsStr = request.getParameter("keywords");
084:                String shortTitle = request.getParameter("short_title");
085:                String expCache = request.getParameter("exp_cache");
086:                String resourceBundleName = request
087:                        .getParameter("resource_bundle");
088:                String supportedLocales = request
089:                        .getParameter("supported_locales");
090:
091:                String totalSecRoles = request.getParameter("sec_roles_total");
092:                String totalDescrLang = request
093:                        .getParameter("descr_lang_total");
094:                String totalDispLang = request
095:                        .getParameter("display_lang_total");
096:
097:                int numOfSecRoles = Integer.parseInt(totalSecRoles);
098:                int numOfDescrLangs = Integer.parseInt(totalDescrLang);
099:                int numOfDispLangs = Integer.parseInt(totalDispLang);
100:
101:                //String fileURL = request.getParameter("file_url");
102:                String htmlFileURL = request.getParameter("html_file_url");
103:                String xhtmlFileURL = request.getParameter("xhtml_file_url");
104:                String wmlFileURL = request.getParameter("wml_file_url");
105:
106:                String editPath = request.getParameter("edit_path");
107:                String helpPath = request.getParameter("help_path");
108:
109:                String error = "";
110:                if (pName == null || pName.trim().equals("")) {
111:                    error += "You must provide portlet name.<br/>";
112:                } else if (PortalServlet.getInstance().isPortletExists(pName)) {
113:                    if (!isEdit
114:                            || !pName.equals(((PortletConfigInfo) PortalServlet
115:                                    .getInstance().getPortletConfigInfoList()
116:                                    .elementAt(pIndex)).name)) {
117:                        error += "Duplicate portlet name.<br/>";
118:                    }
119:                }
120:                if (title == null || title.trim().equals("")) {
121:                    error += "You must provide portlet title.<br/>";
122:                }
123:                if (htmlFileURL == null || htmlFileURL.trim().equals("")) {
124:                    error += "You must provide URL for the file to be displayed.<br/>";
125:                } else if (htmlFileURL.indexOf("://") == -1) {
126:                    error += "File URL is not a valid URL. The URL should be in form of http:// or file://<br/>";
127:                }
128:                if (htmlFileURL == null || htmlFileURL.trim().equals("")) {
129:                    error += "You must provide URL for the file to be displayed.<br/>";
130:                } else if (htmlFileURL.indexOf("://") == -1) {
131:                    error += "Invalid file URL. The URL should be in the form of http:// or file://<br/>";
132:                }
133:                if (xhtmlFileURL != null && !"".equals(xhtmlFileURL.trim())
134:                        && xhtmlFileURL.indexOf("://") == -1) {
135:                    error += "Invalid XHTML document URL. The URL should be in the form of http:// or file://<br/>";
136:                }
137:                if (wmlFileURL != null && !"".equals(wmlFileURL.trim())
138:                        && wmlFileURL.indexOf("://") == -1) {
139:                    error += "Invalid WML document URL. The URL should be in the form of http:// or file://<br/>";
140:                }
141:                if (expCache != null && !expCache.trim().equals("")) {
142:                    try {
143:                        Integer.parseInt(expCache);
144:                    } catch (Exception ex) {
145:                        error += "Expiration cache must be a number.<br/>";
146:                    }
147:                }
148:
149:                if (!error.equals("")) {
150:                    response.setRenderParameter("error", error);
151:                    if (isEdit)
152:                        response.setRenderParameter("edit", "true");
153:                    return "failure";
154:                }
155:
156:                PortletType pType = PortletUtil.createPortletType(pName,
157:                        PORTLET_TYPE);
158:                PortletUtil.setTitle(title, pType);
159:                PortletUtil.setShortTitle(shortTitle, pType);
160:                PortletUtil.setResourceBundle(resourceBundleName, pType);
161:
162:                HashMap descrMap = new HashMap();
163:                for (int i = 0; i < numOfDescrLangs; i++) {
164:                    String lang = request.getParameter("descr_lang" + i);
165:                    String descr = request.getParameter("descr" + i);
166:                    if (descrMap.containsKey(lang))
167:                        continue;
168:                    descrMap.put(lang, descr);
169:                }
170:                PortletUtil.setDescription(descrMap, pType);
171:
172:                HashMap displayMap = new HashMap();
173:                for (int i = 0; i < numOfDispLangs; i++) {
174:                    String lang = request.getParameter("display_lang" + i);
175:                    String displayName = request.getParameter("display_name"
176:                            + i);
177:                    if (displayMap.containsKey(lang))
178:                        continue;
179:                    displayMap.put(lang, displayName);
180:                }
181:                PortletUtil.setDisplayName(displayMap, pType);
182:
183:                if (expCache != null && !expCache.trim().equals(""))
184:                    PortletUtil.setExpirationCache(Integer.parseInt(expCache),
185:                            pType);
186:
187:                Hashtable initParams = new Hashtable();
188:
189:                initParams.put(URLPortlet.HTML_URL, htmlFileURL);
190:
191:                if (xhtmlFileURL != null && !xhtmlFileURL.trim().equals("")) {
192:                    initParams.put(URLPortlet.XHTML_URL, xhtmlFileURL);
193:                    isXHTMLMimeTypeSupported = true;
194:                }
195:
196:                if (wmlFileURL != null && !wmlFileURL.trim().equals("")) {
197:                    initParams.put(URLPortlet.WML_URL, wmlFileURL);
198:                    isWMLMimeTypeSupported = true;
199:                }
200:
201:                if (editPath != null && !editPath.trim().equals("")) {
202:                    if (editPath.indexOf("://") == -1
203:                            && !editPath.startsWith("/")) {
204:                        editPath = "/" + editPath;
205:                    }
206:                    initParams.put(BasePortlet.EDIT_JSP_PARAM, editPath);
207:                    isHTMLEditSupported = true;
208:                }
209:
210:                if (helpPath != null && !helpPath.trim().equals("")) {
211:                    if (helpPath.indexOf("://") == -1
212:                            && !helpPath.startsWith("/")) {
213:                        helpPath = "/" + helpPath;
214:                    }
215:                    initParams.put(BasePortlet.HELP_JSP_PARAM, helpPath);
216:                    isHTMLHelpSupported = true;
217:                }
218:
219:                PortletUtil.setInitParams(initParams, pType);
220:
221:                PortletUtil.setKeywords(keywordsStr, pType);
222:
223:                if (isHTMLMimeTypeSupported) {
224:                    String[] supportedModes = null;
225:                    if (isHTMLEditSupported && isHTMLHelpSupported) {
226:                        supportedModes = new String[] { EDIT_MODE, HELP_MODE };
227:
228:                    } else if (isHTMLEditSupported) {
229:                        supportedModes = new String[] { EDIT_MODE };
230:
231:                    } else if (isHTMLHelpSupported) {
232:                        supportedModes = new String[] { HELP_MODE };
233:                    }
234:
235:                    PortletUtil.setSupports(supportedModes, MimeTypes.HTML,
236:                            pType);
237:                }
238:
239:                if (isXHTMLMimeTypeSupported) {
240:                    String[] supportedModes = null;
241:                    PortletUtil.setSupports(supportedModes, MimeTypes.XHTML_MP,
242:                            pType);
243:                }
244:
245:                if (isWMLMimeTypeSupported) {
246:                    String[] supportedModes = null;
247:                    PortletUtil.setSupports(supportedModes, MimeTypes.WML,
248:                            pType);
249:                }
250:
251:                if (supportedLocales != null
252:                        && !"".equals(supportedLocales.trim())) {
253:                    String[] locales = StringUtil.split(supportedLocales, ",");
254:                    PortletUtil.setSupportedLocales(locales, pType);
255:                }
256:
257:                HashMap secRoleMap = new HashMap();
258:                for (int i = 0; i < numOfSecRoles; i++) {
259:                    String roleName = request.getParameter("role_name" + i);
260:                    if (roleName != null && !"".equals(roleName.trim())) {
261:                        secRoleMap.put(roleName, request
262:                                .getParameter("role_link" + i));
263:                    }
264:                }
265:                PortletUtil.setSecurityRoleReference(secRoleMap, pType);
266:
267:                try {
268:                    if (isEdit) {
269:                        HttpServletRequest req = ((PortletRequestImpl) request)
270:                                .getHttpServletRequest();
271:                        HttpServletResponse res = ((PortletResponseImpl) response)
272:                                .getHttpServletResponse();
273:                        PortalServlet.getInstance().replacePortlet(pType,
274:                                pIndex, req, res);
275:                    } else {
276:                        PortalServlet.getInstance().addPortlet(pType);
277:                    }
278:                    PortalServlet.getInstance().savePortletConfiguration();
279:                } catch (Exception ex) {
280:                    throw new PortletException("Failed to create URL portlet.",
281:                            ex);
282:                }
283:
284:                return "success";
285:            }
286:
287:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.