-
Notifications
You must be signed in to change notification settings - Fork 134
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
Adds the link_filter.yml file to the default configuration when running ACHE as a REST server #175
Open
jpmantuano
wants to merge
10
commits into
VIDA-NYU:master
Choose a base branch
from
jpmantuano:link_filters_v1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d90ce5a
es_5 compatible with readability
379e909
es 5 config
040f0f1
running ache with elasticsearch 5.3.2
89ff4d0
Merge remote-tracking branch 'upstream/master'
4dc22d5
Merge remote-tracking branch 'upstream/master'
e2b8b7d
fixes merge conflict
280f6c7
merges conflicts
7800c04
removes local configuration changes
7b6d477
removes local configuration changes
74c62d6
initial attempt to add the default link_filter.yml file when starting…
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 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 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 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,97 @@ | ||
package focusedCrawler.link; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class LinkFilterConfig { | ||
|
||
private static final ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory()); | ||
private static final String LINK_FILTERS_FILE = "link_filters.yml"; | ||
|
||
static { | ||
yamlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | ||
} | ||
|
||
@JsonProperty("global.type") | ||
private String type = "wildcard"; | ||
|
||
@JsonProperty("global.whitelist") | ||
private List<String> whitelist = Collections.emptyList(); | ||
|
||
@JsonProperty("global.blacklist") | ||
private List<String> blacklist = Collections.emptyList(); | ||
|
||
private String fileLocation; | ||
|
||
public LinkFilterConfig() { | ||
} | ||
|
||
public LinkFilterConfig(String configPath) { | ||
this(Paths.get(configPath)); | ||
} | ||
|
||
public LinkFilterConfig(Path linkFiltersPath) { | ||
Path linkFiltersFile; | ||
if (Files.isDirectory(linkFiltersPath)) { | ||
linkFiltersFile = linkFiltersPath.resolve(LINK_FILTERS_FILE); | ||
} else { | ||
linkFiltersFile = linkFiltersPath; | ||
} | ||
try { | ||
init(yamlMapper.readTree(linkFiltersFile.toFile())); | ||
} catch (IOException e) { | ||
throw new IllegalArgumentException("Could not read config from file: " + linkFiltersFile.toString(), e); | ||
} | ||
} | ||
|
||
private void init(JsonNode linkFilters) throws IOException { | ||
yamlMapper.readerForUpdating(this).readValue(linkFilters); | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public List<String> getWhitelist() { | ||
return whitelist; | ||
} | ||
|
||
public List<String> getBlacklist() { | ||
return blacklist; | ||
} | ||
|
||
public void setLinkFilterType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public void setWhiteList(List<String> whitelist) { | ||
this.whitelist = whitelist; | ||
} | ||
|
||
public void setBlackList(List<String> blacklist) { | ||
this.blacklist = blacklist; | ||
} | ||
|
||
public String getFileLocation() { | ||
if (StringUtils.isNotEmpty(fileLocation)) { | ||
return fileLocation.trim(); | ||
} else { | ||
return ""; | ||
} | ||
} | ||
|
||
public void setFileLocation(String fileLocation) { | ||
this.fileLocation = fileLocation; | ||
} | ||
} |
This file contains 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 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 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 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.
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 setter doesn't seem necessary since
configPath
is already passed in the constructor.