Search in sources :

Example 1 with BaseFileItemConverter

use of org.apache.openmeetings.backup.converter.BaseFileItemConverter in project openmeetings by apache.

the class BackupImport method importRoomFiles.

/*
	 * ##################### Import Room Files
	 */
private void importRoomFiles(File f) throws Exception {
    log.info("Poll import complete, starting room files import");
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    Serializer serializer = new Persister(strategy);
    registry.bind(BaseFileItem.class, new BaseFileItemConverter(fileItemDao, fileItemMap));
    List<RoomFile> list = readList(serializer, f, "roomFiles.xml", "RoomFiles", RoomFile.class, true);
    for (RoomFile rf : list) {
        Room r = roomDao.get(roomMap.get(rf.getRoomId()));
        if (r == null || rf.getFile() == null || rf.getFile().getId() == null) {
            continue;
        }
        if (r.getFiles() == null) {
            r.setFiles(new ArrayList<>());
        }
        rf.setId(null);
        rf.setRoomId(r.getId());
        r.getFiles().add(rf);
        roomDao.update(r, null);
    }
}
Also used : BaseFileItemConverter(org.apache.openmeetings.backup.converter.BaseFileItemConverter) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RoomFile(org.apache.openmeetings.db.entity.room.RoomFile) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) Room(org.apache.openmeetings.db.entity.room.Room) Serializer(org.simpleframework.xml.Serializer)

Aggregations

BaseFileItemConverter (org.apache.openmeetings.backup.converter.BaseFileItemConverter)1 Room (org.apache.openmeetings.db.entity.room.Room)1 RoomFile (org.apache.openmeetings.db.entity.room.RoomFile)1 Serializer (org.simpleframework.xml.Serializer)1 Registry (org.simpleframework.xml.convert.Registry)1 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)1 Persister (org.simpleframework.xml.core.Persister)1 Strategy (org.simpleframework.xml.strategy.Strategy)1