ConflictOverrides overrides = null;
try {
overrides = new ConflictOverrides(overrideConflicts);
}
catch (IllegalArgumentException e) {
throw new BadRequestException(i18n.tr("Unknown conflict to force"));
}
String filename = "";
Owner owner = findOwner(ownerKey);
Map<String, Object> data = new HashMap<String, Object>();
try {
InputPart part = input.getParts().get(0);
MultivaluedMap<String, String> headers = part.getHeaders();
String contDis = headers.getFirst("Content-Disposition");
StringTokenizer st = new StringTokenizer(contDis, ";");
while (st.hasMoreTokens()) {
String entry = st.nextToken().trim();
if (entry.startsWith("filename")) {
filename = entry.substring(entry.indexOf("=") + 2, entry.length() - 1);
break;
}
}
File archive = part.getBody(new GenericType<File>() {
});
log.info("Importing archive " + archive.getAbsolutePath() +
" for owner " + owner.getDisplayName());
data = importer.loadExport(owner, archive, overrides);
sink.emitImportCreated(owner);
recordImportSuccess(owner, data, overrides, filename);
}
catch (IOException e) {
recordImportFailure(owner, data, e, filename);
throw new IseException(i18n.tr("Error reading export archive"), e);
}
// These come back with internationalized messages, so we can transfer:
catch (SyncDataFormatException e) {
recordImportFailure(owner, data, e, filename);
throw new BadRequestException(e.getMessage(), e);
}
catch (ImporterException e) {
recordImportFailure(owner, data, e, filename);
throw new IseException(e.getMessage(), e);
}