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

getResourceInternal implementation for cmis and jcloud #8466

Conversation

wangf1122
Copy link
Collaborator

@wangf1122 wangf1122 commented Oct 24, 2024

This change implement getResourceInternal (created in #5467) for CmisStore and JcloudStore.

It is used by buildDataUrl

public static String buildDataUrl(String url, Integer size) {
StringBuilder sb = new StringBuilder("data:");
String supportedExtension = "jpg|jpeg|png|gif|tif|tiff";
String extension = Files.getFileExtension(url).toLowerCase();
if (extension.matches(supportedExtension)) {
InputStream in = null;
try {
SettingManager settingManager = ApplicationContextHolder.get().getBean(SettingManager.class);
Matcher m = Pattern.compile(settingManager.getNodeURL() + "api/records/(.*)/attachments/(.*)$").matcher(url);
BufferedImage image;
if (m.find()) {
Store store = ApplicationContextHolder.get().getBean(FilesystemStore.class);
try (Store.ResourceHolder file = store.getResourceInternal(

and the function is used within individual shema's search engine indexing. for example:

<xsl:variable name="data"
select="util:buildDataUrl(., 140)"/>
<xsl:if test="$data != ''">,
"data": "<xsl:value-of select="$data"/>"

Checklist

  • I have read the contribution guidelines
  • Pull request provided for main branch, backports managed with label
  • Good housekeeping of code, cleaning up comments, tests, and documentation
  • Clean commit history broken into understandable chucks, avoiding big commits with hundreds of files, cautious of reformatting and whitespace changes
  • Clean commit messages, longer verbose messages are encouraged
  • API Changes are identified in commit messages
  • Testing provided for features or enhancements using automatic tests
  • User documentation provided for new features or enhancements in manual
  • Build documentation provided for development instructions in README.md files
  • Library management using pom.xml dependency management. Update build documentation with intended library use and library tutorials or documentation

@wangf1122 wangf1122 marked this pull request as ready for review October 24, 2024 19:53
@josegar74 josegar74 added this to the 4.4.7 milestone Oct 29, 2024
Copy link
Member

@josegar74 josegar74 left a comment

Choose a reason for hiding this comment

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

I haven't test the changes, but the code looks good.

Copy link
Contributor

@ianwallen ianwallen left a comment

Choose a reason for hiding this comment

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

Tested and works as expected.

@ianwallen ianwallen merged commit c93b5b1 into geonetwork:main Nov 1, 2024
6 checks passed
@geonetworkbuild
Copy link
Collaborator

The backport to 4.2.x failed:

The process '/usr/bin/git' failed with exit code 1
stderr
error: could not apply 0dae38f203... getResourceInternal implementation for cmis and jcloud
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config advice.mergeConflict false"

stdout
Auto-merging core/src/main/java/org/fao/geonet/api/records/attachments/CMISStore.java
Auto-merging core/src/main/java/org/fao/geonet/api/records/attachments/JCloudStore.java
Auto-merging core/src/main/java/org/fao/geonet/util/XslUtil.java
CONFLICT (content): Merge conflict in core/src/main/java/org/fao/geonet/util/XslUtil.java

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.2.x 4.2.x
# Navigate to the new working tree
cd .worktrees/backport-4.2.x
# Create a new branch
git switch --create backport-8466-to-4.2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick 0dae38f2032e24f37b9ec2f38ba9c6e333cb4964,eea7be8c1042ac5e0e712c1d70d5db4b84588b93,ff1b54c68547a26e1d339f0afadfeb118b89f796
# Push it to GitHub
git push --set-upstream origin backport-8466-to-4.2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.2.x

Then, create a pull request where the base branch is 4.2.x and the compare/head branch is backport-8466-to-4.2.x.

ianwallen pushed a commit to ianwallen/core-geonetwork that referenced this pull request Nov 1, 2024
* getResourceInternal implementation for cmis and jcloud

* Implementation in ResourceLoggerStore

* User filesystemStore bean instead of resourceStore
ianwallen added a commit that referenced this pull request Nov 1, 2024
* getResourceInternal implementation for cmis and jcloud

* Implementation in ResourceLoggerStore

* User filesystemStore bean instead of resourceStore

Co-authored-by: wangf1122 <[email protected]>
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.

4 participants