use of org.onehippo.cms7.essentials.dashboard.annotations.HippoEssentialsGenerated in project hippo by NHS-digital-website.
the class Video method getVideoUri.
@HippoEssentialsGenerated(internalName = "website:externallinkbase")
public String getVideoUri() {
String videoUri = getSingleProperty("website:externallinkbase");
// Regex adapted from https://regexr.com/3dj5t - named groups added
Pattern youtubeTest = Pattern.compile("^(?<protocol>(?:https?:)?\\/\\/)" + "?(?<subdomain>(?:www|m)\\.)" + "?(?<domain>(?:youtube\\.com|youtu.be))" + "(?<type>\\/(?:[\\w\\-]+\\?v=|embed\\/|v\\/)?)" + "(?<videoID>[\\w\\-]+)" + "(?<query>\\S+)?$", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
Matcher youtubeMatch = youtubeTest.matcher(videoUri);
// Make sure that YouTube URLs use the right format
if (youtubeMatch.matches()) {
return String.format("https://www.youtube-nocookie.com/embed/%s?modestbranding=1", youtubeMatch.group("videoID"));
}
// Regex adapted from https://regexr.com/393r3 - named groups added
Pattern vimeoTest = Pattern.compile("(?:<iframe [^>]*src=\")?" + "(?:https?:\\/\\/" + "(?:[\\w]+\\.)*vimeo\\.com" + "(?:[\\/\\w:]*(?:\\/videos)?)?\\/" + "(?<videoID>[0-9]+)[^\\s]*)\"?" + "(?:[^>]*><\\/iframe>)?" + "(?:<p>.*<\\/p>)?", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
Matcher vimeoMatch = vimeoTest.matcher(videoUri);
// Make sure that Vimeo URLs use the right embed format
if (vimeoMatch.matches()) {
return String.format("https://player.vimeo.com/video/%s?color=005eb8&portrait=0", vimeoMatch.group("videoID"));
}
return videoUri;
}
use of org.onehippo.cms7.essentials.dashboard.annotations.HippoEssentialsGenerated in project hippo by NHS-digital-website.
the class Role method getPrimaryroles.
@HippoEssentialsGenerated(internalName = "website:primaryrole", allowModifications = false)
public List<String> getPrimaryroles() {
List<String> roles = new ArrayList<String>();
List<HippoBean> rolepickers = this.getRolepicker();
for (HippoBean picker : rolepickers) {
JobRolePicker rolepicker = (JobRolePicker) picker;
if (rolepicker != null && rolepicker.getPrimaryrolepicker() != null) {
JobRole jobrole = rolepicker.getPrimaryrolepicker();
if (jobrole != null) {
roles.add(jobrole.getTitle());
}
}
}
if (roles.size() == 0) {
roles.add(getSingleProperty("website:primaryrole"));
}
return roles;
}
Aggregations