Search in sources :

Example 1 with Configuration

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);
}
Also used : Configuration(org.apache.openmeetings.db.entity.basic.Configuration) ByteArrayOutputStream(java.io.ByteArrayOutputStream) InstallationConfig(org.apache.openmeetings.installation.InstallationConfig) File(java.io.File) Serializer(org.simpleframework.xml.Serializer)

Example 2 with Configuration

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);
}
Also used : Configuration(org.apache.openmeetings.db.entity.basic.Configuration) Serializer(org.simpleframework.xml.Serializer)

Example 3 with Configuration

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);
    }
}
Also used : UserConverter(org.apache.openmeetings.backup.converter.UserConverter) Configuration(org.apache.openmeetings.db.entity.basic.Configuration) RegistryMatcher(org.simpleframework.xml.transform.RegistryMatcher) Registry(org.simpleframework.xml.convert.Registry) IOException(java.io.IOException) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 4 with Configuration

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);
}
Also used : Configuration(org.apache.openmeetings.db.entity.basic.Configuration)

Example 5 with Configuration

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);
}
Also used : Configuration(org.apache.openmeetings.db.entity.basic.Configuration)

Aggregations

Configuration (org.apache.openmeetings.db.entity.basic.Configuration)17 Test (org.junit.Test)3 Serializer (org.simpleframework.xml.Serializer)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 List (java.util.List)1 Locale (java.util.Locale)1 OpenJPAConfiguration (org.apache.openjpa.conf.OpenJPAConfiguration)1 UserConverter (org.apache.openmeetings.backup.converter.UserConverter)1 ConfigurationDao (org.apache.openmeetings.db.dao.basic.ConfigurationDao)1 Type (org.apache.openmeetings.db.entity.basic.Configuration.Type)1 User (org.apache.openmeetings.db.entity.user.User)1 InstallationConfig (org.apache.openmeetings.installation.InstallationConfig)1 SearchableDataView (org.apache.openmeetings.web.admin.SearchableDataView)1 PagedEntityListPanel (org.apache.openmeetings.web.common.PagedEntityListPanel)1 DataViewContainer (org.apache.openmeetings.web.data.DataViewContainer)1 OmOrderByBorder (org.apache.openmeetings.web.data.OmOrderByBorder)1