Opened 2 years ago

Closed 20 months ago

#914 closed defect (fixed)

Refactor petascope ExceptionCodes into Exceptions for WCS-T

Reported by: vmerticariu Owned by: bphamhuu
Priority: major Milestone: 9.2
Component: petascope Version: development
Keywords: Cc: dmisev
Complexity: Medium


The exceptions thrown by WCS-T insert are using dedicated ExceptionCodes? and the general WCSException.

The ones thrown in the update operations are separate classes, sucblassed from WCSTException. This allows catching them by type (instead of catching all WCSExceptions and then do a type check), as well as easy customization and parameterization of the exception messages.

The task is to go through the WCST* ExceptionCodes?, and create, for each of them, a subclass of WCSTException, following the model used, for example, in the UpdateCoverageHandler?.

Attachments (1)

src_2015_02_10.tar.gz (1.3 MB) - added by bphamhuu 21 months ago.
Add new subclass of WCST Exception and changed in all Project

Download all attachments as: .zip

Change History (15)

comment:1 Changed 2 years ago by dmisev

  • Milestone set to 9.2

comment:2 Changed 21 months ago by vmerticariu

  • Owner changed from vmerticariu to bphamhuu
  • Status changed from new to assigned

comment:3 Changed 21 months ago by bphamhuu

  • Cc dmisev added

comment:4 Changed 21 months ago by bphamhuu

Hi Vlad,

Thanks for your guiding. Now, I've ready to go with this task (but it is not easy start from the time I open Petascope Project with NetBean? 8.0.2). Did I do wrong? Because I need to fix some problem then it could compiled.

  1. missing the package " and petascope.rasj", copy from "/home/rasdaman/java/src/" to "$RMANHOME/applications/petascope/src/main/java/"
  1. Could not find the package when import "*" then download the ".jar" file and import to 'Jar library'.
  1. Error with or.gzeromq.ZMQ; Download the ".jar" file and import to 'Jar library'.
  1. Interestingly I could not see the 'Interface of Petascope' (HTML in iframe), I deployed using GlassFish? with NetBean?. The error is
HTTP Status 404 - Not Found

type Status report

messageNot Found

descriptionThe requested resource is not available.

Please note that this is not because the 'path' to 'servlet' is not existed. In fact, it is true path because when I debug, it jump to the class 'PetascopeInterface?.java' and method 'init()' as I expected.

However, it ended with jump to

"" in;

                                        createContext(subject, currentAcc));

and I stucked in there without how to fix this, to show the Interface instead of 404 error.

But if I tried with some WCS query (no need Inteface) http://localhost:46899/petascope/ows?service=WCS&version=2.0.1&request=GetCapabilities it still returns the result.

Tomorrow, I will try to make a sample as you recommended with some WCS-T exception first, and because you are busy so I will need Alex's help.


comment:5 Changed 21 months ago by bphamhuu

Ok, Vlad, I think I could get your idea (well, you wrote a very concise in the ticket description but your instruction with me is clear).

Here is my report:

  1. I've created all the subclass prefix WCST* in ExceptionCode?.java and also the content inside, for example:
package petascope.exceptions.wcst;

import petascope.exceptions.ExceptionCode;

 * @author <a href="">Vlad Merticariu</a>
public class WCSTAxisLabelMismatchException extends WCSTException {

