// Look for the policy in the actual project, if it is found
// then it is treated as if it belonged to the logical project.
PolicyBuilderReader reader = actualProject.getPolicyBuilderReader();
// Try and get the response, may be null.
PolicyBuilderResponse response =
reader.getPolicyBuilder(actualProject, name);
if (response == null) {
// No response from reader so try next one.
continue;
}
// If the logical project is the global project then it
// maybe that the policy is actually in a different project
// but the request was deferred until now in order to allow
// the project identification to be combined with retrieval
// of the policy in order to save time on the server.
RuntimeProject responseProject = (RuntimeProject)
response.getProject();
if (responseProject != actualProject) {
RuntimeProject global = projectManager.getGlobalProject();
if (actualProject == global && logicalProject == global) {
actualProject = responseProject;
logicalProject = responseProject;
} else {
// The project can change only if the policy is remote and
// the actual project is the global project.
throw new IllegalStateException(
"Response indicates policy is in " +
responseProject + " instead of " + actualProject +
" but either it, or " + logicalProject +
" is not the global project " + global);
}
}
// Get the builder from the response, again may be null.
PolicyBuilder policyBuilder = response.getBuilder();
if (policyBuilder == null) {
// No response from builder so try next one.
continue;
}