Example usage for org.apache.commons.vfs FileObject getParent

List of usage examples for org.apache.commons.vfs FileObject getParent

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileObject getParent.

Prototype

public FileObject getParent() throws FileSystemException;

Source Link

Document

Returns the folder that contains this file.

Usage

From source file:org.pentaho.di.core.plugins.PartitionerPluginType.java

protected void registerXmlPlugins() throws KettlePluginException {
    for (PluginFolderInterface folder : pluginFolders) {

        if (folder.isPluginXmlFolder()) {
            List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder());
            for (FileObject file : pluginXmlFiles) {

                try {
                    Document document = XMLHandler.loadXMLFile(file);
                    Node pluginNode = XMLHandler.getSubNode(document, "partitioner-plugin");
                    if (pluginNode != null) {
                        registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()),
                                this.getClass(), false, file.getParent().getURL());
                    }/*  w w w  .j  a  v a  2 s .co  m*/
                } catch (Exception e) {
                    // We want to report this plugin.xml error, perhaps an XML typo or something like that...
                    //
                    log.logError("Error found while reading partitioning plugin.xml file: "
                            + file.getName().toString(), e);
                }
            }
        }
    }
}

From source file:org.pentaho.di.core.plugins.RepositoryPluginType.java

protected void registerXmlPlugins() throws KettlePluginException {
    for (PluginFolderInterface folder : pluginFolders) {

        if (folder.isPluginXmlFolder()) {
            List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder());
            for (FileObject file : pluginXmlFiles) {

                try {
                    Document document = XMLHandler.loadXMLFile(file);
                    Node pluginNode = XMLHandler.getSubNode(document, "plugin");

                    registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()),
                            this.getClass(), false, file.getParent().getURL());
                } catch (Exception e) {
                    // We want to report this plugin.xml error, perhaps an XML typo or something like that...
                    //
                    log.logError("Error found while reading repository plugin.xml file: "
                            + file.getName().toString(), e);
                }//from  w ww  .  ja v  a2  s . co  m
            }
        }
    }
}

From source file:org.pentaho.di.core.plugins.StepPluginType.java

protected void registerXmlPlugins() throws KettlePluginException {
    for (PluginFolderInterface folder : pluginFolders) {

        if (folder.isPluginXmlFolder()) {
            List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder());
            for (FileObject file : pluginXmlFiles) {

                try {
                    Document document = XMLHandler.loadXMLFile(file);
                    Node pluginNode = XMLHandler.getSubNode(document, "plugin");
                    if (pluginNode != null) {
                        registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()),
                                this.getClass(), false, file.getParent().getURL());
                    }/* w w w. java2 s .  co  m*/
                } catch (Exception e) {
                    // We want to report this plugin.xml error, perhaps an XML typo or something like that...
                    //
                    log.logError("Error found while reading step plugin.xml file: " + file.getName().toString(),
                            e);
                }
            }
        }
    }
}

From source file:org.pentaho.di.core.row.value.ValueMetaPluginType.java

@Override
protected void registerXmlPlugins() throws KettlePluginException {
    for (PluginFolderInterface folder : pluginFolders) {

        if (folder.isPluginXmlFolder()) {
            List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder());
            for (FileObject file : pluginXmlFiles) {

                try {
                    Document document = XMLHandler.loadXMLFile(file);
                    Node pluginNode = XMLHandler.getSubNode(document, "plugin");
                    if (pluginNode != null) {
                        registerPluginFromXmlResource(pluginNode, KettleVFS.getFilename(file.getParent()),
                                this.getClass(), false, file.getParent().getURL());
                    }//from  w w  w  .ja  v a2 s .c  o  m
                } catch (Exception e) {
                    // We want to report this plugin.xml error, perhaps an XML typo or something like that...
                    //
                    log.logError("Error found while reading step plugin.xml file: " + file.getName().toString(),
                            e);
                }
            }
        }
    }
}

From source file:org.pentaho.di.core.vfs.KettleVFS.java

