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

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

Introduction

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

Prototype

String FORWARD_SLASH

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

Click Source Link

Usage

From source file:com.vportal.portlet.vcms.util.VCMSFriendlyURLMapper.java

License:Open Source License

public String buildPath(LiferayPortletURL portletURL) {
    // TODO Auto-generated method stub

    String friendlyURLPath = null;

    String portletId = portletURL.getPortletId();

    VcmsArticle article = null;// ww w  .  j  a v  a 2  s.  c om
    VcmsCategory category = null;
    try {

        String articleId = GetterUtil.getString(portletURL.getParameter("articleId"), "0");
        String categoryId = GetterUtil.getString(portletURL.getParameter("categoryId"), "0");

        if (!Validator.equals(articleId, "0") || !Validator.equals(categoryId, "0")) {

            if (portletId.equals(_PORTLET_DEFAULT_INSTANCE)) {
                portletId = _PORTLET_ID;
            }

            String[] arrInstance = StringUtil.split(portletId, "_");

            // friendlyURLPath = "/vcmsviewcontent/" + arrInstance[2];

            friendlyURLPath = StringPool.FORWARD_SLASH + getMapping() + StringPool.FORWARD_SLASH
                    + arrInstance[4];

            portletURL.addParameterIncludedInPath("p_p_id");
            portletURL.addParameterIncludedInPath("p_p_lifecycle");
            // portletURL.addParameterIncludedInPath("p_p_state");// k co
            // portletURL.addParameterIncludedInPath("p_p_mode");// k co
            portletURL.addParameterIncludedInPath("p_p_col_id");
            portletURL.addParameterIncludedInPath("p_p_col_count");
            portletURL.addParameterIncludedInPath("p_p_col_pos");
            portletURL.addParameterIncludedInPath("jspPage");

            if (!categoryId.equalsIgnoreCase("0")) {
                friendlyURLPath += StringPool.FORWARD_SLASH + categoryId;
                portletURL.addParameterIncludedInPath("categoryId");
            }

            if (!articleId.equalsIgnoreCase("0")) {
                friendlyURLPath += StringPool.FORWARD_SLASH + articleId;
                portletURL.addParameterIncludedInPath("articleId");
            }

            if (!articleId.equalsIgnoreCase("0")) {
                article = VcmsArticleServiceUtil.getArticle(articleId);
                friendlyURLPath += StringPool.FORWARD_SLASH
                        + Normalizer.normalize(article.getTitle(), Normalizer.Form.NFD)
                                .replaceAll("[^\\p{ASCII}]", "")
                                // .replaceAll("-", "")                           
                                //                           .replaceAll(" ", "-")                           
                                .replaceAll("[^a-zA-Z0-9-]", "-").replaceAll("-{2,}", "-").toLowerCase()
                        + ".html";
            }

            if (!categoryId.equalsIgnoreCase("0") && articleId.equalsIgnoreCase("0")) {
                category = VcmsCategoryServiceUtil.getCategory(categoryId);
                friendlyURLPath += StringPool.FORWARD_SLASH
                        + Normalizer.normalize(category.getName(), Normalizer.Form.NFD)
                                .replaceAll("[^\\p{ASCII}]", "")
                                // .replaceAll("-", "")
                                //                           .replaceAll("\\b\\s{1,}\\b", "-")
                                .replaceAll("[^a-zA-Z0-9-]", "-").replaceAll("-{2,}", "-").toLowerCase()
                        + ".html";
            }
        }

    } catch (PortalException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return friendlyURLPath;
}

From source file:org.opencps.servicemgt.util.ServiceUtil.java

License:Open Source License

/**
 * @param fileEntryId/*  ww w  . j a va  2  s  .  c  o m*/
 * @return
 */
public static String getDLFileURL(long fileEntryId) {

    DLFileEntry file = null;

    String fileURL = StringPool.BLANK;

    try {
        file = DLFileEntryLocalServiceUtil.getDLFileEntry(fileEntryId);

        fileURL = "/documents/" + file.getGroupId() + StringPool.FORWARD_SLASH + file.getFolderId()
                + StringPool.FORWARD_SLASH + file.getTitle() + StringPool.FORWARD_SLASH + file.getUuid();
    } catch (Exception e) {

    }

    return fileURL;
}

From source file:org.opencps.util.DLFolderUtil.java

License:Open Source License

public static DLFolder getTargetFolder(long userId, long groupId, long repositoryId, boolean mountPoint,
        long parentFolderId, String destination, String description, boolean hidden,
        ServiceContext serviceContext) {

    DLFolder dlFolder = null;//w  w  w. j  a  v a 2s.  c om

    String[] folderNames = StringUtil.split(destination, StringPool.FORWARD_SLASH);

    if (folderNames != null && folderNames.length > 0) {
        String name = folderNames[0];

        dlFolder = makeFolder(userId, groupId, repositoryId, mountPoint, parentFolderId, name, description,
                hidden, serviceContext);
        folderNames = ArrayUtil.remove(folderNames, name);
        if (folderNames.length > 0) {
            dlFolder = getTargetFolder(userId, groupId, repositoryId, mountPoint, dlFolder.getFolderId(),
                    StringUtil.merge(folderNames, StringPool.FORWARD_SLASH), description, hidden,
                    serviceContext);
        }

    }

    return dlFolder;
}

From source file:org.opencps.util.DLFolderUtil.java

License:Open Source License

public static DLFolder getTargetFolder(long groupId, long parentFolderId, String destination) {

    DLFolder dlFolder = null;//from  w  ww . j  ava 2s  .c o m

    String[] folderNames = StringUtil.split(destination, StringPool.FORWARD_SLASH);

    if (folderNames != null && folderNames.length > 0) {
        String name = folderNames[0];
        dlFolder = getFolder(groupId, parentFolderId, name);
        folderNames = ArrayUtil.remove(folderNames, name);
        if (folderNames.length > 0) {
            dlFolder = getTargetFolder(groupId, dlFolder.getFolderId(),
                    StringUtil.merge(folderNames, StringPool.FORWARD_SLASH));
        }

    }

    return dlFolder;
}

From source file:org.opencps.util.PortletUtil.java

License:Open Source License

public static String getDestinationFolder(String[] folderNames) {

    return StringUtil.merge(folderNames, StringPool.FORWARD_SLASH);
}