1 package com.atlassian.dbexporter;
2
3 import com.atlassian.activeobjects.spi.ImportExportException;
4 import com.atlassian.dbexporter.exporter.ExportConfiguration;
5 import com.atlassian.dbexporter.exporter.Exporter;
6 import com.atlassian.dbexporter.node.NodeCreator;
7 import com.atlassian.dbexporter.node.NodeStreamWriter;
8 import com.atlassian.dbexporter.progress.ProgressMonitor;
9
10 import java.util.List;
11
12 import static com.atlassian.dbexporter.node.NodeBackup.RootNode;
13 import static com.google.common.base.Preconditions.checkArgument;
14 import static com.google.common.base.Preconditions.checkNotNull;
15 import static com.google.common.collect.Lists.newArrayList;
16
17
18
19
20
21
22
23
24
25 public final class DbExporter {
26 private final List<Exporter> exporters;
27
28 public DbExporter(final Exporter... exporters) {
29 this(newArrayList(checkNotNull(exporters)));
30 }
31
32 public DbExporter(final List<Exporter> exporters) {
33 checkArgument(!checkNotNull(exporters).isEmpty(), "DbExporter must be created with at least one Exporter!");
34 this.exporters = exporters;
35 }
36
37
38
39
40
41
42
43
44 public void exportData(NodeStreamWriter streamWriter, ExportConfiguration configuration) {
45 final ProgressMonitor monitor = configuration.getProgressMonitor();
46 monitor.begin();
47
48 final NodeCreator node = RootNode.add(streamWriter);
49 final Context context = new Context();
50 for (Exporter exporter : exporters) {
51 exporter.export(node, configuration, context);
52 }
53
54 monitor.end();
55 }
56 }