Example usage for com.liferay.portal.kernel.security.permission ActionKeys UPDATE

List of usage examples for com.liferay.portal.kernel.security.permission ActionKeys UPDATE

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.security.permission ActionKeys UPDATE.

Prototype

String UPDATE

To view the source code for com.liferay.portal.kernel.security.permission ActionKeys UPDATE.

Click Source Link

Usage

From source file:com.liferay.dynamic.data.mapping.service.impl.DDMTemplateServiceImpl.java

License:Open Source License

@Override
public void revertTemplate(long templateId, String version, ServiceContext serviceContext)
        throws PortalException {

    DDMTemplatePermission.check(getPermissionChecker(), templateId, ActionKeys.UPDATE);

    ddmTemplateLocalService.revertTemplate(getUserId(), templateId, version, serviceContext);
}

From source file:com.liferay.dynamic.data.mapping.service.impl.DDMTemplateServiceImpl.java

License:Open Source License

/**
 * Updates the template matching the ID.
 *
 * @param  templateId the primary key of the template
 * @param  classPK the primary key of the template's related entity
 * @param  nameMap the template's new locales and localized names
 * @param  descriptionMap the template's new locales and localized
 *         description/*w  w w .ja v  a 2  s. c  o m*/
 * @param  type the template's type. For more information, see
 *         DDMTemplateConstants in the dynamic-data-mapping-api module.
 * @param  mode the template's mode. For more information, see
 *         DDMTemplateConstants in the dynamic-data-mapping-api module.
 * @param  language the template's script language. For more information,
 *         see DDMTemplateConstants in the dynamic-data-mapping-api module.
 * @param  script the template's script
 * @param  cacheable whether the template is cacheable
 * @param  smallImage whether the template has a small image
 * @param  smallImageURL the template's small image URL (optionally
 *         <code>null</code>)
 * @param  smallImageFile the template's small image file (optionally
 *         <code>null</code>)
 * @param  serviceContext the service context to be applied. Can set the
 *         modification date.
 * @return the updated template
 */
@Override
public DDMTemplate updateTemplate(long templateId, long classPK, Map<Locale, String> nameMap,
        Map<Locale, String> descriptionMap, String type, String mode, String language, String script,
        boolean cacheable, boolean smallImage, String smallImageURL, File smallImageFile,
        ServiceContext serviceContext) throws PortalException {

    DDMTemplatePermission.check(getPermissionChecker(), templateId, ActionKeys.UPDATE);

    return ddmTemplateLocalService.updateTemplate(getUserId(), templateId, classPK, nameMap, descriptionMap,
            type, mode, language, script, cacheable, smallImage, smallImageURL, smallImageFile, serviceContext);
}

From source file:com.liferay.dynamic.data.mapping.service.impl.DDMTemplateServiceImpl.java

License:Open Source License

/**
 * Updates the template matching the ID.
 *
 * @param  templateId the primary key of the template
 * @param  classPK the primary key of the template's related entity
 * @param  nameMap the template's new locales and localized names
 * @param  descriptionMap the template's new locales and localized
 *         description// ww  w .  j  ava 2  s  . c o m
 * @param  type the template's type. For more information, see
 *         DDMTemplateConstants in the dynamic-data-mapping-api module.
 * @param  mode the template's mode. For more information, see
 *         DDMTemplateConstants in the dynamic-data-mapping-api module.
 * @param  language the template's script language. For more information,
 *         see DDMTemplateConstants in the dynamic-data-mapping-api module.
 * @param  script the template's script
 * @param  cacheable whether the template is cacheable
 * @param  serviceContext the service context to be applied. Can set the
 *         modification date.
 * @return the updated template
 */
@Override
public DDMTemplate updateTemplate(long templateId, long classPK, Map<Locale, String> nameMap,
        Map<Locale, String> descriptionMap, String type, String mode, String language, String script,
        boolean cacheable, ServiceContext serviceContext) throws PortalException {

    DDMTemplatePermission.check(getPermissionChecker(), templateId, ActionKeys.UPDATE);

    return ddmTemplateLocalService.updateTemplate(getUserId(), templateId, classPK, nameMap, descriptionMap,
            type, mode, language, script, cacheable, serviceContext);
}

From source file:com.liferay.expando.taglib.servlet.taglib.CustomAttributesAvailableTag.java

License:Open Source License

