You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrp4j-dev@portals.apache.org by es...@apache.org on 2007/08/21 06:13:23 UTC

svn commit: r567942 - /portals/wsrp4j/trunk/commons-producer/src/java/org/apache/wsrp4j/commons/producer/provider/driver/URLComposerImpl.java

Author: esm
Date: Mon Aug 20 21:13:22 2007
New Revision: 567942

URL: http://svn.apache.org/viewvc?rev=567942&view=rev
Log:
Code formatting and logging updates.

Modified:
    portals/wsrp4j/trunk/commons-producer/src/java/org/apache/wsrp4j/commons/producer/provider/driver/URLComposerImpl.java

Modified: portals/wsrp4j/trunk/commons-producer/src/java/org/apache/wsrp4j/commons/producer/provider/driver/URLComposerImpl.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/commons-producer/src/java/org/apache/wsrp4j/commons/producer/provider/driver/URLComposerImpl.java?rev=567942&r1=567941&r2=567942&view=diff
==============================================================================
--- portals/wsrp4j/trunk/commons-producer/src/java/org/apache/wsrp4j/commons/producer/provider/driver/URLComposerImpl.java (original)
+++ portals/wsrp4j/trunk/commons-producer/src/java/org/apache/wsrp4j/commons/producer/provider/driver/URLComposerImpl.java Mon Aug 20 21:13:22 2007
@@ -35,38 +35,45 @@
 import org.apache.wsrp4j.commons.util.Constants;
 import org.apache.wsrp4j.commons.util.Utility;
 
-
 /**
- * <p>This class implements the URLComposer interface providing methods to generate
- * URLs or namespace tokens.</p>
- * <p>There are two kinds of methods:
+ * <p>
+ * This class implements the URLComposer interface providing methods to generate
+ * URLs or namespace tokens.
+ * </p>
+ * <p>
+ * There are two kinds of methods:
  * <ul>
- *   <li>Methods defining URLs or tokens to be rewritten by the consumer.</li>
- *   <li>Methods defining complete URLs or namespaced tokens according to the
- *       templates delivered by the Consumer.</li></p>
- *
+ * <li>Methods defining URLs or tokens to be rewritten by the consumer.</li>
+ * <li>Methods defining complete URLs or namespaced tokens according to the
+ * templates delivered by the Consumer.</li>
+ * </p>
+ * 
  * @version $Id$
  */
