isRecordAccessPermitted(ActionContext, Object)
This is a method that checks record permissions for a user. It checks permissions for users who may belong to a division or site. Such users are restricted to access information from their site only. A user who is not assigned a site (i.e., -1) has access data from all sites. This method is used when site information exists in the record for which permissions need to be checked.
protected static boolean isRecordAccessPermitted(ActionContext context, Object object) throws Exception { int tmpUserSiteId = UserUtils.getUserSiteId(context.getRequest()); if (tmpUserSiteId != -1) { Method method = object.getClass().getMethod( "getSiteId", (java.lang.Class[]) null); Object result = method.invoke(object, (java.lang.Object[]) null); int tmpObjectSiteId = ((Integer) result).intValue(); if (tmpObjectSiteId == tmpUserSiteId) { return true; } else { return false; } } else { // has permission to view records of all sites return true; } }
NOTE: This validation uses reflection to examine the getSiteId() method of the object for which record access needs to be checked, hence it is mandatory for these classes to have the getSiteId method.
Sign in to add your comment.