@Override
public int doStartTag() throws JspException {
    try {//w w w  .ja v a 2  s . c o  m
        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

        ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

        long companyId = _companyId;

        if (companyId == 0) {
            companyId = themeDisplay.getCompanyId();
        }

        ExpandoBridge expandoBridge = null;

        if (_classPK == 0) {
            expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(companyId, _className);
        } else {
            expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(companyId, _className, _classPK);
        }

        List<String> attributeNames = ListUtil.remove(Collections.list(expandoBridge.getAttributeNames()),
                ListUtil.fromString(_ignoreAttributeNames, StringPool.COMMA));

        if (attributeNames.isEmpty()) {
            return SKIP_BODY;
        }

        if (_classPK == 0) {
            return EVAL_BODY_INCLUDE;
        }

        PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

        for (String attributeName : attributeNames) {
            Serializable value = expandoBridge.getAttribute(attributeName);

            if (Validator.isNull(value)) {
                continue;
            }

            UnicodeProperties properties = expandoBridge.getAttributeProperties(attributeName);

            boolean propertyHidden = GetterUtil
                    .getBoolean(properties.get(ExpandoColumnConstants.PROPERTY_HIDDEN));
            boolean propertyVisibleWithUpdatePermission = GetterUtil
                    .getBoolean(properties.get(ExpandoColumnConstants.PROPERTY_VISIBLE_WITH_UPDATE_PERMISSION));

            if (_editable && propertyVisibleWithUpdatePermission) {
                if (ExpandoColumnPermissionUtil.contains(permissionChecker, companyId, _className,
                        ExpandoTableConstants.DEFAULT_TABLE_NAME, attributeName, ActionKeys.UPDATE)) {

                    propertyHidden = false;
                } else {
                    propertyHidden = true;
                }
            }

            if (!propertyHidden && ExpandoColumnPermissionUtil.contains(permissionChecker, companyId,
                    _className, ExpandoTableConstants.DEFAULT_TABLE_NAME, attributeName, ActionKeys.VIEW)) {

                return EVAL_BODY_INCLUDE;
            }
        }

        return SKIP_BODY;
    } catch (Exception e) {
        throw new JspException(e);
    } finally {
        if (!ServerDetector.isResin()) {
            _className = null;
            _classPK = 0;
            _companyId = 0;
            _editable = false;
            _ignoreAttributeNames = null;
        }
    }
}

From source file:com.liferay.exportimport.test.LayoutSetPrototypePropagationTest.java

License:Open Source License

@Test
public void testResetPrototypeWithPermissions() throws Exception {
    Role role = RoleTestUtil.addRole(RoleConstants.TYPE_REGULAR);

    RoleLocalServiceUtil.addUserRole(_user1.getUserId(), role);

    ResourcePermissionLocalServiceUtil.addResourcePermission(_user1.getCompanyId(), Group.class.getName(),
            ResourceConstants.SCOPE_COMPANY, String.valueOf(_user1.getCompanyId()), role.getRoleId(),
            ActionKeys.UPDATE);

    PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(_user1);

    PermissionThreadLocal.setPermissionChecker(permissionChecker);

    Group userGroup = GroupLocalServiceUtil.getUserGroup(_user2.getCompanyId(), _user2.getUserId());

    LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(userGroup.getGroupId(), true);

    SitesUtil.resetPrototype(layoutSet);
}

From source file:com.liferay.journal.content.web.internal.display.context.JournalContentDisplayContext.java

License:Open Source License

public boolean isShowEditArticleIcon() {
    if (_showEditArticleIcon != null) {
        return _showEditArticleIcon;
    }//w  ww .j  a  v  a 2 s  . c  o  m

    JournalArticle latestArticle = getLatestArticle();

    _showEditArticleIcon = false;

    if (latestArticle == null) {
        return _showEditArticleIcon;
    }

    ThemeDisplay themeDisplay = (ThemeDisplay) _portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    _showEditArticleIcon = JournalArticlePermission.contains(themeDisplay.getPermissionChecker(), latestArticle,
            ActionKeys.UPDATE);

    return _showEditArticleIcon;
}

From source file:com.liferay.journal.content.web.internal.display.context.JournalContentDisplayContext.java

License:Open Source License

public boolean isShowEditTemplateIcon() {
    if (_showEditTemplateIcon != null) {
        return _showEditTemplateIcon;
    }//from  w w  w . j  ava2  s  .  co m

    _showEditTemplateIcon = false;

    DDMTemplate ddmTemplate = getDDMTemplate();

    if (ddmTemplate == null) {
        return _showEditTemplateIcon;
    }

    ThemeDisplay themeDisplay = (ThemeDisplay) _portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    try {
        _showEditTemplateIcon = DDMTemplatePermission.contains(themeDisplay.getPermissionChecker(),
                themeDisplay.getScopeGroupId(), ddmTemplate, portletDisplay.getId(), ActionKeys.UPDATE);
    } catch (PortalException pe) {
        _log.error("Unable to check permission on DDM template " + ddmTemplate.getTemplateId(), pe);
    }

    return _showEditTemplateIcon;
}

