Source Code Cross Referenced for RSSPortletCreator.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:
020:        package com.nabhinc.portlet.portletadmin;
021:
022:        import java.io.IOException;
023:        import java.util.ArrayList;
024:        import java.util.HashMap;
025:        import java.util.Hashtable;
026:
027:        import javax.portlet.ActionRequest;
028:        import javax.portlet.ActionResponse;
029:        import javax.portlet.PortletException;
030:        import javax.servlet.http.HttpServletRequest;
031:        import javax.servlet.http.HttpServletResponse;
032:
033:        import com.nabhinc.core.MimeTypes;
034:        import com.nabhinc.portal.config.PortletType;
035:        import com.nabhinc.portal.container.PortletRequestImpl;
036:        import com.nabhinc.portal.container.PortletResponseImpl;
037:        import com.nabhinc.portal.core.PortalServlet;
038:        import com.nabhinc.portal.core.PortletConfigInfo;
039:        import com.nabhinc.portlet.base.BasePortlet;
040:        import com.nabhinc.portlet.mvcportlet.core.ActionConfig;
041:        import com.nabhinc.portlet.mvcportlet.core.ActionProcessor;
042:        import com.nabhinc.portlet.mvcportlet.core.BaseRequestProcessor;
043:        import com.nabhinc.portlet.rss.RSSPortlet;
044:        import com.nabhinc.util.StringUtil;
045:
046:        /**
047:         * 
048:         *
049:         * @author Padmanabh Dabke
050:         * (c) 2005 Nabh Information Systems, Inc. All Rights Reserved.
051:         * @since 2.4.1
052:         */
053:        public class RSSPortletCreator extends BaseRequestProcessor implements 
054:                ActionProcessor {
055:
056:            /* 
057:             * Loads or reloads a portlet
058:             */
059:            public String process(ActionRequest request,
060:                    ActionResponse response, ActionConfig actionConfig)
061:                    throws PortletException, IOException {
062:
063:                final String PORTLET_TYPE = "com.nabhinc.portlet.rss.RSSPortlet";
064:
065:                final String VIEW_MODE = "view";
066:                final String EDIT_MODE = "edit";
067:                final String HELP_MODE = "help";
068:
069:                boolean isEdit = "true".equals(request.getParameter("edit"));
070:                String portletIndex = request.getParameter("portlet_index");
071:                int pIndex = portletIndex == null ? -1 : Integer
072:                        .parseInt(portletIndex);
073:                String requestType = request.getParameter("request_type");
074:
075:                //HTML mime type is supported by default
076:                boolean isHTMLMimeTypeSupported = true;
077:                boolean isHTMLEditSupported = request
078:                        .getParameter("html_edit_mode") != null;
079:                boolean isHTMLHelpSupported = request
080:                        .getParameter("html_help_mode") != null;
081:                boolean isXHTMLMimeTypeSupported = true; //request.getParameter("xhtml_mime_type") != null;
082:                boolean isWMLMimeTypeSupported = true; //request.getParameter("wml_mime_type") != null;    
083:
084:                String pName = request.getParameter("pname");
085:                String title = request.getParameter("title");
086:                String shortTitle = request.getParameter("short_title");
087:                String expCache = request.getParameter("exp_cache");
088:                String resourceBundleName = request
089:                        .getParameter("resource_bundle");
090:                String supportedLocales = request
091:                        .getParameter("supported_locales");
092:                String keywordsStr = request.getParameter("keywords");
093:                String rssDocURL = request.getParameter("rss_doc_url");
094:                String rssDocPath = request.getParameter("rss_doc_path");
095:
096:                String totalSecRoles = request.getParameter("sec_roles_total");
097:                String totalDescrLang = request
098:                        .getParameter("descr_lang_total");
099:                String totalDispLang = request
100:                        .getParameter("display_lang_total");
101:                int numOfSecRoles = Integer.parseInt(totalSecRoles);
102:                int numOfDescrLangs = Integer.parseInt(totalDescrLang);
103:                int numOfDispLangs = Integer.parseInt(totalDispLang);
104:
105:                String refreshPeriodStr = request.getParameter("period");
106:                int refreshPeriod = -1;
107:
108:                String maxItemsStr = request.getParameter("max_items");
109:
110:                String editPath = request.getParameter("edit_path");
111:                String helpPath = request.getParameter("help_path");
112:
113:                String error = "";
114:                // Check for errors
115:                if (pName == null || "".equals(pName.trim())) {
116:                    error += "You must provide portlet name.<br/>";
117:                } else if (PortalServlet.getInstance().isPortletExists(pName)) {
118:                    if (!isEdit
119:                            || !pName.equals(((PortletConfigInfo) PortalServlet
120:                                    .getInstance().getPortletConfigInfoList()
121:                                    .elementAt(pIndex)).name)) {
122:                        error += "Duplicate portlet name.<br/>";
123:                    }
124:                }
125:
126:                if (title == null || "".equals(title.trim())) {
127:                    error += "You must provide portlet title.<br/>";
128:                }
129:                if (rssDocURL == null || "".equals(rssDocURL.trim())) {
130:                    if (rssDocPath == null || "".equals(rssDocPath.trim()))
131:                        error += "You must provide either URL or path (local) for the RSS document.<br/>";
132:
133:                } else if (rssDocURL.indexOf("://") == -1) {
134:                    error += "Invalid RSS document URL.<br/>";
135:                }
136:                if (refreshPeriodStr != null
137:                        && !refreshPeriodStr.trim().equals("")) {
138:                    try {
139:                        refreshPeriod = Integer.parseInt(refreshPeriodStr);
140:                    } catch (Exception ex) {
141:                        error += "Refresh period entry must be a number.<br/>";
142:                    }
143:                }
144:                if (maxItemsStr != null && !maxItemsStr.trim().equals("")) {
145:                    try {
146:                        Integer.parseInt(maxItemsStr);
147:                    } catch (Exception ex) {
148:                        error += "Maximum headlines must be a number.<br/>";
149:                    }
150:                }
151:                if (expCache != null && !expCache.trim().equals("")) {
152:                    try {
153:                        Integer.parseInt(expCache);
154:                    } catch (Exception ex) {
155:                        error += "Expiration cache must be a number.<br/>";
156:                    }
157:                }
158:
159:                if (!error.equals("")) {
160:                    response.setRenderParameter("error", error);
161:                    if (isEdit)
162:                        response.setRenderParameter("edit", "true");
163:                    return "failure";
164:                }
165:
166:                PortletType pType = PortletUtil.createPortletType(pName,
167:                        PORTLET_TYPE);
168:                PortletUtil.setTitle(title, pType);
169:                PortletUtil.setShortTitle(shortTitle, pType);
170:                PortletUtil.setResourceBundle(resourceBundleName, pType);
171:                PortletUtil.setKeywords(keywordsStr, pType);
172:
173:                HashMap descrMap = new HashMap();
174:                for (int i = 0; i < numOfDescrLangs; i++) {
175:                    String lang = request.getParameter("descr_lang" + i);
176:                    String descr = request.getParameter("descr" + i);
177:                    if (descrMap.containsKey(lang))
178:                        continue;
179:                    descrMap.put(lang, descr);
180:                }
181:                PortletUtil.setDescription(descrMap, pType);
182:
183:                HashMap displayMap = new HashMap();
184:                for (int i = 0; i < numOfDispLangs; i++) {
185:                    String lang = request.getParameter("display_lang" + i);
186:                    String displayName = request.getParameter("display_name"
187:                            + i);
188:                    if (displayMap.containsKey(lang))
189:                        continue;
190:                    displayMap.put(lang, displayName);
191:                }
192:                PortletUtil.setDisplayName(displayMap, pType);
193:
194:                if (expCache != null && !expCache.trim().equals(""))
195:                    PortletUtil.setExpirationCache(Integer.parseInt(expCache),
196:                            pType);
197:
198:                Hashtable initParams = new Hashtable();
199:                if (rssDocURL != null && !rssDocURL.trim().equals(""))
200:                    initParams.put(RSSPortlet.RSS_DOC_URL, rssDocURL);
201:                else
202:                    initParams.put(RSSPortlet.RSS_DOC_PATH, rssDocPath);
203:
204:                initParams.put(RSSPortlet.REFRESH_PERIOD, refreshPeriodStr);
205:
206:                if (editPath != null && !editPath.trim().equals("")) {
207:                    if (editPath.indexOf("://") == -1
208:                            && !editPath.startsWith("/")) {
209:                        editPath = "/" + editPath;
210:                    }
211:                    initParams.put(BasePortlet.EDIT_JSP_PARAM, editPath);
212:                    isHTMLEditSupported = true;
213:                }
214:
215:                if (helpPath != null && !helpPath.trim().equals("")) {
216:                    if (helpPath.indexOf("://") == -1
217:                            && !helpPath.startsWith("/")) {
218:                        helpPath = "/" + helpPath;
219:                    }
220:                    initParams.put(BasePortlet.HELP_JSP_PARAM, helpPath);
221:                    isHTMLHelpSupported = true;
222:                }
223:
224:                PortletUtil.setInitParams(initParams, pType);
225:
226:                if (supportedLocales != null
227:                        && !"".equals(supportedLocales.trim())) {
228:                    String[] locales = StringUtil.split(supportedLocales, ",");
229:                    PortletUtil.setSupportedLocales(locales, pType);
230:                }
231:
232:                if (isHTMLMimeTypeSupported) {
233:                    String[] supportedModes = null;
234:                    if (isHTMLEditSupported && isHTMLHelpSupported) {
235:                        supportedModes = new String[] { EDIT_MODE, HELP_MODE };
236:
237:                    } else if (isHTMLEditSupported) {
238:                        supportedModes = new String[] { EDIT_MODE };
239:
240:                    } else if (isHTMLHelpSupported) {
241:                        supportedModes = new String[] { HELP_MODE };
242:
243:                    }
244:
245:                    PortletUtil.setSupports(supportedModes, MimeTypes.HTML,
246:                            pType);
247:                }
248:
249:                if (isXHTMLMimeTypeSupported) {
250:                    String[] supportedModes = new String[0];
251:                    PortletUtil.setSupports(supportedModes, MimeTypes.XHTML_MP,
252:                            pType);
253:                }
254:
255:                if (isWMLMimeTypeSupported) {
256:                    String[] supportedModes = new String[0];
257:                    PortletUtil.setSupports(supportedModes, MimeTypes.WML,
258:                            pType);
259:                }
260:
261:                HashMap secRoleMap = new HashMap();
262:                for (int i = 0; i < numOfSecRoles; i++) {
263:                    String roleName = request.getParameter("role_name" + i);
264:                    if (roleName != null && !"".equals(roleName.trim())) {
265:                        secRoleMap.put(roleName, request
266:                                .getParameter("role_link" + i));
267:                    }
268:                }
269:                PortletUtil.setSecurityRoleReference(secRoleMap, pType);
270:
271:                if (maxItemsStr != null && !"".equals(maxItemsStr.trim())) {
272:                    Hashtable prefMap = new Hashtable();
273:                    ArrayList valueList = new ArrayList();
274:                    valueList.add(maxItemsStr);
275:                    prefMap.put(RSSPortlet.MAX_ITEMS, valueList);
276:                    PortletUtil.setPreferences(prefMap, pType);
277:                }
278:
279:                try {
280:                    if (isEdit) {
281:                        HttpServletRequest req = ((PortletRequestImpl) request)
282:                                .getHttpServletRequest();
283:                        HttpServletResponse res = ((PortletResponseImpl) response)
284:                                .getHttpServletResponse();
285:                        PortalServlet.getInstance().replacePortlet(pType,
286:                                pIndex, req, res);
287:                    } else {
288:                        PortalServlet.getInstance().addPortlet(pType);
289:                    }
290:                    PortalServlet.getInstance().savePortletConfiguration();
291:                } catch (Exception ex) {
292:                    throw new PortletException("Failed to create RSS portlet.",
293:                            ex);
294:                }
295:                return "success";
296:            }
297:
298:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.