Skip to content

Add GenericConversionService with support for UUID and Strings - #6141

Closed
nenaraab wants to merge 1 commit into
spring-projects:masterfrom
nenaraab:spring-acl-4814
Closed

nenaraab wants to merge 1 commit into
spring-projects:masterfrom
nenaraab:spring-acl-4814

Conversation

@nenaraab

Copy link
Copy Markdown
Contributor

Motivation

As of now only acl_object_identity.object_id_identity of type java.util.Long are supported. In case you use identifiers of type java.lang.String or java.util.UUID the application needs to provide a ConversionService. This commit comes with two default Converters to support Strings and UUIDs.

related commit

pwheel@8efec02

related issue(s)

@jzheaux jzheaux left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@nenaraab Thank you for addressing all these items. There are two that I think I miscommunicated on, so I've tried clarifying that in one more review.

Once you have this commit ready, would you squash your commits, please? Thanks again for the PR!

@nenaraab

nenaraab commented Nov 27, 2018 •

Copy link
Copy Markdown
Contributor Author

@jzheaux

Sorry, i was not sure how to correct a pull request best... If i would have squashed it, would it then look prettier, i.e. better readable for review?

The additional String identifier was introduced by intention, to make sure that the String2String (and not only LongAsString2String) conversion works as expected.

Thanks for your time, help and review :-)

โ€ฆl_object_identity.object_id_identity

Co-Authored-By: nenaraab <nenaraab@users.noreply.github.com>
@jzheaux

jzheaux commented Nov 27, 2018

Copy link
Copy Markdown
Collaborator

@nenaraab Squashing helps with backpatches mostly, but yes it also helps a bit with the review process.

@nenaraab

Copy link
Copy Markdown
Contributor Author

@jzheaux
In regard to your question with the DEFAULT_IDENTIFIER_AS_STRING...

Before I'v started with the code change, i created the test to simulate the issues i've seen within my application when not specifying any ConversionService.

Before of this pull request: this test case would have been green.

   @Test
   public void shouldReturnStringWhenStringClassIdType() throws SQLException {
      // given
      String identifier = DEFAULT_IDENTIFIER_AS_STRING;
      // when
      Serializable newIdentifier = aclClassIdUtils.identifierFrom(identifier, resultSet);
   ...
   }

...as โ€œ999โ€ can be transformed to Long 999L. But the one below not:

   @Test
   public void shouldReturnStringWhenStringClassIdType() throws SQLException {
      // given
      String identifier = "MY_STRING_IDENTIFIER";
      // when
      Serializable newIdentifier = aclClassIdUtils.identifierFrom(identifier, resultSet);
      ....
   }

It gives me an java.lang.NumberFormatException: For input string: "MY_STRING_IDENTIFIER" because โ€œMY_STRING_IDENTIFIERโ€ can NOT be transformed to Long.

That's why i've decided to use a real "String" Identifier ...

@nenaraab

Copy link
Copy Markdown
Contributor Author

So, the commits are squashed... anything else to change :-)

@jzheaux jzheaux added type: enhancement A general enhancement in: acl An issue in spring-security-acl labels Nov 28, 2018
@jzheaux jzheaux added this to the 5.2.0.M1 milestone Nov 28, 2018
@jzheaux

jzheaux commented Nov 28, 2018

Copy link
Copy Markdown
Collaborator

Thanks again, @nenaraab for the PR! This is now merged into master via 918a4cd where I edited the commit message for clarity.

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

Labels

in: acl An issue in spring-security-acl type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants