Author: rareddy
Date: 2010-09-24 14:16:49 -0400 (Fri, 24 Sep 2010)
New Revision: 2600
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
Log:
TEIID-1275: fixing the code to get model-id correctly from element symbols.
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java 2010-09-23
21:09:51 UTC (rev 2599)
+++
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java 2010-09-24
18:16:49 UTC (rev 2600)
@@ -231,22 +231,18 @@
Object metadataID = null;
if(symbol instanceof ElementSymbol) {
metadataID = ((ElementSymbol)symbol).getMetadataID();
- if (metadataID instanceof MultiSourceElement || metadataID instanceof
TempMetadataID) {
+ GroupSymbol groupSymbol = ((ElementSymbol)symbol).getGroupSymbol();
+ if (metadataID instanceof MultiSourceElement || metadataID instanceof
TempMetadataID || groupSymbol == null || isSystemModel(groupSymbol.getMetadataID())) {
continue;
}
} else if(symbol instanceof GroupSymbol) {
GroupSymbol group = (GroupSymbol)symbol;
metadataID = group.getMetadataID();
- if (metadataID instanceof TempMetadataID &&
!group.isProcedure()) {
+ if ((metadataID instanceof TempMetadataID &&
!group.isProcedure()) || isSystemModel(metadataID)) {
continue;
}
}
fullName = getMetadata().getFullName(metadataID);
- Object modelId = getMetadata().getModelID(metadataID);
- String modelName = getMetadata().getFullName(modelId);
- if (CoreConstants.SYSTEM_MODEL.equals(modelName) ||
CoreConstants.ODBC_MODEL.equals(modelName)) {
- continue;
- }
nameToSymbolMap.put(fullName, symbol);
} catch(QueryMetadataException e) {
handleException(e);
@@ -273,6 +269,12 @@
}
}
+
+ private boolean isSystemModel(Object groupMetadataID) throws QueryMetadataException,
TeiidComponentException {
+ Object modelId = getMetadata().getModelID(groupMetadataID);
+ String modelName = getMetadata().getFullName(modelId);
+ return (CoreConstants.SYSTEM_MODEL.equals(modelName) ||
CoreConstants.ODBC_MODEL.equals(modelName));
+ }
/**
* Out of resources specified, return the subset for which the specified not have
authorization to access.
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2010-09-23
21:09:51 UTC (rev 2599)
+++
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2010-09-24
18:16:49 UTC (rev 2600)
@@ -296,4 +296,7 @@
}
}
+ @Test public void testSystemTablesAccessible() throws Exception {
+ helpTest(exampleAuthSvc2(), "select * from Sys.tables",
FakeMetadataFactory.example1Cached(), new String[] {}, FakeMetadataFactory.example1VDB());
//$NON-NLS-1$ //$NON-NLS-2$
+ }
}
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2010-09-23
21:09:51 UTC (rev 2599)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2010-09-24
18:16:49 UTC (rev 2600)
@@ -178,6 +178,7 @@
FakeMetadataObject vm1 = createVirtualModel("vm1"); //$NON-NLS-1$
FakeMetadataObject vm2 = createVirtualModel("vm2"); //$NON-NLS-1$
FakeMetadataObject tm1 = createVirtualModel("tm1"); //$NON-NLS-1$
+ FakeMetadataObject sys = createPhysicalModel("SYS"); //$NON-NLS-1$
// Create physical groups
FakeMetadataObject pm1g1 = createPhysicalGroup("pm1.g1", pm1); //$NON-NLS-1$
@@ -198,6 +199,7 @@
FakeMetadataObject pm5g2 = createPhysicalGroup("pm5.g2", pm5); //$NON-NLS-1$
FakeMetadataObject pm5g3 = createPhysicalGroup("pm5.g3", pm5); //$NON-NLS-1$
FakeMetadataObject pm6g1 = createPhysicalGroup("pm6.g1", pm6);
//$NON-NLS-1$
+ FakeMetadataObject sysTables = createPhysicalGroup("SYS.Tables", sys);
//$NON-NLS-1$
// Create physical elements
@@ -258,6 +260,9 @@
List pm6g1e = createElements(pm6g1,
new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER });
+ List sysTablese = createElements(sysTables,
+ new String[] { "e1", "e2" }, //$NON-NLS-1$
//$NON-NLS-2$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING,
DataTypeManager.DefaultDataTypes.INTEGER });
// Create access patterns - pm4
@@ -1237,6 +1242,10 @@
store.addObject(pm6);
store.addObject(pm6g1);
store.addObjects(pm6g1e);
+
+ store.addObject(sys);
+ store.addObject(sysTables);
+ store.addObjects(sysTablese);
store.addObject(tm1);
store.addObject(tm1g1);
Show replies by date