Skip to content

Commit

Permalink
TEIID-3097 validating model names cannot contain .
Browse files Browse the repository at this point in the history
Conflicts:
	runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
	runtime/src/main/resources/org/teiid/runtime/i18n.properties
  • Loading branch information
shawkins committed Aug 21, 2014
1 parent b0b7fe5 commit 19bebb6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
Expand Up @@ -77,6 +77,9 @@ public void addMetadataRepository(String name, MetadataRepository<?, ?> metadata

protected void assignMetadataRepositories(VDBMetaData deployment, MetadataRepository<?, ?> defaultRepo) throws VirtualDatabaseException {
for (ModelMetaData model:deployment.getModelMetaDatas().values()) {
if (model.getModelType() != Type.OTHER && (model.getName() == null || model.getName().indexOf('.') >= 0)) {
throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40121, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40121, model.getName(), deployment.getName(), deployment.getVersion()));
}
if (model.isSource() && model.getSourceNames().isEmpty()) {
throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40093, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40093, model.getName(), deployment.getName(), deployment.getVersion()));
}
Expand Down
6 changes: 5 additions & 1 deletion runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
Expand Up @@ -128,6 +128,10 @@ public static enum Event implements BundleUtil.Event{
TEIID40114,
TEIID40115,
TEIID40116,
TEIID40117,
TEIID40117,
TEIID40118,
TEIID40119,
TEIID40120,
TEIID40121, //invalid model name
}
}
6 changes: 6 additions & 0 deletions runtime/src/main/resources/org/teiid/runtime/i18n.properties
Expand Up @@ -117,3 +117,9 @@ TEIID40114=Unhandled exception, closing client instance: {0}
TEIID40115=Local pass-through connection implicitly closing session {0} so that the connection can be used in a different security context.
TEIID40116=No Security Domain configured for Teiid for authentication
TEIID40117=No authentication being performed as part of this connection request.

TEIID40118=VDB {0}.{1} added to the repository - is reloading {2}
TEIID40119=VDB {0}.{1} removed from the repository
TEIID40120=VDB {0}.{1} will be removed from the repository

TEIID40121=In VDB {1}.{2} model "{0}" has an invalid name. Model names must be non-null and not contain a dot '.' character.
10 changes: 10 additions & 0 deletions runtime/src/test/java/org/teiid/runtime/TestEmbeddedServer.java
Expand Up @@ -304,6 +304,16 @@ public int[] getUpdateCounts() throws DataNotAvailableException,
assertNull(es.getSchemaDdl("empty", "xxx"));
}

@Test(expected=VirtualDatabaseException.class) public void testInvalidName() throws Exception {
es.start(new EmbeddedConfiguration());
ModelMetaData mmd1 = new ModelMetaData();
mmd1.setName("virt.1");
mmd1.setModelType(Type.VIRTUAL);
mmd1.setSchemaSourceType("ddl");
mmd1.setSchemaText("create view \"my-view\" as select 1");
es.deployVDB("x", mmd1);
}

@Test public void testDeployZip() throws Exception {
es.start(new EmbeddedConfiguration());

Expand Down

0 comments on commit 19bebb6

Please sign in to comment.