@@ -26,40 +26,39 @@ class OurRevisionListener(
26
26
override fun newRevision (revisionEntity : Any? ) {
27
27
revisionEntity as OurRevision
28
28
29
+ var actor: String? = null
30
+
29
31
val request = try {
30
32
val requestAttributes = RequestContextHolder .getRequestAttributes()
31
33
if (requestAttributes != null ) {
32
34
val request = (requestAttributes as ServletRequestAttributes ).request
33
35
request.method + " " + request.requestURI
34
36
} else {
37
+ // no exception occurred, we just don't have a request
38
+ actor = systembrukerIdent
35
39
null
36
40
}
37
41
} catch (e: Exception ) {
38
42
logger.debug(" No request found to set on revision entity. Setting to null." , e)
39
43
null
40
44
}
41
45
42
- val actor = if (request == null ) {
43
- systembrukerIdent
44
- } else {
45
- val navIdentFromToken = try {
46
- tokenUtil.getIdent()
47
- } catch (e: Exception ) {
48
- logger.debug(" No NAVIdent found in token." , e)
49
- null
50
- }
51
- val callingApplication = try {
52
- tokenUtil.getCallingApplication()
53
- } catch (e: Exception ) {
54
- logger.warn(" Failed to get calling application from token." , e)
55
- null
56
- }
46
+ val navIdentFromToken = try {
47
+ tokenUtil.getIdent()
48
+ } catch (e: Exception ) {
49
+ logger.debug(" No NAVIdent found in token." , e)
50
+ null
51
+ }
57
52
58
- if (navIdentFromToken == null && callingApplication == null ) {
59
- logger.warn(" Neither NAVIdent nor calling application could be found from token. Setting 'unknown'." )
60
- }
53
+ val callingApplication = try {
54
+ tokenUtil.getCallingApplication()
55
+ } catch (e: Exception ) {
56
+ logger.warn(" Failed to get calling application from token." , e)
57
+ null
58
+ }
61
59
62
- navIdentFromToken ? : callingApplication ? : " unknown"
60
+ if (navIdentFromToken != null || callingApplication != null ) {
61
+ actor = navIdentFromToken ? : callingApplication
63
62
}
64
63
65
64
val traceId = try {
@@ -70,7 +69,7 @@ class OurRevisionListener(
70
69
}
71
70
72
71
revisionEntity.request = request
73
- revisionEntity.actor = actor
72
+ revisionEntity.actor = actor ? : " unknown "
74
73
revisionEntity.traceId = traceId
75
74
}
76
75
}
0 commit comments