String message = null;
// Process the file uploaded
try {
// Wrap multipart request to get the submission info
FileUploadRequest wrapper = new FileUploadRequest(request);
String inputType = wrapper.getParameter("inputType");
List<String> reqCollectionsTmp = getRepeatedParameter(wrapper, "collections", "collections");
String[] reqCollections = new String[reqCollectionsTmp.size()];
reqCollectionsTmp.toArray(reqCollections);
//Get all collections
List<Collection> collections = null;
String colIdS = wrapper.getParameter("colId");
if (colIdS!=null){
collections = new ArrayList<Collection>();
collections.add(Collection.find(context, Integer.parseInt(colIdS)));
}
else {
collections = Arrays.asList(Collection.findAll(context));
}
request.setAttribute("collections", collections);
Collection owningCollection = null;
if (wrapper.getParameter("collection") != null) {
int colId = Integer.parseInt(wrapper.getParameter("collection"));
if (colId > 0)
owningCollection = Collection.find(context, colId);
}
//Get all the possible data loaders from the Spring configuration
BTEBatchImportService dls = new DSpace().getSingletonService(BTEBatchImportService.class);
List<String> inputTypes =dls.getFileDataLoaders();
request.setAttribute("input-types", inputTypes);
File f = null;
String zipurl = null;
if (inputType.equals("saf")){
zipurl = wrapper.getParameter("zipurl");
if (StringUtils.isEmpty(zipurl)) {
request.setAttribute("has-error", "true");
Locale locale = request.getLocale();
ResourceBundle msgs = ResourceBundle.getBundle("Messages", locale);
try {
message = msgs.getString("jsp.layout.navbar-admin.batchimport.fileurlempty");
} catch (Exception e) {
message = "???jsp.layout.navbar-admin.batchimport.fileurlempty???";
}
request.setAttribute("message", message);
JSPManager.showJSP(request, response, "/dspace-admin/batchimport.jsp");
return;
}
}
else {
f = wrapper.getFile("file");
if (f == null) {
request.setAttribute("has-error", "true");
Locale locale = request.getLocale();
ResourceBundle msgs = ResourceBundle.getBundle("Messages", locale);
try {
message = msgs.getString("jsp.layout.navbar-admin.batchimport.fileempty");
} catch (Exception e) {
message = "???jsp.layout.navbar-admin.batchimport.fileempty???";
}
request.setAttribute("message", message);
JSPManager.showJSP(request, response, "/dspace-admin/batchimport.jsp");
return;
}
else if (owningCollection==null){
request.setAttribute("has-error", "true");
Locale locale = request.getLocale();
ResourceBundle msgs = ResourceBundle.getBundle("Messages", locale);
try {
message = msgs.getString("jsp.layout.navbar-admin.batchimport.owningcollectionempty");
} catch (Exception e) {
message = "???jsp.layout.navbar-admin.batchimport.owningcollectionempty???";
}
request.setAttribute("message", message);
JSPManager.showJSP(request, response, "/dspace-admin/batchimport.jsp");
return;
}
}
String uploadId = wrapper.getParameter("uploadId");
if (uploadId != null){
request.setAttribute("uploadId", uploadId);
}
if (owningCollection==null && reqCollections != null && reqCollections.length > 0){