diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/model/FileInfo.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/model/FileInfo.java index 53cd50c0e..2504c1878 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/model/FileInfo.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/model/FileInfo.java @@ -103,21 +103,15 @@ public class FileInfo { log.debug("mimeType for '" + uri + "' was '" + mimeType + "'"); } - String bytestreamUri; Individual byteStream = surrogate .getRelatedIndividual(VitroVocabulary.FS_DOWNLOAD_LOCATION); if (byteStream == null) { - bytestreamUri = null; log.error("File surrogate '" + uri + "' had no associated bytestream."); - } else { - bytestreamUri = byteStream.getURI(); - log.debug("File surroage'" + uri + "' had associated bytestream: '" - + byteStream.getURI() + "'"); } - String bytestreamAliasUrl = FileServingHelper.getBytestreamAliasUrl( - bytestreamUri, filename); + String bytestreamUri = findBytestreamUri(byteStream, uri); + String bytestreamAliasUrl = findBytestreamAliasUrl(byteStream, uri); return new FileInfo.Builder().setUri(uri).setFilename(filename) .setMimeType(mimeType).setBytestreamUri(bytestreamUri) @@ -154,6 +148,40 @@ public class FileInfo { return false; } + /** + * Get the URI of the bytestream, or null if there is none. + */ + private static String findBytestreamUri(Individual byteStream, + String surrogateUri) { + if (byteStream == null) { + return null; + } + + String bytestreamUri = byteStream.getURI(); + log.debug("File surrogate'" + surrogateUri + + "' had associated bytestream: '" + byteStream.getURI() + "'"); + return bytestreamUri; + } + + /** + * Get the alias URL from the bytestream, or null if there is none. + */ + private static String findBytestreamAliasUrl(Individual byteStream, + String surrogateUri) { + if (byteStream == null) { + return null; + } + + String aliasUrl = byteStream.getDataValue(VitroVocabulary.FS_ALIAS_URL); + if (aliasUrl == null) { + log.error("File had no aliasUrl: '" + surrogateUri + "'"); + } else { + log.debug("aliasUrl for '" + surrogateUri + "' was '" + aliasUrl + + "'"); + } + return aliasUrl; + } + // ---------------------------------------------------------------------- // The instance variables and methods. // ----------------------------------------------------------------------