protected String createTemplate()

in blocks/cocoon-portal/cocoon-portal-wsrp-impl/src/main/java/org/apache/cocoon/portal/wsrp/consumer/URLTemplateComposerImpl.java [268:421]


    protected String createTemplate(String url,
                                    boolean needsURLType,
                                    boolean needsPortletMode,
                                    boolean needsNavState,
                                    boolean needsInteractionState,
                                    boolean needsWinState,
                                    boolean needsSecURL,
                                    boolean needsURL,
                                    boolean needsRewriteResource,
                                    boolean needsPortletHandle,
                                    boolean needsUserContextKey,
                                    boolean needsPortletInstanceKey,
                                    boolean needsSessionID) {

        StringBuffer template = new StringBuffer();
        StringBuffer remainder = null;

        boolean isFirstParam = true;
        int index;

        // check if url already contains parameters
        if ((index = url.indexOf(Constants.PARAMS_START)) != -1) {
            template.append(url.substring(0, index));
            remainder = new StringBuffer(url.substring(index + 1));
        } else {
            template.append(url.toString());
        }

        if (needsURLType) {
            if (isFirstParam) {
                template.append(Constants.PARAMS_START);
                isFirstParam = false;
            }
            template.append(insertPair(Constants.URL_TYPE));
        }

        if (needsPortletMode) {
            if (isFirstParam) {
                template.append(Constants.PARAMS_START);
                isFirstParam = false;
            } else {
                template.append(Constants.NEXT_PARAM);
            }
            template.append(insertPair(Constants.PORTLET_MODE));
        }

        if (needsNavState) {
            if (isFirstParam) {
                template.append(Constants.PARAMS_START);
                isFirstParam = false;
            } else {
                template.append(Constants.NEXT_PARAM);
            }
            template.append(insertPair(Constants.NAVIGATIONAL_STATE));
        }

        if (needsInteractionState) {
            if (isFirstParam) {
                template.append(Constants.PARAMS_START);
                isFirstParam = false;
            } else {
                template.append(Constants.NEXT_PARAM);
            }
            template.append(insertPair(Constants.INTERACTION_STATE));
        }

        if (needsWinState) {
            if (isFirstParam) {
                template.append(Constants.PARAMS_START);
                isFirstParam = false;
            } else {
                template.append(Constants.NEXT_PARAM);
            }
            template.append(insertPair(Constants.WINDOW_STATE));
        }

        if (needsSecURL) {
            if (isFirstParam) {
                template.append(Constants.PARAMS_START);
                isFirstParam = false;
            } else {
                template.append(Constants.NEXT_PARAM);
            }
            template.append(insertPair(Constants.SECURE_URL));
        }

        if (needsURL) {
            if (isFirstParam) {
                template.append(Constants.PARAMS_START);
                isFirstParam = false;
            } else {
                template.append(Constants.NEXT_PARAM);
            }
            template.append(insertPair(Constants.URL));
        }

        if (needsRewriteResource) {
            if (isFirstParam) {
                template.append(Constants.PARAMS_START);
                isFirstParam = false;
            } else {
                template.append(Constants.NEXT_PARAM);
            }
            template.append(insertPair(Constants.REWRITE_RESOURCE));
        }

        if (needsPortletHandle) {
            if (isFirstParam) { 
                template.append(Constants.PARAMS_START);
                isFirstParam = false;
            } else {
                template.append(Constants.NEXT_PARAM);
            }
            template.append(insertPair(Constants.PORTLET_HANDLE));
        }

        if (needsUserContextKey) {
            if (isFirstParam) {
                template.append(Constants.PARAMS_START);
                isFirstParam = false;
            } else {
                template.append(Constants.NEXT_PARAM);
            }
            template.append(insertPair(Constants.USER_CONTEXT_KEY));
        }

        if (needsPortletInstanceKey) {
            if (isFirstParam) {
                template.append(Constants.PARAMS_START);
                isFirstParam = false;
            } else {
                template.append(Constants.NEXT_PARAM);
            }
            template.append(insertPair(Constants.PORTLET_INSTANCE_KEY));
        }

        if (needsSessionID) {
            if (isFirstParam) {
                template.append(Constants.PARAMS_START);
                isFirstParam = false;
            } else {
                template.append(Constants.NEXT_PARAM);
            }
            template.append(insertPair(Constants.SESSION_ID));
        }

        // append remainder (static parameters)
        if (remainder != null) {
            template.append(Constants.NEXT_PARAM);
            template.append(remainder);
        }

        return template.toString();
    }