String name)
throws RepositoryException {
ActivatedPolicy policy = null;
RuntimeProject actualProject = logicalProject;
// Only fallback if the name is project relative.
boolean supportFallback = name.startsWith("/");
// Iterate over the project and its fallbacks.
boolean finished = false;
for (; !finished && policy == null && actualProject != null;
actualProject = actualProject.getBaseProject()) {
// This iteration is the last one if fallbacks are not being
// performed.
finished = !supportFallback;
// 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