• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IQSS / dataverse / #24490

06 Feb 2025 11:53PM UTC coverage: 22.757% (-0.005%) from 22.762%
#24490

Pull #11225

github

web-flow
Merge 2ee746b83 into 3aea1482d
Pull Request #11225: Flaky XmlMetadataTemplateTest fix

19944 of 87640 relevant lines covered (22.76%)

0.23 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.88
/src/main/java/edu/harvard/iq/dataverse/actionlogging/ActionLogRecord.java
1
package edu.harvard.iq.dataverse.actionlogging;
2

3
import java.util.Date;
4
import java.util.Objects;
5
import java.util.UUID;
6
import jakarta.persistence.Column;
7
import jakarta.persistence.Entity;
8
import jakarta.persistence.EnumType;
9
import jakarta.persistence.Enumerated;
10
import jakarta.persistence.Id;
11
import jakarta.persistence.Index;
12
import jakarta.persistence.PrePersist;
13
import jakarta.persistence.Table;
14
import jakarta.persistence.Temporal;
15
import jakarta.persistence.TemporalType;
16

17
/**
18
 * Logs a single action in the action log.
19
 * @author michael
20
 */
21
@Entity
22
@Table(indexes = {@Index(columnList="useridentifier"), @Index(columnList="actiontype"), @Index(columnList="starttime")})
23
public class ActionLogRecord implements java.io.Serializable {
24
    
25
    public enum Result {
1✔
26
        OK, BadRequest, PermissionError, InternalError
1✔
27
    }
28
    
29
    public enum ActionType {
1✔
30
        /** login, logout */
31
        SessionManagement,
1✔
32
        
33
        /** Command execution */
34
        Command,
1✔
35
        
36
        BuiltinUser, 
1✔
37
        
38
        /** A setting being updated */
39
        Setting,
1✔
40
        
41
        Auth,
1✔
42
        
43
        Admin,
1✔
44

45
        ExternalTool,
1✔
46
        
47
        GlobalGroups
1✔
48
    }
49
    
50
    @Id
51
    @Column( length=36 )
52
    private String id;
53
    
54
    @Temporal(value = TemporalType.TIMESTAMP)
55
    private Date startTime;
56
    
57
    @Temporal(value = TemporalType.TIMESTAMP)
58
    private Date endTime;
59
    
60
    @Enumerated(EnumType.STRING)
61
    private Result actionResult;
62
    
63
    private String userIdentifier;
64
    
65
    @Enumerated(EnumType.STRING)
66
    private ActionType actionType;
67
    
68
    private String actionSubType;
69
    
70
    @Column(columnDefinition="TEXT")
71
    private String info;
72
    
73
    public ActionLogRecord(){}
1✔
74
    
75
    /**
76
     * @param anActionType
77
     * @param anActionSubType
78
     */
79
    // TODO: Add ability to set `info` in constructor.
80
    public ActionLogRecord( ActionType anActionType, String anActionSubType ) {
1✔
81
        actionType = anActionType;
1✔
82
        actionSubType = anActionSubType;
1✔
83
        startTime = new Date();
1✔
84
    }
1✔
85
    
86
    @Override
87
    public String toString() {
88
        return "[ActionLogRecord id:" + getId() + " type:" + getActionType() 
×
89
                    + "/" + getActionSubType()
×
90
                    + " result:" + getActionResult() + "]";
×
91
    }
92
    
93
    @PrePersist
94
    void prepresist() {
95
        if ( id == null ) {
×
96
            id = UUID.randomUUID().toString();
×
97
        }
98
    }
×
99

100
    public String getId() {
101
        return id;
×
102
    }
103

104
    public void setId(String id) {
105
        this.id = id;
×
106
    }
×
107

108
    public Date getStartTime() {
109
        return startTime;
1✔
110
    }
111

112
    public ActionLogRecord setStartTime(Date startTime) {
113
        this.startTime = startTime;
1✔
114
        return this;
1✔
115
    }
116

117
    public Date getEndTime() {
118
        return endTime;
1✔
119
    }
120

121
    public ActionLogRecord setEndTime(Date endTime) {
122
        this.endTime = endTime;
1✔
123
        return this;
1✔
124
    }
125

126
    public Result getActionResult() {
127
        return actionResult;
1✔
128
    }
129

130
    public ActionLogRecord setActionResult(Result actionResult) {
131
        this.actionResult = actionResult;
1✔
132
        return this;
1✔
133
    }
134

135
    public String getUserIdentifier() {
136
        return userIdentifier;
1✔
137
    }
138

139
    public ActionLogRecord setUserIdentifier(String userIdentifier) {
140
        this.userIdentifier = userIdentifier;
1✔
141
        return this;
1✔
142
    }
143

144
    public ActionType getActionType() {
145
        return actionType;
1✔
146
    }
147

148
    public ActionLogRecord setActionType(ActionType actionType) {
149
        this.actionType = actionType;
1✔
150
        return this;
1✔
151
    }
152

153
    public String getActionSubType() {
154
        return actionSubType;
1✔
155
    }
156

157
    public ActionLogRecord setActionSubType(String actionSubType) {
158
        this.actionSubType = actionSubType;
1✔
159
        return this;
1✔
160
    }
161

162
    public String getInfo() {
163
        return info;
1✔
164
    }
165

166
    public ActionLogRecord setInfo(String info) {
167
        this.info = info;
1✔
168
        return this;
1✔
169
    }
170

171
    @Override
172
    public int hashCode() {
173
        int hash = 7;
×
174
        hash = 71 * hash + Objects.hashCode(this.id);
×
175
        return hash;
×
176
    }
177

178
    @Override
179
    public boolean equals(Object obj) {
180
        if (obj == null) {
1✔
181
            return false;
1✔
182
        }
183
        if (getClass() != obj.getClass()) {
1✔
184
            return false;
1✔
185
        }
186
        final ActionLogRecord other = (ActionLogRecord) obj;
1✔
187
        if (!Objects.equals(this.startTime, other.startTime)) {
1✔
188
            return false;
1✔
189
        }
190
        if (!Objects.equals(this.endTime, other.endTime)) {
1✔
191
            return false;
×
192
        }
193
        if (this.actionResult != other.actionResult) {
1✔
194
            return false;
1✔
195
        }
196
        if (!Objects.equals(this.userIdentifier, other.userIdentifier)) {
1✔
197
            return false;
1✔
198
        }
199
        if (this.actionType != other.actionType) {
1✔
200
            return false;
1✔
201
        }
202
        if (!Objects.equals(this.actionSubType, other.actionSubType)) {
1✔
203
            return false;
1✔
204
        }
205
        return Objects.equals(this.info, other.info);
1✔
206
    }
207
    
208
    
209
    
210
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc