Search in sources :

Example 6 with Strategy

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);
}
Also used : ChatMessage(org.apache.openmeetings.db.entity.basic.ChatMessage) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 7 with Strategy

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);
}
Also used : RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Recording(org.apache.openmeetings.db.entity.record.Recording) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 8 with Strategy

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);
}
Also used : RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) RoomPoll(org.apache.openmeetings.db.entity.room.RoomPoll) Serializer(org.simpleframework.xml.Serializer)

Example 9 with Strategy

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);
}
Also used : RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) OAuthServer(org.apache.openmeetings.db.entity.server.OAuthServer) Serializer(org.simpleframework.xml.Serializer)

Example 10 with Strategy

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);
    }
}
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)

Aggregations

Persister (org.simpleframework.xml.core.Persister)34 Strategy (org.simpleframework.xml.strategy.Strategy)34 Registry (org.simpleframework.xml.convert.Registry)33 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)33 Serializer (org.simpleframework.xml.Serializer)31 UserConverter (org.apache.openmeetings.backup.converter.UserConverter)9 RegistryMatcher (org.simpleframework.xml.transform.RegistryMatcher)7 RoomConverter (org.apache.openmeetings.backup.converter.RoomConverter)5 Room (org.apache.openmeetings.db.entity.room.Room)4 FileItem (org.apache.openmeetings.db.entity.file.FileItem)3 IOException (java.io.IOException)2 GroupConverter (org.apache.openmeetings.backup.converter.GroupConverter)2 ChatMessage (org.apache.openmeetings.db.entity.basic.ChatMessage)2 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)2 OmCalendar (org.apache.openmeetings.db.entity.calendar.OmCalendar)2 BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)2 Recording (org.apache.openmeetings.db.entity.record.Recording)2 RoomFile (org.apache.openmeetings.db.entity.room.RoomFile)2 RoomPoll (org.apache.openmeetings.db.entity.room.RoomPoll)2 PrivateMessage (org.apache.openmeetings.db.entity.user.PrivateMessage)2