Search in sources :

Example 56 with Persister

use of org.simpleframework.xml.core.Persister in project openmeetings by apache.

the class BackupExport method exportContacts.

/*
	 * ##################### User Contacts
	 */
private void exportContacts(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    Serializer serializer = new Persister(strategy);
    registry.bind(User.class, UserConverter.class);
    writeList(serializer, zos, "userContacts.xml", "usercontacts", userContactDao.get());
    progressHolder.setProgress(60);
}
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) Serializer(org.simpleframework.xml.Serializer)

Example 57 with Persister

use of org.simpleframework.xml.core.Persister in project openmeetings by apache.

the class BackupExport method exportMeetingMember.

/*
	 * ##################### Backup Meeting Members
	 */
private void exportMeetingMember(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    Serializer serializer = new Persister(strategy);
    registry.bind(User.class, UserConverter.class);
    registry.bind(Appointment.class, AppointmentConverter.class);
    writeList(serializer, zos, "meetingmembers.xml", "meetingmembers", meetingMemberDao.getMeetingMembers());
    progressHolder.setProgress(30);
}
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) Serializer(org.simpleframework.xml.Serializer)

Example 58 with Persister

use of org.simpleframework.xml.core.Persister in project openmeetings by apache.

the class BackupExport method getConfigSerializer.

private static Serializer getConfigSerializer(List<Configuration> list) throws Exception {
    Registry registry = new Registry();
    registry.bind(User.class, UserConverter.class);
    Strategy strategy = new RegistryStrategy(registry);
    Serializer serializer = new Persister(strategy);
    bindDate(registry, list);
    return serializer;
}
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) Serializer(org.simpleframework.xml.Serializer)

Example 59 with Persister

use of org.simpleframework.xml.core.Persister 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 60 with Persister

use of org.simpleframework.xml.core.Persister in project openmeetings by apache.

the class BackupExport method performExport.

public void performExport(File zip, boolean includeFiles, ProgressHolder progressHolder) throws Exception {
    if (zip.getParentFile() != null && !zip.getParentFile().exists()) {
        zip.getParentFile().mkdirs();
    }
    try (FileOutputStream fos = new FileOutputStream(zip);
        ZipOutputStream zos = new ZipOutputStream(fos)) {
        Serializer ser = new Persister();
        progressHolder.setProgress(0);
        /*
			 * ##################### Backup Groups
			 */
        writeList(ser, zos, "version.xml", "version", Arrays.asList(BackupVersion.get()));
        progressHolder.setProgress(2);
        exportGroups(zos, progressHolder);
        exportUsers(zos, progressHolder);
        exportRoom(zos, progressHolder);
        exportRoomGroup(zos, progressHolder);
        exportRoomFile(zos, progressHolder);
        exportCalendar(zos, progressHolder);
        exportAppointment(zos, progressHolder);
        exportMeetingMember(zos, progressHolder);
        exportLdap(zos, progressHolder, ser);
        exportOauth(zos, progressHolder);
        exportPrivateMsg(zos, progressHolder);
        exportPrivateMsgFolder(zos, progressHolder, ser);
        exportContacts(zos, progressHolder);
        exportFile(zos, progressHolder);
        exportRecording(zos, progressHolder);
        exportPoll(zos, progressHolder);
        exportConfig(zos, progressHolder);
        exportChat(zos, progressHolder);
        if (includeFiles) {
            // ##################### Backup Room Files
            for (File file : getUploadDir().listFiles()) {
                String fName = file.getName();
                if (file.isDirectory() && !IMPORT_DIR.equals(fName) && !BACKUP_DIR.equals(fName)) {
                    log.debug("### " + file.getName());
                    writeZipDir(BCKP_ROOM_FILES, file.getParentFile().toURI(), file, zos);
                }
            }
            // ##################### Backup Recording Files
            final File recDir = getStreamsHibernateDir();
            writeZipDir(BCKP_RECORD_FILES, recDir.toURI(), recDir, zos);
            progressHolder.setProgress(90);
            final File customCss = getCustomCss();
            if (customCss != null && customCss.exists() && customCss.isFile()) {
                writeZip(CSS_DIR, customCss.getParentFile().toURI(), customCss, zos);
            }
        }
    }
    progressHolder.setProgress(100);
    log.debug("---Done");
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) Persister(org.simpleframework.xml.core.Persister) File(java.io.File) Serializer(org.simpleframework.xml.Serializer)

Aggregations

Persister (org.simpleframework.xml.core.Persister)187 Serializer (org.simpleframework.xml.Serializer)149 StringWriter (java.io.StringWriter)74 Writer (java.io.Writer)62 Registry (org.simpleframework.xml.convert.Registry)30 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)30 Strategy (org.simpleframework.xml.strategy.Strategy)30 AnnotationStrategy (org.simpleframework.xml.convert.AnnotationStrategy)20 File (java.io.File)19 Test (org.junit.Test)14 IOException (java.io.IOException)13 Format (org.simpleframework.xml.stream.Format)11 StorageException (org.syncany.plugins.transfer.StorageException)8 Style (org.simpleframework.xml.stream.Style)7 RegistryMatcher (org.simpleframework.xml.transform.RegistryMatcher)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 SimpleDateFormat (java.text.SimpleDateFormat)5 ArrayList (java.util.ArrayList)5 CamelCaseStyle (org.simpleframework.xml.stream.CamelCaseStyle)5 ConfigTO (org.syncany.config.to.ConfigTO)5