1 17 package org.alfresco.repo.security.permissions.impl.hibernate; 18 19 import org.alfresco.util.EqualsHelper; 20 21 26 public class PermissionEntryImpl implements PermissionEntry 27 { 28 31 private long id; 32 33 36 private NodePermissionEntry nodePermissionEntry; 37 38 42 private PermissionReference permissionReference; 43 44 48 private Recipient recipient; 49 50 53 private boolean allowed; 54 55 public PermissionEntryImpl() 56 { 57 super(); 58 } 59 60 public long getId() 61 { 62 return id; 63 } 64 65 67 void setId(long id) 68 { 69 this.id = id; 70 } 71 72 public NodePermissionEntry getNodePermissionEntry() 73 { 74 return nodePermissionEntry; 75 } 76 77 private void setNodePermissionEntry(NodePermissionEntry nodePermissionEntry) 78 { 79 this.nodePermissionEntry = nodePermissionEntry; 80 } 81 82 public PermissionReference getPermissionReference() 83 { 84 return permissionReference; 85 } 86 87 private void setPermissionReference(PermissionReference permissionReference) 88 { 89 this.permissionReference = permissionReference; 90 } 91 92 public Recipient getRecipient() 93 { 94 return recipient; 95 } 96 97 private void setRecipient(Recipient recipient) 98 { 99 this.recipient = recipient; 100 } 101 102 public boolean isAllowed() 103 { 104 return allowed; 105 } 106 107 public void setAllowed(boolean allowed) 108 { 109 this.allowed = allowed; 110 } 111 112 113 122 public static PermissionEntryImpl create(NodePermissionEntry nodePermissionEntry, PermissionReference permissionReference, Recipient recipient, boolean allowed) 123 { 124 PermissionEntryImpl permissionEntry = new PermissionEntryImpl(); 125 permissionEntry.setNodePermissionEntry(nodePermissionEntry); 126 permissionEntry.setPermissionReference(permissionReference); 127 permissionEntry.setRecipient(recipient); 128 permissionEntry.setAllowed(allowed); 129 nodePermissionEntry.getPermissionEntries().add(permissionEntry); 130 return permissionEntry; 131 } 132 133 136 public void delete() 137 { 138 nodePermissionEntry.getPermissionEntries().remove(this); 139 } 140 141 145 @Override 146 public boolean equals(Object o) 147 { 148 if (this == o) 149 { 150 return true; 151 } 152 if (!(o instanceof PermissionEntryImpl)) 153 { 154 return false; 155 } 156 PermissionEntryImpl other = (PermissionEntryImpl) o; 157 return EqualsHelper.nullSafeEquals(this.nodePermissionEntry, 158 other.nodePermissionEntry) 159 && EqualsHelper.nullSafeEquals(this.permissionReference, 160 other.permissionReference) 161 && EqualsHelper.nullSafeEquals(this.recipient, other.recipient) 162 && (this.allowed == other.allowed); 163 } 164 165 @Override 166 public int hashCode() 167 { 168 int hashCode = nodePermissionEntry.hashCode(); 169 if (permissionReference != null) 170 { 171 hashCode = hashCode * 37 + permissionReference.hashCode(); 172 } 173 if (recipient != null) 174 { 175 hashCode = hashCode * 37 + recipient.hashCode(); 176 } 177 hashCode = hashCode * 37 + (allowed ? 1 : 0); 178 return hashCode; 179 } 180 181 } 182 | Popular Tags |