1 16 package org.apache.cocoon.portal.pluto; 17 18 import java.util.HashSet ; 19 import java.util.Iterator ; 20 21 import javax.portlet.PortletMode; 22 import javax.portlet.WindowState; 23 24 import org.apache.avalon.framework.service.ServiceManager; 25 import org.apache.cocoon.portal.coplet.CopletInstanceData; 26 import org.apache.cocoon.portal.pluto.om.PortletEntityImpl; 27 import org.apache.pluto.om.window.PortletWindow; 28 import org.apache.pluto.services.information.DynamicInformationProvider; 29 import org.apache.pluto.services.information.PortletActionProvider; 30 import org.apache.pluto.services.information.PortletURLProvider; 31 import org.apache.pluto.services.information.ResourceURLProvider; 32 33 40 public class DynamicInformationProviderImpl 41 implements DynamicInformationProvider { 42 43 44 protected final ServiceManager manager; 45 46 47 protected final PortalContextProviderImpl provider; 48 49 52 public DynamicInformationProviderImpl(ServiceManager manager, 53 PortalContextProviderImpl provider) { 54 this.manager = manager; 55 this.provider = provider; 56 } 57 58 61 public PortletURLProvider getPortletURLProvider(PortletWindow portletWindow) { 62 return new PortletURLProviderImpl(portletWindow, this.manager); 63 } 64 65 68 public ResourceURLProvider getResourceURLProvider(PortletWindow portletWindow) { 69 return new ResourceURLProviderImpl(this.provider); 70 } 71 72 75 public PortletActionProvider getPortletActionProvider(PortletWindow portletWindow) { 76 return new PortletActionProviderImpl(portletWindow); 77 } 78 79 82 public PortletMode getPortletMode(PortletWindow portletWindow) { 83 final CopletInstanceData cid = ((PortletEntityImpl)portletWindow.getPortletEntity()).getCopletInstanceData(); 84 PortletMode pm = (PortletMode) cid.getTemporaryAttribute("portlet-mode"); 85 if ( pm == null ) { 86 pm = PortletMode.VIEW; 87 } 88 return pm; 89 } 90 91 94 public PortletMode getPreviousPortletMode(PortletWindow portletWindow) { 95 final CopletInstanceData cid = ((PortletEntityImpl)portletWindow.getPortletEntity()).getCopletInstanceData(); 96 PortletMode pm = (PortletMode) cid.getTemporaryAttribute("previous-portlet-mode"); 97 return pm; 98 } 99 100 103 public WindowState getWindowState(PortletWindow portletWindow) { 104 final CopletInstanceData cid = ((PortletEntityImpl)portletWindow.getPortletEntity()).getCopletInstanceData(); 105 WindowState ws = (WindowState) cid.getTemporaryAttribute("window-state"); 106 if ( ws == null ) { 107 ws = WindowState.NORMAL; 108 } 109 return ws; 110 } 111 112 115 public WindowState getPreviousWindowState(PortletWindow portletWindow) { 116 final CopletInstanceData cid = ((PortletEntityImpl)portletWindow.getPortletEntity()).getCopletInstanceData(); 117 WindowState ws = (WindowState) cid.getTemporaryAttribute("previous-window-state"); 118 return ws; 119 } 120 121 124 public String getResponseContentType() { 125 return "text/html"; 126 } 127 128 static protected final HashSet responseMimeTypes = new HashSet (); 129 130 static { 131 responseMimeTypes.add("text/html"); 132 } 133 134 137 public Iterator getResponseContentTypes() { 138 return responseMimeTypes.iterator(); 139 } 140 141 144 public boolean isPortletModeAllowed(PortletMode mode) { 145 return this.provider.getSupportedPortletModes().contains(mode); 146 } 147 148 151 public boolean isWindowStateAllowed(WindowState state) { 152 return this.provider.getSupportedWindowStates().contains(state); 153 } 154 155 } 156 | Popular Tags |