gluu
公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.gluu.credmanager.core.ResourceExtractor クラス
org.gluu.credmanager.core.ResourceExtractor 連携図
Collaboration graph

公開メンバ関数

void createDirectory (Path sourcePath, Path destinationPath) throws IOException
 
void createDirectory (JarInputStream inStream, String pattern, Path destinationPath) throws IOException
 
void removeDestinationDirectory (Path destPath) throws IOException
 

非公開メンバ関数

void recursiveCopy (Path source, Path target) throws IOException
 
void recursiveDelete (Path start) throws IOException
 
void prepareDirectory (Path destinationPath) throws IOException
 

非公開変数類

Logger logger
 

詳解

著者
jgomer

関数詳解

◆ createDirectory() [1/2]

void org.gluu.credmanager.core.ResourceExtractor.createDirectory ( Path  sourcePath,
Path  destinationPath 
) throws IOException
inline
96  {
97  prepareDirectory(destinationPath);
98  recursiveCopy(sourcePath, destinationPath);
99  }
void prepareDirectory(Path destinationPath)
Definition: ResourceExtractor.java:86
void recursiveCopy(Path source, Path target)
Definition: ResourceExtractor.java:35

◆ createDirectory() [2/2]

void org.gluu.credmanager.core.ResourceExtractor.createDirectory ( JarInputStream  inStream,
String  pattern,
Path  destinationPath 
) throws IOException
inline
101  {
102 
103  String destination = destinationPath.toString();
104  prepareDirectory(destinationPath);
105 
106  JarEntry entry = inStream.getNextJarEntry();
107  for (; entry != null; entry = inStream.getNextJarEntry()) {
108 
109  if (entry.getName().startsWith(pattern)) {
110 
111  String entryName = entry.getName();
112  logger.trace("Extracting {}", entryName);
113  Path path = Paths.get(destination, entryName.substring(pattern.length()).split("/"));
114 
115  if (entry.isDirectory()) {
116  path.toFile().mkdirs();
117  } else {
118  try (OutputStream outStream = new BufferedOutputStream(new FileOutputStream(path.toString()))) {
119 
120  byte[] buffer = new byte[4096];
121 
122  int read = inStream.read(buffer, 0, buffer.length);
123  while (read > 0) {
124  outStream.write(buffer, 0, read);
125  read = inStream.read(buffer, 0, buffer.length);
126  }
127  }
128  }
129  }
130  }
131 
132  }
Logger logger
Definition: ResourceExtractor.java:33
void prepareDirectory(Path destinationPath)
Definition: ResourceExtractor.java:86

◆ prepareDirectory()

void org.gluu.credmanager.core.ResourceExtractor.prepareDirectory ( Path  destinationPath) throws IOException
inlineprivate
86  {
87 
88  //Flush destination path if already exists
89  if (Files.isDirectory(destinationPath)) {
90  recursiveDelete(destinationPath);
91  }
92  Files.createDirectory(destinationPath);
93 
94  }
void recursiveDelete(Path start)
Definition: ResourceExtractor.java:62

◆ recursiveCopy()

void org.gluu.credmanager.core.ResourceExtractor.recursiveCopy ( Path  source,
Path  target 
) throws IOException
inlineprivate
35  {
36 
37  Files.walkFileTree(source, new SimpleFileVisitor<Path>() {
38 
39  @Override
40  public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
41 
42  logger.trace("Copying directory {}", dir.toString());
43  Path targetdir = target.resolve(source.relativize(dir));
44 
45  Files.copy(dir, targetdir, StandardCopyOption.REPLACE_EXISTING);
46  return FileVisitResult.CONTINUE;
47 
48  }
49 
50  @Override
51  public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
52 
53  logger.trace("Copying file {}", file.toString());
54  Files.copy(file, target.resolve(source.relativize(file)), StandardCopyOption.REPLACE_EXISTING);
55  return FileVisitResult.CONTINUE;
56 
57  }
58  });
59 
60  }
Logger logger
Definition: ResourceExtractor.java:33

◆ recursiveDelete()

void org.gluu.credmanager.core.ResourceExtractor.recursiveDelete ( Path  start) throws IOException
inlineprivate
62  {
63 
64  Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
65 
66  @Override
67  public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
68  Files.delete(file);
69  return FileVisitResult.CONTINUE;
70  }
71 
72  @Override
73  public FileVisitResult postVisitDirectory(Path dir, IOException e) throws IOException {
74  if (e == null) {
75  Files.delete(dir);
76  return FileVisitResult.CONTINUE;
77  } else {
78  // directory iteration failed
79  throw e;
80  }
81  }
82  });
83 
84  }

◆ removeDestinationDirectory()

void org.gluu.credmanager.core.ResourceExtractor.removeDestinationDirectory ( Path  destPath) throws IOException
inline
134  {
135  logger.debug("Removing directory {}", destPath.toString());
136  recursiveDelete(destPath);
137  }
void recursiveDelete(Path start)
Definition: ResourceExtractor.java:62
Logger logger
Definition: ResourceExtractor.java:33

メンバ詳解

◆ logger

Logger org.gluu.credmanager.core.ResourceExtractor.logger
private

このクラス詳解は次のファイルから抽出されました: