Author: weaver
Date: Tue Dec 6 17:01:12 2005
New Revision: 354638
URL: http://svn.apache.org/viewcvs?rev=354638&view=rev
Log:
Added dynamic listing to the DecorationFactoryImpl
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationFactoryImpl.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/DecorationFactory.java
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationFactoryImpl.java
URL:
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationFactoryImpl.java?rev=354638&r1=354637&r2=354638&view=diff
==============================================================================
---
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationFactoryImpl.java
(original)
+++
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationFactoryImpl.java
Tue Dec 6 17:01:12 2005
@@ -17,11 +17,14 @@
import java.io.IOException;
import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
+import java.util.Set;
import javax.servlet.ServletContext;
@@ -53,6 +56,12 @@
private final PortletRegistry registry;
private ServletContext servletContext;
+
+ private Set layoutDecorationsDir = Collections.EMPTY_SET;
+ private Set portletDecorationsDir = Collections.EMPTY_SET;
+
+ private Set layoutDecorationsList = Collections.EMPTY_SET;;
+ private Set portletDecorationsList = Collections.EMPTY_SET;;
public DecorationFactoryImpl(String decorationsPath, ResourceValidator
validator, String defaultLayoutDecorator, String defaultPortletDecorator)
{
@@ -235,18 +244,16 @@
*
* @return A list of page decorations of type <code>Decoration</code>
*/
- public List getPageDecorations(RequestContext request)
+ public Set getPageDecorations(RequestContext request)
{
- List list = new LinkedList();
- /// TODO: hard code until Scotts commits arrive with new directory
format
- list.add("clear");
- list.add("jetspeed");
- list.add("jscookmenu");
- list.add("metal");
- list.add("minty-blue");
- list.add("simple");
- list.add("tigris");
- return list;
+ Set decorations =
servletContext.getResourcePaths(decorationsPath.toString()+"/layout");
+ if(!layoutDecorationsDir.equals(decorations))
+ {
+ layoutDecorationsList = getListing(decorations);
+ layoutDecorationsDir = decorations;
+
+ }
+ return layoutDecorationsList;
}
/**
@@ -254,20 +261,16 @@
*
* @return A list of portlet decorations of type <code>String</code>
*/
- public List getPortletDecorations(RequestContext request)
+ public Set getPortletDecorations(RequestContext request)
{
- List list = new LinkedList();
- /// TODO: hard code until Scotts commits arrive with new directory
format
- list.add("blue-gradient");
- list.add("clear");
- list.add("gray-gradient");
- list.add("gray-gradient-noborder");
- list.add("jetspeed");
- list.add("metal");
- list.add("minty-blue");
- list.add("pretty-single-portlet");
- list.add("tigris");
- return list;
+ Set decorations =
servletContext.getResourcePaths(decorationsPath.toString()+"/portlet");
+ if(!portletDecorationsDir.equals(decorations))
+ {
+ portletDecorationsList = getListing(decorations);
+ portletDecorationsDir = decorations;
+
+ }
+ return portletDecorationsList;
}
/**
@@ -296,6 +299,22 @@
}
return list;
+ }
+
+ protected Set getListing(Set rawList)
+ {
+ Iterator itr = rawList.iterator();
+ Set filteredList = new HashSet();
+ while(itr.hasNext())
+ {
+ Path path = new Path((String) itr.next());
+ if(path.getFileName() == null &&
validator.resourceExists(path.toString()+"decorator.properties"))
+ {
+ int offset = path.length() - 1;
+ filteredList.add(path.getSegment(offset));
+ }
+ }
+ return filteredList;
}
}
Modified:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/DecorationFactory.java
URL:
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/DecorationFactory.java?rev=354638&r1=354637&r2=354638&view=diff
==============================================================================
---
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/DecorationFactory.java
(original)
+++
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/DecorationFactory.java
Tue Dec 6 17:01:12 2005
@@ -16,6 +16,7 @@
package org.apache.jetspeed.decoration;
import java.util.List;
+import java.util.Set;
import org.apache.jetspeed.om.page.Fragment;
import org.apache.jetspeed.om.page.Page;
@@ -117,14 +118,14 @@
*
* @return A list of page decorations of type <code>String</code>
*/
- List getPageDecorations(RequestContext request);
+ Set getPageDecorations(RequestContext request);
/**
* Get the portal-wide list of portlet decorations.
*
* @return A list of portlet decorations of type <code>String</code>
*/
- List getPortletDecorations(RequestContext request);
+ Set getPortletDecorations(RequestContext request);
/**
* Get the portal-wide list of available layouts.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]