Author: smilek
Date: Wed Feb 21 13:30:33 2007
New Revision: 510239
URL: http://svn.apache.org/viewvc?view=rev&rev=510239
Log:
added support for decorations (layout and portlet) to optionally support
jetspeed desktop (support for near parallel desktop-themes and desktop
windowthemes has been removed)
Modified:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/Decoration.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/DecorationFactory.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/Theme.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/desktop/JetspeedDesktop.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/desktop/JetspeedDesktopContext.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/headerresource/HeaderResource.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/headerresource/HeaderResourceLib.java
Modified:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/Decoration.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/Decoration.java?view=diff&rev=510239&r1=510238&r2=510239
==============================================================================
---
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/Decoration.java
(original)
+++
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/Decoration.java
Wed Feb 21 13:30:33 2007
@@ -16,6 +16,8 @@
package org.apache.jetspeed.decoration;
import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
/**
*
@@ -25,12 +27,31 @@
public interface Decoration
{
/** Default style sheet location */
- String DEFAULT_STYLE_SHEET = "css/styles.css";
+ String DEFAULT_COMMON_STYLE_SHEET = "css/styles.css";
+ String DEFAULT_PORTAL_STYLE_SHEET = "css/portal.css";
+ String DEFAULT_DESKTOP_STYLE_SHEET = "css/desktop.css";
- /** Decoration configruation filename */
+ /** Decoration configuration filename */
String CONFIG_FILE_NAME = "decorator.properties";
+
+ /** Decoration desktop configuration filename */
+ String CONFIG_DESKTOP_FILE_NAME = "decoratordesktop.properties";
+
+ /** Property which indicates whether or not decoration supports desktop
mode */
+ String DESKTOP_SUPPORTED_PROPERTY = "desktop.supported";
+
+ /**
+ * Property for specifying the base CSS class to be used to
+ * create a proper CSS cascade and style isolation for a decoration.
+ */
+ String BASE_CSS_CLASS_PROP = "base.css.class";
+
+ /** Property which specifies the resource bundle locator prefix */
+ String RESOURCE_BUNDLE_PROP = "resource.file";
+
+ /** Property which specifies the directory name for resource bundle */
+ String RESOURCES_DIRECTORY_NAME = "resources";
- public static final String BASE_CSS_CLASS_PROP = "base.css.class";
/**
* The name of this Decoration.
@@ -41,6 +62,26 @@
/**
* <p>
+ * Returns the base path for the decoration.
+ * </p>
+ *
+ * @return the base path for the decoration.
+ */
+ String getBasePath();
+
+ /**
+ * <p>
+ * Returns the base path for the decoration
+ * with the relativePath argument added.
+ * </p>
+ *
+ * @param relativePath
+ * @return the base path for the decoration with the relativePath argument
added.
+ */
+ String getBasePath( String relativePath );
+
+ /**
+ * <p>
* Returns the correct path to the resource based on the
* relative <code>path</code> argument. This usually entails
* locating the resource that is most appropriate for the
@@ -78,7 +119,8 @@
* </pre>
*
* @param path
- * @return
+ * @return the correct path to the resource based on the
+ * relative <code>path</code> argument.
*/
String getResource(String path);
@@ -87,9 +129,23 @@
* @return The appropriate stylesheet to be used with this
* decoration.
*/
- String getStyleSheet();
+ String getStyleSheet();
+
+ /**
+ *
+ * @return the /portal specific stylesheet to be used with this
+ * decoration; defined only when decoration supports /desktop.
+ */
+ String getStyleSheetPortal();
/**
+ *
+ * @return the /desktop specific stylesheet to be used with this
+ * decoration; defined only when decoration supports /desktop.
+ */
+ String getStyleSheetDesktop();
+
+ /**
* Returns the list of <code>DecoratorAction</code>s to be displayed
* within the portlet window.
*
@@ -114,7 +170,7 @@
* within your <code>decorator.properties</code> config
* file.
* @param name
- * @return
+ * @return value of decoration property which matches name argument.
*/
String getProperty(String name);
@@ -152,4 +208,20 @@
*
*/
void setCurrentStateAction( String currentStateAction );
+
+ /**
+ * @return the resource bundle locator prefix.
+ */
+ String getResourceBundleName();
+
+ /**
+ * @return the resource bundle for the given Locale and RequestContext.
+ */
+ ResourceBundle getResourceBundle( Locale locale,
org.apache.jetspeed.request.RequestContext context );
+
+ /**
+ * Indicates whether the decorator supports /desktop
+ *
+ */
+ boolean supportsDesktop();
}
Modified:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/DecorationFactory.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/DecorationFactory.java?view=diff&rev=510239&r1=510238&r2=510239
==============================================================================
---
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
Wed Feb 21 13:30:33 2007
@@ -103,6 +103,17 @@
Decoration getDecoration(Page page, Fragment fragment, RequestContext
requestContext);
/**
+ * Indicates whether /desktop is enabled for the current portal request.
+ * Located here due to range of jetspeed components which need this
information and
+ * already have a DecorationFactory reference.
+ *
+ * @param requestContext current portal request.
+ *
+ * @return true if /desktop is enabled for the current portal request,
otherwise false
+ */
+ boolean isDesktopEnabled( RequestContext requestContext );
+
+ /**
* Clears the lookup cache of all previous located pathes. This only
* clears the cache the <code>RequestContext</code>'s current user. This
* will generally delegate the cache operation to the
<code>PathResolverCache</code>
@@ -115,7 +126,6 @@
*/
void clearCache(RequestContext requestContext);
-
/**
* Get the portal-wide list of page decorations.
*
@@ -138,10 +148,58 @@
List getLayouts(RequestContext request);
/**
- * Get the portal-wide list of available desktop skins.
+ * Get the portal-wide list of available desktop page decorations.
*
* @return A list of desktop skins of type <code>String</code>
*/
- Set getDesktopThemes(RequestContext request);
+ Set getDesktopPageDecorations(RequestContext request);
+
+ /**
+ * Get the portal-wide list of desktop portlet decorations.
+ *
+ * @return A list of desktop skins of type <code>String</code>
+ */
+ Set getDesktopPortletDecorations(RequestContext request);
+
+ /**
+ * Get the path to the layout decorations directory.
+ *
+ * @return path to layout decorations directory
+ */
+ String getLayoutDecorationsBasePath();
+ /**
+ * Get the path to the portlet decorations directory.
+ *
+ * @return path to portlet decorations directory
+ */
+ String getPortletDecorationsBasePath();
+
+ /**
+ * Get the default desktop layout decoration to be used when
+ * selected layout decoration does not support /desktop.
+ *
+ * @return default desktop layout decoration.
+ */
+ String getDefaultDesktopLayoutDecoration();
+
+ /**
+ * Set the default desktop layout decoration to be used when
+ * selected layout decoration does not support /desktop.
+ */
+ void setDefaultDesktopLayoutDecoration( String newOne );
+
+ /**
+ * Get the default desktop portlet decoration to be used when
+ * selected portlet decoration does not support /desktop.
+ *
+ * @return default desktop portlet decoration.
+ */
+ String getDefaultDesktopPortletDecoration();
+
+ /**
+ * Set the default desktop portlet decoration to be used when
+ * selected portlet decoration does not support /desktop.
+ */
+ void setDefaultDesktopPortletDecoration( String newOne );
}
Modified:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/Theme.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/Theme.java?view=diff&rev=510239&r1=510238&r2=510239
==============================================================================
---
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/Theme.java
(original)
+++
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/decoration/Theme.java
Wed Feb 21 13:30:33 2007
@@ -15,6 +15,7 @@
*/
package org.apache.jetspeed.decoration;
+import java.util.Collection;
import java.util.Set;
import org.apache.jetspeed.om.page.Fragment;
@@ -45,6 +46,18 @@
* @see Fragment
*/
Decoration getDecoration(Fragment fragment);
+
+ /**
+ * Get a list of portlet decoration names used by
+ * portlets on the current page.
+ *
+ * @return unmodifiable list for portlet decoration names.
+ *
+ * @see Decoration
+ * @see Fragment
+ */
+ Collection getPortletDecorationNames();
+
/**
* Returns the the top most, "root" layout fragment's
Modified:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/desktop/JetspeedDesktop.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/desktop/JetspeedDesktop.java?view=diff&rev=510239&r1=510238&r2=510239
==============================================================================
---
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/desktop/JetspeedDesktop.java
(original)
+++
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/desktop/JetspeedDesktop.java
Wed Feb 21 13:30:33 2007
@@ -26,7 +26,7 @@
*/
public interface JetspeedDesktop
{
- String CONFIG_FILE_NAME = "theme.properties";
+ String DESKTOP_ENABLED_REQUEST_ATTRIBUTE = "desktop.enabled";
/**
* Render a desktop theme.
@@ -36,11 +36,15 @@
void render(RequestContext request);
/**
- * Retrieve the default theme for this portal
+ * Indicates whether /desktop is enabled for the current portal request.
+ * Located here due to range of jetspeed components which need this
information and
+ * already have a DecorationFactory reference.
*
- * @return default theme for portal
+ * @param requestContext current portal request.
+ *
+ * @return true if /desktop is enabled for the current portal request,
otherwise false
*/
- String getDefaultTheme();
+ boolean isDesktopEnabled( RequestContext requestContext );
/**
* Retrieve the header resource factory
@@ -48,5 +52,68 @@
* @return header resource factory
*/
HeaderResourceFactory getHeaderResourceFactory();
+
+ /**
+ * Desktop servlet path ( e.g. /desktop )
+ *
+ * @return portal base url
+ */
+ public String getDesktopServletPath();
+
+ /**
+ * Portal base url ( e.g. http://localhost:8080/jetspeed )
+ *
+ * @return portal base url
+ */
+ public String getPortalBaseUrl( RequestContext requestContext );
+
+ /**
+ * Portal base url ( e.g. http://localhost:8080/jetspeed )
+ *
+ * @return portal base url
+ */
+ public String getPortalBaseUrl( RequestContext requestContext, boolean
encode );
+
+ /**
+ * Portal base url with relativePath argument appended ( e.g.
http://localhost:8080/jetspeed/javascript/dojo/ )
+ *
+ * @return portal base url with relativePath argument appended
+ */
+ public String getPortalResourceUrl( RequestContext requestContext, String
relativePath );
+
+ /**
+ * Portal base url with relativePath argument appended ( e.g.
http://localhost:8080/jetspeed/javascript/dojo/ )
+ *
+ * @return portal base url with relativePath argument appended
+ */
+ public String getPortalResourceUrl( RequestContext requestContext, String
relativePath, boolean encode );
+
+ /**
+ * Portal base servlet url ( e.g. http://localhost:8080/jetspeed/desktop/ )
+ *
+ * @return portal base servlet url
+ */
+ public String getPortalUrl( RequestContext requestContext );
+
+ /**
+ * Portal base servlet url ( e.g. http://localhost:8080/jetspeed/desktop/ )
+ *
+ * @return portal base servlet url
+ */
+ public String getPortalUrl( RequestContext requestContext, boolean encode
);
+
+ /**
+ * Portal base servlet url with relativePath argument appended ( e.g.
http://localhost:8080/jetspeed/desktop/default-page.psml )
+ *
+ * @return portal base servlet url with relativePath argument appended
+ */
+ public String getPortalUrl( RequestContext requestContext, String
relativePath );
+
+ /**
+ * Portal base servlet url with relativePath argument appended ( e.g.
http://localhost:8080/jetspeed/desktop/default-page.psml )
+ *
+ * @return portal base servlet url with relativePath argument appended
+ */
+ public String getPortalUrl( RequestContext requestContext, String
relativePath, boolean encode );
}
Modified:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/desktop/JetspeedDesktopContext.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/desktop/JetspeedDesktopContext.java?view=diff&rev=510239&r1=510238&r2=510239
==============================================================================
---
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/desktop/JetspeedDesktopContext.java
(original)
+++
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/desktop/JetspeedDesktopContext.java
Wed Feb 21 13:30:33 2007
@@ -24,13 +24,21 @@
* Jetspeed Desktop
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Steve Milek</a>
* @version $Id: JetspeedDesktopContext.java $
*/
public interface JetspeedDesktopContext
{
- String DESKTOP_ATTRIBUTE = "jetspeedDesktop";
+ String DESKTOP_CONTEXT_ATTRIBUTE = "jetspeedDesktop";
+ String DESKTOP_REQUEST_CONTEXT_ATTRIBUTE = "JS2RequestContext";
+ String DESKTOP_COMPONENT_MANAGER_ATTRIBUTE = "JS2ComponentManager";
- String RESOURCES_DIRECTORY_NAME = "resources";
+ String LAYOUT_TEMPLATE_EXTENSION_PROP = "template.extension";
+
+ String LAYOUT_TEMPLATE_ID_PROP = "template.id";
+
+ String LAYOUT_TEMPLATE_ID_DEFAULT = "desktop";
+
/**
* Portal base url ( e.g. http://localhost:8080/jetspeed )
@@ -89,36 +97,80 @@
public String getPortalUrl( String relativePath, boolean encode );
/**
- * Gets the desktop-theme name
+ * Gets the layout decoration name
*
* @return
*/
- public String getDesktopTheme();
-
+ public String getLayoutDecorationName();
+
/**
- * Gets an absolute resource url to the desktop-theme directory
+ * <p>
+ * Get the path to the layout decoration desktop template file.
+ * </p>
*
- * @return
+ * @return the desktop template file path.
*/
- public String getDesktopThemeRootUrl();
+ public String getLayoutTemplatePath();
/**
- * Gets an absolute resource url to a desktop-theme resource
+ * <p>
+ * Get the path to the layout decoration desktop template file.
+ * The property name parameter is provided to allow for an alternate
+ * property value to be used as the filename (without extension)
+ * of the desktop template file.
+ * </p>
+ *
+ * @return the desktop template file path.
+ */
+ public String getLayoutTemplatePath( String layoutTemplateIdPropertyName );
+
+ /**
+ * <p>
+ * Returns the base path for the layout decoration.
+ * </p>
+ *
+ * @return the base path for the layout decoration.
+ */
+ public String getLayoutBasePath();
+
+ /**
+ * <p>
+ * Returns the base path for the layout decoration
+ * with the relativePath argument added.
+ * </p>
*
* @param relativePath
- * @return
+ * @return the base path for the layout decoration with the relativePath
argument added.
+ */
+ public String getLayoutBasePath( String relativePath );
+
+ /**
+ * <p>
+ * Returns the base url for the layout decoration.
+ * </p>
+ *
+ * @return the base url for the layout decoration.
*/
- public String getDesktopThemeResourceUrl( String relativePath );
+ public String getLayoutBaseUrl();
/**
- * Gets an relative resource url to a desktop-theme resource
+ * <p>
+ * Returns the base url for the layout decoration
+ * with the relativePath argument added.
+ * </p>
*
* @param relativePath
- * @return
+ * @return the base url for the layout decoration with the relativePath
argument added.
*/
- public String getDesktopThemeResource( String relativePath );
+ public String getLayoutBaseUrl( String relativePath );
- public ResourceBundle getResourceBundle(Locale locale);
+ /**
+ * @return the layout decoration resource bundle for the given Locale.
+ */
+ public ResourceBundle getLayoutResourceBundle( Locale locale );
+ /**
+ * @return the HeaderResource component.
+ */
public HeaderResource getHeaderResource();
}
Modified:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/headerresource/HeaderResource.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/headerresource/HeaderResource.java?view=diff&rev=510239&r1=510238&r2=510239
==============================================================================
---
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/headerresource/HeaderResource.java
(original)
+++
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/headerresource/HeaderResource.java
Wed Feb 21 13:30:33 2007
@@ -21,6 +21,7 @@
* HeaderResource has tags information to put them into <head> tag.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Shinsuke Sugaya</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Steve Milek</a>
* @version $Id: HeaderResource.java 188569 2005-05-13 13:35:18Z weaver $
*/
public interface HeaderResource
@@ -70,7 +71,7 @@
public final static String HEADER_SECTION_DOJO_MODULES_NAMESPACE =
"header.dojo.modules.namespace";
public final static String HEADER_SECTION_DOJO_STYLE_BODYEXPAND =
"header.dojo.style.bodyexpand";
public final static String HEADER_SECTION_DOJO_STYLE_BODYEXPAND_NOSCROLL =
"header.dojo.style.bodyexpand.noscroll";
- public final static String HEADER_SECTION_DESKTOP_STYLE_DESKTOPTHEME =
"header.desktop.style.desktoptheme";
+ public final static String HEADER_SECTION_DESKTOP_STYLE_LAYOUT =
"header.desktop.style.layout";
public final static String HEADER_SECTION_DESKTOP_INIT =
"header.desktop.init";
public final static String HEADER_INTERNAL_JETSPEED_VAR_NAME = "jetspeed";
@@ -88,6 +89,8 @@
public final static String HEADER_CONFIG_DOJO_REQUIRES_MODULES =
"dojo.requires.modules";
// header configuration - desktop
+ public final static String HEADER_CONFIG_DESKTOP_LAYOUT_DECORATION_DEFAULT
= "desktop.decoration.layout";
+ public final static String
HEADER_CONFIG_DESKTOP_PORTLET_DECORATION_DEFAULT = "desktop.decoration.portlet";
public final static String HEADER_CONFIG_DESKTOP_WINDOW_TILING =
"desktop.window.tiling";
public final static String HEADER_CONFIG_DESKTOP_WINDOW_HEIGHT_EXPAND =
"desktop.window.heightexpand";
public final static String HEADER_CONFIG_DESKTOP_WINDOW_HEIGHT =
"desktop.window.height";
@@ -100,8 +103,6 @@
public final static String HEADER_CONFIG_DESKTOP_WINDOW_ACTION_BUTTON_MAX
= "desktop.window.action.button.maximum";
public final static String HEADER_CONFIG_DESKTOP_WINDOW_ICON_ENABLED =
"desktop.window.icon.enabled";
public final static String HEADER_CONFIG_DESKTOP_WINDOW_ICON_PATH =
"desktop.window.icon.path";
- public final static String HEADER_CONFIG_DESKTOP_WINDOW_THEME =
"desktop.window.theme";
- public final static String HEADER_CONFIG_DESKTOP_WINDOW_THEME_ALLOWED =
"desktop.window.theme.allowed";
public final static String
HEADER_CONFIG_DESKTOP_PAGE_ACTION_BUTTON_TOOLTIP =
"desktop.page.action.button.tooltip";
public final static String HEADER_INTERNAL_CONFIG_DESKTOP_WINDOW_ACTION =
"desktop.window.action";
Modified:
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/headerresource/HeaderResourceLib.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/headerresource/HeaderResourceLib.java?view=diff&rev=510239&r1=510238&r2=510239
==============================================================================
---
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/headerresource/HeaderResourceLib.java
(original)
+++
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/headerresource/HeaderResourceLib.java
Wed Feb 21 13:30:33 2007
@@ -15,6 +15,10 @@
*/
package org.apache.jetspeed.headerresource;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Collection;
+
import javax.servlet.http.HttpServletRequest;
import org.apache.jetspeed.container.url.BasePortalURL;
@@ -28,6 +32,10 @@
*/
public class HeaderResourceLib
{
+ protected final static String EOL = "\r\n"; // html eol
+ private final static String MAILTO_URL_SCHEME = "mailto";
+ private final static int MAILTO_URL_SCHEME_LEN =
MAILTO_URL_SCHEME.length();
+
public static int getHeaderTypeId( String headerType )
{
int headerTypeNumber = -1;
@@ -178,6 +186,20 @@
}
/**
+ * Portal base servlet url ( e.g. http://localhost:8080/jetspeed/desktop/ )
+ * Expects portalBaseUrl argument to be defined (ie. it does not call
getPortalBaseUrl)
+ * Also expects servletPath argument to be defined
+ *
+ * @return portal base servlet url
+ */
+ public static String getPortalUrl( String portalBaseUrl, RequestContext
requestContext, String servletPath )
+ {
+ HttpServletRequest request = requestContext.getRequest();
+ StringBuffer portalurl = new StringBuffer();
+ return portalurl.append( portalBaseUrl ).append( ( servletPath == null
) ? request.getServletPath() : servletPath ).toString();
+ }
+
+ /**
* Portal base servlet url with relativePath argument appended ( e.g.
http://localhost:8080/jetspeed/desktop/default-page.psml )
* Expects portalUrl argument to be defined (ie. it does not call
getPortalUrl)
*
@@ -243,10 +265,24 @@
{
if ( relativePath == null )
relativePath = "";
- if ( relativePath.indexOf( "://" ) == -1 && relativePath.indexOf(
"mailto:" ) == -1 )
+ boolean isPathRelative = true;
+ int colonPos = relativePath.indexOf( ':' );
+ if ( colonPos != -1 )
+ {
+ int pathLen = relativePath.length();
+ if ( colonPos <= ( pathLen - 3 ) && relativePath.charAt( colonPos
+ 1 ) == '/' && relativePath.charAt( colonPos + 2 ) == '/' )
+ {
+ isPathRelative = false;
+ }
+ else if ( colonPos >= MAILTO_URL_SCHEME_LEN &&
relativePath.substring( colonPos - MAILTO_URL_SCHEME_LEN, colonPos ).equals(
MAILTO_URL_SCHEME ) )
+ {
+ isPathRelative = false;
+ }
+ }
+ if ( isPathRelative )
{
StringBuffer path = new StringBuffer();
- String resourceurl = path.append( portalBaseUrl ).append(
relativePath ).toString();
+ String resourceurl = path.append( portalBaseUrl ).append(
relativePath.startsWith( "/" ) ? "" : "/" ).append( relativePath ).toString();
if ( encode && requestContext != null )
{
return requestContext.getResponse().encodeURL( resourceurl );
@@ -257,5 +293,103 @@
}
}
return relativePath;
+ }
+
+
+ public static String makeJavascriptStatement( String statement, String
indent, boolean addEOL )
+ {
+ StringBuffer statementOut = new StringBuffer();
+ if ( statement != null )
+ {
+ statement = statement.trim();
+ if ( statement.length() > 0 )
+ {
+ if ( indent != null )
+ {
+ statementOut.append( indent );
+ }
+ statementOut.append( statement );
+ if ( statement.charAt( statement.length()-1 ) != ';' )
+ {
+ statementOut.append( ";" );
+ }
+ if ( addEOL )
+ {
+ statementOut.append( EOL );
+ }
+ }
+ }
+ return statementOut.toString();
+ }
+ public static String makeJSONStringArray( Collection stringList )
+ {
+ return makeJSONStringArray( stringList, null );
+ }
+ public static String makeJSONStringArray( Collection stringList, List
compiledUniqueValues )
+ {
+ if ( stringList != null && stringList.size() > 0 )
+ {
+ StringBuffer stringListContent = new StringBuffer();
+ Iterator stringListIter = stringList.iterator();
+ while ( stringListIter.hasNext() )
+ {
+ String value = (String)stringListIter.next();
+ if ( value != null && value.length() > 0 )
+ {
+ if ( stringListContent.length() > 0 )
+ {
+ stringListContent.append( ", " );
+ }
+ else
+ {
+ stringListContent.append( "[ " );
+ }
+ stringListContent.append( "\"" ).append( value ).append(
"\"" );
+ if ( compiledUniqueValues != null )
+ {
+ if ( ! compiledUniqueValues.contains( value ) )
+ {
+ compiledUniqueValues.add( value );
+ }
+ }
+ }
+ }
+ if ( stringListContent.length() > 0 )
+ {
+ stringListContent.append( " ]" );
+ return stringListContent.toString();
+ }
+ }
+ return null;
+ }
+ public static String makeJSONInteger( Object source, boolean quote )
+ {
+ String sourceStr = ( ( source == null ) ? (String)null :
source.toString() );
+ if ( sourceStr != null )
+ {
+ try
+ {
+ Integer.parseInt( sourceStr );
+ if ( quote )
+ {
+ sourceStr = "\"" + sourceStr + "\"";
+ }
+ }
+ catch ( NumberFormatException nex )
+ {
+ sourceStr = null;
+ }
+ }
+ return sourceStr;
+ }
+
+ public static String makeJSONBoolean( Object source )
+ {
+ String boolStr = ( ( source == null ) ? (String)null :
source.toString() );
+ if ( boolStr != null && ( ! boolStr.equals( "false" ) ) && ( !
boolStr.equals( "true" ) ) )
+ {
+ boolStr = null;
+ }
+ return boolStr;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]