Repository navigation
Allow users of the SDK to provide their own copy of the apache HTTP … #1
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
60 changes: 60 additions & 0 deletions
60
cloudinary-core/src/main/java/com/cloudinary/legacy/LegacyCloudinaryLoader.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package com.cloudinary.legacy; | ||
|
|
||
| import com.cloudinary.Cloudinary; | ||
| import com.cloudinary.Configuration; | ||
| import com.cloudinary.strategies.AbstractApiStrategy; | ||
| import com.cloudinary.strategies.AbstractUploaderStrategy; | ||
| import com.cloudinary.strategies.StrategyLoader; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Allows for construction of the abstract Cloudinary class using the legacy method of loading classes dynamically | ||
| * using reflection. This is needed to support the cloudinary-taglib library. | ||
| * | ||
| * @since some version number | ||
| * <p> | ||
| * Replaced by {@link com.cloudinary.http5.CloudinaryClient} | ||
| * @deprecated this method of instantiation is deprecated and not recommended for new projects. | ||
| */ | ||
| @Deprecated | ||
| public class LegacyCloudinaryLoader extends Cloudinary { | ||
| private static final List<String> UPLOAD_STRATEGIES = new ArrayList<>(Arrays.asList( | ||
| "com.cloudinary.android.UploaderStrategy", | ||
| "com.cloudinary.http5.UploaderStrategy")); | ||
| public static final List<String> API_STRATEGIES = new ArrayList<>(Arrays.asList( | ||
| "com.cloudinary.android.ApiStrategy", | ||
| "com.cloudinary.http5.ApiStrategy")); | ||
|
|
||
|
|
||
| public LegacyCloudinaryLoader() { | ||
| super(loadDefaultConfig(), getUploaderStrategy(loadDefaultConfig()), getApiStrategy(loadDefaultConfig())); | ||
| } | ||
|
|
||
| public LegacyCloudinaryLoader(Map<String, Object> configuration) { | ||
| super(new Configuration(configuration), getUploaderStrategy(new Configuration(configuration)), getApiStrategy(new Configuration(configuration))); | ||
| } | ||
|
|
||
| public LegacyCloudinaryLoader(String url) { | ||
| super(Configuration.from(url), getUploaderStrategy(Configuration.from(url)), getApiStrategy(Configuration.from(url))); | ||
| } | ||
|
|
||
| private static AbstractApiStrategy getApiStrategy(Configuration configuration) { | ||
| if (!configuration.loadStrategies) { | ||
| return null; | ||
| } | ||
|
|
||
| return StrategyLoader.find(API_STRATEGIES); | ||
| } | ||
|
|
||
| private static AbstractUploaderStrategy getUploaderStrategy(Configuration configuration) { | ||
| if (!configuration.loadStrategies) { | ||
| return null; | ||
| } | ||
|
|
||
| return StrategyLoader.find(UPLOAD_STRATEGIES); | ||
| } | ||
| } | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
31 changes: 31 additions & 0 deletions
31
cloudinary-http5/src/main/java/com/cloudinary/http5/CloudinaryClient.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package com.cloudinary.http5; | ||
|
|
||
| import com.cloudinary.Cloudinary; | ||
| import com.cloudinary.Configuration; | ||
| import com.cloudinary.strategies.AbstractApiStrategy; | ||
| import com.cloudinary.strategies.AbstractUploaderStrategy; | ||
| import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| public class CloudinaryClient extends Cloudinary { | ||
| public CloudinaryClient() { | ||
| super(loadDefaultConfig(), new UploaderStrategy(), new ApiStrategy()); | ||
| } | ||
|
|
||
| public CloudinaryClient(Configuration config, AbstractUploaderStrategy uploaderStrategy, AbstractApiStrategy apiStrategy) { | ||
| super(config, uploaderStrategy, apiStrategy); | ||
| } | ||
|
|
||
| public CloudinaryClient(Map config) { | ||
| super(new Configuration(config), new UploaderStrategy(), new ApiStrategy()); | ||
| } | ||
|
|
||
| public CloudinaryClient(String url) { | ||
| super(Configuration.from(url), new UploaderStrategy(), new ApiStrategy()); | ||
| } | ||
|
|
||
| public CloudinaryClient(Configuration configuration, CloseableHttpClient httpClient) { | ||
| super(configuration, new UploaderStrategy(httpClient), new ApiStrategy(httpClient)); | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
The
load_strategiesconfiguration property introduces unnecessary complexity to these constructors. Due to Java 8's requirement thatsuper()must be the first statement in a constructor, combined with the conditional nature of the legacy strategy loading, we're forced into a more complicated implementation than is ideal.I think that this property only exists for testing purposes in
CloudinaryTest.java. If it were up to me I would consider removing it entirely and restructuring those tests accordingly. This would lead to cleaner, more maintainable constructor logic.