private AsyncCallFuture<TemplateApiResult> syncToRegionStoreAsync( TemplateInfo template, DataStore store) { AsyncCallFuture<TemplateApiResult> future = new AsyncCallFuture<TemplateApiResult>(); // no need to create entry on template_store_ref here, since entries are already created when // prepareSecondaryStorageForMigration is invoked. // But we need to set default install path so that sync can be done in the right s3 path TemplateInfo templateOnStore = _templateFactory.getTemplate(template, store); String installPath = TemplateConstants.DEFAULT_TMPLT_ROOT_DIR + "/" + TemplateConstants.DEFAULT_TMPLT_FIRST_LEVEL_DIR + template.getAccountId() + "/" + template.getId() + "/" + template.getUniqueName(); ((TemplateObject) templateOnStore).setInstallPath(installPath); TemplateOpContext<TemplateApiResult> context = new TemplateOpContext<TemplateApiResult>(null, (TemplateObject) templateOnStore, future); AsyncCallbackDispatcher<TemplateServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().syncTemplateCallBack(null, null)).setContext(context); _motionSrv.copyAsync(template, templateOnStore, caller); return future; }
private AsyncCallFuture<TemplateApiResult> copyAsync( DataObject source, TemplateInfo template, DataStore store) { AsyncCallFuture<TemplateApiResult> future = new AsyncCallFuture<TemplateApiResult>(); DataObject templateOnStore = store.create(template); templateOnStore.processEvent(Event.CreateOnlyRequested); TemplateOpContext<TemplateApiResult> context = new TemplateOpContext<TemplateApiResult>(null, (TemplateObject) templateOnStore, future); AsyncCallbackDispatcher<TemplateServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().copyTemplateCallBack(null, null)).setContext(context); _motionSrv.copyAsync(source, templateOnStore, caller); return future; }