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
magdumaparna
@magdumaparna
Hey guys, I want to perform PATCH operation with bulk payload request..anybody know about it??
Remo
@remmeier
Hi, that is the one thing currently not yet implemented. somebody was looking into it a d opened an early pr, but notnsure about the progress. what works already is JsonPatch/OperationsModule with bulk patches
AhmedSabry
@ahmedsabryy93_twitter
Hey, I want to know how can i make relationship with object which has a composite key and an Id, what i want to know on the request . ex :
"relationships":{
"relatedObject":{
"data":[{
"type":"relatedObject",
"id":{
"key1":"f568fec0-10b6-4b94-9daf-e62c50c9bf3e",
"key2": "anything"}
}]
}
}
when make a post request it gives an error . any thoughts?
abakabak
@abakabak

Good day everyone,

I am trying to intercept the error response thrown by Crnk then add our custom error details. (e.g. if a resource is not found a 404 is thrown directly by Crnk without any details) Anyone has idea on how to intercept this error response then added a custom details?

Thank you in advance.

Arun Bitla
@abitla
Hi guys...is there a way to have resource attributes in a specific order?
Rehab Reda
@rehab-reda0

Hi
Is there anyway to make crnk accepts this url
/parents/{parentID}/childs/{ChildID}
I see in the documentation an example but I don't know how I can apply it if am using jpaentityrepository base
Parent class

@Data
@JsonApiResource(type = "parents")
@Entity
@Table(name = "parents")
public class Parent {

  @Id
  @JsonApiId
  @GeneratedValue(generator = "UUID")
  @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
  @Column(name = "id", updatable = false, nullable = false)
  private UUID id;
  @NotEmpty
  private String name;

  @JsonApiRelation(serialize = SerializeType.ONLY_ID)
  @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, orphanRemoval = true)
  private List<Child> childs;

}

Child class

@Data
@JsonApiResource(type = "childs")
@Entity
@Table(name = "childs")
public class Child {


  @Id
  @JsonApiId
  @GeneratedValue(generator = "UUID")
  @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
  @Column(name = "id", updatable = false, nullable = false)
  private UUID id;

  @ManyToOne
  @JoinColumn(name = "parent_id", referencedColumnName = "id")
  private Parent parent;

  @NotEmpty(message = "koko")
  private String value;


}

when I add nested = true to the child class
it throws an exception any help
Please advice

adellalin
@adellalin
I deployed a crnk application in AWS lambda but had difficulty invoking it from requestHander. is crnk supported by AWS lambda? if so, some sample code will be helpful
Remo
@remmeier
@adellalin in general it shouldnwork with lamba. but as of yet there is no official integration, meaning a bit more effort. e.g. crnk-setup-servlet could be a good template. maybe there is also a framrwork out there that would help to generalize across the varous faas impleme tations that then could be added to crnk.
@abitla order should be as defined in the java class
@ahmedsabryy93_twitter you can have compisite keys on the java-level. but it will serialize it to a single string on the rest layer to adhere to the json:api spec.
@abakabak a custom document filter or error handler would do. or if you have something generally useful, could also be added to crnk
Remo
@remmeier
@rehab-reda0 what is the exception? should work well if nesting is setup. current master may provide better exceptions then stable
Rehab Reda
@rehab-reda0

how can i setup nesting ? if the repo extends jpa entity repo ?
also I have another question

the parent model here has list<child> one to many relation ship
If i put the relationships id in the post request no effect will be done ?

if u do a get request of this model again the child relationship will be empty array not like what i did in the post request

like the following

