Example usage for com.liferay.portal.kernel.util StringPool AMPERSAND

List of usage examples for com.liferay.portal.kernel.util StringPool AMPERSAND

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringPool AMPERSAND.

Prototype

String AMPERSAND

To view the source code for com.liferay.portal.kernel.util StringPool AMPERSAND.

Click Source Link

Usage

From source file:com.rivetlogic.ecommerce.paypal.PaypalUtil.java

License:Open Source License

private static void formatParam(StringBuilder sb, String name, Object value) {
    if (!StringPool.QUESTION.equals(sb.subSequence(sb.length() - 1, sb.length() - 1)))
        sb.append(StringPool.AMPERSAND);
    sb.append(String.format("%s=%s", name, HttpUtil.encodeURL(value.toString())));
}

From source file:com.twelve.capital.external.feed.util.HttpImpl.java

License:Open Source License

@Override
public String addParameter(String url, String name, String value) {
    if (url == null) {
        return null;
    }//from w  w  w .ja va  2  s. c o  m

    String[] urlArray = PortalUtil.stripURLAnchor(url, StringPool.POUND);

    url = urlArray[0];

    String anchor = urlArray[1];

    StringBundler sb = new StringBundler(7);

    sb.append(url);

    if (url.indexOf(CharPool.QUESTION) == -1) {
        sb.append(StringPool.QUESTION);
    } else if (!url.endsWith(StringPool.QUESTION) && !url.endsWith(StringPool.AMPERSAND)) {

        sb.append(StringPool.AMPERSAND);
    }

    sb.append(name);
    sb.append(StringPool.EQUAL);
    sb.append(encodeURL(value));
    sb.append(anchor);

    return sb.toString();
}

From source file:com.twelve.capital.external.feed.util.HttpImpl.java

License:Open Source License

@Override
public String parameterMapToString(Map<String, String[]> parameterMap, boolean addQuestion) {

    if (parameterMap.isEmpty()) {
        return StringPool.BLANK;
    }/*from   w  ww . j  a  v  a  2 s  .co m*/

    StringBundler sb = new StringBundler();

    if (addQuestion) {
        sb.append(StringPool.QUESTION);
    }

    for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
        String name = entry.getKey();
        String[] values = entry.getValue();

        for (String value : values) {
            sb.append(name);
            sb.append(StringPool.EQUAL);
            sb.append(encodeURL(value));
            sb.append(StringPool.AMPERSAND);
        }
    }

    if (sb.index() > 1) {
        sb.setIndex(sb.index() - 1);
    }

    return sb.toString();
}

From source file:com.twelve.capital.external.feed.util.HttpImpl.java

License:Open Source License

@Override
public String removeParameter(String url, String name) {
    if (Validator.isNull(url) || Validator.isNull(name)) {
        return url;
    }//from  w  w  w  .  ja  va 2  s  . c o  m

    int pos = url.indexOf(CharPool.QUESTION);

    if (pos == -1) {
        return url;
    }

    String[] array = PortalUtil.stripURLAnchor(url, StringPool.POUND);

    url = array[0];

    String anchor = array[1];

    StringBundler sb = new StringBundler();

    sb.append(url.substring(0, pos + 1));

    String[] parameters = StringUtil.split(url.substring(pos + 1, url.length()), CharPool.AMPERSAND);

    for (String parameter : parameters) {
        if (parameter.length() > 0) {
            String[] kvp = StringUtil.split(parameter, CharPool.EQUAL);

            String key = kvp[0];

            String value = StringPool.BLANK;

            if (kvp.length > 1) {
                value = kvp[1];
            }

            if (!key.equals(name)) {
                sb.append(key);
                sb.append(StringPool.EQUAL);
                sb.append(value);
                sb.append(StringPool.AMPERSAND);
            }
        }
    }

    url = StringUtil.replace(sb.toString(), StringPool.AMPERSAND + StringPool.AMPERSAND, StringPool.AMPERSAND);

    if (url.endsWith(StringPool.AMPERSAND)) {
        url = url.substring(0, url.length() - 1);
    }

    if (url.endsWith(StringPool.QUESTION)) {
        url = url.substring(0, url.length() - 1);
    }

    return url + anchor;
}

From source file:de.olafkock.liferay.blogs.PodcastingUtil.java

License:Open Source License

public static String exportToRSS(String name, String description, String type, double version,
        String displayStyle, String feedURL, String entryURL, List<BlogsEntry> blogsEntries,
        ThemeDisplay themeDisplay) throws SystemException, PortalException {

    SyndFeed syndFeed = new SyndFeedImpl();

    syndFeed.setFeedType(RSSUtil.getFeedType(type, version));
    syndFeed.setTitle(name);/*from   w w w .  j  a v  a 2s . c  o m*/
    syndFeed.setLink(feedURL);
    syndFeed.setDescription(description);

    List<SyndEntry> syndEntries = new ArrayList<SyndEntry>();

    syndFeed.setEntries(syndEntries);

    for (BlogsEntry entry : blogsEntries) {
        String author = HtmlUtil.escape(PortalUtil.getUserName(entry.getUserId(), entry.getUserName()));

        StringBundler link = new StringBundler(4);

        if (entryURL.endsWith("/blogs/rss")) {
            link.append(entryURL.substring(0, entryURL.length() - 3));
            link.append(entry.getUrlTitle());
        } else {
            link.append(entryURL);

            if (!entryURL.endsWith(StringPool.QUESTION)) {
                link.append(StringPool.AMPERSAND);
            }

            link.append("entryId=");
            link.append(entry.getEntryId());
        }

        String value = null;

        if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) {
            String summary = entry.getDescription();

            if (Validator.isNull(summary)) {
                summary = entry.getContent();
            }

            value = StringUtil.shorten(HtmlUtil.extractText(summary),
                    200 /* PropsValues.BLOGS_RSS_ABSTRACT_LENGTH */, StringPool.BLANK);
        } else if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) {
            value = StringPool.BLANK;
        } else {
            value = StringUtil.replace(entry.getContent(), new String[] { "href=\"/", "src=\"/" },
                    new String[] { "href=\"" + themeDisplay.getURLPortal() + "/",
                            "src=\"" + themeDisplay.getURLPortal() + "/" });
        }

        SyndEntry syndEntry = new SyndEntryImpl();

        syndEntry.setAuthor(author);
        syndEntry.setTitle(entry.getTitle());
        syndEntry.setLink(link.toString());
        syndEntry.setUri(syndEntry.getLink());
        syndEntry.setPublishedDate(entry.getCreateDate());
        syndEntry.setUpdatedDate(entry.getModifiedDate());

        SyndEnclosure enclosure = getEnclosure(entry.getCompanyId(), entry.getPrimaryKey());
        if (enclosure != null) {
            List<SyndEnclosure> enclosures = new LinkedList<SyndEnclosure>();
            enclosures.add(enclosure);
            syndEntry.setEnclosures(enclosures);
            EntryInformation info = getItunesInfo(entry);
            ArrayList<EntryInformation> modules = new ArrayList<EntryInformation>();
            modules.add(info);
            syndEntry.setModules(modules);
        }

        SyndContent syndContent = new SyndContentImpl();

        syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT);
        syndContent.setValue(value);

        syndEntry.setDescription(syndContent);

        syndEntries.add(syndEntry);
    }

    try {
        return RSSUtil.export(syndFeed);
    } catch (FeedException fe) {
        throw new SystemException(fe);
    }
}

From source file:org.apache.jsp.html.portlet.communities.tree_005fjs_jsp.java

License:Open Source License

public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;/*from   w w w  .j a  v a  2 s.c o  m*/
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
        response.setContentType("text/html; charset=UTF-8");
        pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
        _jspx_page_context = pageContext;
        application = pageContext.getServletContext();
        config = pageContext.getServletConfig();
        session = pageContext.getSession();
        out = pageContext.getOut();
        _jspx_out = out;

        /**
         * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
         *
         * This library is free software; you can redistribute it and/or modify it under
         * the terms of the GNU Lesser General Public License as published by the Free
         * Software Foundation; either version 2.1 of the License, or (at your option)
         * any later version.
         *
         * This library is distributed in the hope that it will be useful, but WITHOUT
         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
         * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
         * details.
         */

        out.write('\n');
        out.write('\n');

        /**
         * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
         *
         * This library is free software; you can redistribute it and/or modify it under
         * the terms of the GNU Lesser General Public License as published by the Free
         * Software Foundation; either version 2.1 of the License, or (at your option)
         * any later version.
         *
         * This library is distributed in the hope that it will be useful, but WITHOUT
         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
         * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
         * details.
         */

        out.write('\n');
        out.write('\n');

        /**
         * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
         *
         * This library is free software; you can redistribute it and/or modify it under
         * the terms of the GNU Lesser General Public License as published by the Free
         * Software Foundation; either version 2.1 of the License, or (at your option)
         * any later version.
         *
         * This library is distributed in the hope that it will be useful, but WITHOUT
         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
         * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
         * details.
         */

        out.write('\n');
        out.write('\n');

        /**
         * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
         *
         * This library is free software; you can redistribute it and/or modify it under
         * the terms of the GNU Lesser General Public License as published by the Free
         * Software Foundation; either version 2.1 of the License, or (at your option)
         * any later version.
         *
         * This library is distributed in the hope that it will be useful, but WITHOUT
         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
         * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
         * details.
         */

        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        //  liferay-theme:defineObjects
        com.liferay.taglib.theme.DefineObjectsTag _jspx_th_liferay_002dtheme_005fdefineObjects_005f0 = (com.liferay.taglib.theme.DefineObjectsTag) _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody
                .get(com.liferay.taglib.theme.DefineObjectsTag.class);
        _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setPageContext(_jspx_page_context);
        _jspx_th_liferay_002dtheme_005fdefineObjects_005f0.setParent(null);
        int _jspx_eval_liferay_002dtheme_005fdefineObjects_005f0 = _jspx_th_liferay_002dtheme_005fdefineObjects_005f0
                .doStartTag();
        if (_jspx_th_liferay_002dtheme_005fdefineObjects_005f0
                .doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
            _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody
                    .reuse(_jspx_th_liferay_002dtheme_005fdefineObjects_005f0);
            return;
        }
        _005fjspx_005ftagPool_005fliferay_002dtheme_005fdefineObjects_005fnobody
                .reuse(_jspx_th_liferay_002dtheme_005fdefineObjects_005f0);
        com.liferay.portal.theme.ThemeDisplay themeDisplay = null;
        com.liferay.portal.model.Company company = null;
        com.liferay.portal.model.Account account = null;
        com.liferay.portal.model.User user = null;
        com.liferay.portal.model.User realUser = null;
        com.liferay.portal.model.Contact contact = null;
        com.liferay.portal.model.Layout layout = null;
        java.util.List layouts = null;
        java.lang.Long plid = null;
        com.liferay.portal.model.LayoutTypePortlet layoutTypePortlet = null;
        java.lang.Long scopeGroupId = null;
        com.liferay.portal.security.permission.PermissionChecker permissionChecker = null;
        java.util.Locale locale = null;
        java.util.TimeZone timeZone = null;
        com.liferay.portal.model.Theme theme = null;
        com.liferay.portal.model.ColorScheme colorScheme = null;
        com.liferay.portal.theme.PortletDisplay portletDisplay = null;
        java.lang.Long portletGroupId = null;
        themeDisplay = (com.liferay.portal.theme.ThemeDisplay) _jspx_page_context.findAttribute("themeDisplay");
        company = (com.liferay.portal.model.Company) _jspx_page_context.findAttribute("company");
        account = (com.liferay.portal.model.Account) _jspx_page_context.findAttribute("account");
        user = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("user");
        realUser = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("realUser");
        contact = (com.liferay.portal.model.Contact) _jspx_page_context.findAttribute("contact");
        layout = (com.liferay.portal.model.Layout) _jspx_page_context.findAttribute("layout");
        layouts = (java.util.List) _jspx_page_context.findAttribute("layouts");
        plid = (java.lang.Long) _jspx_page_context.findAttribute("plid");
        layoutTypePortlet = (com.liferay.portal.model.LayoutTypePortlet) _jspx_page_context
                .findAttribute("layoutTypePortlet");
        scopeGroupId = (java.lang.Long) _jspx_page_context.findAttribute("scopeGroupId");
        permissionChecker = (com.liferay.portal.security.permission.PermissionChecker) _jspx_page_context
                .findAttribute("permissionChecker");
        locale = (java.util.Locale) _jspx_page_context.findAttribute("locale");
        timeZone = (java.util.TimeZone) _jspx_page_context.findAttribute("timeZone");
        theme = (com.liferay.portal.model.Theme) _jspx_page_context.findAttribute("theme");
        colorScheme = (com.liferay.portal.model.ColorScheme) _jspx_page_context.findAttribute("colorScheme");
        portletDisplay = (com.liferay.portal.theme.PortletDisplay) _jspx_page_context
                .findAttribute("portletDisplay");
        portletGroupId = (java.lang.Long) _jspx_page_context.findAttribute("portletGroupId");
        out.write('\n');
        out.write('\n');

        /**
         * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
         *
         * This library is free software; you can redistribute it and/or modify it under
         * the terms of the GNU Lesser General Public License as published by the Free
         * Software Foundation; either version 2.1 of the License, or (at your option)
         * any later version.
         *
         * This library is distributed in the hope that it will be useful, but WITHOUT
         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
         * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
         * details.
         */

        out.write('\n');
        out.write('\n');
        //  portlet:defineObjects
        com.liferay.taglib.portlet.DefineObjectsTag _jspx_th_portlet_005fdefineObjects_005f0 = (com.liferay.taglib.portlet.DefineObjectsTag) _005fjspx_005ftagPool_005fportlet_005fdefineObjects_005fnobody
                .get(com.liferay.taglib.portlet.DefineObjectsTag.class);
        _jspx_th_portlet_005fdefineObjects_005f0.setPageContext(_jspx_page_context);
        _jspx_th_portlet_005fdefineObjects_005f0.setParent(null);
        int _jspx_eval_portlet_005fdefineObjects_005f0 = _jspx_th_portlet_005fdefineObjects_005f0.doStartTag();
        if (_jspx_th_portlet_005fdefineObjects_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
            _005fjspx_005ftagPool_005fportlet_005fdefineObjects_005fnobody
                    .reuse(_jspx_th_portlet_005fdefineObjects_005f0);
            return;
        }
        _005fjspx_005ftagPool_005fportlet_005fdefineObjects_005fnobody
                .reuse(_jspx_th_portlet_005fdefineObjects_005f0);
        javax.portlet.ActionRequest actionRequest = null;
        javax.portlet.ActionResponse actionResponse = null;
        javax.portlet.EventRequest eventRequest = null;
        javax.portlet.EventResponse eventResponse = null;
        javax.portlet.PortletConfig portletConfig = null;
        java.lang.String portletName = null;
        javax.portlet.PortletPreferences portletPreferences = null;
        java.util.Map portletPreferencesValues = null;
        javax.portlet.PortletSession portletSession = null;
        java.util.Map portletSessionScope = null;
        javax.portlet.RenderRequest renderRequest = null;
        javax.portlet.RenderResponse renderResponse = null;
        javax.portlet.ResourceRequest resourceRequest = null;
        javax.portlet.ResourceResponse resourceResponse = null;
        actionRequest = (javax.portlet.ActionRequest) _jspx_page_context.findAttribute("actionRequest");
        actionResponse = (javax.portlet.ActionResponse) _jspx_page_context.findAttribute("actionResponse");
        eventRequest = (javax.portlet.EventRequest) _jspx_page_context.findAttribute("eventRequest");
        eventResponse = (javax.portlet.EventResponse) _jspx_page_context.findAttribute("eventResponse");
        portletConfig = (javax.portlet.PortletConfig) _jspx_page_context.findAttribute("portletConfig");
        portletName = (java.lang.String) _jspx_page_context.findAttribute("portletName");
        portletPreferences = (javax.portlet.PortletPreferences) _jspx_page_context
                .findAttribute("portletPreferences");
        portletPreferencesValues = (java.util.Map) _jspx_page_context.findAttribute("portletPreferencesValues");
        portletSession = (javax.portlet.PortletSession) _jspx_page_context.findAttribute("portletSession");
        portletSessionScope = (java.util.Map) _jspx_page_context.findAttribute("portletSessionScope");
        renderRequest = (javax.portlet.RenderRequest) _jspx_page_context.findAttribute("renderRequest");
        renderResponse = (javax.portlet.RenderResponse) _jspx_page_context.findAttribute("renderResponse");
        resourceRequest = (javax.portlet.ResourceRequest) _jspx_page_context.findAttribute("resourceRequest");
        resourceResponse = (javax.portlet.ResourceResponse) _jspx_page_context
                .findAttribute("resourceResponse");
        out.write('\n');
        out.write('\n');

        WindowState windowState = null;
        PortletMode portletMode = null;

        PortletURL currentURLObj = null;

        if (renderRequest != null) {
            windowState = renderRequest.getWindowState();
            portletMode = renderRequest.getPortletMode();

            currentURLObj = PortletURLUtil.getCurrent(renderRequest, renderResponse);
        } else if (resourceRequest != null) {
            windowState = resourceRequest.getWindowState();
            portletMode = resourceRequest.getPortletMode();

            currentURLObj = PortletURLUtil.getCurrent(resourceRequest, resourceResponse);
        }

        String currentURL = currentURLObj.toString();
        //String currentURL = PortalUtil.getCurrentURL(request);

        out.write('\n');
        out.write('\n');

        /**
         * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
         *
         * This library is free software; you can redistribute it and/or modify it under
         * the terms of the GNU Lesser General Public License as published by the Free
         * Software Foundation; either version 2.1 of the License, or (at your option)
         * any later version.
         *
         * This library is distributed in the hope that it will be useful, but WITHOUT
         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
         * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
         * details.
         */

        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");
        out.write("\n");

        Format dateFormatDate = FastDateFormatFactoryUtil.getDate(locale, timeZone);
        Format dateFormatDateTime = FastDateFormatFactoryUtil.getDateTime(locale, timeZone);

        out.write('\n');
        out.write('\n');

        long groupId = ((Long) request.getAttribute("edit_pages.jsp-groupId")).longValue();
        long selPlid = ((Long) request.getAttribute("edit_pages.jsp-selPlid")).longValue();
        boolean privateLayout = ((Boolean) request.getAttribute("edit_pages.jsp-privateLayout")).booleanValue();

        String rootNodeName = (String) request.getAttribute("edit_pages.jsp-rootNodeName");

        boolean selectableTree = ParamUtil.getBoolean(request, "selectableTree");
        String treeId = ParamUtil.getString(request, "treeId");

        PortletURL portletURL = (PortletURL) request.getAttribute("edit_pages.jsp-portletURL");

        out.write("\n");
        out.write("\n");
        out.write("<div class=\"lfr-tree-loading\" id=\"");
        if (_jspx_meth_portlet_005fnamespace_005f0(_jspx_page_context))
            return;
        out.write("treeLoading\">\n");
        out.write("\t<span class=\"aui-icon aui-icon-loading lfr-tree-loading-icon\"></span>\n");
        out.write("</div>\n");
        out.write("\n");
        out.write("<div class=\"lfr-tree\" id=\"");
        if (_jspx_meth_portlet_005fnamespace_005f1(_jspx_page_context))
            return;
        out.print(HtmlUtil.escape(treeId));
        out.write("Output\"></div>\n");
        out.write("\n");
        //  aui:script
        com.liferay.taglib.aui.ScriptTag _jspx_th_aui_005fscript_005f0 = (com.liferay.taglib.aui.ScriptTag) _005fjspx_005ftagPool_005faui_005fscript_0026_005fuse
                .get(com.liferay.taglib.aui.ScriptTag.class);
        _jspx_th_aui_005fscript_005f0.setPageContext(_jspx_page_context);
        _jspx_th_aui_005fscript_005f0.setParent(null);
        // /html/portlet/communities/tree_js.jsp(38,0) name = use type = null reqTime = true required = false fragment = false deferredValue = false expectedTypeName = null deferredMethod = false methodSignature = null
        _jspx_th_aui_005fscript_005f0.setUse("aui-io-request,aui-tree-view,dataschema-xml,datatype-xml");
        int _jspx_eval_aui_005fscript_005f0 = _jspx_th_aui_005fscript_005f0.doStartTag();
        if (_jspx_eval_aui_005fscript_005f0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
            if (_jspx_eval_aui_005fscript_005f0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {
                out = _jspx_page_context.pushBody();
                _jspx_th_aui_005fscript_005f0.setBodyContent((javax.servlet.jsp.tagext.BodyContent) out);
                _jspx_th_aui_005fscript_005f0.doInitBody();
            }
            do {
                out.write("\n");
                out.write("\tvar TreeUtil = {\n");
                out.write("\t\tDEFAULT_PARENT_LAYOUT_ID: ");
                out.print(LayoutConstants.DEFAULT_PARENT_LAYOUT_ID);
                out.write(",\n");
                out.write("\t\tOPEN_NODES: '");
                out.print(SessionTreeJSClicks.getOpenNodes(request, treeId));
                out.write("'.split(','),\n");
                out.write("\t\tPREFIX_LAYOUT_ID: '_layoutId_',\n");
                out.write("\t\tPREFIX_PLID: '_plid_',\n");
                out.write("\t\tSELECTED_NODES: '");
                out.print(SessionTreeJSClicks.getOpenNodes(request, treeId + "SelectedNode"));
                out.write("'.split(','),\n");
                out.write("\n");
                out.write("\t\tafterRenderTree: function(event) {\n");
                out.write("\t\t\tvar treeInstance = event.target;\n");
                out.write("\n");
                out.write("\t\t\tvar rootNode = treeInstance.item(0);\n");
                out.write("\t\t\tvar loadingEl = A.one('#");
                if (_jspx_meth_portlet_005fnamespace_005f2(_jspx_th_aui_005fscript_005f0, _jspx_page_context))
                    return;
                out.write("treeLoading');\n");
                out.write("\n");
                out.write("\t\t\tloadingEl.hide();\n");
                out.write("\n");
                out.write("\t\t\tTreeUtil.restoreNodeState(rootNode);\n");
                out.write("\t\t},\n");
                out.write("\n");
                out.write("\t\tcreateId: function(layoutId, plid) {\n");
                out.write("\t\t\treturn '");
                out.print(HtmlUtil.escape(treeId));
                out.write("' + TreeUtil.PREFIX_LAYOUT_ID + layoutId + TreeUtil.PREFIX_PLID + plid;\n");
                out.write("\t\t},\n");
                out.write("\n");
                out.write("\t\tcreateLink: function(label, plid) {\n");
                out.write("\t\t\treturn '<a href=\"");
                out.print(portletURL + StringPool.AMPERSAND + portletDisplay.getNamespace() + "selPlid=");
                out.write("'+ plid +'\">'+ Liferay.Util.escapeHTML(label) +'</a>';\n");
                out.write("\t\t},\n");
                out.write("\n");
                out.write("\t\textractLayoutId: function(node) {\n");
                out.write("\t\t\treturn node.get('id').match(/layoutId_(\\d+)/)[1];\n");
                out.write("\t\t},\n");
                out.write("\n");
                out.write("\t\textractPlid: function(node) {\n");
                out.write("\t\t\treturn node.get('id').match(/plid_(\\d+)/)[1];\n");
                out.write("\t\t},\n");
                out.write("\n");
                out.write("\t\tformatJSONResults: function(json) {\n");
                out.write("\t\t\tvar output = [];\n");
                out.write("\n");
                out.write("\t\t\tA.each(\n");
                out.write("\t\t\t\tjson,\n");
                out.write("\t\t\t\tfunction(node) {\n");
                out.write("\t\t\t\t\tvar nameXML = A.DataType.XML.parse(node.name);\n");
                out.write("\n");
                out.write("\t\t\t\t\tvar schema = {\n");
                out.write("\t\t\t\t\t\tresultListLocator: 'root',\n");
                out.write("\t\t\t\t\t\tresultFields: [\n");
                out.write("\t\t\t\t\t\t\t{\n");
                out.write("\t\t\t\t\t\t\t\tkey: 'label',\n");
                out.write("\t\t\t\t\t\t\t\tlocator: 'name'\n");
                out.write("\t\t\t\t\t\t\t}\n");
                out.write("\t\t\t\t\t\t]\n");
                out.write("\t\t\t\t\t};\n");
                out.write("\n");
                out.write("\t\t\t\t\tvar nodeBase = A.DataSchema.XML.apply(schema, nameXML).results[0];\n");
                out.write("\n");
                out.write("\t\t\t\t\tvar newNode = A.mix(\n");
                out.write("\t\t\t\t\t\tnodeBase,\n");
                out.write("\t\t\t\t\t\t{\n");
                out.write("\t\t\t\t\t\t\tafter: {\n");
                out.write("\t\t\t\t\t\t\t\tcheck: function(event) {\n");
                out.write("\t\t\t\t\t\t\t\t\tvar plid = TreeUtil.extractPlid(event.target);\n");
                out.write("\n");
                out.write("\t\t\t\t\t\t\t\t\tTreeUtil.updateSessionTreeClick(plid, true, '");
                out.print(HtmlUtil.escape(treeId));
                out.write("SelectedNode');\n");
                out.write("\t\t\t\t\t\t\t\t},\n");
                out.write("\t\t\t\t\t\t\t\tuncheck: function(event) {\n");
                out.write("\t\t\t\t\t\t\t\t\tvar plid = TreeUtil.extractPlid(event.target);\n");
                out.write("\n");
                out.write("\t\t\t\t\t\t\t\t\tTreeUtil.updateSessionTreeClick(plid, false, '");
                out.print(HtmlUtil.escape(treeId));
                out.write("SelectedNode');\n");
                out.write("\t\t\t\t\t\t\t\t}\n");
                out.write("\t\t\t\t\t\t\t},\n");
                out.write("\t\t\t\t\t\t\talwaysShowHitArea: node.hasChildren,\n");
                out.write("\t\t\t\t\t\t\tid: TreeUtil.createId(node.layoutId, node.plid),\n");
                out.write("\t\t\t\t\t\t\ttype: '");
                out.print(selectableTree ? "task" : "io");
                out.write("'\n");
                out.write("\t\t\t\t\t\t}\n");
                out.write("\t\t\t\t\t);\n");
                out.write("\n");
                out.write("\t\t\t\t\tif (!");
                out.print(selectableTree);
                out.write(") {\n");
                out.write("\t\t\t\t\t\tnewNode.label = TreeUtil.createLink(newNode.label, node.plid);\n");
                out.write("\t\t\t\t\t}\n");
                out.write("\n");
                out.write("\t\t\t\t\toutput.push(newNode);\n");
                out.write("\t\t\t\t}\n");
                out.write("\t\t\t);\n");
                out.write("\n");
                out.write("\t\t\treturn output;\n");
                out.write("\t\t},\n");
                out.write("\n");
                out.write("\t\trestoreNodeState: function(node) {\n");
                out.write("\t\t\tvar instance = this;\n");
                out.write("\n");
                out.write("\t\t\tvar id = node.get('id');\n");
                out.write("\t\t\tvar plid = TreeUtil.extractPlid(node);\n");
                out.write("\n");
                out.write("\t\t\tif (plid == '");
                out.print(selPlid);
                out.write("') {\n");
                out.write("\t\t\t\tnode.select();\n");
                out.write("\t\t\t}\n");
                out.write("\n");
                out.write("\t\t\tif (A.Array.indexOf(TreeUtil.OPEN_NODES, id) > -1) {\n");
                out.write("\t\t\t\tnode.expand();\n");
                out.write("\t\t\t}\n");
                out.write("\n");
                out.write("\t\t\tif (A.Array.indexOf(TreeUtil.SELECTED_NODES, plid) > -1) {\n");
                out.write("\t\t\t\tif (node.check) {\n");
                out.write("\t\t\t\t\tnode.check();\n");
                out.write("\t\t\t\t}\n");
                out.write("\t\t\t}\n");
                out.write("\t\t},\n");
                out.write("\n");
                out.write("\t\tupdateLayout: function(data) {\n");
                out.write(
                        "\t\t\tvar updateURL = themeDisplay.getPathMain() + '/layout_management/update_page';\n");
                out.write("\n");
                out.write("\t\t\tA.io.request(\n");
                out.write("\t\t\t\tupdateURL,\n");
                out.write("\t\t\t\t{\n");
                out.write("\t\t\t\t\tdata: data\n");
                out.write("\t\t\t\t}\n");
                out.write("\t\t\t);\n");
                out.write("\t\t},\n");
                out.write("\n");
                out.write("\t\tupdateLayoutParent: function(dragPlid, dropPlid) {\n");
                out.write("\t\t\tTreeUtil.updateLayout(\n");
                out.write("\t\t\t\t{\n");
                out.write("\t\t\t\t\tcmd: 'parent_layout_id',\n");
                out.write("\t\t\t\t\tparentPlid: dropPlid,\n");
                out.write("\t\t\t\t\tplid: dragPlid\n");
                out.write("\t\t\t\t}\n");
                out.write("\t\t\t);\n");
                out.write("\t\t},\n");
                out.write("\n");
                out.write("\t\tupdateLayoutPriority: function(dragPlid, index) {\n");
                out.write("\t\t\tTreeUtil.updateLayout(\n");
                out.write("\t\t\t\t{\n");
                out.write("\t\t\t\t\tcmd: 'priority',\n");
                out.write("\t\t\t\t\tplid: dragPlid,\n");
                out.write("\t\t\t\t\tpriority: index\n");
                out.write("\t\t\t\t}\n");
                out.write("\t\t\t);\n");
                out.write("\t\t},\n");
                out.write("\n");
                out.write("\t\tupdateSessionTreeClick: function(id, open, treeId) {\n");
                out.write(
                        "\t\t\tvar sessionClickURL = themeDisplay.getPathMain() + '/portal/session_tree_js_click';\n");
                out.write("\n");
                out.write("\t\t\tvar data = {\n");
                out.write("\t\t\t\tnodeId: id,\n");
                out.write("\t\t\t\topenNode: open || false,\n");
                out.write("\t\t\t\ttreeId: treeId\n");
                out.write("\t\t\t};\n");
                out.write("\n");
                out.write("\t\t\tA.io.request(\n");
                out.write("\t\t\t\tsessionClickURL,\n");
                out.write("\t\t\t\t{\n");
                out.write("\t\t\t\t\tdata: data\n");
                out.write("\t\t\t\t}\n");
                out.write("\t\t\t);\n");
                out.write("\t\t}\n");
                out.write("\t};\n");
                out.write("\n");
                out.write(
                        "\tvar getLayoutsURL = themeDisplay.getPathMain() + '/layout_management/get_layouts';\n");
                out.write("\tvar rootId = TreeUtil.createId(TreeUtil.DEFAULT_PARENT_LAYOUT_ID, 0);\n");
                out.write("\tvar rootLabel = '");
                out.print(HtmlUtil.escape(rootNodeName));
                out.write("';\n");
                out.write("\tvar treeElId = '");
                if (_jspx_meth_portlet_005fnamespace_005f3(_jspx_th_aui_005fscript_005f0, _jspx_page_context))
                    return;
                out.print(HtmlUtil.escape(treeId));
                out.write("Output';\n");
                out.write("\n");
                out.write("\tvar RootNodeType = A.TreeNodeTask;\n");
                out.write("\tvar TreeViewType = A.TreeView;\n");
                out.write("\n");
                out.write("\tif (!");
                out.print(selectableTree);
                out.write(") {\n");
                out.write("\t\tRootNodeType = A.TreeNodeIO;\n");
                out.write("\t\tTreeViewType = A.TreeViewDD;\n");
                out.write("\n");
                out.write(
                        "\t\trootLabel = TreeUtil.createLink(rootLabel, TreeUtil.DEFAULT_PARENT_LAYOUT_ID);\n");
                out.write("\t}\n");
                out.write("\n");
                out.write("\tvar rootNode = new RootNodeType(\n");
                out.write("\t\t{\n");
                out.write("\t\t\talwaysShowHitArea: true,\n");
                out.write("\t\t\tdraggable: false,\n");
                out.write("\t\t\tid: rootId,\n");
                out.write("\t\t\tlabel: rootLabel,\n");
                out.write("\t\t\tleaf: false\n");
                out.write("\t\t}\n");
                out.write("\t);\n");
                out.write("\n");
                out.write("\trootNode.get('contentBox').addClass('lfr-root-node');\n");
                out.write("\n");
                out.write("\tvar treeview = new TreeViewType(\n");
                out.write("\t\t{\n");
                out.write("\t\t\tafter: {\n");
                out.write("\t\t\t\tcollapse: function(event) {\n");
                out.write("\t\t\t\t\tvar id = event.tree.node.get('id');\n");
                out.write("\n");
                out.write("\t\t\t\t\tTreeUtil.updateSessionTreeClick(id, false, '");
                out.print(HtmlUtil.escape(treeId));
                out.write("');\n");
                out.write("\t\t\t\t},\n");
                out.write("\t\t\t\texpand: function(event) {\n");
                out.write("\t\t\t\t\tvar id = event.tree.node.get('id');\n");
                out.write("\n");
                out.write("\t\t\t\t\tTreeUtil.updateSessionTreeClick(id, true, '");
                out.print(HtmlUtil.escape(treeId));
                out.write("');\n");
                out.write("\t\t\t\t},\n");
                out.write("\t\t\t\trender: TreeUtil.afterRenderTree\n");
                out.write("\t\t\t},\n");
                out.write("\t\t\tboundingBox: '#' + treeElId,\n");
                out.write("\t\t\tchildren: [rootNode],\n");
                out.write("\t\t\tio: {\n");
                out.write("\t\t\t\tcfg: {\n");
                out.write("\t\t\t\t\tdata: function(node) {\n");
                out.write("\t\t\t\t\t\tvar parentLayoutId = TreeUtil.extractLayoutId(node);\n");
                out.write("\n");
                out.write("\t\t\t\t\t\treturn {\n");
                out.write("\t\t\t\t\t\t\tgroupId: ");
                out.print(groupId);
                out.write(",\n");
                out.write("\t\t\t\t\t\t\tprivateLayout: ");
                out.print(privateLayout);
                out.write(",\n");
                out.write("\t\t\t\t\t\t\tparentLayoutId: parentLayoutId\n");
                out.write("\t\t\t\t\t\t};\n");
                out.write("\t\t\t\t\t},\n");
                out.write("\t\t\t\t\tmethod: AUI.defaults.io.method\n");
                out.write("\t\t\t\t},\n");
                out.write("\t\t\t\tformatter: TreeUtil.formatJSONResults,\n");
                out.write("\t\t\t\turl: getLayoutsURL\n");
                out.write("\t\t\t},\n");
                out.write("\t\t\ton: {\n");
                out.write("\t\t\t\tappend: function(event) {\n");
                out.write("\t\t\t\t\tTreeUtil.restoreNodeState(event.tree.node);\n");
                out.write("\t\t\t\t},\n");
                out.write("\t\t\t\tdrop: function(event) {\n");
                out.write("\t\t\t\t\tvar tree = event.tree;\n");
                out.write("\n");
                out.write("\t\t\t\t\tvar index = tree.dragNode.get('parentNode').indexOf(tree.dragNode);\n");
                out.write("\n");
                out.write("\t\t\t\t\tTreeUtil.updateLayoutPriority(\n");
                out.write("\t\t\t\t\t\tTreeUtil.extractPlid(tree.dragNode),\n");
                out.write("\t\t\t\t\t\tindex\n");
                out.write("\t\t\t\t\t);\n");
                out.write("\t\t\t\t},\n");
                out.write("\t\t\t\tdropAppend: function(event) {\n");
                out.write("\t\t\t\t\tvar tree = event.tree;\n");
                out.write("\n");
                out.write("\t\t\t\t\tTreeUtil.updateLayoutParent(\n");
                out.write("\t\t\t\t\t\tTreeUtil.extractPlid(tree.dragNode),\n");
                out.write("\t\t\t\t\t\tTreeUtil.extractPlid(tree.dropNode)\n");
                out.write("\t\t\t\t\t);\n");
                out.write("\t\t\t\t},\n");
                out.write("\t\t\t\tdropInsert: function(event) {\n");
                out.write("\t\t\t\t\tvar tree = event.tree;\n");
                out.write("\n");
                out.write("\t\t\t\t\tTreeUtil.updateLayoutParent(\n");
                out.write("\t\t\t\t\t\tTreeUtil.extractPlid(tree.dragNode),\n");
                out.write("\t\t\t\t\t\tTreeUtil.extractPlid(tree.dropNode.get('parentNode'))\n");
                out.write("\t\t\t\t\t);\n");
                out.write("\t\t\t\t}\n");
                out.write("\t\t\t},\n");
                out.write("\t\t\ttype: 'pages'\n");
                out.write("\t\t}\n");
                out.write("\t).render();\n");
                int evalDoAfterBody = _jspx_th_aui_005fscript_005f0.doAfterBody();
                if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)
                    break;
            } while (true);
            if (_jspx_eval_aui_005fscript_005f0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {
                out = _jspx_page_context.popBody();
            }
        }
        if (_jspx_th_aui_005fscript_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
            _005fjspx_005ftagPool_005faui_005fscript_0026_005fuse.reuse(_jspx_th_aui_005fscript_005f0);
            return;
        }
        _005fjspx_005ftagPool_005faui_005fscript_0026_005fuse.reuse(_jspx_th_aui_005fscript_005f0);
    } catch (Throwable t) {
        if (!(t instanceof SkipPageException)) {
            out = _jspx_out;
            if (out != null && out.getBufferSize() != 0)
                try {
                    out.clearBuffer();
                } catch (java.io.IOException e) {
                }
            if (_jspx_page_context != null)
                _jspx_page_context.handlePageException(t);
        }
    } finally {
        _jspxFactory.releasePageContext(_jspx_page_context);
    }
}

