示例#1
0
  /** Format a JournalEntry object and write a JournalEntry tag to the journal. */
  protected void writeJournalEntry(CreatorJournalEntry journalEntry, XMLEventWriter writer)
      throws JournalException {
    try {
      writeJournaEntryStartTag(journalEntry, writer);

      new ContextXmlWriter().writeContext(journalEntry.getContext(), writer);

      writeArguments(journalEntry.getArgumentsMap(), writer);

      putEndTag(writer, QNAME_TAG_JOURNAL_ENTRY);
      writer.flush();
    } catch (XMLStreamException e) {
      throw new JournalException(e);
    }
  }
示例#2
0
  private void writeJournaEntryStartTag(CreatorJournalEntry journalEntry, XMLEventWriter writer)
      throws XMLStreamException {
    putStartTag(writer, QNAME_TAG_JOURNAL_ENTRY);
    putAttribute(writer, QNAME_ATTR_METHOD, journalEntry.getMethodName());
    putAttribute(
        writer, QNAME_ATTR_TIMESTAMP, JournalHelper.formatDate(journalEntry.getContext().now()));

    String[] clientIpArray =
        journalEntry
            .getContext()
            .getEnvironmentValues(Constants.HTTP_REQUEST.CLIENT_IP_ADDRESS.attributeId);
    if (clientIpArray != null && clientIpArray.length > 0) {
      putAttribute(writer, QNAME_ATTR_CLIENT_IP, clientIpArray[0]);
    }

    String[] loginIdArray =
        journalEntry.getContext().getSubjectValues(Constants.SUBJECT.LOGIN_ID.uri);
    if (loginIdArray != null && loginIdArray.length > 0) {
      putAttribute(writer, QNAME_ATTR_LOGIN_ID, loginIdArray[0]);
    }
  }