mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 14:33:09 +00:00
38 lines
1.4 KiB
Java
38 lines
1.4 KiB
Java
/**
|
|
* The contents of this file are subject to the license and copyright
|
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
* tree and available online at
|
|
*
|
|
* http://www.dspace.org/license/
|
|
*/
|
|
package org.dspace.curate;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import org.apache.commons.cli.ParseException;
|
|
import org.dspace.core.Context;
|
|
import org.dspace.eperson.EPerson;
|
|
|
|
public class CurationCli extends Curation {
|
|
|
|
@Override
|
|
protected void assignCurrentUserInContext() throws ParseException {
|
|
if (this.commandLine.hasOption('e')) {
|
|
String ePersonEmail = this.commandLine.getOptionValue('e');
|
|
this.context = new Context(Context.Mode.BATCH_EDIT);
|
|
try {
|
|
EPerson ePerson = ePersonService.findByEmail(this.context, ePersonEmail);
|
|
if (ePerson == null) {
|
|
super.handler.logError("EPerson not found: " + ePersonEmail);
|
|
throw new IllegalArgumentException("Unable to find a user with email: " + ePersonEmail);
|
|
}
|
|
this.context.setCurrentUser(ePerson);
|
|
} catch (SQLException e) {
|
|
throw new IllegalArgumentException("SQLException trying to find user with email: " + ePersonEmail);
|
|
}
|
|
} else {
|
|
throw new ParseException("Required parameter -e missing!");
|
|
}
|
|
}
|
|
}
|