Search in sources :

Example 61 with Persister

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

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

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

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

the class BackupImport method importFiles.

/*
	 * ##################### Import File-Explorer Items
	 */
private List<FileItem> importFiles(File f) throws Exception {
    log.info("Private message import complete, starting file explorer item import");
    List<FileItem> result = new ArrayList<>();
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    RegistryMatcher matcher = new RegistryMatcher();
    Serializer ser = new Persister(strategy, matcher);
    matcher.bind(Long.class, LongTransform.class);
    matcher.bind(Integer.class, IntegerTransform.class);
    registry.bind(Date.class, DateConverter.class);
    List<FileItem> list = readList(ser, f, "fileExplorerItems.xml", "fileExplorerItems", FileItem.class);
    for (FileItem file : list) {
        Long fId = file.getId();
        // We need to reset this as openJPA reject to store them otherwise
        file.setId(null);
        Long roomId = file.getRoomId();
        file.setRoomId(roomMap.containsKey(roomId) ? roomMap.get(roomId) : null);
        if (file.getOwnerId() != null) {
            file.setOwnerId(userMap.get(file.getOwnerId()));
        }
        if (file.getParentId() != null && file.getParentId().longValue() <= 0L) {
            file.setParentId(null);
        }
        if (Strings.isEmpty(file.getHash())) {
            file.setHash(UUID.randomUUID().toString());
        }
        file = fileItemDao.update(file);
        result.add(file);
        fileItemMap.put(fId, file.getId());
    }
    return result;
}
Also used : FileItem(org.apache.openmeetings.db.entity.file.FileItem) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) ArrayList(java.util.ArrayList) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) RegistryMatcher(org.simpleframework.xml.transform.RegistryMatcher) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 65 with Persister

use of org.simpleframework.xml.core.Persister in project netxms by netxms.

the class LogParser method createXml.

/**
 * Create XML from configuration.
 *
 * @return XML document
 * @throws Exception if the schema for the object is not valid
 */
public String createXml() throws Exception {
    Serializer serializer = new Persister();
    Writer writer = new StringWriter();
    serializer.write(this, writer);
    return writer.toString();
}
Also used : StringWriter(java.io.StringWriter) Persister(org.simpleframework.xml.core.Persister) StringWriter(java.io.StringWriter) Writer(java.io.Writer) 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