    public WCSTAxisLabelMismatchException(String axisName) {
        super(ExceptionCode.InconsistentChange, EXCEPTION_TEXT.replace("$axisName", axisName));

    private final static String EXCEPTION_TEXT = "Axis label $axisName from the input coverage was not found in the target coverage.";


  1. Now, I've to reread your task description many times, to find what do you mean in "UpdateCoverageHandler?.java", so, I could think that you meant in here you used with Petascope Exception or WCS Exception in methods instead of throw "WCSTException"
throws PetascopeException

so you need to change if the method throw "ExceptionCode? with WCSTException" then it should throws "WCSTException" not the general "PetascopeException? or WCSException".
For example, this should be change to class "WCSTInvalidXML".

catch (ParsingException e) {
            Logger.getLogger(InsertCoverageHandler.class.getName()).log(Level.SEVERE, null, e);
            throw new PetascopeException(ExceptionCode.WCSTInvalidXML, e.getMessage());

And if not throw "WCST ExceptionCode?" then I don't need to change.

private void handleSubsetCoefficients(CoverageMetadata currentCoverageMetadata, List<DimensionSubset> subsets) throws PetascopeException {
        for (DimensionSubset subset : subsets) {
            //check if axis is irregular is irregular
            if (currentCoverageMetadata.getDomainByName(subset.getDimension()).isIrregular()) {
                //update coefficient corresponding to this slice
                DomainElement currentDom = currentCoverageMetadata.getDomainByName(subset.getDimension());
                int axisId;
                try {
                    axisId = meta.getGridAxisId(currentCoverageMetadata.getCoverageId(), currentDom.getOrder());
                } catch (SQLException e) {
                    '''throw new PetascopeException(ExceptionCode.InternalSqlError)''';
                BigDecimal currentCoefficient = computeSubsetCoefficient(currentDom, subset);
                int coefficientOrder = computeCoefficientOrder(currentCoverageMetadata, currentDom, currentCoefficient, (DimensionSlice) subset);
                try {
                    meta.updateAxisCoefficient(axisId, currentCoefficient, coefficientOrder);
                } catch (SQLException e) {
                    throw new '''PetascopeException(ExceptionCode.InternalSqlError)''';

I hope I'm doing it right, although I should try to understand what is the purpose of these exception later. So, next I will basically, search all project and see which code uses 'WCST Exception Code' but using object 'Petascope or WCSException' I will change it with the suitable class of WCSTException (like WCSTInvalidXML).

Changed 21 months ago by bphamhuu

Add new subclass of WCST Exception and changed in all Project

comment:6 Changed 21 months ago by bphamhuu

Today, I've fixed all of these exception with "return new WCSException or PetascopeException? that has arguments is Exceptions.WCST*). Typically in the file now will throws WCST* subclass as Vlad's example.

Vlad or Alex when you have time, please download and have a look with the code I've changed.
+ New Classes add in src/main/java/petascope/exceptions/wcst.
+ All other exceptions relating to this ticket were changed.


comment:7 Changed 21 months ago by pbaumann

What is the status here - is it complete, does it compile, are there sufficient test cases?

comment:8 Changed 21 months ago by mdumitru

Please provide a patch instead of the whole tar archive as it is impossible to follow the changes this way.

comment:9 Changed 21 months ago by bphamhuu

As you request, Alex, I've submitted a patch as Vlad has suggested latest ticket. Please have a look, thanks:

[PATCH] ticket:914 - Refactor petascope ExceptionCodes? into Exceptions for WCS-T, not verified - wait Vlad, Alex confirm

comment:10 Changed 21 months ago by mdumitru

Your changes to the WCST code seem correct, however the patch submitted has many other unrelated changes. Please learn how to properly use git, for example using these tutorials

In this case you will want to revert your commit, then git add only the files that have a connection to the current ticket (wcst modifications) and then format the patch.

@Peter, please reject the current uploaded patch and wait for a new one.

comment:11 Changed 21 months ago by bphamhuu

well, actually it is my bad when I think you could also need some jar files, also with some file I've modified but not related to this ticket.

Anyway, thanks for your time and I will have a look with tutorials. You're right when what I can do is I could know how to add file to commit (stag) (also know to reset to last commit or remove file from staged list - reset), and that is all.

I've submitted new patch, please check there are only related files.

comment:12 Changed 21 months ago by mdumitru

Looks good from my perspective, nice work! Also, please note that the branch to which you submitted is not used anymore, all patches should go into the main branch in the patchmanager.

comment:13 Changed 20 months ago by bphamhuu

Thanks to Vlad and Alex for your help, comments and time to review. I will close the ticket as it has been accepted.

comment:14 Changed 20 months ago by bphamhuu

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.