From 64f930f053f024e1b98b89f40cc75e4048865d38 Mon Sep 17 00:00:00 2001 From: ryounes Date: Fri, 15 Jul 2011 21:38:59 +0000 Subject: [PATCH] NIHVIVO-2886, NIHVIVO-2940 Fix display of links based on policy checks --- .../freemarker/SiteAdminController.java | 60 +++++++------------ .../siteAdmin/siteAdmin-advancedDataTools.ftl | 12 ++-- .../siteAdmin/siteAdmin-indexCacheRebuild.ftl | 21 ++++--- .../siteAdmin/siteAdmin-ontologyEditor.ftl | 6 +- .../siteAdmin/siteAdmin-siteConfiguration.ftl | 27 ++++----- .../forms/institutionalInternalClassForm.ftl | 2 +- 6 files changed, 54 insertions(+), 74 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SiteAdminController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SiteAdminController.java index 728fd298b..64934223e 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SiteAdminController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/SiteAdminController.java @@ -61,51 +61,41 @@ public class SiteAdminController extends FreemarkerHttpServlet { body.put("dataInput", getDataInputData(vreq)); } - body.put("siteConfig", getSiteConfigurationData(vreq)); + body.put("siteConfig", getSiteConfigUrls(vreq)); - body.put("indexCacheRebuild", getIndexCacheRebuildData(vreq)); + if (PolicyHelper.isAuthorizedForActions(vreq, new UseMiscellaneousAdminPages())) { + body.put("indexCacheRebuild", getIndexCacheRebuildUrls(vreq)); + } - // rjy7 There is a risk that the login levels required to show the links will get out - // of step with the levels required by the pages themselves. We should implement a - // mechanism similar to what's used on the front end to display links to Site Admin - // and Revision Info iff the user has access to those pages. if (PolicyHelper.isAuthorizedForActions(vreq, new EditOntology())) { body.put("ontologyEditor", getOntologyEditorData(vreq)); } + if (PolicyHelper.isAuthorizedForActions(vreq, new UseAdvancedDataToolsPages())) { - body.put("dataTools", getDataToolsData(vreq)); - - // Only for DataStar. Should handle without needing a DataStar-specific version of this controller. - //body.put("customReports", getCustomReportsData(vreq)); + body.put("dataTools", getDataToolsUrls(vreq)); } return new TemplateResponseValues(TEMPLATE_DEFAULT, body); } - private Object getIndexCacheRebuildData(VitroRequest vreq) { - - Map map = new HashMap(); + private Map getIndexCacheRebuildUrls(VitroRequest vreq) { Map urls = new HashMap(); + + urls.put("recomputeInferences", UrlBuilder.getUrl("/RecomputeInferences")); + + urls.put("rebuildClassGroupCache", UrlBuilder.getUrl("/browse?clearcache=1")); if (PolicyHelper.isAuthorizedForActions(vreq, IndexController.REQUIRED_ACTIONS)) { urls.put("rebuildSearchIndex", UrlBuilder.getUrl("/SearchIndex")); } - if (PolicyHelper.isAuthorizedForActions(vreq, new UseMiscellaneousAdminPages())) { - urls.put("recomputeInferences", UrlBuilder.getUrl("/RecomputeInferences")); - } - - if (PolicyHelper.isAuthorizedForActions(vreq, new UseMiscellaneousAdminPages())) { - urls.put("rebuildClassGroupCache", UrlBuilder.getUrl("/browse?clearcache=1")); - } - + if (PolicyHelper.isAuthorizedForActions(vreq, new RefreshVisualizationCacheAction())) { urls.put("rebuildVisCache", UrlBuilder.getUrl("/vis/tools")); } - - map.put("urls", urls); - return map; + + return urls; } private Map getDataInputData(VitroRequest vreq) { @@ -117,8 +107,7 @@ public class SiteAdminController extends FreemarkerHttpServlet { // Create map for data input entry form options list List classGroups = wadf.getVClassGroupDao().getPublicGroupsWithVClasses(true,true,false); // order by displayRank, include uninstantiated classes, don't get the counts of individuals - - //boolean classGroupDisplayAssumptionsMet = checkClassGroupDisplayAssumptions(classGroups); + Set seenGroupNames = new HashSet(); @@ -143,17 +132,16 @@ public class SiteAdminController extends FreemarkerHttpServlet { return map; } - private Map getSiteConfigurationData(VitroRequest vreq) { + private Map getSiteConfigUrls(VitroRequest vreq) { - Map map = new HashMap(); Map urls = new HashMap(); if (PolicyHelper.isAuthorizedForActions(vreq, new ManageUserAccounts())) { - urls.put("userList", UrlBuilder.getUrl("/accountsAdmin")); + urls.put("userAccounts", UrlBuilder.getUrl("/accountsAdmin")); } if (PolicyHelper.isAuthorizedForActions(vreq, new EditSiteInformation())) { - urls.put("siteInfo", UrlBuilder.getUrl("/editForm", new ParamMap("controller", "ApplicationBean"))); + urls.put("siteInfo", UrlBuilder.getUrl("/editForm", "controller", "ApplicationBean")); } if (PolicyHelper.isAuthorizedForActions(vreq, new ManageMenus())) { @@ -166,9 +154,7 @@ public class SiteAdminController extends FreemarkerHttpServlet { urls.put("internalClass", UrlBuilder.getUrl("/processInstitutionalInternalClass")); } - map.put("urls", urls); - - return map; + return urls; } private Map getOntologyEditorData(VitroRequest vreq) { @@ -210,10 +196,8 @@ public class SiteAdminController extends FreemarkerHttpServlet { return map; } - private Map getDataToolsData(VitroRequest vreq) { + private Map getDataToolsUrls(VitroRequest vreq) { - Map map = new HashMap(); - Map urls = new HashMap(); urls.put("ingest", UrlBuilder.getUrl("/ingest")); urls.put("rdfData", UrlBuilder.getUrl("/uploadRDFForm")); @@ -221,9 +205,7 @@ public class SiteAdminController extends FreemarkerHttpServlet { urls.put("sparqlQuery", UrlBuilder.getUrl("/admin/sparqlquery")); urls.put("sparqlQueryBuilder", UrlBuilder.getUrl("/admin/sparqlquerybuilder")); - map.put("urls", urls); - - return map; + return urls; } } diff --git a/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-advancedDataTools.ftl b/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-advancedDataTools.ftl index cf0a437ff..9edd62a13 100644 --- a/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-advancedDataTools.ftl +++ b/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-advancedDataTools.ftl @@ -2,17 +2,17 @@ <#-- Template for Site Administration advanced data tools panel --> -<#if dataTools??> +<#if dataTools?has_content>

