Skip to content
Snippets Groups Projects
Commit 34e04bf4 authored by gmantele's avatar gmantele
Browse files

[TAP] Fix exception management: do not encapsulate in a UWSException a...

[TAP] Fix exception management: do not encapsulate in a UWSException a TAPException whose the cause is already a UWSException ; in such case, the TAPException cause must be returned.
parent e7dff888
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ package tap; ...@@ -16,7 +16,7 @@ package tap;
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with TAPLibrary. If not, see <http://www.gnu.org/licenses/>. * along with TAPLibrary. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI) * Astronomisches Rechen Institut (ARI)
*/ */
...@@ -53,7 +53,7 @@ import adql.query.ADQLQuery; ...@@ -53,7 +53,7 @@ import adql.query.ADQLQuery;
* Only the functions related with the database connection stay abstract. * Only the functions related with the database connection stay abstract.
* *
* @author Gr&eacute;gory Mantelet (CDS;ARI) * @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 2.0 (12/2014) * @version 2.0 (02/2015)
*/ */
public abstract class AbstractTAPFactory extends TAPFactory { public abstract class AbstractTAPFactory extends TAPFactory {
...@@ -248,6 +248,9 @@ public abstract class AbstractTAPFactory extends TAPFactory { ...@@ -248,6 +248,9 @@ public abstract class AbstractTAPFactory extends TAPFactory {
TAPParameters tapParams = createTAPParameters(request); TAPParameters tapParams = createTAPParameters(request);
return new TAPJob(owner, tapParams); return new TAPJob(owner, tapParams);
}catch(TAPException te){ }catch(TAPException te){
if (te.getCause() != null && te.getCause() instanceof UWSException)
throw (UWSException)te.getCause();
else
throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, te, "Can not create a TAP asynchronous job!"); throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, te, "Can not create a TAP asynchronous job!");
} }
} }
...@@ -265,6 +268,9 @@ public abstract class AbstractTAPFactory extends TAPFactory { ...@@ -265,6 +268,9 @@ public abstract class AbstractTAPFactory extends TAPFactory {
try{ try{
return new TAPJob(jobId, owner, params, quote, startTime, endTime, results, error); return new TAPJob(jobId, owner, params, quote, startTime, endTime, results, error);
}catch(TAPException te){ }catch(TAPException te){
if (te.getCause() != null && te.getCause() instanceof UWSException)
throw (UWSException)te.getCause();
else
throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, te, "Can not create a TAP asynchronous job !"); throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, te, "Can not create a TAP asynchronous job !");
} }
} }
......
...@@ -16,7 +16,7 @@ package tap; ...@@ -16,7 +16,7 @@ package tap;
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with TAPLibrary. If not, see <http://www.gnu.org/licenses/>. * along with TAPLibrary. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI) * Astronomisches Rechen Institut (ARI)
*/ */
...@@ -61,7 +61,7 @@ import adql.query.ADQLQuery; ...@@ -61,7 +61,7 @@ import adql.query.ADQLQuery;
* </ul> * </ul>
* *
* @author Gr&eacute;gory Mantelet (CDS;ARI) * @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 2.0 (12/2014) * @version 2.0 (02/2015)
*/ */
public abstract class TAPFactory implements UWSFactory { public abstract class TAPFactory implements UWSFactory {
...@@ -364,6 +364,9 @@ public abstract class TAPFactory implements UWSFactory { ...@@ -364,6 +364,9 @@ public abstract class TAPFactory implements UWSFactory {
try{ try{
return new AsyncThread((TAPJob)job, createADQLExecutor(), getErrorWriter()); return new AsyncThread((TAPJob)job, createADQLExecutor(), getErrorWriter());
}catch(TAPException te){ }catch(TAPException te){
if (te.getCause() != null && te.getCause() instanceof UWSException)
throw (UWSException)te.getCause();
else
throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, te, "Impossible to create an AsyncThread !"); throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, te, "Impossible to create an AsyncThread !");
} }
} }
...@@ -385,7 +388,7 @@ public abstract class TAPFactory implements UWSFactory { ...@@ -385,7 +388,7 @@ public abstract class TAPFactory implements UWSFactory {
try{ try{
return createTAPParameters(request); return createTAPParameters(request);
}catch(TAPException te){ }catch(TAPException te){
if (te.getCause() != null && te.getCause() instanceof UWSException && te.getMessage().equals(te.getCause().getMessage())) if (te.getCause() != null && te.getCause() instanceof UWSException)
throw (UWSException)te.getCause(); throw (UWSException)te.getCause();
else else
throw new UWSException(te.getHttpErrorCode(), te); throw new UWSException(te.getHttpErrorCode(), te);
...@@ -423,7 +426,7 @@ public abstract class TAPFactory implements UWSFactory { ...@@ -423,7 +426,7 @@ public abstract class TAPFactory implements UWSFactory {
try{ try{
return createTAPParameters(params); return createTAPParameters(params);
}catch(TAPException te){ }catch(TAPException te){
if (te.getCause() != null && te.getCause() instanceof UWSException && te.getMessage().equals(te.getCause().getMessage())) if (te.getCause() != null && te.getCause() instanceof UWSException)
throw (UWSException)te.getCause(); throw (UWSException)te.getCause();
else else
throw new UWSException(te.getHttpErrorCode(), te); throw new UWSException(te.getHttpErrorCode(), te);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment