예제 #1
0
  public void logUpdate(final Update update) {
    Element updateElement = createOrGetUpdateElement(update);

    int attempt = 1;
    try {
      attempt = Integer.parseInt(updateElement.getAttribute("attempt")) + 1;
      updates.removeChild(updateElement);
      updateElements.remove(update);

      updateElement = createOrGetUpdateElement(update);
    } catch (NumberFormatException ignored) {
    }

    updateElement.setAttribute("attempt", String.valueOf(attempt));
    updateElement.setAttribute(
        "time", FormatHelper.dateTimeToString(dateTimeProvider.getCurrentDateTime()));

    final RpslObject updatedObject = update.getSubmittedObject();
    updateElement.appendChild(keyValue("key", updatedObject.getFormattedKey()));
    updateElement.appendChild(keyValue("operation", update.getOperation().name()));
    updateElement.appendChild(
        keyValue("reason", StringUtils.join(update.getDeleteReasons(), ", ")));
    updateElement.appendChild(keyValue("paragraph", update.getParagraph().getContent()));
    updateElement.appendChild(keyValue("object", updatedObject.toString()));
  }
예제 #2
0
  @Test
  public void transform_changed() {
    when(dateTimeProvider.getCurrentDate()).thenReturn(new LocalDate(2013, 02, 25));
    final RpslObject rpslObject =
        RpslObject.parse(
            "inet6num: 2001::/16\n"
                + "changed: [email protected] 20120601\n"
                + "changed: [email protected]\n"
                + "remarks: changed");

    final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages);
    final List<RpslAttribute> changed = result.findAttributes(AttributeType.CHANGED);
    assertThat(changed.get(0).getCleanValue().toString(), is("[email protected] 20120601"));
    assertThat(changed.get(1).getCleanValue().toString(), is("[email protected] 20130225"));
    verifyZeroInteractions(objectMessages);
  }
예제 #3
0
  AuditLogger(final DateTimeProvider dateTimeProvider, final OutputStream outputStream) {
    this.dateTimeProvider = dateTimeProvider;
    this.outputStream = outputStream;

    try {
      final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
      final DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();

      doc = documentBuilder.newDocument();
      dbupdate = doc.createElement("dbupdate");
      dbupdate.setAttribute(
          "created", FormatHelper.dateTimeToString(dateTimeProvider.getCurrentDateTime()));
      doc.appendChild(dbupdate);

      messages = doc.createElement("messages");
      dbupdate.appendChild(messages);

      updates = doc.createElement("updates");
      dbupdate.appendChild(updates);
    } catch (ParserConfigurationException e) {
      throw new IllegalStateException("Creating audit logger", e);
    }
  }
 @Before
 public void setUp() throws Exception {
   now = new LocalDate();
   when(dateTimeProvider.getCurrentDate()).thenReturn(now);
   when(ipResourceConfiguration.getLimit(any(InetAddress.class))).thenReturn(QUERY_LIMIT);
 }
예제 #5
0
 private String getRequestId(final String remoteAddress) {
   return "syncupdate_" + remoteAddress + "_" + dateTimeProvider.getNanoTime();
 }