Source Code Cross Referenced for PortletContentEditorPortlet.java in  » Portal » jboss-portal-2.6.4 » org » jboss » portal » core » ui » content » portlet » 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 » jboss portal 2.6.4 » org.jboss.portal.core.ui.content.portlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * JBoss, a division of Red Hat                                               *
003:         * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
004:         * contributors as indicated by the @authors tag. See the                     *
005:         * copyright.txt in the distribution for a full listing of                    *
006:         * individual contributors.                                                   *
007:         *                                                                            *
008:         * This is free software; you can redistribute it and/or modify it            *
009:         * under the terms of the GNU Lesser General Public License as                *
010:         * published by the Free Software Foundation; either version 2.1 of           *
011:         * the License, or (at your option) any later version.                        *
012:         *                                                                            *
013:         * This software is distributed in the hope that it will be useful,           *
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
016:         * Lesser General Public License for more details.                            *
017:         *                                                                            *
018:         * You should have received a copy of the GNU Lesser General Public           *
019:         * License along with this software; if not, write to the Free                *
020:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
021:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
022:         ******************************************************************************/package org.jboss.portal.core.ui.content.portlet;
023:
024:        import org.jboss.portal.Mode;
025:        import org.jboss.portal.core.model.instance.Instance;
026:        import org.jboss.portal.core.model.instance.InstanceContainer;
027:        import org.jboss.portal.portlet.Portlet;
028:        import org.jboss.portal.portlet.PortletInvokerException;
029:        import org.jboss.portal.portlet.info.ModeInfo;
030:        import org.jboss.portal.portlet.info.PortletInfo;
031:
032:        import javax.portlet.ActionRequest;
033:        import javax.portlet.ActionResponse;
034:        import javax.portlet.GenericPortlet;
035:        import javax.portlet.PortletException;
036:        import javax.portlet.PortletMode;
037:        import javax.portlet.PortletRequestDispatcher;
038:        import javax.portlet.PortletSecurityException;
039:        import javax.portlet.PortletURL;
040:        import javax.portlet.RenderRequest;
041:        import javax.portlet.RenderResponse;
042:        import java.io.IOException;
043:        import java.io.PrintWriter;
044:        import java.util.ArrayList;
045:        import java.util.Collections;
046:        import java.util.Comparator;
047:        import java.util.Iterator;
048:        import java.util.List;
049:
050:        /**
051:         * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
052:         * @version $Revision: 9221 $
053:         */
054:        public class PortletContentEditorPortlet extends GenericPortlet {
055:
056:            public static final String DEFAULT_PORTLET_ICON = "/portal-core/images/portletIcon_Default1.gif";
057:
058:            /** . */
059:            private final PortletMode EDIT_CONTENT = new PortletMode(
060:                    "edit_content");
061:
062:            /** . */
063:            private final Mode INTERNAL_EDIT_CONTENT = Mode
064:                    .create("edit_content");
065:
066:            /** . */
067:            private InstanceContainer instanceContainer;
068:
069:            public void init() throws PortletException {
070:                instanceContainer = (InstanceContainer) getPortletContext()
071:                        .getAttribute("InstanceContainer");
072:            }
073:
074:            public void processAction(ActionRequest req, ActionResponse resp)
075:                    throws PortletException, PortletSecurityException,
076:                    IOException {
077:                if ((req.getPortletMode().equals(EDIT_CONTENT))) {
078:                    String uri = req.getParameter("content.uri");
079:                    if (uri != null) {
080:                        resp.setRenderParameter("content.uri", uri);
081:                    }
082:                }
083:            }
084:
085:            protected void doDispatch(RenderRequest req, RenderResponse resp)
086:                    throws PortletException, PortletSecurityException,
087:                    IOException {
088:                if (EDIT_CONTENT.equals(req.getPortletMode())) {
089:                    doEditContent(req, resp);
090:                } else {
091:                    super .doDispatch(req, resp);
092:                }
093:            }
094:
095:            protected void doEditContent(RenderRequest req, RenderResponse resp)
096:                    throws PortletException, PortletSecurityException,
097:                    IOException {
098:                getContent(req, resp, false);
099:            }
100:
101:            protected void getContent(RenderRequest req, RenderResponse resp,
102:                    boolean newContent) throws PortletException,
103:                    PortletSecurityException, IOException {
104:                String selectedURI = req.getParameter("content.uri");
105:
106:                //
107:                PortletURL actionURL = resp.createActionURL();
108:
109:                //
110:                resp.setContentType("text/html");
111:                PrintWriter writer = resp.getWriter();
112:
113:                // load instances this user has access to.
114:
115:                // Remove content editors
116:                List available_instances = new ArrayList();
117:                nextInstance: for (Iterator i = instanceContainer
118:                        .getDefinitions().iterator(); i.hasNext();) {
119:                    Instance instance = (Instance) i.next();
120:
121:                    //
122:                    try {
123:                        // Filter portlets that are editors 
124:                        Portlet portlet = instance.getPortlet();
125:                        PortletInfo info = portlet.getInfo();
126:                        for (Iterator j = info.getCapabilities().getAllModes()
127:                                .iterator(); j.hasNext();) {
128:                            ModeInfo modeInfo = (ModeInfo) j.next();
129:                            if (modeInfo.getMode()
130:                                    .equals(INTERNAL_EDIT_CONTENT)) {
131:                                continue nextInstance;
132:                            }
133:                        }
134:
135:                        //
136:                        available_instances.add(instance);
137:                    } catch (PortletInvokerException ignore) {
138:                    }
139:                }
140:
141:                // Sort alphabetically
142:                Comparator simpleComparator = new Comparator() {
143:                    public int compare(Object o1, Object o2) {
144:                        Instance i1 = (Instance) o1;
145:                        Instance i2 = (Instance) o2;
146:                        return i1.getId().compareToIgnoreCase(i2.getId());
147:                    }
148:                };
149:                Collections.sort(available_instances, simpleComparator);
150:
151:                //
152:                Instance selectedInstance = null;
153:                for (int i = 0; i < available_instances.size(); i++) {
154:                    Instance instance = (Instance) available_instances.get(i);
155:                    if (instance.getId().equals(selectedURI)) {
156:                        selectedInstance = instance;
157:                    }
158:                }
159:
160:                //
161:                req.setAttribute("INSTANCES", available_instances);
162:                req.setAttribute("SELECTED_INSTANCE", selectedInstance);
163:                req.setAttribute("NEW_CONTENT", Boolean.valueOf(newContent));
164:
165:                //
166:                PortletRequestDispatcher dispatcher = getPortletContext()
167:                        .getRequestDispatcher(
168:                                "/WEB-INF/jsp/content/portlet_editor.jsp");
169:                dispatcher.include(req, resp);
170:
171:                //
172:                writer.close();
173:            }
174:
175:        }
w_w__w_.___j_a_va__2_s_.___c___o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.