コード例 #1
0
    private synchronized void reTryFailedMove(PollTableEntry entry, FileObject fileObject)
        throws AxisFault {
      try {

        String moveToDirectoryURI = entry.getMoveAfterMoveFailure();
        FileObject moveToDirectory = fsManager.resolveFile(moveToDirectoryURI);
        if (!moveToDirectory.exists()) {
          moveToDirectory.createFolder();
        }
        String prefix;
        if (entry.getMoveTimestampFormat() != null) {
          prefix = entry.getMoveTimestampFormat().format(new Date());
        } else {
          prefix = "";
        }
        FileObject dest = moveToDirectory.resolveFile(prefix + fileObject.getName().getBaseName());
        if (log.isDebugEnabled()) {
          log.debug("The failed file is moving to :" + dest.getName().getURI());
        }
        try {
          fileObject.moveTo(
              dest); // FIXME - when an exception occurs here it causes the in folder to vanish
        } catch (FileSystemException e) {
          handleException(
              "Error moving the failed file : " + fileObject + " to " + moveToDirectoryURI, e);
        }
      } catch (FileSystemException e) {
        handleException("Cloud not move the failed file object '" + fileObject + "'", e);
      } catch (IOException e) {
        handleException("Cloud not create the folder", e);
      }
    }
コード例 #2
0
ファイル: Files.java プロジェクト: prasaadk/renjin
  /**
   * Creates the last element of the path, unless recursive = TRUE. Trailing path separators are
   * removed.
   *
   * @param context the current call Context
   * @param path the path
   * @param showWarnings should the warnings on failure be shown?
   * @param recursive Should elements of the path other than the last be created? If true, like
   *     Unix's mkdir -p
   * @param mode the file mode to be used on Unix-alikes: it will be coerced by as.octmode.
   *     (currently ignored by renjin)
   * @return true if the operation succeeded for each of the files attempted. Using a missing value
   *     for a path name will always be regarded as a failure. returns false if the directory
   *     already exists
   * @throws FileSystemException
   */
  @Internal("dir.create")
  public static SEXP dirCreate(
      @Current Context context, String path, boolean showWarnings, boolean recursive, int mode)
      throws FileSystemException {
    FileObject dir = context.resolveFile(path);
    dir.createFolder();

    // TODO: return correct value and implement warnings documented above

    context.setInvisibleFlag();
    return new LogicalArrayVector(true);
  }
コード例 #3
0
 private FileObject getChildFolder(
     final FileSystemManager fileSystem, final FileObject baseFolder, final String baseName)
     throws FileSystemException {
   for (int counter = 0; counter < TEMPORARY_FOLDER_ATTEMPTS; ++counter) {
     final FileObject temporaryFolder = fileSystem.resolveFile(baseFolder, baseName + counter);
     if (!temporaryFolder.exists()) {
       temporaryFolder.createFolder();
       return temporaryFolder;
     }
   }
   throw new FileSystemException(
       "Failed to create directory within "
           + TEMPORARY_FOLDER_ATTEMPTS
           + " attempts (tried "
           + baseName
           + "0 to "
           + baseName
           + (TEMPORARY_FOLDER_ATTEMPTS - 1)
           + ')');
 }