1 5 6 11 package org.exoplatform.services.portletcontainer.impl.portletAPIImp; 12 13 import java.util.Enumeration ; 14 import java.util.HashMap ; 15 import java.util.Iterator ; 16 import java.util.List ; 17 import java.util.Locale ; 18 import java.util.Map ; 19 import java.util.ResourceBundle ; 20 import java.util.Vector ; 21 22 import javax.portlet.PortletConfig; 23 import javax.portlet.PortletContext; 24 import org.exoplatform.container.PortalContainer; 25 import org.exoplatform.services.portletcontainer.impl.portletAPIImp.bundle.ResourceBundleManager; 26 import org.exoplatform.services.portletcontainer.pci.model.*; 27 28 29 30 34 public class PortletConfigImp implements PortletConfig { 35 36 private Portlet portletDatas_; 37 private Map params_ = new HashMap (); 38 private PortletContext portletContext; 39 private List securityContraints; 40 private List userAttributes_; 41 private List customPortletModes_; 42 private List customWindowStates_; 43 44 public PortletConfigImp(Portlet portletDatas, 45 PortletContext portletContext, 46 List securityContraints, 47 List userAttributes, 48 List customPortletModes, 49 List customWindowStates) { 50 this.portletDatas_ = portletDatas; 51 this.portletContext = portletContext; 52 this.securityContraints = securityContraints; 53 this.userAttributes_ = userAttributes; 54 this. customPortletModes_ = customPortletModes; 55 this.customWindowStates_ = customWindowStates; 56 57 List l = portletDatas.getInitParam(); 59 for (Iterator iterator = l.iterator(); iterator.hasNext();) { 60 InitParam initParam = (InitParam) iterator.next(); 61 params_.put(initParam.getName(), initParam); 62 } 63 } 64 65 public String getPortletName() { return portletDatas_.getPortletName();} 66 67 public PortletContext getPortletContext() { 68 return portletContext; 69 } 70 71 public ResourceBundle getResourceBundle(Locale locale) { 72 ResourceBundleManager manager = (ResourceBundleManager)PortalContainer.getInstance(). 73 getComponentInstanceOfType(ResourceBundleManager.class); 74 return manager.lookupBundle(portletDatas_ , locale); 75 } 76 77 public String getInitParameter(String name) { 78 if (name == null ) { 79 throw new IllegalArgumentException ("You cannot have null as a paramter") ; 80 } 81 InitParam initParam = (InitParam) params_.get(name); 82 if (initParam != null) return initParam.getValue(); 83 return null; 84 } 85 86 public Enumeration getInitParameterNames() { 87 return new Vector (params_.keySet()).elements(); 88 } 89 90 public Portlet getPortletDatas() { return portletDatas_; } 91 92 public boolean needsSecurityContraints(String portletName) { 93 for (Iterator iterator = securityContraints.iterator(); iterator.hasNext();) { 94 SecurityConstraint securityConstraint = (SecurityConstraint) iterator.next(); 95 List l = securityConstraint.getPortletCollection().getPortletName(); 96 for (Iterator iterator2 = l.iterator(); iterator2.hasNext();) { 97 String portlet = (String ) iterator2.next(); 98 if(portlet.equals(portletName)) return true; 99 } 100 } 101 return false; 102 } 103 } | Popular Tags |