Advanced Data Tools

diff --git a/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-indexCacheRebuild.ftl b/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-indexCacheRebuild.ftl index b92a4a6d6..2b6dd98f0 100644 --- a/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-indexCacheRebuild.ftl +++ b/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-indexCacheRebuild.ftl @@ -2,28 +2,27 @@ <#-- Template for the main Site Administration page --> -<#-- <#if indexRebuildCache?has_content> --> +<#if indexCacheRebuild?has_content>

Refresh Content

-<#-- --> \ No newline at end of file + \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-ontologyEditor.ftl b/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-ontologyEditor.ftl index 48b17f053..466e2bd9d 100644 --- a/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-ontologyEditor.ftl +++ b/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-ontologyEditor.ftl @@ -2,15 +2,15 @@ <#-- Template for Site Administration Ontology Editor --> -<#if ontologyEditor??> +<#if ontologyEditor?has_content>

Ontology Editor

- <#if ontologyEditor.pellet??> + <#if ontologyEditor.pellet?has_content>

${ontologyEditor.pellet.error}

- <#if ontologyEditor.pellet.explanation??> + <#if ontologyEditor.pellet.explanation?has_content>

Cause: ${ontologyEditor.pellet.explanation}

diff --git a/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-siteConfiguration.ftl b/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-siteConfiguration.ftl index 1b0d51885..1856f1886 100644 --- a/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-siteConfiguration.ftl +++ b/webapp/web/templates/freemarker/body/siteAdmin/siteAdmin-siteConfiguration.ftl @@ -8,23 +8,22 @@

Site Configuration

diff --git a/webapp/web/templates/freemarker/edit/forms/institutionalInternalClassForm.ftl b/webapp/web/templates/freemarker/edit/forms/institutionalInternalClassForm.ftl index 50aae2354..d1b3ba685 100644 --- a/webapp/web/templates/freemarker/edit/forms/institutionalInternalClassForm.ftl +++ b/webapp/web/templates/freemarker/edit/forms/institutionalInternalClassForm.ftl @@ -21,7 +21,7 @@ edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.Institu <#--If no local ontologies, display message for user to create a local ontology--> <#if ontologiesExist = false>
-

There are currently no local ontologies. You must create a new local ontology

+

There are currently no local ontologies. You must create a new local ontology.

<#--else if local ontologies exist and local classes exist, show drop-down of local classes-->