use of org.apache.openmeetings.util.process.ProcessResultList in project openmeetings by apache.
the class TestFileProcessor method testProcessJpeg.
@Test
public void testProcessJpeg() throws Exception {
for (String ext : new String[] { null, "txt", "png" }) {
FileItem f = new FileItemDTO().setName(String.format(FILE_NAME_FMT, FILE_NAME, ext)).setHash(UUID.randomUUID().toString()).setType(BaseFileItem.Type.Recording).get();
try (InputStream is = new FileInputStream(getDefaultProfilePicture())) {
ProcessResultList result = processor.processFile(f, is);
assertFalse("Conversion should be successful", result.hasError());
assertEquals("Type should be image", BaseFileItem.Type.Image, f.getType());
}
}
}
use of org.apache.openmeetings.util.process.ProcessResultList in project openmeetings by apache.
the class UploadDialog method onSubmit.
@Override
protected void onSubmit(AjaxRequestTarget target) {
List<FileUpload> ful = uploadField.getFileUploads();
if (ful != null) {
boolean clean = cleanWb.getModelObject();
for (FileUpload fu : ful) {
FileItem f = new FileItem();
f.setSize(fu.getSize());
f.setName(fu.getClientFileName());
BaseFileItem parent = roomFiles.getLastSelected();
if (parent == null || !(parent instanceof FileItem)) {
f.setOwnerId(getUserId());
} else {
f.setRoomId(parent.getRoomId());
f.setOwnerId(parent.getOwnerId());
f.setGroupId(parent.getGroupId());
if (parent.getId() != null) {
f.setParentId(BaseFileItem.Type.Folder == parent.getType() ? parent.getId() : parent.getParentId());
}
}
f.setInsertedBy(getUserId());
try {
ProcessResultList logs = processor.processFile(f, fu.getInputStream());
for (ProcessResult res : logs.getJobs()) {
fileLogDao.add(res.getProcess(), f, res);
}
room.getSidebar().updateFiles(target);
if (logs.hasError()) {
form.error(getString("convert.errors.file"));
} else {
if (toWb.getModelObject()) {
room.getWb().sendFileToWb(f, clean);
clean = false;
}
}
} catch (Exception e) {
form.error(e.getMessage());
} finally {
fu.closeStreams();
fu.delete();
}
}
if (form.hasError()) {
onError(target);
} else {
close(target, null);
}
}
}
Aggregations