-public class URLComposerImpl implements URLComposer {
-    
-    // for logging and exception support
-    private static final Log log = LogFactory.getLog(URLComposerImpl.class);
-    
-    private URLComposerImpl() {
-        // private
-    }
-    
-    public static URLComposerImpl getInstance(Provider provider) {
-        URLComposerImpl urlComposer = new URLComposerImpl();
-        
-        return urlComposer;
+public class URLComposerImpl implements URLComposer
+{
+
+    /**
+     * Logger
+     */
+    private static final Log LOG = LogFactory.getLog( URLComposerImpl.class );
+
+    private URLComposerImpl()
+    {
+        // prevent external instantiation
+    }
+
+    public static URLComposerImpl getInstance( Provider provider )
+    {
+        // ignore the provider, just provide a new instance.
+        return new URLComposerImpl();
     }
-    
+
     // methods generating rewrite urls
-    
+
     /**
      * creates a rewrite blocking-action-url
-     *
+     * 
      * @param portletMode
      * @param navigationalState
      * @param interactionState
@@ -75,679 +82,520 @@
      * @param runtimeContext
      * @param portletContext
      * @param userContext
-     *
+     * 
      * @return URL as String
      */
-    public String createBlockingActionURL(
-            String portletMode,
-            String navigationalState,
-            String interactionState,
-            String windowState,
-            boolean secureURL,
-            RuntimeContext runtimeContext,
-            PortletContext portletContext,
-            UserContext userContext) {
-        
-        String MN = "createBlockingActionURL";
-        
-        if (log.isDebugEnabled()) {
-            log.debug(Utility.strEnter(MN));
-        }
-        
+    public String createBlockingActionURL( String portletMode, String navigationalState, String interactionState,
+            String windowState, boolean secureURL, RuntimeContext runtimeContext, PortletContext portletContext,
+            UserContext userContext )
+    {
         // check if valid templates are provided
-        if (runtimeContext != null) {
-            
+        if ( runtimeContext != null )
+        {
+
             Templates templates = runtimeContext.getTemplates();
-            if (templates != null) {
-                
+            if ( templates != null )
+            {
+
                 String template = null;
-                if (secureURL) {
-                    
+                if ( secureURL )
+                {
+
                     template = templates.getSecureBlockingActionTemplate();
-                    if (template == null)
+                    if ( template == null )
                         template = templates.getSecureDefaultTemplate();
-                    
-                } else {
-                    
+
+                }
+                else
+                {
+
                     template = templates.getBlockingActionTemplate();
-                    if (template == null)
+                    if ( template == null )
                         template = templates.getDefaultTemplate();
                 }
-                
-                try {
-                    if (template != null) {
-                        
-                        if (log.isDebugEnabled()) {
-                            log.debug(Utility.strExit(MN));
-                        }
-                        
-                        return this.createBlockingActionURLByTemplate(
-                                template,
-                                portletMode,
-                                navigationalState,
-                                interactionState,
-                                windowState,
-                                portletContext==null ? null : 
-                                    portletContext.getPortletHandle(),
-                                userContext==null ? null : 
-                                    userContext.getUserContextKey(),
-                                runtimeContext.getPortletInstanceKey(),
-                                runtimeContext.getSessionID());
+
+                try
+                {
+                    if ( template != null )
+                    {
+
+                        LOG.debug( "Composing blocking action url by template." );                        
+                        String url = this.createBlockingActionURLByTemplate( template, portletMode, navigationalState,
+                                interactionState, windowState, portletContext == null ? null : portletContext
+                                        .getPortletHandle(), userContext == null ? null : userContext
+                                        .getUserContextKey(), runtimeContext.getPortletInstanceKey(), runtimeContext
+                                        .getSessionID() );                                              
+                        return url;
                     }
-                } catch (WSRPException e) {
-                    
+                }
+                catch ( WSRPException e )
+                {
+
                     // TODO: pass exception to consumer
                 }
             }
         }
         
-        if (log.isDebugEnabled()) {
-            log.debug(Utility.strExit(MN));
-        }
-        
-        return createRewriteURL(
-                Constants.URL_TYPE_BLOCKINGACTION,
-                portletMode,
-                navigationalState,
-                interactionState,
-                windowState,
-                null,
-                null,
-                null,
-                java.lang.String.valueOf(secureURL));
+        LOG.debug( "Composing blocking action url by rewrite." );
+        String url = createRewriteURL( Constants.URL_TYPE_BLOCKINGACTION, portletMode, navigationalState, interactionState,
+                windowState, null, null, null, java.lang.String.valueOf( secureURL ) );
+        return url;
     }
-    
+
     /**
      * creates a rewrite render-url
      */
-    public String createRenderURL(
-            String portletMode,
-            String navigationalState,
-            String windowState,
-            boolean secureURL,
-            RuntimeContext runtimeContext,
-            PortletContext portletContext,
-            UserContext userContext) {
-        
-        String MN = "createRenderURL";
-        
-        if (log.isDebugEnabled()) {
-            log.debug(Utility.strEnter(MN));
-        }
-        
+    public String createRenderURL( String portletMode, String navigationalState, String windowState, boolean secureURL,
+            RuntimeContext runtimeContext, PortletContext portletContext, UserContext userContext )
+    {
+
         // check if valid templates are provided
-        if (runtimeContext != null) {
-            
+        if ( runtimeContext != null )
+        {
+
             Templates templates = runtimeContext.getTemplates();
-            if (templates != null) {
-                
+            if ( templates != null )
+            {
+
                 String template = null;
-                if (secureURL) {
-                    
+                if ( secureURL )
+                {
+
                     template = templates.getSecureRenderTemplate();
-                    if (template == null)
+                    if ( template == null )
+                    {
                         template = templates.getSecureDefaultTemplate();
-                    
-                } else {
-                    
+                    }
+
+                }
+                else
+                {
+
                     template = templates.getRenderTemplate();
-                    if (template == null)
+                    if ( template == null )
+                    {
                         template = templates.getDefaultTemplate();
+                    }
                 }
-                
-                try {
-                    if (template != null) {
-                        
-                        if (log.isDebugEnabled()) {
-                            log.debug(Utility.strExit(MN));
-                        }
-                        
-                        return this.createRenderURLByTemplate(
-                                template,
-                                portletMode,
-                                navigationalState,
-                                windowState,
-                                portletContext==null ? null :
-                                    portletContext.getPortletHandle(),
-                                userContext==null ? null : 
-                                    userContext.getUserContextKey(),
-                                runtimeContext.getPortletInstanceKey(),
-                                runtimeContext.getSessionID());
+
+                try
+                {
+                    if ( template != null )
+                    {
+                        LOG.debug( "Composing render url by template." );
+                        String url = this.createRenderURLByTemplate( template, portletMode, navigationalState, windowState,
+                                portletContext == null ? null : portletContext.getPortletHandle(),
+                                userContext == null ? null : userContext.getUserContextKey(), runtimeContext
+                                        .getPortletInstanceKey(), runtimeContext.getSessionID() );
+                        return url;
                     }
-                } catch (WSRPException e) {
-                    
+                }
+                catch ( WSRPException e )
+                {
                     // TODO: pass exception to consumer
-                    if (log.isDebugEnabled()) {
-                        log.debug(e);
-                    }
-                    
+                    LOG.error( e );
                 }
             }
         }
         
-        if (log.isDebugEnabled()) {
-            log.debug(Utility.strExit(MN));
-        }
-        
-        return createRewriteURL(
-                Constants.URL_TYPE_RENDER,
-                portletMode,
-                navigationalState,
-                null,
-                windowState,
-                null,
-                null,
-                null,
-                java.lang.String.valueOf(secureURL));
+        LOG.debug( "Composing render url by rewrite." );
+        String url = createRewriteURL( Constants.URL_TYPE_RENDER, portletMode, navigationalState, null, windowState, null,
+                null, null, java.lang.String.valueOf( secureURL ) );
+        return url;
     }
-    
+
     /**
      * creates a rewrite resource-url
      */
-    public String createResourceURL(
-            String url,
-            boolean rewriteResource,
-            boolean secureURL,
-            RuntimeContext runtimeContext,
-            PortletContext portletContext,
-            UserContext userContext) {
-        
-        String MN = "createResourceURL";
-        
-        if (log.isDebugEnabled()) {
-            log.debug(Utility.strEnter(MN));
-        }
-        
+    public String createResourceURL( String url, boolean rewriteResource, boolean secureURL,
+            RuntimeContext runtimeContext, PortletContext portletContext, UserContext userContext )
+    {
         // check if valid templates are provided
-        if (runtimeContext != null) {
-            
+        if ( runtimeContext != null )
+        {
             Templates templates = runtimeContext.getTemplates();
-            if (templates != null) {
-                
+            if ( templates != null )
+            {
                 String template = null;
-                if (secureURL) {
-                    
+                if ( secureURL )
+                {
                     template = templates.getSecureResourceTemplate();
-                    if (template == null)
+                    if ( template == null )
+                    {
                         template = templates.getSecureDefaultTemplate();
-                    
-                } else {
-                    
+                    }
+                }
+                else
+                {
+
                     template = templates.getResourceTemplate();
-                    if (template == null)
+                    if ( template == null )
+                    {
                         template = templates.getDefaultTemplate();
+                    }
                 }
-                
-                try {
-                    if (template != null) {
-                        
-                        if (log.isDebugEnabled()) {
-                            log.debug(Utility.strExit(MN));
-                        }
-                        
-                        return this.createResourceURLByTemplate(
-                                template,
-                                url,
-                                rewriteResource,
-                                portletContext==null ? null : 
-                                    portletContext.getPortletHandle(),
-                                userContext==null ? null :
-                                    userContext.getUserContextKey(),
-                                runtimeContext.getPortletInstanceKey(),
-                                runtimeContext.getSessionID());
+
+                try
+                {
+                    if ( template != null )
+                    {
+                        LOG.debug( "Composing resource url by template." );                        
+                        String resourceUrl = this.createResourceURLByTemplate( template, url, rewriteResource,
+                                portletContext == null ? null : portletContext.getPortletHandle(),
+                                userContext == null ? null : userContext.getUserContextKey(), runtimeContext
+                                        .getPortletInstanceKey(), runtimeContext.getSessionID() );
+                        return resourceUrl;
                     }
-                    
-                } catch (WSRPException e) {
-                    
+                }
+                catch ( WSRPException e )
+                {
                     // TODO: pass exception to consumer
-                    
+                    LOG.error( e );
                 }
             }
         }
-        
-        if (log.isDebugEnabled()) {
-            log.debug(Utility.strExit(MN));
-        }
-        
-        return createRewriteURL(
-                Constants.URL_TYPE_RESOURCE,
-                null,
-                null,
-                null,
-                null,
-                url,
-                java.lang.String.valueOf(rewriteResource),
-                null,
-                java.lang.String.valueOf(secureURL));
+
+        LOG.debug( "Composing resource url by rewrite." );
+        String resourceUrl = createRewriteURL( Constants.URL_TYPE_RESOURCE, null, null, null, null, url,
+                java.lang.String.valueOf( rewriteResource ), null, java.lang.String.valueOf( secureURL ) );
+        return resourceUrl;
     }
-    
+
     /**
      * creates a namespaced token
      */
-    public String createNamespacedToken(String token, 
-            RuntimeContext runtimeContext) {
-        
-        String MN = "createNamespacedToken";
-        
-        if (log.isDebugEnabled()) {
-            log.debug(Utility.strEnter(MN));
-        }
-        
+    public String createNamespacedToken( String token, RuntimeContext runtimeContext )
+    {
         String nsToken = null;
-        
+
         // first get the prefix
         // this is either the prefix passed in the RuntimeContext
-        if (runtimeContext != null) {
+        if ( runtimeContext != null )
+        {
             nsToken = runtimeContext.getNamespacePrefix();
         }
+        
         // no namespace prefix obtained?
         // then need to put in the rewrite NS wsrp_rewrite_
-        if (nsToken == null) {
+        if ( nsToken == null )
+        {
             nsToken = Constants.REWRITE_START + Constants.NAMESPACE_START;
         }
-        
+
         // append the token
         // if token is null, simply return the namespace
-        if (token != null) {
-            nsToken = nsToken.concat(token);
-        }
-        
-        if (log.isDebugEnabled()) {
-            log.debug(Utility.strExit(MN));
+        if ( token != null )
+        {
+            nsToken = nsToken.concat( token );
         }
-        
+
+        LOG.debug( "Created namespaced token [" + nsToken + "] from [" + token + "] for runtime context [" + runtimeContext + "]" );
         return nsToken;
     }
-    
-    private String createRewriteURL(
-            String urlType,
-            String portletMode,
-            String navigationalState,
-            String interactionState,
-            String windowState,
-            String url,
-            String rewriteResource,
-            String token,
-            String secureURL) {
-        
-        String MN = "createRewriteURL()";
-        
-        if (log.isDebugEnabled()) {
-            log.debug(new Object[] {
-                        urlType,
-                        portletMode,
-                        navigationalState,
-                        interactionState,
-                        windowState,
-                        url,
-                        rewriteResource,
-                        token,
-                        secureURL });
-        }
-        
+
+    private String createRewriteURL( String urlType, String portletMode, String navigationalState,
+            String interactionState, String windowState, String url, String rewriteResource, String token,
+            String secureURL )
+    {
         StringBuffer resultURL = new StringBuffer();
-        
-        resultURL.append(Constants.REWRITE_START);
-        resultURL.append(Constants.PARAMS_START);
-        
+
+        resultURL.append( Constants.REWRITE_START );
+        resultURL.append( Constants.PARAMS_START );
+
         // urlType must be first (required)
-        if (urlType != null) {
-            resultURL.append(appendNameValuePair(Constants.URL_TYPE, urlType));
-        } else {
-            
-            //TODO: Error
+        if ( urlType != null )
+        {
+            resultURL.append( appendNameValuePair( Constants.URL_TYPE, urlType ) );
         }
-        
+        else
+        {
+
+            // TODO: Error
+        }
+
         // portletMode
-        if (portletMode != null && portletMode.length() > 0) {
-            resultURL.append(Constants.NEXT_PARAM_AMP);
-            resultURL.append(appendNameValuePair(
-                    Constants.PORTLET_MODE, portletMode));
+        if ( portletMode != null && portletMode.length() > 0 )
+        {
+            resultURL.append( Constants.NEXT_PARAM_AMP );
+            resultURL.append( appendNameValuePair( Constants.PORTLET_MODE, portletMode ) );
         }
-        
+
         // navigationalState
-        if (navigationalState != null && navigationalState.length() > 0) {
-            resultURL.append(Constants.NEXT_PARAM_AMP);
-            resultURL.append(appendNameValuePair(
-                    Constants.NAVIGATIONAL_STATE, navigationalState));
+        if ( navigationalState != null && navigationalState.length() > 0 )
+        {
+            resultURL.append( Constants.NEXT_PARAM_AMP );
+            resultURL.append( appendNameValuePair( Constants.NAVIGATIONAL_STATE, navigationalState ) );
         }
-        
+
         // interactionState
-        if (interactionState != null && interactionState.length() > 0) {
-            resultURL.append(Constants.NEXT_PARAM_AMP);
-            resultURL.append(appendNameValuePair(
-                    Constants.INTERACTION_STATE, interactionState));
+        if ( interactionState != null && interactionState.length() > 0 )
+        {
+            resultURL.append( Constants.NEXT_PARAM_AMP );
+            resultURL.append( appendNameValuePair( Constants.INTERACTION_STATE, interactionState ) );
         }
-        
+
         // windowState
-        if (windowState != null && windowState.length() > 0) {
-            resultURL.append(Constants.NEXT_PARAM_AMP);
-            resultURL.append(appendNameValuePair(
-                    Constants.WINDOW_STATE, windowState));
+        if ( windowState != null && windowState.length() > 0 )
+        {
+            resultURL.append( Constants.NEXT_PARAM_AMP );
+            resultURL.append( appendNameValuePair( Constants.WINDOW_STATE, windowState ) );
         }
-        
+
         // url
-        if (url != null && url.length() > 0) {
-            resultURL.append(Constants.NEXT_PARAM_AMP);
-            try {
-                resultURL.append(appendNameValuePair(
-                        Constants.URL, Utility.encode(url, "utf-8")));
-            } catch (UnsupportedEncodingException uee) {
+        if ( url != null && url.length() > 0 )
+        {
+            resultURL.append( Constants.NEXT_PARAM_AMP );
+            try
+            {
+                resultURL.append( appendNameValuePair( Constants.URL, Utility.encode( url, "utf-8" ) ) );
+            }
+            catch ( UnsupportedEncodingException uee )
+            {
                 // this should never happen
-                resultURL.append(appendNameValuePair(Constants.URL, url));
+                resultURL.append( appendNameValuePair( Constants.URL, url ) );
             }
         }
-        
+
         // rewriteResource
-        if (rewriteResource != null && rewriteResource.length() > 0) {
-            resultURL.append(Constants.NEXT_PARAM_AMP);
-            resultURL.append(appendNameValuePair(
-                    Constants.REWRITE_RESOURCE, rewriteResource));
+        if ( rewriteResource != null && rewriteResource.length() > 0 )
+        {
+            resultURL.append( Constants.NEXT_PARAM_AMP );
+            resultURL.append( appendNameValuePair( Constants.REWRITE_RESOURCE, rewriteResource ) );
         }
-        
+
         // secureURL
-        if (secureURL != null && secureURL.length() > 0) {
-            resultURL.append(Constants.NEXT_PARAM_AMP);
-            resultURL.append(appendNameValuePair(
-                    Constants.SECURE_URL, secureURL));
+        if ( secureURL != null && secureURL.length() > 0 )
+        {
+            resultURL.append( Constants.NEXT_PARAM_AMP );
+            resultURL.append( appendNameValuePair( Constants.SECURE_URL, secureURL ) );
         }
-        
-        resultURL.append(Constants.REWRITE_END);
 
-        String result = resultURL.toString();
+        resultURL.append( Constants.REWRITE_END );
 
-        if (log.isDebugEnabled()) {
-            log.debug("Result: " + result);
-        }
-        
-        if (log.isDebugEnabled()) {
-            log.debug(Utility.strExit(MN));
-        }
+        String result = resultURL.toString();
         
         return result;
-        
     }
-    
-    private String createNameValuePair(String name, String value) {
-        
-        StringBuffer pair = new StringBuffer(name);
-        pair.append(Constants.EQUALS);
-        pair.append(value);
-        
+
+    private String createNameValuePair( String name, String value )
+    {
+        StringBuffer pair = new StringBuffer( name );
+        pair.append( Constants.EQUALS );
+        pair.append( value );
+
         return pair.toString();
     }
-    
-    private String appendNameValuePair(String name, String value) {
-        return createNameValuePair(name, value);
+
+    private String appendNameValuePair( String name, String value )
+    {
+        return createNameValuePair( name, value );
     }
-    
+
     // methods generating urls by template processing
-    
-    private String createBlockingActionURLByTemplate(
-            String blockingActionTemplate,
-            String portletMode,
-            String navigationalState,
-            String interactionState,
-            String windowState,
-            String portletHandle,
-            String userContextKey,
-            String portletInstanceKey,
-            String sessionID)
-            throws WSRPException {
-        
-        return processTemplate(
-                blockingActionTemplate,
-                Constants.URL_TYPE_BLOCKINGACTION,
-                portletMode,
-                navigationalState,
-                interactionState,
-                windowState,
-                null,
-                null,
-                portletHandle,
-                userContextKey,
-                portletInstanceKey,
-                sessionID);
-        
+
+    private String createBlockingActionURLByTemplate( String blockingActionTemplate, String portletMode,
+            String navigationalState, String interactionState, String windowState, String portletHandle,
+            String userContextKey, String portletInstanceKey, String sessionID ) 
+        throws WSRPException
+    {
+        String url = processTemplate( blockingActionTemplate, Constants.URL_TYPE_BLOCKINGACTION, portletMode,
+                navigationalState, interactionState, windowState, null, null, portletHandle, userContextKey,
+                portletInstanceKey, sessionID );
+        LOG.debug( "Composed blocking action url [" + url + "] using template [" + blockingActionTemplate + "]" );
+        return url;
     }
-    
-    private String createRenderURLByTemplate(
-            String renderTemplate,
-            String portletMode,
-            String navigationalState,
-            String windowState,
-            String portletHandle,
-            String userContextKey,
-            String portletInstanceKey,
-            String sessionID)
-            throws WSRPException {
-        
-        return processTemplate(
-                renderTemplate,
-                Constants.URL_TYPE_RENDER,
-                portletMode,
-                navigationalState,
-                null,
-                windowState,
-                null,
-                null,
-                portletHandle,
-                userContextKey,
-                portletInstanceKey,
-                sessionID);
-        
+
+    private String createRenderURLByTemplate( String renderTemplate, String portletMode, String navigationalState,
+            String windowState, String portletHandle, String userContextKey, String portletInstanceKey, String sessionID )
+        throws WSRPException
+    {
+        String url = processTemplate( renderTemplate, Constants.URL_TYPE_RENDER, portletMode, navigationalState, null,
+                windowState, null, null, portletHandle, userContextKey, portletInstanceKey, sessionID );
+        LOG.debug( "Composed render url [" + url + "] using template [" + renderTemplate + "]" );
+        return url;
     }
-    
-    private String createResourceURLByTemplate(
-            String resourceTemplate,
-            String url,
-            boolean rewriteResource,
-            String portletHandle,
-            String userContextKey,
-            String portletInstanceKey,
-            String sessionID)
-            throws WSRPException {
-        
-        return processTemplate(
-                resourceTemplate,
-                Constants.URL_TYPE_RESOURCE,
-                null,
-                null,
-                null,
-                null,
-                url,
-                java.lang.String.valueOf(rewriteResource),
-                portletHandle,
-                userContextKey,
-                portletInstanceKey,
-                sessionID);
-        
+
+    private String createResourceURLByTemplate( String resourceTemplate, String url, boolean rewriteResource,
+            String portletHandle, String userContextKey, String portletInstanceKey, String sessionID )
+        throws WSRPException
+    {
+        String resourceUrl = processTemplate( resourceTemplate, Constants.URL_TYPE_RESOURCE, null, null, null, null, url,
+                java.lang.String.valueOf( rewriteResource ), portletHandle, userContextKey, portletInstanceKey,
+                sessionID );        
+        LOG.debug( "Composed resource url [" + resourceUrl + "] from url [" + url + "] using template [" + resourceTemplate + "]" );
+        return resourceUrl;
     }
-    
-    private String processTemplate(
-            String template,
-            String urlType,
-            String portletMode,
-            String navigationalState,
-            String interactionState,
-            String windowState,
-            String url,
-            String rewriteResource,
-            String portletHandle,
-            String userContextKey,
-            String portletInstanceKey,
-            String sessionID)
-            throws WSRPException {
-        
-        String MN = "processTemplate";
-        
-        if (log.isDebugEnabled()) {
-            log.debug(Utility.strEnter(MN));
-        }
-        
+
+    private String processTemplate( String template, String urlType, String portletMode, String navigationalState,
+            String interactionState, String windowState, String url, String rewriteResource, String portletHandle,
+            String userContextKey, String portletInstanceKey, String sessionID ) 
+        throws WSRPException
+    {
         String replaceToken = "";
-        
+
         // Any template containing "{" or "}" will be processed.
-        while ((template.indexOf(Constants.REPLACE_START) != -1) | 
-                (template.indexOf(Constants.REPLACE_END) != -1)) {
-            
-            StringBuffer templateBuffer = new StringBuffer(template);
-            
+        while ( ( template.indexOf( Constants.REPLACE_START ) != -1 )
+                | ( template.indexOf( Constants.REPLACE_END ) != -1 ) )
+        {
+
+            StringBuffer templateBuffer = new StringBuffer( template );
+
             // get positions of next left and right brackets
-            int left_br = template.indexOf(Constants.REPLACE_START);
-            int right_br = template.indexOf(Constants.REPLACE_END) + 1;
-            
+            int left_br = template.indexOf( Constants.REPLACE_START );
+            int right_br = template.indexOf( Constants.REPLACE_END ) + 1;
+
             // check if bracketing is correct
-            if ((left_br > right_br) | (left_br == -1) | (right_br == -1)) {
-                
-                WSRPXHelper.throwX(log, ErrorCodes.SYNTAX_ERROR_IN_TEMPLATE);
-                
+            if ( ( left_br > right_br ) | ( left_br == -1 ) | ( right_br == -1 ) )
+            {
+
+                WSRPXHelper.throwX( LOG, ErrorCodes.SYNTAX_ERROR_IN_TEMPLATE );
+
             }
-            
+
             // get replaceToken without curly brackets enclosing it
-            replaceToken = templateBuffer.substring(left_br + 1, right_br - 1);
-            
+            replaceToken = templateBuffer.substring( left_br + 1, right_br - 1 );
+
             // urlType
-            if (replaceToken.equalsIgnoreCase(Constants.URL_TYPE)) {
-                if (urlType == null) {
+            if ( replaceToken.equalsIgnoreCase( Constants.URL_TYPE ) )
+            {
+                if ( urlType == null )
+                {
                     urlType = "";
                 }
-                templateBuffer.replace(left_br, right_br, urlType);
+                templateBuffer.replace( left_br, right_br, urlType );
             }
-            
+
             // portletMode
-            else if (replaceToken.equalsIgnoreCase(Constants.PORTLET_MODE)) {
-                if (portletMode == null) {
+            else if ( replaceToken.equalsIgnoreCase( Constants.PORTLET_MODE ) )
+            {
+                if ( portletMode == null )
+                {
                     portletMode = "";
                 }
-                templateBuffer.replace(left_br, right_br, portletMode);
+                templateBuffer.replace( left_br, right_br, portletMode );
             }
-            
+
             // navigationalState
-            else if (replaceToken.equalsIgnoreCase(
-                    Constants.NAVIGATIONAL_STATE)) {
-                if (navigationalState == null) {
+            else if ( replaceToken.equalsIgnoreCase( Constants.NAVIGATIONAL_STATE ) )
+            {
+                if ( navigationalState == null )
+                {
                     navigationalState = "";
                 }
-                templateBuffer.replace(left_br, right_br, navigationalState);
+                templateBuffer.replace( left_br, right_br, navigationalState );
             }
-            
+
             // interactionState
-            else if (replaceToken.equalsIgnoreCase(
-                    Constants.INTERACTION_STATE)) {
-                if (interactionState == null) {
+            else if ( replaceToken.equalsIgnoreCase( Constants.INTERACTION_STATE ) )
+            {
+                if ( interactionState == null )
+                {
                     interactionState = "";
                 }
-                templateBuffer.replace(left_br, right_br, interactionState);
+                templateBuffer.replace( left_br, right_br, interactionState );
             }
-            
+
             // windowState
-            else if (replaceToken.equalsIgnoreCase(Constants.WINDOW_STATE)) {
-                if (windowState == null) {
+            else if ( replaceToken.equalsIgnoreCase( Constants.WINDOW_STATE ) )
+            {
+                if ( windowState == null )
+                {
                     windowState = "";
                 }
-                templateBuffer.replace(left_br, right_br, windowState);
+                templateBuffer.replace( left_br, right_br, windowState );
             }
-            
+
             // url
-            else if (replaceToken.equalsIgnoreCase(Constants.URL)) {
-                if (url == null) {
+            else if ( replaceToken.equalsIgnoreCase( Constants.URL ) )
+            {
+                if ( url == null )
+                {
                     url = "";
                 }
-                templateBuffer.replace(left_br, right_br, url);
+                templateBuffer.replace( left_br, right_br, url );
             }
-            
+
             // rewriteResource
-            else if (replaceToken.equalsIgnoreCase(
-                    Constants.REWRITE_RESOURCE)) {
-                if (rewriteResource == null) {
+            else if ( replaceToken.equalsIgnoreCase( Constants.REWRITE_RESOURCE ) )
+            {
+                if ( rewriteResource == null )
+                {
                     rewriteResource = "";
                 }
-                templateBuffer.replace(left_br, right_br, rewriteResource);
+                templateBuffer.replace( left_br, right_br, rewriteResource );
             }
-            
+
             /*
-             
-                        // secureURL
-                        else if (replaceToken.equalsIgnoreCase(
-                                Constants.SECURE_URL))
-                        {
-                            if (secureURL == null)
-                            {
-                                secureURL = "";
-                            }
-                            templateBuffer.replace(left_br, right_br, 
-                                secureURL);
-                        }
-             
-                        // token
-                        else if (replaceToken.equalsIgnoreCase(Constants.TOKEN))
-                        {
-                            if (token == null)
-                            {
-                                token = "";
-                            }
-                            templateBuffer.replace(left_br, right_br, token);
-                        }
+             *  // secureURL else if (replaceToken.equalsIgnoreCase(
+             * Constants.SECURE_URL)) { if (secureURL == null) { secureURL = ""; }
+             * templateBuffer.replace(left_br, right_br, secureURL); }
+             *  // token else if
+             * (replaceToken.equalsIgnoreCase(Constants.TOKEN)) { if (token ==
+             * null) { token = ""; } templateBuffer.replace(left_br, right_br,
+             * token); }
              */
             // portletHandle
-            else if (replaceToken.equalsIgnoreCase(Constants.PORTLET_HANDLE)) {
-                if (portletHandle == null) {
+            else if ( replaceToken.equalsIgnoreCase( Constants.PORTLET_HANDLE ) )
+            {
+                if ( portletHandle == null )
+                {
                     portletHandle = "";
                 }
-                templateBuffer.replace(left_br, right_br, portletHandle);
+                templateBuffer.replace( left_br, right_br, portletHandle );
             }
-            
+
             // userContextKey
-            else if (replaceToken.equalsIgnoreCase(
-                    Constants.USER_CONTEXT_KEY)) {
-                if (userContextKey == null) {
+            else if ( replaceToken.equalsIgnoreCase( Constants.USER_CONTEXT_KEY ) )
+            {
+                if ( userContextKey == null )
+                {
                     userContextKey = "";
                 }
-                templateBuffer.replace(left_br, right_br, userContextKey);
+                templateBuffer.replace( left_br, right_br, userContextKey );
             }
-            
+
             // portletInstanceKey
-            else if (replaceToken.equalsIgnoreCase(
-                    Constants.PORTLET_INSTANCE_KEY)) {
-                if (portletInstanceKey == null) {
+            else if ( replaceToken.equalsIgnoreCase( Constants.PORTLET_INSTANCE_KEY ) )
+            {
+                if ( portletInstanceKey == null )
+                {
                     portletInstanceKey = "";
                 }
-                templateBuffer.replace(left_br, right_br, portletInstanceKey);
+                templateBuffer.replace( left_br, right_br, portletInstanceKey );
             }
-            
+
             // sessionID
-            else if (replaceToken.equalsIgnoreCase(Constants.SESSION_ID)) {
-                if (sessionID == null) {
+            else if ( replaceToken.equalsIgnoreCase( Constants.SESSION_ID ) )
+            {
+                if ( sessionID == null )
+                {
                     sessionID = "";
                 }
-                templateBuffer.replace(left_br, right_br, sessionID);
+                templateBuffer.replace( left_br, right_br, sessionID );
             }
-            
+
             // fragmentID
-            else if (replaceToken.equalsIgnoreCase(Constants.FRAGMENT_ID)) {
+            else if ( replaceToken.equalsIgnoreCase( Constants.FRAGMENT_ID ) )
+            {
                 /* For now don't assign it */
                 String fragmentID = "";
-                templateBuffer.replace(left_br, right_br, fragmentID);
+                templateBuffer.replace( left_br, right_br, fragmentID );
             }
-            
+
             // unknown
-            else {
-                
-                WSRPXHelper.throwX(log, ErrorCodes.UNKNOWN_TOKEN_IN_TEMPLATE);
-                
+            else
+            {
+
+                WSRPXHelper.throwX( LOG, ErrorCodes.UNKNOWN_TOKEN_IN_TEMPLATE );
+
             }
-            
+
             // update template
             template = templateBuffer.toString();
-            
-        }
-        
-        if (log.isDebugEnabled()) {
-            log.debug(Utility.strExit(MN));
+
         }
         
         return template;
     }
-    
+
 }