Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 26 2017 20:07
    @remmeier banned @hibaymj
Stephan Arndt
@sarndt
@remmeier , Hmm, that's what I thought, but it didn't work. When stepping through with the debugger, the filterspec it gets from the query looks completely fine (it's something like compositeId EQ "somevalidcompositeId", it just never gets really applied it seems.
Is there something I need to be aware of, when trying to use this with nested resources?

My steps in findAll(Queryspec queryspec) are:

  1. populate a DefaultResourceList with the secondary resource for the given firstlevel resource
  2. Run queryspec.apply(resourcelist) on the populated list.

That should be it, right?

Jon Fulk
@jonfulk
I'm trying to pass a request from an orchestrator service to a microservice using crnk in both services. So the orchestrator will get a request like /orch-service/micro-service/someResource?filter[accountKey]=SomeKeyHere and return the response from the microservice which would interpret the request as /micro-service/someResource?filter[accountKey]=SomeKeyHere. I'm following the example in the crnk-framework examples repo and have created a linker module for the microservice, adding in the link to the microservice in the CrnkClient and then adding the repository from the microservice based on the resource class just like in TaskProjectLinkerModule.java. I'm importing and using the same resource in both the microservice and the orchestrator, and i've defined an in memory repository in the orchestrator, passing in the resource class in the constructor... All that to say, I think I'm following the example, yet I'm just getting 404s and I don't see the request hitting my microservice. Is it possible to pass a request through to a microservice and return the response from that microservice to the caller with crnk?
Jon Fulk
@jonfulk
correction: i want to request /orch-service/someResourceFromMicroservice?filter[accountKey]=SomeKeyHere and pass that down to the microservice as /micro-service/someResourcefromMicroservice?filter[accountKey]=SomeKeyHere. Eventually, the goal would be that the orchestrator would know how to make requests from multiple microservices using crnk when other resources are included in the original request to the orchestrator and then return the whole payload back after reaching into the microservices.
Remo
@remmeier
@sarndt if you like you could reproduce it with the crnk-example application, then I can have a look. should all be fine.
@jonfulk what do the DEBUG logs show? 404 on the orchestration or the micro services? url in the CrnkCient properly configured? no issues with virtual host names? security,... there are many possibilities. the log should help
Jon Fulk
@jonfulk
@remmeier great questions. The request isn’t making it to the micro service and the 404 is from the orchestration. Crnkclient url is configured properly, as far as I understand it. Security isn’t an issue because I’m hitting a public endpoint from the same network. Logs haven’t been super helpful, but I’ll keep digging there. It’s good enough for now to hear that I’m not trying to achieve something impossible based on your questions.
Remo
@remmeier
no, not at all impossible. Make use of the same things on daily basis. If Logs are not super helpful in an area, than feel free to create tickets. At least the underlying HTTP client implementation should show a lot of things.
challarao
@challarao
Hello all

I'm extending CrnkMappableException for an exception. I would like to include a meta-object in top-level JSONAPI document(not as part of the error). The response I would like is below:

{
"meta" : {
"meta-obj": {
//some meta
}
},
"errors" : [ {
//error object
} ]
}

As far as I know the ErrorDataBuilder.meta adds the meta to individual error object.
How do I achieve the top level meta object with crnk?
challarao
@challarao
ErrorResponse doesn't have a method to set meta
challarao
@challarao
q2: How do I get access to QuerySpec in ResourceFieldContributor?
challarao
@challarao
(to access include relations param)
challarao
@challarao
Is ResourceFieldContributor called for every request?
challarao
@challarao
@remmeier any pointers on above questions?
Jon Fulk
@jonfulk
anyone else have a working example of using crnk with microservices that i could look at? the example in the crnk repo is good, but i'd like to see another example if i could as well.
rockeshub
@rockeshub
hi all, I have integrated crnk to an existing spring boot project and when i hit the API i get this response
{
"errors": [
{
"status": "404",
"title": "Not Found",
"detail": "No message available",
"meta": {
"path": "/api/user",
"timestamp": "2020-03-13T08:38:16.555+0000"
}
}

can anyone help me
After seeing the debug logs. I am guessing spring doesn't know about the crnk resources,

2020-03-13 14:23:30.302 DEBUG 67625 --- [nio-8080-exec-9] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/api/user]
2020-03-13 14:23:30.302 DEBUG 67625 --- [nio-8080-exec-9] pertySourcedRequestMappingHandlerMapping : Looking up handler method for path /api/user
2020-03-13 14:23:30.302 DEBUG 67625 --- [nio-8080-exec-9] pertySourcedRequestMappingHandlerMapping : looking up handler for path: /api/user
2020-03-13 14:23:30.302 DEBUG 67625 --- [nio-8080-exec-9] pertySourcedRequestMappingHandlerMapping : Did not find handler method for [/api/user]
2020-03-13 14:23:30.302 DEBUG 67625 --- [nio-8080-exec-9] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Looking up handler method for path /api/user
2020-03-13 14:23:30.302 DEBUG 67625 --- [nio-8080-exec-9] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Did not find handler method for [/api/user]
2020-03-13 14:23:30.302 DEBUG 67625 --- [nio-8080-exec-9] a.e.w.s.ControllerEndpointHandlerMapping : Looking up handler method for path /api/user
2020-03-13 14:23:30.302 DEBUG 67625 --- [nio-8080-exec-9] a.e.w.s.ControllerEndpointHandlerMapping : Did not find handler method for [/api/user]
2020-03-13 14:23:30.302 DEBUG 67625 --- [nio-8080-exec-9] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /api/user
2020-03-13 14:23:30.303 DEBUG 67625 --- [nio-8080-exec-9] s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/api/user]
2020-03-13 14:23:30.303 DEBUG 67625 --- [nio-8080-exec-9] o.s.w.s.handler.SimpleUrlHandlerMapping : Matching patterns for request [/api/user] are [/**]
2020-03-13 14:23:30.303 DEBUG 67625 --- [nio-8080-exec-9] o.s.w.s.handler.SimpleUrlHandlerMapping : URI Template variables for request [/api/user] are {}

rockeshub
@rockeshub
can anyone please help me with this?
Remo
@remmeier

does the CrnkFilter get invoked? You may have to figure the context path in your application.yaml:

crnk:
  path-prefix: /api/

otherwise CrnkFilter will ignore such requests.

@jonfulk what are you looking for in detail?
@challarao a DocumentFilter allows to make arbitrary customization to the response document. So it would allow to set additional meta data.
ResourceFieldContributor is not dynamic, no. It is only called once. If you look more more dynamic behavior, then @JsonAnyGetter/Setter might be the simplest solution More details here http://www.crnk.io/releases/stable/documentation/#_create_repositories_at_runtime. More advanced/complex solution could maintain a resource model on per-request basis. But that should rarely be necessry. What are you looking for?
Alexander Matthiesen
@alexander-matthiesen
Hey there, is there a tutorial on how to add my CustomExceptionMapper to the CrnkClient that it converts the Exceptions into my exceptions?
challarao
@challarao
@remmeier Thanks for your previous pointers.

I'm using CrnkClient and it looks like header() method invocation in the adapter is not taking effect. This following OkHttpRequest code seems to be ignoring the header values set by the listeners:

public HttpAdapterResponse execute() throws IOException {
Request request = this.builder.build(); //it is being pre built here
this.listeners.stream().forEach((it) -> {
it.onRequest(this); //due to above reason, the headers set by listeners here won't have any effect
});
Response response = this.client.newCall(request).execute();
OkHttpResponse adapterResponse = new OkHttpResponse(response);
this.listeners.stream().forEach((it) -> {
it.onResponse(this, adapterResponse);
});
return adapterResponse;
}

Am I missing something? or is it a bug?
challarao
@challarao
I solved my issue by using apache client adapter.
Can I fix the above issue by contributing to the code?
codealways
@DarshanMurthy
Hey guys, Is there a way to send header and path variable using crnk ?
Please, advice.. Thx.
Alexander Matthiesen
@alexander-matthiesen
How can I contribute? It says, that my push was denied. :( (I'm pushing on a new branch)
Vadim Ippolitov
@vadipp
Usually one pushes to a personal fork, then submits a pull request to mainstream
Alexander Matthiesen
@alexander-matthiesen
Ah okay, I will try that. Thanks!
Alexander Matthiesen
@alexander-matthiesen
Could anyone please take a look? crnk-project/crnk-framework#704
Remo
@remmeier
@DarshanMurthy you can set headers in CrnkClient.getHttpAdapter() or the underlying HTTP implementation (okhttp, apache)
Remo
@remmeier
@challarao yes sure, if you have seen something. Feel free to create a ticket/PR.
codealways
@DarshanMurthy
 ```  @Override
public synchronized ResourceList<Bucket> findAll(final QuerySpec querySpec) {
    Connection connection = new Connection("username", "password",
            "url");
    BucketApiResponse bucketApiResponse = bucketService.getBucketList(connection);
    List<Bucket> bucketList = bucketApiResponse.getResponseData().getListOfBuckets();
    return querySpec.apply(bucketList);
}  ```  Is there a way to pass username, password and url ?
Remo
@remmeier
how do you mean? I assume those properties are set with dependency injection, constructor or in some other way. Or are you looking to pass it a long from the client?
codealways
@DarshanMurthy
``` Thanks for the response   @GetMapping("api/buckets")
public ResourceList<Bucket> getAllBuckets(
        @RequestHeader(CLSF_USERNAME_HEADER) final String username,
        @RequestHeader(CLSF_PASSWORD_HEADER) final String password) {
    QuerySpec querySpec = new QuerySpec(Bucket.class);
    return bucketRepository.findAll(username, password, querySpec);
} ... Yes, the secrets should be passed from the client. ```
Remo
@remmeier
introducing more parameters is not possible, as would break the resource-oriented nature of crnk & json-api strive to implement. But you can get access to the Http headers through HttpRequestContextAware interface that can be implemented by the repository.
codealways
@DarshanMurthy
@remmeier, thanks a lot :) Its been three days and still struggling :( Do we have some examples? That would help me.
Alexander Matthiesen
@alexander-matthiesen
Is there any way to validate the body that was sent to Crnk? For example I want to return a 400 HTTPStatusCode if the user writed "colorr": instead of "color" for a field.
Remo
@remmeier
@alexander-matthiesen there is crnk-data-validation which brings the regular JSR 303 bean validation. But the repository is free to add any kind of validation. Or filters can be added that intercept data before hitting a repository.
Mikael Blomström
@mikaelblomstrom
@remmeier Would there be a possibility to get your view on PR crnk-project/crnk-framework#579 to resolve #500
codealways
@DarshanMurthy
hey guys, how do we test public ResourceList<Namespace> findAll(@NonNull final QuerySpec querySpec) { using mockito ? Is there an exmaple ?
It seems like I getting null if I try mock... Is there an example ?