// get the resource this set pertains to
Resource resource = set.getResource();
// create a response set that we will append the granted
// permissions to
ActionMap grantSet = new ActionMap(resource);
grant.put(resource.getId(), grantSet);
// create a set of requests to schedule. We do not add the
// set immediately -- it will be added at the end if it
// is not empty
ActionMap scheduleSet = new ActionMap(resource);
// go through each action, and decider whether to grant or deny
// access, or if necessary, schedule for later
for (Action action : set.values()) {
// query the resource about this permission, and handle the
// result
switch (resource.request(id.getIdentity(), action)) {
case GRANT:
// access is granted, add to the response list
grantSet.put(action.getName(), action);
break;
case DENY:
// access is denied -- nothing to do
break;
case SCHEDULE:
// add to the set to schedule
scheduleSet.put(action.getName(), action);
break;
}
}
// if the schedule set is not empty, add it for scheduling
if (!scheduleSet.isEmpty()) {
schedule.put(resource.getId(), scheduleSet);
}
}
// determine if we can respond immediately