NIHVIVO-1277 When uploading a file, store the alias URL on the FileByteStream resource.
This commit is contained in:
parent
fcf0eb527f
commit
a79b203a15
1 changed files with 18 additions and 12 deletions
|
@ -66,23 +66,24 @@ public class UploadedFileHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the file individuals in the model
|
// Create the file individuals in the model
|
||||||
Individual byteStream = createByteStreamIndividual();
|
Individual byteStream = createByteStreamIndividual(filename);
|
||||||
String bytestreamUri = byteStream.getURI();
|
String bytestreamUri = byteStream.getURI();
|
||||||
|
String aliasUrl = byteStream.getDataValue(VitroVocabulary.FS_ALIAS_URL);
|
||||||
|
|
||||||
Individual file = createFileIndividual(mimeType, filename, byteStream);
|
Individual file = createFileIndividual(mimeType, filename, byteStream);
|
||||||
String fileUri = file.getURI();
|
String fileUri = file.getURI();
|
||||||
|
|
||||||
// Store the file in the FileStorage system.
|
// Store the file in the FileStorage system.
|
||||||
fileStorage.createFile(bytestreamUri, filename, inputStream);
|
fileStorage.createFile(bytestreamUri, filename, inputStream);
|
||||||
|
|
||||||
// Figure out the alias URL
|
|
||||||
String aliasUrl = FileServingHelper.getBytestreamAliasUrl(
|
|
||||||
bytestreamUri, filename);
|
|
||||||
|
|
||||||
// And wrap it all up in a tidy little package.
|
// And wrap it all up in a tidy little package.
|
||||||
return new FileInfo.Builder().setFilename(filename)
|
FileInfo.Builder builder = new FileInfo.Builder();
|
||||||
.setMimeType(mimeType).setUri(fileUri)
|
builder.setFilename(filename);
|
||||||
.setBytestreamUri(bytestreamUri)
|
builder.setMimeType(mimeType);
|
||||||
.setBytestreamAliasUrl(aliasUrl).build();
|
builder.setUri(fileUri);
|
||||||
|
builder.setBytestreamUri(bytestreamUri);
|
||||||
|
builder.setBytestreamAliasUrl(aliasUrl);
|
||||||
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,10 +152,10 @@ public class UploadedFileHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a bytestream individual in the model. It's just a naked individual
|
* Create a bytestream individual in the model. The only property is the
|
||||||
* with no properties.
|
* alias URL
|
||||||
*/
|
*/
|
||||||
private Individual createByteStreamIndividual() {
|
private Individual createByteStreamIndividual(String filename) {
|
||||||
Individual byteStream = new IndividualImpl();
|
Individual byteStream = new IndividualImpl();
|
||||||
byteStream.setVClassURI(VitroVocabulary.FS_BYTESTREAM_CLASS);
|
byteStream.setVClassURI(VitroVocabulary.FS_BYTESTREAM_CLASS);
|
||||||
|
|
||||||
|
@ -166,6 +167,11 @@ public class UploadedFileHelper {
|
||||||
"Failed to create the bytestream individual.", e);
|
"Failed to create the bytestream individual.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dataPropertyStatementDao
|
||||||
|
.insertNewDataPropertyStatement(new DataPropertyStatementImpl(
|
||||||
|
uri, VitroVocabulary.FS_ALIAS_URL, FileServingHelper
|
||||||
|
.getBytestreamAliasUrl(uri, filename)));
|
||||||
|
|
||||||
return individualDao.getIndividualByURI(uri);
|
return individualDao.getIndividualByURI(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue