use of org.simpleframework.xml.strategy.Strategy in project openmeetings by apache.
the class BackupExport method exportRoomFile.
/*
* ##################### Backup Room Files
*/
private void exportRoomFile(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
registry.bind(FileItem.class, BaseFileItemConverter.class);
registry.bind(Recording.class, BaseFileItemConverter.class);
writeList(serializer, zos, "roomFiles.xml", "RoomFiles", roomDao.getFiles());
progressHolder.setProgress(17);
}
use of org.simpleframework.xml.strategy.Strategy in project openmeetings by apache.
the class BackupExport method exportAppointment.
/*
* ##################### Backup Appointments
*/
private void exportAppointment(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
List<Appointment> list = appointmentDao.get();
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
registry.bind(User.class, UserConverter.class);
registry.bind(Appointment.Reminder.class, AppointmentReminderTypeConverter.class);
registry.bind(Room.class, RoomConverter.class);
bindDate(registry, list);
writeList(serializer, zos, "appointements.xml", "appointments", list);
progressHolder.setProgress(25);
}
use of org.simpleframework.xml.strategy.Strategy in project openmeetings by apache.
the class BackupExport method exportRoom.
/*
* ##################### Backup Room
*/
private void exportRoom(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
registry.bind(User.class, UserConverter.class);
registry.bind(Room.Type.class, RoomTypeConverter.class);
List<Room> list = roomDao.get();
bindDate(registry, list);
writeList(serializer, zos, "rooms.xml", "rooms", list);
progressHolder.setProgress(15);
}
use of org.simpleframework.xml.strategy.Strategy in project openmeetings by apache.
the class BackupImport method importUsers.
/*
* ##################### Import Users
*/
private void importUsers(File f, Long defaultLdapId) throws Exception {
log.info("OAuth2 servers import complete, starting user import");
String jNameTimeZone = getDefaultTimezone();
// add existence email from database
List<User> users = userDao.getAllUsers();
final Map<String, Integer> userEmailMap = new HashMap<>();
final Map<String, Integer> userLoginMap = new HashMap<>();
for (User u : users) {
if (u.getAddress() == null || u.getAddress().getEmail() == null || User.Type.user != u.getType()) {
continue;
}
userEmailMap.put(u.getAddress().getEmail(), Integer.valueOf(-1));
userLoginMap.put(u.getLogin(), Integer.valueOf(-1));
}
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
Serializer ser = new Persister(strategy);
registry.bind(Group.class, new GroupConverter(groupDao, groupMap));
registry.bind(Salutation.class, SalutationConverter.class);
registry.bind(Date.class, DateConverter.class);
List<User> list = readList(ser, f, "users.xml", "users", User.class);
int minLoginLength = getMinLoginLength(cfgDao);
for (User u : list) {
if (u.getLogin() == null) {
continue;
}
// check that email is unique
if (u.getAddress() != null && u.getAddress().getEmail() != null && User.Type.user == u.getType()) {
if (userEmailMap.containsKey(u.getAddress().getEmail())) {
log.warn("Email is duplicated for user " + u.toString());
String updateEmail = String.format("modified_by_import_<%s>%s", UUID.randomUUID(), u.getAddress().getEmail());
u.getAddress().setEmail(updateEmail);
}
userEmailMap.put(u.getAddress().getEmail(), Integer.valueOf(userEmailMap.size()));
}
if (userLoginMap.containsKey(u.getLogin())) {
log.warn("Login is duplicated for user " + u.toString());
String updateLogin = String.format("modified_by_import_<%s>%s", UUID.randomUUID(), u.getLogin());
u.setLogin(updateLogin);
}
userLoginMap.put(u.getLogin(), Integer.valueOf(userLoginMap.size()));
if (u.getGroupUsers() != null) {
for (GroupUser gu : u.getGroupUsers()) {
gu.setUser(u);
}
}
if (u.getType() == User.Type.contact && u.getLogin().length() < minLoginLength) {
u.setLogin(UUID.randomUUID().toString());
}
String tz = u.getTimeZoneId();
if (tz == null) {
u.setTimeZoneId(jNameTimeZone);
u.setForceTimeZoneCheck(true);
} else {
u.setForceTimeZoneCheck(false);
}
Long userId = u.getId();
u.setId(null);
if (u.getSipUser() != null && u.getSipUser().getId() != 0) {
u.getSipUser().setId(0);
}
if (LDAP_EXT_TYPE.equals(u.getExternalType()) && User.Type.external != u.getType()) {
log.warn("Found LDAP user in 'old' format, external_type == 'LDAP':: " + u);
u.setType(User.Type.ldap);
u.setExternalType(null);
if (u.getDomainId() == null) {
// domainId was not supported in old versions of OM
u.setDomainId(defaultLdapId);
}
}
if (!Strings.isEmpty(u.getExternalType())) {
u.setType(User.Type.external);
}
if (AuthLevelUtil.hasLoginLevel(u.getRights()) && !Strings.isEmpty(u.getActivatehash())) {
u.setActivatehash(null);
}
userDao.update(u, Long.valueOf(-1));
userMap.put(userId, u.getId());
}
}
use of org.simpleframework.xml.strategy.Strategy in project openmeetings by apache.
the class BackupImport method importRecordings.
/*
* ##################### Import Recordings
*/
private void importRecordings(File f) throws Exception {
log.info("Meeting members import complete, starting recordings server import");
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
RegistryMatcher matcher = new RegistryMatcher();
Serializer ser = new Persister(strategy, matcher);
matcher.bind(Long.class, LongTransform.class);
matcher.bind(Integer.class, IntegerTransform.class);
registry.bind(Date.class, DateConverter.class);
registry.bind(Recording.Status.class, RecordingStatusConverter.class);
List<Recording> list = readList(ser, f, "flvRecordings.xml", "flvrecordings", Recording.class);
for (Recording r : list) {
Long recId = r.getId();
r.setId(null);
if (r.getRoomId() != null) {
r.setRoomId(roomMap.get(r.getRoomId()));
}
if (r.getOwnerId() != null) {
r.setOwnerId(userMap.get(r.getOwnerId()));
}
if (r.getMetaData() != null) {
for (RecordingMetaData meta : r.getMetaData()) {
meta.setId(null);
meta.setRecording(r);
}
}
if (!Strings.isEmpty(r.getHash()) && r.getHash().startsWith(RECORDING_FILE_NAME)) {
String name = getFileName(r.getHash());
r.setHash(UUID.randomUUID().toString());
fileMap.put(String.format(FILE_NAME_FMT, name, EXTENSION_JPG), String.format(FILE_NAME_FMT, r.getHash(), EXTENSION_PNG));
fileMap.put(String.format("%s.%s.%s", name, EXTENSION_FLV, EXTENSION_MP4), String.format(FILE_NAME_FMT, r.getHash(), EXTENSION_MP4));
}
if (Strings.isEmpty(r.getHash())) {
r.setHash(UUID.randomUUID().toString());
}
r = recordingDao.update(r);
fileItemMap.put(recId, r.getId());
}
}
Aggregations