Exemplo n.º 1
0
  public static boolean contains(
      PermissionChecker permissionChecker, ShoppingItem item, String actionId)
      throws PortalException, SystemException {

    if (PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE) {
      if (item.getCategoryId() != ShoppingCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {

        ShoppingCategory category = item.getCategory();

        if (!ShoppingCategoryPermission.contains(permissionChecker, category, ActionKeys.VIEW)) {

          return false;
        }
      }
    }

    if (permissionChecker.hasOwnerPermission(
        item.getCompanyId(),
        ShoppingItem.class.getName(),
        item.getItemId(),
        item.getUserId(),
        actionId)) {

      return true;
    }

    return permissionChecker.hasPermission(
        item.getGroupId(), ShoppingItem.class.getName(), item.getItemId(), actionId);
  }
  @Override
  public void deleteItem(ShoppingItem item) throws PortalException, SystemException {

    // Item

    shoppingItemPersistence.remove(item);

    // Resources

    resourceLocalService.deleteResource(
        item.getCompanyId(),
        ShoppingItem.class.getName(),
        ResourceConstants.SCOPE_INDIVIDUAL,
        item.getItemId());

    // Images

    imageLocalService.deleteImage(item.getSmallImageId());
    imageLocalService.deleteImage(item.getMediumImageId());
    imageLocalService.deleteImage(item.getLargeImageId());

    // Item fields

    shoppingItemFieldPersistence.removeByItemId(item.getItemId());

    // Item prices

    shoppingItemPricePersistence.removeByItemId(item.getItemId());
  }
  public void addItemResources(
      ShoppingItem item, String[] groupPermissions, String[] guestPermissions)
      throws PortalException, SystemException {

    resourceLocalService.addModelResources(
        item.getCompanyId(),
        item.getGroupId(),
        item.getUserId(),
        ShoppingItem.class.getName(),
        item.getItemId(),
        groupPermissions,
        guestPermissions);
  }
  public void addItemResources(
      ShoppingItem item, boolean addGroupPermissions, boolean addGuestPermissions)
      throws PortalException, SystemException {

    resourceLocalService.addResources(
        item.getCompanyId(),
        item.getGroupId(),
        item.getUserId(),
        ShoppingItem.class.getName(),
        item.getItemId(),
        false,
        addGroupPermissions,
        addGuestPermissions);
  }