public static OutputStream getOutputStream(FileObject fileObject, boolean append) throws IOException {
    FileObject parent = fileObject.getParent();
    if (parent != null) {
        if (!parent.exists()) {
            throw new IOException(BaseMessages.getString(PKG, "KettleVFS.Exception.ParentDirectoryDoesNotExist",
                    getFilename(parent)));
        }//from   w ww.  ja  va  2  s . c o  m
    }
    try {
        fileObject.createFile();
        FileContent content = fileObject.getContent();
        return content.getOutputStream(append);
    } catch (FileSystemException e) {
        // Perhaps if it's a local file, we can retry using the standard
        // File object. This is because on Windows there is a bug in VFS.
        //
        if (fileObject instanceof LocalFile) {
            try {
                String filename = getFilename(fileObject);
                return new FileOutputStream(new File(filename), append);
            } catch (Exception e2) {
                throw e; // throw the original exception: hide the retry.
            }
        } else {
            throw e;
        }
    }
}

From source file:org.pentaho.di.job.entries.copyfiles.JobEntryCopyFiles.java

private boolean ProcessFileFolder(String sourcefilefoldername, String destinationfilefoldername,
        String wildcard, Job parentJob, Result result) {
    boolean entrystatus = false;
    FileObject sourcefilefolder = null;
    FileObject destinationfilefolder = null;

    // Clear list files to remove after copy process
    // This list is also added to result files name
    list_files_remove.clear();/*from  w  ww  .  j  a v  a2 s.  co  m*/
    list_add_result.clear();

    // Get real source, destination file and wildcard
    String realSourceFilefoldername = environmentSubstitute(sourcefilefoldername);
    String realDestinationFilefoldername = environmentSubstitute(destinationfilefoldername);
    String realWildcard = environmentSubstitute(wildcard);

    try {
        sourcefilefolder = KettleVFS.getFileObject(realSourceFilefoldername, this);
        destinationfilefolder = KettleVFS.getFileObject(realDestinationFilefoldername, this);

        if (sourcefilefolder.exists()) {

            // Check if destination folder/parent folder exists !
            // If user wanted and if destination folder does not exist
            // PDI will create it
            if (CreateDestinationFolder(destinationfilefolder)) {

                // Basic Tests
                if (sourcefilefolder.getType().equals(FileType.FOLDER) && destination_is_a_file) {
                    // Source is a folder, destination is a file
                    // WARNING !!! CAN NOT COPY FOLDER TO FILE !!!

                    logError(BaseMessages.getString(PKG, "JobCopyFiles.Log.CanNotCopyFolderToFile",
                            realSourceFilefoldername, realDestinationFilefoldername));

                    NbrFail++;

                } else {

                    if (destinationfilefolder.getType().equals(FileType.FOLDER)
                            && sourcefilefolder.getType().equals(FileType.FILE)) {
                        // Source is a file, destination is a folder
                        // Copy the file to the destination folder

                        destinationfilefolder.copyFrom(sourcefilefolder.getParent(),
                                new TextOneFileSelector(sourcefilefolder.getParent().toString(),
                                        sourcefilefolder.getName().getBaseName(),
                                        destinationfilefolder.toString()));
                        if (isDetailed()) {
                            logDetailed(BaseMessages.getString(PKG, "JobCopyFiles.Log.FileCopied",
                                    sourcefilefolder.getName().toString(),
                                    destinationfilefolder.getName().toString()));
                        }

                    } else if (sourcefilefolder.getType().equals(FileType.FILE) && destination_is_a_file) {
                        // Source is a file, destination is a file

                        destinationfilefolder.copyFrom(sourcefilefolder,
                                new TextOneToOneFileSelector(destinationfilefolder));
                    } else {
                        // Both source and destination are folders
                        if (isDetailed()) {
                            logDetailed("  ");
                            logDetailed(BaseMessages.getString(PKG, "JobCopyFiles.Log.FetchFolder",
                                    sourcefilefolder.toString()));

                        }

                        TextFileSelector textFileSelector = new TextFileSelector(sourcefilefolder,
                                destinationfilefolder, realWildcard, parentJob);
                        try {
                            destinationfilefolder.copyFrom(sourcefilefolder, textFileSelector);
                        } finally {
                            textFileSelector.shutdown();
                        }
                    }

                    // Remove Files if needed
                    if (remove_source_files && !list_files_remove.isEmpty()) {
                        String sourceFilefoldername = sourcefilefolder.toString();
                        int trimPathLength = sourceFilefoldername.length() + 1;
                        FileObject removeFile;

                        for (Iterator<String> iter = list_files_remove.iterator(); iter.hasNext()
                                && !parentJob.isStopped();) {
                            String fileremoventry = iter.next();
                            removeFile = null; // re=null each iteration
                            // Try to get the file relative to the existing connection
                            if (fileremoventry.startsWith(sourceFilefoldername)) {
                                if (trimPathLength < fileremoventry.length()) {
                                    removeFile = sourcefilefolder
                                            .getChild(fileremoventry.substring(trimPathLength));
                                }
                            }

                            // Unable to retrieve file through existing connection; Get the file through a new VFS connection
                            if (removeFile == null) {
                                removeFile = KettleVFS.getFileObject(fileremoventry, this);
                            }

                            // Remove ONLY Files
                            if (removeFile.getType() == FileType.FILE) {
                                boolean deletefile = removeFile.delete();
                                logBasic(" ------ ");
                                if (!deletefile) {
                                    logError("      " + BaseMessages.getString(PKG,
                                            "JobCopyFiles.Error.Exception.CanRemoveFileFolder",
                                            fileremoventry));
                                } else {
                                    if (isDetailed()) {
                                        logDetailed("      " + BaseMessages.getString(PKG,
                                                "JobCopyFiles.Log.FileFolderRemoved", fileremoventry));
                                    }
                                }
                            }
                        }
                    }

                    // Add files to result files name
                    if (add_result_filesname && !list_add_result.isEmpty()) {
                        String destinationFilefoldername = destinationfilefolder.toString();
                        int trimPathLength = destinationFilefoldername.length() + 1;
                        FileObject addFile;

                        for (Iterator<String> iter = list_add_result.iterator(); iter.hasNext();) {
                            String fileaddentry = iter.next();
                            addFile = null; // re=null each iteration

                            // Try to get the file relative to the existing connection
                            if (fileaddentry.startsWith(destinationFilefoldername)) {
                                if (trimPathLength < fileaddentry.length()) {
                                    addFile = destinationfilefolder
                                            .getChild(fileaddentry.substring(trimPathLength));
                                }
                            }

                            // Unable to retrieve file through existing connection; Get the file through a new VFS connection
                            if (addFile == null) {
                                addFile = KettleVFS.getFileObject(fileaddentry, this);
                            }

                            // Add ONLY Files
                            if (addFile.getType() == FileType.FILE) {
                                ResultFile resultFile = new ResultFile(ResultFile.FILE_TYPE_GENERAL, addFile,
                                        parentJob.getJobname(), toString());
                                result.getResultFiles().put(resultFile.getFile().toString(), resultFile);
                                if (isDetailed()) {
                                    logDetailed(" ------ ");
                                    logDetailed("      " + BaseMessages.getString(PKG,
                                            "JobCopyFiles.Log.FileAddedToResultFilesName", fileaddentry));
                                }
                            }
                        }
                    }
                }
                entrystatus = true;
            } else {
                // Destination Folder or Parent folder is missing
                logError(BaseMessages.getString(PKG, "JobCopyFiles.Error.DestinationFolderNotFound",
                        realDestinationFilefoldername));
            }
        } else {
            logError(BaseMessages.getString(PKG, "JobCopyFiles.Error.SourceFileNotExists",
                    realSourceFilefoldername));

        }
    } catch (FileSystemException fse) {
        logError(BaseMessages.getString(PKG, "JobCopyFiles.Error.Exception.CopyProcessFileSystemException",
                fse.getMessage()));
        Throwable throwable = fse.getCause();
        while (throwable != null) {
            logError(BaseMessages.getString(PKG, "JobCopyFiles.Log.CausedBy", throwable.getMessage()));
            throwable = throwable.getCause();
        }
    } catch (Exception e) {
        logError(BaseMessages.getString(PKG, "JobCopyFiles.Error.Exception.CopyProcess",
                realSourceFilefoldername, realDestinationFilefoldername, e.getMessage()), e);
    } finally {
        if (sourcefilefolder != null) {
            try {
                sourcefilefolder.close();
                sourcefilefolder = null;
            } catch (IOException ex) { /* Ignore */
            }
        }
        if (destinationfilefolder != null) {
            try {
                destinationfilefolder.close();
                destinationfilefolder = null;
            } catch (IOException ex) { /* Ignore */
            }
        }
    }

    return entrystatus;
}

