1 16 19 20 package org.apache.pluto.portalImpl.core; 21 22 import java.util.Enumeration ; 23 import java.util.HashMap ; 24 import java.util.Vector ; 25 26 import javax.portlet.PortletMode; 27 import javax.portlet.WindowState; 28 29 import org.apache.pluto.portalImpl.services.config.Config; 30 import org.apache.pluto.services.information.PortalContextProvider; 31 32 public class PortalContextProviderImpl implements PortalContextProvider { 33 34 35 36 private String info = null; 37 38 39 private Vector modes; 40 41 42 private Vector states; 43 44 45 private HashMap properties = new HashMap (); 46 47 48 public PortalContextProviderImpl() 49 { 50 modes = getDefaultModes(); 52 states = getDefaultStates(); 54 info = Config.getParameters().getString("portaldriver.info"); 56 } 57 58 60 public java.lang.String getProperty(java.lang.String name) 61 { 62 if (name == null) { 63 throw new IllegalArgumentException ("Property name == null"); 64 } 65 66 return(String ) properties.get(name); 67 } 68 69 70 public java.util.Collection getPropertyNames() 71 { 72 return properties.keySet(); 73 } 74 75 76 public java.util.Collection getSupportedPortletModes() 77 { 78 return modes; 79 } 80 81 82 public java.util.Collection getSupportedWindowStates() 83 { 84 return states; 85 } 86 87 88 public String getPortalInfo() 89 { 90 return info; 91 } 92 93 95 private Vector getDefaultModes() 96 { 97 98 Vector m = new Vector (); 99 100 String [] supportedModes = Config.getParameters().getStrings("supported.portletmode"); 101 102 for (int i=0; i<supportedModes.length; i++) { 103 m.add(new PortletMode(supportedModes[i].toString().toLowerCase())); 104 } 105 106 return m; 107 } 108 109 private Vector getDefaultStates() 110 { 111 Vector s = new Vector (); 112 113 String [] supportedStates = Config.getParameters().getStrings("supported.windowstate"); 114 115 for (int i=0; i<supportedStates.length; i++) { 116 s.add(new WindowState(supportedStates[i].toString().toLowerCase())); 117 } 118 119 return s; 120 } 121 122 124 126 public void setProperty(String name, String value) 127 { 128 if (name == null) { 129 throw new IllegalArgumentException ("Property name == null"); 130 } 131 132 properties.put(name, value); 133 } 134 135 136 public void setSupportedPortletModes(Enumeration portletModes) 138 { 139 Vector v = new Vector (); 140 while (portletModes.hasMoreElements()) { 141 v.add(portletModes.nextElement()); 142 } 143 modes = v; 144 } 145 146 public void setSupportedWindowStates(Enumeration windowStates) 148 { 149 Vector v = new Vector (); 150 while (windowStates.hasMoreElements()) { 151 v.add(windowStates.nextElement()); 152 } 153 states = v; 154 } 155 156 164 public void reset(String portalInfo) 165 { 166 info = new String (portalInfo); 167 168 modes = getDefaultModes(); 170 states = getDefaultStates(); 172 173 properties.clear(); 174 } 175 176 177 178 } 179 | Popular Tags |