From: <bra...@us...> - 2010-09-28 21:06:58
|
Revision: 3253 http://archive-access.svn.sourceforge.net/archive-access/?rev=3253&view=rev Author: bradtofel Date: 2010-09-28 21:06:39 +0000 (Tue, 28 Sep 2010) Log Message: ----------- Dates now in GMT, HTTP header changed from "Content-datetime" to "Memento-datetime", also changed Link header format and contents.. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-webapp/src/main/webapp/WEB-INF/replay/MementoValidity.jsp Modified: trunk/archive-access/projects/wayback/wayback-webapp/src/main/webapp/WEB-INF/replay/MementoValidity.jsp =================================================================== --- trunk/archive-access/projects/wayback/wayback-webapp/src/main/webapp/WEB-INF/replay/MementoValidity.jsp 2010-09-28 21:02:16 UTC (rev 3252) +++ trunk/archive-access/projects/wayback/wayback-webapp/src/main/webapp/WEB-INF/replay/MementoValidity.jsp 2010-09-28 21:06:39 UTC (rev 3253) @@ -5,6 +5,7 @@ <%@ page import="org.archive.wayback.core.WaybackRequest" %> <%@ page import="org.archive.wayback.archivalurl.ArchivalUrlResultURIConverter" %> <%@ page import="java.text.SimpleDateFormat" %> +<%@ page import="java.util.TimeZone" %> <%@ page import="java.util.Iterator" %> <% UIResults results = UIResults.extractCaptureQuery(request); @@ -14,6 +15,13 @@ String u = wbRequest.getRequestUrl(); SimpleDateFormat httpformatterl = new SimpleDateFormat( "E, dd MMM yyyy HH:mm:ss z"); + TimeZone tzo = TimeZone.getTimeZone("GMT"); + httpformatterl.setTimeZone(tzo); + SimpleDateFormat formatterk = new SimpleDateFormat("yyyyMMddHHmmss"); + formatterk.setTimeZone(tzo); + + + Date closestDate = res.getCaptureDate(); String agguri = results.getContextConfig("aggregationPrefix") + "timebundle/" + u; String timemap = " , <" @@ -27,23 +35,51 @@ Date f = cResults.getFirstResultDate(); Date l = cResults.getLastResultDate(); - String qvalue = "1.0"; //just example + StringBuffer sb = new StringBuffer(); - response.setHeader("Content-Datetime", httpformatterl.format(res + + response.setHeader("Memento-Datetime", httpformatterl.format(res .getCaptureDate())); - SimpleDateFormat formatterk = new SimpleDateFormat("yyyyMMddHHmmss"); - sb.append(", <" + uriPrefix + formatterk.format(f) + "/" + u - + ">;rel=\"first-memento\"; datetime=\"" - + httpformatterl.format(f) + "\""); - if (!f.equals(l)) { - - sb.append(", <" + uriPrefix + formatterk.format(f) + "/" + u - + ">;rel=\"last-memento\"; datetime=\"" - + httpformatterl.format(f) + "\""); - } - - // calculate closest values for alternates - Date closestDate = res.getCaptureDate(); + + String memento = ",<" + uriPrefix + formatterk.format(closestDate) + "/" + u + + ">;rel=\"memento\";datetime=\"" + + httpformatterl.format(closestDate) + "\""; + String mfl = null; + if ( (closestDate.equals(f)) && closestDate.equals(l)) { + mfl = ", <" + uriPrefix + formatterk.format(f) + "/" + u + + ">;rel=\"first-memento memento last-memento\"; datetime=\"" + + httpformatterl.format(f) + "\""; + } + else if (closestDate.equals(f)){ + mfl=", <" + uriPrefix + formatterk.format(f) + "/" + u + + ">;rel=\"first-memento memento\"; datetime=\"" + + httpformatterl.format(f) + "\"" ; + mfl = mfl+", <" + uriPrefix + formatterk.format(l) + "/" + u + + ">;rel=\"last-memento\"; datetime=\"" + + httpformatterl.format(l) + "\""; + + } + else if (closestDate.equals(l)) { + mfl=", <" + uriPrefix + formatterk.format(l) + "/" + u + + ">;rel=\"last-memento memento\"; datetime=\"" + + httpformatterl.format(l) + "\""; + mfl = mfl +", <" + uriPrefix + formatterk.format(f) + "/" + u + + ">;rel=\"first-memento\"; datetime=\"" + + httpformatterl.format(f) + "\""; + } + else { + mfl = memento ; + + mfl = mfl+", <" + uriPrefix + formatterk.format(l) + "/" + u + + ">;rel=\"last-memento\"; datetime=\"" + + httpformatterl.format(l) + "\""; + mfl =mfl +", <" + uriPrefix + formatterk.format(f) + "/" + u + + ">;rel=\"first-memento\"; datetime=\"" + + httpformatterl.format(f) + "\""; + } + + sb = new StringBuffer(mfl); + CaptureSearchResult closestleft = null; CaptureSearchResult closestright = null; long rclosestDistance = 0; @@ -53,13 +89,13 @@ long maxWindow = -1; long wantTime = closestDate.getTime(); - + Iterator<CaptureSearchResult> itr = cResults.iterator(); while (itr.hasNext()) { cur = itr.next(); cur.getCaptureDate(); - long curDistance = wantTime - cur.getCaptureDate().getTime(); - // == 0 propuskaem + long curDistance = cur.getCaptureDate().getTime()-wantTime; + // == 0 skip if (curDistance > 0) { if ((closestright == null) || (Math.abs(curDistance) < Math @@ -81,18 +117,29 @@ } if (closestleft != null) { - if (!closestleft.getCaptureDate().equals(f)) { - sb.append(", <" + uriPrefix + formatterk.format(f) + "/" + if (!(closestleft.getCaptureDate().equals(f))) { + + sb.append(", <" + uriPrefix + formatterk.format(closestleft.getCaptureDate()) + "/" + u + ">;rel=\"prev-memento\"; datetime=\"" - + httpformatterl.format(f) + "\""); + + httpformatterl.format(closestleft.getCaptureDate()) + "\""); } + else { + int m_index = sb.lastIndexOf("\"first-memento\""); + sb.insert(m_index + 1, "prev-memento "); + + } } if (closestright != null) { - if (!closestright.getCaptureDate().equals(l)) { - sb.append(", <" + uriPrefix + formatterk.format(f) + "/" + if (!(closestright.getCaptureDate().equals(l))) { + sb.append(", <" + uriPrefix + formatterk.format(closestright.getCaptureDate()) + "/" + u + ">;rel=\"next-memento\"; datetime=\"" - + httpformatterl.format(f) + "\""); + + httpformatterl.format(closestright.getCaptureDate()) + "\""); } + else { + int m_index = sb.lastIndexOf("\"last-memento\""); + sb.insert(m_index + 1, "next-memento "); + + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |