Cleanup of webapp context root. Removing many unused jsp files and some unused controllers. NIHVIVO-1000
This commit is contained in:
parent
ef3988022f
commit
f4409580b4
23 changed files with 10 additions and 980 deletions
|
@ -31,8 +31,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
|||
public class ContactMailServlet extends VitroHttpServlet {
|
||||
private static final Log log = LogFactory.getLog(ContactMailServlet.class);
|
||||
|
||||
private final static String CONFIRM_PAGE = "/thankyou.jsp";
|
||||
private final static String ERR_PAGE = "/contact_err.jsp";
|
||||
private final static String CONFIRM_PAGE = "/templates/parts/thankyou.jsp";
|
||||
private final static String ERR_PAGE = "/templates/parts/contact_err.jsp";
|
||||
private final static String SPAM_MESSAGE = "Your message was flagged as spam.";
|
||||
private final static String EMAIL_BACKUP_FILE_PATH = "/WEB-INF/LatestMessage.html";
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ public class Controllers {
|
|||
|
||||
// jsps go here:
|
||||
|
||||
public static final String EMPTY = "/empty.jsp";
|
||||
public static final String TAB = "/index.jsp";
|
||||
|
||||
public static final String LOGIN_JSP = "/login_process.jsp";
|
||||
|
@ -80,17 +79,17 @@ public class Controllers {
|
|||
|
||||
public static final String BROWSE_GROUP_JSP = "/templates/browse/browseGroup.jsp";
|
||||
|
||||
public static final String HORIZONTAL_JSP = "/horizontal.jsp";
|
||||
public static final String HORIZONTAL_JSP = "/templates/edit/fetch/horizontal.jsp";
|
||||
public static final String VERTICAL_JSP = "/templates/edit/fetch/vertical.jsp";
|
||||
|
||||
public static final String CHECK_DATATYPE_PROPERTIES = "/checkDatatypeProperties.jsp";
|
||||
public static final String CHECK_DATATYPE_PROPERTIES = "/jsp/checkDatatypeProperties.jsp";
|
||||
public static final String EXPORT_SELECTION_JSP = "/jenaIngest/exportSelection.jsp";
|
||||
|
||||
public static final String VCLASS_RETRY_URL = "vclass_retry";
|
||||
|
||||
public static final String TOGGLE_SCRIPT_ELEMENT = "<script language='JavaScript' type='text/javascript' src='js/toggle.js'></script>";
|
||||
|
||||
public static final Object SEARCH_ERROR_JSP = "/search_error.jsp";
|
||||
public static final Object SEARCH_ERROR_JSP = "/templates/parts/search_error.jsp";
|
||||
|
||||
|
||||
//public static final String TAB_ENTITIES_LIST_JSP = "templates/tab/tabEntities.jsp";
|
||||
|
|
|
@ -1,178 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Tab;
|
||||
|
||||
public class SitemapIndexController extends VitroHttpServlet {
|
||||
private static final Log log = LogFactory.getLog(SitemapIndexController.class.getName());
|
||||
|
||||
private static ArrayList<ArrayList<String>> urlIndex = null;
|
||||
|
||||
public void doGet( HttpServletRequest req, HttpServletResponse res )
|
||||
throws IOException, ServletException {
|
||||
try {
|
||||
super.doGet(req, res);
|
||||
VitroRequest vreq = new VitroRequest(req);
|
||||
String entityListString = vreq.getParameter("entityListNum");
|
||||
Integer entityListNum = null;
|
||||
if(entityListString != null) entityListNum = Integer.parseInt(entityListString);
|
||||
if(entityListNum != null)
|
||||
{
|
||||
generateEntitySitemap(req, res, entityListNum);
|
||||
return;
|
||||
}
|
||||
String tabsPortalString = vreq.getParameter("tabsPortalNum");
|
||||
Integer tabsPortalNum = null;
|
||||
if(tabsPortalString != null) tabsPortalNum = Integer.parseInt(tabsPortalString);
|
||||
if(tabsPortalNum != null)
|
||||
{
|
||||
generateTabsSitemap(req, res, tabsPortalNum);
|
||||
return;
|
||||
}
|
||||
|
||||
setUrlIndex(vreq);
|
||||
|
||||
vreq.setAttribute("individuals", urlIndex.size());
|
||||
vreq.setAttribute("context", req.getServerName()+":"+req.getServerPort()+req.getContextPath());
|
||||
Portal portal = vreq.getPortal();
|
||||
RequestDispatcher rd = vreq.getRequestDispatcher("/siteMapIndex.jsp");
|
||||
rd.forward(req,res);
|
||||
|
||||
} catch (Throwable e) {
|
||||
log.error(e);
|
||||
req.setAttribute("javax.servlet.jsp.jspException",e);
|
||||
RequestDispatcher rd = req.getRequestDispatcher("/error.jsp");
|
||||
rd.forward(req, res);
|
||||
}
|
||||
}
|
||||
|
||||
private void generateEntitySitemap(HttpServletRequest req, HttpServletResponse res, int listNum)
|
||||
{
|
||||
VitroRequest vreq = new VitroRequest(req);
|
||||
if(urlIndex == null) setUrlIndex(vreq);
|
||||
RequestDispatcher rd = vreq.getRequestDispatcher("/siteMap.jsp");
|
||||
vreq.setAttribute("list", urlIndex.get(listNum));
|
||||
try {
|
||||
rd.forward(req,res);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
private void generateTabsSitemap(HttpServletRequest req, HttpServletResponse res, int portalNum)
|
||||
{
|
||||
VitroRequest vreq = new VitroRequest(req);
|
||||
List<Tab> tabs = (List<Tab>)vreq.getWebappDaoFactory().getTabDao().getTabsForPortal(portalNum);
|
||||
ArrayList<String> tabsList = new ArrayList<String>();
|
||||
for(int i=0; i<tabs.size(); i++)
|
||||
{
|
||||
addDecendentTabs(tabsList, tabs.get(i), portalNum, "http://"+vreq.getServerName()+":"+vreq.getServerPort()+vreq.getContextPath());
|
||||
}
|
||||
RequestDispatcher rd = vreq.getRequestDispatcher("/siteMap.jsp");
|
||||
vreq.setAttribute("list", tabsList);
|
||||
try {
|
||||
rd.forward(req,res);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void addDecendentTabs(ArrayList<String> tabsList, Tab tab, int portalNum, String contextPath)
|
||||
{
|
||||
if(tab == null) return;
|
||||
String tabURI = contextPath+escapeEntity("/index.jsp?home="+portalNum+"&"+tab.getTabDepthName()+"="+tab.getTabId());
|
||||
tabsList.add(tabURI);
|
||||
//tabsList.add(tabURI);
|
||||
|
||||
Collection<Tab> childTabs = tab.getChildTabs();
|
||||
if(childTabs != null)
|
||||
for(Tab t:childTabs) addDecendentTabs(tabsList, t, portalNum, contextPath);
|
||||
}
|
||||
|
||||
private void setUrlIndex(VitroRequest vreq)
|
||||
{
|
||||
Iterator<Individual> individualIter = vreq.getWebappDaoFactory().getIndividualDao().getAllOfThisTypeIterator();
|
||||
ArrayList<ArrayList<String>> arrays = new ArrayList<ArrayList<String>>();
|
||||
for(int i=0; individualIter.hasNext(); i++)
|
||||
{
|
||||
ArrayList<String> individuals = new ArrayList<String>();
|
||||
for(int j=0; j<50000 && individualIter.hasNext(); j++)
|
||||
{
|
||||
String individualUri = SitemapIndexController.forURL(individualIter.next().getURI());
|
||||
|
||||
individualUri = "http://"+vreq.getServerName()+":"+vreq.getServerPort()+vreq.getContextPath()+"/entity?home=1&uri="+individualUri;
|
||||
//individualUri = "http://vivo.cornell.edu/entity?home=1&uri="+individualUri;
|
||||
|
||||
individuals.add(escapeEntity(individualUri));
|
||||
|
||||
}
|
||||
arrays.add(individuals);
|
||||
}
|
||||
urlIndex = arrays;
|
||||
}
|
||||
|
||||
private static String forURL(String frag)
|
||||
{
|
||||
String result = null;
|
||||
try
|
||||
{
|
||||
result = URLEncoder.encode(frag, "UTF-8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
throw new RuntimeException("UTF-8 not supported", ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String escapeEntity(String frag)
|
||||
{
|
||||
if(frag.contains("&")) frag = replaceAll(frag, "&", "&");
|
||||
if(frag.contains("'")) frag = replaceAll(frag, "'", "'");
|
||||
if(frag.contains("\"")) frag = replaceAll(frag, "\"", """);
|
||||
if(frag.contains(">")) frag = replaceAll(frag, ">", ">");
|
||||
if(frag.contains("<")) frag = replaceAll(frag, "<", "<");
|
||||
return frag;
|
||||
}
|
||||
|
||||
private String replaceAll(String original, String match, String replace)
|
||||
{
|
||||
int index1 = original.indexOf(match);
|
||||
int index2 = original.indexOf(replace);
|
||||
if(index1 == index2 && index1 != -1)
|
||||
{
|
||||
original = original.substring(0, index1+replace.length()+1)+replaceAll(original.substring(index1+replace.length()+1), match, replace);
|
||||
return original;
|
||||
}
|
||||
if(index1 == -1) return original;
|
||||
String before = original.substring(0, index1) + replace;
|
||||
return before + replaceAll(original.substring(index1+1), match, replace);
|
||||
}
|
||||
|
||||
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException,IOException {
|
||||
doGet(request, response);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
||||
|
||||
/**
|
||||
* Controller for Terms of Use page
|
||||
* @author bjl23
|
||||
*/
|
||||
public class TermsOfUseController extends VitroHttpServlet{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
doGet(request, response);
|
||||
}
|
||||
|
||||
public void doGet( HttpServletRequest request, HttpServletResponse response )
|
||||
throws IOException, ServletException {
|
||||
try {
|
||||
super.doGet(request,response);
|
||||
VitroRequest vreq = new VitroRequest(request);
|
||||
|
||||
ApplicationBean appBean=vreq.getAppBean();
|
||||
Portal portalBean=vreq.getPortal();
|
||||
|
||||
request.setAttribute("rootBreadCrumbAnchorOrAppName", portalBean.getRootBreadCrumbAnchor()==null || portalBean.getRootBreadCrumbAnchor().equals("")?portalBean.getAppName():portalBean.getRootBreadCrumbAnchor());
|
||||
request.setAttribute("copyrightAnchor", portalBean.getCopyrightAnchor());
|
||||
//request.setAttribute("rootLogotypeTitle", appBean.getRootLogotypeTitle()); THIS IS NOT POPULATED
|
||||
request.setAttribute("appName", portalBean.getAppName());
|
||||
|
||||
request.setAttribute("title", portalBean.getAppName()+" Terms of Use");
|
||||
request.setAttribute("bodyJsp", "/usageTerms.jsp");// <<< this is where the body gets set
|
||||
request.setAttribute("portalBean",portalBean);
|
||||
|
||||
RequestDispatcher rd =
|
||||
request.getRequestDispatcher(Controllers.BASIC_JSP);
|
||||
rd.forward(request, response);
|
||||
|
||||
} catch (Throwable e) {
|
||||
// This is how we use an error.jsp
|
||||
//it expects javax.servlet.jsp.jspException to be set to the
|
||||
//exception so that it can display the info out of that.
|
||||
request.setAttribute("javax.servlet.jsp.jspException", e);
|
||||
RequestDispatcher rd = request.getRequestDispatcher("/error.jsp");
|
||||
rd.include(request, response);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -68,7 +68,7 @@ public class UserMailController extends VitroHttpServlet{
|
|||
request.setAttribute("portalId",Integer.valueOf(portalBean.getPortalId()));
|
||||
|
||||
request.setAttribute("title", portalBean.getAppName()+" Mail Users Form");
|
||||
request.setAttribute("bodyJsp", "/emailUsers.jsp");// <<< this is where the body gets set
|
||||
request.setAttribute("bodyJsp", "/templates/parts/emailUsers.jsp");// <<< this is where the body gets set
|
||||
request.setAttribute("portalBean",portalBean);
|
||||
|
||||
RequestDispatcher rd =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue