001/* 002 * (C) Copyright 2006-2012 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Thomas Roger <troger@nuxeo.com> 018 */ 019 020package org.nuxeo.ecm.quota; 021 022import java.util.List; 023 024import org.nuxeo.ecm.core.api.CoreSession; 025import org.nuxeo.ecm.core.api.DocumentModel; 026import org.nuxeo.ecm.core.event.Event; 027import org.nuxeo.ecm.core.event.impl.DocumentEventContext; 028 029/** 030 * Service used to compute quota and statistics on documents. 031 * 032 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a> 033 * @since 5.5 034 */ 035public interface QuotaStatsService { 036 037 List<QuotaStatsUpdater> getQuotaStatsUpdaters(); 038 039 /** 040 * Update the statistics for the given {@code docCtx} and {@code event}. 041 * <p> 042 * Call all the registered {@link org.nuxeo.ecm.quota.QuotaStatsUpdater}s. 043 */ 044 void updateStatistics(DocumentEventContext docCtx, Event event); 045 046 /** 047 * Compute the initial statistics for the given @{code updaterName}. 048 */ 049 void computeInitialStatistics(String updaterName, CoreSession session, QuotaStatsInitialWork currentWorker); 050 051 /** 052 * Launch an asynchronously initial computation for the given {@code updaterName} on {@code repositoryName}. 053 */ 054 void launchInitialStatisticsComputation(String updaterName, String repositoryName); 055 056 /** 057 * Returns the progress status of {@code updaterName}. 058 */ 059 String getProgressStatus(String updaterName, String repositoryName); 060 061 /** 062 * Gets the quota from the first parent where quota has been set. Returns -1 if no quota has been set. For user 063 * workspaces, only the first parent is investigated 064 * 065 * @since 5.7 066 */ 067 public long getQuotaFromParent(DocumentModel doc, CoreSession session); 068 069 /** 070 * Test to see if quota allowed. Skip user worskpaces, where validation rules don't apply. 071 * 072 * @since 5.7 073 */ 074 public boolean canSetMaxQuota(long maxQuota, DocumentModel doc, CoreSession session); 075 076 /** 077 * Sets this maxQuota on all user workspaces 078 * 079 * @since 5.7 080 */ 081 public void launchSetMaxQuotaOnUserWorkspaces(long maxQuota, DocumentModel context, CoreSession session); 082 083 /** 084 * Activates the quota on user personal workspaces 085 * 086 * @since 5.7 087 */ 088 public void activateQuotaOnUserWorkspaces(long maxQuota, CoreSession session); 089 090 /** 091 * @since 5.7 092 */ 093 public long getQuotaSetOnUserWorkspaces(CoreSession session); 094 095}