From source file:org.pentaho.di.job.entries.copyfiles.JobEntryCopyFiles.java

private boolean CreateDestinationFolder(FileObject filefolder) {
    FileObject folder = null;//from ww  w.  j a v  a 2  s.  co  m
    try {
        if (destination_is_a_file) {
            folder = filefolder.getParent();
        } else {
            folder = filefolder;
        }

        if (!folder.exists()) {
            if (create_destination_folder) {
                if (isDetailed()) {
                    logDetailed("Folder  " + folder.getName() + " does not exist !");
                }
                folder.createFolder();
                if (isDetailed()) {
                    logDetailed("Folder parent was created.");
                }
            } else {
                logError("Folder  " + folder.getName() + " does not exist !");
                return false;
            }
        }
        return true;
    } catch (Exception e) {
        logError("Couldn't created parent folder " + folder.getName(), e);
    } finally {
        if (folder != null) {
            try {
                folder.close();
                folder = null;
            } catch (Exception ex) { /* Ignore */
            }
        }
    }
    return false;
}

From source file:org.pentaho.di.job.entries.dostounix.JobEntryDosToUnix.java

private boolean processFileFolder(String sourcefilefoldername, String wildcard, int convertion, Job parentJob,
        Result result) {//  w w  w  .jav  a  2s .  co  m
    boolean entrystatus = false;
    FileObject sourcefilefolder = null;
    FileObject CurrentFile = null;

    // Get real source file and wilcard
    String realSourceFilefoldername = environmentSubstitute(sourcefilefoldername);
    if (Const.isEmpty(realSourceFilefoldername)) {
        logError(BaseMessages.getString(PKG, "JobDosToUnix.log.FileFolderEmpty", sourcefilefoldername));
        // Update Errors
        updateErrors();

        return entrystatus;
    }
    String realWildcard = environmentSubstitute(wildcard);

    try {
        sourcefilefolder = KettleVFS.getFileObject(realSourceFilefoldername);

        if (sourcefilefolder.exists()) {
            if (isDetailed()) {
                logDetailed(BaseMessages.getString(PKG, "JobDosToUnix.Log.FileExists",
                        sourcefilefolder.toString()));
            }
            if (sourcefilefolder.getType() == FileType.FILE) {
                entrystatus = convertOneFile(sourcefilefolder, convertion, result, parentJob);

            } else if (sourcefilefolder.getType() == FileType.FOLDER) {
                FileObject[] fileObjects = sourcefilefolder.findFiles(new AllFileSelector() {
                    public boolean traverseDescendents(FileSelectInfo info) {
                        return info.getDepth() == 0 || include_subfolders;
                    }

                    public boolean includeFile(FileSelectInfo info) {

                        FileObject fileObject = info.getFile();
                        try {
                            if (fileObject == null) {
                                return false;
                            }
                            if (fileObject.getType() != FileType.FILE) {
                                return false;
                            }
                        } catch (Exception ex) {
                            // Upon error don't process the file.
                            return false;
                        } finally {
                            if (fileObject != null) {
                                try {
                                    fileObject.close();
                                } catch (IOException ex) { /* Ignore */
                                }
                            }

                        }
                        return true;
                    }
                });

                if (fileObjects != null) {
                    for (int j = 0; j < fileObjects.length && !parentJob.isStopped(); j++) {
                        if (successConditionBroken) {
                            if (!successConditionBrokenExit) {
                                logError(BaseMessages.getString(PKG,
                                        "JobDosToUnix.Error.SuccessConditionbroken", "" + nrAllErrors));
                                successConditionBrokenExit = true;
                            }
                            return false;
                        }
                        // Fetch files in list one after one ...
                        CurrentFile = fileObjects[j];

                        if (!CurrentFile.getParent().toString().equals(sourcefilefolder.toString())) {
                            // Not in the Base Folder..Only if include sub folders
                            if (include_subfolders) {
                                if (GetFileWildcard(CurrentFile.toString(), realWildcard)) {
                                    convertOneFile(CurrentFile, convertion, result, parentJob);
                                }
                            }

                        } else {
                            // In the base folder
                            if (GetFileWildcard(CurrentFile.toString(), realWildcard)) {
                                convertOneFile(CurrentFile, convertion, result, parentJob);
                            }
                        }
                    }
                }
            } else {
                logError(BaseMessages.getString(PKG, "JobDosToUnix.Error.UnknowFileFormat",
                        sourcefilefolder.toString()));
                // Update Errors
                updateErrors();
            }
        } else {
            logError(BaseMessages.getString(PKG, "JobDosToUnix.Error.SourceFileNotExists",
                    realSourceFilefoldername));
            // Update Errors
            updateErrors();
        }
    } catch (Exception e) {
        logError(BaseMessages.getString(PKG, "JobDosToUnix.Error.Exception.Processing",
                realSourceFilefoldername.toString(), e.getMessage()));
        // Update Errors
        updateErrors();
    } finally {
        if (sourcefilefolder != null) {
            try {
                sourcefilefolder.close();
            } catch (IOException ex) {
                /* Ignore */
            }

        }
        if (CurrentFile != null) {
            try {
                CurrentFile.close();
            } catch (IOException ex) { /* Ignore */
            }
        }
    }
    return entrystatus;
}

