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=========================================================
23 package org.openecomp.policy.rest.jpa;
24 import java.io.Serializable;
25 import java.util.Date;
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.GeneratedValue;
30 import javax.persistence.GenerationType;
31 import javax.persistence.Id;
32 import javax.persistence.JoinColumn;
33 import javax.persistence.ManyToOne;
34 import javax.persistence.NamedQueries;
35 import javax.persistence.NamedQuery;
36 import javax.persistence.OrderBy;
37 import javax.persistence.PrePersist;
38 import javax.persistence.PreUpdate;
39 import javax.persistence.Table;
40 import javax.persistence.Temporal;
41 import javax.persistence.TemporalType;
43 import org.apache.commons.logging.Log;
44 import org.apache.commons.logging.LogFactory;
45 import org.openecomp.policy.rest.XacmlAdminAuthorization;
47 import org.openecomp.policy.common.logging.eelf.MessageCodes;
48 import org.openecomp.policy.common.logging.eelf.PolicyLogger;
51 @Table(name="ActionPolicyDict")
52 //@NamedQuery(name="ActionPolicyDict.findAll", query="SELECT e FROM ActionPolicyDict e ")
54 @NamedQuery(name="ActionPolicyDict.findAll", query="SELECT e FROM ActionPolicyDict e")
56 public class ActionPolicyDict implements Serializable {
57 private static final long serialVersionUID = 1L;
59 @GeneratedValue(strategy = GenerationType.AUTO)
63 @Column(name="ATTRIBUTE_NAME", nullable=false)
65 private String attributeName;
67 @Column(name="Type", nullable=false)
71 @Column(name="URL", nullable=false)
75 @Column(name="Method", nullable=false)
77 private String method;
79 @Column(name="Headers", nullable=true)
81 private String header;
83 @Column(name="Body", nullable=true)
87 @Temporal(TemporalType.TIMESTAMP)
88 @Column(name="created_date", updatable=false)
89 private Date createdDate;
91 @Column(name="description", nullable=true, length=2048)
92 private String description;
94 @Temporal(TemporalType.TIMESTAMP)
95 @Column(name="modified_date", nullable=false)
96 private Date modifiedDate;
98 @ManyToOne(optional = false)
99 @JoinColumn(name="created_by")
100 private UserInfo userCreatedBy;
102 @ManyToOne(optional = false)
103 @JoinColumn(name="modified_by")
104 private UserInfo userModifiedBy;
106 public UserInfo getUserCreatedBy() {
107 return userCreatedBy;
110 public void setUserCreatedBy(UserInfo userCreatedBy) {
111 this.userCreatedBy = userCreatedBy;
114 public UserInfo getUserModifiedBy() {
115 return userModifiedBy;
118 public void setUserModifiedBy(UserInfo userModifiedBy) {
119 this.userModifiedBy = userModifiedBy;
122 private static Log logger = LogFactory.getLog(ActionPolicyDict.class);
123 public ActionPolicyDict() {
127 public ActionPolicyDict(String string, String userid) {
131 public ActionPolicyDict(String domain) {
135 public void prePersist() {
136 Date date = new Date();
137 this.createdDate = date;
138 this.modifiedDate = date;
141 public void preUpdate() {
142 this.modifiedDate = new Date();
144 this.userModifiedBy =XacmlAdminAuthorization.getUserId();;
145 } catch (Exception e) {
146 logger.error("Exception caused While adding Modified by Role"+e);
147 // TODO:EELF Cleanup - Remove logger
148 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "ActionPolicyDict", "Exception caused While adding Modified by Role");
154 public void setId(int id) {
158 public Date getCreatedDate() {
159 return this.createdDate;
161 public void setCreatedDate(Date createdDate) {
162 this.createdDate = createdDate;
164 public String getDescription() {
165 return this.description;
167 public void setDescription(String description) {
168 this.description = description;
171 public Date getModifiedDate() {
172 return this.modifiedDate;
174 public void setModifiedDate(Date modifiedDate) {
175 this.modifiedDate = modifiedDate;
177 public String getType() {
180 public void setType(String type) {
184 public String getUrl() {
187 public void setUrl(String url) {
190 public String getMethod() {
193 public void setMethod(String method) {
194 this.method = method;
196 public String getHeader() {
199 public void setHeader(String header) {
200 this.header = header;
203 public String getBody() {
206 public void setBody(String body) {
209 public String getAttributeName() {
210 return attributeName;
212 public void setAttributeName(String attributeName) {
213 this.attributeName = attributeName;