use of org.forgerock.openam.utils.collections.PrefixSet in project OpenAM by OpenRock.
the class CreateFedlet method extractJars.
private void extractJars(ServletContext servletCtx, String workDir) throws WorkflowException {
for (final Map.Entry<String, PrefixSet> jarFilter : jarExtracts.entrySet()) {
final String fileName = jarFilter.getKey();
final PrefixSet pkgNames = jarFilter.getValue();
if (StringUtils.isEmpty(fileName)) {
continue;
}
try (JarInputStream jarInputStream = new JarInputStream(servletCtx.getResourceAsStream(fileName));
JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream(workDir + fileName))) {
JarEntry entry = jarInputStream.getNextJarEntry();
while (entry != null) {
if (entry.getSize() != 0) {
String name = entry.getName();
if (pkgNames.containsPrefixOf(name)) {
jarOutputStream.putNextEntry(entry);
IOUtils.copyStream(jarInputStream, jarOutputStream);
}
}
entry = jarInputStream.getNextJarEntry();
}
} catch (IOException ex) {
throw new WorkflowException(ex.getMessage());
}
}
}
Aggregations