-
Notifications
You must be signed in to change notification settings - Fork 96
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
Review of endpoint to return all resources #392
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixed adding permissions to the payload for the external resources search list.
afabiani
reviewed
Jan 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General Observations
- Repeated Permission Logic
- You have permission checks scattered in ResourceServiceImpl, RESTExtJsServiceImpl, ResourceEnvelop, and the ShortResource creation. This can lead to maintenance headaches.
- Recommendation: Centralize read/write/copy permission checks in a single place (e.g., PermissionService or a “Policy” class). Then, everything that needs permission info calls that service.
- Potential Performance / DB Queries
- Repeated calls to resourceService.getSecurityRules(...) inside loops or streams can become expensive if you have many resources.
- Recommendation: Where feasible, fetch all relevant SecurityRules for the user in bulk. Or do a single join in the DAO so each Resource already has the needed rules loaded.
- DTO vs. Entity
- The @transient fields (canEdit, canDelete, canCopy) indicate you’re mixing view-layer logic with domain objects. If that’s a conscious design choice, it’s valid, but watch out for “entity bloat.”
- Recommendation: A simpler approach might be returning a dedicated ResourceDTO from the service layer, which includes these transient fields and no JPA annotations.
- Logging / Exception Handling
- Some methods (like search(Search searchCriteria)) catch IllegalArgumentException and rethrow a BadRequestServiceEx with “Resource search failed.” That’s fine, but ensure you log the root cause somewhere for debugging.
- Recommendation: Add a logger statement with the exception’s message or full stack trace if it helps with debugging.
- Documentation
- Before consider this PR done, let's make sure we updated the WIKI API sections with the relevant parameters.
- There shouldn't be any model update here, so no need to update the
doc/sql/
scripts
src/core/model/src/main/java/it/geosolutions/geostore/core/model/Resource.java
Outdated
Show resolved
Hide resolved
src/core/services-api/src/main/java/it/geosolutions/geostore/services/ResourceService.java
Outdated
Show resolved
Hide resolved
src/core/services-impl/src/main/java/it/geosolutions/geostore/services/ResourceServiceImpl.java
Outdated
Show resolved
Hide resolved
src/core/services-impl/src/main/java/it/geosolutions/geostore/services/ResourceServiceImpl.java
Outdated
Show resolved
Hide resolved
...st/extjs/src/main/java/it/geosolutions/geostore/services/rest/impl/RESTExtJsServiceImpl.java
Outdated
Show resolved
Hide resolved
...st/extjs/src/main/java/it/geosolutions/geostore/services/rest/impl/RESTExtJsServiceImpl.java
Outdated
Show resolved
Hide resolved
...st/extjs/src/main/java/it/geosolutions/geostore/services/rest/impl/RESTExtJsServiceImpl.java
Outdated
Show resolved
Hide resolved
src/core/services-impl/src/main/java/it/geosolutions/geostore/util/SearchConverter.java
Outdated
Show resolved
Hide resolved
src/core/services-impl/src/main/java/it/geosolutions/geostore/util/SearchConverter.java
Show resolved
Hide resolved
...xtjs/src/test/java/it/geosolutions/geostore/services/rest/impl/RESTExtJsServiceImplTest.java
Show resolved
Hide resolved
As it is, that exception already gets logged at the warning level from the REST service, along with its root cause. |
afabiani
approved these changes
Jan 21, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes as per #379:
Other changes:
/extjs/search/{nameLike}
to/extjs/search/resource/{nameLike}
, avoiding the clash with GET requests on/extjs/search/list
Closes #379 .