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

ASSETS-33747 named smartcrop in image core v3 component #2676

Closed
wants to merge 20 commits into from

Conversation

mohiaror
Copy link
Collaborator

Instead of fastly smartcrops, expect named smartcrops in delivery URLs.

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Minor: New Feature?
Major: Breaking Change?
Tests Added + Pass? Yes
Documentation Provided Yes (code comments and or markdown)
Any Dependency Changes?
License Apache License, Version 2.0

@@ -32,6 +43,8 @@
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONException;
Copy link
Contributor

Choose a reason for hiding this comment

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

You should no longer use those deprecated dependencies (https://javadoc.io/doc/com.adobe.aem/uber-jar/latest/org/json/package-summary.html), but rather javax.json

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Refactored to remove the deprecated dependencies.

StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == HttpStatus.SC_OK) {
HttpEntity e = response.getEntity();
Copy link
Contributor

Choose a reason for hiding this comment

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

You should always close the response. Better use the execute method taking a ResponseHandler (https://hc.apache.org/httpcomponents-client-4.5.x/current/httpclient/apidocs/org/apache/http/client/HttpClient.html#execute(org.apache.http.client.methods.HttpUriRequest,%20org.apache.http.client.ResponseHandler)) and directly act on the returned input stream.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kwin Thanks. Incorporated the feedback in new commit.

@mohiaror mohiaror changed the title ASSETS-33747 named smartcrop in image core v3 component powered by fastly ASSETS-33747 named smartcrop in image core v3 component Feb 28, 2024
@@ -135,6 +155,37 @@ public String getSrcset() {
// in case of dm image and auto smartcrop the srcset needs to generated client side
if (dmImage && StringUtils.equals(smartCropRendition, SMART_CROP_AUTO)) {
srcSet = EMPTY_PIXEL;
} else if (ngdmImage && StringUtils.equals(smartCropRendition, SMART_CROP_AUTO) && client != null) {
String endPointUrl = "https://" + nextGenDynamicMediaConfig.getRepositoryId() + metadataDeliveryEndpoint;
Copy link
Member

Choose a reason for hiding this comment

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

Please move this to a separate method to facilitate unit-testing!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved it into a separate function.

Copy link

sonarcloud bot commented Mar 12, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

codecov bot commented Mar 17, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 87.15%. Comparing base (8fbb567) to head (1566ce3).

Files Patch % Lines
.../core/components/internal/models/v3/ImageImpl.java 86.48% 2 Missing and 3 partials ⚠️
...dels/v3/NextGenDMSrcsetBuilderResponseHandler.java 75.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2676      +/-   ##
============================================
- Coverage     87.17%   87.15%   -0.03%     
- Complexity     2668     2673       +5     
============================================
  Files           233      234       +1     
  Lines          7128     7161      +33     
  Branches       1090     1095       +5     
============================================
+ Hits           6214     6241      +27     
- Misses          363      365       +2     
- Partials        551      555       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mohiaror
Copy link
Collaborator Author

Closing this PR in favor of #2698

@mohiaror mohiaror closed this Apr 30, 2024
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.

None yet

4 participants