1 /** 2 * This file Copyright (c) 2003-2010 Magnolia International 3 * Ltd. (http://www.magnolia-cms.com). All rights reserved. 4 * 5 * 6 * This file is dual-licensed under both the Magnolia 7 * Network Agreement and the GNU General Public License. 8 * You may elect to use one or the other of these licenses. 9 * 10 * This file is distributed in the hope that it will be 11 * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the 12 * implied warranty of MERCHANTABILITY or FITNESS FOR A 13 * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT. 14 * Redistribution, except as permitted by whichever of the GPL 15 * or MNA you select, is prohibited. 16 * 17 * 1. For the GPL license (GPL), you can redistribute and/or 18 * modify this file under the terms of the GNU General 19 * Public License, Version 3, as published by the Free Software 20 * Foundation. You should have received a copy of the GNU 21 * General Public License, Version 3 along with this program; 22 * if not, write to the Free Software Foundation, Inc., 51 23 * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 24 * 25 * 2. For the Magnolia Network Agreement (MNA), this file 26 * and the accompanying materials are made available under the 27 * terms of the MNA which accompanies this distribution, and 28 * is available at http://www.magnolia-cms.com/mna.html 29 * 30 * Any modifications to this file must keep this entire header 31 * intact. 32 * 33 */ 34 package info.magnolia.context; 35 36 import info.magnolia.cms.core.search.QueryManager; 37 import info.magnolia.cms.i18n.Messages; 38 import info.magnolia.cms.security.AccessManager; 39 import info.magnolia.cms.security.User; 40 import info.magnolia.cms.core.HierarchyManager; 41 42 import java.util.Locale; 43 import java.util.Map; 44 45 46 /** 47 * This interface defines all the methods which should be implemented by any configured magnolia context. Implementing 48 * class should never be accessible directly but only via MgnlContext static methods which work on a local (Thread) copy 49 * of the implementation. 50 * @author Sameer Charles 51 * @version $Revision $ ($Author $) 52 */ 53 public interface Context extends org.apache.commons.chain.Context { 54 55 /** 56 * Attribute visibility scope. 57 */ 58 public static final int LOCAL_SCOPE = 1; 59 60 /** 61 * Attribute visibility scope Shared by all requests from this session. 62 */ 63 public static final int SESSION_SCOPE = 2; 64 65 /** 66 * Attribute visibility scope, its visible to all sessions of this application. 67 */ 68 public static final int APPLICATION_SCOPE = 3; 69 70 final static public String ATTRIBUTE_REPOSITORY = "repository"; 71 72 final static public String ATTRIBUTE_PATH = "path"; 73 74 final static public String ATTRIBUTE_VERSION = "version"; 75 76 final static public String ATTRIBUTE_VERSION_MAP = "versionMap"; 77 78 final static public String ATTRIBUTE_UUID = "uuid"; 79 80 final static public String ATTRIBUTE_RECURSIVE = "recursive"; 81 82 public static final String ATTRIBUTE_COMMENT = "comment"; 83 84 public static final String ATTRIBUTE_MESSAGE = "msg"; 85 86 public static final String ATTRIBUTE_EXCEPTION = "exception"; 87 88 /** 89 * If this is not a UserContext this method will very likely return the system user. 90 */ 91 public User getUser(); 92 93 /** 94 * @param locale 95 */ 96 public void setLocale(Locale locale); 97 98 /** 99 * Get the current locale. 100 */ 101 public Locale getLocale(); 102 103 /** 104 * Get hierarchy manager initialized for this user. 105 * @param repositoryId 106 * @return hierarchy manager 107 */ 108 public HierarchyManager getHierarchyManager(String repositoryId); 109 110 /** 111 * Get hierarchy manager initialized for this user. 112 * @param repositoryId 113 * @param workspaceId 114 * @return hierarchy manager 115 */ 116 public HierarchyManager getHierarchyManager(String repositoryId, String workspaceId); 117 118 /** 119 * Get access manager for the specified repository on default workspace. 120 * @param repositoryId 121 * @return access manager 122 */ 123 public AccessManager getAccessManager(String repositoryId); 124 125 /** 126 * Get access manager for the specified repository on the specified workspace. 127 * @param repositoryId 128 * @param workspaceId 129 * @return access manager 130 */ 131 public AccessManager getAccessManager(String repositoryId, String workspaceId); 132 133 /** 134 * Get QueryManager created for this user on the specified repository. 135 * @param repositoryId 136 * @return query manager 137 */ 138 public QueryManager getQueryManager(String repositoryId); 139 140 /** 141 * Get QueryManager created for this user on the specified repository and workspace. 142 * @param repositoryId 143 * @param workspaceId 144 * @return query manager 145 */ 146 public QueryManager getQueryManager(String repositoryId, String workspaceId); 147 148 /** 149 * Set attribute value, scope of the attribute is defined. 150 * @param name is used as a key 151 * @param value 152 * @param scope , highest level of scope from which this attribute is visible 153 */ 154 public void setAttribute(String name, Object value, int scope); 155 156 /** 157 * Get attribute value. 158 * @param name to which value is associated to 159 * @param scope the scope (request, session, application) 160 * @return attribute value 161 */ 162 public Object getAttribute(String name, int scope); 163 164 /** 165 * Get attribute value without passing a scope. the scopes are searched from bottom up (request, session, 166 * application) 167 * @param name to which value is associated to 168 * @return attribute value 169 */ 170 public Object getAttribute(String name); 171 172 /** 173 * Get a map of a attributes set in the scope. 174 * @param scope 175 * @return the map 176 */ 177 public Map<String, Object> getAttributes(int scope); 178 179 /** 180 * Remove an attribute. 181 * @param name 182 * @param scope 183 */ 184 public void removeAttribute(String name, int scope); 185 186 /** 187 * Get an over all map. 188 * @return the map 189 */ 190 public Map<String, Object> getAttributes(); 191 192 /** 193 * Get the default messages. It uses the locale set on this context 194 * TODO: This duplicates methods from MessagesManager : remove either 195 */ 196 public Messages getMessages(); 197 198 /** 199 * Get the messages of the named bundle. It uses the locale set on this context 200 * @param basename name of the bundle 201 * TODO: This duplicates methods from MessagesManager : remove either 202 */ 203 public Messages getMessages(String basename); 204 205 /** 206 * Release any resource used by this Context (e.g. jcr sessions). 207 */ 208 public void release(); 209 210 }