コード例 #1
0
ファイル: logout.java プロジェクト: silverwzw/Aegis-System
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    if (req.getParameter("sid") != null) {

      Session session;
      long sid;
      try {
        sid = Long.parseLong(req.getParameter("sid"));
      } catch (NumberFormatException e) {
        Send.Error(resp, "sid parse error");
        Log.sidInvalid(req);
        return;
      }
      try {
        session = new Session(sid, req);
      } catch (SecurityException e) {
        Send.Error(resp, e);
        Log.append(sid, e);
        return;
      }
      session.abandon();
    }
    Send.Data(
        resp,
        "{\"logout\":\""
            + UserServiceFactory.getUserService().createLogoutURL("close.html")
            + "\"}");
    return;
  }
コード例 #2
0
ファイル: Util.java プロジェクト: Bobnova/Energia
 public static void exec(String[] cmd, Log log) throws ExecException {
   BufferedReader is = null;
   try {
     if (WINDOWS_OS) {
       for (int i = 0; i < cmd.length; i++) {
         cmd[i] = cmd[i].replaceAll("/", "\\\\");
       }
     }
     Process p = Runtime.getRuntime().exec(cmd);
     is = new BufferedReader(new InputStreamReader(p.getErrorStream()));
     String line;
     int errLine = -1;
     Pattern pattern = Pattern.compile(":\\d+:");
     while ((line = is.readLine()) != null) {
       log.append(line);
       Matcher matcher = pattern.matcher(line);
       if (matcher.find()) {
         errLine =
             Integer.valueOf(line.substring(matcher.start() + 1, matcher.end() - 1)).intValue();
         if (line.matches("(?i).*unrecognized escape sequence")) {
           log.append(Messages.getString("Util.use.double.backslash"));
         }
         break;
       }
     }
     is.close();
     p.waitFor();
     if (errLine != -1) {
       throw new ExecException(Messages.getString("Util.exec.failed") + ": " + cmd, errLine);
     }
     if (p.exitValue() != 0) {
       throw new ExecException(
           Messages.getString("Util.exec.failed") + "(" + p.exitValue() + "): " + cmd);
     }
   } catch (IOException e) {
     close(is);
     throw new ExecException(e);
   } catch (InterruptedException e) {
     close(is);
     throw new ExecException(e);
   }
 }
コード例 #3
0
ファイル: AbstractLogTest.java プロジェクト: jiangcc/copycat
 /**
  * Appends {@code numEntries} increasingly numbered ByteBuffer wrapped entries to the log,
  * starting at the {@code startingId}.
  */
 protected List<Long> appendEntries(int numEntries, int startingId, Compaction.Mode mode) {
   List<Integer> entryIds =
       IntStream.range(startingId, startingId + numEntries).boxed().collect(Collectors.toList());
   return entryIds
       .stream()
       .map(
           entryId -> {
             try (TestEntry entry = log.create(TestEntry.class)) {
               entry.setTerm(1).setCompactionMode(mode).setPadding(entryPadding);
               return log.append(entry);
             }
           })
       .collect(Collectors.toList());
 }
コード例 #4
0
ファイル: Util.java プロジェクト: 01org/intel-arduino-updater
 public static void exec(String[] cmd, Log log) throws ExecException {
   BufferedReader is = null;
   try {
     if (WINDOWS_OS) {
       for (int i = 0; i < cmd.length; i++) {
         cmd[i] = cmd[i].replaceAll("/", "\\\\");
       }
     }
     Process p = Runtime.getRuntime().exec(cmd);
     is = new BufferedReader(new InputStreamReader(p.getErrorStream()));
     String line;
     int errLine = -1;
     Pattern pattern = Pattern.compile(":\\d+:");
     while ((line = is.readLine()) != null) {
       log.append(line);
       Matcher matcher = pattern.matcher(line);
       if (matcher.find()) {
         errLine =
             Integer.valueOf(line.substring(matcher.start() + 1, matcher.end() - 1)).intValue();
         break;
       }
     }
     is.close();
     p.waitFor();
     if (errLine != -1) {
       StringBuffer sb = new StringBuffer(Messages.getString("Util.exec.failed"));
       AppendCommandLine(sb, cmd);
       throw new ExecException(sb.toString(), errLine);
     }
     if (p.exitValue() != 0) {
       StringBuffer sb = new StringBuffer(Messages.getString("Util.exec.failed"));
       sb.append(" (");
       sb.append(p.exitValue());
       sb.append(')');
       AppendCommandLine(sb, cmd);
       throw new ExecException(sb.toString());
     }
   } catch (IOException e) {
     close(is);
     throw new ExecException(e);
   } catch (InterruptedException e) {
     close(is);
     throw new ExecException(e);
   }
 }
コード例 #5
0
ファイル: LogTest.java プロジェクト: hongchaodeng/javazab
 void appendTxns(Log log, Zxid startZxid, int count) throws IOException {
   for (int i = 0; i < count; ++i) {
     Zxid zxid = new Zxid(startZxid.getEpoch(), startZxid.getXid() + i);
     log.append(new Transaction(zxid, ByteBuffer.wrap("txn".getBytes())));
   }
 }
コード例 #6
0
ファイル: LogTest.java プロジェクト: hongchaodeng/javazab
 /**
  * Appending a transaction with the zxid equal to previous zxid should result in a
  * RuntimeException.
  */
 @Test(expected = RuntimeException.class)
 public void testAppendSameZxid() throws Exception {
   Log log = getLog();
   log.append(new Transaction(new Zxid(0, 1), ByteBuffer.wrap("txn".getBytes())));
   log.append(new Transaction(new Zxid(0, 1), ByteBuffer.wrap("txn".getBytes())));
 }