Skip to content

Add extra attributes to Link and use for HAL mediatype #567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

gregturn
Copy link
Contributor

@gregturn gregturn commented Mar 26, 2017

Adds many additional attributes defined in RFC5988 and verifies they work properly in the neutral representation of Link while also being rendered properly in the HAL module.

Related tickets: #100, #417, #235
Previous pull requests: #240, #238, #223, #79

gregturn added a commit that referenced this pull request Mar 26, 2017
Adds many additional attributes defined in RFC5988 and verifies they work properly in the neutral representation of Link while also being rendered properly in the HAL module.

Related tickets: #100, #417, #235, #240, #238, #223
@gregturn
Copy link
Contributor Author

@olivergierke I redid this PR so that it doesn't attempt to clean up any whitespace.

@gregturn gregturn self-assigned this Mar 26, 2017
@gregturn gregturn requested a review from odrotbohm March 26, 2017 17:24
gregturn added a commit that referenced this pull request Mar 26, 2017
Adds many additional attributes defined in RFC5988 and verifies they work properly in the neutral representation of Link while also being rendered properly in the HAL module.

Related tickets: #100, #417, #235
Previous pull requests: #240, #238, #223
gregturn added a commit that referenced this pull request Mar 26, 2017
Adds many additional attributes defined in RFC5988 and verifies they work properly in the neutral representation of Link while also being rendered properly in the HAL module.

Related tickets: #100, #417, #235
Previous pull requests: #240, #238, #223, #79
@gregturn gregturn added this to the 0.24 milestone Mar 26, 2017
Adds many additional attributes defined in RFC5988 and verifies they work properly in the neutral representation of Link while also being rendered properly in the HAL module.

Related tickets: #100, #417, #235
Previous pull requests: #240, #238, #223, #79
@netwolfuk
Copy link

Hi @gregturn @olivergierke
I'm just wondering if you have an ETA for 0.24 release?
Many thanks.

@gregturn
Copy link
Contributor Author

@netwolfuk I can certainly comment that Oliver was out for a couple weeks, so he has been catching up on a stack of stuff across the Spring Data suite, the biggest HATEOAS one being the Affordances API effort. The goal is to at least have that pulled in.

I'm working to get several other patches pulled in as well (may be at least 7 other PRs I have yet to review with Oliver).

What may be highly pertinent to this PR is that the Affordances PR ALSO pulls in extra RFC 5988 material, so I'll have to certainly reevaluate this one when the dust settles.

As to how many fit into 0.24, that has yet to be determined. It may be shaped by the state of Spring Data's release train when we finish Affordances.

Sorry about being so vague. Wanted to give you insight into the process.

@netwolfuk
Copy link

@gregturn Thanks for the thorough response. I really appreciate all you guys do.

@nstaeger
Copy link

nstaeger commented Jun 22, 2017

Would highly appreciate if this would be merged and released with the next version, as it would be very useful to us. Thanks for implementing @gregturn

@gregturn
Copy link
Contributor Author

I'm shooting to get all the RFC 5988 material included. Just want a coherent solution between this PR and Affordances.

* @param type
* @param deprecation
*/
public Link(String href, String rel, String hreflang, String media, String title, String type, String deprecation) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to use Lombok here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

*
* @return
*/
public String getHreflang() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lombok?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* @param hreflang
* @return
*/
public Link withHreflang(String hreflang) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lombok's @Wither? Should we have withHref(…) and withRel(…), too, for consistency reasons?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -212,7 +347,20 @@ public boolean equals(Object obj) {

Link that = (Link) obj;

return this.href.equals(that.href) && this.rel.equals(that.rel);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EqualsAndHashCode?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -263,7 +448,34 @@ public static Link valueOf(String element) {
throw new IllegalArgumentException("Link does not provide a rel attribute!");
}

return new Link(matcher.group(1), attributes.get("rel"));
Set<String> unrecognizedHeaders = unrecognizedHeaders(attributes);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following Postel's Law I think we should not throw an exception here but just ignore attributes that we don't understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

odrotbohm pushed a commit that referenced this pull request Jul 28, 2017
Adds many additional attributes defined in RFC5988 and verifies they work properly in the neutral representation of Link while also being rendered properly in the HAL module.

Related tickets: #100, #417, #235
Previous pull requests: #240, #238, #223, #79
odrotbohm added a commit that referenced this pull request Jul 28, 2017
Field annotations inline. Formatting.
@odrotbohm
Copy link
Member

That's merged.

@VelDeveloper
Copy link

@olivergierke @gregturn I am facing the similar issue... I would like to add an extra attribute along with "href". May I know how to do it? Any help would be appreciable. I am using spring-boot 1.5.8 along with Hateoas

@gregturn
Copy link
Contributor Author

Not sure what attribute you seek. What mediatype can this property be found in?

To answer your question, Link is a cornerstone class to all of Spring HATEOAS. There are factory methods that generate Links, hence the only way to customize the class is the fork the project and code your own tweaks. Anything else would require inserting some factory pattern which is frankly unnecessary.

We don't lots of requests of people needed to customize the Link type, especially in light of added RFC 5988 support, so a little more explanation of what you seek would help, especially in a new issue, since this one is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants