當前位置: 首頁>>代碼示例>>Java>>正文


Java ContentQuotaException類代碼示例

本文整理匯總了Java中org.alfresco.service.cmr.usage.ContentQuotaException的典型用法代碼示例。如果您正苦於以下問題:Java ContentQuotaException類的具體用法?Java ContentQuotaException怎麽用?Java ContentQuotaException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ContentQuotaException類屬於org.alfresco.service.cmr.usage包,在下文中一共展示了ContentQuotaException類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: incrementUserUsage

import org.alfresco.service.cmr.usage.ContentQuotaException; //導入依賴的package包/類
private void incrementUserUsage(String userName, long contentSize, NodeRef contentNodeRef)
{
    if (!authenticationContext.isSystemUserName(userName) && !excludedTypes.contains(nodeService.getType(contentNodeRef)))
    {
        // increment usage - add positive delta
        if (logger.isDebugEnabled()) logger.debug("incrementUserUsage: username="+userName+", contentSize="+contentSize+", contentNodeRef="+contentNodeRef);
        
        long currentSize = getUserUsage(userName);
        long quotaSize = getUserQuota(userName);
        
        long newSize = currentSize + contentSize;
        
        // check whether user's quota exceeded
        if ((quotaSize != -1) && (newSize > quotaSize))
        {
            if (logger.isWarnEnabled())
            {
                logger.warn("User (" + userName + ") quota exceeded: content=" + contentSize +
                              ", usage=" + currentSize +
                              ", quota=" + quotaSize);
            }
            throw new ContentQuotaException("User quota exceeded");
        }
        
        NodeRef personNodeRef = getPerson(userName);
        if (personNodeRef != null)
        {
            usageService.insertDelta(personNodeRef, contentSize);
        }
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:32,代碼來源:ContentUsageImpl.java

示例2: contentStreamClosedImpl

import org.alfresco.service.cmr.usage.ContentQuotaException; //導入依賴的package包/類
public void contentStreamClosedImpl() throws ContentIOException
{
    try
    {
        // set the full content property
        ContentData contentData = writer.getContentData();
        nodeService.setProperty(nodeRef, propertyQName, contentData);
        // done
        if (logger.isDebugEnabled())
        {
            logger.debug("Stream listener updated node: \n" +
                    "   node: " + nodeRef + "\n" +
                    "   property: " + propertyQName + "\n" +
                    "   value: " + contentData);
        }
    }
    catch (ContentQuotaException qe)
    {
        throw qe;
    }
    catch (Throwable e)
    {
        throw new ContentIOException("Failed to set content property on stream closure: \n" +
                "   node: " + nodeRef + "\n" +
                "   property: " + propertyQName + "\n" +
                "   writer: " + writer + "\n" + 
                e.toString(),
                e);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:31,代碼來源:ContentServiceImpl.java

示例3: writeContent

import org.alfresco.service.cmr.usage.ContentQuotaException; //導入依賴的package包/類
private void writeContent(NodeRef nodeRef, String fileName, InputStream stream, boolean guessEncoding)
{
    try
    {
        ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);

        String mimeType = mimetypeService.guessMimetype(fileName);
        if ((mimeType != null) && (!mimeType.equals(MimetypeMap.MIMETYPE_BINARY)))
        {
            // quick/weak guess based on file extension
            writer.setMimetype(mimeType);
        } else
        {
            // stronger guess based on file stream
            writer.guessMimetype(fileName);
        }

        InputStream is = null;

        if (guessEncoding)
        {
            is = new BufferedInputStream(stream);
            is.mark(1024);
            writer.setEncoding(guessEncoding(is, mimeType, false));
            try
            {
                is.reset();
            } catch (IOException ioe)
            {
                if (logger.isWarnEnabled())
                {
                    logger.warn("Failed to reset stream after trying to guess encoding: " + ioe.getMessage());
                }
            }
        } else
        {
            is = stream;
        }

        writer.putContent(is);
    }
    catch (ContentQuotaException cqe)
    {
        throw new InsufficientStorageException();
    }
    catch (ContentLimitViolationException clv)
    {
        throw new RequestEntityTooLargeException(clv.getMessage());
    }
    catch (ContentIOException cioe)
    {
        if (cioe.getCause() instanceof NodeLockedException)
        {
            throw (NodeLockedException)cioe.getCause();
        }
        throw cioe;
    }
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:59,代碼來源:NodesImpl.java


注:本文中的org.alfresco.service.cmr.usage.ContentQuotaException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。