@Override public boolean checkReadPermission(Resource resource, Session cs) { if (cs.getPrivileges() != null) { if (checkPrivileges(resource, cs.getPrivileges())) { return true; } } Map<Long, Resource> groupMap = new HashMap<Long, Resource>(); for (Iterator<Resource> it = cs.getGroups().iterator(); it.hasNext(); ) { Resource currGroup = it.next(); groupMap.put(currGroup.getId(), currGroup); } if (resource.getOwnResourceId().equals(cs.getAccount().getResource().getId())) { Byte permission = resource.getCurrentAccountPermission(); if (permission.equals(CommonConstants.PERMISSION.ALL) || permission.equals(CommonConstants.PERMISSION.RW) || permission.equals(CommonConstants.PERMISSION.RX) || permission.equals(CommonConstants.PERMISSION.READ)) { return true; } } if (groupMap.get(resource.getOwnGroupResourceId()) != null) { Byte permission = resource.getCurrentGroupPermission(); if (permission.equals(CommonConstants.PERMISSION.ALL) || permission.equals(CommonConstants.PERMISSION.RW) || permission.equals(CommonConstants.PERMISSION.RX) || permission.equals(CommonConstants.PERMISSION.READ)) { return true; } } Byte permission = resource.getOthersPermission(); if (permission.equals(CommonConstants.PERMISSION.ALL) || permission.equals(CommonConstants.PERMISSION.RW) || permission.equals(CommonConstants.PERMISSION.RX) || permission.equals(CommonConstants.PERMISSION.READ)) { return true; } return false; }
@Override public void fillForm(Resource resource, IForm iFrom) { if (resource == null) { return; } Boolean[] pCurrentUser = PermissionUtil.integerToBoolean(resource.getCurrentAccountPermission().intValue()); iFrom.setPermission("0", pCurrentUser[0]); iFrom.setPermission("1", pCurrentUser[1]); iFrom.setPermission("2", pCurrentUser[2]); Boolean[] pCurrentGroup = PermissionUtil.integerToBoolean(resource.getCurrentGroupPermission().intValue()); iFrom.setPermission("3", pCurrentGroup[0]); iFrom.setPermission("4", pCurrentGroup[1]); iFrom.setPermission("5", pCurrentGroup[2]); Boolean[] pOther = PermissionUtil.integerToBoolean(resource.getOthersPermission().intValue()); iFrom.setPermission("6", pOther[0]); iFrom.setPermission("7", pOther[1]); iFrom.setPermission("8", pOther[2]); }