diff --git a/config/configuration/bundles/src/bundle/org/sakaiproject/config/bundle/default.sakai.properties b/config/configuration/bundles/src/bundle/org/sakaiproject/config/bundle/default.sakai.properties index d7d24c3ce0e6..aee543a703b2 100644 --- a/config/configuration/bundles/src/bundle/org/sakaiproject/config/bundle/default.sakai.properties +++ b/config/configuration/bundles/src/bundle/org/sakaiproject/config/bundle/default.sakai.properties @@ -2968,6 +2968,11 @@ # DEFAULT: 500 # site.entity.pagesize.maximum=200 +# Set the site entity broker properties that can be updated by a user with site update permission. +# Only works for single value properties, not multivalued. +# DEFAULT: contact-email, contact-name +# site.entity.updateable.props=contact-email, contact-name + # Show the menu option for duplicate site # SAK-27908: disabled this option by default because it is not run in a separate thread like Import from Site # DEFAULT: false diff --git a/entitybroker/core-providers/src/java/org/sakaiproject/entitybroker/providers/SiteEntityProvider.java b/entitybroker/core-providers/src/java/org/sakaiproject/entitybroker/providers/SiteEntityProvider.java index 183b4a5f5921..6d315dc4de6f 100644 --- a/entitybroker/core-providers/src/java/org/sakaiproject/entitybroker/providers/SiteEntityProvider.java +++ b/entitybroker/core-providers/src/java/org/sakaiproject/entitybroker/providers/SiteEntityProvider.java @@ -159,6 +159,8 @@ public String getEntityPrefix() { * a property of "site.entity.pagesize.maximum". */ private int maxPageSize = 500; + + private static String[] updateableSiteProps; public void init() { int dps = serverConfigurationService.getInt( @@ -174,6 +176,12 @@ public void init() { } else { maxPageSize = defaultPageSize; } + + updateableSiteProps = serverConfigurationService.getStrings("site.entity.updateable.props"); + // Set defaults as these are the same values that can be changed through the UI. + if (updateableSiteProps == null) { + updateableSiteProps = new String [] {"contact-email", "contact-name"}; + } } // ACTIONS @@ -903,10 +911,19 @@ public void updateEntity(EntityReference ref, Object entity, Map s.setSkin(site.getSkin()); s.setTitle(site.getTitle()); - // put in properties if admin, otherwise ignore + // put in properties if admin, otherwise allow update of specific configurable fields. if (admin) { ResourcePropertiesEdit rpe = s.getPropertiesEdit(); rpe.set(site.getProperties()); + } else { + if (updateableSiteProps != null && updateableSiteProps.length != 0) { + ResourcePropertiesEdit rpe = s.getPropertiesEdit(); + for (String prop : updateableSiteProps) { + if (site.getProperties().getProperty(prop) != null) { + rpe.addProperty(prop, site.getProperties().getProperty(prop)); + } + } + } } // set the new publish status @@ -949,13 +966,25 @@ public void updateEntity(EntityReference ref, Object entity, Map if (site.getInfoUrl() != null) s.setInfoUrl(site.getInfoUrl()); - // put in properties if admin, otherwise ignore + // put in properties if admin, otherwise allow update of specific configurable fields. if (admin) { ResourcePropertiesEdit rpe = s.getPropertiesEdit(); for (String key : site.getProps().keySet()) { String value = site.getProps().get(key); rpe.addProperty(key, value); } + } else { + if (updateableSiteProps != null && updateableSiteProps.length != 0) { + ResourcePropertiesEdit rpe = s.getPropertiesEdit(); + for (String prop: updateableSiteProps) { + for (String key : site.getProps().keySet()) { + if (prop.equals(key)) { + String value = site.getProps().get(key); + rpe.addProperty(key, value); + } + } + } + } } // attempt to set the owner as requested