Author: chris.laprun(a)jboss.com
Date: 2010-06-28 03:47:16 -0400 (Mon, 28 Jun 2010)
New Revision: 3494
Modified:
portal/branches/wsrp2-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
portal/branches/wsrp2-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java
Log:
- Cleaned code up. getSupportModes semantics with respect to view and config needs to be
checked.
Modified:
portal/branches/wsrp2-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java
===================================================================
---
portal/branches/wsrp2-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-06-28
07:45:06 UTC (rev 3493)
+++
portal/branches/wsrp2-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortlet.java 2010-06-28
07:47:16 UTC (rev 3494)
@@ -110,6 +110,7 @@
{
protected static final Log log = ExoLogger.getLogger("portal:UIPortlet");
+ private final static boolean debug = log.isDebugEnabled();
static final public String DEFAULT_THEME =
"Default:DefaultTheme::Vista:VistaTheme::Mac:MacTheme";
@@ -147,14 +148,6 @@
private WindowState currentWindowState_ = WindowState.NORMAL;
- private List<String> supportModes_;
-
- private List<QName> supportedProcessingEvents_;
-
- private List<QName> supportedPublishingEvents_;
-
- private List<String> supportedPublicParams_;
-
private boolean portletInPortal_ = true;
private StateString navigationalState;
@@ -340,26 +333,6 @@
currentWindowState_ = state;
}
- public List<QName> getSupportedProcessingEvents()
- {
- return supportedProcessingEvents_;
- }
-
- public void setSupportedProcessingEvents(List<QName> supportedProcessingEvents)
- {
- supportedProcessingEvents_ = supportedProcessingEvents;
- }
-
- public List<String> getSupportedPublicRenderParameters()
- {
- return supportedPublicParams_;
- }
-
- public void setSupportedPublicRenderParameters(List<String>
supportedPublicRenderParameters)
- {
- supportedPublicParams_ = supportedPublicRenderParameters;
- }
-
public String getDisplayTitle()
{
String title = getTitle();
@@ -424,119 +397,39 @@
public List<String> getSupportModes()
{
- if (supportModes_ != null)
- {
- return supportModes_;
- }
-
- List<String> supportModes = new ArrayList<String>();
-
+ // todo: use a Google Collections Lists.transform or similar?
org.gatein.pc.api.Portlet portlet = getProducedOfferedPortlet();
+ Set<ModeInfo> modes =
portlet.getInfo().getCapabilities().getModes(MediaType.TEXT_HTML);
+ int modeNb = modes.size();
+ List<String> supportModes = new ArrayList<String>(modeNb);
- // if we couldn't get the portlet that just return an empty modes list
- if (portlet == null)
+ for (ModeInfo mode : modes)
{
- return supportModes;
+ // todo: PortalDataMapper seemed like "config" mode was supposed to be
handled differently, albeit with a wrong implementation. Needs to be done?
+ supportModes.add(mode.getModeName());
}
- Set<ModeInfo> modes =
portlet.getInfo().getCapabilities().getModes(MediaType.create("text/html"));
- Iterator<ModeInfo> modeIter = modes.iterator();
- while (modeIter.hasNext())
+ // todo: check that this is the proper behavior
+ if(modeNb > 1)
{
- ModeInfo info = modeIter.next();
- supportModes.add(info.getModeName());
- }
-
- if (supportModes.size() > 0)
- {
supportModes.remove("view");
}
- setSupportModes(supportModes);
return supportModes;
}
- public void setSupportModes(List<String> supportModes)
- {
- supportModes_ = supportModes;
- }
-
/**
* Tells, according to the info located in portlet.xml, wether this portlet can handle
a portlet event with the QName
* given as the method argument
*/
public boolean supportsProcessingEvent(QName name)
{
-
- if (supportedProcessingEvents_ == null)
- {
-
- org.gatein.pc.api.Portlet portlet = getProducedOfferedPortlet();
-
- if (portlet == null)
- {
- log.info("Could not find portlet with ID : " +
producerOfferedPortletContext.getId());
- return false;
- }
-
- Map<QName, EventInfo> consumedEvents =
- (Map<QName,
EventInfo>)portlet.getInfo().getEventing().getConsumedEvents();
-
- if (consumedEvents == null)
- {
- return false;
- }
-
- supportedProcessingEvents_ = new
ArrayList<QName>(consumedEvents.keySet());
- }
-
- for (Iterator<QName> iter = supportedProcessingEvents_.iterator();
iter.hasNext();)
- {
- QName eventName = iter.next();
- if (eventName.equals(name))
- {
- log.info("The Portlet " + producerOfferedPortletContext + "
supports comsuming the event : " + name);
- return true;
- }
- }
- log.info("The portlet " + producerOfferedPortletContext + "
doesn't support consuming the event : " + name);
- return false;
+ return
getProducedOfferedPortlet().getInfo().getEventing().getConsumedEvents().containsKey(name);
}
public boolean supportsPublishingEvent(QName name)
{
- if (supportedPublishingEvents_ == null)
- {
- org.gatein.pc.api.Portlet portlet = getProducedOfferedPortlet();
-
- if (portlet == null)
- {
- log.info("Could not find portlet with ID : " +
producerOfferedPortletContext.getId());
- return false;
- }
-
- Map<QName, EventInfo> producedEvents =
- (Map<QName,
EventInfo>)portlet.getInfo().getEventing().getProducedEvents();
-
- if (producedEvents == null)
- {
- return false;
- }
-
- supportedPublishingEvents_ = new
ArrayList<QName>(producedEvents.keySet());
- }
-
- for (Iterator<QName> iter = supportedPublishingEvents_.iterator();
iter.hasNext();)
- {
- QName eventName = iter.next();
- if (eventName.equals(name))
- {
- log.info("The Portlet " + producerOfferedPortletContext + "
supports producing the event : " + name);
- return true;
- }
- }
- log.info("The portlet " + producerOfferedPortletContext + "
doesn't support producing the event : " + name);
- return false;
+ return
getProducedOfferedPortlet().getInfo().getEventing().getProducedEvents().containsKey(name);
}
/**
@@ -545,42 +438,7 @@
*/
public boolean supportsPublicParam(String supportedPublicParam)
{
- if (supportedPublicParams_ == null)
- {
-
- //
- if (producedOfferedPortlet == null)
- {
- log.info("Could not find portlet with ID : " +
producerOfferedPortletContext.getId());
- return false;
- }
-
- //
- Collection<ParameterInfo> parameters =
-
(Collection<ParameterInfo>)producedOfferedPortlet.getInfo().getNavigation().getPublicParameters();
- supportedPublicParams_ = new ArrayList<String>();
- for (ParameterInfo parameter : parameters)
- {
- supportedPublicParams_.add(parameter.getId());
- }
- }
-
- //
- for (String publicParam : supportedPublicParams_)
- {
- if (publicParam.equals(supportedPublicParam))
- {
- if (log.isDebugEnabled())
- {
- log.debug("The Portlet " +
producerOfferedPortletContext.getId()
- + " supports the public render parameter : " +
supportedPublicParam);
- }
- return true;
- }
- }
-
- //
- return false;
+ return
getProducedOfferedPortlet().getInfo().getNavigation().getPublicParameter(supportedPublicParam)
!= null;
}
/**
Modified:
portal/branches/wsrp2-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java
===================================================================
---
portal/branches/wsrp2-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java 2010-06-28
07:45:06 UTC (rev 3493)
+++
portal/branches/wsrp2-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/util/PortalDataMapper.java 2010-06-28
07:47:16 UTC (rev 3494)
@@ -252,35 +252,6 @@
if (model.getAccessPermissions() != null)
uiPortlet.setAccessPermissions(model.getAccessPermissions());
uiPortlet.setModifiable(model.isModifiable());
-
- Portlet portlet = uiPortlet.getProducedOfferedPortlet();
- if (portlet == null || portlet.getInfo() == null)
- return;
-
- PortletInfo portletInfo = portlet.getInfo();
-
- /*
- * Define which portlet modes the portlet supports and hence should be shown
- * in the portlet info bar
- */
- Set<ModeInfo> modes =
portletInfo.getCapabilities().getModes(MediaType.create("text/html"));
- List<String> supportModes = new ArrayList<String>();
- for (ModeInfo modeInfo : modes)
- {
- String modeName = modeInfo.getModeName().toLowerCase();
- if ("config".equals(modeInfo.getModeName()))
- {
- supportModes.add(modeName);
- }
- else
- {
- supportModes.add(modeName);
- }
- }
-
- if (supportModes.size() > 1)
- supportModes.remove("view");
- uiPortlet.setSupportModes(supportModes);
}
public static void toUIContainer(UIContainer uiContainer, Container model) throws
Exception
Show replies by date