@Test public void shouldIgnoreBadZipFile() throws Exception { assertFalse(karArtifactInstaller.canHandle(new File(badZipFile))); }
public boolean canHandle(File file) { if (file.getName().endsWith(KAR_SUFFIX)) { LOGGER.info("Found a .kar file to deploy."); return true; } else if (file.isFile() && file.getName().endsWith(ZIP_SUFFIX)) { LOGGER.debug("Found a .zip file to deploy; checking contents to see if it's a Karaf archive."); ZipFile zipFile = null; try { zipFile = new ZipFile(file); if (zipFile.getEntry("META-INF/KARAF.MF") != null) { LOGGER.info("Found a Karaf archive with .zip prefix; will deploy."); return true; } } catch (Exception e) { LOGGER.warn("Problem extracting zip file '{}'; ignoring.", file.getName(), e); } finally { try { if (zipFile != null) { zipFile.close(); } } catch (IOException e) { LOGGER.warn("Problem closing zip file '{}'; ignoring.", file.getName(), e); } } } return false; }
KarArtifactInstaller implements ArtifactInstaller { public boolean canHandle(File file) { if (file.getName().endsWith(KAR_SUFFIX)) { LOGGER.info("Found a .kar file to deploy."); return true; } else if (file.isFile() && file.getName().endsWith(ZIP_SUFFIX)) { LOGGER.debug("Found a .zip file to deploy; checking contents to see if it's a Karaf archive."); ZipFile zipFile = null; try { zipFile = new ZipFile(file); if (zipFile.getEntry("META-INF/KARAF.MF") != null) { LOGGER.info("Found a Karaf archive with .zip prefix; will deploy."); return true; } } catch (Exception e) { LOGGER.warn("Problem extracting zip file '{}'; ignoring.", file.getName(), e); } finally { try { if (zipFile != null) { zipFile.close(); } } catch (IOException e) { LOGGER.warn("Problem closing zip file '{}'; ignoring.", file.getName(), e); } } } return false; } }
KarArtifactInstaller implements ArtifactInstaller { public boolean canHandle(File file) { if (file.getName().endsWith(KAR_SUFFIX)) { LOGGER.info("Found a .kar file to deploy."); return true; } else if (file.isFile() && file.getName().endsWith(ZIP_SUFFIX)) { LOGGER.debug("Found a .zip file to deploy; checking contents to see if it's a Karaf archive."); ZipFile zipFile = null; try { zipFile = new ZipFile(file); if (zipFile.getEntry("META-INF/KARAF.MF") != null) { LOGGER.info("Found a Karaf archive with .zip prefix; will deploy."); return true; } } catch (Exception e) { LOGGER.warn("Problem extracting zip file '{}'; ignoring.", file.getName(), e); } finally { try { if (zipFile != null) { zipFile.close(); } } catch (IOException e) { LOGGER.warn("Problem closing zip file '{}'; ignoring.", file.getName(), e); } } } return false; }  }
KarArtifactInstaller implements ArtifactInstaller { public boolean canHandle(File file) { if (file.getName().endsWith(KAR_SUFFIX)) { LOGGER.info("Found a .kar file to deploy."); return true; } else if (file.isFile() && file.getName().endsWith(ZIP_SUFFIX)) { LOGGER.debug("Found a .zip file to deploy; checking contents to see if it's a Karaf archive."); ZipFile zipFile = null; try { zipFile = new ZipFile(file); if (zipFile.getEntry("META-INF/KARAF.MF") != null) { LOGGER.info("Found a Karaf archive with .zip prefix; will deploy."); return true; } } catch (Exception e) { LOGGER.warn("Problem extracting zip file '{}'; ignoring.", file.getName(), e); } finally { try { if (zipFile != null) { zipFile.close(); } } catch (IOException e) { LOGGER.warn("Problem closing zip file '{}'; ignoring.", file.getName(), e); } } } return false; }  void install(File file); void uninstall(File file); void update(File file); boolean canHandle(File file); KarService getKarService(); void setKarService(KarService karService); }
KarArtifactInstaller implements ArtifactInstaller { public boolean canHandle(File file) { if (file.getName().endsWith(KAR_SUFFIX)) { LOGGER.info("Found a .kar file to deploy."); return true; } else if (file.isFile() && file.getName().endsWith(ZIP_SUFFIX)) { LOGGER.debug("Found a .zip file to deploy; checking contents to see if it's a Karaf archive."); ZipFile zipFile = null; try { zipFile = new ZipFile(file); if (zipFile.getEntry("META-INF/KARAF.MF") != null) { LOGGER.info("Found a Karaf archive with .zip prefix; will deploy."); return true; } } catch (Exception e) { LOGGER.warn("Problem extracting zip file '{}'; ignoring.", file.getName(), e); } finally { try { if (zipFile != null) { zipFile.close(); } } catch (IOException e) { LOGGER.warn("Problem closing zip file '{}'; ignoring.", file.getName(), e); } } } return false; }  void install(File file); void uninstall(File file); void update(File file); boolean canHandle(File file); KarService getKarService(); void setKarService(KarService karService); static final String FEATURE_CLASSIFIER; }