private void convertAll()

in openmeetings-web/src/main/java/org/apache/openmeetings/web/room/sidebar/RoomFileUploadResourceReference.java [98:163]


	private void convertAll(Client c, List<FileItem> files, String uuid, boolean toWb, boolean clean, long lastSelectedId, long lastSelectedRoom, long lastSelectedOwner, long lastSelectedGroup) {
		final BaseFileItem parent = fileDao.get(lastSelectedId);
		final long langId = getLangId(c);
		final long totalSize = files.stream().mapToLong(FileItem::getSize).sum();
		final AtomicInteger progress = new AtomicInteger(0);
		long currentSize = 0;
		for (FileItem curItem : files) {
			long size = curItem.getSize();
			try {
				org.apache.openmeetings.db.entity.file.FileItem f = new org.apache.openmeetings.db.entity.file.FileItem();
				f.setSize(size);
				f.setName(curItem.getName());
				if (parent == null || BaseFileItem.Type.RECORDING == parent.getType()) {
					if (lastSelectedGroup > -1) {
						f.setGroupId(lastSelectedGroup);
					} else if (lastSelectedRoom > -1) {
						f.setRoomId(lastSelectedRoom);
					} else {
						f.setOwnerId(lastSelectedOwner > -1 ? lastSelectedOwner : 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());

				ProcessResultList logs = processor.processFile(f, curItem.getInputStream()
						, Optional.<DoubleConsumer>of(part -> sendProgress(c, uuid, progress, progress.get() + (int)(100 * part * size / totalSize))));
				for (ProcessResult res : logs.getJobs()) {
					fileLogDao.add(res.getProcess(), f, res);
				}
				if (logs.hasError()) {
					sendError(c, uuid, Application.getString("convert.errors.file", langId));
				} else {
					WebSocketHelper.sendClient(c, new TextRoomMessage(c.getRoomId(), c, RoomMessage.Type.FILE_TREE_UPDATE
							, new JSONObject() // not necessary for now
									.put("fileId", f.getId())
									.toString()));
					if (toWb) {
						WebSocketHelper.sendClient(c, new TextRoomMessage(c.getRoomId(), c, RoomMessage.Type.WB_PUT_FILE
								, new JSONObject()
										.put("fileId", f.getId())
										.put("clean", clean)
										.toString()));
						clean = false;
					}
				}
			} catch (Exception e) {
				log.error("Unexpected error while processing uploaded file", e);
				sendError(c, uuid, e.getMessage() == null ? "Unexpected error" : e.getMessage());
			} finally {
				try {
					curItem.delete();
				} catch (IOException e) {
					log.error("IOException while deleting FileItem ", e);
				}
			}
			currentSize += size;
			sendProgress(c, uuid, progress, (int)(100 * currentSize / totalSize));
		}
		sendProgress(c, uuid, progress, 100);
	}