private String getVersionedPath(final String originalPath, final LibraryType libraryType) {
try {
boolean appendMinSelector = false;
String libraryPath = StringUtils.substringBeforeLast(originalPath, ".");
if (libraryPath.endsWith(MIN_SELECTOR_SEGMENT)) {
appendMinSelector = true;
libraryPath = StringUtils.substringBeforeLast(libraryPath, ".");
}
final HtmlLibrary htmlLibrary = htmlLibraryManager.getLibrary(libraryType, libraryPath);
if (htmlLibrary != null) {
StringBuilder builder = new StringBuilder();
builder.append(htmlLibrary.getLibraryPath());
builder.append(".");
if (appendMinSelector) {
builder.append(MIN_SELECTOR).append(".");
}
builder.append(getMd5(htmlLibrary));
builder.append(libraryType.extension);
return builder.toString();
} else {
log.debug("Could not find HtmlLibrary at path: {}", libraryPath);
return null;
}
} catch (Exception ex) {
log.error("Attempting to get a versioned path for [ {} ] but could not because of: {}", originalPath,
ex.getMessage());
return originalPath;
}
}