List of usage examples for org.apache.commons.vfs FileObject toString
public String toString()
From source file:org.pentaho.di.job.entries.folderscompare.JobEntryFoldersCompare.java
public Result execute(Result previousResult, int nr) { Result result = previousResult; result.setResult(false);//from www .j a va 2s . co m boolean ok = true; String realFilename1 = getRealFilename1(); String realFilename2 = getRealFilename2(); FileObject folder1 = null; FileObject folder2 = null; FileObject filefolder1 = null; FileObject filefolder2 = null; try { if (filename1 != null && filename2 != null) { // Get Folders/Files to compare folder1 = KettleVFS.getFileObject(realFilename1, this); folder2 = KettleVFS.getFileObject(realFilename2, this); if (folder1.exists() && folder2.exists()) { if (!folder1.getType().equals(folder2.getType())) { // pb...we try to compare file with folder !!! logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.CanNotCompareFilesFolders")); if (folder1.getType() == FileType.FILE) { logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.IsAFile", realFilename1)); } else if (folder1.getType() == FileType.FOLDER) { logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.IsAFolder", realFilename1)); } else { logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.IsUnknownFileType", realFilename1)); } if (folder2.getType() == FileType.FILE) { logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.IsAFile", realFilename2)); } else if (folder2.getType() == FileType.FOLDER) { logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.IsAFolder", realFilename2)); } else { logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.IsUnknownFileType", realFilename2)); } } else { if (folder1.getType() == FileType.FILE) { // simply compare 2 files .. if (equalFileContents(folder1, folder2)) { result.setResult(true); } else { result.setResult(false); } } else if (folder1.getType() == FileType.FOLDER) { // We compare 2 folders ... FileObject[] list1 = folder1.findFiles(new TextFileSelector(folder1.toString())); FileObject[] list2 = folder2.findFiles(new TextFileSelector(folder2.toString())); int lenList1 = list1.length; int lenList2 = list2.length; if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobFoldersCompare.Log.FolderContains", realFilename1, "" + lenList1)); logDetailed(BaseMessages.getString(PKG, "JobFoldersCompare.Log.FolderContains", realFilename2, "" + lenList2)); } if (lenList1 == lenList2) { HashMap<String, String> collection1 = new HashMap<String, String>(); HashMap<String, String> collection2 = new HashMap<String, String>(); for (int i = 0; i < list1.length; i++) { // Put files list1 in TreeMap collection1 collection1.put(list1[i].getName().getBaseName(), list1[i].toString()); } for (int i = 0; i < list2.length; i++) { // Put files list2 in TreeMap collection2 collection2.put(list2[i].getName().getBaseName(), list2[i].toString()); } // Let's now fetch Folder1 // and for each entry, we will search it in Folder2 // if the entry exists..we will compare file entry (file or folder?) // if the 2 entry are file (not folder), we will compare content Set<Map.Entry<String, String>> entrees = collection1.entrySet(); Iterator<Map.Entry<String, String>> iterateur = entrees.iterator(); while (iterateur.hasNext()) { Map.Entry<String, String> entree = iterateur.next(); if (!collection2.containsKey(entree.getKey())) { ok = false; if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobFoldersCompare.Log.FileCanNotBeFoundIn", entree.getKey().toString(), realFilename2)); } } else { if (log.isDebug()) { logDebug(BaseMessages.getString(PKG, "JobFoldersCompare.Log.FileIsFoundIn", entree.getKey().toString(), realFilename2)); } filefolder1 = KettleVFS.getFileObject(entree.getValue().toString(), this); filefolder2 = KettleVFS .getFileObject(collection2.get(entree.getKey()).toString(), this); if (!filefolder2.getType().equals(filefolder1.getType())) { // The file1 exist in the folder2..but they don't have the same type ok = false; if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobFoldersCompare.Log.FilesNotSameType", filefolder1.toString(), filefolder2.toString())); } if (filefolder1.getType() == FileType.FILE) { logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.IsAFile", filefolder1.toString())); } else if (filefolder1.getType() == FileType.FOLDER) { logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.IsAFolder", filefolder1.toString())); } else { logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.IsUnknownFileType", filefolder1.toString())); } if (filefolder2.getType() == FileType.FILE) { logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.IsAFile", filefolder2.toString())); } else if (filefolder2.getType() == FileType.FOLDER) { logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.IsAFolder", filefolder2.toString())); } else { logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.IsUnknownFileType", filefolder2.toString())); } } else { // Files are the same type ... if (filefolder2.getType() == FileType.FILE) { // Let's compare file size if (comparefilesize) { long filefolder1_size = filefolder1.getContent().getSize(); long filefolder2_size = filefolder2.getContent().getSize(); if (filefolder1_size != filefolder2_size) { ok = false; if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobFoldersCompare.Log.FilesNotSameSize", filefolder1.toString(), filefolder2.toString())); logDetailed(BaseMessages.getString(PKG, "JobFoldersCompare.Log.SizeFileIs", filefolder1.toString(), "" + filefolder1_size)); logDetailed(BaseMessages.getString(PKG, "JobFoldersCompare.Log.SizeFileIs", filefolder2.toString(), "" + filefolder2_size)); } } } if (ok) { // Let's compare files content.. if (comparefilecontent) { if (!equalFileContents(filefolder1, filefolder2)) { ok = false; if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobFoldersCompare.Log.FilesNotSameContent", filefolder1.toString(), filefolder2.toString())); } } } } } } } // logBasic(entree.getKey() + " - " + entree.getValue()); } result.setResult(ok); } else { // The 2 folders don't have the same files number if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobFoldersCompare.Log.FoldersDifferentFiles", realFilename1.toString(), realFilename2.toString())); } } } // else: File type unknown !! } } else { if (!folder1.exists()) { logError(BaseMessages.getString(PKG, "JobFileCompare.Log.FileNotExist", realFilename1)); } if (!folder2.exists()) { logError(BaseMessages.getString(PKG, "JobFileCompare.Log.FileNotExist", realFilename2)); } result.setResult(false); result.setNrErrors(1); } } else { logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.Need2Files")); } } catch (Exception e) { result.setResult(false); result.setNrErrors(1); logError(BaseMessages.getString(PKG, "JobFoldersCompare.Log.ErrorComparing", realFilename2, realFilename2, e.getMessage())); } finally { try { if (folder1 != null) { folder1.close(); folder1 = null; } if (folder2 != null) { folder2.close(); folder2 = null; } if (filefolder1 != null) { filefolder1.close(); filefolder1 = null; } if (filefolder2 != null) { filefolder2.close(); filefolder2 = null; } } catch (IOException e) { // Ignore errors } } return result; }
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 www. j a va 2s . com 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; }
From source file:org.pentaho.di.job.entries.movefiles.JobEntryMoveFiles.java
private boolean MoveFile(String shortfilename, FileObject sourcefilename, FileObject destinationfilename, FileObject movetofolderfolder, Job parentJob, Result result) { FileObject destinationfile = null; boolean retval = false; try {// ww w .j a v a2 s. co m if (!destinationfilename.exists()) { if (!simulate) { sourcefilename.moveTo(destinationfilename); } if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobMoveFiles.Log.FileMoved", sourcefilename.getName().toString(), destinationfilename.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfilename.toString(), result, parentJob); } updateSuccess(); retval = true; } else { if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobMoveFiles.Log.FileExists", destinationfilename.toString())); } if (iffileexists.equals("overwrite_file")) { if (!simulate) { sourcefilename.moveTo(destinationfilename); } if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobMoveFiles.Log.FileOverwrite", destinationfilename.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfilename.toString(), result, parentJob); } updateSuccess(); retval = true; } else if (iffileexists.equals("unique_name")) { String short_filename = shortfilename; // return destination short filename try { short_filename = getMoveDestinationFilename(short_filename, "ddMMyyyy_HHmmssSSS"); } catch (Exception e) { logError(BaseMessages.getString(PKG, BaseMessages.getString(PKG, "JobMoveFiles.Error.GettingFilename", short_filename)), e); return retval; } String movetofilenamefull = destinationfilename.getParent().toString() + Const.FILE_SEPARATOR + short_filename; destinationfile = KettleVFS.getFileObject(movetofilenamefull, this); if (!simulate) { sourcefilename.moveTo(destinationfile); } if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobMoveFiles.Log.FileMoved", sourcefilename.getName().toString(), destinationfile.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfile.toString(), result, parentJob); } updateSuccess(); retval = true; } else if (iffileexists.equals("delete_file")) { if (!simulate) { destinationfilename.delete(); } if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobMoveFiles.Log.FileDeleted", destinationfilename.getName().toString())); } } else if (iffileexists.equals("move_file")) { String short_filename = shortfilename; // return destination short filename try { short_filename = getMoveDestinationFilename(short_filename, null); } catch (Exception e) { logError(BaseMessages.getString(PKG, BaseMessages.getString(PKG, "JobMoveFiles.Error.GettingFilename", short_filename)), e); return retval; } String movetofilenamefull = movetofolderfolder.toString() + Const.FILE_SEPARATOR + short_filename; destinationfile = KettleVFS.getFileObject(movetofilenamefull, this); if (!destinationfile.exists()) { if (!simulate) { sourcefilename.moveTo(destinationfile); } if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobMoveFiles.Log.FileMoved", sourcefilename.getName().toString(), destinationfile.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfile.toString(), result, parentJob); } } else { if (ifmovedfileexists.equals("overwrite_file")) { if (!simulate) { sourcefilename.moveTo(destinationfile); } if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobMoveFiles.Log.FileOverwrite", destinationfile.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfile.toString(), result, parentJob); } updateSuccess(); retval = true; } else if (ifmovedfileexists.equals("unique_name")) { SimpleDateFormat daf = new SimpleDateFormat(); Date now = new Date(); daf.applyPattern("ddMMyyyy_HHmmssSSS"); String dt = daf.format(now); short_filename += "_" + dt; String destinationfilenamefull = movetofolderfolder.toString() + Const.FILE_SEPARATOR + short_filename; destinationfile = KettleVFS.getFileObject(destinationfilenamefull, this); if (!simulate) { sourcefilename.moveTo(destinationfile); } if (log.isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobMoveFiles.Log.FileMoved", destinationfile.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfile.toString(), result, parentJob); } updateSuccess(); retval = true; } else if (ifmovedfileexists.equals("fail")) { // Update Errors updateErrors(); } } } else if (iffileexists.equals("fail")) { // Update Errors updateErrors(); } } } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobMoveFiles.Error.Exception.MoveProcessError", sourcefilename.toString(), destinationfilename.toString(), e.getMessage())); updateErrors(); } finally { if (destinationfile != null) { try { destinationfile.close(); } catch (IOException ex) { /* Ignore */ } } } return retval; }
From source file:org.pentaho.di.job.entries.movefiles.JobEntryMoveFiles.java
private boolean MoveOneFile(FileObject Currentfile, FileObject sourcefilefolder, String realDestinationFilefoldername, String realWildcard, Job parentJob, Result result, FileObject movetofolderfolder) { boolean entrystatus = false; FileObject file_name = null;//from w ww . j a v a2 s .co m try { if (!Currentfile.toString().equals(sourcefilefolder.toString())) { // Pass over the Base folder itself // return destination short filename String sourceshortfilename = Currentfile.getName().getBaseName(); String shortfilename = sourceshortfilename; try { shortfilename = getDestinationFilename(sourceshortfilename); } catch (Exception e) { logError(BaseMessages.getString(PKG, BaseMessages.getString(PKG, "JobMoveFiles.Error.GettingFilename", Currentfile.getName().getBaseName(), e.toString()))); return entrystatus; } int lenCurrent = sourceshortfilename.length(); String short_filename_from_basefolder = shortfilename; if (!isDoNotKeepFolderStructure()) { short_filename_from_basefolder = Currentfile.toString() .substring(sourcefilefolder.toString().length(), Currentfile.toString().length()); } short_filename_from_basefolder = short_filename_from_basefolder.substring(0, short_filename_from_basefolder.length() - lenCurrent) + shortfilename; // Built destination filename file_name = KettleVFS.getFileObject( realDestinationFilefoldername + Const.FILE_SEPARATOR + short_filename_from_basefolder, this); if (!Currentfile.getParent().toString().equals(sourcefilefolder.toString())) { // Not in the Base Folder..Only if include sub folders if (include_subfolders) { // Folders..only if include subfolders if (Currentfile.getType() == FileType.FOLDER) { if (include_subfolders && move_empty_folders && Const.isEmpty(wildcard)) { entrystatus = MoveFile(shortfilename, Currentfile, file_name, movetofolderfolder, parentJob, result); } } else { if (GetFileWildcard(sourceshortfilename, realWildcard)) { entrystatus = MoveFile(shortfilename, Currentfile, file_name, movetofolderfolder, parentJob, result); } } } } else { // In the Base Folder... // Folders..only if include subfolders if (Currentfile.getType() == FileType.FOLDER) { if (include_subfolders && move_empty_folders && Const.isEmpty(wildcard)) { entrystatus = MoveFile(shortfilename, Currentfile, file_name, movetofolderfolder, parentJob, result); } } else { // file...Check if exists if (GetFileWildcard(sourceshortfilename, realWildcard)) { entrystatus = MoveFile(shortfilename, Currentfile, file_name, movetofolderfolder, parentJob, result); } } } } entrystatus = true; } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobMoveFiles.Log.Error", e.toString())); } finally { if (file_name != null) { try { file_name.close(); } catch (IOException ex) { /* Ignore */ } } } return entrystatus; }
From source file:org.pentaho.di.job.entries.pgpdecryptfiles.JobEntryPGPDecryptFiles.java
private boolean ProcessFileFolder(String sourcefilefoldername, String passPhrase, 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 {/* w w w . j a v a 2s. co m*/ sourcefilefolder = KettleVFS.getFileObject(realSourceFilefoldername); destinationfilefolder = KettleVFS.getFileObject(realDestinationFilefoldername); if (!Const.isEmpty(MoveToFolder)) { movetofolderfolder = KettleVFS.getFileObject(MoveToFolder); } 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 !!! logError(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Log.Forbidden"), BaseMessages.getString(PKG, "JobPGPDecryptFiles.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(sourcefilefolder.getName().getBaseName()); } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Error.GettingFilename", sourcefilefolder.getName().getBaseName(), e.toString())); return entrystatus; } // Move the file to the destination folder String destinationfilenamefull = destinationfilefolder.toString() + Const.FILE_SEPARATOR + shortfilename; FileObject destinationfile = KettleVFS.getFileObject(destinationfilenamefull); entrystatus = DecryptFile(shortfilename, sourcefilefolder, passPhrase, destinationfile, movetofolderfolder, parentJob, result); } else if (sourcefilefolder.getType().equals(FileType.FILE) && destination_is_a_file) { // Source is a file, destination is a file FileObject destinationfile = KettleVFS.getFileObject(realDestinationFilefoldername); // return destination short filename String shortfilename = destinationfile.getName().getBaseName(); try { shortfilename = getDestinationFilename(destinationfile.getName().getBaseName()); } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Error.GettingFilename", sourcefilefolder.getName().getBaseName(), e.toString())); return entrystatus; } String destinationfilenamefull = destinationfilefolder.getParent().toString() + Const.FILE_SEPARATOR + shortfilename; destinationfile = KettleVFS.getFileObject(destinationfilenamefull); entrystatus = DecryptFile(shortfilename, sourcefilefolder, passPhrase, destinationfile, movetofolderfolder, parentJob, result); } else { // Both source and destination are folders if (isDetailed()) { logDetailed(" "); logDetailed(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Log.FetchFolder", sourcefilefolder.toString())); } 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; } } catch (Exception ex) { // Upon error don't process the file. return false; } finally { if (fileObject != null) { try { fileObject.close(); fileObject = null; } 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, "JobPGPDecryptFiles.Error.SuccessConditionbroken", "" + NrErrors)); successConditionBrokenExit = true; } return false; } // Fetch files in list one after one ... Currentfile = fileObjects[j]; if (!DecryptOneFile(Currentfile, sourcefilefolder, passPhrase, realDestinationFilefoldername, realWildcard, parentJob, result, movetofolderfolder)) { // Update Errors updateErrors(); } } } } } entrystatus = true; } else { // Destination Folder or Parent folder is missing logError(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Error.DestinationFolderNotFound", realDestinationFilefoldername)); } } else { logError(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Error.SourceFileNotExists", realSourceFilefoldername)); } } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Error.Exception.MoveProcess", realSourceFilefoldername.toString(), destinationfilefolder.toString(), e.getMessage())); // Update Errors updateErrors(); } 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; }
From source file:org.pentaho.di.job.entries.pgpdecryptfiles.JobEntryPGPDecryptFiles.java
private boolean DecryptFile(String shortfilename, FileObject sourcefilename, String passPharse, FileObject destinationfilename, FileObject movetofolderfolder, Job parentJob, Result result) { FileObject destinationfile = null; boolean retval = false; try {/* w ww .j a v a2 s . c o m*/ if (!destinationfilename.exists()) { gpg.decryptFile(sourcefilename, passPharse, destinationfilename); if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Log.FileDecrypted", sourcefilename.getName().toString(), destinationfilename.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfilename.toString(), result, parentJob); } updateSuccess(); } else { if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Log.FileExists", destinationfilename.toString())); } if (iffileexists.equals("overwrite_file")) { gpg.decryptFile(sourcefilename, passPharse, destinationfilename); if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Log.FileOverwrite", destinationfilename.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfilename.toString(), result, parentJob); } updateSuccess(); } else if (iffileexists.equals("unique_name")) { String short_filename = shortfilename; // return destination short filename try { short_filename = getMoveDestinationFilename(short_filename, "ddMMyyyy_HHmmssSSS"); } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Error.GettingFilename", short_filename), e); return retval; } String movetofilenamefull = destinationfilename.getParent().toString() + Const.FILE_SEPARATOR + short_filename; destinationfile = KettleVFS.getFileObject(movetofilenamefull); gpg.decryptFile(sourcefilename, passPharse, destinationfile); if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Log.FileDecrypted", sourcefilename.getName().toString(), destinationfile.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfile.toString(), result, parentJob); } updateSuccess(); } else if (iffileexists.equals("delete_file")) { destinationfilename.delete(); if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Log.FileDeleted", destinationfilename.getName().toString())); } } else if (iffileexists.equals("move_file")) { String short_filename = shortfilename; // return destination short filename try { short_filename = getMoveDestinationFilename(short_filename, null); } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Error.GettingFilename", short_filename), e); return retval; } String movetofilenamefull = movetofolderfolder.toString() + Const.FILE_SEPARATOR + short_filename; destinationfile = KettleVFS.getFileObject(movetofilenamefull); if (!destinationfile.exists()) { sourcefilename.moveTo(destinationfile); if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Log.FileDecrypted", sourcefilename.getName().toString(), destinationfile.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfile.toString(), result, parentJob); } } else { if (ifmovedfileexists.equals("overwrite_file")) { sourcefilename.moveTo(destinationfile); if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Log.FileOverwrite", destinationfile.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfile.toString(), result, parentJob); } updateSuccess(); } else if (ifmovedfileexists.equals("unique_name")) { SimpleDateFormat daf = new SimpleDateFormat(); Date now = new Date(); daf.applyPattern("ddMMyyyy_HHmmssSSS"); String dt = daf.format(now); short_filename += "_" + dt; String destinationfilenamefull = movetofolderfolder.toString() + Const.FILE_SEPARATOR + short_filename; destinationfile = KettleVFS.getFileObject(destinationfilenamefull); sourcefilename.moveTo(destinationfile); if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Log.FileDecrypted", destinationfile.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfile.toString(), result, parentJob); } updateSuccess(); } else if (ifmovedfileexists.equals("fail")) { // Update Errors updateErrors(); } } } else if (iffileexists.equals("fail")) { // Update Errors updateErrors(); } } } catch (Exception e) { updateErrors(); logError(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Error.Exception.MoveProcessError", sourcefilename.toString(), destinationfilename.toString(), e.getMessage())); } finally { if (destinationfile != null) { try { destinationfile.close(); } catch (IOException ex) { /* Ignore */ } } } return retval; }
From source file:org.pentaho.di.job.entries.pgpdecryptfiles.JobEntryPGPDecryptFiles.java
private boolean DecryptOneFile(FileObject Currentfile, FileObject sourcefilefolder, String passPhrase, String realDestinationFilefoldername, String realWildcard, Job parentJob, Result result, FileObject movetofolderfolder) { boolean entrystatus = false; FileObject file_name = null;//from ww w .j a v a2 s.c o m try { if (!Currentfile.toString().equals(sourcefilefolder.toString())) { // Pass over the Base folder itself // return destination short filename String sourceshortfilename = Currentfile.getName().getBaseName(); String shortfilename = sourceshortfilename; try { shortfilename = getDestinationFilename(sourceshortfilename); } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Error.GettingFilename", Currentfile.getName().getBaseName(), e.toString())); return entrystatus; } int lenCurrent = sourceshortfilename.length(); String short_filename_from_basefolder = shortfilename; if (!isDoNotKeepFolderStructure()) { short_filename_from_basefolder = Currentfile.toString() .substring(sourcefilefolder.toString().length(), Currentfile.toString().length()); } short_filename_from_basefolder = short_filename_from_basefolder.substring(0, short_filename_from_basefolder.length() - lenCurrent) + shortfilename; // Built destination filename file_name = KettleVFS.getFileObject( realDestinationFilefoldername + Const.FILE_SEPARATOR + short_filename_from_basefolder); if (!Currentfile.getParent().toString().equals(sourcefilefolder.toString())) { // Not in the Base Folder..Only if include sub folders if (include_subfolders) { // Folders..only if include subfolders if (Currentfile.getType() != FileType.FOLDER) { if (GetFileWildcard(sourceshortfilename, realWildcard)) { entrystatus = DecryptFile(shortfilename, Currentfile, passPhrase, file_name, movetofolderfolder, parentJob, result); } } } } else { // In the Base Folder... // Folders..only if include subfolders if (Currentfile.getType() != FileType.FOLDER) { // file...Check if exists if (GetFileWildcard(sourceshortfilename, realWildcard)) { entrystatus = DecryptFile(shortfilename, Currentfile, passPhrase, file_name, movetofolderfolder, parentJob, result); } } } } entrystatus = true; } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobPGPDecryptFiles.Log.Error", e.toString())); } finally { if (file_name != null) { try { file_name.close(); } catch (IOException ex) { /* Ignore */ } } } return entrystatus; }
From source file:org.pentaho.di.job.entries.pgpencryptfiles.JobEntryPGPEncryptFiles.java
private boolean ProcessFileFolder(int actionType, String sourcefilefoldername, String userID, 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 realuserID = environmentSubstitute(userID); String realDestinationFilefoldername = environmentSubstitute(destinationfilefoldername); String realWildcard = environmentSubstitute(wildcard); try {/*from w w w .j a v a 2 s . co m*/ sourcefilefolder = KettleVFS.getFileObject(realSourceFilefoldername); destinationfilefolder = KettleVFS.getFileObject(realDestinationFilefoldername); if (!Const.isEmpty(MoveToFolder)) { movetofolderfolder = KettleVFS.getFileObject(MoveToFolder); } 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 !!! logError(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Log.Forbidden"), BaseMessages.getString(PKG, "JobPGPEncryptFiles.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(sourcefilefolder.getName().getBaseName()); } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Error.GettingFilename", sourcefilefolder.getName().getBaseName(), e.toString())); return entrystatus; } // Move the file to the destination folder String destinationfilenamefull = destinationfilefolder.toString() + Const.FILE_SEPARATOR + shortfilename; FileObject destinationfile = KettleVFS.getFileObject(destinationfilenamefull); entrystatus = EncryptFile(actionType, shortfilename, sourcefilefolder, realuserID, destinationfile, movetofolderfolder, parentJob, result); } else if (sourcefilefolder.getType().equals(FileType.FILE) && destination_is_a_file) { // Source is a file, destination is a file FileObject destinationfile = KettleVFS.getFileObject(realDestinationFilefoldername); // return destination short filename String shortfilename = destinationfile.getName().getBaseName(); try { shortfilename = getDestinationFilename(destinationfile.getName().getBaseName()); } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Error.GettingFilename", sourcefilefolder.getName().getBaseName(), e.toString())); return entrystatus; } String destinationfilenamefull = destinationfilefolder.getParent().toString() + Const.FILE_SEPARATOR + shortfilename; destinationfile = KettleVFS.getFileObject(destinationfilenamefull); entrystatus = EncryptFile(actionType, shortfilename, sourcefilefolder, realuserID, destinationfile, movetofolderfolder, parentJob, result); } else { // Both source and destination are folders if (isDetailed()) { logDetailed(" "); logDetailed(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Log.FetchFolder", sourcefilefolder.toString())); } 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; } } catch (Exception ex) { // Upon error don't process the file. return false; } finally { if (fileObject != null) { try { fileObject.close(); fileObject = null; } 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, "JobPGPEncryptFiles.Error.SuccessConditionbroken", "" + NrErrors)); successConditionBrokenExit = true; } return false; } // Fetch files in list one after one ... Currentfile = fileObjects[j]; if (!EncryptOneFile(actionType, Currentfile, sourcefilefolder, realuserID, realDestinationFilefoldername, realWildcard, parentJob, result, movetofolderfolder)) { // Update Errors updateErrors(); } } } } } entrystatus = true; } else { // Destination Folder or Parent folder is missing logError(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Error.DestinationFolderNotFound", realDestinationFilefoldername)); } } else { logError(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Error.SourceFileNotExists", realSourceFilefoldername)); } } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Error.Exception.MoveProcess", realSourceFilefoldername.toString(), destinationfilefolder.toString(), e.getMessage())); // Update Errors updateErrors(); } 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; }
From source file:org.pentaho.di.job.entries.pgpencryptfiles.JobEntryPGPEncryptFiles.java
private boolean EncryptFile(int actionType, String shortfilename, FileObject sourcefilename, String userID, FileObject destinationfilename, FileObject movetofolderfolder, Job parentJob, Result result) { FileObject destinationfile = null; boolean retval = false; try {/*from w w w. java 2 s . c o m*/ if (!destinationfilename.exists()) { doJob(actionType, sourcefilename, userID, destinationfilename); if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Log.FileEncrypted", sourcefilename.getName().toString(), destinationfilename.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfilename.toString(), result, parentJob); } updateSuccess(); } else { if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Log.FileExists", destinationfilename.toString())); } if (iffileexists.equals("overwrite_file")) { doJob(actionType, sourcefilename, userID, destinationfilename); if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Log.FileOverwrite", destinationfilename.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfilename.toString(), result, parentJob); } updateSuccess(); } else if (iffileexists.equals("unique_name")) { String short_filename = shortfilename; // return destination short filename try { short_filename = getMoveDestinationFilename(short_filename, "ddMMyyyy_HHmmssSSS"); } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Error.GettingFilename", short_filename), e); return retval; } String movetofilenamefull = destinationfilename.getParent().toString() + Const.FILE_SEPARATOR + short_filename; destinationfile = KettleVFS.getFileObject(movetofilenamefull); doJob(actionType, sourcefilename, userID, destinationfilename); if (isDetailed()) { logDetailed(toString(), BaseMessages.getString(PKG, "JobPGPEncryptFiles.Log.FileEncrypted", sourcefilename.getName().toString(), destinationfile.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfile.toString(), result, parentJob); } updateSuccess(); } else if (iffileexists.equals("delete_file")) { destinationfilename.delete(); if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Log.FileDeleted", destinationfilename.getName().toString())); } } else if (iffileexists.equals("move_file")) { String short_filename = shortfilename; // return destination short filename try { short_filename = getMoveDestinationFilename(short_filename, null); } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Error.GettingFilename", short_filename), e); return retval; } String movetofilenamefull = movetofolderfolder.toString() + Const.FILE_SEPARATOR + short_filename; destinationfile = KettleVFS.getFileObject(movetofilenamefull); if (!destinationfile.exists()) { sourcefilename.moveTo(destinationfile); if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Log.FileEncrypted", sourcefilename.getName().toString(), destinationfile.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfile.toString(), result, parentJob); } } else { if (ifmovedfileexists.equals("overwrite_file")) { sourcefilename.moveTo(destinationfile); if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Log.FileOverwrite", destinationfile.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfile.toString(), result, parentJob); } updateSuccess(); } else if (ifmovedfileexists.equals("unique_name")) { SimpleDateFormat daf = new SimpleDateFormat(); Date now = new Date(); daf.applyPattern("ddMMyyyy_HHmmssSSS"); String dt = daf.format(now); short_filename += "_" + dt; String destinationfilenamefull = movetofolderfolder.toString() + Const.FILE_SEPARATOR + short_filename; destinationfile = KettleVFS.getFileObject(destinationfilenamefull); sourcefilename.moveTo(destinationfile); if (isDetailed()) { logDetailed(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Log.FileEncrypted", destinationfile.getName().toString())); } // add filename to result filename if (add_result_filesname && !iffileexists.equals("fail") && !iffileexists.equals("do_nothing")) { addFileToResultFilenames(destinationfile.toString(), result, parentJob); } updateSuccess(); } else if (ifmovedfileexists.equals("fail")) { // Update Errors updateErrors(); } } } else if (iffileexists.equals("fail")) { // Update Errors updateErrors(); } } } catch (Exception e) { updateErrors(); logError(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Error.Exception.MoveProcessError", sourcefilename.toString(), destinationfilename.toString(), e.getMessage())); } finally { if (destinationfile != null) { try { destinationfile.close(); } catch (IOException ex) { /* Ignore */ } } } return retval; }
From source file:org.pentaho.di.job.entries.pgpencryptfiles.JobEntryPGPEncryptFiles.java
private boolean EncryptOneFile(int actionType, FileObject Currentfile, FileObject sourcefilefolder, String userID, String realDestinationFilefoldername, String realWildcard, Job parentJob, Result result, FileObject movetofolderfolder) { boolean entrystatus = false; FileObject file_name = null;/* w w w .j a v a 2 s .c o m*/ try { if (!Currentfile.toString().equals(sourcefilefolder.toString())) { // Pass over the Base folder itself // return destination short filename String sourceshortfilename = Currentfile.getName().getBaseName(); String shortfilename = sourceshortfilename; try { shortfilename = getDestinationFilename(sourceshortfilename); } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Error.GettingFilename", Currentfile.getName().getBaseName(), e.toString())); return entrystatus; } int lenCurrent = sourceshortfilename.length(); String short_filename_from_basefolder = shortfilename; if (!isDoNotKeepFolderStructure()) { short_filename_from_basefolder = Currentfile.toString() .substring(sourcefilefolder.toString().length(), Currentfile.toString().length()); } short_filename_from_basefolder = short_filename_from_basefolder.substring(0, short_filename_from_basefolder.length() - lenCurrent) + shortfilename; // Built destination filename file_name = KettleVFS.getFileObject( realDestinationFilefoldername + Const.FILE_SEPARATOR + short_filename_from_basefolder); if (!Currentfile.getParent().toString().equals(sourcefilefolder.toString())) { // Not in the Base Folder..Only if include sub folders if (include_subfolders) { // Folders..only if include subfolders if (Currentfile.getType() != FileType.FOLDER) { if (GetFileWildcard(sourceshortfilename, realWildcard)) { entrystatus = EncryptFile(actionType, shortfilename, Currentfile, userID, file_name, movetofolderfolder, parentJob, result); } } } } else { // In the Base Folder... // Folders..only if include subfolders if (Currentfile.getType() != FileType.FOLDER) { // file...Check if exists if (GetFileWildcard(sourceshortfilename, realWildcard)) { entrystatus = EncryptFile(actionType, shortfilename, Currentfile, userID, file_name, movetofolderfolder, parentJob, result); } } } } entrystatus = true; } catch (Exception e) { logError(BaseMessages.getString(PKG, "JobPGPEncryptFiles.Log.Error", e.toString())); } finally { if (file_name != null) { try { file_name.close(); } catch (IOException ex) { /* Ignore */ } } } return entrystatus; }