Author: julien(a)jboss.com
Date: 2007-04-25 15:40:14 -0400 (Wed, 25 Apr 2007)
New Revision: 7053
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
trunk/theme/src/main/org/jboss/portal/theme/LayoutServiceInfo.java
trunk/theme/src/main/org/jboss/portal/theme/ThemeServiceInfo.java
trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java
trunk/theme/src/main/org/jboss/portal/theme/impl/ThemeServiceImpl.java
Log:
moved theme code to theme place
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2007-04-25
19:19:43 UTC (rev 7052)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/render/RenderPageCommand.java 2007-04-25
19:40:14 UTC (rev 7053)
@@ -44,9 +44,7 @@
import org.jboss.portal.core.theme.WindowRendition;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.PortalTheme;
-import org.jboss.portal.theme.ServerRegistrationID;
import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.theme.ThemeService;
import org.jboss.portal.theme.PageService;
import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.theme.page.WindowResult;
@@ -58,8 +56,6 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
/**
* Render a full page.
@@ -263,41 +259,7 @@
private PortalTheme getTheme(String themeIdString)
{
- //
- ThemeService service = context.getController().getPageService().getThemeService();
-
- PortalTheme theme;
-
- // If the id is provided in the form of context.name then look up the theme via a
registration id
- if (themeIdString == null)
- {
- theme = service.getDefaultTheme();
- }
- else if (themeIdString.lastIndexOf(".") > 0)
- {
- ServerRegistrationID themeId =
ServerRegistrationID.createID(ServerRegistrationID.TYPE_THEME, parseId(themeIdString));
- theme = service.getTheme(themeId, true);
- }
- else
- {
- // Otherwise use the ordinary theme name provided and lookup the theme via the
name
- theme = service.getTheme(themeIdString, true);
- }
-
- // Last Chance
- if (theme == null)
- {
- theme = service.getTheme("renaissance", true);
- }
-
- // We don't like that situation
- if (theme == null)
- {
- throw new IllegalStateException("No Theme found for " +
themeIdString);
- }
-
- //
- return theme;
+ return
context.getController().getPageService().getThemeService().getThemeById(themeIdString);
}
/**
@@ -312,67 +274,6 @@
public static PortalLayout getLayout(LayoutService layoutService, Page page)
{
String layoutIdString = page.getProperty(ThemeConstants.PORTAL_PROP_LAYOUT);
-
- //
- PortalLayout layout;
-
- if (layoutIdString == null)
- {
- layout = layoutService.getDefaultLayout();
- }
- else if (layoutIdString.lastIndexOf(".") > 0)
- {
- // if the id is provided in the form of context.name then look up the layout via
a registration id
- ServerRegistrationID layoutID =
ServerRegistrationID.createID(ServerRegistrationID.TYPE_LAYOUT, parseId(layoutIdString));
- layout = layoutService.getLayout(layoutID, true);
- }
- else
- {
- // otherwise use the ordinary layout name provided and lookup the layout via the
name
- layout = layoutService.getLayout(layoutIdString, true);
- }
-
- // Last Chance
- if (layout == null)
- {
- layout = layoutService.getLayout("generic", true);
- }
-
- // We don't like that situation
- if (layout == null)
- {
- throw new IllegalStateException("NO LAYOUT FOUND FOR " +
layoutIdString);
- }
-
- //
- return layout;
+ return layoutService.getLayoutById(layoutIdString);
}
-
- /**
- * parse the provided String for '.' as a separator. For each token, add an
entry to a String[] that will be returned
- * as the result
- *
- * @param layoutIDString the string to be examined
- * @return an array of Strings
- */
- private static String[] parseId(String layoutIDString)
- {
- List names = new ArrayList();
- StringTokenizer tokens = new StringTokenizer(layoutIDString, ".");
- if (tokens.countTokens() > 1)
- {
- while (tokens.hasMoreElements())
- {
- names.add(tokens.nextToken());
- }
- }
- else
- {
- names.add(layoutIDString);
- }
-
- String[] id = new String[names.size()];
- names.toArray(id);
- return id;
- }
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/LayoutServiceInfo.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/LayoutServiceInfo.java 2007-04-25 19:19:43
UTC (rev 7052)
+++ trunk/theme/src/main/org/jboss/portal/theme/LayoutServiceInfo.java 2007-04-25 19:40:14
UTC (rev 7053)
@@ -25,7 +25,6 @@
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.common.util.ContentInfo;
-import org.jboss.portal.theme.PortalRenderSet;
import java.util.Collection;
@@ -57,6 +56,8 @@
*/
PortalLayout getLayout(String name, boolean defaultOnNull);
+ PortalLayout getLayoutById(String layoutIdString);
+
/**
* Get the render set for the provided layout.
*
Modified: trunk/theme/src/main/org/jboss/portal/theme/ThemeServiceInfo.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/ThemeServiceInfo.java 2007-04-25 19:19:43
UTC (rev 7052)
+++ trunk/theme/src/main/org/jboss/portal/theme/ThemeServiceInfo.java 2007-04-25 19:40:14
UTC (rev 7053)
@@ -54,6 +54,14 @@
PortalTheme getTheme(String name, boolean defaultOnNull);
/**
+ *
+ *
+ * @param themeId
+ * @return
+ */
+ PortalTheme getThemeById(String themeId);
+
+ /**
* Get a Collection of all registered themes.
*
* @return a Collection of all registered themes
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java 2007-04-25
19:19:43 UTC (rev 7052)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/LayoutServiceImpl.java 2007-04-25
19:40:14 UTC (rev 7053)
@@ -233,6 +233,43 @@
return null;
}
+ public PortalLayout getLayoutById(String layoutIdString)
+ {
+ //
+ PortalLayout layout;
+
+ if (layoutIdString == null)
+ {
+ layout = getDefaultLayout();
+ }
+ else if (layoutIdString.lastIndexOf(".") > 0)
+ {
+ // if the id is provided in the form of context.name then look up the layout via
a registration id
+ ServerRegistrationID layoutID =
ServerRegistrationID.createID(ServerRegistrationID.TYPE_LAYOUT,
ThemeServiceImpl.parseId(layoutIdString));
+ layout = getLayout(layoutID, true);
+ }
+ else
+ {
+ // otherwise use the ordinary layout name provided and lookup the layout via the
name
+ layout = getLayout(layoutIdString, true);
+ }
+
+ // Last Chance
+ if (layout == null)
+ {
+ layout = getLayout("generic", true);
+ }
+
+ // We don't like that situation
+ if (layout == null)
+ {
+ throw new IllegalStateException("NO LAYOUT FOUND FOR " +
layoutIdString);
+ }
+
+ //
+ return layout;
+ }
+
/**
* Remove the layout identified by the provided registration id.
*
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/ThemeServiceImpl.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/ThemeServiceImpl.java 2007-04-25
19:19:43 UTC (rev 7052)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/ThemeServiceImpl.java 2007-04-25
19:40:14 UTC (rev 7053)
@@ -24,8 +24,6 @@
import org.jboss.logging.Logger;
import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.theme.LayoutService;
-import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.PortalTheme;
import org.jboss.portal.theme.RuntimeContext;
import org.jboss.portal.theme.ServerRegistrationID;
@@ -42,6 +40,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.StringTokenizer;
/**
* TODO: A description of this class.
@@ -314,6 +313,42 @@
return null;
}
+ public PortalTheme getThemeById(String themeIdString)
+ {
+ PortalTheme theme;
+
+ // If the id is provided in the form of context.name then look up the theme via a
registration id
+ if (themeIdString == null)
+ {
+ theme = getDefaultTheme();
+ }
+ else if (themeIdString.lastIndexOf(".") > 0)
+ {
+ ServerRegistrationID themeId =
ServerRegistrationID.createID(ServerRegistrationID.TYPE_THEME, parseId(themeIdString));
+ theme = getTheme(themeId, true);
+ }
+ else
+ {
+ // Otherwise use the ordinary theme name provided and lookup the theme via the
name
+ theme = getTheme(themeIdString, true);
+ }
+
+ // Last Chance
+ if (theme == null)
+ {
+ theme = getTheme("renaissance", true);
+ }
+
+ // We don't like that situation
+ if (theme == null)
+ {
+ throw new IllegalStateException("No Theme found for " +
themeIdString);
+ }
+
+ //
+ return theme;
+ }
+
/** @see org.jboss.portal.theme.ThemeService#getThemes() */
public Collection getThemes()
{
@@ -325,4 +360,32 @@
{
return Collections.unmodifiableCollection(themeNames.keySet());
}
+
+ /**
+ * parse the provided String for '.' as a separator. For each token, add an
entry to a String[] that will be returned
+ * as the result
+ *
+ * @param layoutIDString the string to be examined
+ * @return an array of Strings
+ */
+ public static String[] parseId(String layoutIDString)
+ {
+ List names = new ArrayList();
+ StringTokenizer tokens = new StringTokenizer(layoutIDString, ".");
+ if (tokens.countTokens() > 1)
+ {
+ while (tokens.hasMoreElements())
+ {
+ names.add(tokens.nextToken());
+ }
+ }
+ else
+ {
+ names.add(layoutIDString);
+ }
+
+ String[] id = new String[names.size()];
+ names.toArray(id);
+ return id;
+ }
}