Example usage for com.liferay.portal.kernel.portlet PortletProviderUtil getPortletId

List of usage examples for com.liferay.portal.kernel.portlet PortletProviderUtil getPortletId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.portlet PortletProviderUtil getPortletId.

Prototype

public static String getPortletId(String className, PortletProvider.Action action) 

Source Link

Usage

From source file:ca.efendi.datafeeds.service.permission.CJProductPermission.java

License:Apache License

public static boolean contains(PermissionChecker permissionChecker, CJProduct entry, String actionId) {

    String portletId = PortletProviderUtil.getPortletId(CJProduct.class.getName(), PortletProvider.Action.EDIT);

    Boolean hasPermission = StagingPermissionUtil.hasPermission(permissionChecker, entry.getGroupId(),
            CJProduct.class.getName(), entry.getProductId(), portletId, actionId);

    if (hasPermission != null) {
        return hasPermission.booleanValue();
    }/*from w  w  w .j  a  va2s. co  m*/

    if (entry.isDraft() || entry.isScheduled()) {
        if (actionId.equals(ActionKeys.VIEW) && !contains(permissionChecker, entry, ActionKeys.UPDATE)) {

            return false;
        }
    } else if (entry.isPending()) {
        hasPermission = WorkflowPermissionUtil.hasPermission(permissionChecker, entry.getGroupId(),
                CJProduct.class.getName(), entry.getProductId(), actionId);

        if (hasPermission != null) {
            return hasPermission.booleanValue();
        }
    }

    if (permissionChecker.hasOwnerPermission(entry.getCompanyId(), CJProduct.class.getName(),
            entry.getProductId(), entry.getUserId(), actionId)) {

        return true;
    }

    return permissionChecker.hasPermission(entry.getGroupId(), CJProduct.class.getName(), entry.getProductId(),
            actionId);
}

From source file:com.liferay.announcements.uad.display.AnnouncementsEntryUADEntityDisplay.java

License:Open Source License

@Override
public String getEditURL(UADEntity uadEntity, LiferayPortletRequest liferayPortletRequest,
        LiferayPortletResponse liferayPortletResponse) throws Exception {

    AnnouncementsEntryUADEntity announcementsEntryUADEntity = (AnnouncementsEntryUADEntity) uadEntity;

    String portletId = PortletProviderUtil.getPortletId(AnnouncementsEntry.class.getName(),
            PortletProvider.Action.VIEW);

    PortletURL portletURL = liferayPortletResponse.createLiferayPortletURL(
            portal.getControlPanelPlid(liferayPortletRequest), portletId, PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/announcements/edit_entry");

    AnnouncementsEntry announcementsEntry = announcementsEntryUADEntity.getAnnouncementsEntry();

    portletURL.setParameter("entryId", String.valueOf(announcementsEntry.getEntryId()));

    return portletURL.toString();
}

From source file:com.liferay.asset.taglib.servlet.taglib.AssetCategoriesSelectorTag.java

License:Open Source License

protected String getEventName() {
    String portletId = PortletProviderUtil.getPortletId(AssetCategory.class.getName(),
            PortletProvider.Action.BROWSE);

    return PortalUtil.getPortletNamespace(portletId) + "selectCategory";
}

From source file:com.liferay.asset.taglib.servlet.taglib.AssetTagsSelectorTag.java

License:Open Source License

protected String getEventName() {
    String portletId = PortletProviderUtil.getPortletId(AssetTag.class.getName(),
            PortletProvider.Action.BROWSE);

    return PortalUtil.getPortletNamespace(portletId) + "selectTag";
}

From source file:com.liferay.blogs.internal.atom.BlogsEntryAtomCollectionAdapter.java

License:Open Source License

@Override
public String getFeedTitle(AtomRequestContext atomRequestContext) {
    String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(),
            PortletProvider.Action.VIEW);

    return AtomUtil.createFeedTitleFromPortletName(atomRequestContext, portletId);
}

From source file:com.liferay.blogs.internal.trash.BlogsEntryTrashHandler.java

License:Open Source License

protected PortletURL getRestoreURL(PortletRequest portletRequest, long classPK, boolean containerModel)
        throws PortalException {

    PortletURL portletURL = null;//  w ww.  j av a2 s  .co  m

    BlogsEntry entry = _blogsEntryLocalService.getEntry(classPK);
    String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(),
            PortletProvider.Action.VIEW);

    long plid = PortalUtil.getPlidFromPortletId(entry.getGroupId(), portletId);

    if (plid == LayoutConstants.DEFAULT_PLID) {
        portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.MANAGE);

        portletURL = PortalUtil.getControlPanelPortletURL(portletRequest, portletId,
                PortletRequest.RENDER_PHASE);
    } else {
        portletURL = PortletURLFactoryUtil.create(portletRequest, portletId, plid, PortletRequest.RENDER_PHASE);
    }

    if (!containerModel) {
        portletURL.setParameter("mvcRenderCommandName", "/blogs/view_entry");
    }

    return portletURL;
}

