NIHVIVO-1277 When referencing a file, assume that the FileByteStream resource contains the alias URL.
This commit is contained in:
parent
a79b203a15
commit
cb7fdf17ca
1 changed files with 36 additions and 8 deletions
|
@ -103,21 +103,15 @@ public class FileInfo {
|
||||||
log.debug("mimeType for '" + uri + "' was '" + mimeType + "'");
|
log.debug("mimeType for '" + uri + "' was '" + mimeType + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
String bytestreamUri;
|
|
||||||
Individual byteStream = surrogate
|
Individual byteStream = surrogate
|
||||||
.getRelatedIndividual(VitroVocabulary.FS_DOWNLOAD_LOCATION);
|
.getRelatedIndividual(VitroVocabulary.FS_DOWNLOAD_LOCATION);
|
||||||
if (byteStream == null) {
|
if (byteStream == null) {
|
||||||
bytestreamUri = null;
|
|
||||||
log.error("File surrogate '" + uri
|
log.error("File surrogate '" + uri
|
||||||
+ "' had no associated bytestream.");
|
+ "' had no associated bytestream.");
|
||||||
} else {
|
|
||||||
bytestreamUri = byteStream.getURI();
|
|
||||||
log.debug("File surroage'" + uri + "' had associated bytestream: '"
|
|
||||||
+ byteStream.getURI() + "'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String bytestreamAliasUrl = FileServingHelper.getBytestreamAliasUrl(
|
String bytestreamUri = findBytestreamUri(byteStream, uri);
|
||||||
bytestreamUri, filename);
|
String bytestreamAliasUrl = findBytestreamAliasUrl(byteStream, uri);
|
||||||
|
|
||||||
return new FileInfo.Builder().setUri(uri).setFilename(filename)
|
return new FileInfo.Builder().setUri(uri).setFilename(filename)
|
||||||
.setMimeType(mimeType).setBytestreamUri(bytestreamUri)
|
.setMimeType(mimeType).setBytestreamUri(bytestreamUri)
|
||||||
|
@ -154,6 +148,40 @@ public class FileInfo {
|
||||||
return false;
|
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.
|
// The instance variables and methods.
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue