try {
Request request = ObjectModelHelper.getRequest(objectModel);
Session session = RepositoryUtil.getSession(this.manager, request);
ResourceType resourceType;
Publication pub = null;
String attribute;
String[] steps = name.split(":");
if (steps.length == 1) {
DocumentFactory docFactory = DocumentUtil.createDocumentFactory(this.manager,
session);
String webappUrl = ServletHelper.getWebappURI(request);
Document document = docFactory.getFromURL(webappUrl);
pub = document.getPublication();
attribute = name;
resourceType = document.getResourceType();
} else {
attribute = steps[1];
String resourceTypeName = steps[0];
ServiceSelector selector = null;
try {
selector = (ServiceSelector) this.manager
.lookup(ResourceType.ROLE + "Selector");
resourceType = (ResourceType) selector.select(resourceTypeName);
} finally {
this.manager.release(selector);
}
}
if (attribute.startsWith("format-")) {
String[] formatSteps = name.split("-");
String format = formatSteps[1];
value = resourceType.getFormatURI(format);
} else if (attribute.equals(SCHEMA_URI)) {
value = resourceType.getSchema().getURI();
} else if (attribute.equals(HTTP_SCHEMA_URI)) {
String uri = resourceType.getSchema().getURI();
value = transformFallbackUriToHttp(pub.getId(), uri);
} else if (attribute.equals(EXPIRES)) {
Date expires = resourceType.getExpires();
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy kk:mm:ss zzz");
value = sdf.format(expires);
} else if (attribute.equals(SUPPORTS_FORMAT)) {
String format = steps[steps.length - 1];
String[] formats = resourceType.getFormats();
return Boolean.toString(Arrays.asList(formats).contains(format));
} else {
throw new ConfigurationException("Attribute [" + name + "] not supported!");
}