Skip to content

Commit

Permalink
Move isOnlineFile to model
Browse files Browse the repository at this point in the history
add changelog
  • Loading branch information
Siedlerchr committed Oct 27, 2017
1 parent 7cae604 commit d03c71f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where JabRef would freeze when trying to replace the original entry after a merge with new information from identifiers like DOI/ISBN etc. [3294](https://github.com/JabRef/jabref/issues/3294)
- We fixed an issue where JabRef would not show the translated content at some points, although there existed a translation
- We fixed an issue where editing in the source tab would override content of other entries [#3352](https://github.com/JabRef/jabref/issues/3352#issue-268580818)
### Removed
- We fixed an issue where file links created under windows could not be opened on Linux/OSX [#3311](https://github.com/JabRef/jabref/issues/3311)

### Removed



Expand Down
9 changes: 0 additions & 9 deletions src/main/java/org/jabref/logic/util/io/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,6 @@ public static String getValidFileName(String fileName) {
return fileName;
}

/**
* Checks if the given String is an online link
* @param toCheck The String to check
* @return True if it starts with http://, https:// or contains www; false otherwise
*/
public static boolean isOnlineLink(String toCheck) {
return toCheck.startsWith("http://") || toCheck.startsWith("https://") || toCheck.contains("www.");
}

/**
* Adds an extension to the given file name. The original extension is not replaced. That means, "demo.bib", ".sav"
* gets "demo.bib.sav" and not "demo.sav"
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/org/jabref/model/entry/LinkedFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import org.jabref.logic.util.io.FileUtil;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.metadata.FileDirectoryPreferences;
import org.jabref.model.util.FileHelper;
Expand All @@ -36,7 +35,7 @@ public LinkedFile(String description, String link, String fileType) {
this.description.setValue(Objects.requireNonNull(description));

String fileLink = Objects.requireNonNull(link);
if (!FileUtil.isOnlineLink(fileLink)) {
if (!FileHelper.isOnlineLink(fileLink)) {
this.link.setValue(fileLink.replace("\\", "/"));
} else {
this.link.setValue(fileLink);
Expand Down Expand Up @@ -70,7 +69,7 @@ public String getLink() {
}

public void setLink(String link) {
if (!FileUtil.isOnlineLink(link)) {
if (!FileHelper.isOnlineLink(link)) {
this.link.setValue(link.replace("\\", "/"));
} else {
this.link.setValue(link);
Expand Down Expand Up @@ -137,7 +136,7 @@ public boolean isEmpty() {
}

public boolean isOnlineLink() {
return FileUtil.isOnlineLink(link.get());
return FileHelper.isOnlineLink(link.get());
}

public Optional<Path> findIn(BibDatabaseContext databaseContext, FileDirectoryPreferences fileDirectoryPreferences) {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/jabref/model/util/FileHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

public class FileHelper {

/**
* Checks if the given String is an online link
* @param toCheck The String to check
* @return True if it starts with http://, https:// or contains www; false otherwise
*/
public static boolean isOnlineLink(String toCheck) {
return toCheck.startsWith("http://") || toCheck.startsWith("https://") || toCheck.contains("www.");
}

/**
* Returns the extension of a file or Optional.empty() if the file does not have one (no . in name).
*
Expand Down

0 comments on commit d03c71f

Please sign in to comment.