use of org.apache.openmeetings.db.dto.room.Whiteboard in project openmeetings by apache.
the class WbConverter method convert.
public static Whiteboard convert(FileItem fi) {
Whiteboard wb = new Whiteboard();
wb.setWidth(0);
wb.setHeight(0);
Set<String> uids = new HashSet<>();
List<?> wml = loadWmlFile(fi.getHash());
for (Object wo : wml) {
List<?> props = (List<?>) wo;
if (!props.isEmpty()) {
String uid = (String) props.get(props.size() - 1);
if (uids.contains(uid)) {
continue;
}
uids.add(uid);
switch((String) props.get(0)) {
case "letter":
processText(wb, props);
break;
case "paint":
processPath(wb, props);
break;
case "line":
case "uline":
processLine(wb, props);
break;
case "rectangle":
case // will replace with rectangle
"drawarrow":
add(wb, processRect(wb, props));
break;
case "ellipse":
processEllipse(wb, props);
break;
case "clipart":
processClipart(wb, props);
break;
case TYPE_IMAGE:
processImage(wb, props);
break;
case "swf":
processDoc(wb, props);
break;
case "flv":
processVid(wb, props);
break;
}
}
}
return wb;
}
use of org.apache.openmeetings.db.dto.room.Whiteboard in project openmeetings by apache.
the class BackupImport method performImport.
public void performImport(InputStream is) throws Exception {
userMap.clear();
groupMap.clear();
calendarMap.clear();
appointmentMap.clear();
roomMap.clear();
messageFolderMap.clear();
userContactMap.clear();
fileMap.clear();
messageFolderMap.put(INBOX_FOLDER_ID, INBOX_FOLDER_ID);
messageFolderMap.put(SENT_FOLDER_ID, SENT_FOLDER_ID);
messageFolderMap.put(TRASH_FOLDER_ID, TRASH_FOLDER_ID);
File f = unzip(is);
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
RegistryMatcher matcher = new RegistryMatcher();
Serializer simpleSerializer = new Persister(strategy, matcher);
matcher.bind(Long.class, LongTransform.class);
registry.bind(Date.class, DateConverter.class);
BackupVersion ver = getVersion(simpleSerializer, f);
importConfigs(f);
importGroups(f, simpleSerializer);
Long defaultLdapId = importLdap(f, simpleSerializer);
importOauth(f, simpleSerializer);
importUsers(f, defaultLdapId);
importRooms(f);
importRoomGroups(f);
importChat(f);
importCalendars(f);
importAppointments(f);
importMeetingMembers(f);
importRecordings(f);
importPrivateMsgFolders(f, simpleSerializer);
importContacts(f);
importPrivateMsgs(f);
List<FileItem> files = importFiles(f);
importPolls(f);
importRoomFiles(f);
log.info("Room files import complete, starting copy of files and folders");
/*
* ##################### Import real files and folders
*/
importFolders(f);
if (ver.compareTo(BackupVersion.get("4.0.0")) < 0) {
for (BaseFileItem bfi : files) {
if (bfi.isDeleted()) {
continue;
}
if (BaseFileItem.Type.Presentation == bfi.getType()) {
convertOldPresentation((FileItem) bfi);
fileItemDao._update(bfi);
}
if (BaseFileItem.Type.WmlFile == bfi.getType()) {
try {
Whiteboard wb = WbConverter.convert((FileItem) bfi);
wb.save(bfi.getFile().toPath());
} catch (Exception e) {
log.error("Unexpected error while converting WB", e);
}
}
}
}
log.info("File explorer item import complete, clearing temp files");
FileUtils.deleteDirectory(f);
}
use of org.apache.openmeetings.db.dto.room.Whiteboard in project openmeetings by apache.
the class RoomResourceReference method getFileItem.
@Override
protected FileItem getFileItem(Attributes attr) {
PageParameters params = attr.getParameters();
StringValue _id = params.get("id");
String uid = params.get("uid").toString();
Long id = null;
try {
id = _id.toOptionalLong();
} catch (NumberFormatException e) {
// no-op expected
}
WebSession ws = WebSession.get();
Client c = cm.get(uid);
if (id == null || !ws.isSignedIn() || c == null) {
return null;
}
FileItem f = (FileItem) fileDao.getAny(id);
if (f == null) {
return null;
}
String ruid = params.get("ruid").toString();
String wuid = params.get("wuid").toString();
if (c.getRoom() != null) {
Whiteboards wbs = wbManager.get(c.getRoom().getId());
if (!Strings.isEmpty(wuid) && !Strings.isEmpty(ruid) && ruid.equals(wbs.getUid())) {
for (Entry<Long, Whiteboard> e : wbs.getWhiteboards().entrySet()) {
JSONObject file = e.getValue().get(wuid);
if (file != null && f.getId().equals(file.optLong(ATTR_FILE_ID))) {
// item IS on WB
return f;
}
}
}
}
if (f.getGroupId() != null && groupUserDao.isUserInGroup(f.getGroupId(), getUserId())) {
return f;
}
return null;
}
use of org.apache.openmeetings.db.dto.room.Whiteboard in project openmeetings by apache.
the class WbPanel method saveWb.
public String saveWb(Long roomId, Long wbId, String name) {
Whiteboard wb = wbm.get(roomId).get(wbId);
FileItem f = new FileItem();
f.setType(BaseFileItem.Type.WmlFile);
f.setRoomId(roomId);
f.setHash(UUID.randomUUID().toString());
f.setName(name);
f = fileDao.update(f);
return wb.save(f.getFile().toPath());
}
use of org.apache.openmeetings.db.dto.room.Whiteboard in project openmeetings by apache.
the class WbPanel method internalWbLoad.
@Override
void internalWbLoad(StringBuilder sb) {
Long langId = rp.getClient().getUser().getLanguageId();
if (!wbm.contains(roomId) && rp.getRoom().getFiles() != null && !rp.getRoom().getFiles().isEmpty()) {
if (wbm.tryLock(roomId)) {
try {
TreeMap<Long, List<BaseFileItem>> files = new TreeMap<>();
for (RoomFile rf : rp.getRoom().getFiles()) {
List<BaseFileItem> bfl = files.get(rf.getWbIdx());
if (bfl == null) {
files.put(rf.getWbIdx(), new ArrayList<>());
bfl = files.get(rf.getWbIdx());
}
bfl.add(rf.getFile());
}
Whiteboards _wbs = wbm.get(roomId, langId);
for (Map.Entry<Long, List<BaseFileItem>> e : files.entrySet()) {
Whiteboard wb = wbm.add(roomId, langId);
_wbs.setActiveWb(wb.getId());
for (BaseFileItem fi : e.getValue()) {
sendFileToWb(fi, false);
}
}
} finally {
wbm.unlock(roomId);
}
}
}
Whiteboards wbs = wbm.get(roomId, langId);
loadWhiteboards(sb, rp.getClient(), wbs, wbm.list(roomId));
JSONObject wbj = getWbJson(wbs.getActiveWb());
sb.append("WbArea.activateWb(").append(wbj).append(");");
Whiteboard wb = wbs.get(wbs.getActiveWb());
if (wb != null) {
sb.append("WbArea.setSlide(").append(wbj.put(ATTR_SLIDE, wb.getSlide())).append(");");
}
sb.append("WbArea.loadVideos();");
}
Aggregations