Source Code Cross Referenced for AbstractUserProfileManager.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » portal » profile » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.portal.profile.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.portal.profile.impl;
018:
019:        import java.util.ArrayList;
020:        import java.util.Collection;
021:        import java.util.HashMap;
022:        import java.util.Iterator;
023:        import java.util.List;
024:        import java.util.Map;
025:
026:        import org.apache.avalon.framework.CascadingRuntimeException;
027:        import org.apache.avalon.framework.service.ServiceException;
028:        import org.apache.avalon.framework.service.ServiceSelector;
029:        import org.apache.cocoon.ProcessingException;
030:        import org.apache.cocoon.portal.PortalService;
031:        import org.apache.cocoon.portal.coplet.CopletData;
032:        import org.apache.cocoon.portal.coplet.CopletFactory;
033:        import org.apache.cocoon.portal.coplet.CopletInstanceData;
034:        import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
035:        import org.apache.cocoon.portal.layout.CompositeLayout;
036:        import org.apache.cocoon.portal.layout.Item;
037:        import org.apache.cocoon.portal.layout.Layout;
038:        import org.apache.cocoon.portal.layout.LayoutFactory;
039:
040:        /**
041:         * The profile manager using the authentication framework
042:         * 
043:         * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
044:         * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
045:         * @deprecated Use the {@link org.apache.cocoon.portal.profile.impl.GroupBasedProfileManager}
046:         * @version CVS $Id: AbstractUserProfileManager.java 433543 2006-08-22 06:22:54Z crossley $
047:         */
048:        public abstract class AbstractUserProfileManager extends
049:                AbstractProfileManager {
050:
051:            /* (non-Javadoc)
052:             * @see org.apache.cocoon.portal.profile.ProfileManager#login()
053:             */
054:            public void login() {
055:                super .login();
056:                // TODO - we should move most of the stuff from getPortalLayout to here
057:                // for now we use a hack :)
058:                this .getPortalLayout(null, null);
059:            }
060:
061:            /* (non-Javadoc)
062:             * @see org.apache.cocoon.portal.profile.ProfileManager#logout()
063:             */
064:            public void logout() {
065:                PortalService service = null;
066:                ServiceSelector adapterSelector = null;
067:                try {
068:                    adapterSelector = (ServiceSelector) this .manager
069:                            .lookup(CopletAdapter.ROLE + "Selector");
070:                    service = (PortalService) this .manager
071:                            .lookup(PortalService.ROLE);
072:                    final String layoutKey = service.getDefaultLayoutKey();
073:
074:                    CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager) service
075:                            .getAttribute("CopletInstanceData:" + layoutKey);
076:                    if (copletInstanceDataManager != null) {
077:                        Iterator iter = copletInstanceDataManager
078:                                .getCopletInstanceData().values().iterator();
079:                        while (iter.hasNext()) {
080:                            CopletInstanceData cid = (CopletInstanceData) iter
081:                                    .next();
082:                            CopletAdapter adapter = null;
083:                            try {
084:                                adapter = (CopletAdapter) adapterSelector
085:                                        .select(cid.getCopletData()
086:                                                .getCopletBaseData()
087:                                                .getCopletAdapterName());
088:                                adapter.logout(cid);
089:                            } finally {
090:                                adapterSelector.release(adapter);
091:                            }
092:                        }
093:                    }
094:
095:                    service.removeAttribute("CopletData:" + layoutKey);
096:                    service.removeAttribute("CopletInstanceData:" + layoutKey);
097:                    service.removeAttribute("Layout:" + layoutKey);
098:                } catch (ServiceException e) {
099:                    throw new CascadingRuntimeException(
100:                            "Unable to lookup portal service.", e);
101:                } finally {
102:                    this .manager.release(service);
103:                    this .manager.release(adapterSelector);
104:                }
105:                super .logout();
106:            }
107:
108:            /**
109:             * @param layoutMap
110:             * @param layout
111:             */
112:            protected void cacheLayouts(Map layoutMap, Layout layout) {
113:                if (layout != null) {
114:                    if (layout.getId() != null) {
115:                        layoutMap.put(layout.getId(), layout);
116:                    }
117:                    if (layout instanceof  CompositeLayout) {
118:                        CompositeLayout cl = (CompositeLayout) layout;
119:                        Iterator i = cl.getItems().iterator();
120:                        while (i.hasNext()) {
121:                            Item current = (Item) i.next();
122:                            this .cacheLayouts(layoutMap, current.getLayout());
123:                        }
124:                    }
125:                }
126:
127:            }
128:
129:            /**
130:             * Prepares the object by using the specified factory.
131:             */
132:            protected void prepareObject(Object object, Object factory)
133:                    throws ProcessingException {
134:                if (factory != null && object != null) {
135:                    if (object instanceof  Layout) {
136:                        ((LayoutFactory) factory)
137:                                .prepareLayout((Layout) object);
138:                    } else if (object instanceof  CopletDataManager) {
139:                        CopletFactory copletFactory = (CopletFactory) factory;
140:                        Iterator iterator = ((CopletDataManager) object)
141:                                .getCopletData().values().iterator();
142:                        while (iterator.hasNext()) {
143:                            CopletData cd = (CopletData) iterator.next();
144:                            copletFactory.prepare(cd);
145:                        }
146:                    } else if (object instanceof  CopletInstanceDataManager) {
147:                        CopletFactory copletFactory = (CopletFactory) factory;
148:                        Iterator iterator = ((CopletInstanceDataManager) object)
149:                                .getCopletInstanceData().values().iterator();
150:                        while (iterator.hasNext()) {
151:                            CopletInstanceData cid = (CopletInstanceData) iterator
152:                                    .next();
153:                            copletFactory.prepare(cid);
154:                        }
155:                    }
156:                }
157:            }
158:
159:            /* (non-Javadoc)
160:             * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstanceData(java.lang.String)
161:             */
162:            public CopletInstanceData getCopletInstanceData(String copletID) {
163:                PortalService service = null;
164:                String attribute = null;
165:                try {
166:                    service = (PortalService) this .manager
167:                            .lookup(PortalService.ROLE);
168:                    final String layoutKey = service.getDefaultLayoutKey();
169:
170:                    attribute = "CopletInstanceData:" + layoutKey;
171:                    CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager) service
172:                            .getAttribute(attribute);
173:
174:                    return copletInstanceDataManager
175:                            .getCopletInstanceData(copletID);
176:                } catch (ServiceException e) {
177:                    throw new CascadingRuntimeException(
178:                            "Unable to lookup portal service.", e);
179:                } finally {
180:                    this .manager.release(service);
181:                }
182:            }
183:
184:            /* (non-Javadoc)
185:             * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletData(java.lang.String)
186:             */
187:            public CopletData getCopletData(String copletDataId) {
188:                PortalService service = null;
189:                String attribute = null;
190:                try {
191:                    service = (PortalService) this .manager
192:                            .lookup(PortalService.ROLE);
193:                    final String layoutKey = service.getDefaultLayoutKey();
194:
195:                    attribute = "CopletInstanceData:" + layoutKey;
196:                    CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager) service
197:                            .getAttribute(attribute);
198:
199:                    Iterator i = copletInstanceDataManager
200:                            .getCopletInstanceData().values().iterator();
201:                    boolean found = false;
202:                    CopletInstanceData current = null;
203:                    while (!found && i.hasNext()) {
204:                        current = (CopletInstanceData) i.next();
205:                        found = current.getCopletData().getId().equals(
206:                                copletDataId);
207:                    }
208:                    if (found) {
209:                        return current.getCopletData();
210:                    }
211:                    return null;
212:                } catch (ServiceException e) {
213:                    throw new CascadingRuntimeException(
214:                            "Unable to lookup portal service.", e);
215:                } finally {
216:                    this .manager.release(service);
217:                }
218:            }
219:
220:            /* (non-Javadoc)
221:             * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstanceData(org.apache.cocoon.portal.coplet.CopletData)
222:             */
223:            public List getCopletInstanceData(CopletData data) {
224:                List coplets = new ArrayList();
225:                PortalService service = null;
226:                String attribute = null;
227:                try {
228:                    service = (PortalService) this .manager
229:                            .lookup(PortalService.ROLE);
230:                    final String layoutKey = service.getDefaultLayoutKey();
231:
232:                    attribute = "CopletInstanceData:" + layoutKey;
233:                    CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager) service
234:                            .getAttribute(attribute);
235:
236:                    Iterator iter = copletInstanceDataManager
237:                            .getCopletInstanceData().values().iterator();
238:                    while (iter.hasNext()) {
239:                        CopletInstanceData current = (CopletInstanceData) iter
240:                                .next();
241:                        if (current.getCopletData().equals(data)) {
242:                            coplets.add(current);
243:                        }
244:                    }
245:                    return coplets;
246:                } catch (ServiceException e) {
247:                    throw new CascadingRuntimeException(
248:                            "Unable to lookup portal service.", e);
249:                } finally {
250:                    this .manager.release(service);
251:                }
252:            }
253:
254:            /* (non-Javadoc)
255:             * @see org.apache.cocoon.portal.profile.ProfileManager#register(org.apache.cocoon.portal.coplet.CopletInstanceData)
256:             */
257:            public void register(CopletInstanceData coplet) {
258:                PortalService service = null;
259:                String attribute = null;
260:                try {
261:                    service = (PortalService) this .manager
262:                            .lookup(PortalService.ROLE);
263:                    final String layoutKey = service.getDefaultLayoutKey();
264:
265:                    attribute = "CopletInstanceData:" + layoutKey;
266:                    CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager) service
267:                            .getAttribute(attribute);
268:
269:                    copletInstanceDataManager.putCopletInstanceData(coplet);
270:
271:                } catch (ServiceException e) {
272:                    throw new CascadingRuntimeException(
273:                            "Unable to lookup portal service.", e);
274:                } finally {
275:                    this .manager.release(service);
276:                }
277:            }
278:
279:            /* (non-Javadoc)
280:             * @see org.apache.cocoon.portal.profile.ProfileManager#unregister(org.apache.cocoon.portal.coplet.CopletInstanceData)
281:             */
282:            public void unregister(CopletInstanceData coplet) {
283:                PortalService service = null;
284:                String attribute = null;
285:                try {
286:                    service = (PortalService) this .manager
287:                            .lookup(PortalService.ROLE);
288:                    final String layoutKey = service.getDefaultLayoutKey();
289:
290:                    attribute = "CopletInstanceData:" + layoutKey;
291:                    CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager) service
292:                            .getAttribute(attribute);
293:
294:                    copletInstanceDataManager.getCopletInstanceData().remove(
295:                            coplet.getId());
296:
297:                } catch (ServiceException e) {
298:                    throw new CascadingRuntimeException(
299:                            "Unable to lookup portal service.", e);
300:                } finally {
301:                    this .manager.release(service);
302:                }
303:            }
304:
305:            /* (non-Javadoc)
306:             * @see org.apache.cocoon.portal.profile.ProfileManager#register(org.apache.cocoon.portal.layout.Layout)
307:             */
308:            public void register(Layout layout) {
309:                PortalService service = null;
310:                try {
311:                    service = (PortalService) this .manager
312:                            .lookup(PortalService.ROLE);
313:                    final String layoutKey = service.getDefaultLayoutKey();
314:
315:                    Map layoutMap = (Map) service.getAttribute("Layout-Map:"
316:                            + layoutKey);
317:                    if (layoutMap == null) {
318:                        layout = (Layout) service.getAttribute("Layout:"
319:                                + layoutKey);
320:                        if (layout != null) {
321:                            layoutMap = new HashMap();
322:                            this .cacheLayouts(layoutMap, layout);
323:                            service.setAttribute("Layout-Map:" + layoutKey,
324:                                    layoutMap);
325:                        }
326:                    }
327:
328:                    if (layoutMap != null) {
329:                        layoutMap.put(layout.getId(), layout);
330:                    }
331:
332:                } catch (ServiceException e) {
333:                    throw new CascadingRuntimeException(
334:                            "Unable to lookup portal service.", e);
335:                } finally {
336:                    this .manager.release(service);
337:                }
338:            }
339:
340:            /* (non-Javadoc)
341:             * @see org.apache.cocoon.portal.profile.ProfileManager#unregister(org.apache.cocoon.portal.layout.Layout)
342:             */
343:            public void unregister(Layout layout) {
344:                PortalService service = null;
345:                try {
346:                    service = (PortalService) this .manager
347:                            .lookup(PortalService.ROLE);
348:                    final String layoutKey = service.getDefaultLayoutKey();
349:
350:                    Map layoutMap = (Map) service.getAttribute("Layout-Map:"
351:                            + layoutKey);
352:
353:                    if (layoutMap != null) {
354:                        layoutMap.remove(layout.getId());
355:                    }
356:
357:                } catch (ServiceException e) {
358:                    throw new CascadingRuntimeException(
359:                            "Unable to lookup portal service.", e);
360:                } finally {
361:                    this .manager.release(service);
362:                }
363:            }
364:
365:            /* (non-Javadoc)
366:             * @see org.apache.cocoon.portal.profile.ProfileManager#getPortalLayout(java.lang.String, java.lang.String)
367:             */
368:            public Layout getPortalLayout(String layoutKey, String layoutID) {
369:                PortalService service = null;
370:                ServiceSelector adapterSelector = null;
371:
372:                try {
373:                    service = (PortalService) this .manager
374:                            .lookup(PortalService.ROLE);
375:                    LayoutFactory factory = service.getComponentManager()
376:                            .getLayoutFactory();
377:                    CopletFactory copletFactory = service.getComponentManager()
378:                            .getCopletFactory();
379:
380:                    adapterSelector = (ServiceSelector) this .manager
381:                            .lookup(CopletAdapter.ROLE + "Selector");
382:
383:                    if (null == layoutKey) {
384:                        layoutKey = service.getDefaultLayoutKey();
385:                    }
386:
387:                    final String layoutAttributeKey = "Layout:" + layoutKey;
388:                    final String layoutObjectsAttributeKey = "Layout-Map:"
389:                            + layoutKey;
390:
391:                    Layout layout = (Layout) service
392:                            .getAttribute(layoutAttributeKey);
393:                    if (layout == null) {
394:                        layout = this .loadProfile(layoutKey, service,
395:                                copletFactory, factory, adapterSelector);
396:                    }
397:
398:                    if (layoutID != null) {
399:                        // now search for a layout
400:                        Map layoutMap = (Map) service
401:                                .getAttribute(layoutObjectsAttributeKey);
402:                        if (layoutMap == null) {
403:                            layoutMap = new HashMap();
404:                            this .cacheLayouts(layoutMap, layout);
405:                            service.setAttribute(layoutObjectsAttributeKey,
406:                                    layoutMap);
407:                        }
408:                        if (layoutMap != null) {
409:                            return (Layout) layoutMap.get(layoutID);
410:                        }
411:                    }
412:
413:                    return layout;
414:                } catch (Exception ce) {
415:                    throw new CascadingRuntimeException(
416:                            "Exception during loading of profile.", ce);
417:                } finally {
418:                    this .manager.release(service);
419:                    this .manager.release(adapterSelector);
420:                }
421:            }
422:
423:            /**
424:             * This loads a new profile
425:             */
426:            protected abstract Layout loadProfile(String layoutKey,
427:                    PortalService service, CopletFactory copletFactory,
428:                    LayoutFactory layoutFactory, ServiceSelector adapterSelector)
429:                    throws Exception;
430:
431:            /* (non-Javadoc)
432:             * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletDatas()
433:             */
434:            public Collection getCopletDatas() {
435:                PortalService service = null;
436:                try {
437:                    service = (PortalService) this .manager
438:                            .lookup(PortalService.ROLE);
439:                    final String layoutKey = service.getDefaultLayoutKey();
440:                    CopletDataManager manager = (CopletDataManager) service
441:                            .getAttribute("CopletData:" + layoutKey);
442:                    return manager.getCopletData().values();
443:                } catch (Exception e) {
444:                    throw new CascadingRuntimeException(
445:                            "Error in getCopletDatas.", e);
446:                } finally {
447:                    this .manager.release(service);
448:                }
449:            }
450:
451:            /* (non-Javadoc)
452:             * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstanceDatas()
453:             */
454:            public Collection getCopletInstanceDatas() {
455:                PortalService service = null;
456:                try {
457:                    service = (PortalService) this .manager
458:                            .lookup(PortalService.ROLE);
459:                    final String layoutKey = service.getDefaultLayoutKey();
460:                    CopletInstanceDataManager manager = (CopletInstanceDataManager) service
461:                            .getAttribute("CopletInstanceData:" + layoutKey);
462:                    return manager.getCopletInstanceData().values();
463:                } catch (Exception e) {
464:                    throw new CascadingRuntimeException(
465:                            "Error in getCopletInstanceDatas.", e);
466:                } finally {
467:                    this .manager.release(service);
468:                }
469:            }
470:
471:            /* (non-Javadoc)
472:             * @see org.apache.cocoon.portal.profile.ProfileManager#storeProfile(org.apache.cocoon.portal.layout.Layout, java.lang.String)
473:             */
474:            public void storeProfile(Layout rootLayout, String layoutKey) {
475:                PortalService service = null;
476:
477:                try {
478:                    service = (PortalService) this .manager
479:                            .lookup(PortalService.ROLE);
480:                    if (null == layoutKey) {
481:                        layoutKey = service.getDefaultLayoutKey();
482:                    }
483:
484:                    final String layoutAttributeKey = "Layout:" + layoutKey;
485:
486:                    service.setAttribute(layoutAttributeKey, rootLayout);
487:                } catch (Exception ce) {
488:                    throw new CascadingRuntimeException(
489:                            "Exception during loading of profile.", ce);
490:                } finally {
491:                    this.manager.release(service);
492:                }
493:            }
494:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.