Example usage for com.liferay.portal.util PropsValues DEFAULT_USER_PUBLIC_LAYOUT_FRIENDLY_URL

List of usage examples for com.liferay.portal.util PropsValues DEFAULT_USER_PUBLIC_LAYOUT_FRIENDLY_URL

Introduction

In this page you can find the example usage for com.liferay.portal.util PropsValues DEFAULT_USER_PUBLIC_LAYOUT_FRIENDLY_URL.

Prototype

String DEFAULT_USER_PUBLIC_LAYOUT_FRIENDLY_URL

To view the source code for com.liferay.portal.util PropsValues DEFAULT_USER_PUBLIC_LAYOUT_FRIENDLY_URL.

Click Source Link

Usage

From source file:com.liferay.grow.service.wrapper.LayoutCustomServiceWrapper.java

License:Open Source License

@Override
public Layout addLayout(long userId, long groupId, boolean privateLayout, long parentLayoutId, String name,
        String title, String description, String type, boolean hidden, String friendlyURL,
        ServiceContext serviceContext) throws PortalException {

    Layout layout = super.addLayout(userId, groupId, privateLayout, parentLayoutId, name, title, description,
            type, hidden, friendlyURL, serviceContext);

    try {/* w  ww. ja v a2  s . c o m*/
        Group group = layout.getGroup();

        String layoutFriendlyURL = layout.getFriendlyURL();

        String defaultUserPublicLayoutFriendlyURL = getFriendlyURL(
                PropsValues.DEFAULT_USER_PUBLIC_LAYOUT_FRIENDLY_URL);

        // Remove the Guest role's View permission for default user Profile
        // Page

        if (group.isUser() && layout.isPublicLayout()
                && layoutFriendlyURL.equals(defaultUserPublicLayoutFriendlyURL)) {

            Role guestRole = _roleLocalService.getRole(layout.getCompanyId(), RoleConstants.GUEST);

            _resourcePermissionLocalService.setResourcePermissions(layout.getCompanyId(),
                    Layout.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL,
                    String.valueOf(layout.getPlid()), guestRole.getRoleId(), new String[0]);
        }
    } catch (Exception e) {
        _log.error("Cannot withdraw View permission for Layout with plid " + layout.getPlid(), e);
    }

    return layout;
}