}
output = rl.getTextRepresentation();
} else {
// Return the file content
output = new FileRepresentation(file, metadataService
.getDefaultMediaType(), getTimeToLive());
updateMetadata(metadataService, file.getName(), output);
}
} else {
// We look for the possible variant which has the same
// extensions in a distinct order.
// 1- set up base name as the longest part of the name
// without known extensions (beginning from the left)
String baseName = getBaseName(file, metadataService);
Set<String> extensions = getExtensions(file,
metadataService);
// 2- loooking for resources with the same base name
File[] files = file.getParentFile().listFiles();
File uniqueVariant = null;
if (files != null) {
for (File entry : files) {
if (baseName.equals(getBaseName(entry,
metadataService))) {
Set<String> entryExtensions = getExtensions(
entry, metadataService);
if (entryExtensions.containsAll(extensions)
&& extensions
.containsAll(entryExtensions)) {
// The right representation has been found.
uniqueVariant = entry;
break;
}
}
}
}
if (uniqueVariant != null) {
// Return the file content
output = new FileRepresentation(uniqueVariant,
metadataService.getDefaultMediaType(),
getTimeToLive());
updateMetadata(metadataService, file.getName(), output);
}
}