Package org.beangle.security.blueprint.restrict

Examples of org.beangle.security.blueprint.restrict.Restriction


  /**
   * 删除数据限制权限
   */
  public String remove() {
    Restriction restriction = getRestriction();
    RestrictionHolder holer = new RestrictionHelper(entityDao).getHolder();
    holer.getRestrictions().remove(restriction);
    entityDao.saveOrUpdate(holer);
    return redirect("info", "info.delete.success");
  }
View Full Code Here


    helper.populateInfo(helper.getHolder());
    return forward();
  }

  public String save() {
    Restriction restriction = getRestriction();
    RestrictionHolder holder = new RestrictionHelper(entityDao).getHolder();
    List<Restriction> myRestrictions = getMyRestrictions(restriction.getPattern(), holder);
    Set<RestrictField> ignoreParams = getIgnoreParams(myRestrictions);
    boolean isAdmin = isAdmin(getUser());
    for (RestrictField param : restriction.getPattern().getObject().getFields()) {
      String value = get(param.getName());
      if ((ignoreParams.contains(param) || isAdmin) && getBool("ignoreParam" + param.getId())) {
        restriction.setItem(param, "*");
      } else {
        if (StringUtils.isEmpty(value)) {
          restriction.getItems().remove(param.getId());
        } else {
          restriction.setItem(param, value);
        }
      }
    }
    if (restriction.getItems().isEmpty()) {
      holder.getRestrictions().remove(restriction);
      entityDao.saveOrUpdate(holder);
      return redirect("info", "info.save.success");
    } else {
      if (!restriction.isPersisted()) {
        holder.getRestrictions().add(restriction);
        entityDao.saveOrUpdate(holder);
      } else {
        entityDao.saveOrUpdate(
            (String) RestrictionHelper.restrictionTypeMap.get(get("restrictionType")),
View Full Code Here

  /**
   * 编辑权限<br>
   */
  public String edit() {
    // 取得各参数的值
    Restriction restriction = getRestriction();
    boolean isAdmin = isAdmin(getUser());
    Map<String, Object> mngParams = CollectUtils.newHashMap();
    Map<String, Object> aoParams = CollectUtils.newHashMap();
    List<Restriction> myRestricitons = getMyRestrictions(restriction.getPattern(),
        restriction.getHolder());
    Set<RestrictField> ignores = getIgnoreParams(myRestricitons);
    put("ignoreParams", ignores);
    Set<RestrictField> holderIgnoreParams = CollectUtils.newHashSet();
    put("holderIgnoreParams", holderIgnoreParams);
    for (RestrictField param : restriction.getPattern().getObject().getFields()) {
      List<Object> mngParam = restrictionService.getValues(param);
      if (!isAdmin) {
        mngParam.retainAll(getMyRestrictionValues(myRestricitons, param.getName()));
      } else {
        ignores.add(param);
      }
      String paramValue = restriction.getItem(param);
      if ("*".equals(paramValue)) {
        holderIgnoreParams.add(param);
      }
      mngParams.put(param.getName(), mngParam);
      if (null == param.getSource()) {
View Full Code Here

    return values;
  }

  private Restriction getRestriction() {
    Long restrictionId = getLong("restriction.id");
    Restriction restriction = null;
    String entityName = (String) RestrictionHelper.restrictionTypeMap
        .get(get("restrictionType"));
    if (null == restrictionId) {
      restriction = (Restriction) Model.getEntityType(entityName).newInstance();
    } else {
      restriction = (Restriction) entityDao.get(entityName, restrictionId);
    }
    populate(Params.sub("restriction"), restriction, entityName);
    if (null == restrictionId) {
      restriction.setPattern((RestrictPattern) entityDao.get(RestrictPattern.class, restriction.getPattern()
          .getId()));
    }
    return restriction;
  }
View Full Code Here

    RestrictionHolder userHolder = (RestrictionHolder) user;
    restrictions.addAll(userHolder.getRestrictions());
    // 模式过滤
    return (List<Restriction>) CollectionUtils.select(restrictions, new Predicate() {
      public boolean evaluate(Object obj) {
        Restriction restriciton = (Restriction) obj;
        if (restriciton.isEnabled()
            && objects.contains(restriciton.getPattern().getObject())) return true;
        else return false;
      }
    });
  }
View Full Code Here

TOP

Related Classes of org.beangle.security.blueprint.restrict.Restriction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.