/** * Merges this context info with the values from the other context info.<p> * * @param other the context info to merge with */ public void merge(CmsFlexRequestContextInfo other) { updateDateLastModified(other.getDateLastModified()); updateDateExpires(other.getDateExpires()); }
/** * Updates both the "last modified" and the "expires" date * for this context with the given values.<p> * * @param dateLastModified the value to update the "last modified" date with * @param dateExpires the value to update the "expires" date with */ public void updateDates(long dateLastModified, long dateExpires) { updateDateLastModified(dateLastModified); updateDateExpires(dateExpires); }
/** * Updates the current users context dates with each {@link CmsResource} object in the given list.<p> * * The given input list is returned unmodified.<p> * * Please see {@link #updateContextDates(CmsDbContext, CmsResource)} for an explanation of what this method does.<p> * * @param dbc the current database context * @param resourceList a list of {@link CmsResource} objects * * @return the original list of CmsResources with the full resource name set */ private List updateContextDates(CmsDbContext dbc, List resourceList) { CmsFlexRequestContextInfo info = dbc.getFlexRequestContextInfo(); if (info != null) { for (int i = 0; i < resourceList.size(); i++) { CmsResource resource = (CmsResource)resourceList.get(i); info.updateFromResource(resource); } } return resourceList; }
/** * Returns the combined "last modified" date for all resources read during this request.<p> * * @return the combined "last modified" date for all resources read during this request */ public long getDateLastModified() { int pos = m_flexContextInfoList.size() - 1; if (pos < 0) { // ensure a valid position is used return CmsResource.DATE_RELEASED_DEFAULT; } return (m_flexContextInfoList.get(pos)).getDateLastModified(); }
/** * Adds another flex request/response pair to the stack.<p> * * @param req the request to add * @param res the response to add */ public void push(CmsFlexRequest req, CmsFlexResponse res) { m_flexRequestList.add(req); m_flexResponseList.add(res); m_flexContextInfoList.add(new CmsFlexRequestContextInfo()); updateRequestContextInfo(); }
/** * Returns the combined "expires" date for all resources read during this request.<p> * * @return the combined "expires" date for all resources read during this request */ public long getDateExpires() { int pos = m_flexContextInfoList.size() - 1; if (pos < 0) { // ensure a valid position is used return CmsResource.DATE_EXPIRED_DEFAULT; } return ((CmsFlexRequestContextInfo)m_flexContextInfoList.get(pos)).getDateExpires(); }
/** * Updates the "expires" date for this context with the given value.<p> * * @param dateExpires the value to update the "expires" date with */ public void updateDateExpires(long dateExpires) { if (dateExpires > System.currentTimeMillis()) { if (dateExpires < m_dateExpires) { m_dateExpires = dateExpires; } } else { updateDateLastModified(dateExpires); } }
/** * Removes the topmost request/response pair from the stack.<p> */ public void pop() { if ((m_flexRequestList != null) && !m_flexRequestList.isEmpty()) { m_flexRequestList.remove(m_flexRequestList.size() - 1); } if ((m_flexResponseList != null) && !m_flexRequestList.isEmpty()) { m_flexResponseList.remove(m_flexResponseList.size() - 1); } if ((m_flexContextInfoList != null) && !m_flexContextInfoList.isEmpty()) { CmsFlexRequestContextInfo info = (CmsFlexRequestContextInfo)m_flexContextInfoList.remove(m_flexContextInfoList.size() - 1); if (m_flexContextInfoList.size() > 0) { ((CmsFlexRequestContextInfo)m_flexContextInfoList.get(0)).merge(info); updateRequestContextInfo(); } } }
/** * Updates the "last modified" date and the "expires" date * for all resources read during this request with the given values.<p> * * The currently stored value for "last modified" is only updated with the new value if * the new value is either larger (i.e. newer) then the stored value, * or if the new value is less then zero, which indicates that the "last modified" * optimization can not be used because the element is dynamic.<p> * * The stored "expires" value is only updated if the new value is smaller * then the stored value.<p> * * @param dateLastModified the value to update the "last modified" date with * @param dateExpires the value to update the "expires" date with */ public void updateDates(long dateLastModified, long dateExpires) { int pos = m_flexContextInfoList.size() - 1; if (pos < 0) { // ensure a valid position is used return; } (m_flexContextInfoList.get(pos)).updateDates(dateLastModified, dateExpires); }
/** * Updates both the "last modified" and the "expires" date * for this context with the given values.<p> * * @param dateLastModified the value to update the "last modified" date with * @param dateExpires the value to update the "expires" date with */ public void updateDates(long dateLastModified, long dateExpires) { updateDateLastModified(dateLastModified); updateDateExpires(dateExpires); }
/** * Updates the current users context dates with the given resource.<p> * * This checks the date information of the resource based on * {@link CmsResource#getDateLastModified()} as well as * {@link CmsResource#getDateReleased()} and {@link CmsResource#getDateExpired()}. * The current users request context is updated with the the "latest" dates found.<p> * * This is required in order to ensure proper setting of <code>"last-modified"</code> http headers * and also for expiration of cached elements in the Flex cache. * Consider the following use case: Page A is generated from resources x, y and z. * If either x, y or z has an expiration / release date set, then page A must expire at a certain point * in time. This is ensured by the context date check here.<p> * * @param dbc the current database context * @param resource the resource to get the date information from */ private void updateContextDates(CmsDbContext dbc, CmsResource resource) { CmsFlexRequestContextInfo info = dbc.getFlexRequestContextInfo(); if (info != null) { info.updateFromResource(resource); } }
/** * Returns the combined "last modified" date for all resources read during this request.<p> * * @return the combined "last modified" date for all resources read during this request */ public long getDateLastModified() { int pos = m_flexContextInfoList.size() - 1; if (pos < 0) { // ensure a valid position is used return CmsResource.DATE_RELEASED_DEFAULT; } return ((CmsFlexRequestContextInfo)m_flexContextInfoList.get(pos)).getDateLastModified(); }
/** * Adds another flex request/response pair to the stack.<p> * * @param req the request to add * @param res the response to add */ public void push(CmsFlexRequest req, CmsFlexResponse res) { m_flexRequestList.add(req); m_flexResponseList.add(res); m_flexContextInfoList.add(new CmsFlexRequestContextInfo()); updateRequestContextInfo(); }
/** * Returns the combined "expires" date for all resources read during this request.<p> * * @return the combined "expires" date for all resources read during this request */ public long getDateExpires() { int pos = m_flexContextInfoList.size() - 1; if (pos < 0) { // ensure a valid position is used return CmsResource.DATE_EXPIRED_DEFAULT; } return (m_flexContextInfoList.get(pos)).getDateExpires(); }
/** * Updates the "expires" date for this context with the given value.<p> * * @param dateExpires the value to update the "expires" date with */ public void updateDateExpires(long dateExpires) { if (dateExpires > System.currentTimeMillis()) { if (dateExpires < m_dateExpires) { m_dateExpires = dateExpires; } } else { updateDateLastModified(dateExpires); } }
/** * Removes the topmost request/response pair from the stack.<p> */ public void pop() { if ((m_flexRequestList != null) && !m_flexRequestList.isEmpty()) { m_flexRequestList.remove(m_flexRequestList.size() - 1); } if ((m_flexResponseList != null) && !m_flexRequestList.isEmpty()) { m_flexResponseList.remove(m_flexResponseList.size() - 1); } if ((m_flexContextInfoList != null) && !m_flexContextInfoList.isEmpty()) { CmsFlexRequestContextInfo info = m_flexContextInfoList.remove(m_flexContextInfoList.size() - 1); if (m_flexContextInfoList.size() > 0) { (m_flexContextInfoList.get(0)).merge(info); updateRequestContextInfo(); } } }
/** * Updates the "last modified" date and the "expires" date * for all resources read during this request with the given values.<p> * * The currently stored value for "last modified" is only updated with the new value if * the new value is either larger (i.e. newer) then the stored value, * or if the new value is less then zero, which indicates that the "last modified" * optimization can not be used because the element is dynamic.<p> * * The stored "expires" value is only updated if the new value is smaller * then the stored value.<p> * * @param dateLastModified the value to update the "last modified" date with * @param dateExpires the value to update the "expires" date with */ public void updateDates(long dateLastModified, long dateExpires) { int pos = m_flexContextInfoList.size() - 1; if (pos < 0) { // ensure a valid position is used return; } ((CmsFlexRequestContextInfo)m_flexContextInfoList.get(pos)).updateDates(dateLastModified, dateExpires); }
/** * Merges this context info with the values from the other context info.<p> * * @param other the context info to merge with */ public void merge(CmsFlexRequestContextInfo other) { updateDateLastModified(other.getDateLastModified()); updateDateExpires(other.getDateExpires()); }
/** * Updates the "last modified" date for this context as well as the * "expires" date with the values from a given resource.<p> * * The "expires" date is the calculated from the given date values * of resource release and expiration and also the current time.<p> * * @param resource the resource to use for updating the context values */ public void updateFromResource(CmsResource resource) { // first set the last modification date updateDateLastModified(resource.getDateLastModified()); // now use both release and expiration date from the resource to update the expires info updateDateExpires(resource.getDateReleased()); updateDateExpires(resource.getDateExpired()); } }
/** * Updates the current users context dates with each {@link CmsResource} object in the given list.<p> * * The given input list is returned unmodified.<p> * * Please see {@link #updateContextDates(CmsDbContext, CmsResource)} for an explanation of what this method does.<p> * * @param dbc the current database context * @param resourceList a list of {@link CmsResource} objects * * @return the original list of CmsResources with the full resource name set */ private List<CmsResource> updateContextDates(CmsDbContext dbc, List<CmsResource> resourceList) { CmsFlexRequestContextInfo info = dbc.getFlexRequestContextInfo(); if (info != null) { for (int i = 0; i < resourceList.size(); i++) { CmsResource resource = resourceList.get(i); info.updateFromResource(resource); } } return resourceList; }