Skip to content

Commit

Permalink
Retaining mimetype from simple object upload submissions as the mimet…
Browse files Browse the repository at this point in the history
…ype during ingest
  • Loading branch information
bbpennel committed Jul 1, 2015
1 parent 5aabd9b commit 917997b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Expand Up @@ -42,6 +42,7 @@

import edu.unc.lib.deposit.work.AbstractDepositJob;
import edu.unc.lib.dl.fedora.PID;
import edu.unc.lib.dl.util.ContentModelHelper.DepositRelationship;
import edu.unc.lib.dl.util.DepositConstants;
import edu.unc.lib.dl.util.PackagingType;
import edu.unc.lib.dl.util.PremisEventLogger.Type;
Expand Down Expand Up @@ -81,14 +82,15 @@ public void runJob() {
Map<String, String> depositStatus = getDepositStatus();
String filename = depositStatus.get(DepositField.fileName.name());
String slug = depositStatus.get(DepositField.depositSlug.name());
String mimetype = depositStatus.get(DepositField.fileMimetype.name());

String contentModel = depositStatus.get(hasModel.toString());

// Create the primary resource as a simple resource
Resource primaryResource = model.createResource(primaryPID.getURI());

if (contentModel == null || SIMPLE.equals(contentModel)) {
populateSimple(model, primaryResource, slug, filename);
populateSimple(model, primaryResource, slug, filename, mimetype);
} else {
populateContainer(model, primaryResource, primaryPID, slug, contentModel);
}
Expand All @@ -106,7 +108,8 @@ public void runJob() {
PackagingType.SIMPLE_OBJECT.getUri(), PackagingType.BAG_WITH_N3.getUri());
}

private void populateSimple(Model model, Resource primaryResource, String alabel, String filename) {
private void populateSimple(Model model, Resource primaryResource, String alabel, String filename,
String mimetype) {
File contentFile = new File(this.getDataDirectory(), filename);
if (!contentFile.exists()) {
failJob("Failed to find upload file for simple deposit: " + filename,
Expand All @@ -115,10 +118,12 @@ private void populateSimple(Model model, Resource primaryResource, String alabel

if(alabel == null) alabel = contentFile.getName();
model.add(primaryResource, dprop(model, label), alabel);
if (mimetype != null) {
model.add(primaryResource, dprop(model, DepositRelationship.mimetype), mimetype);
}

// Reference the content file as the data file
try {

model.add(primaryResource, dprop(model, stagingLocation),
DepositConstants.DATA_DIR + "/" + UriUtils.encodeUri(contentFile.getName(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
Expand Down
Expand Up @@ -13,7 +13,8 @@ public static enum DepositField {
fileName, resubmitDirName, resubmitFileName, isResubmit, depositMethod, containerId, payLoadOctets,
createTime, startTime, endTime, ingestedOctets, ingestedObjects, directory, lock, submitTime,
depositorEmail, packagingType, metsProfile, metsType, permissionGroups, depositMd5, depositSlug,
errorMessage, stackTrace, excludeDepositRecord, stagingFolderURI, publishObjects, manifestURI;
errorMessage, stackTrace, excludeDepositRecord, stagingFolderURI, publishObjects, manifestURI,
fileMimetype;
}

public static enum JobField {
Expand Down
Expand Up @@ -112,6 +112,7 @@ protected void registerDeposit(PID depositPid, PID destination, Deposit deposit,
status.put(DepositField.uuid.name(), depositPid.getUUID());
status.put(DepositField.submitTime.name(), String.valueOf(System.currentTimeMillis()));
status.put(DepositField.fileName.name(), deposit.getFilename());
status.put(DepositField.fileMimetype.name(), deposit.getMimeType());
String email = SwordConfigurationImpl.getUserEmailAddress();
status.put(DepositField.depositorName.name(), owner);
status.put(DepositField.depositorEmail.name(), email != null ? email : owner+"@email.unc.edu");
Expand Down

0 comments on commit 917997b

Please sign in to comment.