Search in sources :

Example 1 with DataSourceUsage

use of com.zimbra.soap.mail.message.DataSourceUsage in project zm-mailbox by Zimbra.

the class GetDataSourceUsage method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Account account = getRequestedAccount(zsc);
    GetDataSourceUsageResponse resp = new GetDataSourceUsageResponse();
    resp.setDataSourceQuota(account.getDataSourceQuota());
    resp.setDataSourceTotalQuota(account.getDataSourceTotalQuota());
    for (DataSource ds : account.getAllDataSources()) {
        DataSourceUsage dsu = new DataSourceUsage();
        dsu.setId(ds.getId());
        dsu.setUsage(ds.getUsage());
        resp.addDataSourceUsage(dsu);
    }
    return zsc.jaxbToElement(resp);
}
Also used : GetDataSourceUsageResponse(com.zimbra.soap.mail.message.GetDataSourceUsageResponse) Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) DataSourceUsage(com.zimbra.soap.mail.message.DataSourceUsage) DataSource(com.zimbra.cs.account.DataSource)

Example 2 with DataSourceUsage

use of com.zimbra.soap.mail.message.DataSourceUsage in project zm-mailbox by Zimbra.

the class TestPurgeDataSource method checkDataSourceUsage.

private void checkDataSourceUsage() throws ServiceException {
    GetDataSourceUsageResponse usage = mbox.invokeJaxb(new GetDataSourceUsageRequest());
    long quota = usage.getDataSourceQuota();
    for (DataSourceUsage usg : usage.getUsages()) {
        assertTrue(usg.getId() + " is over quota", usg.getUsage() <= quota);
    }
}
Also used : GetDataSourceUsageResponse(com.zimbra.soap.mail.message.GetDataSourceUsageResponse) DataSourceUsage(com.zimbra.soap.mail.message.DataSourceUsage) GetDataSourceUsageRequest(com.zimbra.soap.mail.message.GetDataSourceUsageRequest)

Aggregations

DataSourceUsage (com.zimbra.soap.mail.message.DataSourceUsage)2 GetDataSourceUsageResponse (com.zimbra.soap.mail.message.GetDataSourceUsageResponse)2 Account (com.zimbra.cs.account.Account)1 DataSource (com.zimbra.cs.account.DataSource)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 GetDataSourceUsageRequest (com.zimbra.soap.mail.message.GetDataSourceUsageRequest)1