From source file:com.liferay.blogs.internal.util.PingbackMethodImpl.java

License:Open Source License

protected ServiceContext buildServiceContext(long companyId, long groupId, String urlTitle) throws Exception {

    ServiceContext serviceContext = new ServiceContext();

    String pingbackUserName = LanguageUtil.get(LocaleUtil.getSiteDefault(), "pingback");

    serviceContext.setAttribute("pingbackUserName", pingbackUserName);

    StringBundler sb = new StringBundler(5);

    String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(),
            PortletProvider.Action.VIEW);

    if (Validator.isNull(portletId)) {
        return serviceContext;
    }//from  www.  j  av  a 2s  .c  o m

    String layoutFullURL = PortalUtil.getLayoutFullURL(groupId, portletId);

    sb.append(layoutFullURL);

    sb.append(Portal.FRIENDLY_URL_SEPARATOR);

    Portlet portlet = _portletLocalService.getPortletById(companyId, portletId);

    sb.append(portlet.getFriendlyURLMapping());
    sb.append(StringPool.SLASH);
    sb.append(urlTitle);

    serviceContext.setAttribute("redirect", sb.toString());

    serviceContext.setLayoutFullURL(layoutFullURL);

    return serviceContext;
}

From source file:com.liferay.blogs.internal.util.PingbackMethodImpl.java

License:Open Source License

protected BlogsEntry getBlogsEntry(long companyId) throws Exception {
    BlogsEntry entry = null;//from  w  w  w  .  j av a  2 s  .  c  o  m

    URL url = new URL(_targetURI);

    String friendlyURL = url.getPath();

    int end = friendlyURL.indexOf(Portal.FRIENDLY_URL_SEPARATOR);

    if (end != -1) {
        friendlyURL = friendlyURL.substring(0, end);
    }

    long plid = PortalUtil.getPlidFromFriendlyURL(companyId, friendlyURL);
    long groupId = PortalUtil.getScopeGroupId(plid);

    Map<String, String[]> params = new HashMap<>();

    FriendlyURLMapperThreadLocal.setPRPIdentifiers(new HashMap<String, String>());

    String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(),
            PortletProvider.Action.VIEW);

    Portlet portlet = _portletLocalService.getPortletById(portletId);

    FriendlyURLMapper friendlyURLMapper = portlet.getFriendlyURLMapperInstance();

    friendlyURL = url.getPath();

    end = friendlyURL.indexOf(Portal.FRIENDLY_URL_SEPARATOR);

    if (end != -1) {
        friendlyURL = friendlyURL.substring(end + Portal.FRIENDLY_URL_SEPARATOR.length() - 1);
    }

    Map<String, Object> requestContext = new HashMap<>();

    friendlyURLMapper.populateParams(friendlyURL, params, requestContext);

    String param = getParam(params, "entryId");

    if (Validator.isNotNull(param)) {
        long entryId = GetterUtil.getLong(param);

        entry = _blogsEntryLocalService.getEntry(entryId);
    } else {
        String urlTitle = getParam(params, "urlTitle");

        entry = _blogsEntryLocalService.getEntry(groupId, urlTitle);
    }

    return entry;
}

From source file:com.liferay.blogs.internal.util.PingbackMethodImpl.java

License:Open Source License

protected String getParam(Map<String, String[]> params, String name) {
    String[] paramArray = params.get(name);

    if (paramArray == null) {
        String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(),
                PortletProvider.Action.VIEW);

        String namespace = PortalUtil.getPortletNamespace(portletId);

        paramArray = params.get(namespace + name);
    }//ww  w  . ja  va2 s. c o m

    if (ArrayUtil.isNotEmpty(paramArray)) {
        return paramArray[0];
    } else {
        return null;
    }
}

From source file:com.liferay.blogs.portlet.test.PortletLayoutFinderTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    _portletIds = new String[] {
            PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.MANAGE),
            PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.VIEW) };

    _portletLayoutFinder = new BasePortletLayoutFinder() {

        @Override//from  w w w. j  a  va 2  s .c  o m
        protected String[] getPortletIds() {
            return _portletIds;
        }

    };

    User user = TestPropsValues.getUser();

    PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user);

    _originalPermissionChecker = PermissionThreadLocal.getPermissionChecker();

    PermissionThreadLocal.setPermissionChecker(permissionChecker);
}