Ejemplo n.º 1
0
  public String packLogEntries(Project project, List<LogEntry<? extends ILogable>> logs) {

    StringBuffer sb = new StringBuffer(getUUIDStringForProject(project)).append(LOGENTRIES_MESSAGE);
    StringBuffer partResult = new StringBuffer();

    log.debug("Starting to process log entries...");
    for (LogEntry<? extends ILogable> l : logs) {
      try {
        // clear partResult
        partResult.delete(0, partResult.length());

        // build serialized version of l
        partResult
            .append(BEGIN_LOGENTRY)
            .append(this.logEntrySerializer.serialize(l, project))
            .append(END_LOGENTRY);

        log.debug("Serialised log entry " + partResult.toString());
        // only if building succeeded, add the logEntry to sb
        sb.append(partResult);
        log.debug("New sb content: " + sb.toString());
      } catch (Throwable e) {
        log.warn(
            "Failed to serialize log entry: "
                + l.getLogAction().toString()
                + "("
                + l.toString()
                + ")",
            e);
      }
    }
    log.debug("Finished processing log entries! Now sending.");

    return sb.toString();
  }
Ejemplo n.º 2
0
  public List<LogEntry<? extends ILogable>> unpackLogEntries(String les) {
    log.debug("unpacking string " + les);
    List<LogEntry<? extends ILogable>> results = new ArrayList<LogEntry<? extends ILogable>>();
    String[] logentries = les.split(END_LOGENTRY + BEGIN_LOGENTRY);

    for (String l : logentries) {
      try {
        log.debug("unpacking substring " + l);
        LogEntry<? extends ILogable> logentry = this.logEntrySerializer.deserialize(l);
        log.debug("got logentry: " + logentry.toString());
        results.add(logentry);
      } catch (Throwable t) {
        log.warn("Failed to deserialize and/or save", t);
      }
    }
    return results;
  }
Ejemplo n.º 3
0
 public String requestFile(Project project, LogEntry<JakeObject> le) {
   // can't use XML characters
   return project.getProjectId() + "." + le.getUuid();
 }