1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.common.rest.api.beans;
20
21 import io.swagger.v3.oas.annotations.Parameter;
22 import io.swagger.v3.oas.annotations.media.ArraySchema;
23 import io.swagger.v3.oas.annotations.media.Schema;
24 import java.util.ArrayList;
25 import java.util.List;
26 import javax.ws.rs.QueryParam;
27 import org.apache.syncope.common.lib.types.AuditElements;
28 import org.apache.syncope.common.rest.api.service.JAXRSService;
29
30 public class AuditQuery extends AbstractTimeframeQuery {
31
32 private static final long serialVersionUID = -2863334226169614417L;
33
34 public static class Builder extends AbstractTimeframeQuery.Builder<AuditQuery, Builder> {
35
36 @Override
37 protected AuditQuery newInstance() {
38 return new AuditQuery();
39 }
40
41 public Builder entityKey(final String entityKey) {
42 getInstance().setEntityKey(entityKey);
43 return this;
44 }
45
46 public Builder type(final AuditElements.EventCategoryType type) {
47 getInstance().setType(type);
48 return this;
49 }
50
51 public Builder category(final String category) {
52 getInstance().setCategory(category);
53 return this;
54 }
55
56 public Builder subcategory(final String subcategory) {
57 getInstance().setSubcategory(subcategory);
58 return this;
59 }
60
61 public Builder event(final String event) {
62 getInstance().getEvents().add(event);
63 return this;
64 }
65
66 public Builder events(final List<String> events) {
67 getInstance().setEvents(events);
68 return this;
69 }
70
71 public Builder result(final AuditElements.Result result) {
72 getInstance().setResult(result);
73 return this;
74 }
75 }
76
77 private String entityKey;
78
79 private AuditElements.EventCategoryType type;
80
81 private String category;
82
83 private String subcategory;
84
85 private final List<String> events = new ArrayList<>();
86
87 private AuditElements.Result result;
88
89 @Parameter(name = JAXRSService.PARAM_ENTITY_KEY, description = "audit entity key to match", schema =
90 @Schema(implementation = String.class, example = "50592942-73ec-44c4-a377-e859524245e4"))
91 public String getEntityKey() {
92 return entityKey;
93 }
94
95 @QueryParam(JAXRSService.PARAM_ENTITY_KEY)
96 public void setEntityKey(final String entityKey) {
97 this.entityKey = entityKey;
98 }
99
100 @Parameter(name = "type", description = "audit type to match", schema =
101 @Schema(implementation = AuditElements.EventCategoryType.class))
102 public AuditElements.EventCategoryType getType() {
103 return type;
104 }
105
106 @QueryParam("type")
107 public void setType(final AuditElements.EventCategoryType type) {
108 this.type = type;
109 }
110
111 @Parameter(name = "category", description = "audit category to match", schema =
112 @Schema(implementation = String.class))
113 public String getCategory() {
114 return category;
115 }
116
117 @QueryParam("category")
118 public void setCategory(final String category) {
119 this.category = category;
120 }
121
122 @Parameter(name = "subcategory", description = "audit subcategory to match", schema =
123 @Schema(implementation = String.class))
124 public String getSubcategory() {
125 return subcategory;
126 }
127
128 @QueryParam("subcategory")
129 public void setSubcategory(final String subcategory) {
130 this.subcategory = subcategory;
131 }
132
133 @Parameter(name = "result", description = "audit result to match", schema =
134 @Schema(implementation = AuditElements.Result.class))
135 public AuditElements.Result getResult() {
136 return result;
137 }
138
139 @QueryParam("result")
140 public void setResult(final AuditElements.Result result) {
141 this.result = result;
142 }
143
144 @Parameter(name = "events", description = "audit events(s) to match", array =
145 @ArraySchema(uniqueItems = true, schema =
146 @Schema(implementation = String.class)))
147 public List<String> getEvents() {
148 return events;
149 }
150
151 @QueryParam("events")
152 public void setEvents(final List<String> events) {
153 if (events != null) {
154 this.events.addAll(events);
155 }
156 }
157 }