43
43
*/
44
44
public class RestoreTask extends AbstractXMLDBTask
45
45
{
46
- private Path zipFile = null ;
47
- private Path dir = null ;
48
- private DirSet dirSet = null ;
49
- private String restorePassword = null ;
50
- private boolean overwriteApps = false ;
46
+ private Path zipFile ;
47
+ private Path dir ;
48
+ private DirSet dirSet ;
49
+ private String restorePassword ;
50
+ private boolean overwriteApps ;
51
51
52
52
@ Override
53
53
public void execute () throws BuildException
@@ -61,7 +61,7 @@ public void execute() throws BuildException
61
61
}
62
62
63
63
if ( ( dir != null ) && !Files .isReadable (dir )) {
64
- final String msg = "Cannot read restore file: " + dir .toAbsolutePath (). toString () ;
64
+ final String msg = "Cannot read restore file: " + dir .toAbsolutePath ();
65
65
66
66
if ( failonerror ) {
67
67
throw ( new BuildException ( msg ) );
@@ -75,11 +75,11 @@ public void execute() throws BuildException
75
75
try {
76
76
77
77
if ( dir != null ) {
78
- log ( "Restoring from " + dir .toAbsolutePath (). toString () , Project .MSG_INFO );
78
+ log ( "Restoring from " + dir .toAbsolutePath (), Project .MSG_INFO );
79
79
final Path file = dir .resolve ("__contents__.xml" );
80
80
81
81
if ( !Files .exists (file )) {
82
- final String msg = "Could not find file " + file .toAbsolutePath (). toString () ;
82
+ final String msg = "Could not find file " + file .toAbsolutePath ();
83
83
84
84
if ( failonerror ) {
85
85
throw ( new BuildException ( msg ) );
@@ -89,7 +89,7 @@ public void execute() throws BuildException
89
89
} else {
90
90
final RestoreServiceTaskListener listener = new ConsoleRestoreServiceTaskListener ();
91
91
final Collection collection = DatabaseManager .getCollection (uri , user , password );
92
- final EXistRestoreService service = ( EXistRestoreService ) collection .getService ("RestoreService" , "1.0" );
92
+ final EXistRestoreService service = collection .getService (EXistRestoreService . class );
93
93
service .restore (file .normalize ().toAbsolutePath ().toString (), restorePassword , listener , overwriteApps );
94
94
}
95
95
@@ -104,29 +104,29 @@ public void execute() throws BuildException
104
104
final Path contentsFile = dir .resolve ("__contents__.xml" );
105
105
106
106
if ( !Files .exists (contentsFile )) {
107
- final String msg = "Did not found file " + contentsFile .toAbsolutePath (). toString () ;
107
+ final String msg = "Did not found file " + contentsFile .toAbsolutePath ();
108
108
109
109
if ( failonerror ) {
110
110
throw ( new BuildException ( msg ) );
111
111
} else {
112
112
log ( msg , Project .MSG_ERR );
113
113
}
114
114
} else {
115
- log ( "Restoring from " + contentsFile .toAbsolutePath (). toString () + " ...\n " );
115
+ log ( "Restoring from " + contentsFile .toAbsolutePath () + " ...\n " );
116
116
117
117
// TODO subdirectories as sub-collections?
118
118
final RestoreServiceTaskListener listener = new ConsoleRestoreServiceTaskListener ();
119
119
final Collection collection = DatabaseManager .getCollection (uri , user , password );
120
- final EXistRestoreService service = ( EXistRestoreService ) collection .getService ("RestoreService" , "1.0" );
120
+ final EXistRestoreService service = collection .getService (EXistRestoreService . class );
121
121
service .restore (contentsFile .normalize ().toAbsolutePath ().toString (), restorePassword , listener , overwriteApps );
122
122
}
123
123
}
124
124
125
125
} else if ( zipFile != null ) {
126
- log ( "Restoring from " + zipFile .toAbsolutePath (). toString () , Project .MSG_INFO );
126
+ log ( "Restoring from " + zipFile .toAbsolutePath (), Project .MSG_INFO );
127
127
128
128
if ( !Files .exists (zipFile )) {
129
- final String msg = "File not found: " + zipFile .toAbsolutePath (). toString () ;
129
+ final String msg = "File not found: " + zipFile .toAbsolutePath ();
130
130
131
131
if ( failonerror ) {
132
132
throw ( new BuildException ( msg ) );
@@ -136,7 +136,7 @@ public void execute() throws BuildException
136
136
} else {
137
137
final RestoreServiceTaskListener listener = new ConsoleRestoreServiceTaskListener ();
138
138
final Collection collection = DatabaseManager .getCollection (uri , user , password );
139
- final EXistRestoreService service = ( EXistRestoreService ) collection .getService ("RestoreService" , "1.0" );
139
+ final EXistRestoreService service = collection .getService (EXistRestoreService . class );
140
140
service .restore (zipFile .normalize ().toAbsolutePath ().toString (), restorePassword , listener , overwriteApps );
141
141
}
142
142
}
@@ -184,4 +184,9 @@ public void setRestorePassword(final String pass )
184
184
{
185
185
this .restorePassword = pass ;
186
186
}
187
+
188
+ public void setOverwriteApps (final boolean overwriteApps )
189
+ {
190
+ this .overwriteApps = overwriteApps ;
191
+ }
187
192
}
0 commit comments