if (urlManager.isActionableBitstreamUrl(context, emUri))
{
Bitstream bitstream = urlManager.getBitstream(context, emUri);
if (bitstream == null)
{
throw new SwordError(404);
}
// now we have the deposit target, we can determine whether this operation is allowed
// at all
WorkflowManager wfm = WorkflowManagerFactory.getInstance();
wfm.replaceBitstream(context, bitstream);
// check that we can submit to ALL the items this bitstream is in
List<Item> items = new ArrayList<Item>();
for (Bundle bundle : bitstream.getBundles())
{
for (Item item : bundle.getItems())
{
this.checkAuth(sc, item);
items.add(item);
}
}
// make a note of the authentication in the verbose string
this.verboseDescription.append("Authenticated user: " + sc.getAuthenticated().getEmail());
if (sc.getOnBehalfOf() != null)
{
this.verboseDescription.append("Depositing on behalf of: " + sc.getOnBehalfOf().getEmail());
}
DepositResult result = null;
try
{
result = this.replaceBitstream(sc, items, bitstream, deposit, authCredentials, config);
}
catch(DSpaceSwordException e)
{
if (config.isKeepPackageOnFailedIngest())
{
try
{
this.storePackageAsFile(deposit, authCredentials, config);
}
catch(IOException e2)
{
log.warn("Unable to store SWORD package as file: " + e);
}
}
throw e;
}
catch(SwordError e)
{
if (config.isKeepPackageOnFailedIngest())
{
try
{
this.storePackageAsFile(deposit, authCredentials, config);
}
catch(IOException e2)
{
log.warn("Unable to store SWORD package as file: " + e);
}
}
throw e;
}
// now we've produced a deposit, we need to decide on its workflow state
wfm.resolveState(context, deposit, null, this.verboseDescription, false);
ReceiptGenerator genny = new ReceiptGenerator();
receipt = genny.createFileReceipt(context, result, config);
}
else
{
// get the deposit target
Item item = this.getDSpaceTarget(context, emUri, config);
if (item == null)
{
throw new SwordError(404);
}
// now we have the deposit target, we can determine whether this operation is allowed
// at all
WorkflowManager wfm = WorkflowManagerFactory.getInstance();