Package org.beangle.ems.security

Examples of org.beangle.ems.security.Resource$Scope


  public ResourcePropertyExtractor(TextResource textResource) {
    super(textResource);
  }

  public Object getPropertyValue(Object target, String property) throws Exception {
    Resource resource = (Resource) target;
    if ("enabled".equals(property)) {
      return resource.isEnabled() ? "激活" : "冻结";
    } else if ("scope".equals(property)) {
      String scope = "公开";
      if (1 == resource.getScope()) scope = "公有";
      else if (2 == resource.getScope()) scope = "私有";
      return scope;
    } else if ("categories".equals(property)) {
      return getPropertyIn(resource.getCategories(), "title");
    } else return super.getPropertyValue(target, property);
  }
View Full Code Here


        .get("security.restriction");
    if (null == restrictionMap) {
      restrictionMap = CollectUtils.newHashMap();
      session.put("security.restriction", restrictionMap);
    }
    Resource resource = getResource();
    if (resource.getEntities().isEmpty()) { return Collections.emptyList(); }
    List<Restriction> realms = restrictionMap.get(resource.getId());
    User user = entityDao.get(User.class, getUserId());
    if (null == realms) {
      realms = restrictionService.getRestrictions(user, resource);
      restrictionMap.put(resource.getId(), realms);
    }
    // 没有权限就报错
    if (realms.isEmpty()) { throw new AccessDeniedException(SecurityContextHolder.getContext()
        .getAuthentication(), resource.getName()); }
    return realms;
  }
View Full Code Here

  public String index() {
    return forward(new Action(this, "search"));
  }

  protected void editSetting(Entity<?> entity) {
    Resource resource = (Resource) entity;
    List<RestrictEntity> entities = entityDao.getAll(RestrictEntity.class);
    entities.removeAll(resource.getEntities());
    put("restrictEntities", entities);
    put("categories", entityDao.getAll(Category.class));
  }
View Full Code Here

    put("restrictEntities", entities);
    put("categories", entityDao.getAll(Category.class));
  }

  protected String saveAndForward(Entity<?> entity) {
    Resource resource = (Resource) entity;
    if (null != resource) {
      if (entityDao.duplicate(Resource.class, resource.getId(), "name", resource.getName())) { return redirect(
          "edit", "error.notUnique"); }
    }

    List<RestrictEntity> entities = entityDao.get(RestrictEntity.class,
        getAll("restrictEntityId", Long.class));
    resource.getEntities().clear();
    resource.getEntities().addAll(entities);

    List<Category> categories = entityDao.get(Category.class, getAll("categoryId",Long.class));
    resource.getCategories().clear();
    resource.getCategories().addAll(categories);

    entityDao.saveOrUpdate(resource);
    authorityManager.refreshCache();

    logger.info("save resource success {}", resource.getTitle());
    return redirect("search", "info.save.success");
  }
View Full Code Here

    // .get("security.restriction");
    // if (null == restrictionMap) {
    // restrictionMap = CollectUtils.newHashMap();
    // session.put("security.restriction", restrictionMap);
    // }
    Resource resource = getResource();
    // if (resource.getEntities().isEmpty()) { return Collections.emptyList(); }
    // List<Restriction> realms = restrictionMap.get(resource.getId());
//    User user = entityDao.get(User.class, getUserId());
    // if (null == realms) {
    UserProfile profile = getUserProfile();
    List<Restriction> holders = restrictionService.getRestrictions(profile, resource);
    // restrictionMap.put(resource.getId(), realms);
    // }
    // 没有权限就报错
    if (holders.isEmpty()) { throw new AccessDeniedException(SecurityContextHolder.getContext()
        .getAuthentication(), resource.getName()); }
    return holders;
  }
View Full Code Here

  public ResourcePropertyExtractor(TextResource textResource) {
    super(textResource);
  }

  public Object getPropertyValue(Object target, String property) throws Exception {
    Resource resource = (Resource) target;
    if ("enabled".equals(property)) {
      return resource.isEnabled() ? "激活" : "冻结";
    } else return super.getPropertyValue(target, property);
  }
View Full Code Here

    // .get("security.restriction");
    // if (null == restrictionMap) {
    // restrictionMap = CollectUtils.newHashMap();
    // session.put("security.restriction", restrictionMap);
    // }
    Resource resource = getResource();
    // if (resource.getEntities().isEmpty()) { return Collections.emptyList(); }
    // List<Restriction> realms = restrictionMap.get(resource.getId());
//    User user = entityDao.get(User.class, getUserId());
    // if (null == realms) {
    UserProfile profile = getUserProfile();
    List<Restriction> holders = restrictionService.getRestrictions(profile, resource);
    // restrictionMap.put(resource.getId(), realms);
    // }
    // 没有权限就报错
    if (holders.isEmpty()) { throw new AccessDeniedException(SecurityContextHolder.getContext()
        .getAuthentication(), resource.getName()); }
    return holders;
  }
View Full Code Here

  public String index() {
    return forward(new Action(this, "search"));
  }

  protected String saveAndForward(Entity<?> entity) {
    Resource resource = (Resource) entity;
    if (null != resource) {
      if (entityDao.duplicate(Resource.class, resource.getId(), "name", resource.getName())) { return redirect(
          "edit", "error.notUnique"); }
    }
    entityDao.saveOrUpdate(resource);
    authorityManager.refreshCache();

    logger.info("save resource success {}", resource.getTitle());
    return redirect("search", "info.save.success");
  }
View Full Code Here

TOP

Related Classes of org.beangle.ems.security.Resource$Scope

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.