Source Code Cross Referenced for ChangeWorkspaceLayoutAction.java in  » Portal » mypersonalizer » es » udc » mypersonalizer » portal » controller » actions » 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 » Portal » mypersonalizer » es.udc.mypersonalizer.portal.controller.actions.content 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /export/home/cvsroot/MyPersonalizerRepository/MyPersonalizer/Subsystems/Portal/Sources/es/udc/mypersonalizer/portal/controller/actions/content/ChangeWorkspaceLayoutAction.java,v 1.1.1.1 2004/03/25 12:08:40 fbellas Exp $
003:         * $Revision: 1.1.1.1 $
004:         * $Date: 2004/03/25 12:08:40 $
005:         *
006:         * =============================================================================
007:         *
008:         * Copyright (c) 2003, The MyPersonalizer Development Group
009:         * (http://www.tic.udc.es/~fbellas/mypersonalizer/index.html) at 
010:         * University Of A Coruna
011:         * All rights reserved.
012:         *
013:         * Redistribution and use in source and binary forms, with or without
014:         * modification, are permitted provided that the following conditions are met:
015:         *
016:         *  - Redistributions of source code must retain the above copyright notice, 
017:         *    this list of conditions and the following disclaimer.
018:         *
019:         *  - Redistributions in binary form must reproduce the above copyright notice,
020:         *    this list of conditions and the following disclaimer in the documentation
021:         *    and/or other materials provided with the distribution.
022:         *
023:         *  - Neither the name of the University Of A Coruna nor the names of its 
024:         *    contributors may be used to endorse or promote products derived from 
025:         *    this software without specific prior written permission.
026:         *
027:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
028:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
029:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
030:         * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
031:         * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
032:         * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
033:         * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
034:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
035:         * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
036:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
037:         * POSSIBILITY OF SUCH DAMAGE.
038:         *
039:         */
040:
041:        package es.udc.mypersonalizer.portal.controller.actions.content;
042:
043:        import es.udc.mypersonalizer.kernel.controller.actions.DefaultAction;
044:        import es.udc.mypersonalizer.kernel.model.actions.ActionProcessorSingleton;
045:        import es.udc.mypersonalizer.kernel.model.editors.EditorFactory;
046:        import es.udc.mypersonalizer.kernel.model.editors.WorkspaceLayoutEditor;
047:        import es.udc.mypersonalizer.kernel.model.repository.interfaces.WorkspaceLayout;
048:        import es.udc.mypersonalizer.portal.controller.session.SessionManager;
049:        import es.udc.mypersonalizer.portal.model.permissions.UserCredentials;
050:        import es.udc.mypersonalizer.portal.model.types.content.ChangeWorkspaceLayoutEvent;
051:        import java.util.*;
052:        import javax.servlet.http.HttpServletRequest;
053:        import javax.servlet.http.HttpServletResponse;
054:        import org.apache.struts.action.ActionForm;
055:        import org.apache.struts.action.ActionForward;
056:        import org.apache.struts.action.ActionMapping;
057:
058:        /**
059:         * This action performs a layout change. Using this action, the user can
060:         * position his / her services in the area of his preference in the workspace. 
061:         * It calls the model action called <tt>ChangeWorkspaceLayoutAction</tt>, which
062:         * must be registered in configuration. It also updates the workspace layout
063:         * information in the session.<p>
064:         * 
065:         * It needs to take from the request one parameter per area, called
066:         * <tt>servicesList_AX</tt>, being <tt>X</tt> the number of area to which
067:         * the parameter is related. The value of this parameter must be a
068:         * comma-separated list of service identifiers, being in the order that
069:         * these services must appear in the area.<p>
070:         *
071:         * This action requires a <tt>Success</tt> forward, which will usually point
072:         * to the portal main page.<p>
073:         *
074:         * @author  Daniel Fernandez
075:         * @since 1.0
076:         */
077:        public class ChangeWorkspaceLayoutAction extends DefaultAction {
078:
079:            /**
080:             * Name of the model action for changing the layout of a workspace.
081:             * This is "ChangeWorkspaceLayoutAction".
082:             */
083:            private static final String CHANGE_WORKSPACE_LAYOUT_ACTION = "ChangeWorkspaceLayoutAction";
084:
085:            /**
086:             * Prefix for the names of the form parameters which will carry
087:             * the new layout for services. This is <tt>servicesList_A</tt> as
088:             * the list for the first area would be <tt>servicesList_A0</tt>,
089:             * the second <tt>servicesList_A1</tt>, etc.
090:             */
091:            private static final String SERVICE_LAYOUT_PARAMETERS_PREFIX = "servicesList_A";
092:
093:            protected ActionForward doExecute(ActionMapping mapping,
094:                    ActionForm form, HttpServletRequest request,
095:                    HttpServletResponse response) throws Exception {
096:
097:                /* 
098:                 * We get the service identifiers from the action form building
099:                 * the "servicesLayout" map.
100:                 */
101:                Map servicesLayout = new HashMap();
102:                Enumeration parameterNames = request.getParameterNames();
103:                while (parameterNames.hasMoreElements()) {
104:                    String parameterName = (String) parameterNames
105:                            .nextElement();
106:
107:                    if (parameterName
108:                            .startsWith(SERVICE_LAYOUT_PARAMETERS_PREFIX)) {
109:
110:                        Integer area = new Integer(parameterName.substring(14));
111:                        String parameterValue = request
112:                                .getParameter(parameterName);
113:                        StringTokenizer parameterTokens = new StringTokenizer(
114:                                parameterValue, ", ");
115:                        List serviceIdentifiers = new ArrayList();
116:                        while (parameterTokens.hasMoreTokens()) {
117:                            serviceIdentifiers.add(parameterTokens.nextToken());
118:                        }
119:                        servicesLayout.put(area, serviceIdentifiers);
120:
121:                    }
122:
123:                }
124:
125:                /*
126:                 * If there are no workspaces, this action cannot be executed.
127:                 */
128:                if (!SessionManager.getUserHasWorkspaces(request)) {
129:                    throw new NoActiveWorkspacesException(
130:                            "Cannot change layout");
131:                }
132:
133:                ActionProcessorSingleton actionProcessorSingleton = ActionProcessorSingleton
134:                        .getInstance();
135:
136:                UserCredentials userCredentials = SessionManager
137:                        .getUserCredentials(request);
138:
139:                WorkspaceLayout currentWorkspaceLayout = SessionManager
140:                        .getCurrentWorkspaceLayout(request);
141:
142:                Long workspaceLayoutIdentifier = currentWorkspaceLayout
143:                        .getIdentifier();
144:
145:                EditorFactory editorFactory = EditorFactory.getInstance();
146:
147:                WorkspaceLayoutEditor currentWorkspaceLayoutEditor = editorFactory
148:                        .createWorkspaceLayoutEditor(currentWorkspaceLayout
149:                                .getProperty());
150:
151:                /*
152:                 * This time stamp will be necessary to avoid problems related
153:                 * to concurrent access, as this action modifies the workspace layout.
154:                 */
155:                Long timeStamp = currentWorkspaceLayoutEditor.getTimeStamp();
156:
157:                ChangeWorkspaceLayoutEvent changeWorkspaceLayoutEvent = new ChangeWorkspaceLayoutEvent(
158:                        userCredentials, workspaceLayoutIdentifier,
159:                        servicesLayout, timeStamp);
160:
161:                /* We execute the model action */
162:                WorkspaceLayout workspaceLayout = (WorkspaceLayout) actionProcessorSingleton
163:                        .execute(CHANGE_WORKSPACE_LAYOUT_ACTION,
164:                                changeWorkspaceLayoutEvent);
165:
166:                /* 
167:                 * We push the modified WorkspaceLayout into the
168:                 * session.
169:                 */
170:                SessionManager.setCurrentWorkspace(request, workspaceLayout,
171:                        new ArrayList());
172:
173:                return mapping
174:                        .findForward(DefaultAction.ACTION_SUCCESS_FORWARD);
175:            }
176:
177:        }
w_w___w_.___j___a___v___a2___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.