001
014
015 package com.liferay.portlet;
016
017 import com.liferay.portal.kernel.portlet.LiferayPortletMode;
018 import com.liferay.portal.kernel.portlet.LiferayWindowState;
019 import com.liferay.portal.kernel.util.ReleaseInfo;
020
021 import java.util.ArrayList;
022 import java.util.Collections;
023 import java.util.Enumeration;
024 import java.util.List;
025 import java.util.Properties;
026
027 import javax.portlet.PortalContext;
028 import javax.portlet.PortletMode;
029 import javax.portlet.WindowState;
030
031
034 public class PortalContextImpl implements PortalContext {
035
036 static Properties properties = new Properties();
037 static List<PortletMode> portletModes = new ArrayList<PortletMode>();
038 static List<WindowState> windowStates = new ArrayList<WindowState>();
039
040 static {
041 properties.setProperty(
042 MARKUP_HEAD_ELEMENT_SUPPORT, Boolean.TRUE.toString());
043
044 portletModes.add(PortletMode.EDIT);
045 portletModes.add(PortletMode.HELP);
046 portletModes.add(PortletMode.VIEW);
047 portletModes.add(LiferayPortletMode.ABOUT);
048 portletModes.add(LiferayPortletMode.CONFIG);
049 portletModes.add(LiferayPortletMode.EDIT_DEFAULTS);
050 portletModes.add(LiferayPortletMode.PREVIEW);
051 portletModes.add(LiferayPortletMode.PRINT);
052
053 windowStates.add(WindowState.MAXIMIZED);
054 windowStates.add(WindowState.MINIMIZED);
055 windowStates.add(WindowState.NORMAL);
056 windowStates.add(LiferayWindowState.EXCLUSIVE);
057 windowStates.add(LiferayWindowState.POP_UP);
058 }
059
060 public static boolean isSupportedPortletMode(PortletMode portletMode) {
061 return portletModes.contains(portletMode);
062 }
063
064 public static boolean isSupportedWindowState(WindowState windowState) {
065 return windowStates.contains(windowState);
066 }
067
068 @Override
069 public String getPortalInfo() {
070 return ReleaseInfo.getReleaseInfo();
071 }
072
073 @Override
074 public String getProperty(String name) {
075 if (name == null) {
076 throw new IllegalArgumentException();
077 }
078
079 return properties.getProperty(name);
080 }
081
082 @Override
083 public Enumeration<String> getPropertyNames() {
084 return (Enumeration<String>)properties.propertyNames();
085 }
086
087 @Override
088 public Enumeration<PortletMode> getSupportedPortletModes() {
089 return Collections.enumeration(portletModes);
090 }
091
092 @Override
093 public Enumeration<WindowState> getSupportedWindowStates() {
094 return Collections.enumeration(windowStates);
095 }
096
097 }