Skip to content
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

Resources.getInstance(LONG) returns resource, but no externalId #46

Closed
WerVbn opened this issue Aug 23, 2017 · 1 comment
Closed

Resources.getInstance(LONG) returns resource, but no externalId #46

WerVbn opened this issue Aug 23, 2017 · 1 comment

Comments

@WerVbn
Copy link

WerVbn commented Aug 23, 2017

Resource resource = Resources.getInstance(91L); returns the desired resource, but not the externalId of the resource. This happens only, when a long parameter is passed to the method.

resouce.getExternalId() returns null

@fspinnenhirn
Copy link
Member

Hello Tesfel,

what you are observing will make sense when you think of the Resource as a really lightweight data transfer object. The only purpose of the Resources.getInstance() methods is to provide a uniform way to tell an OACC access control context which resource(s) you're operating on, instead of overloading each OACC method with long parameters for resource ids and String parameters for external ids.

The getInstance() methods don't perform any lookups to fully resolve a resource with both resourceId and externalId; they just set whatever parameter you specified on the returned resource instance. If you, for example, use the other factory method Resources.getInstance("myExternalId"), you would get a resource instance that only has the externalId set and its resourceId would be null.

The access control context is the one that will actually resolve each Resource instance and lookup the corresponding resource id for a given external id, and vice versa. Any resources you get back from an access control context call will of course also be fully resolved.

Let me know if you have any other questions, Tesfel.
Regards,
-Fabian

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

No branches or pull requests

2 participants