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 java.util.ArrayList;
24  import java.util.List;
25  import java.util.Optional;
26  import org.apache.syncope.common.lib.BaseBean;
27  import org.apache.syncope.common.lib.types.AuditElements;
28  
29  public class EventCategory implements BaseBean {
30  
31      private static final long serialVersionUID = -4340060002701633401L;
32  
33      private AuditElements.EventCategoryType type;
34  
35      private String category;
36  
37      private String subcategory;
38  
39      private final List<String> events = new ArrayList<>();
40  
41      /**
42       * Constructor for Type.REST event category.
43       */
44      public EventCategory() {
45          this(AuditElements.EventCategoryType.LOGIC);
46      }
47  
48      /**
49       * Constructor for the given Type event category.
50       *
51       * @param type event category type
52       */
53      public EventCategory(final AuditElements.EventCategoryType type) {
54          super();
55          this.type = type;
56      }
57  
58      public AuditElements.EventCategoryType getType() {
59          return type;
60      }
61  
62      public void setType(final AuditElements.EventCategoryType type) {
63          this.type = Optional.ofNullable(type).orElse(AuditElements.EventCategoryType.CUSTOM);
64      }
65  
66      public String getCategory() {
67          return category;
68      }
69  
70      public void setCategory(final String category) {
71          this.category = category;
72      }
73  
74      public String getSubcategory() {
75          return subcategory;
76      }
77  
78      public void setSubcategory(final String subcategory) {
79          this.subcategory = subcategory;
80      }
81  
82      @JacksonXmlElementWrapper(localName = "events")
83      @JacksonXmlProperty(localName = "event")
84      public List<String> getEvents() {
85          return events;
86      }
87  }