Ejemplo 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);
  }
  public ShoppingItem[] getItemsPrevAndNext(long itemId, OrderByComparator obc)
      throws PortalException, SystemException {

    ShoppingItem item = shoppingItemPersistence.findByPrimaryKey(itemId);

    return shoppingItemPersistence.findByG_C_PrevAndNext(
        item.getItemId(), item.getGroupId(), item.getCategoryId(), obc);
  }
  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);
  }
  protected long getCategory(ShoppingItem item, long categoryId) throws SystemException {

    if ((item.getCategoryId() != categoryId)
        && (categoryId != ShoppingCategoryConstants.DEFAULT_PARENT_CATEGORY_ID)) {

      ShoppingCategory newCategory = shoppingCategoryPersistence.fetchByPrimaryKey(categoryId);

      if ((newCategory == null) || (item.getGroupId() != newCategory.getGroupId())) {

        categoryId = item.getCategoryId();
      }
    }

    return categoryId;
  }