From source file:org.opencps.backend.util.PaymentUrlGenerator.java

License:Open Source License

public static PaymentFile generatorPayURL(long groupId, long govAgencyOrganizationId, long paymentFileId,
        String pattern, long dossierId) throws IOException {

    PaymentFile paymentFile = null;// w  w w  . jav  a 2  s .  c o  m
    try {

        paymentFile = PaymentFileLocalServiceUtil.getPaymentFile(paymentFileId);
    } catch (NoSuchPaymentFileException e) {
        _log.error(e);
    } catch (Exception e) {
        _log.error(e);
    }
    PaymentConfig paymentConfig = null;

    if (Validator.isNotNull(paymentFile))

        paymentConfig = PaymentMgtUtil.validatePaymentConfig(groupId, paymentFile.getGovAgencyOrganizationId());

    Dossier dossier = null;
    String url_redirect = StringPool.BLANK;

    if (Validator.isNotNull(paymentConfig)) {

        List<PaymentGateConfig> paymentGateConfigList = new ArrayList<PaymentGateConfig>();
        try {
            paymentGateConfigList = PaymentGateConfigLocalServiceUtil.getPaymentGateConfigs(QueryUtil.ALL_POS,
                    QueryUtil.ALL_POS);
        } catch (SystemException e1) {
            // TODO Auto-generated catch block
            _log.error(e1);
        }

        for (PaymentGateConfig paymentGateConfig : paymentGateConfigList) {

            if (paymentGateConfig.getPaymentGateId() == paymentConfig.getPaymentGateType()
                    && paymentGateConfig.getPaymentGateName().equals("VTCPAY")) {

                // set du lieu cho request
                String website_id = StringPool.BLANK;
                String receiver_account = StringPool.BLANK;
                String language = StringPool.BLANK;
                String url_return = StringPool.BLANK;
                String secret_key = StringPool.BLANK;
                String reference_number = StringPool.BLANK;
                String amount = StringPool.BLANK;
                String currency = StringPool.BLANK;
                String request_url = StringPool.BLANK;
                String trans_ref_no = StringPool.BLANK;
                String status = StringPool.BLANK;
                String data = StringPool.BLANK;
                String signature = StringPool.BLANK;

                request_url = paymentConfig.getKeypayDomain() + StringPool.QUESTION;
                website_id = paymentConfig.getKeypayMerchantCode();
                receiver_account = paymentConfig.getBankInfo();
                secret_key = paymentConfig.getKeypaySecureKey();

                reference_number = String.valueOf(_genetatorTransactionId());

                Double amountDouble = paymentFile.getAmount();
                int amountInt = amountDouble.intValue();
                amount = String.valueOf(amountInt);

                currency = "VND";

                dossier = _getDossier(dossierId);

                url_return = paymentConfig.getReturnUrl();

                VTCPay vtcPay = new VTCPay(website_id, receiver_account, language, url_return, secret_key,
                        reference_number, amount, currency, request_url, trans_ref_no, status, data,
                        paymentConfig.getKeypaySecureKey());

                StringBuffer param = new StringBuffer();
                param.append("amount=").append(URLEncoder.encode(vtcPay.getAmount(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("currency=").append(URLEncoder.encode(vtcPay.getCurrency(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("receiver_account=")
                        .append(URLEncoder.encode(vtcPay.getReceiver_account(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("reference_number=")
                        .append(URLEncoder.encode(vtcPay.getReference_number(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("url_return=").append(URLEncoder.encode(url_return, "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("website_id=").append(URLEncoder.encode(vtcPay.getWebsite_id(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("signature=").append(VTCPay.getSecureHashCodeRequest(vtcPay));

                url_redirect = vtcPay.getRequest_url() + param.toString();

                try {
                    paymentFile = PaymentFileLocalServiceUtil.updatePaymentFile(paymentFileId, url_redirect,
                            Long.parseLong(vtcPay.getReference_number()), StringPool.BLANK,
                            vtcPay.getWebsite_id());

                    paymentFile.setPaymentConfig(paymentConfig.getPaymentConfigId());

                    PaymentFileLocalServiceUtil.updatePaymentFile(paymentFile);

                } catch (Exception e) {
                    _log.error(e);
                }
            } else if (paymentGateConfig.getPaymentGateId() == paymentConfig.getPaymentGateType()
                    && paymentGateConfig.getPaymentGateName().equals("KEYPAY")) {

                List<String> lsMessages = _putPaymentMessage(pattern);

                long merchant_trans_id = _genetatorTransactionId();

                String merchant_code = paymentConfig.getKeypayMerchantCode();

                String good_code = generatorGoodCode(10);

                String net_cost = String.valueOf((int) paymentFile.getAmount());
                String ship_fee = "0";
                String tax = "0";

                String bank_code = StringPool.BLANK;

                String service_code = PortletPropsValues.OPENCPS_KEYPAY_SERVICE_CODE;
                String version = paymentConfig.getKeypayVersion();
                String command = PortletPropsValues.OPENCPS_KEYPAY_COMMAND;
                String currency_code = PortletPropsValues.OPENCPS_KEYPAY_CURRENCY_CODE;

                String desc_1 = StringPool.BLANK;
                String desc_2 = StringPool.BLANK;
                String desc_3 = StringPool.BLANK;
                String desc_4 = StringPool.BLANK;
                String desc_5 = StringPool.BLANK;

                if (lsMessages.size() > 0) {
                    desc_1 = lsMessages.get(0);
                    desc_2 = lsMessages.get(1);
                    desc_3 = lsMessages.get(2);
                    desc_4 = lsMessages.get(3);
                    desc_5 = lsMessages.get(4);

                    if (desc_1.length() >= 20) {
                        desc_1 = desc_1.substring(0, 19);
                    }
                    if (desc_2.length() >= 30) {
                        desc_2 = desc_2.substring(0, 29);
                    }
                    if (desc_3.length() >= 40) {
                        desc_3 = desc_3.substring(0, 39);
                    }
                    if (desc_4.length() >= 100) {
                        desc_4 = desc_4.substring(0, 89);
                    }
                    if (desc_5.length() > 15) {
                        desc_5 = desc_5.substring(0, 15);

                        if (!Validator.isDigit(desc_5)) {
                            desc_5 = StringPool.BLANK;
                        }
                    }
                }

                String xml_description = StringPool.BLANK;
                String current_locale = PortletPropsValues.OPENCPS_KEYPAY_CURRENT_LOCATE;
                String country_code = PortletPropsValues.OPENCPS_KEYPAY_COUNTRY_CODE;
                String internal_bank = PortletPropsValues.OPENCPS_KEYPAY_INTERNAL_BANK;

                String merchant_secure_key = paymentConfig.getKeypaySecureKey();

                // dossier = _getDossier(dossierId);

                // TODO : update returnURL keyPay

                String return_url = StringPool.BLANK;
                return_url = paymentConfig.getReturnUrl();

                KeyPay keypay = new KeyPay(String.valueOf(merchant_trans_id), merchant_code, good_code,
                        net_cost, ship_fee, tax, bank_code, service_code, version, command, currency_code,
                        desc_1, desc_2, desc_3, desc_4, desc_5, xml_description, current_locale, country_code,
                        return_url, internal_bank, merchant_secure_key);

                // keypay.setKeypay_url(paymentConfig.getKeypayDomain());

                StringBuffer param = new StringBuffer();
                param.append("merchant_code=").append(URLEncoder.encode(keypay.getMerchant_code(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("merchant_secure_key=")
                        .append(URLEncoder.encode(keypay.getMerchant_secure_key(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("bank_code=").append(URLEncoder.encode(keypay.getBank_code(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("internal_bank=").append(URLEncoder.encode(keypay.getInternal_bank(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("merchant_trans_id=")
                        .append(URLEncoder.encode(keypay.getMerchant_trans_id(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("good_code=").append(URLEncoder.encode(keypay.getGood_code(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("net_cost=").append(URLEncoder.encode(keypay.getNet_cost(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("ship_fee=").append(URLEncoder.encode(keypay.getShip_fee(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("tax=").append(URLEncoder.encode(keypay.getTax(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("return_url=").append(URLEncoder.encode(keypay.getReturn_url(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("version=").append(URLEncoder.encode(keypay.getVersion(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("command=").append(URLEncoder.encode(keypay.getCommand(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("current_locale=").append(URLEncoder.encode(keypay.getCurrent_locale(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("currency_code=").append(URLEncoder.encode(keypay.getCurrency_code(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("service_code=").append(URLEncoder.encode(keypay.getService_code(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("country_code=").append(URLEncoder.encode(keypay.getCountry_code(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                // param.append("desc_1=").append(URLEncoder.encode(keypay.getDesc_1(),
                // "UTF-8")).append(StringPool.AMPERSAND);
                // param.append("desc_2=").append(URLEncoder.encode(keypay.getDesc_2(),
                // "UTF-8")).append(StringPool.AMPERSAND);
                // param.append("desc_3=").append(URLEncoder.encode(keypay.getDesc_3(),
                // "UTF-8")).append(StringPool.AMPERSAND);
                // param.append("desc_4=").append(URLEncoder.encode(keypay.getDesc_4(),
                // "UTF-8")).append(StringPool.AMPERSAND);
                // param.append("desc_5=").append(URLEncoder.encode(keypay.getDesc_5(),
                // "UTF-8")).append(StringPool.AMPERSAND);
                param.append("desc_1=&");
                param.append("desc_2=&");
                param.append("desc_3=&");
                param.append("desc_4=&");
                param.append("desc_5=&");
                param.append("xml_description=").append(URLEncoder.encode(keypay.getXml_description(), "UTF-8"))
                        .append(StringPool.AMPERSAND);
                param.append("secure_hash=").append(keypay.getSecure_hash());

                url_redirect = paymentConfig.getKeypayDomain() + StringPool.QUESTION + param.toString();

                try {
                    paymentFile = PaymentFileLocalServiceUtil.updatePaymentFile(paymentFileId, url_redirect,
                            GetterUtil.getLong(merchant_trans_id, 0), good_code,
                            paymentConfig.getKeypayMerchantCode());

                    paymentFile.setPaymentConfig(paymentConfig.getPaymentConfigId());

                    PaymentFileLocalServiceUtil.updatePaymentFile(paymentFile);

                } catch (Exception e) {
                    _log.error(e);
                }

            }
        }
    }

    return paymentFile;
}