Skip to content

Commit

Permalink
KYLO-3171 add principalType to feed acl id (equals/hashcode)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottreisdorf committed Dec 5, 2018
1 parent 0859706 commit 46240d8
Showing 1 changed file with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
*
*
*/
package com.thinkbiganalytics.metadata.jpa.feed.security;

Expand All @@ -12,9 +12,9 @@
* Licensed 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.
Expand Down Expand Up @@ -51,39 +51,39 @@
*/
@Entity
@Table(name = "FEED_ACL_INDEX")
public class JpaFeedOpsAclEntry implements FeedOpsAclEntry, Serializable{
public class JpaFeedOpsAclEntry implements FeedOpsAclEntry, Serializable {

@EmbeddedId
private EntryId id;

@Column(name = "feed_id", insertable = false, updatable = false)
private UUID feedId;

@Column(name = "principal", insertable = false, updatable = false)
private String principalName;

@Enumerated(EnumType.STRING)
@Column(name = "principal_type", insertable = false, updatable = false)
@QueryType(PropertyType.ENUM)
private com.thinkbiganalytics.metadata.api.feed.security.FeedOpsAclEntry.PrincipalType principalType = com.thinkbiganalytics.metadata.api.feed.security.FeedOpsAclEntry.PrincipalType.USER;
private com.thinkbiganalytics.metadata.api.feed.security.FeedOpsAclEntry.PrincipalType principalType = com.thinkbiganalytics.metadata.api.feed.security.FeedOpsAclEntry.PrincipalType.USER;

@ManyToOne(targetEntity = JpaOpsManagerFeed.class, fetch = FetchType.LAZY, optional = true)
@JoinColumn(name = "FEED_ID", nullable = true, insertable = false, updatable = false)
private OpsManagerFeed feed;

public JpaFeedOpsAclEntry() {
super();
}

public JpaFeedOpsAclEntry(Feed.ID id, Principal principal) {
this(id, principal.getName(), principal instanceof Group ? PrincipalType.GROUP : PrincipalType.USER);
}

public JpaFeedOpsAclEntry(Feed.ID id, String principalName, PrincipalType type) {
this.id = new EntryId(UUID.fromString(id.toString()), principalName, type);
}


@Override
public UUID getFeedId() {
return this.feedId != null ? this.feedId : (this.getId() != null ? this.getId().getUuid() : null);
Expand All @@ -96,7 +96,7 @@ public String getPrincipalName() {

@Override
public com.thinkbiganalytics.metadata.api.feed.security.FeedOpsAclEntry.PrincipalType getPrincipalType() {
return this.getId() != null && this.getId().getPrincipalType() != null ? this.getId().getPrincipalType() : this.principalType;
return this.getId() != null && this.getId().getPrincipalType() != null ? this.getId().getPrincipalType() : this.principalType;
}

@Override
Expand Down Expand Up @@ -164,23 +164,23 @@ public void setPrincipalType(PrincipalType principalType) {
}

@Override
public int hashCode() {
return Objects.hash(getUuid(), getPrincipalName());
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass().isAssignableFrom(obj.getClass())) {
EntryId that = (EntryId) obj;
return Objects.equals(getUuid(), that.getUuid()) && Objects.equals(getPrincipalName(), that.getPrincipalName());
} else {
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof EntryId)) {
return false;
}
EntryId entryId = (EntryId) o;
return Objects.equals(uuid, entryId.uuid) &&
Objects.equals(principalName, entryId.principalName) &&
principalType == entryId.principalType;
}


@Override
public int hashCode() {
return Objects.hash(uuid, principalName, principalType);
}
}

}

0 comments on commit 46240d8

Please sign in to comment.