http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/c928a415/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyItemUserPerm.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyItemUserPerm.java b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyItemUserPerm.java new file mode 100644 index 0000000..874ca20 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyItemUserPerm.java @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.ranger.entity; + +import javax.persistence.*; +import javax.xml.bind.annotation.XmlRootElement; + +@Entity +@Cacheable +@XmlRootElement +@Table(name = "x_policy_item_user_perm") +public class XXPolicyItemUserPerm extends XXDBBase implements + java.io.Serializable { + private static final long serialVersionUID = 1L; + /** + * id of the XXPolicyItemUserPerm + * <ul> + * </ul> + * + */ + @Id + @SequenceGenerator(name = "x_policy_item_user_perm_SEQ", sequenceName = "x_policy_item_user_perm_SEQ", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "x_policy_item_user_perm_SEQ") + @Column(name = "id") + protected Long id; + + /** + * policyItemId of the XXPolicyItemUserPerm + * <ul> + * </ul> + * + */ + @Column(name = "policy_item_id") + protected Long policyItemId; + + /** + * userId of the XXPolicyItemUserPerm + * <ul> + * </ul> + * + */ + @Column(name = "user_id") + protected Long userId; + + /** + * order of the XXPolicyItemUserPerm + * <ul> + * </ul> + * + */ + @Column(name = "sort_order") + protected Integer order; + + /** + * This method sets the value to the member attribute <b> id</b> . You + * cannot set null to the attribute. + * + * @param id + * Value to set member attribute <b> id</b> + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Returns the value for the member attribute <b>id</b> + * + * @return Date - value of member attribute <b>id</b> . + */ + public Long getId() { + return this.id; + } + + /** + * This method sets the value to the member attribute <b> policyItemId</b> . + * You cannot set null to the attribute. + * + * @param policyItemId + * Value to set member attribute <b> policyItemId</b> + */ + public void setPolicyItemId(Long policyItemId) { + this.policyItemId = policyItemId; + } + + /** + * Returns the value for the member attribute <b>policyItemId</b> + * + * @return Date - value of member attribute <b>policyItemId</b> . + */ + public Long getPolicyitemid() { + return this.policyItemId; + } + + /** + * This method sets the value to the member attribute <b> userId</b> . You + * cannot set null to the attribute. + * + * @param userId + * Value to set member attribute <b> userId</b> + */ + public void setUserId(Long userId) { + this.userId = userId; + } + + /** + * Returns the value for the member attribute <b>userId</b> + * + * @return Date - value of member attribute <b>userId</b> . + */ + public Long getUserid() { + return this.userId; + } + + /** + * This method sets the value to the member attribute <b> order</b> . You + * cannot set null to the attribute. + * + * @param order + * Value to set member attribute <b> order</b> + */ + public void setOrder(Integer order) { + this.order = order; + } + + /** + * Returns the value for the member attribute <b>order</b> + * + * @return Date - value of member attribute <b>order</b> . + */ + public Integer getOrder() { + return this.order; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + XXPolicyItemUserPerm other = (XXPolicyItemUserPerm) obj; + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (order == null) { + if (other.order != null) { + return false; + } + } else if (!order.equals(other.order)) { + return false; + } + if (policyItemId == null) { + if (other.policyItemId != null) { + return false; + } + } else if (!policyItemId.equals(other.policyItemId)) { + return false; + } + if (userId == null) { + if (other.userId != null) { + return false; + } + } else if (!userId.equals(other.userId)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "XXPolicyItemUserPerm [id=" + id + ", policyItemId=" + + policyItemId + ", userId=" + userId + ", order=" + order + + "]"; + } + +} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/c928a415/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyResource.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyResource.java b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyResource.java new file mode 100644 index 0000000..3303e41 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyResource.java @@ -0,0 +1,241 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.ranger.entity; + +import javax.persistence.*; +import javax.xml.bind.annotation.XmlRootElement; + +@Entity +@Cacheable +@XmlRootElement +@Table(name = "x_policy_resource") +public class XXPolicyResource extends XXDBBase implements java.io.Serializable { + private static final long serialVersionUID = 1L; + /** + * id of the XXPolicyResource + * <ul> + * </ul> + * + */ + @Id + @SequenceGenerator(name = "x_policy_resource_SEQ", sequenceName = "x_policy_resource_SEQ", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "x_policy_resource_SEQ") + @Column(name = "id") + protected Long id; + + /** + * policyId of the XXPolicyResource + * <ul> + * </ul> + * + */ + @Column(name = "policy_id") + protected Long policyId; + + /** + * resDefId of the XXPolicyResource + * <ul> + * </ul> + * + */ + @Column(name = "res_def_id") + protected Long resDefId; + + /** + * isExcludes of the XXPolicyResource + * <ul> + * </ul> + * + */ + @Column(name = "is_excludes") + protected boolean isExcludes; + + /** + * isRecursive of the XXPolicyResource + * <ul> + * </ul> + * + */ + @Column(name = "is_recursive") + protected boolean isRecursive; + + /** + * This method sets the value to the member attribute <b> id</b> . You + * cannot set null to the attribute. + * + * @param id + * Value to set member attribute <b> id</b> + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Returns the value for the member attribute <b>id</b> + * + * @return Date - value of member attribute <b>id</b> . + */ + public Long getId() { + return this.id; + } + + /** + * This method sets the value to the member attribute <b> policyId</b> . You + * cannot set null to the attribute. + * + * @param policyId + * Value to set member attribute <b> policyId</b> + */ + public void setPolicyId(Long policyId) { + this.policyId = policyId; + } + + /** + * Returns the value for the member attribute <b>policyId</b> + * + * @return Date - value of member attribute <b>policyId</b> . + */ + public Long getPolicyid() { + return this.policyId; + } + + /** + * This method sets the value to the member attribute <b> resDefId</b> . You + * cannot set null to the attribute. + * + * @param resDefId + * Value to set member attribute <b> resDefId</b> + */ + public void setResDefId(Long resDefId) { + this.resDefId = resDefId; + } + + /** + * Returns the value for the member attribute <b>resDefId</b> + * + * @return Date - value of member attribute <b>resDefId</b> . + */ + public Long getResdefid() { + return this.resDefId; + } + + /** + * This method sets the value to the member attribute <b> isExcludes</b> . + * You cannot set null to the attribute. + * + * @param isExcludes + * Value to set member attribute <b> isExcludes</b> + */ + public void setIsExcludes(boolean isExcludes) { + this.isExcludes = isExcludes; + } + + /** + * Returns the value for the member attribute <b>isExcludes</b> + * + * @return Date - value of member attribute <b>isExcludes</b> . + */ + public boolean getIsexcludes() { + return this.isExcludes; + } + + /** + * This method sets the value to the member attribute <b> isRecursive</b> . + * You cannot set null to the attribute. + * + * @param isRecursive + * Value to set member attribute <b> isRecursive</b> + */ + public void setIsRecursive(boolean isRecursive) { + this.isRecursive = isRecursive; + } + + /** + * Returns the value for the member attribute <b>isRecursive</b> + * + * @return Date - value of member attribute <b>isRecursive</b> . + */ + public boolean getIsrecursive() { + return this.isRecursive; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + XXPolicyResource other = (XXPolicyResource) obj; + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (isExcludes != other.isExcludes) { + return false; + } + if (isRecursive != other.isRecursive) { + return false; + } + if (policyId == null) { + if (other.policyId != null) { + return false; + } + } else if (!policyId.equals(other.policyId)) { + return false; + } + if (resDefId == null) { + if (other.resDefId != null) { + return false; + } + } else if (!resDefId.equals(other.resDefId)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "XXPolicyResource [" + super.toString() + " id=" + id + + ", policyId=" + policyId + ", resDefId=" + resDefId + + ", isExcludes=" + isExcludes + ", isRecursive=" + isRecursive + + "]"; + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/c928a415/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyResourceMap.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyResourceMap.java b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyResourceMap.java new file mode 100644 index 0000000..c000b39 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyResourceMap.java @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.ranger.entity; + +import javax.persistence.*; +import javax.xml.bind.annotation.XmlRootElement; + +@Entity +@Cacheable +@XmlRootElement +@Table(name = "x_policy_resource_map") +public class XXPolicyResourceMap extends XXDBBase implements + java.io.Serializable { + private static final long serialVersionUID = 1L; + /** + * id of the XXPolicyResourceMap + * <ul> + * </ul> + * + */ + @Id + @SequenceGenerator(name = "x_policy_resource_map_SEQ", sequenceName = "x_policy_resource_map_SEQ", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "x_policy_resource_map_SEQ") + @Column(name = "id") + protected Long id; + + /** + * resourceId of the XXPolicyResourceMap + * <ul> + * </ul> + * + */ + @Column(name = "resource_id") + protected Long resourceId; + + /** + * value of the XXPolicyResourceMap + * <ul> + * </ul> + * + */ + @Column(name = "value") + protected String value; + + /** + * order of the XXPolicyResourceMap + * <ul> + * </ul> + * + */ + @Column(name = "sort_order") + protected Integer order; + + /** + * This method sets the value to the member attribute <b> id</b> . You + * cannot set null to the attribute. + * + * @param id + * Value to set member attribute <b> id</b> + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Returns the value for the member attribute <b>id</b> + * + * @return Date - value of member attribute <b>id</b> . + */ + public Long getId() { + return this.id; + } + + /** + * This method sets the value to the member attribute <b> resourceId</b> . + * You cannot set null to the attribute. + * + * @param resourceId + * Value to set member attribute <b> resourceId</b> + */ + public void setResourceId(Long resourceId) { + this.resourceId = resourceId; + } + + /** + * Returns the value for the member attribute <b>resourceId</b> + * + * @return Date - value of member attribute <b>resourceId</b> . + */ + public Long getResourceid() { + return this.resourceId; + } + + /** + * This method sets the value to the member attribute <b> value</b> . You + * cannot set null to the attribute. + * + * @param value + * Value to set member attribute <b> value</b> + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Returns the value for the member attribute <b>value</b> + * + * @return Date - value of member attribute <b>value</b> . + */ + public String getValue() { + return this.value; + } + + /** + * This method sets the value to the member attribute <b> order</b> . You + * cannot set null to the attribute. + * + * @param order + * Value to set member attribute <b> order</b> + */ + public void setOrder(Integer order) { + this.order = order; + } + + /** + * Returns the value for the member attribute <b>order</b> + * + * @return Date - value of member attribute <b>order</b> . + */ + public Integer getOrder() { + return this.order; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + XXPolicyResourceMap other = (XXPolicyResourceMap) obj; + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (order == null) { + if (other.order != null) { + return false; + } + } else if (!order.equals(other.order)) { + return false; + } + if (resourceId == null) { + if (other.resourceId != null) { + return false; + } + } else if (!resourceId.equals(other.resourceId)) { + return false; + } + if (value == null) { + if (other.value != null) { + return false; + } + } else if (!value.equals(other.value)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "XXPolicyResourceMap [" + super.toString() + " id=" + id + + ", resourceId=" + resourceId + ", value=" + value + + ", order=" + order + "]"; + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/c928a415/security-admin/src/main/java/org/apache/ranger/entity/XXResourceDef.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXResourceDef.java b/security-admin/src/main/java/org/apache/ranger/entity/XXResourceDef.java new file mode 100644 index 0000000..7d5df92 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXResourceDef.java @@ -0,0 +1,668 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.ranger.entity; + +import javax.persistence.*; +import javax.xml.bind.annotation.XmlRootElement; + +@Entity +@Cacheable +@XmlRootElement +@Table(name = "x_resource_def") +public class XXResourceDef extends XXDBBase implements java.io.Serializable { + private static final long serialVersionUID = 1L; + /** + * id of the XXResourceDef + * <ul> + * </ul> + * + */ + @Id + @SequenceGenerator(name = "x_resource_def_SEQ", sequenceName = "x_resource_def_SEQ", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "x_resource_def_SEQ") + @Column(name = "id") + protected Long id; + + /** + * defId of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "def_id") + protected Long defId; + + /** + * name of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "name") + protected String name; + + /** + * type of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "type") + protected String type; + + /** + * level of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "level") + protected Integer level; + + /** + * parent of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "parent") + protected Long parent; + + /** + * mandatory of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "mandatory") + protected boolean mandatory; + + /** + * lookUpSupported of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "look_up_supported") + protected boolean lookUpSupported; + + /** + * recursiveSupported of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "recursive_supported") + protected boolean recursiveSupported; + + /** + * excludesSupported of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "excludes_supported") + protected boolean excludesSupported; + + /** + * matcher of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "matcher") + protected String matcher; + + /** + * matcherOptions of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "matcher_options") + protected String matcherOptions; + + /** + * label of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "label") + protected String label; + + /** + * description of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "description") + protected String description; + + /** + * rbKeyLabel of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "rb_key_label") + protected String rbKeyLabel; + + /** + * rbKeyDescription of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "rb_key_description") + protected String rbKeyDescription; + + /** + * order of the XXResourceDef + * <ul> + * </ul> + * + */ + @Column(name = "sort_order") + protected Integer order; + + /** + * This method sets the value to the member attribute <b> id</b> . You + * cannot set null to the attribute. + * + * @param id + * Value to set member attribute <b> id</b> + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Returns the value for the member attribute <b>id</b> + * + * @return Date - value of member attribute <b>id</b> . + */ + public Long getId() { + return this.id; + } + + /** + * This method sets the value to the member attribute <b> defId</b> . You + * cannot set null to the attribute. + * + * @param defId + * Value to set member attribute <b> defId</b> + */ + public void setDefid(Long defId) { + this.defId = defId; + } + + /** + * Returns the value for the member attribute <b>defId</b> + * + * @return Date - value of member attribute <b>defId</b> . + */ + public Long getDefid() { + return this.defId; + } + + /** + * This method sets the value to the member attribute <b> name</b> . You + * cannot set null to the attribute. + * + * @param name + * Value to set member attribute <b> name</b> + */ + public void setName(String name) { + this.name = name; + } + + /** + * Returns the value for the member attribute <b>name</b> + * + * @return Date - value of member attribute <b>name</b> . + */ + public String getName() { + return this.name; + } + + /** + * This method sets the value to the member attribute <b> type</b> . You + * cannot set null to the attribute. + * + * @param type + * Value to set member attribute <b> type</b> + */ + public void setType(String type) { + this.type = type; + } + + /** + * Returns the value for the member attribute <b>type</b> + * + * @return Date - value of member attribute <b>type</b> . + */ + public String getType() { + return this.type; + } + + /** + * This method sets the value to the member attribute <b> level</b> . You + * cannot set null to the attribute. + * + * @param level + * Value to set member attribute <b> level</b> + */ + public void setLevel(Integer level) { + this.level = level; + } + + /** + * Returns the value for the member attribute <b>level</b> + * + * @return Date - value of member attribute <b>level</b> . + */ + public Integer getLevel() { + return this.level; + } + + /** + * This method sets the value to the member attribute <b> parent</b> . You + * cannot set null to the attribute. + * + * @param parent + * Value to set member attribute <b> parent</b> + */ + public void setParent(Long parent) { + this.parent = parent; + } + + /** + * Returns the value for the member attribute <b>parent</b> + * + * @return Date - value of member attribute <b>parent</b> . + */ + public Long getParent() { + return this.parent; + } + + /** + * This method sets the value to the member attribute <b> mandatory</b> . + * You cannot set null to the attribute. + * + * @param mandatory + * Value to set member attribute <b> mandatory</b> + */ + public void setMandatory(boolean mandatory) { + this.mandatory = mandatory; + } + + /** + * Returns the value for the member attribute <b>mandatory</b> + * + * @return Date - value of member attribute <b>mandatory</b> . + */ + public boolean getMandatory() { + return this.mandatory; + } + + /** + * This method sets the value to the member attribute <b> + * lookUpSupported</b> . You cannot set null to the attribute. + * + * @param lookUpSupported + * Value to set member attribute <b> lookUpSupported</b> + */ + public void setLookupsupported(boolean lookUpSupported) { + this.lookUpSupported = lookUpSupported; + } + + /** + * Returns the value for the member attribute <b>lookUpSupported</b> + * + * @return Date - value of member attribute <b>lookUpSupported</b> . + */ + public boolean getLookupsupported() { + return this.lookUpSupported; + } + + /** + * This method sets the value to the member attribute <b> + * recursiveSupported</b> . You cannot set null to the attribute. + * + * @param recursiveSupported + * Value to set member attribute <b> recursiveSupported</b> + */ + public void setRecursivesupported(boolean recursiveSupported) { + this.recursiveSupported = recursiveSupported; + } + + /** + * Returns the value for the member attribute <b>recursiveSupported</b> + * + * @return Date - value of member attribute <b>recursiveSupported</b> . + */ + public boolean getRecursivesupported() { + return this.recursiveSupported; + } + + /** + * This method sets the value to the member attribute <b> + * excludesSupported</b> . You cannot set null to the attribute. + * + * @param excludesSupported + * Value to set member attribute <b> excludesSupported</b> + */ + public void setExcludessupported(boolean excludesSupported) { + this.excludesSupported = excludesSupported; + } + + /** + * Returns the value for the member attribute <b>excludesSupported</b> + * + * @return Date - value of member attribute <b>excludesSupported</b> . + */ + public boolean getExcludessupported() { + return this.excludesSupported; + } + + /** + * This method sets the value to the member attribute <b> matcher</b> . You + * cannot set null to the attribute. + * + * @param matcher + * Value to set member attribute <b> matcher</b> + */ + public void setMatcher(String matcher) { + this.matcher = matcher; + } + + /** + * Returns the value for the member attribute <b>matcher</b> + * + * @return Date - value of member attribute <b>matcher</b> . + */ + public String getMatcher() { + return this.matcher; + } + + /** + * This method sets the value to the member attribute <b> matcherOptions</b> + * . You cannot set null to the attribute. + * + * @param matcherOptions + * Value to set member attribute <b> matcherOptions</b> + */ + public void setMatcheroptions(String matcherOptions) { + this.matcherOptions = matcherOptions; + } + + /** + * Returns the value for the member attribute <b>matcherOptions</b> + * + * @return Date - value of member attribute <b>matcherOptions</b> . + */ + public String getMatcheroptions() { + return this.matcherOptions; + } + + /** + * This method sets the value to the member attribute <b> label</b> . You + * cannot set null to the attribute. + * + * @param label + * Value to set member attribute <b> label</b> + */ + public void setLabel(String label) { + this.label = label; + } + + /** + * Returns the value for the member attribute <b>label</b> + * + * @return Date - value of member attribute <b>label</b> . + */ + public String getLabel() { + return this.label; + } + + /** + * This method sets the value to the member attribute <b> description</b> . + * You cannot set null to the attribute. + * + * @param description + * Value to set member attribute <b> description</b> + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Returns the value for the member attribute <b>description</b> + * + * @return Date - value of member attribute <b>description</b> . + */ + public String getDescription() { + return this.description; + } + + /** + * This method sets the value to the member attribute <b> rbKeyLabel</b> . + * You cannot set null to the attribute. + * + * @param rbKeyLabel + * Value to set member attribute <b> rbKeyLabel</b> + */ + public void setRbkeylabel(String rbKeyLabel) { + this.rbKeyLabel = rbKeyLabel; + } + + /** + * Returns the value for the member attribute <b>rbKeyLabel</b> + * + * @return Date - value of member attribute <b>rbKeyLabel</b> . + */ + public String getRbkeylabel() { + return this.rbKeyLabel; + } + + /** + * This method sets the value to the member attribute <b> + * rbKeyDescription</b> . You cannot set null to the attribute. + * + * @param rbKeyDescription + * Value to set member attribute <b> rbKeyDescription</b> + */ + public void setRbkeydescription(String rbKeyDescription) { + this.rbKeyDescription = rbKeyDescription; + } + + /** + * Returns the value for the member attribute <b>rbKeyDescription</b> + * + * @return Date - value of member attribute <b>rbKeyDescription</b> . + */ + public String getRbkeydescription() { + return this.rbKeyDescription; + } + + /** + * This method sets the value to the member attribute <b> order</b> . You + * cannot set null to the attribute. + * + * @param order + * Value to set member attribute <b> order</b> + */ + public void setOrder(Integer order) { + this.order = order; + } + + /** + * Returns the value for the member attribute <b>order</b> + * + * @return Date - value of member attribute <b>order</b> . + */ + public Integer getOrder() { + return this.order; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + XXResourceDef other = (XXResourceDef) obj; + if (defId == null) { + if (other.defId != null) { + return false; + } + } else if (!defId.equals(other.defId)) { + return false; + } + if (description == null) { + if (other.description != null) { + return false; + } + } else if (!description.equals(other.description)) { + return false; + } + if (excludesSupported != other.excludesSupported) { + return false; + } + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (label == null) { + if (other.label != null) { + return false; + } + } else if (!label.equals(other.label)) { + return false; + } + if (level == null) { + if (other.level != null) { + return false; + } + } else if (!level.equals(other.level)) { + return false; + } + if (lookUpSupported != other.lookUpSupported) { + return false; + } + if (mandatory != other.mandatory) { + return false; + } + if (matcher == null) { + if (other.matcher != null) { + return false; + } + } else if (!matcher.equals(other.matcher)) { + return false; + } + if (matcherOptions == null) { + if (other.matcherOptions != null) { + return false; + } + } else if (!matcherOptions.equals(other.matcherOptions)) { + return false; + } + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + if (order == null) { + if (other.order != null) { + return false; + } + } else if (!order.equals(other.order)) { + return false; + } + if (parent == null) { + if (other.parent != null) { + return false; + } + } else if (!parent.equals(other.parent)) { + return false; + } + if (rbKeyDescription == null) { + if (other.rbKeyDescription != null) { + return false; + } + } else if (!rbKeyDescription.equals(other.rbKeyDescription)) { + return false; + } + if (rbKeyLabel == null) { + if (other.rbKeyLabel != null) { + return false; + } + } else if (!rbKeyLabel.equals(other.rbKeyLabel)) { + return false; + } + if (recursiveSupported != other.recursiveSupported) { + return false; + } + if (type == null) { + if (other.type != null) { + return false; + } + } else if (!type.equals(other.type)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "XXResourceDef [" + super.toString() + " id=" + id + ", defId=" + + defId + ", name=" + name + ", type=" + type + ", level=" + + level + ", parent=" + parent + ", mandatory=" + mandatory + + ", lookUpSupported=" + lookUpSupported + + ", recursiveSupported=" + recursiveSupported + + ", excludesSupported=" + excludesSupported + ", matcher=" + + matcher + ", matcherOptions=" + matcherOptions + ", label=" + + label + ", description=" + description + ", rbKeyLabel=" + + rbKeyLabel + ", rbKeyDescription=" + rbKeyDescription + + ", order=" + order + "]"; + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/c928a415/security-admin/src/main/java/org/apache/ranger/entity/XXService.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXService.java b/security-admin/src/main/java/org/apache/ranger/entity/XXService.java new file mode 100644 index 0000000..9d6cf4d --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXService.java @@ -0,0 +1,390 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.ranger.entity; + +import java.util.Date; + +import javax.persistence.*; +import javax.xml.bind.annotation.XmlRootElement; + +@Entity +@Cacheable +@XmlRootElement +@Table(name = "x_service") +public class XXService extends XXDBBase implements java.io.Serializable { + private static final long serialVersionUID = 1L; + /** + * id of the XXService + * <ul> + * </ul> + * + */ + @Id + @SequenceGenerator(name = "x_service_SEQ", sequenceName = "x_service_SEQ", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "x_service_SEQ") + @Column(name = "id") + protected Long id; + + /** + * Global Id for the object + * <ul> + * <li>The maximum length for this attribute is <b>512</b>. + * </ul> + * + */ + @Column(name = "guid", unique = true, nullable = false, length = 512) + protected String guid; + + /** + * version of the XXServiceDef + * <ul> + * </ul> + * + */ + @Column(name = "version") + protected Long version; + + /** + * type of the XXService + * <ul> + * </ul> + * + */ + @Column(name = "type") + protected Long type; + + /** + * name of the XXService + * <ul> + * </ul> + * + */ + @Column(name = "name") + protected String name; + + /** + * policyVersion of the XXService + * <ul> + * </ul> + * + */ + @Column(name = "policy_version") + protected Long policyVersion; + + /** + * policyUpdateTime of the XXService + * <ul> + * </ul> + * + */ + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "policy_update_time") + protected Date policyUpdateTime; + + /** + * description of the XXService + * <ul> + * </ul> + * + */ + @Column(name = "description") + protected String description; + + /** + * isEnabled of the XXService + * <ul> + * </ul> + * + */ + @Column(name = "is_enabled") + protected Boolean isEnabled; + + /** + * This method sets the value to the member attribute <b> id</b> . You + * cannot set null to the attribute. + * + * @param id + * Value to set member attribute <b> id</b> + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Returns the value for the member attribute <b>id</b> + * + * @return Date - value of member attribute <b>id</b> . + */ + public Long getId() { + return this.id; + } + + /** + * @return the gUID + */ + public String getGuid() { + return this.guid; + } + + /** + * @param guid + * the gUID to set + */ + public void setGuid(String guid) { + this.guid = guid; + } + + /** + * This method sets the value to the member attribute <b> version</b> . You + * cannot set null to the attribute. + * + * @param version + * Value to set member attribute <b> version</b> + */ + public void setVersion(Long version) { + this.version = version; + } + + /** + * Returns the value for the member attribute <b>version</b> + * + * @return Date - value of member attribute <b>version</b> . + */ + public Long getVersion() { + return this.version; + } + + /** + * This method sets the value to the member attribute <b> type</b> . You + * cannot set null to the attribute. + * + * @param type + * Value to set member attribute <b> type</b> + */ + public void setType(Long type) { + this.type = type; + } + + /** + * Returns the value for the member attribute <b>type</b> + * + * @return Date - value of member attribute <b>type</b> . + */ + public Long getType() { + return this.type; + } + + /** + * This method sets the value to the member attribute <b> name</b> . You + * cannot set null to the attribute. + * + * @param name + * Value to set member attribute <b> name</b> + */ + public void setName(String name) { + this.name = name; + } + + /** + * Returns the value for the member attribute <b>name</b> + * + * @return Date - value of member attribute <b>name</b> . + */ + public String getName() { + return this.name; + } + + /** + * This method sets the value to the member attribute <b> policyVersion</b> + * . You cannot set null to the attribute. + * + * @param policyVersion + * Value to set member attribute <b> policyVersion</b> + */ + public void setPolicyVersion(Long policyVersion) { + this.policyVersion = policyVersion; + } + + /** + * Returns the value for the member attribute <b>policyVersion</b> + * + * @return Date - value of member attribute <b>policyVersion</b> . + */ + public Long getPolicyVersion() { + return this.policyVersion; + } + + /** + * This method sets the value to the member attribute <b> + * policyUpdateTime</b> . You cannot set null to the attribute. + * + * @param policyUpdateTime + * Value to set member attribute <b> policyUpdateTime</b> + */ + public void setPolicyUpdateTime(Date policyUpdateTime) { + this.policyUpdateTime = policyUpdateTime; + } + + /** + * Returns the value for the member attribute <b>policyUpdateTime</b> + * + * @return Date - value of member attribute <b>policyUpdateTime</b> . + */ + public Date getPolicyUpdateTime() { + return this.policyUpdateTime; + } + + /** + * This method sets the value to the member attribute <b> description</b> . + * You cannot set null to the attribute. + * + * @param description + * Value to set member attribute <b> description</b> + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Returns the value for the member attribute <b>description</b> + * + * @return Date - value of member attribute <b>description</b> . + */ + public String getDescription() { + return this.description; + } + + /** + * This method sets the value to the member attribute <b> isEnabled</b> . + * You cannot set null to the attribute. + * + * @param isEnabled + * Value to set member attribute <b> isEnabled</b> + */ + public void setIsEnabled(Boolean isEnabled) { + this.isEnabled = isEnabled; + } + + /** + * Returns the value for the member attribute <b>isEnabled</b> + * + * @return Date - value of member attribute <b>isEnabled</b> . + */ + public Boolean getIsenabled() { + return this.isEnabled; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + if (this == obj) { + return true; + } + if (getClass() != obj.getClass()) { + return false; + } + XXService other = (XXService) obj; + if (description == null) { + if (other.description != null) { + return false; + } + } else if (!description.equals(other.description)) { + return false; + } + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (isEnabled == null) { + if (other.isEnabled != null) { + return false; + } + } else if (!isEnabled.equals(other.isEnabled)) { + return false; + } + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + if (policyUpdateTime == null) { + if (other.policyUpdateTime != null) { + return false; + } + } else if (!policyUpdateTime.equals(other.policyUpdateTime)) { + return false; + } + if (policyVersion == null) { + if (other.policyVersion != null) { + return false; + } + } else if (!policyVersion.equals(other.policyVersion)) { + return false; + } + if (type == null) { + if (other.type != null) { + return false; + } + } else if (!type.equals(other.type)) { + return false; + } + if (version == null) { + if (other.version != null) { + return false; + } + } else if (!version.equals(other.version)) { + return false; + } + if (guid == null) { + if (other.guid != null) { + return false; + } + } else if (!guid.equals(other.guid)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "XXService [" + super.toString() + " id=" + id + ", guid=" + + guid + ", version=" + version + ", type=" + type + ", name=" + + name + ", policyVersion=" + policyVersion + + ", policyUpdateTime=" + policyUpdateTime + ", description=" + + description + ", isEnabled=" + isEnabled + "]"; + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/c928a415/security-admin/src/main/java/org/apache/ranger/entity/XXServiceConfigDef.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceConfigDef.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceConfigDef.java new file mode 100644 index 0000000..524c2a1 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceConfigDef.java @@ -0,0 +1,502 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.ranger.entity; + +import javax.persistence.*; +import javax.xml.bind.annotation.XmlRootElement; + +@Entity +@Cacheable +@XmlRootElement +@Table(name = "x_service_config_def") +public class XXServiceConfigDef extends XXDBBase implements + java.io.Serializable { + private static final long serialVersionUID = 1L; + /** + * id of the XXServiceConfigDef + * <ul> + * </ul> + * + */ + @Id + @SequenceGenerator(name = "x_service_config_def_SEQ", sequenceName = "x_service_config_def_SEQ", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "x_service_config_def_SEQ") + @Column(name = "id") + protected Long id; + + /** + * defId of the XXServiceConfigDef + * <ul> + * </ul> + * + */ + @Column(name = "def_id") + protected Long defId; + + /** + * name of the XXServiceConfigDef + * <ul> + * </ul> + * + */ + @Column(name = "name") + protected String name; + + /** + * type of the XXServiceConfigDef + * <ul> + * </ul> + * + */ + @Column(name = "type") + protected String type; + + /** + * subType of the XXServiceConfigDef + * <ul> + * </ul> + * + */ + @Column(name = "sub_type") + protected String subType; + + /** + * isMandatory of the XXServiceConfigDef + * <ul> + * </ul> + * + */ + @Column(name = "is_mandatory") + protected boolean isMandatory; + + /** + * defaultValue of the XXServiceConfigDef + * <ul> + * </ul> + * + */ + @Column(name = "default_value") + protected String defaultValue; + + /** + * label of the XXServiceConfigDef + * <ul> + * </ul> + * + */ + @Column(name = "label") + protected String label; + + /** + * description of the XXServiceConfigDef + * <ul> + * </ul> + * + */ + @Column(name = "description") + protected String description; + + /** + * rbKeyLabel of the XXServiceConfigDef + * <ul> + * </ul> + * + */ + @Column(name = "rb_key_label") + protected String rbKeyLabel; + + /** + * rbKeyDecription of the XXServiceConfigDef + * <ul> + * </ul> + * + */ + @Column(name = "rb_key_decription") + protected String rbKeyDescription; + + /** + * order of the XXServiceConfigDef + * <ul> + * </ul> + * + */ + @Column(name = "sort_order") + protected Integer order; + + /** + * This method sets the value to the member attribute <b> id</b> . You + * cannot set null to the attribute. + * + * @param id + * Value to set member attribute <b> id</b> + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Returns the value for the member attribute <b>id</b> + * + * @return Date - value of member attribute <b>id</b> . + */ + public Long getId() { + return this.id; + } + + /** + * This method sets the value to the member attribute <b> defId</b> . You + * cannot set null to the attribute. + * + * @param defId + * Value to set member attribute <b> defId</b> + */ + public void setDefid(Long defId) { + this.defId = defId; + } + + /** + * Returns the value for the member attribute <b>defId</b> + * + * @return Date - value of member attribute <b>defId</b> . + */ + public Long getDefid() { + return this.defId; + } + + /** + * This method sets the value to the member attribute <b> name</b> . You + * cannot set null to the attribute. + * + * @param name + * Value to set member attribute <b> name</b> + */ + public void setName(String name) { + this.name = name; + } + + /** + * Returns the value for the member attribute <b>name</b> + * + * @return Date - value of member attribute <b>name</b> . + */ + public String getName() { + return this.name; + } + + /** + * This method sets the value to the member attribute <b> type</b> . You + * cannot set null to the attribute. + * + * @param type + * Value to set member attribute <b> type</b> + */ + public void setType(String type) { + this.type = type; + } + + /** + * Returns the value for the member attribute <b>type</b> + * + * @return Date - value of member attribute <b>type</b> . + */ + public String getType() { + return this.type; + } + + /** + * This method sets the value to the member attribute <b> subType</b> . You + * cannot set null to the attribute. + * + * @param subType + * Value to set member attribute <b> subType</b> + */ + public void setSubtype(String subType) { + this.subType = subType; + } + + /** + * Returns the value for the member attribute <b>subType</b> + * + * @return Date - value of member attribute <b>subType</b> . + */ + public String getSubtype() { + return this.subType; + } + + /** + * This method sets the value to the member attribute <b> isMandatory</b> . + * You cannot set null to the attribute. + * + * @param isMandatory + * Value to set member attribute <b> isMandatory</b> + */ + public void setIsMandatory(boolean isMandatory) { + this.isMandatory = isMandatory; + } + + /** + * Returns the value for the member attribute <b>isMandatory</b> + * + * @return Date - value of member attribute <b>isMandatory</b> . + */ + public boolean getIsMandatory() { + return this.isMandatory; + } + + /** + * This method sets the value to the member attribute <b> defaultValue</b> . + * You cannot set null to the attribute. + * + * @param defaultValue + * Value to set member attribute <b> defaultValue</b> + */ + public void setDefaultvalue(String defaultValue) { + this.defaultValue = defaultValue; + } + + /** + * Returns the value for the member attribute <b>defaultValue</b> + * + * @return Date - value of member attribute <b>defaultValue</b> . + */ + public String getDefaultvalue() { + return this.defaultValue; + } + + /** + * This method sets the value to the member attribute <b> label</b> . You + * cannot set null to the attribute. + * + * @param label + * Value to set member attribute <b> label</b> + */ + public void setLabel(String label) { + this.label = label; + } + + /** + * Returns the value for the member attribute <b>label</b> + * + * @return Date - value of member attribute <b>label</b> . + */ + public String getLabel() { + return this.label; + } + + /** + * This method sets the value to the member attribute <b> description</b> . + * You cannot set null to the attribute. + * + * @param description + * Value to set member attribute <b> description</b> + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Returns the value for the member attribute <b>description</b> + * + * @return Date - value of member attribute <b>description</b> . + */ + public String getDescription() { + return this.description; + } + + /** + * This method sets the value to the member attribute <b> rbKeyLabel</b> . + * You cannot set null to the attribute. + * + * @param rbKeyLabel + * Value to set member attribute <b> rbKeyLabel</b> + */ + public void setRbkeylabel(String rbKeyLabel) { + this.rbKeyLabel = rbKeyLabel; + } + + /** + * Returns the value for the member attribute <b>rbKeyLabel</b> + * + * @return Date - value of member attribute <b>rbKeyLabel</b> . + */ + public String getRbkeylabel() { + return this.rbKeyLabel; + } + + /** + * This method sets the value to the member attribute <b> + * rbKeyDecription</b> . You cannot set null to the attribute. + * + * @param rbKeyDescription + * Value to set member attribute <b> rbKeyDecription</b> + */ + public void setRbkeydescription(String rbKeyDescription) { + this.rbKeyDescription = rbKeyDescription; + } + + /** + * Returns the value for the member attribute <b>rbKeyDecription</b> + * + * @return Date - value of member attribute <b>rbKeyDecription</b> . + */ + public String getRbkeydescription() { + return this.rbKeyDescription; + } + + /** + * This method sets the value to the member attribute <b> order</b> . You + * cannot set null to the attribute. + * + * @param order + * Value to set member attribute <b> order</b> + */ + public void setOrder(Integer order) { + this.order = order; + } + + /** + * Returns the value for the member attribute <b>order</b> + * + * @return Date - value of member attribute <b>order</b> . + */ + public Integer getOrder() { + return this.order; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + XXServiceConfigDef other = (XXServiceConfigDef) obj; + if (defId == null) { + if (other.defId != null) { + return false; + } + } else if (!defId.equals(other.defId)) { + return false; + } + if (defaultValue == null) { + if (other.defaultValue != null) { + return false; + } + } else if (!defaultValue.equals(other.defaultValue)) { + return false; + } + if (description == null) { + if (other.description != null) { + return false; + } + } else if (!description.equals(other.description)) { + return false; + } + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (isMandatory != other.isMandatory) { + return false; + } + if (label == null) { + if (other.label != null) { + return false; + } + } else if (!label.equals(other.label)) { + return false; + } + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + if (order == null) { + if (other.order != null) { + return false; + } + } else if (!order.equals(other.order)) { + return false; + } + if (rbKeyDescription == null) { + if (other.rbKeyDescription != null) { + return false; + } + } else if (!rbKeyDescription.equals(other.rbKeyDescription)) { + return false; + } + if (rbKeyLabel == null) { + if (other.rbKeyLabel != null) { + return false; + } + } else if (!rbKeyLabel.equals(other.rbKeyLabel)) { + return false; + } + if (subType == null) { + if (other.subType != null) { + return false; + } + } else if (!subType.equals(other.subType)) { + return false; + } + if (type == null) { + if (other.type != null) { + return false; + } + } else if (!type.equals(other.type)) { + return false; + } + + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "XXServiceConfigDef [" + super.toString() + " id=" + id + + ", defId=" + defId + ", name=" + name + ", type=" + type + + ", subType=" + subType + ", isMandatory=" + isMandatory + + ", defaultValue=" + defaultValue + ", label=" + label + + ", description=" + description + ", rbKeyLabel=" + rbKeyLabel + + ", rbKeyDecription=" + rbKeyDescription + ", order=" + order + + "]"; + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/c928a415/security-admin/src/main/java/org/apache/ranger/entity/XXServiceConfigMap.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceConfigMap.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceConfigMap.java new file mode 100644 index 0000000..ff9a6f8 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceConfigMap.java @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.ranger.entity; + +import javax.persistence.*; +import javax.xml.bind.annotation.XmlRootElement; + +@Entity +@Cacheable +@XmlRootElement +@Table(name = "x_service_config_map") +public class XXServiceConfigMap extends XXDBBase implements + java.io.Serializable { + private static final long serialVersionUID = 1L; + /** + * id of the XXServiceConfigMap + * <ul> + * </ul> + * + */ + @Id + @SequenceGenerator(name = "x_service_config_map_SEQ", sequenceName = "x_service_config_map_SEQ", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "x_service_config_map_SEQ") + @Column(name = "id") + protected Long id; + + /** + * service of the XXServiceConfigMap + * <ul> + * </ul> + * + */ + @Column(name = "service") + protected Long serviceId; + + /** + * configKey of the XXServiceConfigMap + * <ul> + * </ul> + * + */ + @Column(name = "config_key") + protected String configKey; + + /** + * configValue of the XXServiceConfigMap + * <ul> + * </ul> + * + */ + @Column(name = "config_value") + protected String configValue; + + /** + * This method sets the value to the member attribute <b> id</b> . You + * cannot set null to the attribute. + * + * @param id + * Value to set member attribute <b> id</b> + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Returns the value for the member attribute <b>id</b> + * + * @return Date - value of member attribute <b>id</b> . + */ + public Long getId() { + return this.id; + } + + /** + * This method sets the value to the member attribute <b> service</b> . You + * cannot set null to the attribute. + * + * @param service + * Value to set member attribute <b> service</b> + */ + public void setServiceId(Long serviceId) { + this.serviceId = serviceId; + } + + /** + * Returns the value for the member attribute <b>service</b> + * + * @return Date - value of member attribute <b>service</b> . + */ + public Long getServiceId() { + return this.serviceId; + } + + /** + * This method sets the value to the member attribute <b> configKey</b> . + * You cannot set null to the attribute. + * + * @param configKey + * Value to set member attribute <b> configKey</b> + */ + public void setConfigkey(String configKey) { + this.configKey = configKey; + } + + /** + * Returns the value for the member attribute <b>configKey</b> + * + * @return Date - value of member attribute <b>configKey</b> . + */ + public String getConfigkey() { + return this.configKey; + } + + /** + * This method sets the value to the member attribute <b> configValue</b> . + * You cannot set null to the attribute. + * + * @param configValue + * Value to set member attribute <b> configValue</b> + */ + public void setConfigvalue(String configValue) { + this.configValue = configValue; + } + + /** + * Returns the value for the member attribute <b>configValue</b> + * + * @return Date - value of member attribute <b>configValue</b> . + */ + public String getConfigvalue() { + return this.configValue; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + XXServiceConfigMap other = (XXServiceConfigMap) obj; + if (configKey == null) { + if (other.configKey != null) { + return false; + } + } else if (!configKey.equals(other.configKey)) { + return false; + } + if (configValue == null) { + if (other.configValue != null) { + return false; + } + } else if (!configValue.equals(other.configValue)) { + return false; + } + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (serviceId == null) { + if (other.serviceId != null) { + return false; + } + } else if (!serviceId.equals(other.serviceId)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "XXServiceConfigMap [" + super.toString() + " id=" + id + + ", service=" + serviceId + ", configKey=" + configKey + + ", configValue=" + configValue + "]"; + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/c928a415/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDef.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDef.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDef.java new file mode 100644 index 0000000..4e52eb9 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDef.java @@ -0,0 +1,422 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.ranger.entity; + +import javax.persistence.*; +import javax.xml.bind.annotation.XmlRootElement; + +@Entity +@Cacheable +@XmlRootElement +@Table(name = "x_service_def") +public class XXServiceDef extends XXDBBase implements java.io.Serializable { + private static final long serialVersionUID = 1L; + /** + * id of the XXServiceDef + * <ul> + * </ul> + * + */ + @Id + @SequenceGenerator(name = "x_service_def_SEQ", sequenceName = "x_service_def_SEQ", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "x_service_def_SEQ") + @Column(name = "id") + protected Long id; + + /** + * Global Id for the object + * <ul> + * <li>The maximum length for this attribute is <b>512</b>. + * </ul> + * + */ + @Column(name = "guid", unique = true, nullable = false, length = 512) + protected String guid; + /** + * version of the XXServiceDef + * <ul> + * </ul> + * + */ + @Column(name = "version") + protected Long version; + + /** + * name of the XXServiceDef + * <ul> + * </ul> + * + */ + @Column(name = "name") + protected String name; + + /** + * implClassName of the XXServiceDef + * <ul> + * </ul> + * + */ + @Column(name = "impl_class_name") + protected String implClassName; + + /** + * label of the XXServiceDef + * <ul> + * </ul> + * + */ + @Column(name = "label") + protected String label; + + /** + * description of the XXServiceDef + * <ul> + * </ul> + * + */ + @Column(name = "description") + protected String description; + + /** + * rbKeyLabel of the XXServiceDef + * <ul> + * </ul> + * + */ + @Column(name = "rb_key_label") + protected String rbKeyLabel; + + /** + * rbKeyDescription of the XXServiceDef + * <ul> + * </ul> + * + */ + @Column(name = "rb_key_description") + protected String rbKeyDescription; + /** + * isEnabled of the XXPolicy + * <ul> + * </ul> + * + */ + @Column(name = "is_enabled") + protected Boolean isEnabled; + + /** + * This method sets the value to the member attribute <b> id</b> . You + * cannot set null to the attribute. + * + * @param id + * Value to set member attribute <b> id</b> + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Returns the value for the member attribute <b>id</b> + * + * @return Date - value of member attribute <b>id</b> . + */ + public Long getId() { + return this.id; + } + + /** + * @return the gUID + */ + public String getGuid() { + return this.guid; + } + + /** + * @param guid + * the gUID to set + */ + public void setGuid(String guid) { + this.guid = guid; + } + + /** + * This method sets the value to the member attribute <b> version</b> . You + * cannot set null to the attribute. + * + * @param version + * Value to set member attribute <b> version</b> + */ + public void setVersion(Long version) { + this.version = version; + } + + /** + * Returns the value for the member attribute <b>version</b> + * + * @return Date - value of member attribute <b>version</b> . + */ + public Long getVersion() { + return this.version; + } + + /** + * This method sets the value to the member attribute <b> name</b> . You + * cannot set null to the attribute. + * + * @param name + * Value to set member attribute <b> name</b> + */ + public void setName(String name) { + this.name = name; + } + + /** + * Returns the value for the member attribute <b>name</b> + * + * @return Date - value of member attribute <b>name</b> . + */ + public String getName() { + return this.name; + } + + /** + * This method sets the value to the member attribute <b> implClassName</b> + * . You cannot set null to the attribute. + * + * @param implClassName + * Value to set member attribute <b> implClassName</b> + */ + public void setImplclassname(String implClassName) { + this.implClassName = implClassName; + } + + /** + * Returns the value for the member attribute <b>implClassName</b> + * + * @return Date - value of member attribute <b>implClassName</b> . + */ + public String getImplclassname() { + return this.implClassName; + } + + /** + * This method sets the value to the member attribute <b> label</b> . You + * cannot set null to the attribute. + * + * @param label + * Value to set member attribute <b> label</b> + */ + public void setLabel(String label) { + this.label = label; + } + + /** + * Returns the value for the member attribute <b>label</b> + * + * @return Date - value of member attribute <b>label</b> . + */ + public String getLabel() { + return this.label; + } + + /** + * This method sets the value to the member attribute <b> description</b> . + * You cannot set null to the attribute. + * + * @param description + * Value to set member attribute <b> description</b> + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Returns the value for the member attribute <b>description</b> + * + * @return Date - value of member attribute <b>description</b> . + */ + public String getDescription() { + return this.description; + } + + /** + * This method sets the value to the member attribute <b> rbKeyLabel</b> . + * You cannot set null to the attribute. + * + * @param rbKeyLabel + * Value to set member attribute <b> rbKeyLabel</b> + */ + public void setRbkeylabel(String rbKeyLabel) { + this.rbKeyLabel = rbKeyLabel; + } + + /** + * Returns the value for the member attribute <b>rbKeyLabel</b> + * + * @return Date - value of member attribute <b>rbKeyLabel</b> . + */ + public String getRbkeylabel() { + return this.rbKeyLabel; + } + + /** + * This method sets the value to the member attribute <b> + * rbKeyDescription</b> . You cannot set null to the attribute. + * + * @param rbKeyDescription + * Value to set member attribute <b> rbKeyDescription</b> + */ + public void setRbkeydescription(String rbKeyDescription) { + this.rbKeyDescription = rbKeyDescription; + } + + /** + * Returns the value for the member attribute <b>rbKeyDescription</b> + * + * @return Date - value of member attribute <b>rbKeyDescription</b> . + */ + public String getRbkeydescription() { + return this.rbKeyDescription; + } + + /** + * This method sets the value to the member attribute <b> isEnabled</b> . + * You cannot set null to the attribute. + * + * @param isEnabled + * Value to set member attribute <b> isEnabled</b> + */ + public void setIsEnabled(boolean isEnabled) { + this.isEnabled = isEnabled; + } + + /** + * Returns the value for the member attribute <b>isEnabled</b> + * + * @return Date - value of member attribute <b>isEnabled</b> . + */ + public boolean getIsEnabled() { + return this.isEnabled; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (!super.equals(obj)) { + return false; + } + if (this == obj) { + return true; + } + if (getClass() != obj.getClass()) { + return false; + } + XXServiceDef other = (XXServiceDef) obj; + if (description == null) { + if (other.description != null) { + return false; + } + } else if (!description.equals(other.description)) { + return false; + } + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (guid == null) { + if (other.guid != null) { + return false; + } + } else if (!guid.equals(other.guid)) { + return false; + } + if (implClassName == null) { + if (other.implClassName != null) { + return false; + } + } else if (!implClassName.equals(other.implClassName)) { + return false; + } + if (label == null) { + if (other.label != null) { + return false; + } + } else if (!label.equals(other.label)) { + return false; + } + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + if (rbKeyDescription == null) { + if (other.rbKeyDescription != null) { + return false; + } + } else if (!rbKeyDescription.equals(other.rbKeyDescription)) { + return false; + } + if (rbKeyLabel == null) { + if (other.rbKeyLabel != null) { + return false; + } + } else if (!rbKeyLabel.equals(other.rbKeyLabel)) { + return false; + } + if (version == null) { + if (other.version != null) { + return false; + } + } else if (!version.equals(other.version)) { + return false; + } + if (isEnabled == null) { + if (other.isEnabled != null) { + return false; + } + } else if (!isEnabled.equals(other.isEnabled)) { + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "XXServiceDef [" + super.toString() + " id=" + id + ", guid=" + + guid + ", version=" + version + ", name=" + name + + ", implClassName=" + implClassName + ", label=" + label + + ", description=" + description + ", rbKeyLabel=" + rbKeyLabel + + ", rbKeyDescription=" + rbKeyDescription + ", isEnabled" + + isEnabled + "]"; + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/c928a415/security-admin/src/main/java/org/apache/ranger/service/RangerAuditFields.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerAuditFields.java b/security-admin/src/main/java/org/apache/ranger/service/RangerAuditFields.java new file mode 100644 index 0000000..c5033ad --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/service/RangerAuditFields.java @@ -0,0 +1,17 @@ +package org.apache.ranger.service; + +import org.apache.ranger.entity.XXDBBase; +import org.springframework.stereotype.Component; + +@Component +public class RangerAuditFields<T extends XXDBBase> { + + public T populateAuditFields(T xObj, T parentObj) { + xObj.setCreateTime(parentObj.getCreateTime()); + xObj.setUpdateTime(parentObj.getUpdateTime()); + xObj.setAddedByUserId(parentObj.getAddedByUserId()); + xObj.setUpdatedByUserId(parentObj.getUpdatedByUserId()); + return xObj; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/c928a415/security-admin/src/main/java/org/apache/ranger/service/RangerBaseModelService.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerBaseModelService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerBaseModelService.java new file mode 100644 index 0000000..0a6046b --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/service/RangerBaseModelService.java @@ -0,0 +1,276 @@ +package org.apache.ranger.service; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.TypeVariable; +import java.util.Date; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.ranger.common.ContextUtil; +import org.apache.ranger.common.DateUtil; +import org.apache.ranger.common.MessageEnums; +import org.apache.ranger.common.RESTErrorUtil; +import org.apache.ranger.common.StringUtil; +import org.apache.ranger.common.db.BaseDao; +import org.apache.ranger.db.RangerDaoManager; +import org.apache.ranger.entity.XXDBBase; +import org.apache.ranger.entity.XXPortalUser; +import org.apache.ranger.plugin.model.RangerBaseModelObject; +import org.springframework.beans.factory.annotation.Autowired; + +public abstract class RangerBaseModelService<T extends XXDBBase, V extends RangerBaseModelObject> { + private static final Log LOG = LogFactory + .getLog(RangerBaseModelService.class); + + @Autowired + protected RangerDaoManager daoMgr; + + @Autowired + protected StringUtil stringUtil; + + @Autowired + protected RESTErrorUtil restErrorUtil; + + public static final int OPERATION_CREATE_CONTEXT = 1; + public static final int OPERATION_UPDATE_CONTEXT = 2; + + protected Class<T> tEntityClass; + protected Class<V> tViewClass; + + BaseDao<T> entityDao; + + @SuppressWarnings("unchecked") + public RangerBaseModelService() { + Class klass = getClass(); + ParameterizedType genericSuperclass = (ParameterizedType) klass + .getGenericSuperclass(); + TypeVariable<Class<?>> var[] = klass.getTypeParameters(); + + if (genericSuperclass.getActualTypeArguments()[0] instanceof Class) { + tEntityClass = (Class<T>) genericSuperclass + .getActualTypeArguments()[0]; + tViewClass = (Class<V>) genericSuperclass.getActualTypeArguments()[1]; + } else if (var.length > 0) { + tEntityClass = (Class<T>) var[0].getBounds()[0]; + tViewClass = (Class<V>) var[1].getBounds()[0]; + } else { + LOG.fatal("Cannot find class for template", new Throwable()); + } + } + + protected abstract T mapViewToEntityBean(V viewBean, T t, + int OPERATION_CONTEXT); + + protected abstract V mapEntityToViewBean(V viewBean, T t); + + protected T createEntityObject() { + try { + return tEntityClass.newInstance(); + } catch (Throwable e) { + LOG.error("Error instantiating entity class. tEntityClass=" + + tEntityClass.toString(), e); + } + return null; + } + + protected V createViewObject() { + try { + return tViewClass.newInstance(); + } catch (Throwable e) { + LOG.error("Error instantiating view class. tViewClass=" + + tViewClass.toString(), e); + } + return null; + } + + @SuppressWarnings("unchecked") + protected BaseDao<T> getDao() { + if (entityDao == null) { + entityDao = (BaseDao<T>) daoMgr.getDaoForClassName(tEntityClass + .getSimpleName()); + + } + return entityDao; + } + + protected V populateViewBean(T entityObj) { + V vObj = createViewObject(); + vObj.setId(entityObj.getId()); + vObj.setCreateTime(entityObj.getCreateTime()); + vObj.setUpdateTime(entityObj.getUpdateTime()); + + if (entityObj.getAddedByUserId() != null) { + XXPortalUser tUser = daoMgr.getXXPortalUser().getById( + entityObj.getUpdatedByUserId()); + if (!stringUtil.isEmpty(tUser.getPublicScreenName())) { + vObj.setCreatedBy(tUser.getPublicScreenName()); + } else { + if (!stringUtil.isEmpty(tUser.getFirstName())) { + if (!stringUtil.isEmpty(tUser.getLastName())) { + vObj.setCreatedBy(tUser.getFirstName() + " " + + tUser.getLastName()); + } else { + vObj.setCreatedBy(tUser.getFirstName()); + } + } else { + vObj.setCreatedBy(tUser.getLoginId()); + } + } + } + if (entityObj.getUpdatedByUserId() != null) { + XXPortalUser tUser = daoMgr.getXXPortalUser().getById( + entityObj.getUpdatedByUserId()); + if (!stringUtil.isEmpty(tUser.getPublicScreenName())) { + vObj.setUpdatedBy(tUser.getPublicScreenName()); + } else { + if (!stringUtil.isEmpty(tUser.getFirstName())) { + if (!stringUtil.isEmpty(tUser.getLastName())) { + vObj.setUpdatedBy(tUser.getFirstName() + " " + + tUser.getLastName()); + } else { + vObj.setUpdatedBy(tUser.getFirstName()); + } + } else { + vObj.setUpdatedBy(tUser.getLoginId()); + } + } + } + + return mapEntityToViewBean(vObj, entityObj); + } + + protected T populateEntityBean(V vObj, int operationContext) { + T entityObj; + + Date createTime = null; + Date updTime = null; + Long createdById = null; + Long updById = null; + + if (operationContext == OPERATION_CREATE_CONTEXT) { + entityObj = createEntityObject(); + + createTime = DateUtil.getUTCDate(); + updTime = DateUtil.getUTCDate(); + createdById = ContextUtil.getCurrentUserId(); + updById = ContextUtil.getCurrentUserId(); + } else if (operationContext == OPERATION_UPDATE_CONTEXT) { + entityObj = getDao().getById(vObj.getId()); + + if (entityObj == null) { + throw restErrorUtil.createRESTException( + "No Object found to update.", + MessageEnums.DATA_NOT_FOUND); + } + + createTime = entityObj.getCreateTime(); + if (createTime == null) { + createTime = DateUtil.getUTCDate(); + } + updTime = DateUtil.getUTCDate(); + + createdById = entityObj.getAddedByUserId(); + if (createdById == null) { + createdById = ContextUtil.getCurrentUserId(); + } + updById = ContextUtil.getCurrentUserId(); + } else { + throw restErrorUtil.createRESTException( + "Error while populating EntityBean", + MessageEnums.INVALID_INPUT_DATA); + } + entityObj.setAddedByUserId(createdById); + entityObj.setUpdatedByUserId(updById); + entityObj.setCreateTime(createTime); + entityObj.setUpdateTime(updTime); + + return mapViewToEntityBean(vObj, entityObj, operationContext); + } + + protected abstract void validateForCreate(V vObj); + + protected abstract void validateForUpdate(V vObj, T entityObj); + + public T preCreate(V vObj) { + validateForCreate(vObj); + return populateEntityBean(vObj, OPERATION_CREATE_CONTEXT); + } + + public V postCreate(T xObj) { + return populateViewBean(xObj); + } + + public V create(V vObj) { + T resource = preCreate(vObj); + resource = getDao().create(resource); + vObj = postCreate(resource); + return vObj; + } + + public V read(Long id) { + T resource = getDao().getById(id); + if (resource == null) { + throw restErrorUtil.createRESTException(tViewClass.getName() + + " :Data Not Found for given Id", + MessageEnums.DATA_NOT_FOUND, id, null, + "readResource : No Object found with given id."); + } + return populateViewBean(resource); + } + + public V update(V viewBaseBean) { + T resource = preUpdate(viewBaseBean); + resource = getDao().update(resource); + V viewBean = postUpdate(resource); + return viewBean; + } + + public V postUpdate(T resource) { + return populateViewBean(resource); + } + + public T preUpdate(V viewBaseBean) { + T resource = getDao().getById(viewBaseBean.getId()); + if (resource == null) { + throw restErrorUtil.createRESTException(tEntityClass.getSimpleName() + + " not found", MessageEnums.DATA_NOT_FOUND, + viewBaseBean.getId(), null, "preUpdate: id not found."); + } + validateForUpdate(viewBaseBean, resource); + return populateEntityBean(viewBaseBean, OPERATION_UPDATE_CONTEXT); + } + + public boolean delete(V vObj) { + boolean result = false; + Long id = vObj.getId(); + T resource = preDelete(id); + if (resource == null) { + throw restErrorUtil.createRESTException( + tEntityClass.getSimpleName() + " not found", + MessageEnums.DATA_NOT_FOUND, id, null, + tEntityClass.getSimpleName() + ":" + id); + } + try { + result = getDao().remove(resource); + } catch (Exception e) { + LOG.error("Error deleting " + tEntityClass.getSimpleName() + + ". Id=" + id, e); + + throw restErrorUtil.createRESTException( + tEntityClass.getSimpleName() + " can't be deleted", + MessageEnums.OPER_NOT_ALLOWED_FOR_STATE, id, null, "" + id + + ", error=" + e.getMessage()); + } + return result; + } + + protected T preDelete(Long id) { + T resource = getDao().getById(id); + if (resource == null) { + // Return without error + LOG.info("Delete ignored for non-existent Object, id=" + id); + } + return resource; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/c928a415/security-admin/src/main/java/org/apache/ranger/service/RangerDataHistService.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerDataHistService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerDataHistService.java new file mode 100644 index 0000000..a5aa16e --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/service/RangerDataHistService.java @@ -0,0 +1,126 @@ +package org.apache.ranger.service; + +import java.io.IOException; +import java.util.Date; + +import org.apache.ranger.common.AppConstants; +import org.apache.ranger.common.DateUtil; +import org.apache.ranger.common.MessageEnums; +import org.apache.ranger.common.RESTErrorUtil; +import org.apache.ranger.db.RangerDaoManager; +import org.apache.ranger.entity.XXDataHist; +import org.apache.ranger.plugin.model.RangerBaseModelObject; +import org.apache.ranger.plugin.model.RangerPolicy; +import org.apache.ranger.plugin.model.RangerService; +import org.apache.ranger.plugin.model.RangerServiceDef; +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +@Service +@Scope("singleton") +public class RangerDataHistService { + + @Autowired + RESTErrorUtil restErrorUtil; + + @Autowired + RangerDaoManager daoMgr; + + public static final String ACTION_CREATE = "Create"; + public static final String ACTION_UPDATE = "Update"; + public static final String ACTION_DELETE = "Delete"; + + public void createObjectDataHistory(RangerBaseModelObject baseModelObj, String action) { + if(baseModelObj == null || action == null) { + throw restErrorUtil + .createRESTException("Error while creating DataHistory. " + + "Object or Action can not be null.", + MessageEnums.DATA_NOT_FOUND); + } + + + Integer classType = null; + String objectName = null; + String content = null; + + Long objectId = baseModelObj.getId(); + String objectGuid = baseModelObj.getGuid(); + Long version = baseModelObj.getVersion(); + Date currentDate = DateUtil.getUTCDate(); + + XXDataHist xDataHist = new XXDataHist();; + + xDataHist.setObjectId(baseModelObj.getId()); + xDataHist.setObjectGuid(objectGuid); + xDataHist.setCreateTime(currentDate); + xDataHist.setAction(action); + xDataHist.setVersion(baseModelObj.getVersion()); + xDataHist.setUpdateTime(currentDate); + xDataHist.setFromTime(currentDate); + + if(baseModelObj instanceof RangerServiceDef) { + RangerServiceDef serviceDef = (RangerServiceDef) baseModelObj; + objectName = serviceDef.getName(); + classType = AppConstants.CLASS_TYPE_XA_SERVICE_DEF; + content = writeObjectAsString(serviceDef); + } else if(baseModelObj instanceof RangerService) { + RangerService service = (RangerService) baseModelObj; + objectName = service.getName(); + classType = AppConstants.CLASS_TYPE_XA_SERVICE; + content = writeObjectAsString(service); + } else if(baseModelObj instanceof RangerPolicy) { + RangerPolicy policy = (RangerPolicy) baseModelObj; + objectName = policy.getName(); + classType = AppConstants.CLASS_TYPE_RANGER_POLICY; + content = writeObjectAsString(policy); + } + + xDataHist.setObjectClassType(classType); + xDataHist.setObjectName(objectName); + xDataHist.setContent(content); + xDataHist = daoMgr.getXXDataHist().create(xDataHist); + + if (ACTION_UPDATE.equalsIgnoreCase(action) || ACTION_DELETE.equalsIgnoreCase(action)) { + XXDataHist prevHist = daoMgr.getXXDataHist().findLatestByObjectClassTypeAndObjectId(classType, objectId); + + if(prevHist == null) { + throw restErrorUtil.createRESTException( + "Error updating DataHistory Object. ObjectName: " + + objectName, MessageEnums.DATA_NOT_UPDATABLE); + } + + prevHist.setVersion(version); + prevHist.setUpdateTime(currentDate); + prevHist.setToTime(currentDate); + prevHist.setObjectName(objectName); + prevHist = daoMgr.getXXDataHist().update(prevHist); + } + } + + public String writeObjectAsString(RangerBaseModelObject vObj) { + ObjectMapper mapper = new ObjectMapper(); + + String jsonStr; + try { + jsonStr = mapper.writeValueAsString(vObj); + return jsonStr; + } catch (JsonParseException e) { + throw restErrorUtil.createRESTException( + "Invalid input data: " + e.getMessage(), + MessageEnums.INVALID_INPUT_DATA); + } catch (JsonMappingException e) { + throw restErrorUtil.createRESTException( + "Invalid input data: " + e.getMessage(), + MessageEnums.INVALID_INPUT_DATA); + } catch (IOException e) { + throw restErrorUtil.createRESTException( + "Invalid input data: " + e.getMessage(), + MessageEnums.INVALID_INPUT_DATA); + } + } + +}