From source file:org.pentaho.di.job.entries.evalfilesmetrics.JobEntryEvalFilesMetrics.java

private void ProcessFileFolder(String sourcefilefoldername, String wildcard, String includeSubfolders,
        Job parentJob, Result result) {

    FileObject sourcefilefolder = null;
    FileObject CurrentFile = null;

    // Get real source file and wildcard
    String realSourceFilefoldername = environmentSubstitute(sourcefilefoldername);
    if (Const.isEmpty(realSourceFilefoldername)) {
        // Filename is empty!
        logError(BaseMessages.getString(PKG, "JobEvalFilesMetrics.log.FileFolderEmpty"));
        incrementErrors();//from   www.  j a  va 2 s.  c o  m
        return;
    }
    String realWildcard = environmentSubstitute(wildcard);
    final boolean include_subfolders = YES.equalsIgnoreCase(includeSubfolders);

    try {
        sourcefilefolder = KettleVFS.getFileObject(realSourceFilefoldername);

        if (sourcefilefolder.exists()) {
            // File exists
            if (isDetailed()) {
                logDetailed(BaseMessages.getString(PKG, "JobEvalFilesMetrics.Log.FileExists",
                        sourcefilefolder.toString()));
            }

            if (sourcefilefolder.getType() == FileType.FILE) {
                // We deals here with a file
                // let's get file size
                getFileSize(sourcefilefolder, result, parentJob);

            } else if (sourcefilefolder.getType() == FileType.FOLDER) {
                // We have a folder
                // we will fetch and extract files
                FileObject[] fileObjects = sourcefilefolder.findFiles(new AllFileSelector() {
                    public boolean traverseDescendents(FileSelectInfo info) {
                        return info.getDepth() == 0 || include_subfolders;
                    }

                    public boolean includeFile(FileSelectInfo info) {
                        FileObject fileObject = info.getFile();
                        try {
                            if (fileObject == null) {
                                return false;
                            }
                            if (fileObject.getType() != FileType.FILE) {
                                return false;
                            }
                        } catch (Exception ex) {
                            // Upon error don't process the file.
                            return false;
                        } finally {
                            if (fileObject != null) {
                                try {
                                    fileObject.close();
                                } catch (IOException ex) { /* Ignore */
                                }
                            }
                        }
                        return true;
                    }
                });

                if (fileObjects != null) {
                    for (int j = 0; j < fileObjects.length && !parentJob.isStopped(); j++) {
                        // Fetch files in list one after one ...
                        CurrentFile = fileObjects[j];

                        if (!CurrentFile.getParent().toString().equals(sourcefilefolder.toString())) {
                            // Not in the Base Folder..Only if include sub folders
                            if (include_subfolders) {
                                if (GetFileWildcard(CurrentFile.getName().getBaseName(), realWildcard)) {
                                    getFileSize(CurrentFile, result, parentJob);
                                }
                            }
                        } else {
                            // In the base folder
                            if (GetFileWildcard(CurrentFile.getName().getBaseName(), realWildcard)) {
                                getFileSize(CurrentFile, result, parentJob);
                            }
                        }
                    }
                }
            } else {
                incrementErrors();
                logError(BaseMessages.getString(PKG, "JobEvalFilesMetrics.Error.UnknowFileFormat",
                        sourcefilefolder.toString()));
            }
        } else {
            incrementErrors();
            logError(BaseMessages.getString(PKG, "JobEvalFilesMetrics.Error.SourceFileNotExists",
                    realSourceFilefoldername));
        }
    } catch (Exception e) {
        incrementErrors();
        logError(BaseMessages.getString(PKG, "JobEvalFilesMetrics.Error.Exception.Processing",
                realSourceFilefoldername.toString(), e.getMessage()));

    } finally {
        if (sourcefilefolder != null) {
            try {
                sourcefilefolder.close();
            } catch (IOException ex) { /* Ignore */
            }

        }
        if (CurrentFile != null) {
            try {
                CurrentFile.close();
            } catch (IOException ex) { /* Ignore */
            }
        }
    }
}

