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.audit;
21
22 import java.io.StringWriter;
23 import java.sql.Timestamp;
24 import java.text.SimpleDateFormat;
25 import java.util.Set;
26
27 import org.apache.commons.lang.StringUtils;
28 import org.apache.commons.lang.builder.EqualsBuilder;
29
30 import edu.internet2.middleware.grouper.GrouperAPI;
31 import edu.internet2.middleware.grouper.GrouperSession;
32 import edu.internet2.middleware.grouper.Member;
33 import edu.internet2.middleware.grouper.MemberFinder;
34 import edu.internet2.middleware.grouper.app.loader.GrouperLoader;
35 import edu.internet2.middleware.grouper.hibernate.GrouperContext;
36 import edu.internet2.middleware.grouper.hibernate.HibernateSession;
37 import edu.internet2.middleware.grouper.internal.dao.hib3.Hib3GrouperVersioned;
38 import edu.internet2.middleware.grouper.internal.util.GrouperUuid;
39 import edu.internet2.middleware.grouper.misc.GrouperDAOFactory;
40 import edu.internet2.middleware.grouper.misc.GrouperVersion;
41 import edu.internet2.middleware.grouper.util.GrouperUtil;
42 import edu.internet2.middleware.grouper.xml.export.XmlExportAuditEntry;
43 import edu.internet2.middleware.grouper.xml.export.XmlImportable;
44 import edu.internet2.middleware.subject.Subject;
45
46
47
48
49
50
51 @SuppressWarnings("serial")
52 public class AuditEntry extends GrouperAPI implements Hib3GrouperVersioned, XmlImportable<AuditEntry> {
53
54
55
56
57 public static final String FIELD_ACT_AS_MEMBER_ID = "actAsMemberId";
58
59
60 public static final String FIELD_AUDIT_TYPE_ID = "auditTypeId";
61
62
63 public static final String FIELD_CONTEXT_ID = "contextId";
64
65
66 public static final String FIELD_CREATED_ON_DB = "createdOnDb";
67
68
69 public static final String FIELD_DESCRIPTION = "description";
70
71
72 public static final String FIELD_DURATION_MICROSECONDS = "durationMicroseconds";
73
74
75 public static final String FIELD_ENV_NAME = "envName";
76
77
78 public static final String FIELD_GROUPER_ENGINE = "grouperEngine";
79
80
81 public static final String FIELD_GROUPER_VERSION = "grouperVersion";
82
83
84 public static final String FIELD_ID = "id";
85
86
87 public static final String FIELD_INT01 = "int01";
88
89
90 public static final String FIELD_INT02 = "int02";
91
92
93 public static final String FIELD_INT03 = "int03";
94
95
96 public static final String FIELD_INT04 = "int04";
97
98
99 public static final String FIELD_INT05 = "int05";
100
101
102 public static final String FIELD_LAST_UPDATED_DB = "lastUpdatedDb";
103
104
105 public static final String FIELD_LOGGED_IN_MEMBER_ID = "loggedInMemberId";
106
107
108 public static final String FIELD_QUERY_COUNT = "queryCount";
109
110
111 public static final String FIELD_SERVER_HOST = "serverHost";
112
113
114 public static final String FIELD_SERVER_USER_NAME = "serverUserName";
115
116
117 public static final String FIELD_STRING01 = "string01";
118
119
120 public static final String FIELD_STRING02 = "string02";
121
122
123 public static final String FIELD_STRING03 = "string03";
124
125
126 public static final String FIELD_STRING04 = "string04";
127
128
129 public static final String FIELD_STRING05 = "string05";
130
131
132 public static final String FIELD_STRING06 = "string06";
133
134
135 public static final String FIELD_STRING07 = "string07";
136
137
138 public static final String FIELD_STRING08 = "string08";
139
140
141 public static final String FIELD_USER_IP_ADDRESS = "userIpAddress";
142
143
144
145
146 private static final Set<String> TO_STRING_DEEP_FIELDS = GrouperUtil.toSet(
147 FIELD_ACT_AS_MEMBER_ID, FIELD_AUDIT_TYPE_ID, FIELD_CONTEXT_ID, FIELD_CREATED_ON_DB,
148 FIELD_DESCRIPTION, FIELD_DURATION_MICROSECONDS, FIELD_ENV_NAME, FIELD_GROUPER_ENGINE,
149 FIELD_GROUPER_VERSION, FIELD_HIBERNATE_VERSION_NUMBER, FIELD_ID, FIELD_INT01,
150 FIELD_INT02, FIELD_INT03, FIELD_INT04, FIELD_INT05,
151 FIELD_LAST_UPDATED_DB, FIELD_LOGGED_IN_MEMBER_ID, FIELD_QUERY_COUNT, FIELD_SERVER_HOST,
152 FIELD_SERVER_USER_NAME, FIELD_STRING01, FIELD_STRING02, FIELD_STRING03,
153 FIELD_STRING04, FIELD_STRING05, FIELD_STRING06, FIELD_STRING07,
154 FIELD_STRING08, FIELD_USER_IP_ADDRESS);
155
156
157
158
159
160
161 public boolean equalsDeep(AuditEntry auditEntry) {
162
163 return new EqualsBuilder().append(this.actAsMemberId, auditEntry.actAsMemberId)
164 .append(this.auditTypeId, auditEntry.auditTypeId)
165 .append(this.contextId, auditEntry.contextId)
166 .append(this.createdOnDb, auditEntry.createdOnDb)
167 .append(this.description, auditEntry.description)
168 .append(this.durationMicroseconds, auditEntry.durationMicroseconds)
169 .append(this.envName, auditEntry.envName)
170 .append(this.grouperEngine, auditEntry.grouperEngine)
171 .append(this.grouperVersion, auditEntry.grouperVersion)
172 .append(this.id, auditEntry.id)
173 .append(this.int01, auditEntry.int01)
174 .append(this.int02, auditEntry.int02)
175 .append(this.int03, auditEntry.int03)
176 .append(this.int04, auditEntry.int04)
177 .append(this.int05, auditEntry.int05)
178
179 .append(this.loggedInMemberId, auditEntry.loggedInMemberId)
180 .append(this.queryCount, auditEntry.queryCount)
181 .append(this.serverHost, auditEntry.serverHost)
182 .append(this.serverUserName, auditEntry.serverUserName)
183 .append(this.string01, auditEntry.string01)
184 .append(this.string02, auditEntry.string02)
185 .append(this.string03, auditEntry.string03)
186 .append(this.string04, auditEntry.string04)
187 .append(this.string05, auditEntry.string05)
188 .append(this.string06, auditEntry.string06)
189 .append(this.string07, auditEntry.string07)
190 .append(this.string08, auditEntry.string08)
191 .append(this.userIpAddress, auditEntry.userIpAddress)
192 .isEquals();
193
194 }
195
196
197
198
199
200
201
202
203
204
205
206
207
208 public String toString() {
209 return "Audit entry: " + StringUtils.substring(this.description, 0, 30);
210 }
211
212
213
214
215
216 public AuditType getAuditType() {
217 return AuditTypeFinder.find(this.auditTypeId, true);
218 }
219
220
221
222
223
224
225 public String toStringReport(boolean extended) {
226 StringBuilder result = new StringBuilder();
227 AuditType auditType = this.getAuditType();
228 Timestamp lastUpdated = this.getLastUpdated();
229
230 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
231 String lastUpdatedString = simpleDateFormat.format(lastUpdated);
232
233 result.append(lastUpdatedString).append(" ").append(StringUtils.rightPad(auditType.getAuditCategory(), 12))
234 .append(" - ").append(StringUtils.rightPad(auditType.getActionName(), 20))
235 .append(" (").append(StringUtils.leftPad(Long.toString(this.getDurationMicroseconds()/1000), 6))
236 .append("ms, ").append(StringUtils.leftPad(Integer.toString(this.getQueryCount()), 3)).append(" queries)\n");
237
238 GrouperSession grouperSession = GrouperSession.startRootSession(false);
239
240 if (!StringUtils.isBlank(this.loggedInMemberId)) {
241 result.append(" ").append(StringUtils.rightPad("Logged in user:", 20));
242 Member loggedInMember = MemberFinder.findByUuid(grouperSession, this.loggedInMemberId, false);
243 String loggedInMemberString = subjectToString(loggedInMember);
244 result.append(loggedInMemberString);
245
246 if (!StringUtils.isBlank(this.userIpAddress)) {
247 result.append(" (ip: ").append(this.userIpAddress).append(")");
248 }
249
250 if (!StringUtils.isBlank(this.actAsMemberId) && !StringUtils.equals(this.actAsMemberId, this.loggedInMemberId)) {
251 result.append(" (actAs: ");
252 Member actAsMember = MemberFinder.findByUuid(grouperSession, this.actAsMemberId, false);
253 String actAsMemberString = subjectToString(actAsMember);
254 result.append(actAsMemberString);
255 result.append(")");
256 }
257 result.append("\n");
258 }
259
260 if (!StringUtils.isBlank(this.description)) {
261 result.append(" ").append(StringUtils.rightPad("Description:", 20))
262 .append(StringUtils.abbreviate(this.description, 200)).append("\n");
263 }
264 result.append(" ").append(StringUtils.rightPad("Server:", 20));
265 result.append(this.grouperEngine).append(", host: ").append(this.serverHost);
266 result.append(", user: ").append(this.serverUserName);
267 result.append("\n");
268
269 if (extended) {
270
271 for (String label: auditType.labels()) {
272
273
274 String fieldName = auditType.retrieveAuditEntryFieldForLabel(label);
275 Object value = GrouperUtil.fieldValue(this, fieldName);
276 String valueString = GrouperUtil.stringValue(value);
277 if (!StringUtils.isBlank(valueString)) {
278
279 result.append(" ").append(StringUtils.rightPad(StringUtils.capitalize(label) + ":", 20)).append(value).append("\n");
280
281 }
282 }
283 }
284
285 return result.toString();
286 }
287
288
289
290
291
292
293 private static String subjectToString(Member member) {
294 StringBuilder result = new StringBuilder();
295 result.append(member.getSubjectSourceIdDb()).append(" - ").append(member.getSubjectIdDb())
296 .append(" - ");
297 try {
298 Subject subject = member.getSubject();
299 String more = subject.getAttributeValue("description");
300 if (StringUtils.isBlank(more)) {
301 more = subject.getDescription();
302 }
303 if (StringUtils.isBlank(more)) {
304 more = subject.getAttributeValue("name");
305 }
306 if (StringUtils.isBlank(more)) {
307 more = subject.getName();
308 }
309
310 if (!StringUtils.isBlank(more)) {
311 result.append(more);
312 }
313
314 } catch (Exception e) {
315 result.append(" problem with subject: " + e.getMessage());
316 }
317 return result.toString();
318 }
319
320
321
322
323 public AuditEntry() {
324 this.id = GrouperUuid.getUuid();
325
326 }
327
328
329
330
331
332 public void saveOrUpdate(boolean copyContextData) {
333 if (copyContextData) {
334 GrouperContext.assignAuditEntryFields(this);
335 }
336 if (!GrouperLoader.isDryRun()) {
337 GrouperDAOFactory.getFactory().getAuditEntry().saveOrUpdate(this);
338 }
339 }
340
341
342
343
344
345
346 public AuditEntry(AuditTypeIdentifier auditTypeIdentifier,
347 String... labelNamesAndValues) {
348
349 this.id = GrouperUuid.getUuid();
350
351 AuditType auditType = AuditTypeFinder.find(auditTypeIdentifier.getAuditCategory(),
352 auditTypeIdentifier.getActionName(), true);
353
354 this.auditTypeId = auditType.getId();
355
356 int labelNamesAndValuesLength = GrouperUtil.length(labelNamesAndValues);
357
358 if (labelNamesAndValuesLength % 2 != 0) {
359 throw new RuntimeException("labelNamesAndValuesLength must be divisible by 2: "
360 + labelNamesAndValuesLength);
361 }
362
363 for (int i=0;i<labelNamesAndValuesLength;i+=2) {
364 String label = labelNamesAndValues[i];
365 String value = labelNamesAndValues[i+1];
366
367 assignStringValue(auditType, label, value);
368 }
369 }
370
371
372
373
374
375
376 public void assignStringValue(AuditType auditType, String label, String value) {
377 if (StringUtils.equals(label, auditType.getLabelString01())) {
378 this.string01 = value;
379 } else if (StringUtils.equals(label, auditType.getLabelString02())) {
380 this.string02 = value;
381 } else if (StringUtils.equals(label, auditType.getLabelString03())) {
382 this.string03 = value;
383 } else if (StringUtils.equals(label, auditType.getLabelString04())) {
384 this.string04 = value;
385 } else if (StringUtils.equals(label, auditType.getLabelString05())) {
386 this.string05 = value;
387 } else if (StringUtils.equals(label, auditType.getLabelString06())) {
388 this.string06 = value;
389 } else if (StringUtils.equals(label, auditType.getLabelString07())) {
390 this.string07 = value;
391 } else if (StringUtils.equals(label, auditType.getLabelString08())) {
392 this.string08 = value;
393 } else {
394 throw new RuntimeException("Cant find string label: '" + label
395 + "' in audit type: " + auditType.getAuditCategory() + " - " + auditType.getActionName());
396 }
397 }
398
399
400
401
402
403
404 public void assignIntValue(AuditType auditType, String label, Long value) {
405 if (StringUtils.equals(label, auditType.getLabelInt01())) {
406 this.int01 = value;
407 } else if (StringUtils.equals(label, auditType.getLabelInt02())) {
408 this.int02 = value;
409 } else if (StringUtils.equals(label, auditType.getLabelInt03())) {
410 this.int03 = value;
411 } else if (StringUtils.equals(label, auditType.getLabelInt04())) {
412 this.int04 = value;
413 } else if (StringUtils.equals(label, auditType.getLabelInt05())) {
414 this.int05 = value;
415 throw new RuntimeException("Cant find int label: '" + label
416 + "' in audit type: " + auditType.getAuditCategory() + " - " + auditType.getActionName());
417 }
418 }
419
420
421 public static final String TABLE_GROUPER_AUDIT_ENTRY = "grouper_audit_entry";
422
423
424 private String id;
425
426
427 private String auditTypeId;
428
429
430 private String envName;
431
432
433 private String grouperEngine;
434
435
436 private String grouperVersion;
437
438
439
440
441 private String actAsMemberId;
442
443
444
445
446 private String contextId;
447
448
449
450
451 private String loggedInMemberId;
452
453
454
455
456 private String serverHost;
457
458
459
460
461 private String userIpAddress;
462
463
464
465
466 private String serverUserName;
467
468
469
470
471 private long durationMicroseconds;
472
473
474
475
476 private int queryCount;
477
478
479
480
481 private String description;
482
483
484
485
486 private String string01;
487
488
489
490
491 private String string02;
492
493
494
495
496 private String string03;
497
498
499
500
501 private String string04;
502
503
504
505
506 private String string05;
507
508
509
510
511 private String string06;
512
513
514
515
516 private String string07;
517
518
519
520
521 private String string08;
522
523
524
525
526 private Long int01;
527
528
529
530
531 private Long int02;
532
533
534
535
536 private Long int03;
537
538
539
540
541 private Long int04;
542
543
544
545
546 private Long int05;
547
548
549
550
551 private Long createdOnDb;
552
553
554
555
556 private Long lastUpdatedDb;
557
558
559
560
561
562 public String getAuditTypeId() {
563 return this.auditTypeId;
564 }
565
566
567
568
569
570 public void setAuditTypeId(String auditTypeId1) {
571 this.auditTypeId = auditTypeId1;
572 }
573
574
575
576
577
578 public String getId() {
579 return this.id;
580 }
581
582
583
584
585
586 public void setId(String id1) {
587 this.id = id1;
588 }
589
590
591
592
593
594 public String getActAsMemberId() {
595 return this.actAsMemberId;
596 }
597
598
599
600
601
602 public String getContextId() {
603 return this.contextId;
604 }
605
606
607
608
609
610 public String getLoggedInMemberId() {
611 return this.loggedInMemberId;
612 }
613
614
615
616
617
618 public String getServerHost() {
619 return this.serverHost;
620 }
621
622
623
624
625
626 public String getUserIpAddress() {
627 return this.userIpAddress;
628 }
629
630
631
632
633
634 public void setActAsMemberId(String actAsMemberUuid1) {
635 this.actAsMemberId = actAsMemberUuid1;
636 }
637
638
639
640
641
642 public void setContextId(String contextId1) {
643 this.contextId = contextId1;
644 }
645
646
647
648
649
650 public void setLoggedInMemberId(String loggedInMemberUuid) {
651 this.loggedInMemberId = loggedInMemberUuid;
652 }
653
654
655
656
657
658 public void setServerHost(String serverHost1) {
659 this.serverHost = serverHost1;
660 }
661
662
663
664
665
666 public void setUserIpAddress(String userIpAddress1) {
667 this.userIpAddress = userIpAddress1;
668 }
669
670
671
672
673
674 public String getEnvName() {
675 return this.envName;
676 }
677
678
679
680
681
682 public void setEnvName(String envLabel1) {
683 this.envName = envLabel1;
684 }
685
686
687
688
689
690 public String getGrouperEngine() {
691 return this.grouperEngine;
692 }
693
694
695
696
697
698 public void setGrouperEngine(String grouperSystem1) {
699 this.grouperEngine = grouperSystem1;
700 }
701
702
703
704
705
706 public String getString01() {
707 return this.string01;
708 }
709
710
711
712
713
714 public void setString01(String string01a) {
715 this.string01 = string01a;
716 }
717
718
719
720
721
722 public String getString02() {
723 return this.string02;
724 }
725
726
727
728
729
730 public void setString02(String string02a) {
731 this.string02 = string02a;
732 }
733
734
735
736
737
738 public String getString03() {
739 return this.string03;
740 }
741
742
743
744
745
746 public void setString03(String string03a) {
747 this.string03 = string03a;
748 }
749
750
751
752
753
754 public String getString04() {
755 return this.string04;
756 }
757
758
759
760
761
762 public void setString04(String string04a) {
763 this.string04 = string04a;
764 }
765
766
767
768
769
770 public String getString05() {
771 return this.string05;
772 }
773
774
775
776
777
778 public void setString05(String string05a) {
779 this.string05 = string05a;
780 }
781
782
783
784
785
786 public String getString06() {
787 return this.string06;
788 }
789
790
791
792
793
794 public void setString06(String string06a) {
795 this.string06 = string06a;
796 }
797
798
799
800
801
802 public String getString07() {
803 return this.string07;
804 }
805
806
807
808
809
810 public void setString07(String string07a) {
811 this.string07 = string07a;
812 }
813
814
815
816
817
818 public String getString08() {
819 return this.string08;
820 }
821
822
823
824
825
826 public void setString08(String string08a) {
827 this.string08 = string08a;
828 }
829
830
831
832
833
834 public Long getInt01() {
835 return this.int01;
836 }
837
838
839
840
841
842 public void setInt01(Long int01a) {
843 this.int01 = int01a;
844 }
845
846
847
848
849
850 public Long getInt02() {
851 return this.int02;
852 }
853
854
855
856
857
858 public void setInt02(Long int02a) {
859 this.int02 = int02a;
860 }
861
862
863
864
865
866 public Long getInt03() {
867 return this.int03;
868 }
869
870
871
872
873
874 public void setInt03(Long int03a) {
875 this.int03 = int03a;
876 }
877
878
879
880
881
882 public Long getInt04() {
883 return this.int04;
884 }
885
886
887
888
889
890 public void setInt04(Long int04a) {
891 this.int04 = int04a;
892 }
893
894
895
896
897
898 public Long getInt05() {
899 return this.int05;
900 }
901
902
903
904
905
906 public void setInt05(Long int05a) {
907 this.int05 = int05a;
908 }
909
910
911
912
913
914 public String getDescription() {
915 return this.description;
916 }
917
918
919
920
921
922 public void setDescription(String description1) {
923 this.description = description1;
924 }
925
926
927
928
929
930 public Timestamp getCreatedOn() {
931 return this.createdOnDb == null ? null : new Timestamp(this.createdOnDb);
932 }
933
934
935
936
937
938 public Timestamp getLastUpdated() {
939 return this.lastUpdatedDb == null ? null : new Timestamp(this.lastUpdatedDb);
940 }
941
942
943
944
945
946 public Long getCreatedOnDb() {
947 return this.createdOnDb;
948 }
949
950
951
952
953
954 public Long getLastUpdatedDb() {
955 return this.lastUpdatedDb;
956 }
957
958
959
960
961
962 public void setCreatedOn(Timestamp createdOn1) {
963 this.createdOnDb = createdOn1 == null ? null : createdOn1.getTime();
964 }
965
966
967
968
969
970 public void setLastUpdated(Timestamp lastUpdated1) {
971 this.lastUpdatedDb = lastUpdated1 == null ? null : lastUpdated1.getTime();
972 }
973
974
975
976
977 public void truncate() {
978 this.actAsMemberId = GrouperUtil.truncateAscii(this.actAsMemberId, 128);
979 this.auditTypeId = GrouperUtil.truncateAscii(this.auditTypeId, 128);
980 this.contextId = GrouperUtil.truncateAscii(this.contextId, 128);
981 this.description = GrouperUtil.truncateAscii(this.description, 4000);
982 this.envName = GrouperUtil.truncateAscii(this.envName, 50);
983 this.grouperEngine = GrouperUtil.truncateAscii(this.grouperEngine, 50);
984 this.grouperVersion = GrouperUtil.truncateAscii(this.grouperVersion, 20);
985 this.id = GrouperUtil.truncateAscii(this.id, 128);
986 this.loggedInMemberId = GrouperUtil.truncateAscii(this.loggedInMemberId, 128);
987 this.serverHost = GrouperUtil.truncateAscii(this.serverHost, 50);
988 this.serverUserName = GrouperUtil.truncateAscii(this.serverUserName, 50);
989 this.string01 = GrouperUtil.truncateAscii(this.string01, 4000);
990 this.string02 = GrouperUtil.truncateAscii(this.string02, 4000);
991 this.string03 = GrouperUtil.truncateAscii(this.string03, 4000);
992 this.string04 = GrouperUtil.truncateAscii(this.string04, 4000);
993 this.string05 = GrouperUtil.truncateAscii(this.string05, 4000);
994 this.string06 = GrouperUtil.truncateAscii(this.string06, 4000);
995 this.string07 = GrouperUtil.truncateAscii(this.string07, 4000);
996 this.string08 = GrouperUtil.truncateAscii(this.string08, 4000);
997 this.userIpAddress = GrouperUtil.truncateAscii(this.userIpAddress, 50);
998 }
999
1000
1001
1002
1003
1004 public String getGrouperVersion() {
1005 return this.grouperVersion;
1006 }
1007
1008
1009
1010
1011
1012 public void setGrouperVersion(String grouperVersion1) {
1013 this.grouperVersion = grouperVersion1;
1014 }
1015
1016
1017
1018
1019 @Override
1020 public GrouperAPI clone() {
1021 throw new RuntimeException("not implemented");
1022 }
1023
1024
1025
1026
1027
1028 public long getDurationMicroseconds() {
1029 return this.durationMicroseconds;
1030 }
1031
1032
1033
1034
1035
1036 public void setDurationMicroseconds(long durationMicroseconds1) {
1037 this.durationMicroseconds = durationMicroseconds1;
1038 }
1039
1040
1041
1042
1043
1044 @Override
1045 public void onPreSave(HibernateSession hibernateSession) {
1046 super.onPreSave(hibernateSession);
1047 if (this.lastUpdatedDb == null) {
1048 this.lastUpdatedDb = System.currentTimeMillis();
1049 }
1050 if (this.createdOnDb == null) {
1051 this.createdOnDb = System.currentTimeMillis();
1052 }
1053 if (this.actAsMemberId == null && this.loggedInMemberId != null) {
1054 this.actAsMemberId = this.loggedInMemberId;
1055 }
1056 }
1057
1058
1059
1060
1061
1062 @Override
1063 public void onPreUpdate(HibernateSession hibernateSession) {
1064 super.onPreUpdate(hibernateSession);
1065 this.setLastUpdatedDb(System.currentTimeMillis());
1066 }
1067
1068
1069
1070
1071
1072 public int getQueryCount() {
1073 return this.queryCount;
1074 }
1075
1076
1077
1078
1079
1080 public void setQueryCount(int queryCount) {
1081 this.queryCount = queryCount;
1082 }
1083
1084
1085
1086
1087
1088 public String getServerUserName() {
1089 return this.serverUserName;
1090 }
1091
1092
1093
1094
1095
1096 public void setServerUserName(String serverUserName1) {
1097 this.serverUserName = serverUserName1;
1098 }
1099
1100
1101
1102
1103
1104 public void setCreatedOnDb(Long createdOn1) {
1105 this.createdOnDb = createdOn1;
1106 }
1107
1108
1109
1110
1111
1112 public void setLastUpdatedDb(Long lastUpdated1) {
1113 this.lastUpdatedDb = lastUpdated1;
1114 }
1115
1116
1117
1118
1119
1120 public String toStringDeep() {
1121 return GrouperUtil.toStringFields(this, TO_STRING_DEEP_FIELDS);
1122 }
1123
1124
1125
1126
1127 public XmlImportable<AuditEntry> xmlRetrieveByIdOrKey() {
1128
1129 return GrouperDAOFactory.getFactory().getAuditEntry().findById(this.id, false);
1130 }
1131
1132
1133
1134
1135 public void xmlCopyBusinessPropertiesToExisting(AuditEntry existingRecord) {
1136 existingRecord.setActAsMemberId(this.actAsMemberId);
1137 existingRecord.setAuditTypeId(this.auditTypeId);
1138 existingRecord.setContextId(this.contextId);
1139 existingRecord.setDescription(this.description);
1140 existingRecord.setDurationMicroseconds(this.durationMicroseconds);
1141 existingRecord.setEnvName(this.envName);
1142 existingRecord.setGrouperEngine(this.grouperEngine);
1143 existingRecord.setGrouperVersion(this.grouperVersion);
1144 existingRecord.setId(this.id);
1145 existingRecord.setInt01(this.int01);
1146 existingRecord.setInt02(this.int02);
1147 existingRecord.setInt03(this.int03);
1148 existingRecord.setInt04(this.int04);
1149 existingRecord.setInt05(this.int05);
1150 existingRecord.setLoggedInMemberId(this.loggedInMemberId);
1151 existingRecord.setQueryCount(this.queryCount);
1152 existingRecord.setServerHost(this.serverHost);
1153 existingRecord.setServerUserName(this.serverUserName);
1154 existingRecord.setString01(this.string01);
1155 existingRecord.setString02(this.string02);
1156 existingRecord.setString03(this.string03);
1157 existingRecord.setString04(this.string04);
1158 existingRecord.setString05(this.string05);
1159 existingRecord.setString06(this.string06);
1160 existingRecord.setString07(this.string07);
1161 existingRecord.setString08(this.string08);
1162 existingRecord.setUserIpAddress(this.userIpAddress);
1163 }
1164
1165
1166
1167
1168 public boolean xmlDifferentBusinessProperties(AuditEntry other) {
1169 if (!StringUtils.equals(this.actAsMemberId, other.actAsMemberId)) {
1170 return true;
1171 }
1172 if (!StringUtils.equals(this.auditTypeId, other.auditTypeId)) {
1173 return true;
1174 }
1175 if (!StringUtils.equals(this.description, other.description)) {
1176 return true;
1177 }
1178 if (this.durationMicroseconds != other.durationMicroseconds) {
1179 return true;
1180 }
1181 if (!StringUtils.equals(this.envName, other.envName)) {
1182 return true;
1183 }
1184 if (!StringUtils.equals(this.grouperEngine, other.grouperEngine)) {
1185 return true;
1186 }
1187 if (!StringUtils.equals(this.grouperVersion, other.grouperVersion)) {
1188 return true;
1189 }
1190 if (!StringUtils.equals(this.id, other.id)) {
1191 return true;
1192 }
1193 if (!GrouperUtil.equals(this.int01, other.int01)) {
1194 return true;
1195 }
1196 if (!GrouperUtil.equals(this.int02, other.int02)) {
1197 return true;
1198 }
1199 if (!GrouperUtil.equals(this.int03, other.int03)) {
1200 return true;
1201 }
1202 if (!GrouperUtil.equals(this.int04, other.int04)) {
1203 return true;
1204 }
1205 if (!GrouperUtil.equals(this.int05, other.int05)) {
1206 return true;
1207 }
1208 if (!StringUtils.equals(this.loggedInMemberId, other.loggedInMemberId)) {
1209 return true;
1210 }
1211 if (this.queryCount != other.queryCount) {
1212 return true;
1213 }
1214 if (!StringUtils.equals(this.serverHost, other.serverHost)) {
1215 return true;
1216 }
1217 if (!StringUtils.equals(this.serverUserName, other.serverUserName)) {
1218 return true;
1219 }
1220 if (!StringUtils.equals(this.string01, other.string01)) {
1221 return true;
1222 }
1223 if (!StringUtils.equals(this.string02, other.string02)) {
1224 return true;
1225 }
1226 if (!StringUtils.equals(this.string03, other.string03)) {
1227 return true;
1228 }
1229 if (!StringUtils.equals(this.string04, other.string04)) {
1230 return true;
1231 }
1232 if (!StringUtils.equals(this.string05, other.string05)) {
1233 return true;
1234 }
1235 if (!StringUtils.equals(this.string06, other.string06)) {
1236 return true;
1237 }
1238 if (!StringUtils.equals(this.string07, other.string07)) {
1239 return true;
1240 }
1241 if (!StringUtils.equals(this.string08, other.string08)) {
1242 return true;
1243 }
1244 if (!StringUtils.equals(this.userIpAddress, other.userIpAddress)) {
1245 return true;
1246 }
1247 return false;
1248 }
1249
1250
1251
1252
1253 public boolean xmlDifferentUpdateProperties(AuditEntry other) {
1254 if (!StringUtils.equals(this.contextId, other.contextId)) {
1255 return true;
1256 }
1257 if (!GrouperUtil.equals(this.createdOnDb, other.createdOnDb)) {
1258 return true;
1259 }
1260 if (!GrouperUtil.equals(this.getHibernateVersionNumber(), other.getHibernateVersionNumber())) {
1261 return true;
1262 }
1263 if (!GrouperUtil.equals(this.lastUpdatedDb, other.lastUpdatedDb)) {
1264 return true;
1265 }
1266 return false;
1267 }
1268
1269
1270
1271
1272 public String xmlGetId() {
1273 return this.getId();
1274 }
1275
1276
1277
1278
1279 public AuditEntrynternet2/middleware/grouper/audit/AuditEntry.html#AuditEntry">AuditEntry xmlSaveBusinessProperties(AuditEntry existingRecord) {
1280
1281 if (existingRecord == null) {
1282 existingRecord = new AuditEntry();
1283 }
1284 this.xmlCopyBusinessPropertiesToExisting(existingRecord);
1285
1286 existingRecord.saveOrUpdate(false);
1287 return existingRecord;
1288 }
1289
1290
1291
1292
1293 public void xmlSaveUpdateProperties() {
1294 GrouperDAOFactory.getFactory().getAuditEntry().saveUpdateProperties(this);
1295 }
1296
1297
1298
1299
1300 public void xmlSetId(String theId) {
1301 this.setId(theId);
1302 }
1303
1304
1305
1306
1307
1308
1309 public XmlExportAuditEntry xmlToExportAuditEntry(GrouperVersion grouperVersion) {
1310 if (grouperVersion == null) {
1311 throw new RuntimeException();
1312 }
1313
1314 XmlExportAuditEntryrtAuditEntry.html#XmlExportAuditEntry">XmlExportAuditEntry xmlExportAuditEntry = new XmlExportAuditEntry();
1315 xmlExportAuditEntry.setActAsMemberId(this.getActAsMemberId());
1316 xmlExportAuditEntry.setAuditTypeId(this.getAuditTypeId());
1317 xmlExportAuditEntry.setContextId(this.getContextId());
1318 xmlExportAuditEntry.setCreatedOn(GrouperUtil.dateStringValue(this.getCreatedOnDb()));
1319 xmlExportAuditEntry.setDescription(this.getDescription());
1320 xmlExportAuditEntry.setDurationMicroseconds(this.getDurationMicroseconds());
1321 xmlExportAuditEntry.setEnvName(this.getEnvName());
1322 xmlExportAuditEntry.setGrouperEngine(this.getGrouperEngine());
1323 xmlExportAuditEntry.setGrouperVersion(this.getGrouperVersion());
1324 xmlExportAuditEntry.setHibernateVersionNumber(GrouperUtil.longValue(this.getHibernateVersionNumber(), 0));
1325 xmlExportAuditEntry.setId(this.getId());
1326 xmlExportAuditEntry.setInt01(this.getInt01());
1327 xmlExportAuditEntry.setInt02(this.getInt02());
1328 xmlExportAuditEntry.setInt03(this.getInt03());
1329 xmlExportAuditEntry.setInt04(this.getInt04());
1330 xmlExportAuditEntry.setInt05(this.getInt05());
1331 xmlExportAuditEntry.setLastUpdated(GrouperUtil.dateStringValue(this.getLastUpdatedDb()));
1332 xmlExportAuditEntry.setLoggedInMemberId(this.getLoggedInMemberId());
1333 xmlExportAuditEntry.setQueryCount(this.getQueryCount());
1334 xmlExportAuditEntry.setServerHost(this.getServerHost());
1335 xmlExportAuditEntry.setServerUserName(this.getServerUserName());
1336 xmlExportAuditEntry.setString01(this.getString01());
1337 xmlExportAuditEntry.setString02(this.getString02());
1338 xmlExportAuditEntry.setString03(this.getString03());
1339 xmlExportAuditEntry.setString04(this.getString04());
1340 xmlExportAuditEntry.setString05(this.getString05());
1341 xmlExportAuditEntry.setString06(this.getString06());
1342 xmlExportAuditEntry.setString07(this.getString07());
1343 xmlExportAuditEntry.setString08(this.getString08());
1344 xmlExportAuditEntry.setUserIpAddress(this.getUserIpAddress());
1345 return xmlExportAuditEntry;
1346 }
1347
1348
1349
1350
1351
1352
1353
1354 public String retrieveStringValue(String label) {
1355 return this.retrieveStringValue(this.getAuditType(), label);
1356 }
1357
1358
1359
1360
1361
1362
1363
1364 public String retrieveStringValue(AuditType auditType, String label) {
1365 if (StringUtils.equals(label, auditType.getLabelString01())) {
1366 return this.string01;
1367 } else if (StringUtils.equals(label, auditType.getLabelString02())) {
1368 return this.string02;
1369 } else if (StringUtils.equals(label, auditType.getLabelString03())) {
1370 return this.string03;
1371 } else if (StringUtils.equals(label, auditType.getLabelString04())) {
1372 return this.string04;
1373 } else if (StringUtils.equals(label, auditType.getLabelString05())) {
1374 return this.string05;
1375 } else if (StringUtils.equals(label, auditType.getLabelString06())) {
1376 return this.string06;
1377 } else if (StringUtils.equals(label, auditType.getLabelString07())) {
1378 return this.string07;
1379 } else if (StringUtils.equals(label, auditType.getLabelString08())) {
1380 return this.string08;
1381 } else {
1382 throw new RuntimeException("Cant find string label: '" + label
1383 + "' in audit type: " + auditType.getAuditCategory() + " - " + auditType.getActionName());
1384 }
1385 }
1386
1387
1388
1389
1390 public String xmlToString() {
1391 StringWriter stringWriter = new StringWriter();
1392
1393 stringWriter.write("AuditEntry: " + this.getId());
1394
1395
1396
1397 return stringWriter.toString();
1398
1399 }
1400
1401 }