From source file:com.liferay.journal.service.impl.JournalArticleServiceImpl.java

License:Open Source License

/**
 * Moves all versions of the web content article matching the group and
 * article ID to the folder.//from  www  . ja va 2 s  .  com
 *
 * @param groupId the primary key of the web content article's group
 * @param articleId the primary key of the web content article
 * @param newFolderId the primary key of the web content article's new
 *        folder
 * @param serviceContext the service context to be applied. Can set the user
 *        ID, language ID, portlet preferences, portlet request, portlet
 *        response, theme display, and can set whether to add the default
 *        command update for the web content article. With respect to social
 *        activities, by setting the service context's command to {@link
 *        com.liferay.portal.kernel.util.Constants#UPDATE}, the invocation
 *        is considered a web content update activity; otherwise it is
 *        considered a web content add activity.
 */
@Override
public void moveArticle(long groupId, String articleId, long newFolderId, ServiceContext serviceContext)
        throws PortalException {

    JournalFolderPermission.check(getPermissionChecker(), groupId, newFolderId, ActionKeys.ADD_ARTICLE);

    JournalArticle article = journalArticleLocalService.getArticle(groupId, articleId);

    JournalArticlePermission.check(getPermissionChecker(), article, ActionKeys.UPDATE);

    journalArticleLocalService.moveArticle(groupId, articleId, newFolderId, serviceContext);
}

From source file:com.liferay.journal.service.impl.JournalArticleServiceImpl.java

License:Open Source License

/**
 * Moves the web content article from the Recycle Bin to the folder.
 *
 * @param  groupId the primary key of the web content article's group
 * @param  resourcePrimKey the primary key of the resource instance
 * @param  newFolderId the primary key of the web content article's new
 *         folder//  w  w  w. jav  a 2 s  .  c  om
 * @param  serviceContext the service context to be applied. Can set the
 *         modification date, portlet preferences, and can set whether to
 *         add the default command update for the web content article. With
 *         respect to social activities, by setting the service context's
 *         command to {@link
 *         com.liferay.portal.kernel.util.Constants#UPDATE}, the invocation
 *         is considered a web content update activity; otherwise it is
 *         considered a web content add activity.
 * @return the updated web content article, which was moved from the Recycle
 *         Bin to the folder
 */
@Override
public JournalArticle moveArticleFromTrash(long groupId, long resourcePrimKey, long newFolderId,
        ServiceContext serviceContext) throws PortalException {

    JournalArticle article = getLatestArticle(resourcePrimKey);

    JournalArticlePermission.check(getPermissionChecker(), article, ActionKeys.UPDATE);

    return journalArticleLocalService.moveArticleFromTrash(getUserId(), groupId, article, newFolderId,
            serviceContext);
}

From source file:com.liferay.journal.service.impl.JournalArticleServiceImpl.java

License:Open Source License

/**
 * Moves the web content article from the Recycle Bin to the folder.
 *
 * @param  groupId the primary key of the web content article's group
 * @param  articleId the primary key of the web content article
 * @param  newFolderId the primary key of the web content article's new
 *         folder/*from   w w w.  j  a v a2 s  .com*/
 * @param  serviceContext the service context to be applied. Can set the
 *         modification date, portlet preferences, and can set whether to
 *         add the default command update for the web content article. With
 *         respect to social activities, by setting the service context's
 *         command to {@link
 *         com.liferay.portal.kernel.util.Constants#UPDATE}, the invocation
 *         is considered a web content update activity; otherwise it is
 *         considered a web content add activity.
 * @return the updated web content article, which was moved from the Recycle
 *         Bin to the folder
 */
@Override
public JournalArticle moveArticleFromTrash(long groupId, String articleId, long newFolderId,
        ServiceContext serviceContext) throws PortalException {

    JournalArticle article = getLatestArticle(groupId, articleId, WorkflowConstants.STATUS_IN_TRASH);

    JournalArticlePermission.check(getPermissionChecker(), groupId, articleId, ActionKeys.UPDATE);

    return journalArticleLocalService.moveArticleFromTrash(getUserId(), groupId, article, newFolderId,
            serviceContext);
}