/* (non-Javadoc)
@see org.duracloud.snapshot.restoration.SnapshotRestorationManager#restoreCompleted(java.lang.String)
17941
@Override
    public Restoration restoreCompleted(String restorationId)
        throws SnapshotNotFoundException, SnapshotInProcessException,
        NoRestorationInProcessException, SnapshotException {

        Restoration restoration = getRestoration(restorationId);

        return restoreCompleted(restoration);

    }
889720
@Override
    @Transactional
    public Snapshot transferToStorageComplete(String snapshotId)
        throws SnapshotException {
        try {
            Snapshot snapshot = getSnapshot(snapshotId);
            snapshot = changeSnapshotStatus(snapshot, SnapshotStatus.CLEANING_UP, "");

            File snapshotDir = new File(
                ContentDirUtils.getDestinationPath(snapshot.getName(),
                                                   BridgeConfiguration.getContentRootDir()));

            File zipFile = zipMetadata(snapshotId, snapshotDir);

            DuracloudEndPointConfig source = snapshot.getSource();

            ContentStore store = getContentStore(source);

            ensureMetadataSpaceExists(store);

            String zipChecksum = createChecksumGenerator().generateChecksum(zipFile);

            try {
                new Retrier(4, 1000, 2).execute(new Retriable() {
                    public Object retry() throws Exception {
                        try (FileInputStream zipStream = new FileInputStream(zipFile)) {
                            return store.addContent(Constants.SNAPSHOT_METADATA_SPACE,
                                                    zipFile.getName(),
                                                    zipStream,
                                                    zipFile.length(),
                                                    "application/zip",
                                                    zipChecksum,
                                                    null);
                        }
                    }
                });
            } catch (Exception ex) {
                log.error("failed to upload snapshot zip ("
                          + zipFile.getAbsolutePath() + ") to duracloud: " + ex.getMessage(), ex);
                throw new Exception(ex);
            } finally {
                zipFile.delete();
            }

            FileUtils.deleteDirectory(snapshotDir);

            String spaceId = source.getSpaceId();
            // Call DuraCloud to clean up snapshot
            getSnapshotTaskClient(source).cleanupSnapshot(spaceId);
            log.info("successfully initiated snapshot cleanup on DuraCloud for snapshotId = "
                     + snapshotId + "; spaceId = " + spaceId);

            return snapshot;
        } catch (Exception e) {
            String message = "failed to initiate snapshot clean up: " + e.getMessage();
            log.error(message, e);
            throw new SnapshotManagerException(e.getMessage());
        }
    }
916541
public synchronized void restore(File persistFile, List<File> contentDirs) {
        try {
            FileInputStream fileStream = new FileInputStream(persistFile);
            ObjectInputStream oStream = new ObjectInputStream(fileStream);
            log.info("Restoring changed list from backup: {}", persistFile.getAbsolutePath());
            synchronized (this) {
                LinkedHashMap<String, ChangedFile> fileListFromDisk =
                    (LinkedHashMap<String, ChangedFile>) oStream.readObject();

                //remove files in change list that are not in the content dir list.
                if (contentDirs != null && !contentDirs.isEmpty()) {

                    Iterator<Entry<String, ChangedFile>> entries =
                        fileListFromDisk.entrySet().iterator();
                    while (entries.hasNext()) {
                        Entry<String, ChangedFile> entry = entries.next();
                        ChangedFile file = entry.getValue();
                        boolean watched = false;
                        for (File contentDir : contentDirs) {
                            if (file.getFile()
                                    .getAbsolutePath()
                                    .startsWith(contentDir.getAbsolutePath()) &&
                                !this.fileExclusionManager.isExcluded(file.getFile())) {
                                watched = true;
                                break;
                            }
                        }

                        if (!watched) {
                            entries.remove();
                        }
                    }
                }

                this.fileList = fileListFromDisk;
            }
            oStream.close();
        } catch (Exception e) {
            throw new RuntimeException("Unable to restore File Changed List:" +
                                       e.getMessage(), e);
        }
    }
294070
@Override
    public void recover() {
        try {
            this.messages.clear();
            this.dataLogger.prepareForRead();
            this.dataLogger.recover(this);
        } catch (Exception e) {
            throw new DelegatedRuntimeException(e);
        }
    }
347798
@Override
    public void afterCompletion(int status) {
        if (status == Status.STATUS_COMMITTED)
            controller.notifyOfTaskAssignment(partitionId, taskId, expectedExecTime, binaryFlags, txTimeout);
    }
483276
private void requestRestore(MemberId primary) {
    context.protocol().restore(primary, RestoreRequest.request(context.descriptor(), context.currentTerm()))
        .whenCompleteAsync((response, error) -> {
          if (error == null && response.status() == PrimaryBackupResponse.Status.OK) {
            context.resetIndex(response.index(), response.timestamp());

            Buffer buffer = HeapBuffer.wrap(response.data());
            int sessions = buffer.readInt();
            for (int i = 0; i < sessions; i++) {
              context.getOrCreateSession(buffer.readLong(), MemberId.from(buffer.readString()));
            }

            context.service().restore(new DefaultBackupInput(buffer, context.service().serializer()));
            operations.clear();
          }
        }, context.threadContext());
  }
43946
private void restoreData() {
		Map<String, ?> map = preferenceUtils.getAll();
		Set<String> strings = map.keySet();

		for (String string : strings) {
			if (string.startsWith(SharedPreferenceUtils.keyTestMode)) {
				preferenceUtils.restoreKey(string);
			}
		}

		refreshKeyValues();

	}
691690
@Override
    public Restoration getBySnapshotId(String snapshotId)
        throws RestorationNotFoundException {
        List<Restoration> restorations = this.restoreRepo.findBySnapshotNameOrderByModifiedDesc(snapshotId);
        if (CollectionUtils.isEmpty(restorations)) {
            log.debug("Restoration returned null for snapshot id {}. Throwing exception...",
                      snapshotId);
            throw new RestorationNotFoundException(
                "No restorations associated with snapshot " + snapshotId);
        }

        return restorations.get(0);
    }
592530
public boolean isCompleted() {
    WorkingState state = getWorkingState();
    return state == WorkingState.SUCCESSFUL || state == WorkingState.COMMITTED || state == WorkingState.FAILED;
  }
175526
function restoreAndFinish() {
    traceLog.push('<finishHiding.restoreAndFinish>', '_id:' + props._id, 'state:' + STATE_TEXT[props.state]); // [DEBUG/]
    props.timerRestoreAndFinish = null;
    props.state = STATE_HIDDEN;
    traceLog.push('state:' + STATE_TEXT[props.state]); // [DEBUG/]
    traceLog.push('focusListener:ADD'); // [DEBUG/]
    props.elmTargetBody.addEventListener('focus', props.focusListener, true);
    restoreScroll(props);
    props.savedElementsScroll = null;

    if (props.options.onHide) {
      props.options.onHide.call(props.ins);
    }
    traceLog.push('_id:' + props._id, '</finishHiding.restoreAndFinish>'); // [DEBUG/]
  }
581977
public function restore() 
    {
        $state = array_pop($this->savedStates);
        if ($state != NULL) {
            $this->transform = $state['transform'];
            $this->fillStyle = $state['fillStyle'];
        }
    }
310435
@Override
    public void restore(final List<DataSlice> dataSlices)
                    throws SevereMessageStoreException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "restore", dataSlices);

        stream = (MessageReferenceStream) getReferenceStream();
        //we can only register the listeners if we are fully initialized
        if (stream instanceof DurableSubscriptionItemStream)
        {
            if (!stream.hasInDoubtItems())
            {
                stream.registerListeners(this);
                failedInitInRestore = false; //Set to false so we don't call it again
            }
            else
            {
                //we are not yet restored due to an indoubt tran.
                //We have to mark that we failed to initialise and do
                //it later when we get a callback
                failedInitInRestore = true;
            }
        }

        // If in-doubt remove, set current active transaction for ordered messaging
        if (isRemoving())
            stream.setCurrentTransaction(this, false);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "restore");
    }
536572
private void setLastCompleted(long lastCompleted) {
    if (!log.isOpen())
      return;

    this.lastCompleted = Math.max(this.lastCompleted, lastCompleted);

    // Update the log compaction minor index.
    log.compactor().minorIndex(this.lastCompleted);

    completeSnapshot();
  }
1157941
@Override
    @Transactional
    public void finalizeRestores() {
        log.debug("Running finalize restores...");
        List<Restoration> completedRestores =
            restoreRepo.findByStatus(RestoreStatus.RESTORATION_COMPLETE);

        for (Restoration restoration : completedRestores) {
            Date expirationDate = restoration.getExpirationDate();
            if (expirationDate.before(new Date())) { // Only continue if expired
                DuracloudEndPointConfig destination = restoration.getDestination();
                ContentStore store =
                    storeClientHelper.create(destination,
                                             bridgeConfig.getDuracloudUsername(),
                                             bridgeConfig.getDuracloudPassword());
                try {
                    String spaceId = destination.getSpaceId();
                    Iterator<String> it = store.getSpaceContents(spaceId);
                    if (!it.hasNext()) { // if space is empty
                        // Call DuraCloud to remove space
                        log.info("Deleting expired restoration space: " + spaceId +
                                 " at host: " + destination.getHost());
                        store.deleteSpace(spaceId);

                        // Update restore status
                        validateAndSet(restoration,
                                       RestoreStatus.RESTORATION_EXPIRED,
                                       "Restoration expired");
                        restoration = save(restoration);
                        log.info("Transition of restore " +
                                 restoration.getRestorationId() +
                                 " to expired state completed successfully");

                        // Add history event
                        String history =
                            "[{'" + RESTORE_ACTION_TITLE + "':'" + RESTORE_ACTION_EXPIRED + "'}," +
                            "{'" + RESTORE_ID_TITLE + "':'" + restoration.getRestorationId() + "'}]";
                        snapshotManager.updateHistory(restoration.getSnapshot(), history);
                    }
                } catch (Exception e) {
                    log.error("Failed to transition restore " +
                              restoration.getRestorationId() +
                              " to expired state due to: " + e.getMessage());
                }
            }
        }
    }
50855
public void restore() {
		if (window instanceof RootPaneContainer) {
			final Component glassPane = ((RootPaneContainer) window).getGlassPane();
			glassPane.setVisible(windowGlassPaneVisible);
			glassPane.setCursor(oldWindowCursor);
		}
		if (window != null) {
			window.setCursor(oldWindowCursor);
		}
	}
754482
@Override
    public void afterCompletion(TransactionCommon transaction, boolean committed)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "afterCompletion", new Object[] { transaction, Boolean.valueOf(committed) });

        // Reset the current transaction now that this one has completed
        synchronized (orderLock)
        {
            // If asynch and a rollback occurred, unlock all messages
            // in the LME
            try
            {
                if (!committed && currentLME != null)
                    currentLME.unlockAll();
            } catch (SIResourceException e)
            {
                // FFDC
                FFDCFilter.processException(
                                            e,
                                            "com.ibm.ws.sib.processor.impl.ConsumerDispatcher.afterCompletion",
                                            "1:3673:1.280.5.25",
                                            this);

                SibTr.exception(tc, e);
                SibTr.error(tc, "ORDERED_MESSAGING_ERROR_CWSIP0117",
                            new Object[] {
                                          _baseDestHandler.getName(),
                                          _messageProcessor.getMessagingEngineName() });

            } catch (SISessionDroppedException e)
            {
                // FFDC
                FFDCFilter.processException(
                                            e,
                                            "com.ibm.ws.sib.processor.impl.ConsumerDispatcher.afterCompletion",
                                            "1:3689:1.280.5.25",
                                            this);

                SibTr.exception(tc, e);
                SibTr.error(tc, "ORDERED_MESSAGING_ERROR_CWSIP0117",
                            new Object[] {
                                          _baseDestHandler.getName(),
                                          _messageProcessor.getMessagingEngineName() });

            } catch (SIMPMessageNotLockedException e)
            {
                // No FFDC code needed
                // This exception has occurred beause someone has deleted the
                // message(s). Ignore this exception as it is unlocked anyway
            }

            currentTran = null;
            currentLME = null;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "afterCompletion");
    }
248113
public CompletableFuture<RestoreResponse> restore(RestoreRequest request) {
    ComposableFuture<RestoreResponse> future = new ComposableFuture<>();
    threadContext.execute(() -> {
      role.restore(request).whenComplete(future);
    });
    return future;
  }