From: <hs...@us...> - 2011-12-02 20:12:21
|
Revision: 993 http://treebase.svn.sourceforge.net/treebase/?rev=993&view=rev Author: hshyket Date: 2011-12-02 20:12:15 +0000 (Fri, 02 Dec 2011) Log Message: ----------- Checking to make sure that studies that have been cached but then removed from being published do not redirect from the PURL link to the cached object. Cached object may still remain in the Apache frontend cache and possibly be served to a user directly hitting the URL. Modified Paths: -------------- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSMatrixController.java trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSStudyController.java trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSTreeController.java trunk/treebase-web/src/main/webapp/WEB-INF/web.xml trunk/treebase-web/src/main/webapp/common/meta.jsp Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java 2011-11-30 20:48:02 UTC (rev 992) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSController.java 2011-12-02 20:12:15 UTC (rev 993) @@ -10,10 +10,14 @@ import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.Controller; +import org.cipres.treebase.web.exceptions.NoStudySpecifiedError; + import org.cipres.treebase.NamespacedGUID; import org.cipres.treebase.TreebaseIDString; import org.cipres.treebase.TreebaseUtil; import org.cipres.treebase.TreebaseIDString.MalformedTreebaseIDString; +import org.cipres.treebase.domain.study.Study; +import org.cipres.treebase.domain.study.StudyService; import org.cipres.treebase.web.Constants; /** @@ -58,6 +62,8 @@ public abstract class PhyloWSController implements Controller { private static final long serialVersionUID = 1L; private static String searchBase = "/treebase-web/search/"; + + private boolean redirectDownload = true; /** * Child classes return the display page for the focal type @@ -108,7 +114,10 @@ // output format is something else, re-direct to download services else { - url = createDownloadUrl(tbID.getId(),serializationFormat,req); + url = createDownloadUrl(tbID.getId(),serializationFormat,req); + if (!redirectDownload) { + url = "/treebase-web/accessviolation.html"; + } } } @@ -122,6 +131,7 @@ res.sendError(HttpServletResponse.SC_NOT_FOUND, "Object not found: " + e.getMessage()); } } + if ( ! TreebaseUtil.isEmpty(url) ) { res.setContentType("text/plain"); @@ -274,5 +284,9 @@ super(message); } } + + public void checkAccess(boolean isPublished) { + redirectDownload = isPublished; + } } Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSMatrixController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSMatrixController.java 2011-11-30 20:48:02 UTC (rev 992) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSMatrixController.java 2011-12-02 20:12:15 UTC (rev 993) @@ -40,9 +40,13 @@ throw new ObjectNotFoundException("Can't find matrix " + objectId); } Study study = matrix.getStudy(); + if ( study == null ) { throw new ObjectNotFoundException("Can't find study for matrix "+objectId); } + + checkAccess(study.isPublished()); + Map<String,String> params = new HashMap<String,String>(); params.put("id", ""+study.getId()); params.put("matrixid", ""+objectId); Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSStudyController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSStudyController.java 2011-11-30 20:48:02 UTC (rev 992) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSStudyController.java 2011-12-02 20:12:15 UTC (rev 993) @@ -35,9 +35,13 @@ @Override Map<String,String> getObjectQueryParameters(Long objectId) throws ObjectNotFoundException { Study study = getStudyService().findByID(objectId); + if ( study == null ) { throw new ObjectNotFoundException("Can't find study " + objectId); - } + } + + checkAccess(study.isPublished()); + Map<String,String> params = new HashMap<String,String>(); params.put("id", ""+objectId); return params; Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSTreeController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSTreeController.java 2011-11-30 20:48:02 UTC (rev 992) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/PhyloWSTreeController.java 2011-12-02 20:12:15 UTC (rev 993) @@ -40,9 +40,13 @@ throw new ObjectNotFoundException("Can't find tree " + objectId); } Study study = phyloTree.getStudy(); + if ( study == null ) { throw new ObjectNotFoundException("Can't find study for tree "+objectId); } + + checkAccess(study.isPublished()); + Map<String,String> params = new HashMap<String,String>(); params.put("id",""+study.getId()); params.put("treeid", ""+objectId); Modified: trunk/treebase-web/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/web.xml 2011-11-30 20:48:02 UTC (rev 992) +++ trunk/treebase-web/src/main/webapp/WEB-INF/web.xml 2011-12-02 20:12:15 UTC (rev 993) @@ -82,19 +82,11 @@ <url-pattern>/search/study/anyObjectAsRDF.rdf</url-pattern> </filter-mapping> - <filter-mapping> <filter-name>CacheFilter</filter-name> - <url-pattern>/search/study/summary.html</url-pattern> - </filter-mapping> - - - <filter-mapping> - <filter-name>CacheFilter</filter-name> <url-pattern>/search/downloadANexusFile.html</url-pattern> </filter-mapping> - <filter-mapping> <filter-name>CacheFilter</filter-name> <url-pattern>/search/downloadAMatrix.html</url-pattern> @@ -105,11 +97,6 @@ <url-pattern>/search/downloadATree.html</url-pattern> </filter-mapping> - <filter-mapping> - <filter-name>CacheFilter</filter-name> - <url-pattern>/search/downloadATree.html</url-pattern> - </filter-mapping> - <!-- =================================================================== --> Modified: trunk/treebase-web/src/main/webapp/common/meta.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/common/meta.jsp 2011-11-30 20:48:02 UTC (rev 992) +++ trunk/treebase-web/src/main/webapp/common/meta.jsp 2011-12-02 20:12:15 UTC (rev 993) @@ -1,19 +1,10 @@ -<%@page import="java.util.Date" %> -<%@page import="java.util.Calendar" %> -<%@page import="java.text.SimpleDateFormat;" %> <!-- HTTP 1.1 --> <meta http-equiv="Cache-Control" content="no-store"/> <!-- HTTP 1.0 --> <meta http-equiv="Pragma" content="no-cache"/> <!-- Prevents caching at the Proxy Server --> -<% Calendar expires = Calendar.getInstance(); - expires.add(Calendar.DATE,7); - SimpleDateFormat expiresFormat = new SimpleDateFormat("E, dd MMM yyyy kk:mm:ss"); - if (request.getRequestURI().equals("/treebase-web/search/study/summary.html")) { -%><meta http-equiv="Expires" content="<%=expiresFormat.format(expires.getTime())%> GMT"/> -<%}else { -%><meta http-equiv="Expires" content="0"/> -<% } %><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> +<meta http-equiv="Expires" content="0"/> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <meta name="author" content="Rutger A. Vos (rut...@gm...)"/> <meta name="google-site-verification" content="9Lr7BwyD6VMDIk5dENnSt_2YsUdpq_aEhnee0mMTxrw" /> <meta name="y_key" content="8c736195266b5ebb" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |