4343 */
4444public class RestoreTask extends AbstractXMLDBTask
4545{
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 ;
5151
5252 @ Override
5353 public void execute () throws BuildException
@@ -61,7 +61,7 @@ public void execute() throws BuildException
6161 }
6262
6363 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 ();
6565
6666 if ( failonerror ) {
6767 throw ( new BuildException ( msg ) );
@@ -75,11 +75,11 @@ public void execute() throws BuildException
7575 try {
7676
7777 if ( dir != null ) {
78- log ( "Restoring from " + dir .toAbsolutePath (). toString () , Project .MSG_INFO );
78+ log ( "Restoring from " + dir .toAbsolutePath (), Project .MSG_INFO );
7979 final Path file = dir .resolve ("__contents__.xml" );
8080
8181 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 ();
8383
8484 if ( failonerror ) {
8585 throw ( new BuildException ( msg ) );
@@ -89,7 +89,7 @@ public void execute() throws BuildException
8989 } else {
9090 final RestoreServiceTaskListener listener = new ConsoleRestoreServiceTaskListener ();
9191 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 );
9393 service .restore (file .normalize ().toAbsolutePath ().toString (), restorePassword , listener , overwriteApps );
9494 }
9595
@@ -104,29 +104,29 @@ public void execute() throws BuildException
104104 final Path contentsFile = dir .resolve ("__contents__.xml" );
105105
106106 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 ();
108108
109109 if ( failonerror ) {
110110 throw ( new BuildException ( msg ) );
111111 } else {
112112 log ( msg , Project .MSG_ERR );
113113 }
114114 } else {
115- log ( "Restoring from " + contentsFile .toAbsolutePath (). toString () + " ...\n " );
115+ log ( "Restoring from " + contentsFile .toAbsolutePath () + " ...\n " );
116116
117117 // TODO subdirectories as sub-collections?
118118 final RestoreServiceTaskListener listener = new ConsoleRestoreServiceTaskListener ();
119119 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 );
121121 service .restore (contentsFile .normalize ().toAbsolutePath ().toString (), restorePassword , listener , overwriteApps );
122122 }
123123 }
124124
125125 } else if ( zipFile != null ) {
126- log ( "Restoring from " + zipFile .toAbsolutePath (). toString () , Project .MSG_INFO );
126+ log ( "Restoring from " + zipFile .toAbsolutePath (), Project .MSG_INFO );
127127
128128 if ( !Files .exists (zipFile )) {
129- final String msg = "File not found: " + zipFile .toAbsolutePath (). toString () ;
129+ final String msg = "File not found: " + zipFile .toAbsolutePath ();
130130
131131 if ( failonerror ) {
132132 throw ( new BuildException ( msg ) );
@@ -136,7 +136,7 @@ public void execute() throws BuildException
136136 } else {
137137 final RestoreServiceTaskListener listener = new ConsoleRestoreServiceTaskListener ();
138138 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 );
140140 service .restore (zipFile .normalize ().toAbsolutePath ().toString (), restorePassword , listener , overwriteApps );
141141 }
142142 }
@@ -184,4 +184,9 @@ public void setRestorePassword(final String pass )
184184 {
185185 this .restorePassword = pass ;
186186 }
187+
188+ public void setOverwriteApps (final boolean overwriteApps )
189+ {
190+ this .overwriteApps = overwriteApps ;
191+ }
187192}
0 commit comments