Source Code Cross Referenced for PortletPreferencesLocalServiceImpl.java in  » Portal » liferay-portal-4.4.2 » com » liferay » portal » service » impl » 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 » liferay portal 4.4.2 » com.liferay.portal.service.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003:         *
004:         * Permission is hereby granted, free of charge, to any person obtaining a copy
005:         * of this software and associated documentation files (the "Software"), to deal
006:         * in the Software without restriction, including without limitation the rights
007:         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008:         * copies of the Software, and to permit persons to whom the Software is
009:         * furnished to do so, subject to the following conditions:
010:         *
011:         * The above copyright notice and this permission notice shall be included in
012:         * all copies or substantial portions of the Software.
013:         *
014:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015:         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016:         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017:         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018:         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019:         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020:         * SOFTWARE.
021:         */package com.liferay.portal.service.impl;
022:
023:        import com.liferay.portal.NoSuchPortletPreferencesException;
024:        import com.liferay.portal.PortalException;
025:        import com.liferay.portal.SystemException;
026:        import com.liferay.portal.kernel.util.StringMaker;
027:        import com.liferay.portal.kernel.util.StringPool;
028:        import com.liferay.portal.kernel.util.Validator;
029:        import com.liferay.portal.model.Portlet;
030:        import com.liferay.portal.model.PortletPreferences;
031:        import com.liferay.portal.model.PortletPreferencesIds;
032:        import com.liferay.portal.model.impl.PortletImpl;
033:        import com.liferay.portal.service.base.PortletPreferencesLocalServiceBaseImpl;
034:        import com.liferay.portlet.PortletPreferencesImpl;
035:        import com.liferay.portlet.PortletPreferencesSerializer;
036:
037:        import java.util.List;
038:        import java.util.Map;
039:
040:        /**
041:         * <a href="PortletPreferencesLocalServiceImpl.java.html"><b><i>View Source</i>
042:         * </b></a>
043:         *
044:         * @author Brian Wing Shun Chan
045:         *
046:         */
047:        public class PortletPreferencesLocalServiceImpl extends
048:                PortletPreferencesLocalServiceBaseImpl {
049:
050:            public void deletePortletPreferences(long portletPreferencesId)
051:                    throws PortalException, SystemException {
052:
053:                PortletPreferences portletPreferences = portletPreferencesPersistence
054:                        .findByPrimaryKey(portletPreferencesId);
055:
056:                long ownerId = portletPreferences.getOwnerId();
057:                int ownerType = portletPreferences.getOwnerType();
058:
059:                portletPreferencesPersistence.remove(portletPreferences);
060:
061:                PortletPreferencesLocalUtil.clearPreferencesPool(ownerId,
062:                        ownerType);
063:            }
064:
065:            public void deletePortletPreferences(long ownerId, int ownerType,
066:                    long plid) throws PortalException, SystemException {
067:
068:                portletPreferencesPersistence.removeByO_O_P(ownerId, ownerType,
069:                        plid);
070:
071:                PortletPreferencesLocalUtil.clearPreferencesPool(ownerId,
072:                        ownerType);
073:            }
074:
075:            public void deletePortletPreferences(long ownerId, int ownerType,
076:                    long plid, String portletId) throws PortalException,
077:                    SystemException {
078:
079:                portletPreferencesPersistence.removeByO_O_P_P(ownerId,
080:                        ownerType, plid, portletId);
081:
082:                PortletPreferencesLocalUtil.clearPreferencesPool(ownerId,
083:                        ownerType);
084:            }
085:
086:            public javax.portlet.PortletPreferences getDefaultPreferences(
087:                    long companyId, String portletId) throws PortalException,
088:                    SystemException {
089:
090:                Portlet portlet = portletLocalService.getPortletById(companyId,
091:                        portletId);
092:
093:                return PortletPreferencesSerializer.fromDefaultXML(portlet
094:                        .getDefaultPreferences());
095:            }
096:
097:            public List getPortletPreferences() throws SystemException {
098:                return portletPreferencesPersistence.findAll();
099:            }
100:
101:            public List getPortletPreferences(long plid) throws SystemException {
102:                return portletPreferencesPersistence.findByPlid(plid);
103:            }
104:
105:            public List getPortletPreferences(long plid, String portletId)
106:                    throws SystemException {
107:
108:                return portletPreferencesPersistence.findByP_P(plid, portletId);
109:            }
110:
111:            public List getPortletPreferences(long ownerId, int ownerType,
112:                    long plid) throws PortalException, SystemException {
113:
114:                return portletPreferencesPersistence.findByO_O_P(ownerId,
115:                        ownerType, plid);
116:            }
117:
118:            public PortletPreferences getPortletPreferences(long ownerId,
119:                    int ownerType, long plid, String portletId)
120:                    throws PortalException, SystemException {
121:
122:                return portletPreferencesPersistence.findByO_O_P_P(ownerId,
123:                        ownerType, plid, portletId);
124:            }
125:
126:            public javax.portlet.PortletPreferences getPreferences(
127:                    PortletPreferencesIds portletPreferencesIds)
128:                    throws PortalException, SystemException {
129:
130:                return getPreferences(portletPreferencesIds.getCompanyId(),
131:                        portletPreferencesIds.getOwnerId(),
132:                        portletPreferencesIds.getOwnerType(),
133:                        portletPreferencesIds.getPlid(), portletPreferencesIds
134:                                .getPortletId());
135:            }
136:
137:            public javax.portlet.PortletPreferences getPreferences(
138:                    long companyId, long ownerId, int ownerType, long plid,
139:                    String portletId) throws PortalException, SystemException {
140:
141:                return getPreferences(companyId, ownerId, ownerType, plid,
142:                        portletId, null);
143:            }
144:
145:            public javax.portlet.PortletPreferences getPreferences(
146:                    long companyId, long ownerId, int ownerType, long plid,
147:                    String portletId, String defaultPreferences)
148:                    throws PortalException, SystemException {
149:
150:                Map prefsPool = PortletPreferencesLocalUtil.getPreferencesPool(
151:                        ownerId, ownerType);
152:
153:                String key = encodeKey(plid, portletId);
154:
155:                PortletPreferencesImpl prefs = (PortletPreferencesImpl) prefsPool
156:                        .get(key);
157:
158:                if (prefs == null) {
159:                    PortletPreferences portletPreferences = null;
160:
161:                    Portlet portlet = portletLocalService.getPortletById(
162:                            companyId, portletId);
163:
164:                    try {
165:                        portletPreferences = portletPreferencesPersistence
166:                                .findByO_O_P_P(ownerId, ownerType, plid,
167:                                        portletId);
168:                    } catch (NoSuchPortletPreferencesException nsppe) {
169:                        long portletPreferencesId = counterLocalService
170:                                .increment();
171:
172:                        portletPreferences = portletPreferencesPersistence
173:                                .create(portletPreferencesId);
174:
175:                        portletPreferences.setOwnerId(ownerId);
176:                        portletPreferences.setOwnerType(ownerType);
177:                        portletPreferences.setPlid(plid);
178:                        portletPreferences.setPortletId(portletId);
179:
180:                        if (Validator.isNull(defaultPreferences)) {
181:                            if (portlet == null) {
182:                                defaultPreferences = PortletImpl.DEFAULT_PREFERENCES;
183:                            } else {
184:                                defaultPreferences = portlet
185:                                        .getDefaultPreferences();
186:                            }
187:                        }
188:
189:                        portletPreferences.setPreferences(defaultPreferences);
190:
191:                        portletPreferencesPersistence
192:                                .update(portletPreferences);
193:                    }
194:
195:                    prefs = PortletPreferencesSerializer.fromXML(companyId,
196:                            ownerId, ownerType, plid, portletId,
197:                            portletPreferences.getPreferences());
198:
199:                    prefsPool.put(key, prefs);
200:                }
201:
202:                return (PortletPreferencesImpl) prefs.clone();
203:            }
204:
205:            public PortletPreferences updatePreferences(long ownerId,
206:                    int ownerType, long plid, String portletId,
207:                    javax.portlet.PortletPreferences prefs)
208:                    throws PortalException, SystemException {
209:
210:                PortletPreferences portletPreferences = null;
211:
212:                try {
213:                    portletPreferences = portletPreferencesPersistence
214:                            .findByO_O_P_P(ownerId, ownerType, plid, portletId);
215:                } catch (NoSuchPortletPreferencesException nsppe) {
216:                    long portletPreferencesId = counterLocalService.increment();
217:
218:                    portletPreferences = portletPreferencesPersistence
219:                            .create(portletPreferencesId);
220:
221:                    portletPreferences.setOwnerId(ownerId);
222:                    portletPreferences.setOwnerType(ownerType);
223:                    portletPreferences.setPlid(plid);
224:                    portletPreferences.setPortletId(portletId);
225:                }
226:
227:                PortletPreferencesImpl prefsImpl = (PortletPreferencesImpl) prefs;
228:
229:                String xml = PortletPreferencesSerializer.toXML(prefsImpl);
230:
231:                portletPreferences.setPreferences(xml);
232:
233:                portletPreferencesPersistence.update(portletPreferences);
234:
235:                PortletPreferencesLocalUtil.clearPreferencesPool(ownerId,
236:                        ownerType);
237:
238:                return portletPreferences;
239:            }
240:
241:            protected String encodeKey(long plid, String portletId) {
242:                StringMaker sm = new StringMaker();
243:
244:                sm.append(plid);
245:                sm.append(StringPool.POUND);
246:                sm.append(portletId);
247:
248:                return sm.toString();
249:            }
250:
251:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.