1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package edu.internet2.middleware.grouper.changeLog.consumer;
21
22 import java.util.List;
23
24 import edu.internet2.middleware.grouper.changeLog.ChangeLogConsumerBase;
25 import edu.internet2.middleware.grouper.changeLog.ChangeLogEntry;
26 import edu.internet2.middleware.grouper.changeLog.ChangeLogLabels;
27 import edu.internet2.middleware.grouper.changeLog.ChangeLogProcessorMetadata;
28 import edu.internet2.middleware.grouper.changeLog.ChangeLogTypeBuiltin;
29 import edu.internet2.middleware.grouper.util.GrouperUtil;
30
31
32
33
34
35 public class PrintTest extends ChangeLogConsumerBase {
36
37
38
39
40 @Override
41 public long processChangeLogEntries(List<ChangeLogEntry> changeLogEntryList,
42 ChangeLogProcessorMetadata changeLogProcessorMetadata) {
43
44 long currentId = -1;
45
46
47 try {
48 for (ChangeLogEntry changeLogEntry : GrouperUtil.nonNull(changeLogEntryList)) {
49 currentId = changeLogEntry.getSequenceNumber();
50
51
52 if (changeLogEntry.equalsCategoryAndAction(ChangeLogTypeBuiltin.GROUP_ADD)) {
53
54
55 System.out.println("Group add, name: "
56 + changeLogEntry.retrieveValueForLabel(ChangeLogLabels.GROUP_ADD.name));
57 } else if (changeLogEntry.equalsCategoryAndAction(ChangeLogTypeBuiltin.GROUP_DELETE)) {
58
59
60 System.out.println("Group delete, name: "
61 + changeLogEntry.retrieveValueForLabel(ChangeLogLabels.GROUP_DELETE.name));
62 } else if (changeLogEntry.equalsCategoryAndAction(ChangeLogTypeBuiltin.GROUP_UPDATE)) {
63
64
65 System.out.println("Group update, name: "
66 + changeLogEntry.retrieveValueForLabel(ChangeLogLabels.GROUP_UPDATE.name)
67 + ", property: " + changeLogEntry.retrieveValueForLabel(ChangeLogLabels.GROUP_UPDATE.propertyChanged)
68 + ", from: '" + changeLogEntry.retrieveValueForLabel(ChangeLogLabels.GROUP_UPDATE.propertyOldValue)
69 + "', to: '" + changeLogEntry.retrieveValueForLabel(ChangeLogLabels.GROUP_UPDATE.propertyNewValue) + "'");
70 } else {
71 System.out.println("Change log entry: " + changeLogEntry.getChangeLogType().getChangeLogCategory() +
72 " -> " + changeLogEntry.getChangeLogType().getActionName() + ", " + changeLogEntry.getSequenceNumber());
73
74 }
75
76
77 }
78 } catch (Exception e) {
79 changeLogProcessorMetadata.registerProblem(e, "Error processing record", currentId);
80
81 return currentId-1;
82 }
83 if (currentId == -1) {
84 throw new RuntimeException("Couldnt process any records");
85 }
86
87 return currentId;
88 }
89
90 }