\r
import java.util.Arrays;\r
import java.util.List;\r
+import java.util.UUID;\r
\r
import org.apache.log4j.Logger;\r
\r
+import eu.etaxonomy.cdm.api.application.CdmApplicationController;\r
+import eu.etaxonomy.cdm.api.service.config.CacheUpdaterConfigurator;\r
import eu.etaxonomy.cdm.app.common.CdmDestinations;\r
+import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;\r
import eu.etaxonomy.cdm.database.DbSchemaValidation;\r
import eu.etaxonomy.cdm.database.ICdmDataSource;\r
+import eu.etaxonomy.cdm.io.api.application.CdmIoApplicationController;\r
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;\r
import eu.etaxonomy.cdm.io.common.ImportResult;\r
-import eu.etaxonomy.cdm.io.operation.config.CacheUpdaterConfigurator;\r
import eu.etaxonomy.cdm.model.name.TaxonName;\r
import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
\r
\r
\r
private ImportResult doInvoke(ICdmDataSource destination){\r
- ImportResult success;\r
+ ImportResult success = null;\r
\r
CacheUpdaterConfigurator config;\r
try {\r
- config = CacheUpdaterConfigurator.NewInstance(destination, classListStrings);\r
+ config = CacheUpdaterConfigurator.NewInstance(classListStrings);\r
\r
// invoke import\r
- CdmDefaultImport<CacheUpdaterConfigurator> myImport = new CdmDefaultImport<CacheUpdaterConfigurator>();\r
- success = myImport.invoke(config);\r
- String successString = success.isSuccess() ? "successful" : " with errors ";\r
+ CdmApplicationController appCtrInit = CdmIoApplicationController.NewInstance(destination, DbSchemaValidation.VALIDATE, false);\r
+ appCtrInit.authenticate("admin", "kups366+RU");\r
+ UUID monitUuid = appCtrInit.getLongRunningTasksService().monitLongRunningTask(config);\r
+ IRemotingProgressMonitor monitor = appCtrInit.getProgressMonitorService().getRemotingMonitor(monitUuid);\r
+ while(monitor != null && (!monitor.isCanceled() || !monitor.isDone() || !monitor.isFailed())) {\r
+ try {\r
+ Thread.sleep(10);\r
+ } catch (InterruptedException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ logger.info("Waiting for monitered work to start ..");\r
+ monitor = appCtrInit.getProgressMonitorService().getRemotingMonitor(monitUuid);\r
+ }\r
+ \r
+ \r
+ String successString = monitor == null || monitor.isDone() ? "successful" : " with errors ";\r
System.out.println("End updating caches for "+ destination.getDatabase() + "..." + successString);\r
return success;\r
} catch (ClassNotFoundException e) {\r