001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.ui.apps; 029 030import java.io.Serializable; 031import java.util.HashMap; 032import java.util.Map; 033 034import javax.servlet.http.HttpSession; 035 036/** 037 * Stores the last opened locations for file explorer, page editor and sitemap editor.<p> 038 */ 039public class CmsQuickLaunchLocationCache implements Serializable { 040 041 /** The serial version id. */ 042 private static final long serialVersionUID = -6144984854691623070L; 043 044 /** The page editor locations. */ 045 private Map<String, String> m_pageEditorLocations; 046 047 /** The sitemap editor locations. */ 048 private Map<String, String> m_sitemapEditorLocations; 049 050 /** The file explorer locations. */ 051 private Map<String, String> m_fileExplorerLocations; 052 053 /** 054 * Constructor.<p> 055 */ 056 public CmsQuickLaunchLocationCache() { 057 m_pageEditorLocations = new HashMap<String, String>(); 058 m_sitemapEditorLocations = new HashMap<String, String>(); 059 m_fileExplorerLocations = new HashMap<String, String>(); 060 } 061 062 /** 063 * Returns the location cache from the user session.<p> 064 * 065 * @param session the session 066 * 067 * @return the location cache 068 */ 069 public static CmsQuickLaunchLocationCache getLocationCache(HttpSession session) { 070 071 CmsQuickLaunchLocationCache cache = (CmsQuickLaunchLocationCache)session.getAttribute( 072 CmsQuickLaunchLocationCache.class.getName()); 073 if (cache == null) { 074 cache = new CmsQuickLaunchLocationCache(); 075 session.setAttribute(CmsQuickLaunchLocationCache.class.getName(), cache); 076 } 077 return cache; 078 } 079 080 /** 081 * Returns the file explorer location for the given site root.<p> 082 * 083 * @param siteRoot the site root 084 * 085 * @return the location 086 */ 087 public String getFileExplorerLocation(String siteRoot) { 088 089 return m_fileExplorerLocations.get(siteRoot); 090 } 091 092 /** 093 * Returns the page editor location for the given site root.<p> 094 * 095 * @param siteRoot the site root 096 * 097 * @return the location 098 */ 099 public String getPageEditorLocation(String siteRoot) { 100 101 return m_pageEditorLocations.get(siteRoot); 102 } 103 104 /** 105 * Returns the sitemap editor location for the given site root.<p> 106 * 107 * @param siteRoot the site root 108 * 109 * @return the location 110 */ 111 public String getSitemapEditorLocation(String siteRoot) { 112 113 return m_sitemapEditorLocations.get(siteRoot); 114 } 115 116 /** 117 * Sets the latest file explorer location for the given site.<p> 118 * 119 * @param siteRoot the site root 120 * @param location the location 121 */ 122 public void setFileExplorerLocation(String siteRoot, String location) { 123 124 m_fileExplorerLocations.put(siteRoot, location); 125 } 126 127 /** 128 * Sets the latest page editor location for the given site.<p> 129 * 130 * @param siteRoot the site root 131 * @param location the location 132 */ 133 public void setPageEditorLocation(String siteRoot, String location) { 134 135 m_pageEditorLocations.put(siteRoot, location); 136 } 137 138 /** 139 * Sets the latest sitemap editor location for the given site.<p> 140 * 141 * @param siteRoot the site root 142 * @param location the location 143 */ 144 public void setSitemapEditorLocation(String siteRoot, String location) { 145 146 m_sitemapEditorLocations.put(siteRoot, location); 147 } 148}