use of org.simpleframework.xml.strategy.Strategy in project openmeetings by apache.
the class BackupExport method exportChat.
/*
* ##################### Chat
*/
private void exportChat(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
List<ChatMessage> list = chatDao.get(0, Integer.MAX_VALUE);
Registry registry = new Registry();
registry.bind(User.class, UserConverter.class);
registry.bind(Room.class, RoomConverter.class);
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
bindDate(registry, list, ChatMessage::getSent);
writeList(serializer, zos, "chat_messages.xml", "chat_messages", list);
progressHolder.setProgress(85);
}
use of org.simpleframework.xml.strategy.Strategy in project openmeetings by apache.
the class BackupExport method exportRecording.
/*
* ##################### Recordings
*/
private void exportRecording(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
List<Recording> list = recordingDao.get();
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
bindDate(registry, list);
writeList(serializer, zos, "flvRecordings.xml", "flvrecordings", list);
progressHolder.setProgress(70);
}
use of org.simpleframework.xml.strategy.Strategy in project openmeetings by apache.
the class BackupExport method exportPoll.
/*
* ##################### Polls
*/
private void exportPoll(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
List<RoomPoll> list = pollManager.get();
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
registry.bind(User.class, UserConverter.class);
registry.bind(Room.class, RoomConverter.class);
registry.bind(RoomPoll.Type.class, PollTypeConverter.class);
bindDate(registry, list, RoomPoll::getCreated);
writeList(serializer, zos, "roompolls.xml", "roompolls", list);
progressHolder.setProgress(75);
}
use of org.simpleframework.xml.strategy.Strategy in project openmeetings by apache.
the class BackupExport method exportOauth.
/*
* ##################### OAuth2 servers
*/
private void exportOauth(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
List<OAuthServer> list = auth2Dao.get(0, Integer.MAX_VALUE);
bindDate(registry, list);
writeList(serializer, zos, "oauth2servers.xml", "oauth2servers", list);
progressHolder.setProgress(45);
}
use of org.simpleframework.xml.strategy.Strategy in project openmeetings by apache.
the class BackupImport method importConfigs.
/*
* ##################### Import Configs
*/
private void importConfigs(File f) throws Exception {
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
RegistryMatcher matcher = new RegistryMatcher();
Serializer serializer = new Persister(strategy, matcher);
matcher.bind(Long.class, LongTransform.class);
registry.bind(Date.class, DateConverter.class);
registry.bind(User.class, new UserConverter(userDao, userMap));
List<Configuration> list = readList(serializer, f, "configs.xml", "configs", Configuration.class);
for (Configuration c : list) {
if (c.getKey() == null || c.isDeleted()) {
continue;
}
String newKey = outdatedConfigKeys.get(c.getKey());
if (newKey != null) {
c.setKey(newKey);
}
Configuration.Type type = configTypes.get(c.getKey());
if (type != null) {
c.setType(type);
if (Configuration.Type.bool == type) {
c.setValue(String.valueOf("1".equals(c.getValue()) || "yes".equals(c.getValue()) || "true".equals(c.getValue())));
}
}
Configuration cfg = cfgDao.forceGet(c.getKey());
if (cfg != null && !cfg.isDeleted()) {
log.warn("Non deleted configuration with same key is found! old value: {}, new value: {}", cfg.getValue(), c.getValue());
}
c.setId(cfg == null ? null : cfg.getId());
if (c.getUser() != null && c.getUser().getId() == null) {
c.setUser(null);
}
if (CONFIG_CRYPT.equals(c.getKey())) {
try {
Class<?> clazz = Class.forName(c.getValue());
clazz.getDeclaredConstructor().newInstance();
} catch (Exception e) {
log.warn("Not existing Crypt class found {}, replacing with SCryptImplementation", c.getValue());
c.setValue(SCryptImplementation.class.getCanonicalName());
}
}
cfgDao.update(c, null);
}
}
Aggregations