2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.policy.rest.jpa;
23 import java.io.Serializable;
24 import java.util.Date;
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.GeneratedValue;
29 import javax.persistence.GenerationType;
30 import javax.persistence.Id;
31 import javax.persistence.JoinColumn;
32 import javax.persistence.ManyToOne;
33 import javax.persistence.NamedQuery;
34 import javax.persistence.OrderBy;
35 import javax.persistence.PrePersist;
36 import javax.persistence.PreUpdate;
37 import javax.persistence.Table;
38 import javax.persistence.Temporal;
39 import javax.persistence.TemporalType;
41 import org.apache.commons.logging.Log;
42 import org.apache.commons.logging.LogFactory;
43 import org.openecomp.policy.rest.XacmlAdminAuthorization;
45 import org.openecomp.policy.common.logging.eelf.MessageCodes;
46 import org.openecomp.policy.common.logging.eelf.PolicyLogger;
50 @Table(name="parentdictionaryitems")
51 @NamedQuery(name="FirewallDictionaryList.findAll", query="SELECT e FROM FirewallDictionaryList e")
52 public class FirewallDictionaryList implements Serializable {
53 private static final long serialVersionUID = 1L;
55 private static String domain;
58 @GeneratedValue(strategy = GenerationType.AUTO)
62 @Column(name="parentItemName", nullable=false)
64 private String parentItemName;
66 @Column(name="description")
67 private String description;
69 @Column(name="addressList")
70 private String addressList;
72 @Column(name="serviceList")
73 private String serviceList;
75 /* @Temporal(TemporalType.TIMESTAMP)
76 @Column(name="created_date", updatable=false)
77 private Date createdDate;
79 @Temporal(TemporalType.TIMESTAMP)
80 @Column(name="modified_date", nullable=false)
81 private Date modifiedDate;
83 @ManyToOne(optional = false)
84 @JoinColumn(name="created_by")
85 private UserInfo userCreatedBy;
87 @ManyToOne(optional = false)
88 @JoinColumn(name="modified_by")
89 private UserInfo userModifiedBy;*/
95 public void setId(int id) {
99 public String getParentItemName() {
100 return parentItemName;
103 public String getDescription() {
107 public String getAddressList() {
111 public String getServiceList() {
115 public void setParentItemName(String parentItemName) {
116 this.parentItemName = parentItemName;
119 public void setDescription(String description) {
120 this.description = description;
123 public void setAddressList(String addressList) {
124 this.addressList = addressList;
127 public void setServiceList(String serviceList) {
128 this.serviceList = serviceList;
132 /*public UserInfo getUserCreatedBy() {
133 return userCreatedBy;
136 public void setUserCreatedBy(UserInfo userCreatedBy) {
137 this.userCreatedBy = userCreatedBy;
140 public UserInfo getUserModifiedBy() {
141 return userModifiedBy;
144 public void setUserModifiedBy(UserInfo userModifiedBy) {
145 this.userModifiedBy = userModifiedBy;
148 private static Log logger = LogFactory.getLog(FirewallDictionaryList.class);
150 public FirewallDictionaryList() {
154 private static final Log auditLogger = LogFactory
155 .getLog("auditLogger");
157 public FirewallDictionaryList(String string, String userid) {
160 public FirewallDictionaryList(String domain) {
161 this.parentItemName = domain;
165 public void prePersist() {
166 Date date = new Date();
167 this.createdDate = date;
168 this.modifiedDate = date;
169 auditLogger.debug("Added New Term Name: "+this.parentItemName+" by "+this.userCreatedBy);
173 public void preUpdate() {
174 this.modifiedDate = new Date();
176 this.userModifiedBy =XacmlAdminAuthorization.getUserId();;
177 } catch (Exception e) {
178 logger.error("Exception caused While adding Modified by Role"+e);
179 // TODO:EELF Cleanup - Remove logger
180 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "TermList", "Exception caused While adding Modified by Role");
182 auditLogger.debug("Updated Term Name: "+this.parentItemName+" by "+this.userModifiedBy);