mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +00:00
[TLC-380] Fix checkstyle and duplicate code
This commit is contained in:
@@ -59,23 +59,7 @@ public class CrossLinks {
|
|||||||
* @return true/false
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
public boolean hasLink(String metadata) {
|
public boolean hasLink(String metadata) {
|
||||||
// Resolve wildcards properly, eg. dc.subject.other matches a configuration for dc.subject.*
|
return findLinkType(metadata) != null;
|
||||||
for (String key : links.keySet()) {
|
|
||||||
if (null != key && key.endsWith(".*")) {
|
|
||||||
// A substring of length-1, also substracting the wildcard should work as a "startsWith"
|
|
||||||
// check for the field eg. dc.subject.* -> dc.subject is the start of dc.subject.other
|
|
||||||
if (null != metadata && metadata.startsWith(key.substring(0, key.length()-1 - ".*".length()))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Exact match, if the key field has no .* wildcard
|
|
||||||
if (links.containsKey(metadata)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,7 +102,7 @@ public class CrossLinks {
|
|||||||
if (null != key && key.endsWith(".*")) {
|
if (null != key && key.endsWith(".*")) {
|
||||||
// A substring of length-1, also substracting the wildcard should work as a "startsWith"
|
// A substring of length-1, also substracting the wildcard should work as a "startsWith"
|
||||||
// check for the field eg. dc.subject.* -> dc.subject is the start of dc.subject.other
|
// check for the field eg. dc.subject.* -> dc.subject is the start of dc.subject.other
|
||||||
if (null != metadata && metadata.startsWith(key.substring(0, key.length()-1 - ".*".length()))) {
|
if (null != metadata && metadata.startsWith(key.substring(0, key.length() - 1 - ".*".length()))) {
|
||||||
return links.get(key);
|
return links.get(key);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user