return;
}
PolicyRegistry reg = policyInclude.getPolicyRegistry();
ExternalPolicySerializer serializer = new ExternalPolicySerializer();
if (configCtx.getAxisConfiguration()
.getLocalPolicyAssertions() != null) {
serializer.setAssertionsToFilter(
configCtx.getAxisConfiguration().getLocalPolicyAssertions());
}
if (policyElements.size() == 1) {
response.addHeader(HTTP.CONTENT_TYPE, "text/xml");
if (policyElements.get(0) instanceof Policy) {
Policy policy = (Policy) policyElements.get(0);
serializer.serialize(policy, outputStream);
} else if (policyElements.get(0) instanceof PolicyReference) {
String key = ((PolicyReference) policyElements.get(0)).getURI();
if (key.startsWith("#")) {
key = key.substring(key.indexOf("#") + 1);
}
Policy p = reg.lookup(key);
if (p == null) {
response.addHeader(HTTP.CONTENT_TYPE, "text/html");
outputStream.write("<h4>Policy element not found!</h4>".getBytes());
} else {
serializer.serialize(p, outputStream);
}
}
} else {
// for many policies
String idParam = request.getParameter("id");
if (idParam != null) {
Object policyObject = policyElements.get(Integer.parseInt(idParam));
if (policyObject != null) {
response.addHeader(HTTP.CONTENT_TYPE, "text/xml");
if (policyObject instanceof Policy) {
Policy policy = (Policy) policyObject;
serializer.serialize(policy, outputStream);
} else if (policyObject instanceof PolicyReference) {
String key = ((PolicyReference) policyObject).getURI();
if (key.startsWith("#")) {
key = key.substring(key.indexOf("#") + 1);
}
Policy p = reg.lookup(key);
if (p == null) {
response.addHeader(HTTP.CONTENT_TYPE, "text/html");
outputStream
.write("<h4>Policy element not found!</h4>".getBytes());
} else {
serializer.serialize(p, outputStream);
}
}
} else {
response.addHeader(HTTP.CONTENT_TYPE, "text/html");
outputStream.write("<h4>Policy not found!</h4>".getBytes());