001/* 002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Anahide Tchertchian 016 */ 017package org.nuxeo.ecm.platform.actions; 018 019import java.util.HashMap; 020import java.util.Map; 021 022import javax.el.ELException; 023 024import org.nuxeo.ecm.core.api.CoreSession; 025import org.nuxeo.ecm.core.api.DocumentModel; 026import org.nuxeo.ecm.core.api.NuxeoPrincipal; 027 028/** 029 * @since 5.7.3 030 */ 031public abstract class AbstractActionContext implements ActionContext { 032 033 private static final long serialVersionUID = 1L; 034 035 protected DocumentModel currentDocument; 036 037 protected CoreSession docMgr; 038 039 protected NuxeoPrincipal currentPrincipal; 040 041 protected Map<String, Object> localVariables = new HashMap<String, Object>(); 042 043 public abstract boolean checkCondition(String expression) throws ELException; 044 045 public final void setCurrentDocument(DocumentModel doc) { 046 currentDocument = doc; 047 } 048 049 public final DocumentModel getCurrentDocument() { 050 return currentDocument; 051 } 052 053 public final CoreSession getDocumentManager() { 054 return docMgr; 055 } 056 057 public final void setDocumentManager(CoreSession docMgr) { 058 this.docMgr = docMgr; 059 } 060 061 public final NuxeoPrincipal getCurrentPrincipal() { 062 return currentPrincipal; 063 } 064 065 public final void setCurrentPrincipal(NuxeoPrincipal currentPrincipal) { 066 this.currentPrincipal = currentPrincipal; 067 } 068 069 @Override 070 public Object getLocalVariable(String key) { 071 return localVariables.get(key); 072 } 073 074 @Override 075 public Object putLocalVariable(String key, Object value) { 076 return localVariables.put(key, value); 077 } 078 079 @Override 080 public void putAllLocalVariables(Map<String, Object> vars) { 081 localVariables.putAll(vars); 082 } 083 084 public int size() { 085 return localVariables.size(); 086 } 087 088 @Override 089 public boolean disableGlobalCaching() { 090 return false; 091 } 092 093}