Giter VIP home page Giter VIP logo

gorm-rest-client's Introduction

gorm-rest-client's People

Contributors

graemerocher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gorm-rest-client's Issues

Request/response debug logging

Additional logging requested:

  • Response status code
  • Request/response headers
  • Request/response content (body)

It is very difficult to debug problems with the current debug logging. In particular, I was having difficulty creating an interceptor, because the data being sent was being rejected by the REST API, but I could not see the data that was actually being sent. I haven't yet solved this problem.

Additionally, I was able to get another request to return successfully, but the response contained XML for some odd reason, and I got the following exception. I have no way of debugging this, since I can't see the rest of the response content.

20:33:39.993 ERROR - Error querying [Building] object for URI [/api/buildings/id/7]
org.bson.json.JsonParseException: Invalid JSON input. Position: 1. Character: '<'.
    at org.grails.datastore.bson.json.JsonScanner.nextToken(JsonScanner.java:95)
    ...

An example of the data I'm after is what is displayed in web browsers' developer tools:

screen shot 2016-08-03 at 8 25 14 pm

Grails apps will not deploy to Glassfish 4+

Steps to Reproduce

  1. Deploy a simple Grails app war that utilizes this plugin to glassfish 4+

Expected Behaviour

The war file deploys successfully without error

Actual Behaviour

The war file does not deploy because the close() method signature in RxHttpClientBuilder.groovy throws an exception

Additional Thoughts

Methods annotated with @PreDestroy should not throw a checked exception.

Taking into account that this is a javax.* annotations and checking the documentation https://docs.oracle.com/javaee/7/api/javax/annotation/PreDestroy.html we can see that methods in the Grails source code not fully following the signature according to the Javadoc, thus we may want to adjust the signatures of the the methods that use @PreDestroy annotation by removing the checked exceptions from them.

Environment Information

  • Operating System: macOS 10.13.4
  • Grails Version: 3.3.5
  • JDK Version: 1.8.0_171
  • Container Version (If Applicable): Glassfish 4.x, Glassfish 5.x

Example Application

Questions about RX Gorm and error checking

So I've started playing with RX Gorm(1.0.3) , which looks very promising, but I'm running into several issues. If I run a "get" the json gets populated into the object properly, with dynamic attributes, but if the status is 400, or 500 the onError method isn't called. Why is that?

When I call an "insert"/"save", the JSON I return seems to be ignored for a 200, and it doesn't populate any dynamic attributes, but onError is called for responses for statuses 400 or 500. Also it seems that both end up doing a POST, when the documentation, says that "save" should do a PUT. How do I get the JSON to populate properly, does it expect a status other than 200, 20X? 201 seems to work better for "insert"/"save", but the JSON still doesn't populate the attributes, and I don't get the dynamic attributes.

With Error handling how do I provide information to the onError method, from a server response, and then how do I access that information? It seems like with the RX Gorm I don't have access to the response, is that correct?

JWT Support

Feature request: Support JWTs when communicating with the backing REST service.

Currently, when executing an RxGORM for REST lookup, e.g.,

rx.Observable<Employee> observable = Employee.get(1)
Employee employee = observable.toBlocking().first()

a request is seamlessly sent to the backing REST service, e.g.,

http://localhost:3030/employees/1

Basic Authentication is already supported. However, if the REST service relies on JSON Web Tokens (JWTs) for authentication, the RxGORM lookup will fail. Since JWTs seem to the de facto standard for authenticating REST services, it would be really nice if RxGORM for REST would offer seamless support for JWTs.

Configuration for use with HTTPS

Great work on this, @graemerocher!

Is it possible to configure RxRestDatastoreClient for use with HTTPS?

I am attempting to get a POC working using my company's REST API. I got it working easily with HTTP, but HTTPS is failing with a ClosedChannelException:

...
14:55:41.571 [rxnetty-nio-eventloop-1-1] DEBUG i.n.h.s.u.InsecureTrustManagerFactory - Accepting a server certificate: CN=*.jamf.build, OU=Domain Control Validated
14:55:41.609 [rxnetty-nio-eventloop-1-1] DEBUG io.netty.handler.ssl.SslHandler - [id: 0xf9c6fa76, L:/10.100.249.28:64697 - R:test.jamf.build/10.100.18.14:443] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
Exception in thread "main" java.lang.RuntimeException: java.nio.channels.ClosedChannelException
    at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:456)
    at rx.observables.BlockingObservable.first(BlockingObservable.java:160)
    at rx.observables.BlockingObservable$first.call(Unknown Source)  <3 internal calls>
    at com.jamf.rxjss.Main.listBuildings(Main.groovy:20)
    at com.jamf.rxjss.Main.main(Main.groovy:8)  <5 internal calls>
Caused by: java.nio.channels.ClosedChannelException

Process finished with exit code 1

Here is my application code:

// Main.groovy
import org.grails.datastore.mapping.core.*
import org.grails.datastore.rx.rest.*

class Main {

    static void main(args) {
        init()
        listBuildings()
    }

    static init() {
        def configuration = DatastoreUtils.createPropertyResolver(
                'grails.gorm.rest.host': 'https://test.jamf.build/api',
                'grails.gorm.rest.username': 'admin',
                'grails.gorm.rest.password': 'password')
        new RxRestDatastoreClient(configuration, Building)
    }

    static listBuildings() {
        def buildings = Building.list().toBlocking().first()
        buildings.each { println it.name }
    }
}
// Building.groovy
import grails.gorm.annotation.*
import grails.gorm.rx.rest.*

@Entity
class Building implements RxRestEntity<Building> {
    Long id
    String name

    static mapping = {
        uri '/buildings/id/{id}'
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.