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

Review of endpoint to return all resources #392

Merged
merged 19 commits into from
Jan 21, 2025

Conversation

axl8713
Copy link
Collaborator

@axl8713 axl8713 commented Jan 13, 2025

Changes as per #379:

  • Added order/sort parameter with ascending/descending option for all available resource attributes
  • Added missing support for filtering resources by:
    • creator (the owner of the resource)
    • editor (the last user who modified the resource that is used for indicating the modified by on the front-end)
  • Added missing support for filtering resources by group
  • Added permissions information (canCopy, canDelete, canEdit) to the response
  • Fixed date parsing in filtering to accept dates without milliseconds part

Other changes:

  • Centralized and Refactored the user permissions checks on resources
  • Moved endpoint /extjs/search/{nameLike} to /extjs/search/resource/{nameLike}, avoiding the clash with GET requests on /extjs/search/list

Closes #379 .

@axl8713 axl8713 self-assigned this Jan 13, 2025
@axl8713 axl8713 marked this pull request as draft January 13, 2025 16:30
@axl8713 axl8713 marked this pull request as ready for review January 16, 2025 12:22
@axl8713 axl8713 requested a review from afabiani January 16, 2025 12:23
Copy link
Member

@afabiani afabiani left a comment

Choose a reason for hiding this comment

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

General Observations

  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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

@axl8713
Copy link
Collaborator Author

axl8713 commented Jan 17, 2025

  1. 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.

As it is, that exception already gets logged at the warning level from the REST service, along with its root cause.

@axl8713 axl8713 requested a review from afabiani January 20, 2025 11:41
@afabiani afabiani merged commit 9f4d79a into geosolutions-it:master Jan 21, 2025
2 checks passed
@axl8713 axl8713 deleted the geostore-379 branch January 21, 2025 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Review of endpoint to return all resources
2 participants