Source Code Cross Referenced for PortalObjectManagerBean.java in  » Portal » jboss-portal-2.6.4 » org » jboss » portal » core » admin » ui » 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.admin.ui 
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.admin.ui;
023:
024:        import org.jboss.portal.core.admin.ui.actions.AddPageAction;
025:        import org.jboss.portal.core.admin.ui.actions.PropertyAction;
026:        import org.jboss.portal.core.admin.ui.common.PageManagerBean;
027:        import org.jboss.portal.core.admin.ui.portlet.PortletDefinitionInvoker;
028:        import org.jboss.portal.core.event.PortalEventListenerRegistry;
029:        import org.jboss.portal.core.impl.model.content.ContentProviderRegistryService;
030:        import org.jboss.portal.core.model.content.Content;
031:        import org.jboss.portal.core.model.content.ContentType;
032:        import org.jboss.portal.core.model.content.spi.ContentProvider;
033:        import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
034:        import org.jboss.portal.core.model.instance.Instance;
035:        import org.jboss.portal.core.model.instance.InstanceContainer;
036:        import org.jboss.portal.core.model.portal.Page;
037:        import org.jboss.portal.core.model.portal.PortalObject;
038:        import org.jboss.portal.core.model.portal.PortalObjectContainer;
039:        import org.jboss.portal.core.model.portal.PortalObjectId;
040:        import org.jboss.portal.core.model.portal.PortalObjectPath;
041:        import org.jboss.portal.core.model.portal.PortalObjectPermission;
042:        import org.jboss.portal.core.model.portal.Window;
043:        import org.jboss.portal.faces.component.portlet.PortletActionEvent;
044:        import org.jboss.portal.identity.RoleModule;
045:        import org.jboss.portal.portlet.PortletInvoker;
046:        import org.jboss.portal.security.RoleSecurityBinding;
047:        import org.jboss.portal.security.SecurityConstants;
048:        import org.jboss.portal.security.spi.provider.DomainConfigurator;
049:        import org.jboss.portal.theme.LayoutService;
050:        import org.jboss.portal.theme.ThemeService;
051:
052:        import javax.faces.application.FacesMessage;
053:        import javax.faces.context.FacesContext;
054:        import javax.faces.event.ActionEvent;
055:        import javax.faces.model.SelectItem;
056:        import java.io.Serializable;
057:        import java.util.ArrayList;
058:        import java.util.Collection;
059:        import java.util.Collections;
060:        import java.util.HashMap;
061:        import java.util.Iterator;
062:        import java.util.LinkedList;
063:        import java.util.List;
064:        import java.util.Map;
065:        import java.util.Set;
066:
067:        /** The portal object manager bean. */
068:        public class PortalObjectManagerBean implements  Serializable,
069:                AddPageAction.Listener {
070:
071:            /** The serialVersionUID */
072:            private static final long serialVersionUID = -8923517554726982622L;
073:
074:            /** . */
075:            private static final String CONTENT_URI = "content.uri";
076:
077:            // Configuration
078:
079:            /** . */
080:            private String namespace;
081:
082:            // Wired services
083:
084:            /** . */
085:            private PortalObjectContainer portalObjectContainer;
086:
087:            /** . */
088:            private InstanceContainer instanceContainer;
089:
090:            /** . */
091:            private LayoutService layoutService;
092:
093:            /** . */
094:            private ThemeService themeService;
095:
096:            /** . */
097:            private DomainConfigurator domainConfigurator;
098:
099:            /** . */
100:            private RoleModule roleModule;
101:
102:            /** Listener registry to bind even listener to PortalNodes. */
103:            private PortalEventListenerRegistry listenerRegistry;
104:
105:            // Navigational state
106:
107:            /** The selected id. */
108:            private PortalObjectId selectedId;
109:
110:            /** The current tab name. */
111:            private String selectedPlugin;
112:
113:            /** The selected type for content. */
114:            private ContentType selectedContentType = ContentType.PORTLET;
115:
116:            /** The uri value for content. */
117:            private String selectedContentURI;
118:
119:            /** . */
120:            private Map selectedContentParameters = new HashMap();
121:
122:            /** . */
123:            private Map renderParameters;
124:
125:            // Runtime state
126:
127:            /** . */
128:            private final AuthorizationBean auth = new PortalObjectAuthorizationBean();
129:
130:            /** . */
131:            private SelectItem[] instanceItems;
132:
133:            /** . */
134:            private SelectItem[] portalPageItems;
135:
136:            /** . */
137:            private SelectItem[] portalItems;
138:
139:            /** . */
140:            private List selectedObjectPath;
141:
142:            /** . */
143:            private PortalObject selectedObject;
144:
145:            /** . */
146:            private PortalObject selectedDeletingObject;
147:
148:            /** . */
149:            private PropertiesBean selectedProperties;
150:
151:            /** . */
152:            PropertyAction propertyAction;
153:
154:            /** . */
155:            private ControlPropertiesBean controlProperties;
156:
157:            /** . */
158:            private PortletInvoker portletDefinitionInvoker;
159:
160:            /** . */
161:            private ThemeBean theme;
162:
163:            /** . */
164:            public PageManagerBean pageManager;
165:
166:            /** . */
167:            private Boolean maximizedStateExists;
168:
169:            // Wired services
170:
171:            public String getNamespace() {
172:                return namespace;
173:            }
174:
175:            public void setNamespace(String namespace) {
176:                this .namespace = namespace;
177:            }
178:
179:            public List getAvailableContentTypes() {
180:                LinkedList types = new LinkedList();
181:
182:                //
183:                for (Iterator i = ContentProviderRegistryService.getInstance()
184:                        .getContentTypes().iterator(); i.hasNext();) {
185:                    ContentType contentType = (ContentType) i.next();
186:                    SelectItem item = new SelectItem();
187:                    item.setValue(contentType);
188:                    item.setLabel(contentType.toString());
189:                    if (contentType.equals(ContentType.PORTLET)) {
190:                        types.addFirst(item);
191:                    } else {
192:                        types.addLast(item);
193:                    }
194:                }
195:                return types;
196:            }
197:
198:            public String getSelectedContentEditorInstance() {
199:                if (selectedContentType != null) {
200:                    ContentProvider contentProvider = ContentProviderRegistryService
201:                            .getInstance().getContentProvider(
202:                                    selectedContentType);
203:                    // the content provider exists (i.e. the associated portlet is deployed see: JBPORTAL-1656)
204:                    if (contentProvider != null) {
205:                        return contentProvider.getPortletInfo().getPortletName(
206:                                ContentPortlet.EDIT_CONTENT_MODE);
207:                    }
208:                }
209:                return null;
210:            }
211:
212:            public PortalEventListenerRegistry getListenerRegistry() {
213:                return listenerRegistry;
214:            }
215:
216:            public void setListenerRegistry(
217:                    PortalEventListenerRegistry listenerRegistry) {
218:                this .listenerRegistry = listenerRegistry;
219:            }
220:
221:            public RoleModule getRoleModule() {
222:                return roleModule;
223:            }
224:
225:            public void setRoleModule(RoleModule roleModule) {
226:                this .roleModule = roleModule;
227:            }
228:
229:            public PortalObjectContainer getPortalObjectContainer() {
230:                return portalObjectContainer;
231:            }
232:
233:            public void setPortalObjectContainer(PortalObjectContainer poc) {
234:                this .portalObjectContainer = poc;
235:            }
236:
237:            public InstanceContainer getInstanceContainer() {
238:                return instanceContainer;
239:            }
240:
241:            public void setInstanceContainer(InstanceContainer instanceContainer) {
242:                this .instanceContainer = instanceContainer;
243:                this .portletDefinitionInvoker = new PortletDefinitionInvoker(
244:                        instanceContainer);
245:            }
246:
247:            public LayoutService getLayoutService() {
248:                return layoutService;
249:            }
250:
251:            public void setLayoutService(LayoutService layoutService) {
252:                this .layoutService = layoutService;
253:            }
254:
255:            public ThemeService getThemeService() {
256:                return themeService;
257:            }
258:
259:            public void setThemeService(ThemeService themeService) {
260:                this .themeService = themeService;
261:            }
262:
263:            public ContentType getSelectedContentType() {
264:                return selectedContentType;
265:            }
266:
267:            public void setSelectedContentType(ContentType selectedContentType) {
268:                this .selectedContentType = selectedContentType;
269:            }
270:
271:            public String getSelectedContentURI() {
272:                return selectedContentURI;
273:            }
274:
275:            public void setSelectedContentURI(String selectedContentURI) {
276:                this .selectedContentURI = selectedContentURI;
277:            }
278:
279:            public String getSelectedPlugin() {
280:                return selectedPlugin;
281:            }
282:
283:            public void setSelectedPlugin(String selectedPlugin) {
284:                this .selectedPlugin = selectedPlugin;
285:            }
286:
287:            public Map getRenderParameters() {
288:                return renderParameters;
289:            }
290:
291:            public void setRenderParameters(Map renderParameters) {
292:                this .renderParameters = renderParameters;
293:            }
294:
295:            public Map getSelectedContentParameters() {
296:                return selectedContentParameters;
297:            }
298:
299:            public void setSelectedContentParameters(
300:                    Map selectedContentParameters) {
301:                this .selectedContentParameters = selectedContentParameters;
302:            }
303:
304:            public DomainConfigurator getDomainConfigurator() {
305:                return domainConfigurator;
306:            }
307:
308:            public void setDomainConfigurator(
309:                    DomainConfigurator domainConfigurator) {
310:                this .domainConfigurator = domainConfigurator;
311:            }
312:
313:            // Runtime state
314:
315:            public PortletInvoker getPortletDefinitionInvoker() {
316:                return portletDefinitionInvoker;
317:            }
318:
319:            public AuthorizationBean getAuth() {
320:                return auth;
321:            }
322:
323:            public SelectItem[] getInstanceItems() {
324:                return instanceItems;
325:            }
326:
327:            public SelectItem[] getPortalPageItems() {
328:                return portalPageItems;
329:            }
330:
331:            public SelectItem[] getPortalItems() {
332:                return portalItems;
333:            }
334:
335:            public List getSelectedObjectPath() {
336:                return selectedObjectPath;
337:            }
338:
339:            public PortalObject getSelectedObject() {
340:                return selectedObject;
341:            }
342:
343:            public PortalObject getSelectedDeletingObject() {
344:                return selectedDeletingObject;
345:            }
346:
347:            public PropertiesBean getSelectedProperties() {
348:                return selectedProperties;
349:            }
350:
351:            public ThemeBean getTheme() {
352:                return theme;
353:            }
354:
355:            public Boolean getMaximizedStateExists() {
356:                return maximizedStateExists;
357:            }
358:
359:            public void setMaximizedStateExists(Boolean maximizedStateExists) {
360:                this .maximizedStateExists = maximizedStateExists;
361:            }
362:
363:            // UI operations
364:
365:            public void selectObject(PortalObject po) {
366:                if (po != null) {
367:                    selectObject(po.getId());
368:                } else {
369:                    selectObject((PortalObjectId) null);
370:                }
371:            }
372:
373:            private void selectObject(PortalObjectId id) {
374:                if (id == null) {
375:                    selectedId = null;
376:                    selectedPlugin = null;
377:                    selectedContentType = ContentType.PORTLET;
378:                    selectedContentURI = null;
379:                } else {
380:                    selectedId = id;
381:                    selectedPlugin = "manager";
382:                    selectedContentType = ContentType.PORTLET;
383:                    selectedContentURI = null;
384:                }
385:            }
386:
387:            public void selectObject(ActionEvent ae) {
388:                selectObject();
389:            }
390:
391:            public void selectDeletingObject(ActionEvent ae) {
392:                PortalObjectId poid = getSelectedPortalObjectId();
393:
394:                selectedDeletingObject = portalObjectContainer.getObject(poid);
395:                selectObject();
396:
397:            }
398:
399:            public String makeObjectDefault() {
400:                PortalObjectId poid = getSelectedPortalObjectId();
401:                PortalObject object = portalObjectContainer.getObject(poid);
402:                if (object != null) {
403:                    String typeName;
404:                    int type = object.getType();
405:                    if (type == PortalObject.TYPE_PORTAL
406:                            || type == PortalObject.TYPE_CONTEXT) {
407:                        typeName = "portal";
408:                    } else if (type == PortalObject.TYPE_PAGE) {
409:                        typeName = "page";
410:                    } else {
411:                        throw new IllegalArgumentException(
412:                                "Invalid object type to set as default");
413:                    }
414:
415:                    PortalObject parent = object.getParent();
416:                    if (parent != null) {
417:                        String name = object.getName();
418:                        parent.setDeclaredProperty(
419:                                PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME,
420:                                name);
421:
422:                        FacesMessage message = new FacesMessage(
423:                                FacesMessage.SEVERITY_INFO, "Success", "'"
424:                                        + name + "' " + typeName
425:                                        + " was successfully set as default "
426:                                        + typeName);
427:                        FacesContext.getCurrentInstance().addMessage("status",
428:                                message);
429:                    }
430:                }
431:
432:                return null;
433:            }
434:
435:            public String selectObject() {
436:                try {
437:                    PortalObjectId poid = getSelectedPortalObjectId();
438:
439:                    Map pmap = getRequestParameterMap();
440:                    maximizedStateExists = Boolean.valueOf((String) pmap
441:                            .get("maximizedStateExists"));
442:
443:                    PortalObject object = portalObjectContainer.getObject(poid);
444:
445:                    // Update state if possible
446:                    if (object != null) {
447:                        selectObject(poid);
448:
449:                        //
450:                        switch (object.getType()) {
451:                        case PortalObject.TYPE_CONTEXT:
452:                            break;
453:                        case PortalObject.TYPE_PORTAL:
454:                            break;
455:                        case PortalObject.TYPE_PAGE:
456:                            break;
457:                        case PortalObject.TYPE_WINDOW:
458:                            Window window = (Window) object;
459:                            selectedContentType = window.getContentType();
460:                            Content content = window.getContent();
461:                            if (content != null) {
462:                                renderParameters = new HashMap();
463:                                renderParameters.put(CONTENT_URI,
464:                                        new String[] { content.getURI() });
465:                            }
466:                            break;
467:                        }
468:                    }
469:                } catch (Exception e) {
470:                    e.printStackTrace();
471:                }
472:
473:                //
474:                return "objects";
475:            }
476:
477:            private PortalObjectId getSelectedPortalObjectId() {
478:                // Get id
479:                Map pmap = getRequestParameterMap();
480:                String id = (String) pmap.get("id");
481:
482:                // Set the state from the id
483:                return PortalObjectId.parse(id,
484:                        PortalObjectPath.LEGACY_BASE64_FORMAT);
485:            }
486:
487:            public void selectPlugin() {
488:                // Get plugin
489:                Map pmap = getRequestParameterMap();
490:                selectedPlugin = (String) pmap.get("plugin");
491:            }
492:
493:            public Map getRequestParameterMap() {
494:                return FacesContext.getCurrentInstance().getExternalContext()
495:                        .getRequestParameterMap();
496:            }
497:
498:            public void selectParentObject(ActionEvent actionEvent) {
499:                PortalObject parent = getSelectedObjectParent();
500:                selectObject(parent);
501:            }
502:
503:            public PortalObject getSelectedObjectParent() {
504:                PortalObject current = getSelectedObject();
505:                PortalObject parent = current.getParent();
506:                return parent == null ? current : parent; // if parent is null, return the current object
507:            }
508:
509:            public void selectRootObject(ActionEvent ae) {
510:                PortalObject root = portalObjectContainer.getContext(namespace);
511:                selectObject(root);
512:            }
513:
514:            public void udpateContentType() {
515:                // Do nothing
516:            }
517:
518:            public void destroyObject(ActionEvent ae) {
519:                try {
520:                    selectObject((PortalObjectId) null);
521:
522:                    // Get id
523:                    String id = (String) ae.getComponent().getAttributes().get(
524:                            "objectId");
525:
526:                    // Destroy the object
527:                    if (id != null) {
528:                        PortalObjectId poid = PortalObjectId.parse(id,
529:                                PortalObjectPath.LEGACY_BASE64_FORMAT);
530:                        PortalObject object = portalObjectContainer
531:                                .getObject(poid);
532:
533:                        if (object != null) {
534:                            selectObject(object.getParent());
535:
536:                            String stringMessage = object.getName()
537:                                    + " has successfully been destroyed";
538:
539:                            //
540:                            object.getParent().destroyChild(object.getName());
541:
542:                            FacesMessage message = new FacesMessage(
543:                                    FacesMessage.SEVERITY_INFO, stringMessage,
544:                                    stringMessage);
545:                            FacesContext.getCurrentInstance().addMessage(
546:                                    "status", message);
547:
548:                            selectedDeletingObject = null;
549:                        } else {
550:                            String stringMessage = "Cannot delete this already deleted object";
551:
552:                            FacesMessage message = new FacesMessage(
553:                                    FacesMessage.SEVERITY_ERROR, stringMessage,
554:                                    stringMessage);
555:                            FacesContext.getCurrentInstance().addMessage(
556:                                    "status", message);
557:                        }
558:                    }
559:                } catch (Exception e) {
560:                    e.printStackTrace();
561:                }
562:            }
563:
564:            public void refresh() {
565:                propertyAction = null;
566:                instanceItems = null;
567:                portalPageItems = null;
568:                portalItems = null;
569:                selectedObjectPath = null;
570:                selectedObject = null;
571:                selectedProperties = null;
572:                controlProperties = null;
573:                theme = null;
574:
575:                //
576:                if (selectedId == null) {
577:                    selectedId = new PortalObjectId(namespace,
578:                            PortalObjectPath.ROOT_PATH);
579:                }
580:
581:                //
582:                selectedObject = portalObjectContainer.getObject(selectedId);
583:
584:                //
585:                if (selectedObject.getType() == PortalObject.TYPE_PAGE) {
586:                    if (pageManager == null) {
587:                        pageManager = new PageManagerBean(layoutService,
588:                                portletDefinitionInvoker);
589:                    }
590:                    pageManager.page = (Page) selectedObject;
591:                }
592:
593:                //
594:                selectedProperties = new PropertiesBean(this );
595:                controlProperties = new ControlPropertiesBean(this );
596:                propertyAction = new PropertyAction(this );
597:
598:                //
599:                theme = new ThemeBean(selectedObject);
600:
601:                //
602:                Collection portals = getSelectedObject().getChildren(
603:                        PortalObject.PORTAL_MASK);
604:                ArrayList portalList = new ArrayList(portals.size() + 1);
605:                for (Iterator iterator = portals.iterator(); iterator.hasNext();) {
606:                    PortalObject o = (PortalObject) iterator.next();
607:                    SelectItem item = new SelectItem(o.getName());
608:                    portalList.add(item);
609:                }
610:                portalList.add(new SelectItem("", "no selection"));
611:                portalItems = (SelectItem[]) portalList
612:                        .toArray(new SelectItem[portalList.size()]);
613:
614:                //
615:                Collection pages = getSelectedObject().getChildren(
616:                        PortalObject.PAGE_MASK);
617:                ArrayList list = new ArrayList(pages.size() + 1);
618:                for (Iterator iterator = pages.iterator(); iterator.hasNext();) {
619:                    PortalObject o = (PortalObject) iterator.next();
620:                    SelectItem item = new SelectItem(o.getName());
621:                    list.add(item);
622:                }
623:                list.add(new SelectItem("", "no selection"));
624:                portalPageItems = (SelectItem[]) list
625:                        .toArray(new SelectItem[list.size()]);
626:
627:                //
628:                PortalObject o = getSelectedObject();
629:                ArrayList path = new ArrayList();
630:                while (o != null) {
631:                    path.add(o);
632:                    o = o.getParent();
633:                }
634:                Collections.reverse(path);
635:                selectedObjectPath = path;
636:
637:                //
638:                List tmp = new ArrayList(instanceContainer.getDefinitions());
639:                Collections.sort(tmp, InstanceManagerBean.INSTANCE_COMPARATOR);
640:                for (int i = 0; i < tmp.size(); i++) {
641:                    Instance instance = (Instance) tmp.get(i);
642:                    SelectItem item = new SelectItem(instance.getId());
643:                    tmp.set(i, item);
644:                }
645:                instanceItems = (SelectItem[]) tmp.toArray(new SelectItem[tmp
646:                        .size()]);
647:            }
648:
649:            public void processEvent(ActionEvent event) {
650:                if (event instanceof  PortletActionEvent) {
651:                    PortletActionEvent actionEvent = (PortletActionEvent) event;
652:                    Map actionParams = actionEvent.getParameterMap();
653:                    if (actionParams.get("content.action.select") != null) {
654:                        String[] uris = (String[]) actionParams
655:                                .get(CONTENT_URI);
656:                        if (uris != null && uris.length > 0) {
657:                            String uri = uris[0];
658:                            PortalObject po = getSelectedObject();
659:                            switch (po.getType()) {
660:                            case PortalObject.TYPE_WINDOW: {
661:                                Window window = (Window) po;
662:                                window.getContent().setURI(uri);
663:                                selectParentObject(event);
664:                                break;
665:                            }
666:                            }
667:                        }
668:                    }
669:                }
670:            }
671:
672:            /** The implication configure properly the page security for default access. */
673:            public void pageCreated(Page page) {
674:                Set constraints = Collections
675:                        .singleton(new RoleSecurityBinding(
676:                                PortalObjectPermission.VIEW_RECURSIVE_ACTION,
677:                                SecurityConstants.UNCHECKED_ROLE_NAME));
678:                getDomainConfigurator().setSecurityBindings(
679:                        page.getId()
680:                                .toString(PortalObjectPath.CANONICAL_FORMAT),
681:                        constraints);
682:            }
683:
684:            public class PortalObjectAuthorizationBean extends
685:                    AuthorizationBean {
686:
687:                public DomainConfigurator getDomainConfigurator() {
688:                    return PortalObjectManagerBean.this .getDomainConfigurator();
689:                }
690:
691:                protected String getURI() {
692:                    PortalObject po = getSelectedObject();
693:                    if (po != null) {
694:                        return po.getId().toString(
695:                                PortalObjectPath.CANONICAL_FORMAT);
696:                    } else {
697:                        return null;
698:                    }
699:                }
700:
701:                public SelectItem[] getAvailableActions() {
702:                    return new SelectItem[] {
703:                            new SelectItem("view", "View"),
704:                            new SelectItem("viewrecursive", "View Recursive"),
705:                            new SelectItem("personalize", "Personalize"),
706:                            new SelectItem("personalizerecursive",
707:                                    "Personalize Recursive") };
708:                }
709:
710:                public String submit() {
711:                    String stringMessage = "Security has been correctly updated on the page";
712:                    FacesMessage message = new FacesMessage(
713:                            FacesMessage.SEVERITY_INFO, stringMessage,
714:                            stringMessage);
715:                    FacesContext.getCurrentInstance().addMessage("status",
716:                            message);
717:
718:                    //
719:                    return "objects";
720:                }
721:
722:                public String cancel() {
723:                    return "objects";
724:                }
725:
726:                public RoleModule getRoleModule() {
727:                    return roleModule;
728:                }
729:            }
730:
731:            public String getPreviewURL() {
732:                //      try
733:                //      {
734:                //         //set up the root node
735:                //         PortalNode root = Navigation.getCurrentNode();
736:                //         for (; root.getParent() != null;)
737:                //         {
738:                //            root = root.getParent();
739:                //         }
740:                //
741:                //         //obtain the path to our node
742:                //         PortalObjectImpl object = (PortalObjectImpl)getSelectedObject();
743:                //         String path = object.getObjectNode().getPath();
744:                //
745:                //         //iterate to our point
746:                //         String[] nodes = path.split("\\.");
747:                //         PortalNode dest = root;
748:                //
749:                //         for (int i = 0; i < nodes.length; i++)
750:                //         {
751:                //            String s = nodes[i];
752:                //            dest = dest.getChild(s);
753:                //         }
754:                //
755:                //         //generate url
756:                //         JBossRenderResponse response = (JBossRenderResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
757:                //         String url = response.createRenderURL(dest).toString();
758:                //         return url;
759:                //      }
760:                //      catch (Exception e)
761:                //      {
762:                //         log.info("Failed to generate object preview link");
763:                //         e.printStackTrace();
764:                //      }
765:                //      //in case it fails let's point to some nice page ;)
766:                return "http://www.jboss.org";
767:            }
768:
769:            /**
770:             * Helper method to recognize object type in EL easily
771:             *
772:             * @return
773:             */
774:            public String getSelectedObjectType() {
775:                PortalObject object = getSelectedObject();
776:                if (object != null) {
777:                    switch (object.getType()) {
778:                    case PortalObject.TYPE_CONTEXT:
779:                        return "context";
780:                    case PortalObject.TYPE_PORTAL:
781:                        return "portal";
782:                    case PortalObject.TYPE_PAGE:
783:                        return "page";
784:                    case PortalObject.TYPE_WINDOW:
785:                        return "window";
786:                    }
787:                }
788:
789:                //to make it safe
790:                return "none";
791:            }
792:
793:            public ControlPropertiesBean getControlProperties() {
794:                return controlProperties;
795:            }
796:
797:            public SelectItem[] getListenerIds() {
798:                Set ids = listenerRegistry.getListenerIds();
799:                if (ids != null) {
800:                    SelectItem[] result = new SelectItem[ids.size() + 1];
801:                    int i = 1;
802:                    result[0] = new SelectItem("", "no bound listener");
803:                    for (Iterator idsIt = ids.iterator(); idsIt.hasNext();) {
804:                        result[i++] = new SelectItem(idsIt.next());
805:                    }
806:
807:                    return result;
808:                }
809:
810:                return null;
811:            }
812:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.