You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ma...@apache.org on 2015/08/28 23:56:01 UTC
[2/4] incubator-ranger git commit: RANGER-595: updated tag-store
implementation; replaced externalId references with guid;
service.tagVersion incremented on changes to tagging for the service-resources
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/entity/XXServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceBase.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceBase.java
index 087eb8d..69c4e4d 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceBase.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceBase.java
@@ -96,6 +96,25 @@ public abstract class XXServiceBase extends XXDBBase {
protected Date policyUpdateTime;
/**
+ * tagVersion of the XXService
+ * <ul>
+ * </ul>
+ *
+ */
+ @Column(name = "tag_version")
+ protected Long tagVersion;
+
+ /**
+ * tagUpdateTime of the XXService
+ * <ul>
+ * </ul>
+ *
+ */
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "tag_update_time")
+ protected Date tagUpdateTime;
+
+ /**
* description of the XXService
* <ul>
* </ul>
@@ -248,6 +267,46 @@ public abstract class XXServiceBase extends XXDBBase {
}
/**
+ * This method sets the value to the member attribute <b> tagVersion</b>
+ * . You cannot set null to the attribute.
+ *
+ * @param tagVersion
+ * Value to set member attribute <b> tagVersion</b>
+ */
+ public void setTagVersion(Long tagVersion) {
+ this.tagVersion = tagVersion;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>tagVersion</b>
+ *
+ * @return Long - value of member attribute <b>tagVersion</b> .
+ */
+ public Long getTagVersion() {
+ return this.tagVersion;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>
+ * tagUpdateTime</b> . You cannot set null to the attribute.
+ *
+ * @param tagUpdateTime
+ * Value to set member attribute <b> tagUpdateTime</b>
+ */
+ public void setTagUpdateTime(Date tagUpdateTime) {
+ this.tagUpdateTime = tagUpdateTime;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>tagUpdateTime</b>
+ *
+ * @return Date - value of member attribute <b>tagUpdateTime</b> .
+ */
+ public Date getTagUpdateTime() {
+ return this.tagUpdateTime;
+ }
+
+ /**
* This method sets the value to the member attribute <b> description</b> .
* You cannot set null to the attribute.
*
@@ -346,6 +405,20 @@ public abstract class XXServiceBase extends XXDBBase {
} else if (!policyVersion.equals(other.policyVersion)) {
return false;
}
+ if (tagUpdateTime == null) {
+ if (other.tagUpdateTime != null) {
+ return false;
+ }
+ } else if (!tagUpdateTime.equals(other.tagUpdateTime)) {
+ return false;
+ }
+ if (tagVersion == null) {
+ if (other.tagVersion != null) {
+ return false;
+ }
+ } else if (!tagVersion.equals(other.tagVersion)) {
+ return false;
+ }
if (type == null) {
if (other.type != null) {
return false;
@@ -379,6 +452,7 @@ public abstract class XXServiceBase extends XXDBBase {
public String toString() {
return "XXServiceBase [" + super.toString() + " guid=" + guid + ", version=" + version + ", type=" + type
+ ", name=" + name + ", tagService=" + tagService + ", policyVersion=" + policyVersion + ", policyUpdateTime=" + policyUpdateTime
+ + ", tagVersion=" + tagVersion + ", tagUpdateTime=" + tagUpdateTime
+ ", description=" + description + ", isEnabled=" + isEnabled + "]";
}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResource.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResource.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResource.java
new file mode 100644
index 0000000..8fd3866
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResource.java
@@ -0,0 +1,245 @@
+/*
+ * 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.io.Serializable;
+
+import javax.persistence.Cacheable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.ranger.common.AppConstants;
+
+@Entity
+@Cacheable
+@Table(name="x_service_resource")
+@XmlRootElement
+public class XXServiceResource extends XXDBBase implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @SequenceGenerator(name = "XXServiceResourceSEQ", sequenceName = "XXServiceResourceSEQ", allocationSize = 1)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "XXServiceResourceSEQ")
+ @Column(name = "id")
+ protected Long id;
+
+ @Column(name = "guid", unique = true, nullable = false, length = 512)
+ protected String guid;
+
+ @Column(name = "version")
+ protected Long version;
+
+ @Column(name = "is_enabled")
+ protected Boolean isEnabled;
+
+ @Column(name = "resource_signature")
+ protected String resourceSignature;
+
+ @Column(name = "service_id")
+ protected Long serviceId;
+
+ @Override
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * @return the guid
+ */
+ public String getGuid() {
+ return guid;
+ }
+
+ /**
+ * @param guid
+ * the guid to set
+ */
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ /**
+ * @return the serviceId
+ */
+ public Long getServiceId() {
+ return serviceId;
+ }
+
+ /**
+ * @param serviceId
+ * the serviceId to set
+ */
+ public void setServiceId(Long serviceId) {
+ this.serviceId = serviceId;
+ }
+
+ /**
+ * @return the resourceSignature
+ */
+ public String getResourceSignature() {
+ return resourceSignature;
+ }
+
+ /**
+ * @param resourceSignature
+ * the resourceSignature to set
+ */
+ public void setResourceSignature(String resourceSignature) {
+ this.resourceSignature = resourceSignature;
+ }
+
+ /**
+ * @return the version
+ */
+ public Long getVersion() {
+ return version;
+ }
+
+ /**
+ * @param version
+ * the version to set
+ */
+ public void setVersion(Long version) {
+ this.version = version;
+ }
+
+ /**
+ * @return the isEnabled
+ */
+ public Boolean getIsEnabled() {
+ return isEnabled;
+ }
+
+ /**
+ * @param isEnabled
+ * the isEnabled to set
+ */
+ public void setIsEnabled(Boolean isEnabled) {
+ this.isEnabled = isEnabled;
+ }
+
+ @Override
+ public int getMyClassType() {
+ return AppConstants.CLASS_TYPE_XA_SERVICE_RESOURCE;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((guid == null) ? 0 : guid.hashCode());
+ result = prime * result + ((version == null) ? 0 : version.hashCode());
+ result = prime * result + ((isEnabled == null) ? 0 : isEnabled.hashCode());
+ result = prime * result + ((resourceSignature == null) ? 0 : resourceSignature.hashCode());
+ result = prime * result + ((serviceId == null) ? 0 : serviceId.hashCode());
+ return result;
+ }
+
+ /*
+ * (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;
+ XXServiceResource other = (XXServiceResource) obj;
+ if (resourceSignature == null) {
+ if (other.resourceSignature != null)
+ return false;
+ } else if (!resourceSignature.equals(other.resourceSignature))
+ return false;
+ if (guid == null) {
+ if (other.guid != null)
+ return false;
+ } else if (!guid.equals(other.guid))
+ 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 (serviceId == null) {
+ if (other.serviceId != null)
+ return false;
+ } else if (!serviceId.equals(other.serviceId))
+ return false;
+ if (version == null) {
+ if (other.version != null)
+ return false;
+ } else if (!version.equals(other.version))
+ return false;
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ toString(sb);
+ return sb.toString();
+ }
+
+ public StringBuilder toString(StringBuilder sb) {
+ sb.append("{ ");
+ sb.append(super.toString() + "} ");
+ sb.append("id={").append(id).append("} ");
+ sb.append("guid={").append(guid).append("} ");
+ sb.append("version={").append(version).append("} ");
+ sb.append("isEnabled={").append(isEnabled).append("} ");
+ sb.append("resourceSignature={").append(resourceSignature).append("} ");
+ sb.append("serviceId={").append(serviceId).append("} ");
+ sb.append(" }");
+
+ return sb;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElement.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElement.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElement.java
new file mode 100644
index 0000000..a545133
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElement.java
@@ -0,0 +1,245 @@
+/*
+ * 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.io.Serializable;
+
+import javax.persistence.Cacheable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.ranger.common.AppConstants;
+
+@Entity
+@Cacheable
+@Table(name="x_service_resource_element")
+@XmlRootElement
+public class XXServiceResourceElement extends XXDBBase implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @SequenceGenerator(name = "XXServiceResourceElementSEQ", sequenceName = "XXServiceResourceElementSEQ", allocationSize = 1)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "XXServiceResourceElementSEQ")
+ @Column(name = "id")
+ protected Long id;
+
+ @Column(name = "guid", unique = true, nullable = false, length = 512)
+ protected String guid;
+
+ @Column(name = "res_def_id")
+ protected Long resDefId;
+
+ @Column(name = "res_id")
+ protected Long resourceId;
+
+ @Column(name = "is_excludes")
+ protected Boolean isExcludes;
+
+ @Column(name = "is_recursive")
+ protected Boolean isRecursive;
+
+ @Override
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * @return the guid
+ */
+ public String getGuid() {
+ return guid;
+ }
+
+ /**
+ * @param guid
+ * the guid to set
+ */
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ /**
+ * @return the resDefId
+ */
+ public Long getResDefId() {
+ return resDefId;
+ }
+
+ /**
+ * @param resDefId
+ * the resDefId to set
+ */
+ public void setResDefId(Long resDefId) {
+ this.resDefId = resDefId;
+ }
+
+ /**
+ * @return the isExcludes
+ */
+ public Boolean getIsExcludes() {
+ return isExcludes;
+ }
+
+ /**
+ * @param isExcludes
+ * the isExcludes to set
+ */
+ public void setIsExcludes(Boolean isExcludes) {
+ this.isExcludes = isExcludes;
+ }
+
+ /**
+ * @return the isRecursive
+ */
+ public Boolean getIsRecursive() {
+ return isRecursive;
+ }
+
+ /**
+ * @param isRecursive
+ * the isRecursive to set
+ */
+ public void setIsRecursive(Boolean isRecursive) {
+ this.isRecursive = isRecursive;
+ }
+
+ /**
+ * @return the resourceId
+ */
+ public Long getResourceId() {
+ return resourceId;
+ }
+
+ /**
+ * @param resourceId
+ * the resourceId to set
+ */
+ public void setResourceId(Long resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ @Override
+ public int getMyClassType() {
+ return AppConstants.CLASS_TYPE_XA_SERVICE_RESOURCE_ELEMENT;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((guid == null) ? 0 : guid.hashCode());
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((isExcludes == null) ? 0 : isExcludes.hashCode());
+ result = prime * result + ((isRecursive == null) ? 0 : isRecursive.hashCode());
+ result = prime * result + ((resDefId == null) ? 0 : resDefId.hashCode());
+ result = prime * result + ((resourceId == null) ? 0 : resourceId.hashCode());
+ return result;
+ }
+
+ /*
+ * (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;
+ XXServiceResourceElement other = (XXServiceResourceElement) obj;
+ if (guid == null) {
+ if (other.guid != null)
+ return false;
+ } else if (!guid.equals(other.guid))
+ return false;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ if (isExcludes == null) {
+ if (other.isExcludes != null)
+ return false;
+ } else if (!isExcludes.equals(other.isExcludes))
+ return false;
+ if (isRecursive == null) {
+ if (other.isRecursive != null)
+ return false;
+ } else if (!isRecursive.equals(other.isRecursive))
+ return false;
+ if (resDefId == null) {
+ if (other.resDefId != null)
+ return false;
+ } else if (!resDefId.equals(other.resDefId))
+ return false;
+ if (resourceId == null) {
+ if (other.resourceId != null)
+ return false;
+ } else if (!resourceId.equals(other.resourceId))
+ return false;
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ toString(sb);
+ return sb.toString();
+ }
+
+ public StringBuilder toString(StringBuilder sb) {
+ sb.append("{ ");
+ sb.append(super.toString() + "} ");
+ sb.append("id={").append(id).append("} ");
+ sb.append("guid={").append(guid).append("} ");
+ sb.append("resDefId={").append(resDefId).append("} ");
+ sb.append("resourceId={").append(resourceId).append("} ");
+ sb.append("isExcludes={").append(isExcludes).append("} ");
+ sb.append("isRecursive={").append(isRecursive).append("} ");
+ sb.append(" }");
+
+ return sb;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElementValue.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElementValue.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElementValue.java
new file mode 100644
index 0000000..23b17b9
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElementValue.java
@@ -0,0 +1,220 @@
+/*
+ * 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.io.Serializable;
+
+import javax.persistence.Cacheable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.ranger.common.AppConstants;
+
+@Entity
+@Cacheable
+@Table(name="x_service_resource_element_value")
+@XmlRootElement
+public class XXServiceResourceElementValue extends XXDBBase implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @SequenceGenerator(name = "XXServiceResourceElementValueSEQ", sequenceName = "XXServiceResourceElementValueSEQ", allocationSize = 1)
+ @GeneratedValue(strategy = GenerationType.AUTO, generator = "XXServiceResourceElementValueSEQ")
+ @Column(name = "id")
+ protected Long id;
+
+ @Column(name = "guid", unique = true, nullable = false, length = 512)
+ protected String guid;
+
+ @Column(name = "res_element_id")
+ protected Long resElementId;
+
+ @Column(name = "value")
+ protected String value;
+
+ @Column(name = "sort_order")
+ protected Integer sortOrder;
+
+ @Override
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Override
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * @return the guid
+ */
+ public String getGuid() {
+ return guid;
+ }
+
+ /**
+ * @param guid
+ * the guid to set
+ */
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ /**
+ * @return the resElementId
+ */
+ public Long getResElementId() {
+ return resElementId;
+ }
+
+ /**
+ * @param resElementId
+ * the resElementId to set
+ */
+ public void setResElementId(Long resElementId) {
+ this.resElementId = resElementId;
+ }
+
+ /**
+ * @return the value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * @param value
+ * the value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * @return the sortOrder
+ */
+ public Integer getSortOrder() {
+ return sortOrder;
+ }
+
+ /**
+ * @param sortOrder
+ * the sortOrder to set
+ */
+ public void setSortOrder(Integer sortOrder) {
+ this.sortOrder = sortOrder;
+ }
+
+ @Override
+ public int getMyClassType() {
+ return AppConstants.CLASS_TYPE_XA_SERVICE_RESOURCE_ELEMENT_VALUE;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((guid == null) ? 0 : guid.hashCode());
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((resElementId == null) ? 0 : resElementId.hashCode());
+ result = prime * result + ((sortOrder == null) ? 0 : sortOrder.hashCode());
+ result = prime * result + ((value == null) ? 0 : value.hashCode());
+ return result;
+ }
+
+ /*
+ * (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;
+ XXServiceResourceElementValue other = (XXServiceResourceElementValue) obj;
+ if (guid == null) {
+ if (other.guid != null)
+ return false;
+ } else if (!guid.equals(other.guid))
+ return false;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ if (resElementId == null) {
+ if (other.resElementId != null)
+ return false;
+ } else if (!resElementId.equals(other.resElementId))
+ return false;
+ if (sortOrder == null) {
+ if (other.sortOrder != null)
+ return false;
+ } else if (!sortOrder.equals(other.sortOrder))
+ 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() {
+ StringBuilder sb = new StringBuilder();
+ toString(sb);
+ return sb.toString();
+ }
+
+ public StringBuilder toString(StringBuilder sb) {
+ sb.append("{ ");
+ sb.append(super.toString() + "} ");
+ sb.append("id={").append(id).append("} ");
+ sb.append("guid={").append(guid).append("} ");
+ sb.append("resElementId={").append(resElementId).append("} ");
+ sb.append("value={").append(value).append("} ");
+ sb.append("sortOrder={").append(sortOrder).append("} ");
+ sb.append(" }");
+
+ return sb;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/entity/XXTag.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXTag.java b/security-admin/src/main/java/org/apache/ranger/entity/XXTag.java
index 46b760b..1d8493a 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXTag.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXTag.java
@@ -49,18 +49,6 @@ public class XXTag extends XXDBBase implements Serializable {
@Column(name = "guid", unique = true, nullable = false, length = 512)
protected String guid;
- @Column(name = "version")
- protected Long version;
-
- @Column(name = "is_enabled")
- protected Boolean isEnabled;
-
- @Column(name = "tag_def_id")
- protected Long tagDefId;
-
- @Column(name = "external_id")
- protected String externalId;
-
@Column(name = "name")
protected String name;
@@ -90,51 +78,6 @@ public class XXTag extends XXDBBase implements Serializable {
}
/**
- * @return the version
- */
- public Long getVersion() {
- return version;
- }
-
- /**
- * @param version
- * the version to set
- */
- public void setVersion(Long version) {
- this.version = version;
- }
-
- /**
- * @return the isEnabled
- */
- public Boolean getIsEnabled() {
- return isEnabled;
- }
-
- /**
- * @param isEnabled
- * the isEnabled to set
- */
- public void setIsEnabled(Boolean isEnabled) {
- this.isEnabled = isEnabled;
- }
-
- /**
- * @return the tagDefId
- */
- public Long getTagDefId() {
- return tagDefId;
- }
-
- /**
- * @param tagDefId
- * the tagDefId to set
- */
- public void setTagDefId(Long tagDefId) {
- this.tagDefId = tagDefId;
- }
-
- /**
* @return the name
*/
public String getName() {
@@ -149,21 +92,6 @@ public class XXTag extends XXDBBase implements Serializable {
this.name = name;
}
- /**
- * @return the externalId
- */
- public String getExternalId() {
- return externalId;
- }
-
- /**
- * @param externalId
- * the externalId to set
- */
- public void setExternalId(String externalId) {
- this.externalId = externalId;
- }
-
@Override
public int getMyClassType() {
return AppConstants.CLASS_TYPE_XA_TAG;
@@ -178,11 +106,9 @@ public class XXTag extends XXDBBase implements Serializable {
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((externalId == null) ? 0 : externalId.hashCode());
result = prime * result + ((guid == null) ? 0 : guid.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((tagDefId == null) ? 0 : tagDefId.hashCode());
return result;
}
@@ -200,11 +126,6 @@ public class XXTag extends XXDBBase implements Serializable {
if (getClass() != obj.getClass())
return false;
XXTag other = (XXTag) obj;
- if (externalId == null) {
- if (other.externalId != null)
- return false;
- } else if (!externalId.equals(other.externalId))
- return false;
if (guid == null) {
if (other.guid != null)
return false;
@@ -220,11 +141,6 @@ public class XXTag extends XXDBBase implements Serializable {
return false;
} else if (!name.equals(other.name))
return false;
- if (tagDefId == null) {
- if (other.tagDefId != null)
- return false;
- } else if (!tagDefId.equals(other.tagDefId))
- return false;
return true;
}
@@ -245,8 +161,6 @@ public class XXTag extends XXDBBase implements Serializable {
sb.append(super.toString() + "} ");
sb.append("id={").append(id).append("} ");
sb.append("guid={").append(guid).append("} ");
- sb.append("tagDefId={").append(tagDefId).append("} ");
- sb.append("externalId={").append(externalId).append("} ");
sb.append("name={").append(name).append("} ");
sb.append(" }");
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/entity/XXTagResourceMap.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXTagResourceMap.java b/security-admin/src/main/java/org/apache/ranger/entity/XXTagResourceMap.java
index 953df6b..98f2355 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXTagResourceMap.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXTagResourceMap.java
@@ -52,8 +52,8 @@ public class XXTagResourceMap extends XXDBBase implements Serializable {
@Column(name = "tag_id")
protected Long tagId;
- @Column(name = "tagged_res_id")
- protected Long taggedResId;
+ @Column(name = "res_id")
+ protected Long resourceId;
@Override
public void setId(Long id) {
@@ -96,18 +96,18 @@ public class XXTagResourceMap extends XXDBBase implements Serializable {
}
/**
- * @return the taggedResId
+ * @return the resourceId
*/
- public Long getTaggedResId() {
- return taggedResId;
+ public Long getResourceId() {
+ return resourceId;
}
/**
- * @param taggedResId
- * the taggedResId to set
+ * @param resourceId
+ * the resourceId to set
*/
- public void setTaggedResId(Long taggedResId) {
- this.taggedResId = taggedResId;
+ public void setResourceId(Long resourceId) {
+ this.resourceId = resourceId;
}
@Override
@@ -127,7 +127,7 @@ public class XXTagResourceMap extends XXDBBase implements Serializable {
result = prime * result + ((guid == null) ? 0 : guid.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((tagId == null) ? 0 : tagId.hashCode());
- result = prime * result + ((taggedResId == null) ? 0 : taggedResId.hashCode());
+ result = prime * result + ((resourceId == null) ? 0 : resourceId.hashCode());
return result;
}
@@ -160,10 +160,10 @@ public class XXTagResourceMap extends XXDBBase implements Serializable {
return false;
} else if (!tagId.equals(other.tagId))
return false;
- if (taggedResId == null) {
- if (other.taggedResId != null)
+ if (resourceId == null) {
+ if (other.resourceId != null)
return false;
- } else if (!taggedResId.equals(other.taggedResId))
+ } else if (!resourceId.equals(other.resourceId))
return false;
return true;
}
@@ -186,7 +186,7 @@ public class XXTagResourceMap extends XXDBBase implements Serializable {
sb.append("id={").append(id).append("} ");
sb.append("guid={").append(guid).append("} ");
sb.append("tagId={").append(tagId).append("} ");
- sb.append("taggedResId={").append(taggedResId).append("} ");
+ sb.append("resourceId={").append(resourceId).append("} ");
sb.append(" }");
return sb;
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/entity/XXTaggedResource.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXTaggedResource.java b/security-admin/src/main/java/org/apache/ranger/entity/XXTaggedResource.java
deleted file mode 100644
index 9487bc7..0000000
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXTaggedResource.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * 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.io.Serializable;
-
-import javax.persistence.Cacheable;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.ranger.common.AppConstants;
-
-@Entity
-@Cacheable
-@Table(name="x_tagged_resource")
-@XmlRootElement
-public class XXTaggedResource extends XXDBBase implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- @SequenceGenerator(name = "XXTaggedResourceSEQ", sequenceName = "XXTaggedResourceSEQ", allocationSize = 1)
- @GeneratedValue(strategy = GenerationType.AUTO, generator = "XXTaggedResourceSEQ")
- @Column(name = "id")
- protected Long id;
-
- @Column(name = "guid", unique = true, nullable = false, length = 512)
- protected String guid;
-
- @Column(name = "version")
- protected Long version;
-
- @Column(name = "is_enabled")
- protected Boolean isEnabled;
-
- @Column(name = "external_id")
- protected String externalId;
-
- @Column(name = "service_id")
- protected Long serviceId;
-
- @Override
- public void setId(Long id) {
- this.id = id;
- }
-
- @Override
- public Long getId() {
- return id;
- }
-
- /**
- * @return the guid
- */
- public String getGuid() {
- return guid;
- }
-
- /**
- * @param guid
- * the guid to set
- */
- public void setGuid(String guid) {
- this.guid = guid;
- }
-
- /**
- * @return the serviceId
- */
- public Long getServiceId() {
- return serviceId;
- }
-
- /**
- * @param serviceId
- * the serviceId to set
- */
- public void setServiceId(Long serviceId) {
- this.serviceId = serviceId;
- }
-
- /**
- * @return the externalId
- */
- public String getExternalId() {
- return externalId;
- }
-
- /**
- * @param externalId
- * the externalId to set
- */
- public void setExternalId(String externalId) {
- this.externalId = externalId;
- }
-
- /**
- * @return the version
- */
- public Long getVersion() {
- return version;
- }
-
- /**
- * @param version
- * the version to set
- */
- public void setVersion(Long version) {
- this.version = version;
- }
-
- /**
- * @return the isEnabled
- */
- public Boolean getIsEnabled() {
- return isEnabled;
- }
-
- /**
- * @param isEnabled
- * the isEnabled to set
- */
- public void setIsEnabled(Boolean isEnabled) {
- this.isEnabled = isEnabled;
- }
-
- @Override
- public int getMyClassType() {
- return AppConstants.CLASS_TYPE_XA_TAGGED_RESOURCE;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((externalId == null) ? 0 : externalId.hashCode());
- result = prime * result + ((guid == null) ? 0 : guid.hashCode());
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- result = prime * result + ((isEnabled == null) ? 0 : isEnabled.hashCode());
- result = prime * result + ((serviceId == null) ? 0 : serviceId.hashCode());
- result = prime * result + ((version == null) ? 0 : version.hashCode());
- return result;
- }
-
- /*
- * (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;
- XXTaggedResource other = (XXTaggedResource) obj;
- if (externalId == null) {
- if (other.externalId != null)
- return false;
- } else if (!externalId.equals(other.externalId))
- return false;
- if (guid == null) {
- if (other.guid != null)
- return false;
- } else if (!guid.equals(other.guid))
- 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 (serviceId == null) {
- if (other.serviceId != null)
- return false;
- } else if (!serviceId.equals(other.serviceId))
- return false;
- if (version == null) {
- if (other.version != null)
- return false;
- } else if (!version.equals(other.version))
- return false;
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- toString(sb);
- return sb.toString();
- }
-
- public StringBuilder toString(StringBuilder sb) {
- sb.append("{ ");
- sb.append(super.toString() + "} ");
- sb.append("id={").append(id).append("} ");
- sb.append("guid={").append(guid).append("} ");
- sb.append("version={").append(version).append("} ");
- sb.append("isEnabled={").append(isEnabled).append("} ");
- sb.append("externalId={").append(externalId).append("} ");
- sb.append("serviceId={").append(serviceId).append("} ");
- sb.append(" }");
-
- return sb;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/entity/XXTaggedResourceValue.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXTaggedResourceValue.java b/security-admin/src/main/java/org/apache/ranger/entity/XXTaggedResourceValue.java
deleted file mode 100644
index 977d1f5..0000000
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXTaggedResourceValue.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * 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.io.Serializable;
-
-import javax.persistence.Cacheable;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.ranger.common.AppConstants;
-
-@Entity
-@Cacheable
-@Table(name="x_tagged_resource_value")
-@XmlRootElement
-public class XXTaggedResourceValue extends XXDBBase implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- @SequenceGenerator(name = "XXTaggedResourceValueSEQ", sequenceName = "XXTaggedResourceValueSEQ", allocationSize = 1)
- @GeneratedValue(strategy = GenerationType.AUTO, generator = "XXTaggedResourceValueSEQ")
- @Column(name = "id")
- protected Long id;
-
- @Column(name = "guid", unique = true, nullable = false, length = 512)
- protected String guid;
-
- @Column(name = "res_def_id")
- protected Long resDefId;
-
- @Column(name = "tagged_res_id")
- protected Long taggedResourceId;
-
- @Column(name = "is_excludes")
- protected Boolean isExcludes;
-
- @Column(name = "is_recursive")
- protected Boolean isRecursive;
-
- @Override
- public void setId(Long id) {
- this.id = id;
- }
-
- @Override
- public Long getId() {
- return id;
- }
-
- /**
- * @return the guid
- */
- public String getGuid() {
- return guid;
- }
-
- /**
- * @param guid
- * the guid to set
- */
- public void setGuid(String guid) {
- this.guid = guid;
- }
-
- /**
- * @return the resDefId
- */
- public Long getResDefId() {
- return resDefId;
- }
-
- /**
- * @param resDefId
- * the resDefId to set
- */
- public void setResDefId(Long resDefId) {
- this.resDefId = resDefId;
- }
-
- /**
- * @return the isExcludes
- */
- public Boolean getIsExcludes() {
- return isExcludes;
- }
-
- /**
- * @param isExcludes
- * the isExcludes to set
- */
- public void setIsExcludes(Boolean isExcludes) {
- this.isExcludes = isExcludes;
- }
-
- /**
- * @return the isRecursive
- */
- public Boolean getIsRecursive() {
- return isRecursive;
- }
-
- /**
- * @param isRecursive
- * the isRecursive to set
- */
- public void setIsRecursive(Boolean isRecursive) {
- this.isRecursive = isRecursive;
- }
-
- /**
- * @return the taggedResourceId
- */
- public Long getTaggedResourceId() {
- return taggedResourceId;
- }
-
- /**
- * @param taggedResourceId
- * the taggedResourceId to set
- */
- public void setTaggedResourceId(Long taggedResourceId) {
- this.taggedResourceId = taggedResourceId;
- }
-
- @Override
- public int getMyClassType() {
- return AppConstants.CLASS_TYPE_XA_TAGGED_RESOURCE_VALUE;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((guid == null) ? 0 : guid.hashCode());
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- result = prime * result + ((isExcludes == null) ? 0 : isExcludes.hashCode());
- result = prime * result + ((isRecursive == null) ? 0 : isRecursive.hashCode());
- result = prime * result + ((resDefId == null) ? 0 : resDefId.hashCode());
- result = prime * result + ((taggedResourceId == null) ? 0 : taggedResourceId.hashCode());
- return result;
- }
-
- /*
- * (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;
- XXTaggedResourceValue other = (XXTaggedResourceValue) obj;
- if (guid == null) {
- if (other.guid != null)
- return false;
- } else if (!guid.equals(other.guid))
- return false;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- if (isExcludes == null) {
- if (other.isExcludes != null)
- return false;
- } else if (!isExcludes.equals(other.isExcludes))
- return false;
- if (isRecursive == null) {
- if (other.isRecursive != null)
- return false;
- } else if (!isRecursive.equals(other.isRecursive))
- return false;
- if (resDefId == null) {
- if (other.resDefId != null)
- return false;
- } else if (!resDefId.equals(other.resDefId))
- return false;
- if (taggedResourceId == null) {
- if (other.taggedResourceId != null)
- return false;
- } else if (!taggedResourceId.equals(other.taggedResourceId))
- return false;
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- toString(sb);
- return sb.toString();
- }
-
- public StringBuilder toString(StringBuilder sb) {
- sb.append("{ ");
- sb.append(super.toString() + "} ");
- sb.append("id={").append(id).append("} ");
- sb.append("guid={").append(guid).append("} ");
- sb.append("resDefId={").append(resDefId).append("} ");
- sb.append("taggedResourceId={").append(taggedResourceId).append("} ");
- sb.append("isExcludes={").append(isExcludes).append("} ");
- sb.append("isRecursive={").append(isRecursive).append("} ");
- sb.append(" }");
-
- return sb;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/entity/XXTaggedResourceValueMap.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXTaggedResourceValueMap.java b/security-admin/src/main/java/org/apache/ranger/entity/XXTaggedResourceValueMap.java
deleted file mode 100644
index 62e875f..0000000
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXTaggedResourceValueMap.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * 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.io.Serializable;
-
-import javax.persistence.Cacheable;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.Table;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.ranger.common.AppConstants;
-
-@Entity
-@Cacheable
-@Table(name="x_tagged_resource_value_map")
-@XmlRootElement
-public class XXTaggedResourceValueMap extends XXDBBase implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- @SequenceGenerator(name = "XXTaggedResourceValueMapSEQ", sequenceName = "XXTaggedResourceValueMapSEQ", allocationSize = 1)
- @GeneratedValue(strategy = GenerationType.AUTO, generator = "XXTaggedResourceValueMapSEQ")
- @Column(name = "id")
- protected Long id;
-
- @Column(name = "guid", unique = true, nullable = false, length = 512)
- protected String guid;
-
- @Column(name = "res_value_id")
- protected Long resValueId;
-
- @Column(name = "value")
- protected String value;
-
- @Column(name = "sort_order")
- protected Integer sortOrder;
-
- @Override
- public void setId(Long id) {
- this.id = id;
- }
-
- @Override
- public Long getId() {
- return id;
- }
-
- /**
- * @return the guid
- */
- public String getGuid() {
- return guid;
- }
-
- /**
- * @param guid
- * the guid to set
- */
- public void setGuid(String guid) {
- this.guid = guid;
- }
-
- /**
- * @return the resValueId
- */
- public Long getResValueId() {
- return resValueId;
- }
-
- /**
- * @param resValueId
- * the resValueId to set
- */
- public void setResValueId(Long resValueId) {
- this.resValueId = resValueId;
- }
-
- /**
- * @return the value
- */
- public String getValue() {
- return value;
- }
-
- /**
- * @param value
- * the value to set
- */
- public void setValue(String value) {
- this.value = value;
- }
-
- /**
- * @return the sortOrder
- */
- public Integer getSortOrder() {
- return sortOrder;
- }
-
- /**
- * @param sortOrder
- * the sortOrder to set
- */
- public void setSortOrder(Integer sortOrder) {
- this.sortOrder = sortOrder;
- }
-
- @Override
- public int getMyClassType() {
- return AppConstants.CLASS_TYPE_XA_TAGGED_RESOURCE_VALUE_MAP;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((guid == null) ? 0 : guid.hashCode());
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- result = prime * result + ((resValueId == null) ? 0 : resValueId.hashCode());
- result = prime * result + ((sortOrder == null) ? 0 : sortOrder.hashCode());
- result = prime * result + ((value == null) ? 0 : value.hashCode());
- return result;
- }
-
- /*
- * (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;
- XXTaggedResourceValueMap other = (XXTaggedResourceValueMap) obj;
- if (guid == null) {
- if (other.guid != null)
- return false;
- } else if (!guid.equals(other.guid))
- return false;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- if (resValueId == null) {
- if (other.resValueId != null)
- return false;
- } else if (!resValueId.equals(other.resValueId))
- return false;
- if (sortOrder == null) {
- if (other.sortOrder != null)
- return false;
- } else if (!sortOrder.equals(other.sortOrder))
- 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() {
- StringBuilder sb = new StringBuilder();
- toString(sb);
- return sb.toString();
- }
-
- public StringBuilder toString(StringBuilder sb) {
- sb.append("{ ");
- sb.append(super.toString() + "} ");
- sb.append("id={").append(id).append("} ");
- sb.append("guid={").append(guid).append("} ");
- sb.append("resValueId={").append(resValueId).append("} ");
- sb.append("value={").append(value).append("} ");
- sb.append("sortOrder={").append(sortOrder).append("} ");
- sb.append(" }");
-
- return sb;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/rest/TagREST.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/rest/TagREST.java b/security-admin/src/main/java/org/apache/ranger/rest/TagREST.java
index b667777..0b0d4ca 100644
--- a/security-admin/src/main/java/org/apache/ranger/rest/TagREST.java
+++ b/security-admin/src/main/java/org/apache/ranger/rest/TagREST.java
@@ -20,24 +20,21 @@
package org.apache.ranger.rest;
import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.ListUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ranger.biz.ServiceDBStore;
-//import org.apache.ranger.biz.TagDBStore;
+import org.apache.ranger.biz.TagDBStore;
import org.apache.ranger.common.RESTErrorUtil;
import org.apache.ranger.plugin.model.RangerServiceResource;
import org.apache.ranger.plugin.model.RangerTag;
import org.apache.ranger.plugin.model.RangerTagResourceMap;
import org.apache.ranger.plugin.model.RangerTagDef;
-import org.apache.ranger.plugin.store.TagStore;
import org.apache.ranger.plugin.store.TagValidator;
-
-import org.apache.ranger.plugin.store.file.TagFileStore;
import org.apache.ranger.plugin.util.SearchFilter;
import org.apache.ranger.plugin.util.ServiceTags;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
+import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@@ -46,11 +43,9 @@ import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
-import java.util.ArrayList;
import java.util.List;
@Path(TagRESTConstants.TAGDEF_NAME_AND_VERSION)
-
@Component
@Scope("request")
@Transactional(propagation = Propagation.REQUIRES_NEW)
@@ -64,13 +59,8 @@ public class TagREST {
@Autowired
ServiceDBStore svcStore;
- //@Autowired
- //TagDBStore tagStore;
-
- TagStore tagStore;
-
- //@Autowired
- //TagValidator validator;
+ @Autowired
+ TagDBStore tagStore;
TagValidator validator;
@@ -79,16 +69,16 @@ public class TagREST {
@PostConstruct
public void initStore() {
- tagStore = TagFileStore.getInstance();
+ validator = new TagValidator();
+
tagStore.setServiceStore(svcStore);
- validator = new TagValidator();
validator.setTagStore(tagStore);
}
@POST
@Path(TagRESTConstants.TAGDEFS_RESOURCE)
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public RangerTagDef createTagDef(RangerTagDef tagDef) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.createTagDef(" + tagDef + ")");
@@ -116,8 +106,7 @@ public class TagREST {
@PUT
@Path(TagRESTConstants.TAGDEF_RESOURCE + "/{id}")
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
-
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public RangerTagDef updateTagDef(@PathParam("id") Long id, RangerTagDef tagDef) {
if(LOG.isDebugEnabled()) {
@@ -147,7 +136,7 @@ public class TagREST {
@DELETE
@Path(TagRESTConstants.TAGDEF_RESOURCE + "/{id}")
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public void deleteTagDef(@PathParam("id") Long id) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.deleteTagDef(" + id + ")");
@@ -171,6 +160,7 @@ public class TagREST {
@GET
@Path(TagRESTConstants.TAGDEF_RESOURCE+"/{name}")
@Produces({ "application/json", "application/xml" })
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public List<RangerTagDef> getTagDefByName(@PathParam("name") String name) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.getTagDefByName(" + name + ")");
@@ -179,7 +169,7 @@ public class TagREST {
List<RangerTagDef> ret;
try {
- ret = tagStore.getTagDef(name);
+ ret = tagStore.getTagDefsByName(name);
} catch(Exception excp) {
LOG.error("getTagDefByName(" + name + ") failed", excp);
@@ -200,6 +190,7 @@ public class TagREST {
@GET
@Path(TagRESTConstants.TAGDEFS_RESOURCE)
@Produces({ "application/json", "application/xml" })
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public List<RangerTagDef> getTagDefs() {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.getTagDefs()");
@@ -229,7 +220,7 @@ public class TagREST {
@POST
@Path(TagRESTConstants.TAGS_RESOURCE)
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public RangerTag createTag(RangerTag tag) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.createTag(" + tag + ")");
@@ -256,8 +247,7 @@ public class TagREST {
@PUT
@Path(TagRESTConstants.TAG_RESOURCE + "{id}")
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
-
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public RangerTag updateTagById(@PathParam("id") Long id, RangerTag tag) {
RangerTag ret;
@@ -277,27 +267,26 @@ public class TagREST {
}
@PUT
- @Path(TagRESTConstants.TAG_RESOURCE + "externalId/{externalId}")
+ @Path(TagRESTConstants.TAG_RESOURCE + "guid/{guid}")
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
-
- public RangerTag updateTagByExternalId(@PathParam("externalId") String externalId, RangerTag tag) {
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ public RangerTag updateTagByGuid(@PathParam("guid") String guid, RangerTag tag) {
if(LOG.isDebugEnabled()) {
- LOG.debug("==> TagREST.updateTagByExternalId(" + externalId + ")");
+ LOG.debug("==> TagREST.updateTagByGuid(" + guid + ")");
}
RangerTag ret;
try {
- validator.preUpdateTagByExternalId(externalId, tag);
+ validator.preUpdateTagByGuid(guid, tag);
ret = tagStore.updateTag(tag);
} catch (Exception excp) {
- LOG.error("updateTagByExternalId(" + externalId + ") failed", excp);
+ LOG.error("updateTagByGuid(" + guid + ") failed", excp);
throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
}
if(LOG.isDebugEnabled()) {
- LOG.debug("<== TagREST.updateTagByExternalId(" + externalId + "): " + ret);
+ LOG.debug("<== TagREST.updateTagByGuid(" + guid + "): " + ret);
}
return ret;
@@ -306,8 +295,7 @@ public class TagREST {
@PUT
@Path(TagRESTConstants.TAG_RESOURCE + "name/{name}")
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
-
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public RangerTag updateTagByName(@PathParam("name") String name, RangerTag tag) {
if(LOG.isDebugEnabled()) {
@@ -333,8 +321,7 @@ public class TagREST {
@DELETE
@Path(TagRESTConstants.TAG_RESOURCE + "{id}")
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
-
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public void deleteTagById(@PathParam("id") Long id) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.deleteTagById(" + id +")");
@@ -354,32 +341,32 @@ public class TagREST {
}
@DELETE
- @Path(TagRESTConstants.TAG_RESOURCE + "externalId/{externalId}")
+ @Path(TagRESTConstants.TAG_RESOURCE + "guid/{guid}")
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
- public void deleteTagByExternalId(@PathParam("externalId") String externalId) {
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ public void deleteTagByGuid(@PathParam("guid") String guid) {
if(LOG.isDebugEnabled()) {
- LOG.debug("==> TagREST.deleteTagByExternalId(" + externalId + ")");
+ LOG.debug("==> TagREST.deleteTagByGuid(" + guid + ")");
}
try {
- RangerTag exist = validator.preDeleteTagByExternalId(externalId);
+ RangerTag exist = validator.preDeleteTagByGuid(guid);
tagStore.deleteTagById(exist.getId());
} catch(Exception excp) {
- LOG.error("deleteTagByExternalId(" + externalId + ") failed", excp);
+ LOG.error("deleteTagByGuid(" + guid + ") failed", excp);
throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
}
if(LOG.isDebugEnabled()) {
- LOG.debug("<== TagREST.deleteTagByExternalId(" + externalId + ")");
+ LOG.debug("<== TagREST.deleteTagByGuid(" + guid + ")");
}
}
@DELETE
@Path(TagRESTConstants.TAG_RESOURCE + "name/{name}")
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public void deleteTagByName(@PathParam("name") String name) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.deleteTagByName(" + name + ")");
@@ -402,6 +389,7 @@ public class TagREST {
@GET
@Path(TagRESTConstants.TAGS_RESOURCE + "{id}")
@Produces({ "application/json", "application/xml" })
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public RangerTag getTagById(@PathParam("id") Long id) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.getTagById(" + id + ")");
@@ -424,24 +412,25 @@ public class TagREST {
}
@GET
- @Path(TagRESTConstants.TAGS_RESOURCE + "externalId/{externalId}")
+ @Path(TagRESTConstants.TAGS_RESOURCE + "guid/{guid}")
@Produces({ "application/json", "application/xml" })
- public List<RangerTag> getTagsByExternalId(@PathParam("externalId") String externalId) {
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ public RangerTag getTagByGuid(@PathParam("guid") String guid) {
if(LOG.isDebugEnabled()) {
- LOG.debug("==> TagREST.getTagsByExternalId(" + externalId + ")");
+ LOG.debug("==> TagREST.getTagByGuid(" + guid + ")");
}
- List<RangerTag> ret;
+ RangerTag ret;
try {
- ret = tagStore.getTagsByExternalId(externalId);
+ ret = tagStore.getTagByGuid(guid);
} catch(Exception excp) {
- LOG.error("getTagsByExternalId(" + externalId + ") failed", excp);
+ LOG.error("getTagByGuid(" + guid + ") failed", excp);
throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
}
if(LOG.isDebugEnabled()) {
- LOG.debug("<== TagREST.getTagsByExternalId(" + externalId + "): " + ret);
+ LOG.debug("<== TagREST.getTagByGuid(" + guid + "): " + ret);
}
return ret;
@@ -450,6 +439,7 @@ public class TagREST {
@GET
@Path(TagRESTConstants.TAGS_RESOURCE + "name/{name}")
@Produces({ "application/json", "application/xml" })
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public List<RangerTag> getTagsByName(@PathParam("name") String name) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.getTagsByName(" + name + ")");
@@ -474,6 +464,7 @@ public class TagREST {
@GET
@Path(TagRESTConstants.TAGS_RESOURCE)
@Produces({ "application/json", "application/xml" })
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public List<RangerTag> getAllTags() {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.getAllTags()");
@@ -504,7 +495,7 @@ public class TagREST {
@POST
@Path(TagRESTConstants.RESOURCES_RESOURCE)
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public RangerServiceResource createServiceResource(RangerServiceResource resource) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.createServiceResource(" + resource + ")");
@@ -531,8 +522,7 @@ public class TagREST {
@PUT
@Path(TagRESTConstants.RESOURCE_RESOURCE + "{id}")
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
-
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public RangerServiceResource updateServiceResourceById(@PathParam("id") Long id, RangerServiceResource resource) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.updateServiceResourceById(" + id + ")");
@@ -555,25 +545,24 @@ public class TagREST {
}
@PUT
- @Path(TagRESTConstants.RESOURCE_RESOURCE + "externalId/{externalId}")
+ @Path(TagRESTConstants.RESOURCE_RESOURCE + "guid/{guid}")
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
-
- public RangerServiceResource updateServiceResourceByExternalId(@PathParam("externalId") String externalId, RangerServiceResource resource) {
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ public RangerServiceResource updateServiceResourceByGuid(@PathParam("guid") String guid, RangerServiceResource resource) {
if(LOG.isDebugEnabled()) {
- LOG.debug("==> TagREST.updateServiceResourceByExternalId(" + externalId + ", " + resource + ")");
+ LOG.debug("==> TagREST.updateServiceResourceByGuid(" + guid + ", " + resource + ")");
}
RangerServiceResource ret;
try {
- validator.preUpdateServiceResourceByExternalId(externalId, resource);
+ validator.preUpdateServiceResourceByGuid(guid, resource);
ret = tagStore.updateServiceResource(resource);
} catch(Exception excp) {
- LOG.error("updateServiceResourceByExternalId(" + externalId + ", " + resource + ") failed", excp);
+ LOG.error("updateServiceResourceByGuid(" + guid + ", " + resource + ") failed", excp);
throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
}
if(LOG.isDebugEnabled()) {
- LOG.debug("<== TagREST.updateServiceResourceByExternalId(" + externalId + ", " + resource + "): " + ret);
+ LOG.debug("<== TagREST.updateServiceResourceByGuid(" + guid + ", " + resource + "): " + ret);
}
return ret;
}
@@ -581,7 +570,7 @@ public class TagREST {
@DELETE
@Path(TagRESTConstants.RESOURCE_RESOURCE + "{id}")
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public void deleteServiceResourceById(@PathParam("id") Long id) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.deleteServiceResourceById(" + id + ")");
@@ -601,31 +590,32 @@ public class TagREST {
}
@DELETE
- @Path(TagRESTConstants.RESOURCE_RESOURCE + "externalId/{externalId}")
+ @Path(TagRESTConstants.RESOURCE_RESOURCE + "guid/{guid}")
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
- public void deleteServiceResourceByExternalId(@PathParam("externalId") String externalId) {
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ public void deleteServiceResourceByGuid(@PathParam("guid") String guid) {
if(LOG.isDebugEnabled()) {
- LOG.debug("==> TagREST.deleteServiceResourceByExternalId(" + externalId + ")");
+ LOG.debug("==> TagREST.deleteServiceResourceByGuid(" + guid + ")");
}
try {
- RangerServiceResource exist = validator.preDeleteServiceResourceByExternalId(externalId);
+ RangerServiceResource exist = validator.preDeleteServiceResourceByGuid(guid);
tagStore.deleteServiceResourceById(exist.getId());
} catch(Exception excp) {
- LOG.error("deleteServiceResourceByExternalId(" + externalId + ") failed", excp);
+ LOG.error("deleteServiceResourceByGuid(" + guid + ") failed", excp);
throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
}
if(LOG.isDebugEnabled()) {
- LOG.debug("<== TagREST.deleteServiceResourceByExternalId(" + externalId + ")");
+ LOG.debug("<== TagREST.deleteServiceResourceByGuid(" + guid + ")");
}
}
@GET
@Path(TagRESTConstants.RESOURCES_RESOURCE + "{id}")
@Produces({ "application/json", "application/xml" })
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public RangerServiceResource getServiceResourceById(@PathParam("id") Long id) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> TagREST.getServiceResourceById(" + id + ")");
@@ -645,22 +635,23 @@ public class TagREST {
}
@GET
- @Path(TagRESTConstants.RESOURCES_RESOURCE + "externalId/{externalId}")
+ @Path(TagRESTConstants.RESOURCES_RESOURCE + "guid/{guid}")
@Produces({ "application/json", "application/xml" })
- public List<RangerServiceResource> getServiceResourcesByExternalId(@PathParam("externalId") String externalId) {
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ public RangerServiceResource getServiceResourceByGuid(@PathParam("guid") String guid) {
if(LOG.isDebugEnabled()) {
- LOG.debug("==> TagREST.getServiceResourceByExternalId(" + externalId + ")");
+ LOG.debug("==> TagREST.getServiceResourceByGuid(" + guid + ")");
}
- List<RangerServiceResource> ret;
+ RangerServiceResource ret;
try {
- ret = tagStore.getServiceResourcesByExternalId(externalId);
+ ret = tagStore.getServiceResourceByGuid(guid);
} catch(Exception excp) {
- LOG.error("getServiceResourceByExternalId(" + externalId + ") failed", excp);
+ LOG.error("getServiceResourceByGuid(" + guid + ") failed", excp);
throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
}
if(LOG.isDebugEnabled()) {
- LOG.debug("<== TagREST.getServiceResourceByExternalId(" + externalId + "): " + ret);
+ LOG.debug("<== TagREST.getServiceResourceByGuid(" + guid + "): " + ret);
}
return ret;
}
@@ -668,26 +659,25 @@ public class TagREST {
@POST
@Path(TagRESTConstants.TAGRESOURCEMAPS_RESOURCE)
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
- public RangerTagResourceMap createTagResourceMap(@QueryParam("externalResourceId") String externalResourceId,
- @QueryParam("externalTagId") String externalTagId) {
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ public RangerTagResourceMap createTagResourceMap(@QueryParam("tagGuid") String tagGuid, @QueryParam("resourceGuid") String resourceGuid) {
if(LOG.isDebugEnabled()) {
- LOG.debug("==> TagREST.createTagResourceMap(" + externalResourceId + ", " + externalTagId + ")");
+ LOG.debug("==> TagREST.createTagResourceMap(" + tagGuid + ", " + resourceGuid + ")");
}
RangerTagResourceMap tagResourceMap;
try {
- tagResourceMap = validator.preCreateTagResourceMap(externalResourceId, externalTagId);
+ tagResourceMap = validator.preCreateTagResourceMap(tagGuid, resourceGuid);
tagResourceMap = tagStore.createTagResourceMap(tagResourceMap);
} catch(Exception excp) {
- LOG.error("createTagResourceMap(" + externalResourceId + ", " + externalTagId + ") failed", excp);
+ LOG.error("createTagResourceMap(" + tagGuid + ", " + resourceGuid + ") failed", excp);
throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
}
if(LOG.isDebugEnabled()) {
- LOG.debug("==> TagREST.createTagResourceMap(" + externalResourceId + ", " + externalTagId + ")");
+ LOG.debug("==> TagREST.createTagResourceMap(" + tagGuid + ", " + resourceGuid + ")");
}
return tagResourceMap;
@@ -696,24 +686,23 @@ public class TagREST {
@DELETE
@Path(TagRESTConstants.TAGRESOURCEMAPS_RESOURCE)
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
- public void deleteTagResourceMap(@QueryParam("externalResourceId") String externalResourceId,
- @QueryParam("externalTagId") String externalTagId) {
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ public void deleteTagResourceMap(@QueryParam("tagGuid") String tagGuid, @QueryParam("resourceGuid") String resourceGuid) {
if(LOG.isDebugEnabled()) {
- LOG.debug("==> TagREST.deleteTagResourceMap(" + externalResourceId + ", " + externalTagId + ")");
+ LOG.debug("==> TagREST.deleteTagResourceMap(" + tagGuid + ", " + resourceGuid + ")");
}
try {
- RangerTagResourceMap exist = validator.preDeleteTagResourceMap(externalResourceId, externalTagId);
+ RangerTagResourceMap exist = validator.preDeleteTagResourceMap(tagGuid, resourceGuid);
tagStore.deleteTagResourceMapById(exist.getId());
} catch(Exception excp) {
- LOG.error("deleteTagResourceMap(" + externalResourceId + ", " + externalTagId + ") failed", excp);
+ LOG.error("deleteTagResourceMap(" + tagGuid + ", " + resourceGuid + ") failed", excp);
throw restErrorUtil.createRESTException(HttpServletResponse.SC_BAD_REQUEST, excp.getMessage(), true);
}
if(LOG.isDebugEnabled()) {
- LOG.debug("==> TagREST.deleteTagResourceMap(" + externalResourceId + ", " + externalTagId + ")");
+ LOG.debug("==> TagREST.deleteTagResourceMap(" + tagGuid + ", " + resourceGuid + ")");
}
}
@@ -727,7 +716,7 @@ public class TagREST {
@GET
@Path(TagRESTConstants.RESOURCES_RESOURCE)
@Produces({ "application/json", "application/xml" })
- //@PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public List<RangerServiceResource> getServiceResources(RangerServiceResource resource) throws Exception {
List<RangerServiceResource> ret = null;
@@ -776,6 +765,7 @@ public class TagREST {
@GET
@Path(TagRESTConstants.TAGNAMES_RESOURCE)
@Produces({ "application/json", "application/xml" })
+ @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
public List<String> getTagNames(@QueryParam(TagRESTConstants.SERVICE_NAME_PARAM) String serviceName) {
if(LOG.isDebugEnabled()) {
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/rest/TagRESTConstants.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/rest/TagRESTConstants.java b/security-admin/src/main/java/org/apache/ranger/rest/TagRESTConstants.java
index 915ff13..07a559c 100644
--- a/security-admin/src/main/java/org/apache/ranger/rest/TagRESTConstants.java
+++ b/security-admin/src/main/java/org/apache/ranger/rest/TagRESTConstants.java
@@ -22,25 +22,18 @@ package org.apache.ranger.rest;
public class TagRESTConstants {
public static final String TAGDEF_NAME_AND_VERSION = "tags";
- static final String TAGDEFS_RESOURCE = "/tagdefs/";
- static final String TAGDEF_RESOURCE = "/tagdef/";
-
- static final String TAGS_RESOURCE = "/tags/";
- static final String TAG_RESOURCE = "/tag/";
-
- static final String RESOURCES_RESOURCE = "/resources/";
- static final String RESOURCE_RESOURCE = "/resource/";
-
+ static final String TAGDEFS_RESOURCE = "/tagdefs/";
+ static final String TAGDEF_RESOURCE = "/tagdef/";
+ static final String TAGS_RESOURCE = "/tags/";
+ static final String TAG_RESOURCE = "/tag/";
+ static final String RESOURCES_RESOURCE = "/resources/";
+ static final String RESOURCE_RESOURCE = "/resource/";
static final String TAGRESOURCEMAPS_RESOURCE = "/tagresourcemaps/";
+ static final String TAGNAMES_RESOURCE = "/tags/names/";
+ static final String LOOKUP_TAGS_RESOURCE = "/tags/lookup/";
+ static final String TAGS_DOWNLOAD = "/download/";
-
- static final String TAGNAMES_RESOURCE = "/tags/names/";
- static final String LOOKUP_TAGS_RESOURCE = "/tags/lookup/";
-
- static final String TAGS_DOWNLOAD = "/download/";
-
- public static final String SERVICE_NAME_PARAM = "serviceName";
- public static final String LAST_KNOWN_TAG_VERSION_PARAM = "tagVersion";
- public static final String PATTERN_PARAM = "pattern";
-
+ public static final String SERVICE_NAME_PARAM = "serviceName";
+ public static final String LAST_KNOWN_TAG_VERSION_PARAM = "lastKnownVersion";
+ public static final String PATTERN_PARAM = "pattern";
}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefService.java
index e80ba01..9f9761c 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefService.java
@@ -20,15 +20,6 @@ package org.apache.ranger.service;
import java.util.ArrayList;
import java.util.List;
-import org.apache.ranger.common.SearchField.DATA_TYPE;
-import org.apache.ranger.common.SearchField.SEARCH_TYPE;
-import org.apache.ranger.common.UserSessionBase;
-import org.apache.ranger.entity.XXContextEnricherDef;
-import org.apache.ranger.entity.XXAccessTypeDef;
-import org.apache.ranger.entity.XXEnumDef;
-import org.apache.ranger.entity.XXPolicyConditionDef;
-import org.apache.ranger.entity.XXResourceDef;
-import org.apache.ranger.entity.XXServiceConfigDef;
import org.apache.ranger.entity.XXServiceDef;
import org.apache.ranger.entity.XXServiceDefBase;
import org.apache.ranger.plugin.model.RangerServiceDef;
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/service/RangerServiceResourceService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceResourceService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceResourceService.java
new file mode 100644
index 0000000..3bbd344
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceResourceService.java
@@ -0,0 +1,96 @@
+/*
+ * 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.service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.ranger.common.SearchField;
+import org.apache.ranger.common.SearchField.DATA_TYPE;
+import org.apache.ranger.common.SearchField.SEARCH_TYPE;
+import org.apache.ranger.entity.XXServiceResource;
+import org.apache.ranger.plugin.model.RangerServiceResource;
+import org.apache.ranger.plugin.util.SearchFilter;
+import org.springframework.stereotype.Service;
+
+@Service
+public class RangerServiceResourceService extends RangerServiceResourceServiceBase<XXServiceResource, RangerServiceResource> {
+
+ public RangerServiceResourceService() {
+ searchFields.add(new SearchField(SearchFilter.TAG_RESOURCE_ID, "obj.id", DATA_TYPE.INTEGER, SEARCH_TYPE.FULL));
+ searchFields.add(new SearchField(SearchFilter.TAG_SERVICE_ID, "obj.serviceId", DATA_TYPE.INTEGER, SEARCH_TYPE.FULL));
+ searchFields.add(new SearchField(SearchFilter.TAG_RESOURCE_SIGNATURE, "obj.resourceSignature", DATA_TYPE.STRING, SEARCH_TYPE.FULL));
+ }
+
+ @Override
+ protected void validateForCreate(RangerServiceResource vObj) {
+
+ }
+
+ @Override
+ protected void validateForUpdate(RangerServiceResource vObj, XXServiceResource entityObj) {
+
+ }
+
+ public RangerServiceResource getPopulatedViewObject(XXServiceResource xObj) {
+ return populateViewBean(xObj);
+ }
+
+ public RangerServiceResource getServiceResourceByGuid(String guid) {
+ RangerServiceResource ret = null;
+
+ XXServiceResource xxServiceResource = daoMgr.getXXServiceResource().findByGuid(guid);
+
+ if(xxServiceResource != null) {
+ ret = populateViewBean(xxServiceResource);
+ }
+
+ return ret;
+ }
+
+ public RangerServiceResource getServiceResourceByServiceIdAndResourceSignature(Long serviceId, String resourceSignature) {
+ RangerServiceResource ret = null;
+
+ XXServiceResource xxServiceResource = daoMgr.getXXServiceResource().findByServiceIdAndResourceSignature(serviceId, resourceSignature);
+
+ if(xxServiceResource != null) {
+ ret = populateViewBean(xxServiceResource);
+ }
+
+ return ret;
+ }
+
+ public List<RangerServiceResource> getTaggedResourcesInServiceId(Long serviceId) {
+ List<RangerServiceResource> ret = new ArrayList<RangerServiceResource>();
+
+ List<XXServiceResource> xxServiceResources = daoMgr.getXXServiceResource().findTaggedResourcesInServiceId(serviceId);
+
+ if(CollectionUtils.isNotEmpty(xxServiceResources)) {
+ for(XXServiceResource xxServiceResource : xxServiceResources) {
+ RangerServiceResource serviceResource = populateViewBean(xxServiceResource);
+
+ ret.add(serviceResource);
+ }
+ }
+
+ return ret;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/service/RangerServiceResourceServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceResourceServiceBase.java b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceResourceServiceBase.java
new file mode 100644
index 0000000..f6a1dca
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceResourceServiceBase.java
@@ -0,0 +1,112 @@
+/*
+ * 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.service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.ranger.common.GUIDUtil;
+import org.apache.ranger.common.MessageEnums;
+import org.apache.ranger.entity.XXResourceDef;
+import org.apache.ranger.entity.XXService;
+import org.apache.ranger.entity.XXServiceResource;
+import org.apache.ranger.entity.XXServiceResourceElement;
+import org.apache.ranger.plugin.model.RangerPolicy;
+import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource;
+import org.apache.ranger.plugin.model.RangerServiceResource;
+import org.apache.ranger.plugin.store.PList;
+import org.apache.ranger.plugin.util.SearchFilter;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public abstract class RangerServiceResourceServiceBase<T extends XXServiceResource, V extends RangerServiceResource> extends RangerBaseModelService<T, V> {
+
+ @Autowired
+ GUIDUtil guidUtil;
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected XXServiceResource mapViewToEntityBean(RangerServiceResource vObj, XXServiceResource xObj, int operationContext) {
+ String guid = (StringUtils.isEmpty(vObj.getGuid())) ? guidUtil.genGUID() : vObj.getGuid();
+
+ xObj.setGuid(guid);
+ xObj.setVersion(vObj.getVersion());
+ xObj.setIsEnabled(vObj.getIsEnabled());
+
+ XXService xService = daoMgr.getXXService().findByName(vObj.getServiceName());
+ if (xService == null) {
+ throw restErrorUtil.createRESTException("Error Populating XXServiceResource. No Service found with name: " + vObj.getServiceName(), MessageEnums.INVALID_INPUT_DATA);
+ }
+
+ xObj.setServiceId(xService.getId());
+
+ return xObj;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected RangerServiceResource mapEntityToViewBean(RangerServiceResource vObj, XXServiceResource xObj) {
+ vObj.setGuid(xObj.getGuid());
+ vObj.setVersion(xObj.getVersion());
+ vObj.setIsEnabled(xObj.getIsEnabled());
+
+ XXService xService = daoMgr.getXXService().getById(xObj.getServiceId());
+
+ vObj.setServiceName(xService.getName());
+
+ List<XXServiceResourceElement> resElementList = daoMgr.getXXServiceResourceElement().findByResourceId(xObj.getId());
+ Map<String, RangerPolicy.RangerPolicyResource> resourceSpec = new HashMap<String, RangerPolicy.RangerPolicyResource>();
+
+ for (XXServiceResourceElement resElement : resElementList) {
+ List<String> resValueMapList = daoMgr.getXXServiceResourceElementValue().findValuesByResElementId(resElement.getId());
+
+ XXResourceDef xResDef = daoMgr.getXXResourceDef().getById(resElement.getResDefId());
+
+ RangerPolicyResource policyRes = new RangerPolicyResource();
+ policyRes.setIsExcludes(resElement.getIsExcludes());
+ policyRes.setIsRecursive(resElement.getIsRecursive());
+ policyRes.setValues(resValueMapList);
+
+ resourceSpec.put(xResDef.getName(), policyRes);
+ }
+
+ vObj.setResourceSpec(resourceSpec);
+
+ return vObj;
+ }
+
+ @SuppressWarnings("unchecked")
+ public PList<RangerServiceResource> searchServiceResources(SearchFilter searchFilter) {
+ PList<RangerServiceResource> retList = new PList<RangerServiceResource>();
+ List<RangerServiceResource> resourceList = new ArrayList<RangerServiceResource>();
+
+ List<XXServiceResource> xResourceList = (List<XXServiceResource>) searchRangerObjects(searchFilter, searchFields, sortFields, (PList<V>) retList);
+
+ for (XXServiceResource xResource : xResourceList) {
+ RangerServiceResource taggedRes = populateViewBean((T) xResource);
+ resourceList.add(taggedRes);
+ }
+ retList.setList(resourceList);
+ return retList;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/303f7b70/security-admin/src/main/java/org/apache/ranger/service/RangerTagDefService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerTagDefService.java b/security-admin/src/main/java/org/apache/ranger/service/RangerTagDefService.java
index bd61ff1..462b781 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/RangerTagDefService.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerTagDefService.java
@@ -19,11 +19,17 @@
package org.apache.ranger.service;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.collections.CollectionUtils;
import org.apache.ranger.common.SearchField;
import org.apache.ranger.common.SearchField.DATA_TYPE;
import org.apache.ranger.common.SearchField.SEARCH_TYPE;
import org.apache.ranger.entity.XXTagDef;
+import org.apache.ranger.entity.XXTagResourceMap;
import org.apache.ranger.plugin.model.RangerTagDef;
+import org.apache.ranger.plugin.model.RangerTagResourceMap;
import org.apache.ranger.plugin.util.SearchFilter;
import org.springframework.stereotype.Service;
@@ -32,6 +38,7 @@ public class RangerTagDefService extends RangerTagDefServiceBase<XXTagDef, Range
public RangerTagDefService() {
searchFields.add(new SearchField(SearchFilter.TAG_DEF_ID, "obj.id", DATA_TYPE.INTEGER, SEARCH_TYPE.FULL));
+ searchFields.add(new SearchField(SearchFilter.TAG_DEF_GUID, "obj.guid", DATA_TYPE.STRING, SEARCH_TYPE.FULL));
searchFields.add(new SearchField(SearchFilter.TAG_DEF_NAME, "obj.name", DATA_TYPE.STRING, SEARCH_TYPE.FULL));
}
@@ -45,8 +52,61 @@ public class RangerTagDefService extends RangerTagDefServiceBase<XXTagDef, Range
}
+ @Override
+ public RangerTagDef postUpdate(XXTagDef tagDef) {
+ RangerTagDef ret = super.postUpdate(tagDef);
+
+ daoMgr.getXXTagDef().updateServiceForTagDefUpdate(tagDef.getId(), tagDef.getUpdateTime());
+
+ return ret;
+ }
+
public RangerTagDef getPopulatedViewObject(XXTagDef xObj) {
return populateViewBean(xObj);
}
+ public RangerTagDef getTagDefByGuid(String guid) {
+ RangerTagDef ret = null;
+
+ XXTagDef xxTagDef = daoMgr.getXXTagDef().findByGuid(guid);
+
+ if(xxTagDef != null) {
+ ret = populateViewBean(xxTagDef);
+ }
+
+ return ret;
+ }
+
+ public List<RangerTagDef> getTagDefsByName(String name) {
+ List<RangerTagDef> ret = new ArrayList<RangerTagDef>();
+
+ List<XXTagDef> xxTagDefs = daoMgr.getXXTagDef().findByName(name);
+
+ if(CollectionUtils.isNotEmpty(xxTagDefs)) {
+ for(XXTagDef xxTagDef : xxTagDefs) {
+ RangerTagDef tagDef = populateViewBean(xxTagDef);
+
+ ret.add(tagDef);
+ }
+ }
+
+ return ret;
+ }
+
+ public List<RangerTagDef> getTagDefsByServiceId(Long serviceId) {
+ List<RangerTagDef> ret = new ArrayList<RangerTagDef>();
+
+ List<XXTagDef> xxTagDefs = daoMgr.getXXTagDef().findByServiceId(serviceId);
+
+ if(CollectionUtils.isNotEmpty(xxTagDefs)) {
+ for(XXTagDef xxTagDef : xxTagDefs) {
+ RangerTagDef tagDef = populateViewBean(xxTagDef);
+
+ ret.add(tagDef);
+ }
+ }
+
+ return ret;
+ }
+
}