-
Notifications
You must be signed in to change notification settings - Fork 370
Change: Made API class easier to work with #1374
Conversation
@@ -1,6 +1,6 @@ | |||
package com.iota.iri.service; | |||
|
|||
public class ValidationException extends Exception { | |||
public class ValidationException extends RuntimeException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required so that the functional command routing doesnt need try/catch -> throw another error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better than before
Please delete experimental classes that don't seem to serve functionality (i.e. the one with jax-rs annotations)
throw new IllegalStateException(e); | ||
} | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice,
So in later PRs, wall those statement
methods can be moved to their own services so that the API will only be about declarations and initial parameter processing/validation.
private AbstractResponse process() { | ||
return AbstractResponse.createEmptyResponse(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you couldn't get JAX-RS to work you shouldn't have added your experiments to the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could make it work, but it would change all API paths and calling method. So i left it at this for now.
I left it for us to decide what to do with them. Ill stash them in a local branch
* | ||
*/ | ||
@ApplicationPath("") | ||
public class RestEasy extends Application implements RestConnector { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You made your own resteasy implementation?
Does it have anything to do with this
https://github.com/resteasy/Resteasy/ ?
Because the name is confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it uses the RestEasy implementation provided through UndertowJaxrsServer, what name would you give it? UndertowJaxrsRestEasy? :)
@@ -125,6 +125,19 @@ | |||
<artifactId>undertow-websockets-jsr</artifactId> | |||
<version>${undertow.version}</version> | |||
</dependency> | |||
|
|||
<!-- RESTEasy Undertow Integration --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add digest rules to the enforcer:
Lines 369 to 383 in 9821a60
<digestRule implementation="uk.co.froot.maven.enforcer.DigestRule"> | |
<!-- Create a snapshot to build the list of URNs below --> | |
<buildSnapshot>true</buildSnapshot> | |
<!-- List of required hashes --> | |
<!-- Format is URN of groupId:artifactId:version:type:classifier:scope:hash --> | |
<!-- classifier is "null" if not present --> | |
<urns> | |
<urn> | |
org.apache.commons:commons-lang3:3.5:jar:null:compile:6c6c702c89bfff3cd9e80b04d668c5e190d588c6 | |
</urn> | |
<!-- http://repo2.maven.org/maven2/org/slf4j/slf4j-api/1.7.25/ --> | |
<urn> | |
org.slf4j:slf4j-api:1.7.25:jar:null:compile:da76ca59f6a57ee3102f8f9bd9cee742973efa8a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 little changes and that is all :-)
API still has some reworking to do but we shall wait for #874
try { | ||
return getTransactionsToApproveStatement(depth, reference); | ||
} catch (Exception e) { | ||
throw new IllegalStateException(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you drill down to getTransactionsToApproveStatement
you will see that it doesn't really throw any exception. So you can remove this wrapping.
log.error("API Validation failed: " + e.getLocalizedMessage()); | ||
return ExceptionResponse.create(e.getLocalizedMessage()); | ||
} catch (final IllegalStateException e) { | ||
log.error("API Exception: " + e.getLocalizedMessage()); | ||
return ExceptionResponse.create(e.getLocalizedMessage()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add a clause for unexpected problems we don't foresee
catch (RuntimeException e) {
log.error("Unexpected API Exception: " + e.getLocalizedMessage());
return ExceptionResponse.create(e.getLocalizedMessage());
}
While you are at it, please remove those annoying final
from the other catch clauses.
Description
The API.java class is currently very unmaintainable.
This PR will externalize the REST client used, and switch from pure undertow to resteasy with undertow impl for easy switching later on.
API commands are no longer run from inside a switch, but according to the method proposed in #392
Backwards compatible as no changes are made to the request/result requirements.
Fixes #920
The following files are not yet used, but will be needed for #874
Not sure what to do with them
Type of change
How Has This Been Tested?
Added tests for new classes, node ran and API called.
Checklist: