@Override public void restoreControllerDataBundle(ActiveSpaceController controller) { String uuid = controller.getController().getUuid(); String sourceUri = resourceRepositoryServer.getResourceUri( ResourceRepositoryStorageManager.RESOURCE_CATEGORY_DATA, uuid, DATA_BUNDLE_STATIC_VERSION); sendControllerDataBundleRestoreRequest(controller, sourceUri); }
@Override public void startup() { resourceRepositoryServer.registerResourceUploadListener( ResourceRepositoryUploadChannel.DATA_BUNDLE_UPLOAD, new CopyableResourceListener() { @Override public void onUploadSuccess(String resourceId, CopyableResource resourceUpload) { handleDataBundleUploadSuccess(resourceId, resourceUpload); } }); }
/** * Handle a successful upload to the data bundle upload repository. * * @param controllerUuid the controllerUuid that was uploaded. * @param resourceUpload the actual resource that was uploaded. */ private void handleDataBundleUploadSuccess( String controllerUuid, CopyableResource resourceUpload) { OutputStream outputStream = null; try { outputStream = resourceRepositoryServer.createResourceOutputStream( ResourceRepositoryStorageManager.RESOURCE_CATEGORY_DATA, controllerUuid, DATA_BUNDLE_STATIC_VERSION); resourceUpload.copyTo(outputStream); outputStream.close(); } catch (IOException e) { throw new InteractiveSpacesException("Unable to upload bundle for " + controllerUuid, e); } finally { closeQuietly(outputStream); } }
@Override public void shutdown() { resourceRepositoryServer.removeResourceUploadListener( ResourceRepositoryUploadChannel.DATA_BUNDLE_UPLOAD); }