View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.common.lib.audit;
20  
21  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
22  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
23  import io.swagger.v3.oas.annotations.media.Schema;
24  import java.time.OffsetDateTime;
25  import java.util.ArrayList;
26  import java.util.List;
27  import org.apache.commons.lang3.builder.EqualsBuilder;
28  import org.apache.commons.lang3.builder.HashCodeBuilder;
29  import org.apache.syncope.common.lib.BaseBean;
30  import org.apache.syncope.common.lib.types.AuditLoggerName;
31  
32  public class AuditEntry implements BaseBean {
33  
34      private static final long serialVersionUID = 1215115961911228005L;
35  
36      private String who;
37  
38      private OffsetDateTime date;
39  
40      private AuditLoggerName logger;
41  
42      private String before;
43  
44      private final List<String> inputs = new ArrayList<>();
45  
46      private String output;
47  
48      private String throwable;
49  
50      @Schema(accessMode = Schema.AccessMode.READ_ONLY)
51      public String getWho() {
52          return who;
53      }
54  
55      public void setWho(final String who) {
56          this.who = who;
57      }
58  
59      @Schema(accessMode = Schema.AccessMode.READ_ONLY)
60      public OffsetDateTime getDate() {
61          return date;
62      }
63  
64      public void setDate(final OffsetDateTime date) {
65          this.date = date;
66      }
67  
68      @Schema(accessMode = Schema.AccessMode.READ_ONLY)
69      public AuditLoggerName getLogger() {
70          return logger;
71      }
72  
73      public void setLogger(final AuditLoggerName logger) {
74          this.logger = logger;
75      }
76  
77      @Schema(accessMode = Schema.AccessMode.READ_ONLY)
78      public String getBefore() {
79          return before;
80      }
81  
82      @JacksonXmlElementWrapper(localName = "inputs")
83      @JacksonXmlProperty(localName = "input")
84      @Schema(accessMode = Schema.AccessMode.READ_ONLY)
85      public List<String> getInputs() {
86          return inputs;
87      }
88  
89      public void setBefore(final String before) {
90          this.before = before;
91      }
92  
93      @Schema(accessMode = Schema.AccessMode.READ_ONLY)
94      public String getOutput() {
95          return output;
96      }
97  
98      public void setOutput(final String output) {
99          this.output = output;
100     }
101 
102     @Schema(accessMode = Schema.AccessMode.READ_ONLY)
103     public String getThrowable() {
104         return throwable;
105     }
106 
107     public void setThrowable(final String throwable) {
108         this.throwable = throwable;
109     }
110 
111     @Override
112     public int hashCode() {
113         return new HashCodeBuilder().
114                 appendSuper(super.hashCode()).
115                 append(who).
116                 append(date).
117                 append(logger).
118                 append(before).
119                 append(inputs).
120                 append(output).
121                 append(throwable).
122                 build();
123     }
124 
125     @Override
126     public boolean equals(final Object obj) {
127         if (this == obj) {
128             return true;
129         }
130         if (obj == null) {
131             return false;
132         }
133         if (getClass() != obj.getClass()) {
134             return false;
135         }
136         final AuditEntry other = (AuditEntry) obj;
137         return new EqualsBuilder().
138                 appendSuper(super.equals(obj)).
139                 append(who, other.who).
140                 append(date, other.date).
141                 append(logger, other.logger).
142                 append(before, other.before).
143                 append(inputs, other.inputs).
144                 append(output, other.output).
145                 append(throwable, other.throwable).
146                 build();
147     }
148 }