+ HighLevelCallback<DirectDiskAccessResult> directDiskAccessCallback = directDiskAccessCallbacks.remove(identifier);
+ if (directDiskAccessCallback != null) {
+ directDiskAccessCallback.getIntermediaryResult().setFailed(true);
+ directDiskAccessCallback.setDone();
+ return;
+ }
+ HighLevelProgressCallback<DownloadResult> downloadCallback = downloadCallbacks.remove(identifier);
+ if (downloadCallback != null) {
+ downloadCallback.getIntermediaryResult().setFailed(true);
+ downloadCallback.setDone();
+ return;
+ }
+ }
+ }
+
+ /**
+ * Reads the given file and returns the first line of the file.
+ *
+ * @param readFilename
+ * The name of the file to read
+ * @return The content of the file
+ */
+ private String readContent(String readFilename) {
+ FileReader fileReader = null;
+ BufferedReader bufferedFileReader = null;
+ try {
+ fileReader = new FileReader(readFilename);
+ bufferedFileReader = new BufferedReader(fileReader);
+ String content = bufferedFileReader.readLine();
+ return content;
+ } catch (IOException ioe1) {
+ /* swallow. */
+ } finally {
+ FcpUtils.close(bufferedFileReader);
+ FcpUtils.close(fileReader);
+ }
+ return null;
+ }
+
+ /**
+ * Writes the given content to the given file.
+ *
+ * @param directDiskAccessResult
+ * The DDA result
+ * @param writeFilename
+ * The name of the file to write to
+ * @param writeContent
+ * The content to write to the file
+ */
+ private void writeContent(DirectDiskAccessResult directDiskAccessResult, String writeFilename, String writeContent) {
+ if ((writeFilename == null) || (writeContent == null)) {
+ return;
+ }
+ writtenFiles.put(directDiskAccessResult, writeFilename);
+ FileWriter fileWriter = null;
+ try {
+ fileWriter = new FileWriter(writeFilename);
+ fileWriter.write(writeContent);
+ } catch (IOException ioe1) {
+ /* swallow. */
+ } finally {
+ FcpUtils.close(fileWriter);
+ }
+ }
+
+ /**
+ * Cleans up any files that written for the given result.
+ *
+ * @param directDiskAccessResult
+ * The direct disk access result
+ */
+ @SuppressWarnings("synthetic-access")
+ private void cleanFiles(DirectDiskAccessResult directDiskAccessResult) {
+ String writeFilename = writtenFiles.remove(directDiskAccessResult);
+ if (writeFilename != null) {
+ if (!new File(writeFilename).delete()) {
+ logger.warning("could not delete " + writeFilename);
+ }