this.upload = instance;
if (!validateData()) return null;
resolveContentType();
UploadType newUploadType = uploadTypes.get(contentType);
UploadHandler newupUploadHandler =
newUploadType != null
? newUploadType.getUploadHandler()
: uploadTypes.get(UploadTypes.GENERIC_UPLOAD_TYPE).getUploadHandler();
if (forceSameHandler) {
log.debug("using same upload handler as for the original, based on content type: " + instance.getContentType());
UploadHandler previousUploadHandler;
UploadType previousUploadType = uploadTypes.get(instance.getContentType());
previousUploadHandler =
previousUploadType != null
? previousUploadType.getUploadHandler()
: uploadTypes.get(UploadTypes.GENERIC_UPLOAD_TYPE).getUploadHandler();
if (!previousUploadHandler.getClass().equals(newupUploadHandler.getClass())) {
statusMessages.addFromResourceBundleOrDefault(
ERROR,
"lacewiki.msg.upload.HandlersDontMatch",
"Wrong file type uploaded, please try again with a different file."
);