001/* 002 * (C) Copyright 2006-2012 Nuxeo SA (http://nuxeo.com/) and others. 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 * <a href="mailto:tdelprat@nuxeo.com">Tiry</a> 016 */ 017 018package org.nuxeo.ecm.quota.size; 019 020import java.io.IOException; 021import org.nuxeo.ecm.core.api.DocumentModel; 022 023/** 024 * Interface to manage DocumentModel that supports Quotas 025 * 026 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a> 027 * @since 5.6 028 */ 029public interface QuotaAware { 030 031 public static final String QUOTA_TOTALSIZE_CACHE_NAME = "quota-totalsize-cache"; 032 033 long getInnerSize(); 034 035 long getTotalSize(); 036 037 long getTrashSize(); 038 039 long getVersionsSize(); 040 041 long getMaxQuota(); 042 043 void setInnerSize(long size, boolean save); 044 045 void addInnerSize(long additionalSize, boolean save); 046 047 void addTotalSize(long additionalSize, boolean save); 048 049 void addTrashSize(long additionalSize, boolean save); 050 051 void addVersionsSize(long additionalSize, boolean save); 052 053 void save(); 054 055 /** 056 * @since 5.7 allows to save the document without notifying DublincoreListener and the notification service 057 */ 058 void save(boolean disableNotifications); 059 060 DocumentModel getDoc(); 061 062 void setMaxQuota(long maxSize, boolean save); 063 064 void setMaxQuota(long maxSize, boolean save, boolean skipValidation); 065 066 QuotaInfo getQuotaInfo(); 067 068 void resetInfos(boolean save); 069 070 /** 071 * Invalidates "total size" key-value in cache if exists. 072 * 073 * @throws IOException when unable to invalidate key-value 074 * @since 6.0-HF16, 7.4 075 */ 076 void invalidateTotalSizeCache() throws IOException; 077 078 /** 079 * Returns value of "total size" cache of document OR <code>null</code> if cache does not exist or key does not exist in cache. 080 * 081 * @return <code>Long</code> object or <code>null</code> 082 * @since 6.0-HF16, 7.4 083 */ 084 Long getTotalSizeCache() throws IOException; 085 086 /** 087 * Stores "total size" value in cache if it exists. 088 * 089 * @param size 090 * @throws IOException if unable to store value 091 * @since 6.0-HF16, 7.4 092 */ 093 void putTotalSizeCache(long size) throws IOException; 094 095 /** 096 * @return <code>true</code> if "total size" cache exists otherwise <code>false</code>. 097 * 098 * @since 6.0-HF16, 7.4 099 */ 100 boolean totalSizeCacheExists(); 101}