Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adql2.1jakarta #163

Open
wants to merge 16 commits into
base: adql2.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions ADQLLib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
plugins {
id "org.javacc.javacc" version "3.0.0"
id "org.javacc.javacc" version "3.0.2"
id 'maven-publish'
// FIXME really need to sign too
}

// Describe the library:
version = "2.0-beta"
version = "2.0-SNAPSHOT"
description = "Java library to parse, analyze and transform ADQL queries."

// Name of the JAR name (which will be then suffixed by the version number):
Expand All @@ -15,7 +17,7 @@ distributions {
}

dependencies {
implementation 'uk.ac.starlink:stil:4.2'
implementation 'uk.ac.starlink:stil:4.3.1'
implementation 'postgresql:postgresql:9.1-901.jdbc4'
}

Expand Down Expand Up @@ -62,3 +64,40 @@ compileJavacc.doLast {

// Ensure the generated Java classes and examples are included in the classpath:
sourceSets.main.java.srcDirs = ["src", "examples", project.buildDir.absolutePath+'/generated']


publishing {
publications {
maven(MavenPublication) {
groupId = 'fr.unistra.cds' //FIXME - is this what is wanted?
artifactId = 'ADQLlib'
version = '2.0-SNAPSHOT'

from components.java
pom {
name = 'ADQLlib'
description = 'Java library to parse, analyze and transform ADQL queries.'
url = 'http://cdsportal.u-strasbg.fr/adqltuto/'

licenses {
license {
name = 'GNU Lesser General Public License version 3'
url = 'https://opensource.org/license/lgpl-3-0'
}
}
developers {
developer {
id = 'gmantele'
name = 'Grégory Mantelet'
email = 'gregory.mantelet@astro.u-strasbg.fr'
}
}
scm {
connection = 'scm:git:git://github.com/gmantele/vollt.git'
developerConnection = 'scm:git:ssh://github.com/gmantele/vollt.git'
url = 'http://example.com/my-library/'
}
}
}
}
}
2 changes: 1 addition & 1 deletion ADQLLib/test/adql/translator/TestPgSphereTranslator.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public void testTranslateGeometryFromDB() {

// OTHER
try {
translator.translateGeometryFromDB(new Double(12.3));
translator.translateGeometryFromDB(12.3);
fail("The translation of a Double as a geometry is not supported!");
} catch(Throwable t) {
assertTrue(t instanceof ParseException);
Expand Down
47 changes: 44 additions & 3 deletions TAPLib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
plugins {
id 'maven-publish'
}

// Describe the library:
version = "2.4-beta"
Expand All @@ -11,7 +14,7 @@ dependencies {
implementation project(':UWSLib')

implementation fileTree(dir: '../lib', includes: ['stil_3.3-2.jar'])
implementation 'javax.servlet:javax.servlet-api:3.0.1'
implementation 'jakarta.servlet:jakarta.servlet-api:5.0.0'
implementation 'org.slf4j:slf4j-api:1.7.25'
implementation 'org.json:json:20231013'

Expand All @@ -24,6 +27,44 @@ dependencies {
testRuntimeOnly 'org.xerial:sqlite-jdbc:3.44.1.0'

/* Needed to run Gradle with Java 9+: */
// https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api
implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.2'

implementation ("uk.ac.starlink:stil:4.3.1")
}

publishing {
publications {
maven(MavenPublication) {
groupId = 'fr.unistra.cds' // Change this to the correct group
artifactId = 'TAPlib' // Change this for each library
version = '2.4-SNAPSHOT'

from components.java
pom {
name = 'TAPlib'
description = 'Java library to deploy a TAP service. This is a cloned version of the original to allow the updating of older java functionality'
url = 'http://cdsportal.u-strasbg.fr/taptuto/'

licenses {
license {
name = 'GNU Lesser General Public License version 3'
url = 'https://opensource.org/license/lgpl-3-0'
}
}
developers {
developer {
id = 'gmantele'
name = 'Grégory Mantelet'
email = 'gregory.mantelet@astro.u-strasbg.fr'
}
}
scm {
connection = 'scm:git:git://github.com/slloyd-src/vollt.git'
developerConnection = 'scm:git:ssh://github.com/slloyd-src/vollt.git'
url = 'http://example.com/my-library/'
}
}
}
}

}
4 changes: 2 additions & 2 deletions TAPLib/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ RUN wget -O /usr/local/tomcat/webapps/tap/WEB-INF/lib/commons-fileupload.jar \
'https://repo1.maven.org/maven2/commons-fileupload/commons-fileupload/1.3.3/commons-fileupload-1.3.3.jar'
RUN wget -O /usr/local/tomcat/webapps/tap/WEB-INF/lib/commons-io.jar \
'https://repo1.maven.org/maven2/commons-io/commons-io/2.6/commons-io-2.6.jar'
RUN wget -O /usr/local/tomcat/webapps/tap/WEB-INF/lib/javax-servlet-api.jar \
'https://repo1.maven.org/maven2/javax/servlet/javax.servlet-api/3.0.1/javax.servlet-api-3.0.1.jar'
RUN wget -O /usr/local/tomcat/webapps/tap/WEB-INF/lib/jakarta-servlet-api.jar \
'https://repo1.maven.org/maven2/jakarta/servlet/jakarta.servlet-api/3.0.1/jakarta.servlet-api-3.0.1.jar'
RUN wget -O /usr/local/tomcat/webapps/tap/WEB-INF/lib/json.jar \
'https://repo1.maven.org/maven2/org/json/json/20180813/json-20180813.jar'
RUN wget -O /usr/local/tomcat/webapps/tap/WEB-INF/lib/slf4j-api.jar \
Expand Down
2 changes: 1 addition & 1 deletion TAPLib/docker/scripts/tap-starter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CONTEXT_FILE=$WEBAPPS_DIR/tap/META-INF/context.xml
# Start the Context and Resource definitions:
echo -e '<Context>\n\t<Resource name="jdbc/tapdb" auth="Container"' > $CONTEXT_FILE
# Set the Resource type (SQL's Datasource):
echo -e '\t\ttype="javax.sql.DataSource"' >> $CONTEXT_FILE
echo -e '\t\ttype="jakarta.sql.DataSource"' >> $CONTEXT_FILE
# Set the JDBC driver:
case "$DB_TYPE" in
postgres|pgsphere)
Expand Down
2 changes: 1 addition & 1 deletion TAPLib/docker/tomcat/tap-webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<resource-ref>
<res-ref-name>jdbc/testdb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-type>jakarta.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

Expand Down
2 changes: 1 addition & 1 deletion TAPLib/src/tap/ADQLExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.io.IOException;
import java.io.OutputStream;

import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponse;

import adql.parser.ADQLParser;
import adql.parser.ADQLQueryFactory;
Expand Down
2 changes: 1 addition & 1 deletion TAPLib/src/tap/AbstractTAPFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import adql.db.DBChecker;
import adql.parser.ADQLParser;
Expand Down
4 changes: 2 additions & 2 deletions TAPLib/src/tap/TAPFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import adql.parser.ADQLParser;
import adql.parser.ADQLQueryFactory;
Expand Down Expand Up @@ -308,7 +308,7 @@ protected TAPFactory(final ServiceConnection service) throws NullPointerExceptio
* with the given request, in order to ensure that the returned object is always a {@link TAPJob}.
* </p>
*
* @see uws.service.AbstractUWSFactory#createJob(javax.servlet.http.HttpServletRequest, uws.job.user.JobOwner)
* @see uws.service.AbstractUWSFactory#createJob(jakarta.servlet.http.HttpServletRequest, uws.job.user.JobOwner)
* @see #createTAPJob(HttpServletRequest, JobOwner)
*/
@Override
Expand Down
2 changes: 1 addition & 1 deletion TAPLib/src/tap/TAPRequestParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import uws.UWSException;
import uws.UWSToolBox;
Expand Down
2 changes: 1 addition & 1 deletion TAPLib/src/tap/TAPSyncJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.Date;
import java.util.Iterator;

import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletResponse;

import tap.parameters.TAPExecutionDurationController;
import tap.parameters.TAPParameters;
Expand Down
38 changes: 26 additions & 12 deletions TAPLib/src/tap/config/ConfigurableServiceConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@
import uws.service.log.UWSLog.LogLevel;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -178,7 +182,7 @@ public final class ConfigurableServiceConnection implements ServiceConnection {
* @throws NullPointerException If the given properties set is NULL.
* @throws TAPException If a property is wrong or missing.
*/
public ConfigurableServiceConnection(final Properties tapConfig) throws NullPointerException, TAPException {
public ConfigurableServiceConnection(final Properties tapConfig) throws FileNotFoundException, TAPException {
this(tapConfig, null);
}

Expand All @@ -196,9 +200,9 @@ public ConfigurableServiceConnection(final Properties tapConfig) throws NullPoin
* @throws NullPointerException If the given properties set is NULL.
* @throws TAPException If a property is wrong or missing.
*/
public ConfigurableServiceConnection(final Properties tapConfig, final String webAppRootDir) throws NullPointerException, TAPException {
public ConfigurableServiceConnection(final Properties tapConfig, final String webAppRootDir) throws FileNotFoundException, TAPException {
if (tapConfig == null)
throw new NullPointerException("Missing TAP properties! ");
throw new FileNotFoundException("Missing TAP properties! ");

// 1. INITIALIZE THE FILE MANAGER:
initFileManager(tapConfig, webAppRootDir);
Expand Down Expand Up @@ -335,17 +339,27 @@ private void initFileManager(final Properties tapConfig, final String webAppRoot
*
* @throws ParseException If the given file path is a URI/URL.
*/
protected static final File getFile(final String filePath, final String webAppRootPath, final String propertyName) throws TAPException {
if (filePath == null)
static File getFile(final String filePath, final String webAppRootPath, final String propertyName) throws TAPException {
if (filePath == null) {
return null;
else if (filePath.matches(".*:.*"))
throw new TAPException("Incorrect file path for the property \"" + propertyName + "\": \"" + filePath + "\"! URI/URLs are not expected here.");
}

File f = new File(filePath);
if (f.isAbsolute())
return f;
else
return new File(webAppRootPath, filePath);
// Convert the file path into a Path object to avoid manual checks
Path path;
try {
path = Paths.get(filePath);
} catch (InvalidPathException e) {
throw new TAPException("Invalid file path for the property \"" + propertyName + "\": \"" + filePath + "\"! Please check the path format.", e);
}

// If the path is absolute, return it as a File directly
if (path.isAbsolute()) {
return path.toFile();
}

// Otherwise, assume it's a relative path and resolve it against the webAppRootPath
Path resolvedPath = Paths.get(webAppRootPath).resolve(path);
return resolvedPath.toFile();
}

/**
Expand Down
21 changes: 13 additions & 8 deletions TAPLib/src/tap/config/ConfigurableTAPServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
import java.io.InputStream;
import java.util.Properties;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import tap.ServiceConnection;
import tap.TAPException;
Expand Down Expand Up @@ -113,7 +113,9 @@ public void init(final ServletConfig config) throws ServletException{
}finally{
try{
input.close();
}catch(IOException ioe2){}
}catch(IOException ioe2){
ioe2.printStackTrace();
}
}

/* 4. CREATE THE TAP SERVICE */
Expand All @@ -127,8 +129,11 @@ public void init(final ServletConfig config) throws ServletException{
tap = null;
if (ex instanceof TAPException)
throw new ServletException(ex.getMessage(), ex.getCause());
else
throw new ServletException("Impossible to initialize the TAP service!", ex);
else {
ex.printStackTrace();
System.out.println(ex.getMessage());
throw new ServletException("Impossible to initialize the TAP services!" + ex.getMessage());
}
}

/* 4Bis. SET THE HOME PAGE */
Expand Down
6 changes: 3 additions & 3 deletions TAPLib/src/tap/config/TAPConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ public final static Object[] parseLimit(String value, final String propertyName,

// If empty value, return an infinite limit:
if (value == null || value.length() == 0)
return (longValue ? new Object[]{ new Long(-1L), LimitUnit.rows } : new Object[]{ new Integer(-1), LimitUnit.rows });
return (longValue ? new Object[]{-1L, LimitUnit.rows } : new Object[]{-1, LimitUnit.rows });

// A. Parse the string from the end in order to extract the unit part.
// The final step of the loop is the extraction of the numeric value, when the first digit is encountered.
Expand Down Expand Up @@ -878,9 +878,9 @@ else if (buf.length() > 2)
}

if (numValue < 0)
return (longValue ? new Object[]{ new Long(-1L), unit } : new Object[]{ new Integer(-1), unit });
return (longValue ? new Object[]{-1L, unit } : new Object[]{-1, unit });
else
return (longValue ? new Object[]{ new Long(numValue), unit } : new Object[]{ new Integer((int)numValue), unit });
return (longValue ? new Object[]{numValue, unit } : new Object[]{(int) numValue, unit });
}

}
4 changes: 2 additions & 2 deletions TAPLib/src/tap/data/ResultSetTableIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -760,11 +760,11 @@ else if (colType.type == DBDatatype.SMALLINT)

// if the type is Integer but it is declared as a SMALLINT cast the value (absolutely required for the FITS format):
else if (colValue instanceof Integer && colType != null && colValue != null && colType.type == DBDatatype.SMALLINT)
colValue = new Short(((Integer)colValue).shortValue());
colValue = ((Integer) colValue).shortValue();

// if the column value is a Boolean object, format it as a SMALLINT:
else if (colValue instanceof Boolean)
colValue = ((Boolean)colValue) ? new Short((short)1) : new Short((short)0);
colValue = ((Boolean)colValue) ? Short.valueOf((short)1) : Short.valueOf((short)0);

// if the column should be only a character:
else if (colType != null && colValue != null && colType.type == DBDatatype.CHAR && (colType.length == 1 || colType.length <= 0) && colValue instanceof String)
Expand Down
4 changes: 2 additions & 2 deletions TAPLib/src/tap/error/DefaultTAPErrorWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import java.util.LinkedHashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import tap.ServiceConnection;
import tap.TAPException;
Expand Down
Loading