if (getLogger().isDebugEnabled()) {
getLogger().debug("Resolving publication template for file [" + name + "]");
}
String resolvedUri = null;
PublicationTemplateManager templateManager = null;
try {
templateManager = (PublicationTemplateManager) this.manager
.lookup(PublicationTemplateManager.ROLE);
PublicationFactory factory = PublicationFactory.getInstance(getLogger());
Publication publication;
String targetUri = null;
// check if publication ID is provided in attribute name
if (name.indexOf(":") > -1) {
String[] parts = name.split(":");
if (parts.length > 2) {
throw new RuntimeException(
"The attribute may not contain more than one colons!");
}
String publicationId = parts[0];
targetUri = parts[1];
if (getLogger().isDebugEnabled()) {
getLogger().debug("Publication ID provided explicitely: [" + publicationId
+ "]");
}
SourceResolver resolver = null;
Source source = null;
try {
resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
source = resolver.resolveURI("context://");
String contextPath = SourceUtil.getFile(source).getAbsolutePath();
publication = factory.getPublication(publicationId, contextPath);
} finally {
if (resolver != null) {
if (source != null) {
resolver.release(source);
}
this.manager.release(resolver);
}
}
} else {
publication = factory.getPublication(objectModel);
targetUri = name;
if (getLogger().isDebugEnabled()) {
getLogger().debug("Publication resolved from request: [" + publication.getId()
+ "]");
}
}
ExistingSourceResolver resolver = new ExistingSourceResolver();
templateManager.visit(publication, targetUri, resolver);
resolvedUri = resolver.getURI();
} catch (final Exception e) {
String message = "Resolving path [" + name + "] failed: ";
getLogger().error(message, e);