-
Notifications
You must be signed in to change notification settings - Fork 29
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
base: dev
Are you sure you want to change the base?
Conversation
ba3df7e
to
9f4e08f
Compare
b7ad46d
to
ca74218
Compare
package apoc.util; | ||
|
||
public class CoreUtil {} |
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.
Why is this needed?
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.
It's not 👀
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; | ||
} | ||
} | ||
|
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.
Is this new or moved from somewhere else?
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.
This is from somewhere else, APOC config needed it in common still, so instead of not moving an entire file, I kept this one behind iirc
ca74218
to
0def4e8
Compare
No description provided.