From source file:org.pentaho.di.job.entries.movefiles.JobEntryMoveFiles.java

private boolean ProcessFileFolder(String sourcefilefoldername, String destinationfilefoldername,
        String wildcard, Job parentJob, Result result, String MoveToFolder) {
    boolean entrystatus = false;
    FileObject sourcefilefolder = null;
    FileObject destinationfilefolder = null;
    FileObject movetofolderfolder = null;
    FileObject Currentfile = null;

    // Get real source, destination file and wildcard
    String realSourceFilefoldername = environmentSubstitute(sourcefilefoldername);
    String realDestinationFilefoldername = environmentSubstitute(destinationfilefoldername);
    String realWildcard = environmentSubstitute(wildcard);

    try {//from  w w w.  java  2 s  . c  om
        sourcefilefolder = KettleVFS.getFileObject(realSourceFilefoldername, this);
        destinationfilefolder = KettleVFS.getFileObject(realDestinationFilefoldername, this);
        if (!Const.isEmpty(MoveToFolder)) {
            movetofolderfolder = KettleVFS.getFileObject(MoveToFolder, this);
        }

        if (sourcefilefolder.exists()) {

            // Check if destination folder/parent folder exists !
            // If user wanted and if destination folder does not exist
            // PDI will create it
            if (CreateDestinationFolder(destinationfilefolder)) {

                // Basic Tests
                if (sourcefilefolder.getType().equals(FileType.FOLDER) && destination_is_a_file) {
                    // Source is a folder, destination is a file
                    // WARNING !!! CAN NOT MOVE FOLDER TO FILE !!!

                    log.logError(BaseMessages.getString(PKG, "JobMoveFiles.Log.Forbidden"),
                            BaseMessages.getString(PKG, "JobMoveFiles.Log.CanNotMoveFolderToFile",
                                    realSourceFilefoldername, realDestinationFilefoldername));

                    // Update Errors
                    updateErrors();
                } else {
                    if (destinationfilefolder.getType().equals(FileType.FOLDER)
                            && sourcefilefolder.getType().equals(FileType.FILE)) {
                        // Source is a file, destination is a folder
                        // return destination short filename
                        String shortfilename = sourcefilefolder.getName().getBaseName();

                        try {
                            shortfilename = getDestinationFilename(shortfilename);
                        } catch (Exception e) {
                            logError(BaseMessages.getString(PKG,
                                    BaseMessages.getString(PKG, "JobMoveFiles.Error.GettingFilename",
                                            sourcefilefolder.getName().getBaseName(), e.toString())));
                            return entrystatus;
                        }
                        // Move the file to the destination folder

                        String destinationfilenamefull = KettleVFS.getFilename(destinationfilefolder)
                                + Const.FILE_SEPARATOR + shortfilename;
                        FileObject destinationfile = KettleVFS.getFileObject(destinationfilenamefull, this);

                        entrystatus = MoveFile(shortfilename, sourcefilefolder, destinationfile,
                                movetofolderfolder, parentJob, result);
                        return entrystatus;
                    } else if (sourcefilefolder.getType().equals(FileType.FILE) && destination_is_a_file) {
                        // Source is a file, destination is a file

                        FileObject destinationfile = KettleVFS.getFileObject(realDestinationFilefoldername,
                                this);

                        // return destination short filename
                        String shortfilename = destinationfile.getName().getBaseName();
                        try {
                            shortfilename = getDestinationFilename(shortfilename);
                        } catch (Exception e) {
                            logError(BaseMessages.getString(PKG,
                                    BaseMessages.getString(PKG, "JobMoveFiles.Error.GettingFilename",
                                            sourcefilefolder.getName().getBaseName(), e.toString())));
                            return entrystatus;
                        }

                        String destinationfilenamefull = KettleVFS.getFilename(destinationfile.getParent())
                                + Const.FILE_SEPARATOR + shortfilename;
                        destinationfile = KettleVFS.getFileObject(destinationfilenamefull, this);

                        entrystatus = MoveFile(shortfilename, sourcefilefolder, destinationfile,
                                movetofolderfolder, parentJob, result);
                        return entrystatus;
                    } else {
                        // Both source and destination are folders
                        if (log.isDetailed()) {
                            logDetailed("  ");
                            logDetailed(BaseMessages.getString(PKG, "JobMoveFiles.Log.FetchFolder",
                                    sourcefilefolder.toString()));
                        }

                        FileObject[] fileObjects = sourcefilefolder.findFiles(new AllFileSelector() {
                            public boolean traverseDescendents(FileSelectInfo info) {
                                return true;
                            }

                            public boolean includeFile(FileSelectInfo info) {
                                FileObject fileObject = info.getFile();
                                try {
                                    if (fileObject == null) {
                                        return false;
                                    }
                                } catch (Exception ex) {
                                    // Upon error don't process the file.
                                    return false;
                                } finally {
                                    if (fileObject != null) {
                                        try {
                                            fileObject.close();
                                        } catch (IOException ex) { /* Ignore */
                                        }
                                    }

                                }
                                return true;
                            }
                        });

                        if (fileObjects != null) {
                            for (int j = 0; j < fileObjects.length && !parentJob.isStopped(); j++) {
                                // Success condition broken?
                                if (successConditionBroken) {
                                    if (!successConditionBrokenExit) {
                                        logError(BaseMessages.getString(PKG,
                                                "JobMoveFiles.Error.SuccessConditionbroken", "" + NrErrors));
                                        successConditionBrokenExit = true;
                                    }
                                    return false;
                                }
                                // Fetch files in list one after one ...
                                Currentfile = fileObjects[j];

                                if (!MoveOneFile(Currentfile, sourcefilefolder, realDestinationFilefoldername,
                                        realWildcard, parentJob, result, movetofolderfolder)) {
                                    // Update Errors
                                    updateErrors();
                                }

                            }
                        }
                    }

                }
                entrystatus = true;
            } else {
                // Destination Folder or Parent folder is missing
                logError(BaseMessages.getString(PKG, "JobMoveFiles.Error.DestinationFolderNotFound",
                        realDestinationFilefoldername));
            }
        } else {
            logError(BaseMessages.getString(PKG, "JobMoveFiles.Error.SourceFileNotExists",
                    realSourceFilefoldername));
        }
    } catch (Exception e) {
        logError(BaseMessages.getString(PKG, "JobMoveFiles.Error.Exception.MoveProcess",
                realSourceFilefoldername.toString(), destinationfilefolder.toString(), e.getMessage()));
    } finally {
        if (sourcefilefolder != null) {
            try {
                sourcefilefolder.close();
            } catch (IOException ex) {
                /* Ignore */
            }
        }
        if (destinationfilefolder != null) {
            try {
                destinationfilefolder.close();
            } catch (IOException ex) {
                /* Ignore */
            }
        }
        if (Currentfile != null) {
            try {
                Currentfile.close();
            } catch (IOException ex) {
                /* Ignore */
            }
        }
        if (movetofolderfolder != null) {
            try {
                movetofolderfolder.close();
            } catch (IOException ex) {
                /* Ignore */
            }
        }
    }
    return entrystatus;
}