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

Reduce Common Usage between APOC Extended and APOC Core #706

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

gem-neo4j
Copy link
Contributor

No description provided.

@gem-neo4j gem-neo4j force-pushed the dev_reduce_common_reliance branch 3 times, most recently from ba3df7e to 9f4e08f Compare December 17, 2024 07:59
@gem-neo4j
Copy link
Contributor Author

@gem-neo4j gem-neo4j force-pushed the dev_reduce_common_reliance branch 5 times, most recently from 3e7d15f to b7ad46d Compare December 20, 2024 08:00
@gem-neo4j gem-neo4j force-pushed the dev_reduce_common_reliance branch from b7ad46d to ca74218 Compare December 20, 2024 08:34
@gem-neo4j gem-neo4j marked this pull request as ready for review January 3, 2025 08:57
@JoelBergstrand JoelBergstrand self-assigned this Jan 7, 2025
Comment on lines +19 to +21
package apoc.util;

public class CoreUtil {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

Comment on lines +344 to +377
public static boolean isFile(String fileName) {
return from(fileName) == SupportedProtocols.file;
}

public static SupportedProtocols from(URL url) {
return FileUtils.of(url.getProtocol());
}

public static SupportedProtocols from(String source) {
try {
final URL url = new URL(source);
return from(url);
} catch (MalformedURLException e) {
if (!e.getMessage().contains("no protocol")) {
try {
// in case new URL(source) throw e.g. unknown protocol: hdfs, because of missing jar,
// we retrieve the related enum and throw the associated MissingDependencyException(..)
// otherwise we return unknown protocol: yyyyy
return SupportedProtocols.valueOf(new URI(source).getScheme());
} catch (Exception ignored) {
}

// in case a Windows user write an url like `C:/User/...`
if (e.getMessage().contains("unknown protocol") && Util.isWindows()) {
throw new RuntimeException(e.getMessage()
+ "\n Please note that for Windows absolute paths they have to be explicit by prepending `file:` or supplied without the drive, "
+ "\n e.g. `file:C:/my/path/file` or `/my/path/file`, instead of `C:/my/path/file`");
}
throw new RuntimeException(e);
}
return SupportedProtocols.file;
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this new or moved from somewhere else?

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.

2 participants