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.services.io.StoredFormatIds; 29 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 30 import org.apache.derby.iapi.error.StandardException; 31 import org.apache.derby.impl.sql.catalog.DDdependableFinder; 32 33 37 public class TablePermsDescriptor extends PermissionsDescriptor 38 { 39 private UUID tableUUID; 40 private String tableName; 41 private String selectPriv; 42 private String deletePriv; 43 private String insertPriv; 44 private String updatePriv; 45 private String referencesPriv; 46 private String triggerPriv; 47 48 public TablePermsDescriptor( DataDictionary dd, 49 String grantee, 50 String grantor, 51 UUID tableUUID, 52 String selectPriv, 53 String deletePriv, 54 String insertPriv, 55 String updatePriv, 56 String referencesPriv, 57 String triggerPriv) throws StandardException 58 { 59 super (dd, grantee, grantor); 60 this.tableUUID = tableUUID; 61 this.selectPriv = selectPriv; 62 this.deletePriv = deletePriv; 63 this.insertPriv = insertPriv; 64 this.updatePriv = updatePriv; 65 this.referencesPriv = referencesPriv; 66 this.triggerPriv = triggerPriv; 67 if (tableUUID != null) 70 tableName = dd.getTableDescriptor(tableUUID).getName(); 71 } 72 73 76 public TablePermsDescriptor( DataDictionary dd, 77 String grantee, 78 String grantor, 79 UUID tableUUID) throws StandardException 80 { 81 this( dd, grantee, grantor, tableUUID, 82 (String ) null, (String ) null, (String ) null, (String ) null, (String ) null, (String ) null); 83 } 84 85 public TablePermsDescriptor( DataDictionary dd, 86 UUID tablePermsUUID) throws StandardException 87 { 88 this( dd, null, null, null, 89 (String ) null, (String ) null, (String ) null, (String ) null, (String ) null, (String ) null); 90 this.oid = tablePermsUUID; 91 } 92 93 public int getCatalogNumber() 94 { 95 return DataDictionary.SYSTABLEPERMS_CATALOG_NUM; 96 } 97 98 99 public UUID getTableUUID() { return tableUUID;} 100 public String getSelectPriv() { return selectPriv;} 101 public String getDeletePriv() { return deletePriv;} 102 public String getInsertPriv() { return insertPriv;} 103 public String getUpdatePriv() { return updatePriv;} 104 public String getReferencesPriv() { return referencesPriv;} 105 public String getTriggerPriv() { return triggerPriv;} 106 107 public String toString() 108 { 109 return "tablePerms: grantee=" + getGrantee() + 110 ",tablePermsUUID=" + getUUID() + 111 ",grantor=" + getGrantor() + 112 ",tableUUID=" + getTableUUID() + 113 ",selectPriv=" + getSelectPriv() + 114 ",deletePriv=" + getDeletePriv() + 115 ",insertPriv=" + getInsertPriv() + 116 ",updatePriv=" + getUpdatePriv() + 117 ",referencesPriv=" + getReferencesPriv() + 118 ",triggerPriv=" + getTriggerPriv(); 119 } 120 121 125 public boolean equals( Object other) 126 { 127 if( !( other instanceof TablePermsDescriptor)) 128 return false; 129 TablePermsDescriptor otherTablePerms = (TablePermsDescriptor) other; 130 return super.keyEquals( otherTablePerms) && tableUUID.equals( otherTablePerms.tableUUID); 131 } 132 133 136 public int hashCode() 137 { 138 return super.keyHashCode() + tableUUID.hashCode(); 139 } 140 141 144 public boolean checkOwner(String authorizationId) throws StandardException 145 { 146 TableDescriptor td = getDataDictionary().getTableDescriptor(tableUUID); 147 if (td.getSchemaDescriptor().getAuthorizationId().equals(authorizationId)) 148 return true; 149 else 150 return false; 151 } 152 153 159 164 public String getObjectName() 165 { 166 return "Table Privilege on " + tableName; 167 } 168 169 174 public String getClassType() 175 { 176 return Dependable.TABLE_PERMISSION; 177 } 178 179 184 public DependableFinder getDependableFinder() 185 { 186 return new DDdependableFinder(StoredFormatIds.TABLE_PERMISSION_FINDER_V01_ID); 187 } 188 } 189 | Popular Tags |