Source Code Cross Referenced for SYSROUTINEPERMSRowFactory.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » sql » catalog » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db derby 10.2 » org.apache.derby.impl.sql.catalog 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.sql.catalog.SYSROUTINEPERMSRowFactory
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.sql.catalog;
023:
024:        import org.apache.derby.iapi.sql.dictionary.SystemColumn;
025:        import org.apache.derby.iapi.sql.dictionary.TupleDescriptor;
026:        import org.apache.derby.iapi.sql.dictionary.RoutinePermsDescriptor;
027:        import org.apache.derby.iapi.sql.dictionary.DataDictionary;
028:        import org.apache.derby.iapi.sql.dictionary.PermissionsDescriptor;
029:
030:        import org.apache.derby.iapi.error.StandardException;
031:
032:        import org.apache.derby.iapi.services.sanity.SanityManager;
033:        import org.apache.derby.iapi.sql.execute.ExecRow;
034:        import org.apache.derby.iapi.sql.execute.ExecIndexRow;
035:        import org.apache.derby.iapi.sql.execute.ExecutionFactory;
036:        import org.apache.derby.iapi.types.DataValueFactory;
037:        import org.apache.derby.iapi.types.RowLocation;
038:        import org.apache.derby.iapi.types.DataValueDescriptor;
039:        import org.apache.derby.iapi.types.StringDataValue;
040:        import org.apache.derby.iapi.services.uuid.UUIDFactory;
041:        import org.apache.derby.catalog.UUID;
042:
043:        /**
044:         * Factory for creating a SYSROUTINEPERMS row.
045:         *
046:         */
047:
048:        public class SYSROUTINEPERMSRowFactory extends
049:                PermissionsCatalogRowFactory {
050:            static final String TABLENAME_STRING = "SYSROUTINEPERMS";
051:
052:            // Column numbers for the SYSROUTINEPERMS table. 1 based
053:            private static final int ROUTINEPERMSID_COL_NUM = 1;
054:            private static final int GRANTEE_COL_NUM = 2;
055:            private static final int GRANTOR_COL_NUM = 3;
056:            private static final int ALIASID_COL_NUM = 4;
057:            private static final int GRANTOPTION_COL_NUM = 5;
058:            private static final int COLUMN_COUNT = 5;
059:
060:            static final int GRANTEE_ALIAS_GRANTOR_INDEX_NUM = 0;
061:            public static final int ROUTINEPERMSID_INDEX_NUM = 1;
062:            public static final int ALIASID_INDEX_NUM = 2;
063:
064:            private static final int[][] indexColumnPositions = {
065:                    { GRANTEE_COL_NUM, ALIASID_COL_NUM, GRANTOR_COL_NUM },
066:                    { ROUTINEPERMSID_COL_NUM }, { ALIASID_COL_NUM } };
067:
068:            private static final boolean[] indexUniqueness = { true, true,
069:                    false };
070:
071:            private static final String[] uuids = {
072:                    "2057c01b-0103-0e39-b8e7-00000010f010" // catalog UUID
073:                    , "185e801c-0103-0e39-b8e7-00000010f010" // heap UUID
074:                    , "c065801d-0103-0e39-b8e7-00000010f010" // index1
075:                    , "40f70088-010c-4c2f-c8de-0000000f43a0" // index2
076:                    , "08264012-010c-bc85-060d-000000109ab8" // index3
077:            };
078:
079:            private SystemColumn[] columnList;
080:
081:            public SYSROUTINEPERMSRowFactory(UUIDFactory uuidf,
082:                    ExecutionFactory ef, DataValueFactory dvf,
083:                    boolean convertIdToLower) {
084:                super (uuidf, ef, dvf, convertIdToLower);
085:                initInfo(COLUMN_COUNT, TABLENAME_STRING, indexColumnPositions,
086:                        indexUniqueness, uuids);
087:            }
088:
089:            public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent)
090:                    throws StandardException {
091:                UUID oid;
092:                String routinePermID = null;
093:                DataValueDescriptor grantee = null;
094:                DataValueDescriptor grantor = null;
095:                String routineID = null;
096:
097:                if (td == null) {
098:                    grantee = getNullAuthorizationID();
099:                    grantor = getNullAuthorizationID();
100:                } else {
101:                    RoutinePermsDescriptor rpd = (RoutinePermsDescriptor) td;
102:                    oid = rpd.getUUID();
103:                    if (oid == null) {
104:                        oid = getUUIDFactory().createUUID();
105:                        rpd.setUUID(oid);
106:                    }
107:                    routinePermID = oid.toString();
108:                    grantee = getAuthorizationID(rpd.getGrantee());
109:                    grantor = getAuthorizationID(rpd.getGrantor());
110:                    if (rpd.getRoutineUUID() != null)
111:                        routineID = rpd.getRoutineUUID().toString();
112:                }
113:                ExecRow row = getExecutionFactory().getValueRow(COLUMN_COUNT);
114:                row.setColumn(ROUTINEPERMSID_COL_NUM, dvf
115:                        .getCharDataValue(routinePermID));
116:                row.setColumn(GRANTEE_COL_NUM, grantee);
117:                row.setColumn(GRANTOR_COL_NUM, grantor);
118:                row.setColumn(ALIASID_COL_NUM, dvf.getCharDataValue(routineID));
119:                row.setColumn(GRANTOPTION_COL_NUM, dvf.getCharDataValue("N"));
120:                return row;
121:            } // end of makeRow
122:
123:            /** builds a tuple descriptor from a row */
124:            public TupleDescriptor buildDescriptor(ExecRow row,
125:                    TupleDescriptor parentTuple, DataDictionary dataDictionary)
126:                    throws StandardException {
127:                if (SanityManager.DEBUG)
128:                    SanityManager
129:                            .ASSERT(row.nColumns() == COLUMN_COUNT,
130:                                    "Wrong size row passed to SYSROUTINEPERMSRowFactory.buildDescriptor");
131:
132:                String routinePermsUUIDString = row.getColumn(
133:                        ROUTINEPERMSID_COL_NUM).getString();
134:                UUID routinePermsUUID = getUUIDFactory().recreateUUID(
135:                        routinePermsUUIDString);
136:                String aliasUUIDString = row.getColumn(ALIASID_COL_NUM)
137:                        .getString();
138:                UUID aliasUUID = getUUIDFactory().recreateUUID(aliasUUIDString);
139:
140:                RoutinePermsDescriptor routinePermsDesc = new RoutinePermsDescriptor(
141:                        dataDictionary,
142:                        getAuthorizationID(row, GRANTEE_COL_NUM),
143:                        getAuthorizationID(row, GRANTOR_COL_NUM), aliasUUID);
144:                routinePermsDesc.setUUID(routinePermsUUID);
145:                return routinePermsDesc;
146:            } // end of buildDescriptor
147:
148:            /** builds a column list for the catalog */
149:            public SystemColumn[] buildColumnList() {
150:                if (columnList == null) {
151:                    columnList = new SystemColumn[COLUMN_COUNT];
152:
153:                    columnList[ROUTINEPERMSID_COL_NUM - 1] = new SystemColumnImpl(
154:                            convertIdCase("ROUTINEPERMSID"),
155:                            ROUTINEPERMSID_COL_NUM, 0, // precision
156:                            0, // scale
157:                            false, // nullability
158:                            "CHAR", true, 36);
159:                    columnList[GRANTEE_COL_NUM - 1] = new SystemColumnImpl(
160:                            convertIdCase("GRANTEE"),
161:                            GRANTEE_COL_NUM,
162:                            0, // precision
163:                            0, // scale
164:                            false, // nullability
165:                            AUTHORIZATION_ID_TYPE,
166:                            AUTHORIZATION_ID_IS_BUILTIN_TYPE,
167:                            AUTHORIZATION_ID_LENGTH);
168:                    columnList[GRANTOR_COL_NUM - 1] = new SystemColumnImpl(
169:                            convertIdCase("GRANTOR"),
170:                            GRANTOR_COL_NUM,
171:                            0, // precision
172:                            0, // scale
173:                            false, // nullability
174:                            AUTHORIZATION_ID_TYPE,
175:                            AUTHORIZATION_ID_IS_BUILTIN_TYPE,
176:                            AUTHORIZATION_ID_LENGTH);
177:                    columnList[ALIASID_COL_NUM - 1] = new SystemColumnImpl(
178:                            convertIdCase("ALIASID"), ALIASID_COL_NUM, 0, // precision
179:                            0, // scale
180:                            false, // nullability
181:                            "CHAR", // dataType
182:                            true, // built-in type
183:                            36);
184:                    columnList[GRANTOPTION_COL_NUM - 1] = new SystemColumnImpl(
185:                            convertIdCase("GRANTOPTION"), GRANTOPTION_COL_NUM,
186:                            0, // precision
187:                            0, // scale
188:                            false, // nullability
189:                            "CHAR", // dataType
190:                            true, // built-in type
191:                            1);
192:                }
193:                return columnList;
194:            } // end of buildColumnList
195:
196:            /**
197:             * builds an index key row given for a given index number.
198:             */
199:            public ExecIndexRow buildIndexKeyRow(int indexNumber,
200:                    PermissionsDescriptor perm) throws StandardException {
201:                ExecIndexRow row = null;
202:
203:                switch (indexNumber) {
204:                case GRANTEE_ALIAS_GRANTOR_INDEX_NUM:
205:                    // RESOLVE We do not support the FOR GRANT OPTION, so rougine permission rows are unique on the
206:                    // grantee and alias UUID columns. The grantor column will always have the name of the owner of the
207:                    // routine. So the index key, used for searching the index, only has grantee and alias UUID columns.
208:                    // It does not have a grantor column.
209:                    //
210:                    // If we support FOR GRANT OPTION then there may be multiple routine permissions rows for a
211:                    // (grantee, aliasID) combination. Since there is only one kind of routine permission (execute)
212:                    // execute permission checking need not worry about multiple routine permission rows for a
213:                    // (grantee, aliasID) combination, it only cares whether there are any. Grant and revoke must
214:                    // look through multiple rows to see if the current user has grant/revoke permission and use
215:                    // the full key in checking for the pre-existence of the permission being granted or revoked.
216:                    row = getExecutionFactory().getIndexableRow(2);
217:                    row.setColumn(1, getAuthorizationID(perm.getGrantee()));
218:                    String routineUUIDStr = ((RoutinePermsDescriptor) perm)
219:                            .getRoutineUUID().toString();
220:                    row.setColumn(2, getDataValueFactory().getCharDataValue(
221:                            routineUUIDStr));
222:                    break;
223:                case ROUTINEPERMSID_INDEX_NUM:
224:                    row = getExecutionFactory().getIndexableRow(1);
225:                    String routinePermsUUIDStr = perm.getObjectID().toString();
226:                    row.setColumn(1, getDataValueFactory().getCharDataValue(
227:                            routinePermsUUIDStr));
228:                    break;
229:                case ALIASID_INDEX_NUM:
230:                    row = getExecutionFactory().getIndexableRow(1);
231:                    routineUUIDStr = ((RoutinePermsDescriptor) perm)
232:                            .getRoutineUUID().toString();
233:                    row.setColumn(1, getDataValueFactory().getCharDataValue(
234:                            routineUUIDStr));
235:                    break;
236:                }
237:                return row;
238:            } // end of buildIndexKeyRow
239:
240:            public int getPrimaryKeyIndexNumber() {
241:                return GRANTEE_ALIAS_GRANTOR_INDEX_NUM;
242:            }
243:
244:            /**
245:             * Or a set of permissions in with a row from this catalog table
246:             *
247:             * @param row an existing row
248:             * @param perm a permission descriptor of the appropriate class for this PermissionsCatalogRowFactory class.
249:             * @param colsChanged An array with one element for each column in row. It is updated to
250:             *                    indicate which columns in row were changed
251:             *
252:             * @return The number of columns that were changed.
253:             *
254:             * @exception StandardException standard error policy
255:             */
256:            public int orPermissions(ExecRow row, PermissionsDescriptor perm,
257:                    boolean[] colsChanged) throws StandardException {
258:                // There is only one kind of routine permission: execute or not. So the row would not exist
259:                // unless execute permission is there.
260:                // This changes if we implement WITH GRANT OPTION.
261:                return 0;
262:            }
263:
264:            /**
265:             * Remove a set of permissions from a row from this catalog table
266:             *
267:             * @param row an existing row
268:             * @param perm a permission descriptor of the appropriate class for this PermissionsCatalogRowFactory class.
269:             * @param colsChanged An array with one element for each column in row. It is updated to
270:             *                    indicate which columns in row were changed
271:             *
272:             * @return -1 if there are no permissions left in the row, otherwise the number of columns that were changed.
273:             *
274:             * @exception StandardException standard error policy
275:             */
276:            public int removePermissions(ExecRow row,
277:                    PermissionsDescriptor perm, boolean[] colsChanged)
278:                    throws StandardException {
279:                return -1; // There is only one kind of routine privilege so delete the whole row.
280:            } // end of removePermissions
281:
282:            /** 
283:             * @see PermissionsCatalogRowFactory#setUUIDOfThePassedDescriptor
284:             */
285:            public void setUUIDOfThePassedDescriptor(ExecRow row,
286:                    PermissionsDescriptor perm) throws StandardException {
287:                DataValueDescriptor existingPermDVD = row
288:                        .getColumn(ROUTINEPERMSID_COL_NUM);
289:                perm.setUUID(getUUIDFactory().recreateUUID(
290:                        existingPermDVD.getString()));
291:            }
292:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.