From 4c4789eef3256c80f7cff82db70e139518310aab Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Fri, 15 Dec 2023 10:29:33 +0100 Subject: [PATCH 1/4] refact: moved Role URIs to VitroVocabulary --- .../vitro/webapp/dao/VitroVocabulary.java | 6 ++++++ .../migration/auth/AnnotationMigrator.java | 18 ++++++++--------- .../webapp/migration/auth/ArmMigrator.java | 20 ++++++++++++------- .../webapp/migration/auth/AuthMigrator.java | 11 +++++----- .../auth/SimplePermissionMigrator.java | 10 +++++----- 5 files changed, 38 insertions(+), 27 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java index c762acfa83..3221231643 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java @@ -261,4 +261,10 @@ public enum Precision { } public String uri(){return URI;} } + + public static final String ROLE_PUBLIC_URI = "http://vitro.mannlib.cornell.edu/ns/vitro/authorization#PUBLIC"; + public static final String ROLE_SELF_EDITOR_URI = "http://vitro.mannlib.cornell.edu/ns/vitro/authorization#SELF_EDITOR"; + public static final String ROLE_EDITOR_URI = "http://vitro.mannlib.cornell.edu/ns/vitro/authorization#EDITOR"; + public static final String ROLE_CURATOR_URI = "http://vitro.mannlib.cornell.edu/ns/vitro/authorization#CURATOR"; + public static final String ROLE_ADMIN_URI = "http://vitro.mannlib.cornell.edu/ns/vitro/authorization#ADMIN"; } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/migration/auth/AnnotationMigrator.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/migration/auth/AnnotationMigrator.java index 8145754478..e4cea2785c 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/migration/auth/AnnotationMigrator.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/migration/auth/AnnotationMigrator.java @@ -1,11 +1,12 @@ package edu.cornell.mannlib.vitro.webapp.migration.auth; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_ADMIN_URI; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_CURATOR_URI; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_EDITOR_URI; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_PUBLIC_URI; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_SELF_EDITOR_URI; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.VITRO_AUTH; import static edu.cornell.mannlib.vitro.webapp.migration.auth.AuthMigrator.ALL_ROLES; -import static edu.cornell.mannlib.vitro.webapp.migration.auth.AuthMigrator.ROLE_ADMIN_URI; -import static edu.cornell.mannlib.vitro.webapp.migration.auth.AuthMigrator.ROLE_CURATOR_URI; -import static edu.cornell.mannlib.vitro.webapp.migration.auth.AuthMigrator.ROLE_EDITOR_URI; -import static edu.cornell.mannlib.vitro.webapp.migration.auth.AuthMigrator.ROLE_PUBLIC_URI; -import static edu.cornell.mannlib.vitro.webapp.migration.auth.AuthMigrator.ROLE_SELF_EDITOR_URI; import java.util.Arrays; import java.util.Collections; @@ -31,10 +32,7 @@ public class AnnotationMigrator { - private static final String ROLE_PREFIX = "http://vitro.mannlib.cornell.edu/ns/vitro/authorization#"; - private static final Log log = LogFactory.getLog(AnnotationMigrator.class); - private static final String PREFIX = "http://vitro.mannlib.cornell.edu/ns/vitro/role#"; private static final String OLD_ROLE_PUBLIC = PREFIX + "public"; private static final String OLD_ROLE_SELF = PREFIX + "selfEditor"; @@ -219,8 +217,8 @@ private static Object rolesToString(Set roles) { String result = ""; for (String roleUri : roles) { String roleName = roleUri; - if (roleName.startsWith(ROLE_PREFIX)) { - roleName = roleName.substring(ROLE_PREFIX.length()); + if (roleName.startsWith(VITRO_AUTH)) { + roleName = roleName.substring(VITRO_AUTH.length()); } if (!result.isEmpty()) { result += ", "; diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/migration/auth/ArmMigrator.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/migration/auth/ArmMigrator.java index 58b3af75f9..12a9b3027d 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/migration/auth/ArmMigrator.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/migration/auth/ArmMigrator.java @@ -1,5 +1,12 @@ package edu.cornell.mannlib.vitro.webapp.migration.auth; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.LABEL; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_ADMIN_URI; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_CURATOR_URI; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_EDITOR_URI; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_PUBLIC_URI; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_SELF_EDITOR_URI; + import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -14,7 +21,6 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.EntityPolicyController; import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyLoader; import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyTemplateController; -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils; @@ -79,11 +85,11 @@ public ArmMigrator(RDFService contentRdfService, RDFService configurationRdfServ operationMap.put(PUBLISH, OperationGroup.PUBLISH_GROUP); roleMap = new HashMap<>(); - roleMap.put(ARM_ADMIN, AuthMigrator.ROLE_ADMIN_URI); - roleMap.put(ARM_CURATOR, AuthMigrator.ROLE_CURATOR_URI); - roleMap.put(ARM_EDITOR, AuthMigrator.ROLE_EDITOR_URI); - roleMap.put(ARM_SELF_EDITOR, AuthMigrator.ROLE_SELF_EDITOR_URI); - roleMap.put(ARM_PUBLIC, AuthMigrator.ROLE_PUBLIC_URI); + roleMap.put(ARM_ADMIN, ROLE_ADMIN_URI); + roleMap.put(ARM_CURATOR, ROLE_CURATOR_URI); + roleMap.put(ARM_EDITOR, ROLE_EDITOR_URI); + roleMap.put(ARM_SELF_EDITOR, ROLE_SELF_EDITOR_URI); + roleMap.put(ARM_PUBLIC, ROLE_PUBLIC_URI); Set actualRoles = getPermissionSets(); for (String role : actualRoles) { if (!roleMap.values().contains(role)) { @@ -223,7 +229,7 @@ private void getRoleOperationObjectTypedStatementsToAdd(Map ALL_ROLES = new HashSet( Arrays.asList(ROLE_ADMIN_URI, ROLE_CURATOR_URI, ROLE_EDITOR_URI, ROLE_SELF_EDITOR_URI, ROLE_PUBLIC_URI)); diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/migration/auth/SimplePermissionMigrator.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/migration/auth/SimplePermissionMigrator.java index 6e747ae984..97ab5cbd7d 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/migration/auth/SimplePermissionMigrator.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/migration/auth/SimplePermissionMigrator.java @@ -1,11 +1,11 @@ package edu.cornell.mannlib.vitro.webapp.migration.auth; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_ADMIN_URI; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_CURATOR_URI; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_EDITOR_URI; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_PUBLIC_URI; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_SELF_EDITOR_URI; import static edu.cornell.mannlib.vitro.webapp.migration.auth.AuthMigrator.ALL_ROLES; -import static edu.cornell.mannlib.vitro.webapp.migration.auth.AuthMigrator.ROLE_ADMIN_URI; -import static edu.cornell.mannlib.vitro.webapp.migration.auth.AuthMigrator.ROLE_CURATOR_URI; -import static edu.cornell.mannlib.vitro.webapp.migration.auth.AuthMigrator.ROLE_EDITOR_URI; -import static edu.cornell.mannlib.vitro.webapp.migration.auth.AuthMigrator.ROLE_PUBLIC_URI; -import static edu.cornell.mannlib.vitro.webapp.migration.auth.AuthMigrator.ROLE_SELF_EDITOR_URI; import java.util.Arrays; import java.util.HashMap; From 2acbdd079f7a3e531ee898f672e8d80ab15dd868 Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Fri, 15 Dec 2023 10:50:45 +0100 Subject: [PATCH 2/4] remove mistakenly commited settings --- search_settings.n3 | 1017 -------------------------------------------- 1 file changed, 1017 deletions(-) delete mode 100644 search_settings.n3 diff --git a/search_settings.n3 b/search_settings.n3 deleted file mode 100644 index 21d6d9ae62..0000000000 --- a/search_settings.n3 +++ /dev/null @@ -1,1017 +0,0 @@ -@prefix rdf: . - - - a ; - - "Alte Inv.-Nr. abst."@de-DE , " For. inv. no. desc"@en-US ; - - ; - - "for_inv_no_desc" ; - - 60 ; - - . - - - a ; - - "Type"@en-US ; - - ; - - "type" ; - - true . - - - a ; - - "Ornament"@en-US , "Ornament"@de-DE ; - - ; - - "25"^^ ; - - "25"^^ ; - - "25"^^ ; - - "25"^^ ; - - ; - - "ornament" ; - - 4 ; - - true . - - - a ; - - " Depicted places"@en-US , "Dargestellter Ort"@de-DE ; - - ; - - "depicted_places_ss" ; - - false . - - - a ; - - "Startseite"@de-DE , "Group"@en-US ; - - ; - - true ; - - ; - - , , , , , ; - - "main_filter" ; - - true ; - - 2 ; - - true . - - - a ; - - "Stylistic classification"@en-US ; - - ; - - "stylistic_classification_ss" ; - - true . - - - a , ; - - "Datierung"@de-DE , "Dates"@en-US ; - - ; - - ; - - "1400" ; - - "dates" ; - - 9 ; - - true ; - - "1930" . - - - a ; - - "Personen/Organisationen"@de-DE , "Participant"@en-US ; - - ; - - true ; - - ; - - "participant" ; - - true ; - - 7 ; - - true . - - - a ; - - "Material"@de-DE ; - - ; - - true ; - - ; - - "material" ; - - true ; - - 2 ; - - false . - - - a ; - - "Alte Inv.-Nr."@de-DE , "Former inventory number"@en-US ; - - ; - - false ; - - ; - - "fornum" ; - - 4 ; - - true ; - - true ; - - true . - - - a ; - - "Geographische Einordnung"@de-DE , "Geographic assignment"@en-US ; - - ; - - true ; - - ; - - ; - - "geographic_assignment" ; - - true ; - - 5 ; - - true . - - - a ; - - "Depicted event"@en-US ; - - ; - - "depicted_event_ss" ; - - true . - - - a ; - - "Additional filters"@en-US , "Weitere Filter"@de-DE ; - - ; - - , , , , , , ; - - "extended" ; - - 4 ; - - true . - - - a ; - - "Depiction type"@en-US , "Art der Darstellung"@de-DE ; - - ; - - true ; - - ; - - "depiction_type" ; - - true ; - - 1 ; - - true . - - - a ; - - "Title Z-A"@en-US , "Titel Z-A"@de-DE ; - - ; - - "titleasc" ; - - false ; - - 20 ; - - . - - - a ; - - "Participant"@en-US ; - - ; - - "participants_ss" ; - - true . - - - a ; - - "Cur. inv. no. desc"@en-US , "Aktuelle Inv.-Nr. abst."@de-DE ; - - ; - - "cur_inv_no_desc" ; - - false ; - - 40 ; - - . - - - a ; - - "Sammlermarke"@de-DE , "Collector's mark"@en-US ; - - ; - - true ; - - ; - - "collectors_mark" ; - - true ; - - 5 ; - - true . - - - a ; - - "Watermark"@en-US ; - - ; - - "watermark_ss" . - - - a ; - - "Startpage"@en-US , "Startseite"@de-DE ; - - ; - - "overview_ss" ; - - true . - - - a ; - - "Geographic assignment"@en-US , "Geographische Einordnung"@de-DE ; - - ; - - "geographic_assignment_ss" ; - - true . - - - a ; - - "Default query"@en-US ; - - ; - - "querytext" . - - - a ; - - "Depicted object"@en-US ; - - ; - - "depicted_object_ss" ; - - true . - - - a ; - - "Aktuelle Inv.-Nr."@de-DE , "Current inventory number"@en-US ; - - ; - - "curnum" . - - - a ; - - "Place"@en-US ; - - ; - - "place_ss" ; - - true . - - - a ; - - "Current inventory number"@en-US , "Aktuelle Inv.-Nr."@de-DE ; - - ; - - ; - - "curnum" ; - - 3 ; - - true ; - - true ; - - true . - - - a ; - - "Label"@en-US ; - - ; - - "_label_sort" ; - - true . - - - a ; - - "Collector's mark"@en-US , "Sammlermarke"@de-DE ; - - ; - - "collectors_mark_ss" ; - - true . - - - a ; - - "Material"@de-DE ; - - ; - - "material_ss" . - - - a ; - - "Former inventory number single value (sorting)"@en-US ; - - ; - - "fornum_s" . - - - a ; - - "Thema"@de-DE , "Subject"@en-US ; - - ; - - , , , , , ; - - "subject" ; - - 3 ; - - true . - - - a ; - - "Objects"@en-US , "Werke"@de-DE ; - - ; - - , , , , , , ; - - "basic" ; - - 0 ; - - true . - - - a ; - - "Object category narrower term"@en-US , "Sachgruppe Unterbegriff"@de-DE ; - - ; - - "narrower_term_ss" ; - - true . - - - a ; - - "Depiction type"@en-US ; - - ; - - "depiction_type_ss" ; - - true . - - - a ; - - "Stilistische Einordnung"@de-DE , "Stylistic classification"@en-US ; - - ; - - true ; - - ; - - "stylistic_classification" ; - - true ; - - 7 ; - - true . - - - a ; - - "Type"@en-US ; - - ; - - true ; - - ; - - ; - - "type" ; - - true ; - - 30 ; - - false . - - - a ; - - "Dates"@en-US ; - - ; - - "dates_drsim" . - - - a ; - - "Text"@en-US ; - - ; - - ; - - "querytext" ; - - 1 ; - - true . - - - a ; - - "Intern"@de-DE , "Internal"@en-US ; - - ; - - , ; - - "internal" ; - - 5 ; - - false . - - - a ; - - "Advanced filters"@en-US ; - - ; - - "advanced" ; - - 4 ; - - false . - - - a ; - - "Title A-Z"@en-US , "Titel A-Z"@de-DE ; - - ; - - "titledesc" ; - - true ; - - 10 ; - - . - - - a ; - - " Depicted person"@en-US , "Dargestellte Person"@de-DE ; - - ; - - true ; - - ; - - "depicted_persons" ; - - true ; - - true . - - - a ; - - "Wasserzeichen"@de-DE , "Watermark"@en-US ; - - ; - - true ; - - ; - - "watermark" ; - - true ; - - 6 ; - - true . - - - a ; - - "Cultural object type"@en-US ; - - ; - - true ; - - "http://ontology.tib.eu/gesah/Cultural_Object" ; - - true . - - - a ; - - "Object type"@en-US ; - - ; - - "object_type_ss" ; - - true . - - - a ; - - "Current inventory number single value (sorting)"@en-US ; - - ; - - "curnum_s" . - - - a ; - - "Not assigned"@en-US ; - - ; - - "search:no_assignment" . - - - a ; - - "Technique"@en-US , "Technik"@de-DE ; - - ; - - "technique_ss" ; - - true . - - - a ; - - "Schlagwort"@de-DE , "Keywords"@en-US ; - - ; - - true ; - - ; - - "keywords" ; - - true ; - - 4 ; - - true ; - - false ; - - false . - - - a ; - - "Zeichnung"@de-DE , "Drawing"@en-US ; - - ; - - "25"^^ ; - - "25"^^ ; - - "25"^^ ; - - "25"^^ ; - - ; - - "drawing" ; - - 1 ; - - true . - - - a ; - - "For. inv. no. asc "@en-US , "Alte Inv.-Nr. aufst."@de-DE ; - - ; - - "for_inv_no_asc " ; - - true ; - - 50 ; - - . - - - a ; - - "Dargestelltes Ereignis"@de-DE , "Depicted event"@en-US ; - - ; - - true ; - - ; - - "depicted_event" ; - - true ; - - true . - - - a ; - - "Keywords"@en-US , "Schlagwort"@de-DE ; - - ; - - "keywords_ss" ; - - true . - - - a ; - - "Technique"@en-US , "Technik"@de-DE ; - - ; - - true ; - - ; - - "technique" ; - - true ; - - 2 ; - - true . - - - a ; - - "Alte Inv.-Nr."@de-DE , "Former inventory number"@en-US ; - - "2022-08-22T17:07:23"^^ ; - - ; - - "fornum" . - - - a ; - - "Depicted person"@en-US , "Dargestellte Person"@de-DE ; - - ; - - "depicted_persons_ss" ; - - true . - - - a ; - - "Objektyp"@de-DE , "Object type"@en-US ; - - ; - - true ; - - ; - - "object_type" ; - - true ; - - 2 ; - - true . - - - a ; - - "Cur. inv. no. asc"@en-US , "Aktuelle Inv.-Nr. aufst."@de-DE ; - - ; - - "cur_inv_no_asc" ; - - true ; - - 30 ; - - . - - - a ; - - "Sachgruppe Oberbegriff"@de-DE , "Object Category generic term"@en-US ; - - ; - - "generic_term_ss" ; - - true . - - - a ; - - "Object category (narrower term)"@en-US , "Sachgruppe (Unterbegriff)"@de-DE ; - - ; - - true ; - - ; - - "narrower_term" ; - - true ; - - 4 ; - - true . - - - a ; - - "Sachgruppe (Oberbegriff)"@de-DE , "Object Category (generic term)"@en-US ; - - ; - - true ; - - ; - - "generic_term" ; - - true ; - - 7 ; - - true . - - - a ; - - " Depicted places"@en-US , "Dargestellter Ort"@de-DE ; - - ; - - true ; - - ; - - "depicted_places" ; - - true ; - - true . - - - a ; - - "Garden"@en-US , "Garten"@de-DE ; - - ; - - "25"^^ ; - - "25"^^ ; - - "25"^^ ; - - "25"^^ ; - - ; - - "garden" ; - - 5 ; - - true . - - - a ; - - "Orte"@de-DE , "Place"@en-US ; - - ; - - true ; - - ; - - "place" ; - - true ; - - 8 ; - - true . - - - a ; - - "Print"@en-US , "Druckgraphik"@de-DE ; - - ; - - "20"^^ ; - - ; - - "print" ; - - 2 ; - - true . - - - a ; - - "Architecture"@en-US , "Architektur"@de-DE ; - - ; - - "25"^^ ; - - "20"^^ ; - - "25"^^ ; - - "25"^^ ; - - ; - - "architecture" ; - - 3 ; - - true . - - - a ; - - "Dargestelltes Objekt"@de-DE , "Depicted object"@en-US ; - - ; - - true ; - - ; - - "depicted_object" ; - - true ; - - true . - - - a ; - - "Szenographie"@de-DE , "Scenography"@en-US ; - - ; - - ; - - "scenography" ; - - 6 ; - - true . From 864114bf514c3ba11fbd7d0f4f245123461be87a Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Fri, 15 Dec 2023 10:57:34 +0100 Subject: [PATCH 3/4] Replaced search:defaultPublic data property with isDefaultForRole to apply default filters not only to public role, but to any role. --- .../webapp/search/controller/FilterValue.java | 10 ++--- .../search/controller/SearchFiltering.java | 39 ++++++++++++------- .../tbox/firsttime/searchOntologyLabels.n3 | 2 +- .../rdf/tbox/filegraph/search_ontology.n3 | 8 ++-- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/FilterValue.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/FilterValue.java index d6b43b2532..20ce51fc00 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/FilterValue.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/FilterValue.java @@ -12,7 +12,7 @@ public class FilterValue { private boolean selected = false; - private boolean defaultPublic; + private boolean isDefaultValue; private boolean publiclyAvailable = true; @@ -32,8 +32,8 @@ public FilterValue(String id) { this.id = id; } - public boolean isDefaultPublic() { - return defaultPublic; + public boolean isDefault() { + return isDefaultValue; } public String getName() { @@ -80,7 +80,7 @@ public boolean getSelected() { return selected; } - public void setDefaultPublic(boolean b) { - defaultPublic = b; + public void setDefault(boolean b) { + isDefaultValue = b; } } diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/SearchFiltering.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/SearchFiltering.java index 44d3034aca..6d4352aaa2 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/SearchFiltering.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/search/controller/SearchFiltering.java @@ -1,6 +1,9 @@ package edu.cornell.mannlib.vitro.webapp.search.controller; +import static edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary.ROLE_PUBLIC_URI; + import java.util.Arrays; +import java.util.Collections; import java.util.Comparator; import java.util.Enumeration; import java.util.HashMap; @@ -10,6 +13,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; @@ -45,11 +49,10 @@ public class SearchFiltering { private static final String FILTER_QUERY = "" + "PREFIX search: \n" - + "PREFIX gesah: \n" + "PREFIX rdf: \n" + "PREFIX rdfs: \n" + "SELECT ?filter_id ?filter_type ?filter_label ?value_label ?value_id ?field_name ?public ?filter_order " - + "?value_order (STR(?isUriReq) as ?isUri ) ?multivalued ?input ?regex ?facet ?min ?max ?public_default " + + "?value_order (STR(?isUriReq) as ?isUri ) ?multivalued ?input ?regex ?facet ?min ?max ?role " + "?value_public ?more_limit \n" + "WHERE {\n" + " ?filter rdf:type search:Filter .\n" @@ -58,7 +61,8 @@ public class SearchFiltering { + " ?filter a ?filter_type .\n" + " ?filter search:filterField ?field .\n" + " ?field search:indexField ?field_name .\n" - + " OPTIONAL {?filter search:hasKnownValue ?value . \n" + + " OPTIONAL {\n" + + " ?filter search:hasKnownValue ?value . \n" + " ?value rdfs:label ?value_label .\n" + " ?value search:id ?value_id .\n" + " OPTIONAL {" @@ -66,7 +70,7 @@ public class SearchFiltering { + " bind(?v_order as ?value_order_found).\n" + " }\n" + " OPTIONAL {\n" - + " ?value search:defaultPublic ?public_default .\n" + + " ?value search:isDefaultForRole ?role .\n" + " }\n" + " OPTIONAL {\n" + " ?value search:public ?value_public .\n" @@ -92,7 +96,6 @@ public class SearchFiltering { private static final String FILTER_GROUPS_QUERY = "" + "PREFIX rdf: \n" + "PREFIX search: \n" - + "PREFIX gesah: \n" + "PREFIX rdfs: \n" + "SELECT ?group_id (STR(?group_l) AS ?group_label) ?filter_id ?order ?filter_order ?public\n" + "WHERE {\n" @@ -119,8 +122,7 @@ public class SearchFiltering { private static final String SORT_QUERY = "" + "PREFIX rdf: \n" + "PREFIX rdfs: \n" - + "PREFIX gesah: \n" - + "Prefix search: \n" + + "PREFIX search: \n" + "SELECT ( STR(?sort_label) as ?label ) ?id ?searchField ?multilingual ?isAsc ?sort_order \n" + "WHERE {\n" + " ?sort rdf:type search:Sort . \n" @@ -176,7 +178,7 @@ public static void addFiltersToQuery(VitroRequest vreq, SearchQuery query, Map readFilterConfigurations(VitroRequest vr continue; } String valueId = solution.get("value_id").toString(); + FilterValue value; if (!filter.contains(valueId)) { - FilterValue value = new FilterValue(valueId); + value = new FilterValue(valueId); value.setName(solution.get("value_label")); value.setOrder(solution.get("value_order")); value.setPubliclyAvailable(solution.get("value_public")); filter.addValue(value); - RDFNode pubDefault = solution.get("public_default"); - if (pubDefault != null && pubDefault.asLiteral().getBoolean() && isNotLoggedIn(vreq)) { - value.setDefaultPublic(true); + } + value = filter.getValue(valueId); + RDFNode role = solution.get("role"); + if (role != null && role.isResource()) { + String roleUri = role.asResource().getURI(); + Set currentRoles = getCurrentUserRoles(vreq); + if (currentRoles.contains(roleUri)) { + value.setDefault(true); } } } @@ -489,9 +497,12 @@ private static void setSelectedFilters(Map filtersByField, } } - private static boolean isNotLoggedIn(VitroRequest vreq) { + private static Set getCurrentUserRoles(VitroRequest vreq) { UserAccount user = LoginStatusBean.getCurrentUser(vreq); - return user == null; + if (user == null) { + return Collections.singleton(ROLE_PUBLIC_URI); + } + return user.getPermissionSetUris(); } static boolean isEmptyValues(List requestedValues) { diff --git a/home/src/main/resources/rdf/i18n/en_US/tbox/firsttime/searchOntologyLabels.n3 b/home/src/main/resources/rdf/i18n/en_US/tbox/firsttime/searchOntologyLabels.n3 index 073b6e2e26..2180130760 100644 --- a/home/src/main/resources/rdf/i18n/en_US/tbox/firsttime/searchOntologyLabels.n3 +++ b/home/src/main/resources/rdf/i18n/en_US/tbox/firsttime/searchOntologyLabels.n3 @@ -27,5 +27,5 @@ search:facetResults rdfs:label "Show facet results"@en-US . search:Sort rdfs:label "Sort"@en-US . search:hasKnownValue rdfs:label "hasKnownValue"@en-US . search:public rdfs:label "public"@en-US . -search:defaultPublic rdfs:label "Is default public value"@en-US . +search:isDefaultForRole rdfs:label "Is default for role"@en-US . search:moreLimit rdfs:label "initial facet limit"@en-US . diff --git a/home/src/main/resources/rdf/tbox/filegraph/search_ontology.n3 b/home/src/main/resources/rdf/tbox/filegraph/search_ontology.n3 index 63aa650d1f..a5d8640e66 100644 --- a/home/src/main/resources/rdf/tbox/filegraph/search_ontology.n3 +++ b/home/src/main/resources/rdf/tbox/filegraph/search_ontology.n3 @@ -31,6 +31,7 @@ @prefix ro: . @prefix obo: . @prefix dc: . +@prefix auth: . a owl:Ontology ; @@ -129,11 +130,10 @@ search:public a owl:DatatypeProperty , owl:FunctionalPrope rdfs:domain search:PublicParameter ; rdfs:range xsd:boolean . -search:defaultPublic - a , ; +search:isDefaultForRole + a ; rdfs:domain ; - rdfs:range ; - rdfs:subPropertyOf . + rdfs:range auth:PermissionSet . search:moreLimit a , ; From faa54af4a0aa470fb73de01a252038c29fdbf82e Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Tue, 19 Dec 2023 12:14:26 +0100 Subject: [PATCH 4/4] use VITRO_AUTH prefix in VitroVocabulary role URIs --- .../mannlib/vitro/webapp/dao/VitroVocabulary.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java index 3221231643..f5e38bbc60 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dao/VitroVocabulary.java @@ -262,9 +262,9 @@ public enum Precision { public String uri(){return URI;} } - public static final String ROLE_PUBLIC_URI = "http://vitro.mannlib.cornell.edu/ns/vitro/authorization#PUBLIC"; - public static final String ROLE_SELF_EDITOR_URI = "http://vitro.mannlib.cornell.edu/ns/vitro/authorization#SELF_EDITOR"; - public static final String ROLE_EDITOR_URI = "http://vitro.mannlib.cornell.edu/ns/vitro/authorization#EDITOR"; - public static final String ROLE_CURATOR_URI = "http://vitro.mannlib.cornell.edu/ns/vitro/authorization#CURATOR"; - public static final String ROLE_ADMIN_URI = "http://vitro.mannlib.cornell.edu/ns/vitro/authorization#ADMIN"; + public static final String ROLE_PUBLIC_URI = VITRO_AUTH + "PUBLIC"; + public static final String ROLE_SELF_EDITOR_URI = VITRO_AUTH + "SELF_EDITOR"; + public static final String ROLE_EDITOR_URI = VITRO_AUTH + "EDITOR"; + public static final String ROLE_CURATOR_URI = VITRO_AUTH + "CURATOR"; + public static final String ROLE_ADMIN_URI = VITRO_AUTH + "ADMIN"; }