--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.iapi.sql.dictionary.TablePermsDescriptor\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.iapi.sql.dictionary;\r
+\r
+import org.apache.derby.catalog.Dependable;\r
+import org.apache.derby.catalog.DependableFinder;\r
+import org.apache.derby.catalog.UUID;\r
+\r
+import org.apache.derby.iapi.services.io.StoredFormatIds;\r
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;\r
+import org.apache.derby.iapi.error.StandardException;\r
+import org.apache.derby.impl.sql.catalog.DDdependableFinder;\r
+\r
+/**\r
+ * This class describes a row in the SYS.SYSTABLEPERMS system table, which\r
+ * stores the table permissions that have been granted but not revoked.\r
+ */\r
+public class TablePermsDescriptor extends PermissionsDescriptor\r
+{\r
+ private UUID tableUUID;\r
+ private String tableName;\r
+ private String selectPriv;\r
+ private String deletePriv;\r
+ private String insertPriv;\r
+ private String updatePriv;\r
+ private String referencesPriv;\r
+ private String triggerPriv;\r
+ \r
+ public TablePermsDescriptor( DataDictionary dd,\r
+ String grantee,\r
+ String grantor,\r
+ UUID tableUUID,\r
+ String selectPriv,\r
+ String deletePriv,\r
+ String insertPriv,\r
+ String updatePriv,\r
+ String referencesPriv,\r
+ String triggerPriv) throws StandardException\r
+ {\r
+ super (dd, grantee, grantor);\r
+ this.tableUUID = tableUUID;\r
+ this.selectPriv = selectPriv;\r
+ this.deletePriv = deletePriv;\r
+ this.insertPriv = insertPriv;\r
+ this.updatePriv = updatePriv;\r
+ this.referencesPriv = referencesPriv;\r
+ this.triggerPriv = triggerPriv;\r
+ //tableUUID can be null only if the constructor with tablePermsUUID\r
+ //has been invoked.\r
+ if (tableUUID != null)\r
+ tableName = dd.getTableDescriptor(tableUUID).getName();\r
+ }\r
+\r
+ /**\r
+ * This constructor just sets up the key fields of a TablePermsDescriptor\r
+ */\r
+ public TablePermsDescriptor( DataDictionary dd,\r
+ String grantee,\r
+ String grantor,\r
+ UUID tableUUID) throws StandardException\r
+ {\r
+ this( dd, grantee, grantor, tableUUID,\r
+ (String) null, (String) null, (String) null, (String) null, (String) null, (String) null);\r
+ }\r
+ \r
+ public TablePermsDescriptor( DataDictionary dd,\r
+ UUID tablePermsUUID) throws StandardException\r
+ {\r
+ this( dd, null, null, null,\r
+ (String) null, (String) null, (String) null, (String) null, (String) null, (String) null);\r
+ this.oid = tablePermsUUID;\r
+ }\r
+\r
+ public int getCatalogNumber()\r
+ {\r
+ return DataDictionary.SYSTABLEPERMS_CATALOG_NUM;\r
+ }\r
+ \r
+ /*----- getter functions for rowfactory ------*/\r
+ public UUID getTableUUID() { return tableUUID;}\r
+ public String getSelectPriv() { return selectPriv;}\r
+ public String getDeletePriv() { return deletePriv;}\r
+ public String getInsertPriv() { return insertPriv;}\r
+ public String getUpdatePriv() { return updatePriv;}\r
+ public String getReferencesPriv() { return referencesPriv;}\r
+ public String getTriggerPriv() { return triggerPriv;}\r
+\r
+ public String toString()\r
+ {\r
+ return "tablePerms: grantee=" + getGrantee() +\r
+ ",tablePermsUUID=" + getUUID() +\r
+ ",grantor=" + getGrantor() +\r
+ ",tableUUID=" + getTableUUID() +\r
+ ",selectPriv=" + getSelectPriv() +\r
+ ",deletePriv=" + getDeletePriv() +\r
+ ",insertPriv=" + getInsertPriv() +\r
+ ",updatePriv=" + getUpdatePriv() +\r
+ ",referencesPriv=" + getReferencesPriv() +\r
+ ",triggerPriv=" + getTriggerPriv();\r
+ }\r
+\r
+ /**\r
+ * @return true iff the key part of this permissions descriptor equals the key part of another permissions\r
+ * descriptor.\r
+ */\r
+ public boolean equals( Object other)\r
+ {\r
+ if( !( other instanceof TablePermsDescriptor))\r
+ return false;\r
+ TablePermsDescriptor otherTablePerms = (TablePermsDescriptor) other;\r
+ return super.keyEquals( otherTablePerms) && tableUUID.equals( otherTablePerms.tableUUID);\r
+ }\r
+ \r
+ /**\r
+ * @return the hashCode for the key part of this permissions descriptor\r
+ */\r
+ public int hashCode()\r
+ {\r
+ return super.keyHashCode() + tableUUID.hashCode();\r
+ }\r
+ \r
+ /**\r
+ * @see PermissionsDescriptor#checkOwner\r
+ */\r
+ public boolean checkOwner(String authorizationId) throws StandardException\r
+ {\r
+ TableDescriptor td = getDataDictionary().getTableDescriptor(tableUUID);\r
+ if (td.getSchemaDescriptor().getAuthorizationId().equals(authorizationId))\r
+ return true;\r
+ else\r
+ return false;\r
+ }\r
+\r
+ //////////////////////////////////////////////\r
+ //\r
+ // PROVIDER INTERFACE\r
+ //\r
+ //////////////////////////////////////////////\r
+\r
+ /**\r
+ * Return the name of this Provider. (Useful for errors.)\r
+ *\r
+ * @return String The name of this provider.\r
+ */\r
+ public String getObjectName()\r
+ {\r
+ return "Table Privilege on " + tableName; \r
+ }\r
+\r
+ /**\r
+ * Get the provider's type.\r
+ *\r
+ * @return char The provider's type.\r
+ */\r
+ public String getClassType()\r
+ {\r
+ return Dependable.TABLE_PERMISSION;\r
+ }\r
+\r
+ /** \r
+ @return the stored form of this provider\r
+\r
+ @see Dependable#getDependableFinder\r
+ */\r
+ public DependableFinder getDependableFinder() \r
+ {\r
+ return new DDdependableFinder(StoredFormatIds.TABLE_PERMISSION_FINDER_V01_ID);\r
+ }\r
+}\r