{
"data":
{
"type":"parent",
"attributes":{
"name":"anything"

},
"relationships":{
"childs":{
"data":[{"id":"1","type":"child"}]

}

}


}
}
Remo
@remmeier
the child needs an @enbeededId with the parentId and childId (for multi -valued children, for single one it is just the parentId. the parentId should then carry @JsonRelationId. if you have both parent and parentId, one has to be insetable=updateable=false. i hope there is an example in crnk-example and maybe docs, othereise we should add one
Rehab Reda
@rehab-reda0
@remmeier I did but didnt work can u provide a simple example please if the repo is jpaentityrepo?
Rehab Reda
@rehab-reda0
and what if the id is of type uuid as u are splitting the child and parent id by //-
James Cole
@jc92930
Hi guys, I have a Spring Cloud Gateway in front of a spring boot service and a spring boot crnk service. The gw is called with SSL and the services are http. The Spring Boot service works fine. The Crnk service gives an error:
java.lang.IllegalArgumentException: Illegal character in scheme name at index 4: http,https://api-downstream-notification/notificationsBackend/notifications/v1
at java.base/java.net.URI.create(URI.java:883) ~[na:na]
at io.crnk.core.engine.http.DefaultHttpRequestContextBase.getRequestUri(DefaultHttpRequestContextBase.java:24) ~[crnk-core-3.2.20200419165537.jar!/:na]
at io.crnk.servlet.internal.ServletRequestContext.computeBaseUrl(ServletRequestContext.java:93) ~[crnk-setup-servlet-3.2.20200419165537.jar!/:na]
at io.crnk.servlet.internal.ServletRequestContext.getBaseUrl(ServletRequestContext.java:200) ~[crnk-setup-servlet-3.2.20200419165537.jar!/:na]
at io.crnk.core.engine.internal.http.HttpRequestContextBaseAdapter.<init>(HttpRequestContextBaseAdapter.java:28) ~[crnk-core-3.2.20200419165537.jar!/:na]
I saw this mentioned in December but a resolution was not clear...
Any help would be HUGELY appreciated! :)
James Cole
@jc92930
Anyone? @remmeier ?
Alexander Matthiesen
@alexander-matthiesen
Regarding crnk-gen: Is it possible to define examples and override the description inside of the template? Currently we are using it for generating our OpenAPI-Specification but we cannot override description inside of the "paths:" element. Do you have a suggestion how to do that? (we are using spring)
Our solution is to amend the file manually after the generation.
1 reply
tomivargek
@tomivargek

