Opened 10 years ago
Closed 9 years ago
#914 closed defect (fixed)
Refactor petascope ExceptionCodes into Exceptions for WCS-T
Reported by: | Vlad Merticariu | Owned by: | Bang Pham Huu |
---|---|---|---|
Priority: | major | Milestone: | 9.2 |
Component: | petascope | Version: | development |
Keywords: | Cc: | Dimitar Misev | |
Complexity: | Medium |
Description
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)
Change History (15)
comment:1 by , 9 years ago
Milestone: | → 9.2 |
---|
comment:2 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 9 years ago
Cc: | added |
---|
comment:4 by , 9 years ago
comment:5 by , 9 years ago
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:
- 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="mailto:merticariu@rasdaman.com">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."; }
- 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) { e.printStackTrace(); '''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) { e.printStackTrace(); 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).
by , 9 years ago
Attachment: | src_2015_02_10.tar.gz added |
---|
Add new subclass of WCST Exception and changed in all Project
comment:6 by , 9 years ago
Today, I've fixed all of these exception with "return new WCSException or PetascopeException that has arguments is Exceptions.WCST*). Typically in the file GMLParserUtil.java 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.
http://rasdaman.org/attachment/ticket/914/src_2015_02_10.tar.gz
Thanks,
comment:7 by , 9 years ago
What is the status here - is it complete, does it compile, are there sufficient test cases?
comment:8 by , 9 years ago
Please provide a patch instead of the whole tar archive as it is impossible to follow the changes this way.
comment:9 by , 9 years ago
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 by , 9 years ago
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 https://www.atlassian.com/git/tutorials/ https://try.github.io/levels/1/challenges/1
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 by , 9 years ago
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 by , 9 years ago
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 by , 9 years ago
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 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
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.
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
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.
Thanks,