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;
51 @NamedQuery(name="TermList.findAll", query="SELECT e FROM TermList e")
52 public class TermList implements Serializable {
53 private static final long serialVersionUID = 1L;
55 private static String domain;
58 @GeneratedValue(strategy = GenerationType.AUTO)
62 @Column(name="termName", nullable=false)
64 private String termName;
66 @Column(name="description")
67 private String termDescription;
69 @Column(name="fromzone")
70 private String fromZone;
72 @Column(name="tozone")
73 private String toZone;
75 @Column(name="srcIPList")
76 private String srcIPList;
78 @Column(name="destIPList")
79 private String destIPList;
81 @Column(name="protocolList")
82 private String protocolList;
84 @Column(name="portList")
85 private String portList;
87 @Column(name="srcPortList")
88 private String srcPortList;
90 @Column(name="destPortList")
91 private String destPortList;
93 @Column(name="action")
94 private String action;
96 @Temporal(TemporalType.TIMESTAMP)
97 @Column(name="created_date", updatable=false)
98 private Date createdDate;
100 @Temporal(TemporalType.TIMESTAMP)
101 @Column(name="modified_date", nullable=false)
102 private Date modifiedDate;
104 @ManyToOne(optional = false)
105 @JoinColumn(name="created_by")
106 private UserInfo userCreatedBy;
108 @ManyToOne(optional = false)
109 @JoinColumn(name="modified_by")
110 private UserInfo userModifiedBy;
112 public UserInfo getUserCreatedBy() {
113 return userCreatedBy;
116 public void setUserCreatedBy(UserInfo userCreatedBy) {
117 this.userCreatedBy = userCreatedBy;
120 public UserInfo getUserModifiedBy() {
121 return userModifiedBy;
124 public void setUserModifiedBy(UserInfo userModifiedBy) {
125 this.userModifiedBy = userModifiedBy;
128 private static Log LOGGER = LogFactory.getLog(TermList.class);
134 private static final Log auditLogger = LogFactory
135 .getLog("auditLogger");
137 public TermList(String string, String userid) {
140 public TermList(String domain) {
141 this.termName = domain;
145 public void prePersist() {
146 Date date = new Date();
147 this.createdDate = date;
148 this.modifiedDate = date;
149 auditLogger.debug("Added New Term Name: "+this.termName+" by "+this.userCreatedBy);
153 public void preUpdate() {
154 this.modifiedDate = new Date();
156 this.userModifiedBy =XacmlAdminAuthorization.getUserId();;
157 } catch (Exception e) {
158 LOGGER.error("Exception caused While adding Modified by Role"+e);
159 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "TermList", "Exception caused While adding Modified by Role");
161 auditLogger.debug("Updated Term Name: "+this.termName+" by "+this.userModifiedBy);
168 public void setId(int id) {
172 public String getTermName() {
173 return this.termName;
176 public void setTermName(String termName) {
177 this.termName = termName;
180 public String getTermDescription() {
181 return this.termDescription;
184 public void setDescription(String termDescription) {
185 this.termDescription = termDescription;
188 public String getFromZone() {
189 return this.fromZone;
192 public void setFromZones(String fromZone) {
193 this.fromZone = fromZone;
196 public String getToZone() {
200 public void setToZones(String toZone) {
201 this.toZone = toZone;
204 public String getSrcIPList() {
205 return this.srcIPList;
208 public void setSrcIPList(String srcIPList) {
209 this.srcIPList = srcIPList;
212 public String getDestIPList() {
213 return this.destIPList;
216 public void setDestIPList(String destIPList) {
217 this.destIPList = destIPList;
220 public String getProtocolList() {
221 return this.protocolList;
224 public void setProtocolList(String protocolList) {
225 this.protocolList = protocolList;
228 public String getPortList() {
229 return this.portList;
232 public void setPortList(String portList) {
233 this.portList = portList;
236 public String getSrcPortList() {
237 return this.srcPortList;
240 public void setSrcPortList(String srcPortList) {
241 this.srcPortList = srcPortList;
244 public String getDestPortList() {
245 return this.destPortList;
248 public void setDestPortList(String destPortList) {
249 this.destPortList = destPortList;
253 public String getAction() {
257 public void setAction(String action) {
258 this.action = action;