/** * Only allow strict hierarchies. That is, can level =1 be not null when level = 0 is null * @param authorizables */ public void setAuthorizables(List<? extends Authorizable> authorizables) { if (authorizables == null || authorizables.isEmpty()) { //service scope scope = SERVICE_SCOPE; return; } if (authorizables.size() > AUTHORIZABLE_LEVEL) { throw new IllegalStateException("This generic privilege model only supports maximum 4 level."); } for (int i = 0; i < authorizables.size(); i++) { Authorizable authorizable = authorizables.get(i); if (authorizable == null) { String msg = String.format("The authorizable can't be null. Please check authorizables[%d]:", i); throw new IllegalStateException(msg); } String resourceName = authorizable.getName(); String resourceTYpe = authorizable.getTypeName(); if (isNULL(resourceName) || isNULL(resourceTYpe)) { String msg = String.format("The name and type of authorizable can't be empty or null.Please check authorizables[%d]", i); throw new IllegalStateException(msg); } setField(this, PREFIX_RESOURCE_NAME + String.valueOf(i), toNULLCol(resourceName)); setField(this, PREFIX_RESOURCE_TYPE + String.valueOf(i), toNULLCol(resourceTYpe)); scope = resourceTYpe; } }
/** * Only allow strict hierarchies. That is, can level =1 be not null when level = 0 is null * @param authorizables */ public void setAuthorizables(List<? extends Authorizable> authorizables) { if (authorizables == null || authorizables.isEmpty()) { //service scope scope = SERVICE_SCOPE; return; } if (authorizables.size() > AUTHORIZABLE_LEVEL) { throw new IllegalStateException("This generic privilege model only supports maximum 4 level."); } for (int i = 0; i < authorizables.size(); i++) { Authorizable authorizable = authorizables.get(i); if (authorizable == null) { String msg = String.format("The authorizable can't be null. Please check authorizables[%d]:", i); throw new IllegalStateException(msg); } String resourceName = authorizable.getName(); String resourceTYpe = authorizable.getTypeName(); if (isNULL(resourceName) || isNULL(resourceTYpe)) { String msg = String.format("The name and type of authorizable can't be empty or null.Please check authorizables[%d]", i); throw new IllegalStateException(msg); } setField(this, PREFIX_RESOURCE_NAME + String.valueOf(i), toNULLCol(resourceName)); setField(this, PREFIX_RESOURCE_TYPE + String.valueOf(i), toNULLCol(resourceTYpe)); scope = resourceTYpe; } }