Hi,
we are using Java EE,crnk and Weblogic. We are having problems with generated links (self,relationship, next,prev, etc). When we go through load balancer or proxy, links aren't properly generated. For instance
[https://testEnvironment/_wsE122_model-info/ordering/orders?page[limit]=10] (link without load balancer) => generated links are okay
[https://loadBalancerLink/v1/model-info/ordering/orders?page[limit]=10] (link with load balancer/proxy) => generated links aren't proper, they are like this: [https://testEnvironment/_wsE122_model-info/ordering/orders...).

The problem is links aren't masked (generated) properly. We can't use X-Forward-Headers.. and we were unsuccessful overriding domain-name (crnk resource domain name).

Can you give us any possible solution for this (explain how exactly to override domain name or give us some other proposition of solution)?
Does crnk support using of "Referer" header (that would be great for us)?

whgibbo
@whgibbo

Hi,
Just wanted to ask a quick question regarding validation of the include parameter and expected responses to the following:

  • {url}?include=unknownattr
  • {url}?include[unknownResource]=unknownattr

I know for the first, it seems to ignore it.. But was expecting a BadRequest.
Are the unit tests for these ?

3 replies
filethirteen
@filethirteen
Anyone experience this? When using CrnkClient and expecting an error to be returned, why do all of the error details except for the error.detail field get lost. I tried adding a listener to the httpAdapter and just did a little log statement in both of the OnRequest and OnResponse methods and OnResponse is never invoked when the call results in an exception, like 400 Bad Request. Instead it seems as soon as CrnkClient receives the error it immediately throws it's own exception of that type and the only field it takes from the errors is detail, all the other fields get lost. Makes it kind of hard to propagate things like custom codes in the code field for example. My current workaround for this is jam all necessary info into the error detail and then extract it where needed. Does anyone else know of any way to preserve error detail when using CrnkClient?
Remo
@remmeier
@filethirteen errors are mapped by the ExceptionMapper, so any kind of functionality is possible. CrnkMappableException can hold ErrorData. So in principle it would allow to hold any kind of data if the exception is dervied from it.
logic starts in ClientStubBase.handleError. improvements in the area more than welcome. Just recently added the url to CrnkException to allow also holding the called url to reproduce it manually in the browser.
Remo
@remmeier
/all FYI: crnk 3.3 has been released with a variety of incremental improvements: http://www.crnk.io/releases/stable/
Rehab Reda
@rehab-reda0
Hi Remo can we use dynamodb with crnk ?
Tikaro
@0-Tikaro
Hey guys, does Crnk support filtering by empty relationships? Say I've got entities 'person' and 'group' , where group can have 0..N people, and I want to find only the groups with 0 people. Tried filter[person]=null and various derivatives of that, but that doesn't seem to be working.
Remo
@remmeier
@rehab-reda0 sure. you can implement a repository and map QuerySpec to native dynamodb queries. not unlike crnk-data-jpa.
@0-Tikaro not as of yet with the built-in filtering. but new FilterOperator can be defined to adress it
Romain LE BARO
@scandinave
HI, I try to integrate CRNK with Spring Boot and Keycloak. My goal is to define authorizations inside keycloak and have CRNK to filter resources base on it. My approache consist of let the keycloak adapter to handle resources filtering and use CRKN to handle field-based and data-bases authorizations. Is it the best approaches? And how can i get the Keycloak token that contains user scopes and use it inside CRNK?
Remo
@remmeier
seems good. if you need access to http header or other thing, spring (boot) means like auto wiring should be om I think? nothing needed on crnk side? HttpRequestContextAware is the crnk mechanism to access headers
Romain LE BARO
@scandinave
I have some doubts with how implement security with CRNK. Another possibility i have, is to retrieve user scope and map it with CRNK security. But i dont know where to define this mapping that need to be process on each request :
Resource-based authorization: Don't know where ?

Field-based authorization: Implementing ResourceFilter as Spring @Component?

Data-based authorization: Inside SecurityConfigurer.config.setDataRoomFilter?
Remo
@remmeier
typically one sets up Spring Security. This will hook into the servlet engine. And crnk can just make use of HttpServletRequest.isUserInRole (built-in default). All that then has to be implemented manually is a SecurityConfigurer that will setup the mapping of Roles to actual resource authorizations (and potentially further dataroom one).
Romain LE BARO
@scandinave
If i do it with isUserInRole my application roles will be hardcoded inside the application and will need a rebuild/redeploy of the app if a role is added no? I need something more dynamic where scope are retrieve from the jwt provided by keycloak (I know how to do that ) and map with the crnk authorizations/querySpec .
Remo
@remmeier
adding a new role usually means changing the application itself, not? whereas adding/removing roles for users (and pass along with JWTs) is quite common. or does it work diffferently in your case?
duncanportelli
@duncanportelli
@remmeier when creating a resource, the JSON:API spec that multiple response codes are supported (https://jsonapi.org/format/#crud-creating-responses). I have a case where I want to return a 202 Accepted instead of a 201 Created. Is this supported with the current functionality in Crnk please?
maarten-cb
@maarten-cb

Hi! Has anyone been able to get an OR filter to work with relationships?
When I filter on two attributes, it works fine and I get results that match both conditions:

/things/thing?filter={
    "OR": [
        {"unassigned": true},
        {"active": true}
    ]
}

But when I add a relationships to the filter, it only returns the records matching the relationship condition. I can have a thousand unassigned records without an assignee relationship, but it will not return them.

/things/thing?filter={
    "OR": [
        {"unassigned": true},
        {"assignee": {"user_id": "13d012e6-57ae-11e9-8647-d663bd873d93"}}
    ]
}

Is there a trick to this, a workaround perhaps? I'm on crnk 3.3

@maarten-cb what kind of repository are you using? maybe jpa where inner joins could be an issue?
maarten-cb
@maarten-cb
@remmeier That's right! I'll log the query and see what's going on there. Thanks.
duncanportelli
@duncanportelli
Thanks @remmeier
maarten-cb
@maarten-cb
@remmeier You were correct. It's doing an inner join on assignees, which eliminates the chance of any records without an assignee relationship to be included. I'm not sure how to influence the query to make it a left join. Any ideas?
Romain LE BARO
@scandinave
@Remo yeah, in my case the role and it's authorisations are provided by a authorisations server ( keycloak ) and can be change without having to rebuild the application. I think I have found a way to do this by exploiting permissions inside token and map it with crkn resource and field filters.
Remo
@remmeier
@maarten-cb I think the jpa repository, its config or the executor allows to change the default join type. potentially we should im prove the strategy and automatically go to outer join for some use cases. this is actually already happening for sorting.
@scandinave if you think you need more flexibility, you can have a closer look at the security module. i thin it already allows reconfiguration at runtime. beyond that there is also the possibility to go a layer deeper and buld an own one. the basic filter api is quite generic and then security module is more of a reasonable default i would say.
Jochen Reinhardt
@JochenReinhardt
I have trouble with HTTP authentication.
I always get a 401, then a subsequent request with credentials included, is OK.