@Test public void testGetPathFromArchive_1() throws Exception { String archiveFile = ""; String charSequence = ""; String result = FileNameUtils.getPathFromArchive(archiveFile, charSequence); assertEquals(null, result); }
public static String getPathFromArchive(String archiveFile, String charSequence) { String path = null; ONSFileType fileType = getFileType(archiveFile); if (fileType == ONSFileType.TAR_GZ) { try { GZIPInputStream gzipInputStream = null; gzipInputStream = new GZIPInputStream(new FileInputStream( archiveFile)); TarArchiveInputStream tarInput = new TarArchiveInputStream( gzipInputStream); TarArchiveEntry entry; while (null != (entry = tarInput.getNextTarEntry())) { if (entry.getName().contains(charSequence)) { path = entry.getName(); break; } } } catch (FileNotFoundException e) { LOG.error(e.getMessage(), e); } catch (IOException e) { LOG.error(e.getMessage(), e); } } else if (fileType == ONSFileType.ZIP) { ZipFile zf; try { zf = new ZipFile(archiveFile); Enumeration<? extends ZipEntry> entries = zf.entries(); String fileName; while (entries.hasMoreElements()) { fileName = entries.nextElement().getName(); if (fileName.contains(charSequence)) { path = fileName; break; } } } catch (IOException e) { LOG.error(e.getMessage(), e); } } return path; }
FileNameUtils { public static String getPathFromArchive(String archiveFile, String charSequence) { String path = null; ONSFileType fileType = getFileType(archiveFile); if (fileType == ONSFileType.TAR_GZ) { try { GZIPInputStream gzipInputStream = null; gzipInputStream = new GZIPInputStream(new FileInputStream( archiveFile)); TarArchiveInputStream tarInput = new TarArchiveInputStream( gzipInputStream); TarArchiveEntry entry; while (null != (entry = tarInput.getNextTarEntry())) { if (entry.getName().contains(charSequence)) { path = entry.getName(); break; } } } catch (FileNotFoundException e) { LOG.error(e.getMessage(), e); } catch (IOException e) { LOG.error(e.getMessage(), e); } } else if (fileType == ONSFileType.ZIP) { ZipFile zf; try { zf = new ZipFile(archiveFile); Enumeration<? extends ZipEntry> entries = zf.entries(); String fileName; while (entries.hasMoreElements()) { fileName = entries.nextElement().getName(); if (fileName.contains(charSequence)) { path = fileName; break; } } } catch (IOException e) { LOG.error(e.getMessage(), e); } } return path; } }
FileNameUtils { public static String getPathFromArchive(String archiveFile, String charSequence) { String path = null; ONSFileType fileType = getFileType(archiveFile); if (fileType == ONSFileType.TAR_GZ) { try { GZIPInputStream gzipInputStream = null; gzipInputStream = new GZIPInputStream(new FileInputStream( archiveFile)); TarArchiveInputStream tarInput = new TarArchiveInputStream( gzipInputStream); TarArchiveEntry entry; while (null != (entry = tarInput.getNextTarEntry())) { if (entry.getName().contains(charSequence)) { path = entry.getName(); break; } } } catch (FileNotFoundException e) { LOG.error(e.getMessage(), e); } catch (IOException e) { LOG.error(e.getMessage(), e); } } else if (fileType == ONSFileType.ZIP) { ZipFile zf; try { zf = new ZipFile(archiveFile); Enumeration<? extends ZipEntry> entries = zf.entries(); String fileName; while (entries.hasMoreElements()) { fileName = entries.nextElement().getName(); if (fileName.contains(charSequence)) { path = fileName; break; } } } catch (IOException e) { LOG.error(e.getMessage(), e); } } return path; }  }
FileNameUtils { public static String getPathFromArchive(String archiveFile, String charSequence) { String path = null; ONSFileType fileType = getFileType(archiveFile); if (fileType == ONSFileType.TAR_GZ) { try { GZIPInputStream gzipInputStream = null; gzipInputStream = new GZIPInputStream(new FileInputStream( archiveFile)); TarArchiveInputStream tarInput = new TarArchiveInputStream( gzipInputStream); TarArchiveEntry entry; while (null != (entry = tarInput.getNextTarEntry())) { if (entry.getName().contains(charSequence)) { path = entry.getName(); break; } } } catch (FileNotFoundException e) { LOG.error(e.getMessage(), e); } catch (IOException e) { LOG.error(e.getMessage(), e); } } else if (fileType == ONSFileType.ZIP) { ZipFile zf; try { zf = new ZipFile(archiveFile); Enumeration<? extends ZipEntry> entries = zf.entries(); String fileName; while (entries.hasMoreElements()) { fileName = entries.nextElement().getName(); if (fileName.contains(charSequence)) { path = fileName; break; } } } catch (IOException e) { LOG.error(e.getMessage(), e); } } return path; }  static String getFileExtension(String fileName); static boolean isTarGz(String componentExtension); static boolean isZip(String componentExtension); static boolean isUnsupported(String componentExtension); static String convertToValidPath(String path); static String getName(String filename); static int indexOfLastSeparator(String filename); static String getDependencyFileName(String osName,
			String componentName); static String getInstallerFilePath(String osName,
			String componentName); static String getSciprtPath(String technology, String fileName); static String getParentFolderName(String folderPath); static ONSFileType getFileType(String fileName); static String getPathFromArchive(String archiveFile,
			String charSequence); static String getExtractedDirectoryName(String archiveFile); static String getComponentEnvFilePath(String componentName); }
FileNameUtils { public static String getPathFromArchive(String archiveFile, String charSequence) { String path = null; ONSFileType fileType = getFileType(archiveFile); if (fileType == ONSFileType.TAR_GZ) { try { GZIPInputStream gzipInputStream = null; gzipInputStream = new GZIPInputStream(new FileInputStream( archiveFile)); TarArchiveInputStream tarInput = new TarArchiveInputStream( gzipInputStream); TarArchiveEntry entry; while (null != (entry = tarInput.getNextTarEntry())) { if (entry.getName().contains(charSequence)) { path = entry.getName(); break; } } } catch (FileNotFoundException e) { LOG.error(e.getMessage(), e); } catch (IOException e) { LOG.error(e.getMessage(), e); } } else if (fileType == ONSFileType.ZIP) { ZipFile zf; try { zf = new ZipFile(archiveFile); Enumeration<? extends ZipEntry> entries = zf.entries(); String fileName; while (entries.hasMoreElements()) { fileName = entries.nextElement().getName(); if (fileName.contains(charSequence)) { path = fileName; break; } } } catch (IOException e) { LOG.error(e.getMessage(), e); } } return path; }  static String getFileExtension(String fileName); static boolean isTarGz(String componentExtension); static boolean isZip(String componentExtension); static boolean isUnsupported(String componentExtension); static String convertToValidPath(String path); static String getName(String filename); static int indexOfLastSeparator(String filename); static String getDependencyFileName(String osName,
			String componentName); static String getInstallerFilePath(String osName,
			String componentName); static String getSciprtPath(String technology, String fileName); static String getParentFolderName(String folderPath); static ONSFileType getFileType(String fileName); static String getPathFromArchive(String archiveFile,
			String charSequence); static String getExtractedDirectoryName(String archiveFile); static String getComponentEnvFilePath(String componentName);  }