Skip to content

Commit 758f3a8

Browse files
committed
setup SqlGuard, prev. version lived in rdb
- Create `pom.xml` for `guard/api` and `guard/jsqltranspiler` - Add `SqlGuard` and `SqlGuardFactory` interfaces - Define `DatabaseCatalog`, `DatabaseSchema`, `DatabaseTable`, and `DatabaseColumn` - Implement custom exceptions in `guard/api/exception` - Add OSGi annotations in `package-info.java` files - Implement `TranspilerSqlGuard` and `TranspilerSqlGuardFactory` classes - Add unit tests for `SqlGuard` implementation in `jsqltranspiler` module - Create `test.bndrun` for `jsqltranspiler` module - Add `pom.xml` for `guard` module and update root `pom.xml` - Set Java version to 17 and include dependencies for SLF4J, Mockito, and AssertJ Signed-off-by: Stefan Bischof <[email protected]>
1 parent 870cf01 commit 758f3a8

File tree

23 files changed

+1114
-4
lines changed

23 files changed

+1114
-4
lines changed

guard/api/pom.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/*********************************************************************
4+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
5+
*
6+
* This program and the accompanying materials are made
7+
* available under the terms of the Eclipse Public License 2.0
8+
* which is available at https://www.eclipse.org/legal/epl-2.0/
9+
*
10+
* SPDX-License-Identifier: EPL-2.0
11+
**********************************************************************/
12+
-->
13+
<project xmlns="http://maven.apache.org/POM/4.0.0"
14+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
16+
<modelVersion>4.0.0</modelVersion>
17+
<parent>
18+
<groupId>org.eclipse.daanse</groupId>
19+
<artifactId>org.eclipse.daanse.sql.guard</artifactId>
20+
<version>${revision}</version>
21+
</parent>
22+
<artifactId>org.eclipse.daanse.sql.guard.api</artifactId>
23+
24+
25+
</project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
package org.eclipse.daanse.sql.guard.api;
15+
16+
import org.eclipse.daanse.sql.guard.api.exception.GuardException;
17+
18+
public interface SqlGuard {
19+
20+
String guard(String sql) throws GuardException;
21+
22+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
package org.eclipse.daanse.sql.guard.api;
15+
16+
import org.eclipse.daanse.sql.guard.api.elements.DatabaseCatalog;
17+
18+
public interface SqlGuardFactory {
19+
20+
SqlGuard create(String currentCatalogName, String currentSchemaName, DatabaseCatalog databaseCatalog);
21+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
package org.eclipse.daanse.sql.guard.api.elements;
15+
16+
import java.util.List;
17+
18+
public interface DatabaseCatalog {
19+
20+
String getName();
21+
22+
List<DatabaseSchema> getDatabaseSchemas();
23+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
package org.eclipse.daanse.sql.guard.api.elements;
15+
16+
public interface DatabaseColumn {
17+
18+
String getName();
19+
20+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
package org.eclipse.daanse.sql.guard.api.elements;
15+
16+
import java.util.List;
17+
18+
public interface DatabaseSchema {
19+
20+
String getName();
21+
22+
List<DatabaseTable> getDatabaseTables();
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
package org.eclipse.daanse.sql.guard.api.elements;
15+
16+
import java.util.List;
17+
18+
public interface DatabaseTable {
19+
20+
String getName();
21+
22+
List<DatabaseColumn> getDatabaseColumns();
23+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
15+
@org.osgi.annotation.bundle.Export
16+
@org.osgi.annotation.versioning.Version("0.0.1")
17+
package org.eclipse.daanse.sql.guard.api.elements;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
package org.eclipse.daanse.sql.guard.api.exception;
15+
16+
public class EmptyStatementGuardException extends GuardException {
17+
18+
private static final long serialVersionUID = 1L;
19+
20+
public EmptyStatementGuardException() {
21+
this("The provided Statement must not be empty.");
22+
}
23+
24+
private EmptyStatementGuardException(String message) {
25+
26+
super(message);
27+
}
28+
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
3+
*
4+
* This program and the accompanying materials are made
5+
* available under the terms of the Eclipse Public License 2.0
6+
* which is available at https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* SmartCity Jena - initial
12+
* Stefan Bischof (bipolis.org) - initial
13+
*/
14+
package org.eclipse.daanse.sql.guard.api.exception;
15+
16+
public class GuardException extends Exception {
17+
18+
private static final long serialVersionUID = 1L;
19+
20+
public GuardException() {
21+
22+
}
23+
24+
public GuardException(String message) {
25+
super(message);
26+
}
27+
28+
}

0 commit comments

Comments
 (0)