예제 #1
0
 private File getAndValidateFile(String pFile, String pWhat) throws IOException {
   File ret = new File(pFile);
   if (!ret.exists()) {
     throw new FileNotFoundException("No such " + pWhat + " " + pFile);
   }
   if (!ret.canRead()) {
     throw new IOException(
         pWhat.substring(0, 1).toUpperCase()
             + pWhat.substring(1)
             + " "
             + pFile
             + " is not readable");
   }
   return ret;
 }
예제 #2
0
 private ArrayList<HashMap<String, String>> getLogs(boolean asList) {
   Set<File> files = new DbgPacker().getItems();
   ArrayList<HashMap<String, String>> logs =
       asList ? new ArrayList<HashMap<String, String>>() : null;
   for (File f : files) {
     if (f.exists()) {
       String id = String.valueOf(parent.getResources().add(f));
       if (asList) {
         HashMap<String, String> item = new HashMap<>();
         item.put("filename", f.getName());
         item.put("id", id);
         logs.add(item);
       }
     }
   }
   return logs;
 }
예제 #3
0
 private void readCred() throws IOException {
   String cPath = (String) configuration.getCustomProperty("cred.path");
   if (StringUtils.isEmpty(cPath)) {
     return;
   }
   File f = new File(cPath);
   if (!f.exists()) {
     return;
   }
   try (BufferedReader in =
       new BufferedReader(new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8))) {
     String str;
     while ((str = in.readLine()) != null) {
       str = str.trim();
       if (StringUtils.isEmpty(str) || str.startsWith("#")) {
         continue;
       }
       String[] s = str.split("\\s*=\\s*", 2);
       if (s.length < 2) {
         continue;
       }
       if (!s[0].startsWith("web")) {
         continue;
       }
       String[] s1 = s[0].split("\\.", 2);
       String[] s2 = s[1].split(",", 2);
       if (s2.length < 2) {
         continue;
       }
       // s2[0] == usr s2[1] == pwd s1[1] == tag
       users.put(s2[0], s2[1]);
       if (s1.length > 1) {
         // there is a tag here
         tags.put(s2[0], s1[1]);
       }
     }
   }
 }