1 21 22 package org.apache.derby.iapi.sql.dictionary; 23 24 import org.apache.derby.catalog.Dependable; 25 import org.apache.derby.catalog.DependableFinder; 26 import org.apache.derby.catalog.UUID; 27 28 import org.apache.derby.iapi.error.StandardException; 29 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 30 import org.apache.derby.iapi.services.io.FormatableBitSet; 31 import org.apache.derby.iapi.services.io.StoredFormatIds; 32 import org.apache.derby.impl.sql.catalog.DDdependableFinder; 33 34 38 public class ColPermsDescriptor extends PermissionsDescriptor 39 { 40 private UUID tableUUID; 41 private String type; 42 private FormatableBitSet columns; 43 private String tableName; 44 45 public ColPermsDescriptor( DataDictionary dd, 46 String grantee, 47 String grantor, 48 UUID tableUUID, 49 String type, 50 FormatableBitSet columns) throws StandardException 51 { 52 super (dd, grantee, grantor); 53 this.tableUUID = tableUUID; 54 this.type = type; 55 this.columns = columns; 56 if (tableUUID != null) 59 tableName = dd.getTableDescriptor(tableUUID).getName(); 60 } 61 62 65 public ColPermsDescriptor( DataDictionary dd, 66 String grantee, 67 String grantor, 68 UUID tableUUID, 69 String type) throws StandardException 70 { 71 this( dd, grantee, grantor, tableUUID, type, (FormatableBitSet) null); 72 } 73 74 public ColPermsDescriptor( DataDictionary dd, 75 UUID colPermsUUID) throws StandardException 76 { 77 super(dd,null,null); 78 this.oid = colPermsUUID; 79 } 80 81 public int getCatalogNumber() 82 { 83 return DataDictionary.SYSCOLPERMS_CATALOG_NUM; 84 } 85 86 87 public UUID getTableUUID() { return tableUUID;} 88 public String getType() { return type;} 89 public FormatableBitSet getColumns() { return columns;} 90 91 public String toString() 92 { 93 return "colPerms: grantee=" + getGrantee() + 94 ",colPermsUUID=" + getUUID() + 95 ",grantor=" + getGrantor() + 96 ",tableUUID=" + getTableUUID() + 97 ",type=" + getType() + 98 ",columns=" + getColumns(); 99 } 100 101 105 public boolean equals( Object other) 106 { 107 if( !( other instanceof ColPermsDescriptor)) 108 return false; 109 ColPermsDescriptor otherColPerms = (ColPermsDescriptor) other; 110 return super.keyEquals( otherColPerms) && 111 tableUUID.equals( otherColPerms.tableUUID) && 112 ((type == null) ? (otherColPerms.type == null) : type.equals( otherColPerms.type)); 113 } 114 115 118 public int hashCode() 119 { 120 return super.keyHashCode() + tableUUID.hashCode() + 121 ((type == null) ? 0 : type.hashCode()); 122 } 123 124 127 public boolean checkOwner(String authorizationId) throws StandardException 128 { 129 TableDescriptor td = getDataDictionary().getTableDescriptor(tableUUID); 130 if (td.getSchemaDescriptor().getAuthorizationId().equals(authorizationId)) 131 return true; 132 else 133 return false; 134 } 135 136 142 147 public String getObjectName() 148 { 149 return "Column Privilege on " + tableName; 150 } 151 152 157 public String getClassType() 158 { 159 return Dependable.COLUMNS_PERMISSION; 160 } 161 162 167 public DependableFinder getDependableFinder() 168 { 169 return new DDdependableFinder(StoredFormatIds.COLUMNS_PERMISSION_FINDER_V01_ID); 170 } 171 172 } 173 | Popular Tags |