NIHVIVO-2886, NIHVIVO-2940 Refactoring for clarity of admin link generation

This commit is contained in:
ryounes 2011-07-15 21:50:50 +00:00
parent 64f930f053
commit 7c51af4a38

View file

@ -55,33 +55,24 @@ public class SiteAdminController extends FreemarkerHttpServlet {
@Override @Override
protected ResponseValues processRequest(VitroRequest vreq) { protected ResponseValues processRequest(VitroRequest vreq) {
Map<String, Object> body = new HashMap<String, Object>(); Map<String, Object> body = new HashMap<String, Object>();
if (PolicyHelper.isAuthorizedForActions(vreq, new EditIndividuals())) {
body.put("dataInput", getDataInputData(vreq)); body.put("dataInput", getDataInputData(vreq));
}
body.put("siteConfig", getSiteConfigUrls(vreq)); body.put("siteConfig", getSiteConfigUrls(vreq));
if (PolicyHelper.isAuthorizedForActions(vreq, new UseMiscellaneousAdminPages())) {
body.put("indexCacheRebuild", getIndexCacheRebuildUrls(vreq)); body.put("indexCacheRebuild", getIndexCacheRebuildUrls(vreq));
}
if (PolicyHelper.isAuthorizedForActions(vreq, new EditOntology())) {
body.put("ontologyEditor", getOntologyEditorData(vreq)); body.put("ontologyEditor", getOntologyEditorData(vreq));
}
if (PolicyHelper.isAuthorizedForActions(vreq, new UseAdvancedDataToolsPages())) {
body.put("dataTools", getDataToolsUrls(vreq)); body.put("dataTools", getDataToolsUrls(vreq));
}
return new TemplateResponseValues(TEMPLATE_DEFAULT, body); return new TemplateResponseValues(TEMPLATE_DEFAULT, body);
} }
private Map<String, String> getIndexCacheRebuildUrls(VitroRequest vreq) { private Map<String, String> getIndexCacheRebuildUrls(VitroRequest vreq) {
Map<String, String> urls = new HashMap<String, String>(); Map<String, String> urls = new HashMap<String, String>();
if (PolicyHelper.isAuthorizedForActions(vreq, new UseMiscellaneousAdminPages())) {
urls.put("recomputeInferences", UrlBuilder.getUrl("/RecomputeInferences")); urls.put("recomputeInferences", UrlBuilder.getUrl("/RecomputeInferences"));
urls.put("rebuildClassGroupCache", UrlBuilder.getUrl("/browse?clearcache=1")); urls.put("rebuildClassGroupCache", UrlBuilder.getUrl("/browse?clearcache=1"));
@ -90,17 +81,19 @@ public class SiteAdminController extends FreemarkerHttpServlet {
urls.put("rebuildSearchIndex", UrlBuilder.getUrl("/SearchIndex")); urls.put("rebuildSearchIndex", UrlBuilder.getUrl("/SearchIndex"));
} }
if (PolicyHelper.isAuthorizedForActions(vreq, new RefreshVisualizationCacheAction())) { if (PolicyHelper.isAuthorizedForActions(vreq, new RefreshVisualizationCacheAction())) {
urls.put("rebuildVisCache", UrlBuilder.getUrl("/vis/tools")); urls.put("rebuildVisCache", UrlBuilder.getUrl("/vis/tools"));
} }
}
return urls; return urls;
} }
private Map<String, Object> getDataInputData(VitroRequest vreq) { private Map<String, Object> getDataInputData(VitroRequest vreq) {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
if (PolicyHelper.isAuthorizedForActions(vreq, new EditIndividuals())) {
map.put("formAction", UrlBuilder.getUrl("/edit/editRequestDispatch.jsp")); map.put("formAction", UrlBuilder.getUrl("/edit/editRequestDispatch.jsp"));
WebappDaoFactory wadf = vreq.getFullWebappDaoFactory(); WebappDaoFactory wadf = vreq.getFullWebappDaoFactory();
@ -108,7 +101,6 @@ public class SiteAdminController extends FreemarkerHttpServlet {
// Create map for data input entry form options list // 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 List classGroups = wadf.getVClassGroupDao().getPublicGroupsWithVClasses(true,true,false); // order by displayRank, include uninstantiated classes, don't get the counts of individuals
Set<String> seenGroupNames = new HashSet<String>(); Set<String> seenGroupNames = new HashSet<String>();
Iterator classGroupIt = classGroups.iterator(); Iterator classGroupIt = classGroups.iterator();
@ -129,6 +121,7 @@ public class SiteAdminController extends FreemarkerHttpServlet {
} }
map.put("groupedClassOptions", orderedClassGroups); map.put("groupedClassOptions", orderedClassGroups);
}
return map; return map;
} }
@ -161,6 +154,8 @@ public class SiteAdminController extends FreemarkerHttpServlet {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
if (PolicyHelper.isAuthorizedForActions(vreq, new EditOntology())) {
String pelletError = null; String pelletError = null;
String pelletExplanation = null; String pelletExplanation = null;
Object plObj = getServletContext().getAttribute("pelletListener"); Object plObj = getServletContext().getAttribute("pelletListener");
@ -192,6 +187,7 @@ public class SiteAdminController extends FreemarkerHttpServlet {
urls.put("propertyGroups", UrlBuilder.getUrl("/listPropertyGroups")); urls.put("propertyGroups", UrlBuilder.getUrl("/listPropertyGroups"));
urls.put("objectPropertyHierarchy", UrlBuilder.getUrl("/showObjectPropertyHierarchy", new ParamMap("iffRoot", "true"))); urls.put("objectPropertyHierarchy", UrlBuilder.getUrl("/showObjectPropertyHierarchy", new ParamMap("iffRoot", "true")));
map.put("urls", urls); map.put("urls", urls);
}
return map; return map;
} }
@ -199,11 +195,14 @@ public class SiteAdminController extends FreemarkerHttpServlet {
private Map<String, String> getDataToolsUrls(VitroRequest vreq) { private Map<String, String> getDataToolsUrls(VitroRequest vreq) {
Map<String, String> urls = new HashMap<String, String>(); Map<String, String> urls = new HashMap<String, String>();
if (PolicyHelper.isAuthorizedForActions(vreq, new UseAdvancedDataToolsPages())) {
urls.put("ingest", UrlBuilder.getUrl("/ingest")); urls.put("ingest", UrlBuilder.getUrl("/ingest"));
urls.put("rdfData", UrlBuilder.getUrl("/uploadRDFForm")); urls.put("rdfData", UrlBuilder.getUrl("/uploadRDFForm"));
urls.put("rdfExport", UrlBuilder.getUrl("/export")); urls.put("rdfExport", UrlBuilder.getUrl("/export"));
urls.put("sparqlQuery", UrlBuilder.getUrl("/admin/sparqlquery")); urls.put("sparqlQuery", UrlBuilder.getUrl("/admin/sparqlquery"));
urls.put("sparqlQueryBuilder", UrlBuilder.getUrl("/admin/sparqlquerybuilder")); urls.put("sparqlQueryBuilder", UrlBuilder.getUrl("/admin/sparqlquerybuilder"));
}
return urls; return urls;
} }