Index: web/web-portlet/src/java/org/sakaiproject/portlets/PortletIFrame.java =================================================================== --- web/web-portlet/src/java/org/sakaiproject/portlets/PortletIFrame.java (revision 128024) +++ web/web-portlet/src/java/org/sakaiproject/portlets/PortletIFrame.java (working copy) @@ -772,6 +772,24 @@ } } + // Handle the infoUrl + if (SPECIAL_WORKSITE.equals(special)) + { + if ((infoUrl != null) && (infoUrl.length() > 0) && (!infoUrl.startsWith("/")) && (infoUrl.indexOf("://") == -1)) + { + infoUrl = "http://" + infoUrl; + } + String description = StringUtils.trimToNull(request.getParameter("description")); + StringBuilder errorMessages = new StringBuilder(); + description = FormattedText.processFormattedText(description, errorMessages); + + // TODO: Alert users to errors in their markup rather than silently dropping + + // update the site info + site.setDescription(description); + site.setInfoUrl(infoUrl); + } + SiteService.save(site); } catch (Exception ignore) @@ -792,27 +810,6 @@ placement.getPlacementConfig().setProperty(XFRAME_LAST_TIME, "-1"); placement.save(); - // Handle the infoUrl - if (SPECIAL_WORKSITE.equals(special)) - { - if ((infoUrl != null) && (infoUrl.length() > 0) && (!infoUrl.startsWith("/")) && (infoUrl.indexOf("://") == -1)) - { - infoUrl = "http://" + infoUrl; - } - String description = StringUtils.trimToNull(request.getParameter("description")); - description = FormattedText.processEscapedHtml(description); - - // update the site info - try - { - SiteService.saveSiteInfo(ToolManager.getCurrentPlacement().getContext(), description, infoUrl); - } - catch (Throwable e) - { - M_log.warn("doConfigure_update: " + e); - } - } - response.setPortletMode(PortletMode.VIEW); } Index: kernel/kernel-impl/src/main/java/org/sakaiproject/site/impl/BaseSiteService.java =================================================================== --- kernel/kernel-impl/src/main/java/org/sakaiproject/site/impl/BaseSiteService.java (revision 128024) +++ kernel/kernel-impl/src/main/java/org/sakaiproject/site/impl/BaseSiteService.java (working copy) @@ -967,7 +967,34 @@ // track it eventTrackingService().post(eventTrackingService().newEvent(SECURE_UPDATE_GROUP_MEMBERSHIP, site.getReference(), true)); } + + /* + * Check if the changes between the given site and its cached version are significant + * enough to flush the user-site cache. + * + * For now, we just check if the title, infoUrl, or description changed because the title persists + * in the portal navigation and the infoUrl/description is used for the content of the site home + * page when set. As with other areas, if the main site and user-site caches were more integrated + * (keeping references for users rather than copies), we would not have to synchronize explicitly here. + */ + protected boolean shouldChangeCauseCacheFlush(Site site) + { + if (site == null) + return false; + Site cached = getCachedSite(site.getId()); + + // This block uses a fall-through pattern to simplify what would be a nasty if-statement. + // Any of the cases can flip the bit and short-circuit the rest. There is nothing special + // happening here, just stylistic preference so the block can be extended easily if cases arise. + boolean flush = false; + flush = flush || cached == null; + flush = flush || site.getTitle() != null && !site.getTitle().equals(cached.getTitle()); + flush = flush || site.getDescription() != null && !site.getDescription().equals(cached.getDescription()); + flush = flush || site.getInfoUrl() != null && !site.getInfoUrl().equals(cached.getInfoUrl()); + return flush; + } + /** * Comlete the save process. * @@ -995,11 +1022,8 @@ storage().save(site); // Check to see if an this is an interesting enough change to invalidate the user-site cache. - // For now, we just check if the title changed because that persists in the portal navigation. - // As with other areas, if the main and user-site caches were more integrated (keeping references - // for users rather than copies), we would not have to synchronize explicitly here. - Site cached = getCachedSite(site.getId()); - if (cached != null && site.getTitle() != null && !site.getTitle().equals(cached.getTitle())) { + if (shouldChangeCauseCacheFlush(site)) + { clearUserCacheForSite(site); } cacheSite(site);