Author: julien(a)jboss.com
Date: 2008-06-26 19:53:59 -0400 (Thu, 26 Jun 2008)
New Revision: 11162
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletManagedModeInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/PortletManagedModeInfo.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerCapabilitiesInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerModeInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/CapabilitiesInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/ModeInfo.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/WindowStateInfo.java
Log:
- implement portlet managed mode in meta data
- implements custom portlet mode defined at the applciation level
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerCapabilitiesInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerCapabilitiesInfo.java 2008-06-26
16:27:34 UTC (rev 11161)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerCapabilitiesInfo.java 2008-06-26
23:53:59 UTC (rev 11162)
@@ -79,9 +79,14 @@
public void add(String contentType, Mode mode)
{
+ add(contentType, new ContainerModeInfo(mode));
+ }
+
+ public void add(String contentType, ContainerModeInfo mode)
+ {
try
{
- supportedModes.put(contentType, new ContainerModeInfo(mode));
+ supportedModes.put(contentType, mode);
}
catch (IllegalArgumentException e)
{
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-06-26
16:27:34 UTC (rev 11161)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerInfoBuilder.java 2008-06-26
23:53:59 UTC (rev 11162)
@@ -36,6 +36,7 @@
import org.jboss.portal.portlet.impl.metadata.PortletApplication20MetaData;
import org.jboss.portal.portlet.impl.metadata.PublicRenderParameterMetaData;
import org.jboss.portal.portlet.impl.metadata.UserAttributeMetaData;
+import org.jboss.portal.portlet.impl.metadata.CustomPortletModeMetaData;
import org.jboss.portal.portlet.impl.metadata.common.ContainerRuntimeMetaData;
import org.jboss.portal.portlet.impl.metadata.common.InitParamMetaData;
import org.jboss.portal.portlet.impl.metadata.event.EventDefinitionMetaData;
@@ -136,6 +137,9 @@
private static final Map<String, ContainerRuntimeMetaData>
EMPTY_CONTAINER_RUNTIME_OPTION_MAP = Collections.emptyMap();
/** . */
+ private static final Map<String, CustomPortletModeMetaData>
EMPTY_CUSTOM_PORTLET_MODES = Collections.emptyMap();
+
+ /** . */
private final PortletApplication10MetaData portletApplicationMD;
/** . */
@@ -157,11 +161,14 @@
private final Map<String, ContainerPortletInfo> portlets;
/** . */
- private final Logger log = Logger.getLogger(ContainerInfoBuilder.class);
+ private final Map<String, ContainerOptionInfo> applicationOptions;
/** . */
- private Map<String, ContainerOptionInfo> applicationOptions;
+ private final Map<Mode, ContainerModeInfo> customModes;
+ /** . */
+ private final Logger log = Logger.getLogger(ContainerInfoBuilder.class);
+
public ContainerInfoBuilder(
String portletApplicationId,
PortletApplication10MetaData portletApplicationMD,
@@ -173,6 +180,8 @@
this.events = new LinkedHashMap<QName, ContainerEventInfo>();
this.publicParameters = new LinkedHashMap<String, ContainerParameterInfo>();
this.portlets = new LinkedHashMap<String, ContainerPortletInfo>();
+ this.applicationOptions = new HashMap<String, ContainerOptionInfo>();
+ this.customModes = new HashMap<Mode, ContainerModeInfo>();
}
public ContainerPortletApplicationInfo getApplication()
@@ -233,6 +242,12 @@
tmp.setContainerRuntimeOptions(EMPTY_CONTAINER_RUNTIME_OPTION_MAP);
}
}
+
+ //
+ if (portletApplicationMD.getCustomPortletModes() == null)
+ {
+ portletApplicationMD.setCustomPortletModes(EMPTY_CUSTOM_PORTLET_MODES);
+ }
}
private void fixMetaData(PortletMetaData portletMD)
@@ -387,15 +402,11 @@
}
//
- applicationOptions = build(tmp.getContainerRuntimeOptions().values());
+ Map<String, ContainerOptionInfo> applicationOptions =
build(tmp.getContainerRuntimeOptions().values());
if (applicationOptions != null)
{
- applicationOptions = Collections.unmodifiableMap(applicationOptions);
+ this.applicationOptions.putAll(applicationOptions);
}
- else
- {
- applicationOptions = Collections.emptyMap();
- }
//
listeners = new
ArrayList<ContainerListenerInfo>(tmp.getListeners().size());
@@ -412,6 +423,49 @@
ContainerFilterInfo filter = build(filterMD);
allFilters.put(filter.getName(), filter);
}
+
+ // Build custom mode infos for reuse in portlet info
+ for (CustomPortletModeMetaData customPortletModeMD :
portletApplicationMD.getCustomPortletModes().values())
+ {
+ Mode mode = Mode.create(customPortletModeMD.getPortletMode());
+
+ //
+ LocalizedString description = customPortletModeMD.getDescription();
+
+ //
+ ContainerModeInfo modeInfo;
+ if (customPortletModeMD.isPortalManaged())
+ {
+ if (description != null)
+ {
+ modeInfo = new ContainerModeInfo(mode, description);
+ }
+ else
+ {
+ modeInfo = new ContainerModeInfo(mode);
+ }
+ }
+ else
+ {
+ ResourceBundleManager bundleMgr = context.getBundleManager();
+
+ //
+ LocalizedString displayName =
bundleMgr.getLocalizedValue("javax.portlet.app.custom-portlet-mode." + mode +
".decoration-name", "" + mode);
+
+ //
+ if (description != null)
+ {
+ modeInfo = new ContainerPortletManagedModeInfo(mode, description,
displayName);
+ }
+ else
+ {
+ modeInfo = new ContainerPortletManagedModeInfo(mode, displayName);
+ }
+ }
+
+ //
+ customModes.put(mode, modeInfo);
+ }
}
//
@@ -793,7 +847,17 @@
// Then process each mode
for (PortletModeMetaData modeMD : supportsMD.getPortletModes())
{
- capabilities.add(mimeType, modeMD.getPortletMode());
+ ContainerModeInfo mode = customModes.get(modeMD.getPortletMode());
+
+ //
+ if (mode != null)
+ {
+ capabilities.add(mimeType, mode);
+ }
+ else
+ {
+ capabilities.add(mimeType, modeMD.getPortletMode());
+ }
}
//
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerModeInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerModeInfo.java 2008-06-26
16:27:34 UTC (rev 11161)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerModeInfo.java 2008-06-26
23:53:59 UTC (rev 11162)
@@ -43,6 +43,26 @@
/** . */
private final Mode mode;
+ /** . */
+ private final LocalizedString description;
+
+ public ContainerModeInfo(Mode mode, LocalizedString description)
+ {
+ if (mode == null)
+ {
+ throw new IllegalArgumentException("Specified mode cannot be null!");
+ }
+
+ //
+ this.mode = mode;
+ this.description = description;
+ }
+
+ public ContainerModeInfo(Mode mode)
+ {
+ this(mode, DEFAULT_DESCRIPTION);
+ }
+
public boolean equals(Object o)
{
if (this == o)
@@ -64,15 +84,6 @@
return mode.hashCode();
}
- public ContainerModeInfo(Mode mode)
- {
- if (mode == null)
- {
- throw new IllegalArgumentException("Specified mode cannot be null!");
- }
- this.mode = mode;
- }
-
public LocalizedString getDescription()
{
return DEFAULT_DESCRIPTION; // fix-me
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletManagedModeInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletManagedModeInfo.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletManagedModeInfo.java 2008-06-26
23:53:59 UTC (rev 11162)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.info;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.portlet.info.PortletManagedModeInfo;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ContainerPortletManagedModeInfo extends ContainerModeInfo implements
PortletManagedModeInfo
+{
+
+ /** . */
+ private LocalizedString displayName;
+
+ public ContainerPortletManagedModeInfo(Mode mode, LocalizedString description,
LocalizedString displayName)
+ {
+ super(mode, description);
+
+ //
+ this.displayName = displayName;
+ }
+
+ public ContainerPortletManagedModeInfo(Mode mode, LocalizedString displayName)
+ {
+ super(mode);
+
+ //
+ this.displayName = displayName;
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return displayName;
+ }
+}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/CapabilitiesInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/CapabilitiesInfo.java 2008-06-26
16:27:34 UTC (rev 11161)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/CapabilitiesInfo.java 2008-06-26
23:53:59 UTC (rev 11162)
@@ -23,6 +23,8 @@
package org.jboss.portal.portlet.info;
import org.jboss.portal.common.net.media.MediaType;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
import java.util.Set;
import java.util.Locale;
@@ -51,6 +53,13 @@
Set<ModeInfo> getAllModes();
/**
+ *
+ * @param mode
+ * @return
+ */
+ // ModeInfo getMode(Mode mode);
+
+ /**
* Retrieves the portlet modes supported by the associated Portlet for the specified
Media type.
*
* @param mediaType the media type
@@ -74,6 +83,13 @@
Set<WindowStateInfo> getWindowStates(MediaType mimeType);
/**
+ *
+ * @param windowState
+ * @return
+ */
+ // WindowStateInfo getWindowState(WindowState windowState);
+
+ /**
* Retrieves all the locales supported by the associated Portlet.
*
* @return the Set of supported {@link java.util.Locale}s
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/ModeInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/ModeInfo.java 2008-06-26
16:27:34 UTC (rev 11161)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/ModeInfo.java 2008-06-26
23:53:59 UTC (rev 11162)
@@ -24,7 +24,10 @@
import org.jboss.portal.Mode;
import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.net.media.MediaType;
+import java.util.Set;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 6818 $
@@ -52,4 +55,7 @@
* @return the associated Mode name.
*/
String getModeName();
+
+
+ //Set<MediaType> getMediaTypes();
}
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/PortletManagedModeInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/PortletManagedModeInfo.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/PortletManagedModeInfo.java 2008-06-26
23:53:59 UTC (rev 11162)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.info;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+
+/**
+ * Extends the mode info interface to add the notion of portlet managed mode.
+ *
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface PortletManagedModeInfo extends ModeInfo
+{
+
+ /**
+ * Returns the display name of the mode.
+ *
+ * @return the display name
+ */
+ LocalizedString getDisplayName();
+}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/WindowStateInfo.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/WindowStateInfo.java 2008-06-26
16:27:34 UTC (rev 11161)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/info/WindowStateInfo.java 2008-06-26
23:53:59 UTC (rev 11162)
@@ -24,7 +24,10 @@
import org.jboss.portal.WindowState;
import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.common.net.media.MediaType;
+import java.util.Set;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 6818 $
@@ -52,4 +55,10 @@
* @return the associated window state name.
*/
String getWindowStateName();
+
+ /**
+ *
+ * @return
+ */
+ // Set<MediaType> getMediaTypes();
}