/**
   * Download file from encyclopdia to the specified directory If document is decomposed ,multiple
   * attachments of files will be discarded as its not in viewable format.But attachments ids will
   * be shown to user.This example can be modified easily to save those attachments as different
   * files.
   *
   * @param FileName
   * @param decomposeCompoundDocument
   * @param downloadEmbedded
   * @param downloadDirectory
   * @return boolean
   */
  public String downloadFile(
      String FileName,
      boolean decomposeCompoundDocument,
      boolean downloadEmbedded,
      String downloadDirectory)
      throws Exception {
    System.out.println("Download " + FileName);
    com.actuate.schemas.DownloadFile downloadFile = new com.actuate.schemas.DownloadFile();
    downloadFile.setFileName(FileName);
    downloadFile.setDecomposeCompoundDocument(new Boolean(decomposeCompoundDocument));
    downloadFile.setDownloadEmbedded(new Boolean(downloadEmbedded));

    String downloadName = null;
    com.actuate.schemas.DownloadFileResponse downloadFileResponse = null;
    try {
      downloadFileResponse = proxy.downloadFile(downloadFile);

      String serverFilePath = downloadFileResponse.getFile().getName();
      String localFileName =
          serverFilePath.substring(serverFilePath.lastIndexOf('/') + 1, serverFilePath.length());

      if (!downloadEmbedded) {
        downloadName =
            saveNonEmbededResponse(downloadDirectory, localFileName, decomposeCompoundDocument);
      } else {
        downloadName =
            saveEmbededResponse(
                downloadDirectory, localFileName, downloadFileResponse, decomposeCompoundDocument);
      }

    } catch (SOAPException e) {
      throw AxisFault.makeFault(e);
    } catch (RemoteException e) {
      throw e;
    } catch (IOException e) {
      throw e;
    }
    return downloadName;
  }