use of org.apache.openmeetings.db.entity.basic.Configuration in project openmeetings by apache.
the class BackupExport method main.
public static void main(String[] args) throws Exception {
List<Configuration> list = ImportInitvalues.initialCfgs(new InstallationConfig());
Serializer ser = getConfigSerializer(list);
ByteArrayOutputStream baos = stream(ser, "configs", list);
File f = new File(args[0]);
if (!f.exists() && !f.getParentFile().exists()) {
f.getParentFile().mkdirs();
}
Files.write(Paths.get(args[0]), baos.toByteArray(), StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);
}
use of org.apache.openmeetings.db.entity.basic.Configuration in project openmeetings by apache.
the class BackupExport method exportConfig.
/*
* ##################### Config
*/
private void exportConfig(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
List<Configuration> list = configurationDao.get(0, Integer.MAX_VALUE);
Serializer serializer = getConfigSerializer(list);
writeList(serializer, zos, "configs.xml", "configs", list);
progressHolder.setProgress(80);
}
use of org.apache.openmeetings.db.entity.basic.Configuration 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);
}
}
use of org.apache.openmeetings.db.entity.basic.Configuration in project openmeetings by apache.
the class ConfigForm method onNewSubmit.
@Override
protected void onNewSubmit(AjaxRequestTarget target, Form<?> form) {
this.setModelObject(new Configuration());
refresh(target);
}
use of org.apache.openmeetings.db.entity.basic.Configuration in project openmeetings by apache.
the class ConfigForm method onRefreshSubmit.
@Override
protected void onRefreshSubmit(AjaxRequestTarget target, Form<?> form) {
Configuration conf = getModelObject();
if (conf.getId() != null) {
conf = cfgDao.get(conf.getId());
} else {
conf = new Configuration();
}
setModelObject(conf);
refresh(target);
}
Aggregations