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


Java RatingServiceException類代碼示例

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


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

示例1: applyRating

import org.alfresco.service.cmr.rating.RatingServiceException; //導入依賴的package包/類
@Extend(traitAPI=RatingServiceTrait.class,extensionAPI=RatingServiceExtension.class)
public void applyRating(final NodeRef targetNode, final float rating,
        final String ratingSchemeName) throws RatingServiceException
{
    final String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
    boolean isCreator = isCurrentUserNodeCreator(targetNode);
    if (isCreator && this.getRatingScheme(ratingSchemeName).isSelfRatingAllowed() == false)
    {
        throw new RatingServiceException("Users can't rate their own content for scheme " + ratingSchemeName);
    }
    
    AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Void>() 
    {
        public Void doWork() throws Exception
        {
            applyRating(targetNode, rating, ratingSchemeName, currentUser);
            return null;
        }
    }, AuthenticationUtil.getSystemUserName());
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:21,代碼來源:RatingServiceImpl.java

示例2: getRatingRollup

import org.alfresco.service.cmr.rating.RatingServiceException; //導入依賴的package包/類
@Extend(traitAPI=RatingServiceTrait.class,extensionAPI=RatingServiceExtension.class)
public Serializable getRatingRollup(NodeRef targetNode, String ratingSchemeName, String ratingRollupName)
{
    RatingScheme scheme = schemeRegistry.getRatingSchemes().get(ratingSchemeName);
    if (scheme == null)
    {
        throw new RatingServiceException("Cannot retrieve rollup. Unrecognized rating scheme " + ratingSchemeName);
    }
    
    QName rollupAspectName = ratingNamingConventions.getRollupAspectNameFor(scheme);

    Serializable result = null;
    // If the rated node has the rollup aspect applied
    if (nodeService.hasAspect(targetNode, rollupAspectName))
    {
        QName rollupPropertyName = ratingNamingConventions.getRollupPropertyNameFor(scheme, ratingRollupName);
        result = nodeService.getProperty(targetNode, rollupPropertyName);
    }
    
    return result;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:22,代碼來源:RatingServiceImpl.java

示例3: applyIllegalRating

import org.alfresco.service.cmr.rating.RatingServiceException; //導入依賴的package包/類
private void applyIllegalRating(final NodeRef nodeRef, final float illegalRating, final String schemeName)
{
    try
    {
        TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<Void>()
        {
            @Override
            public Void execute() throws Throwable
            {
                RATING_SERVICE.applyRating(nodeRef, illegalRating, schemeName);
                return null;
            }
        });
    } 
    catch (RatingServiceException expectedException)
    {
        return;
    }
    fail("Illegal rating " + illegalRating + " should have caused exception.");
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:21,代碼來源:RatingServiceIntegrationTest.java

示例4: usersCantRateTheirOwnContent

import org.alfresco.service.cmr.rating.RatingServiceException; //導入依賴的package包/類
@Test @RunAsUser(userName=USER_ONE_NAME) public void usersCantRateTheirOwnContent() throws Exception
{
    TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<Void>()
    {
        public Void execute() throws Throwable
        {
            // In the likes rating scheme, users can rate their own content.
            RATING_SERVICE.applyRating(testDoc_UserOne, 1, LIKES_SCHEME_NAME);
            
            // But fiveStar rating scheme disallows rating your own content.
            boolean expectedExceptionThrown = false;
            try
            {
                RATING_SERVICE.applyRating(testDoc_UserOne, 4, FIVE_STAR_SCHEME_NAME);
            } catch (RatingServiceException expected)
            {
                expectedExceptionThrown = true;
            }
            assertTrue(expectedExceptionThrown);
            
            return null;
        }
    });
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:25,代碼來源:RatingServiceIntegrationTest.java

示例5: applyRating

import org.alfresco.service.cmr.rating.RatingServiceException; //導入依賴的package包/類
@Override
public void applyRating(NodeRef nodeRef, Object rating)
{
	try
	{
		Float ratingServiceRating = getRatingServiceRating(rating);
		ratingService.applyRating(nodeRef, ratingServiceRating, getRatingServiceName());

		QName nodeType = nodeService.getType(nodeRef);
           boolean isContainer = dictionaryService.isSubClass(nodeType, ContentModel.TYPE_FOLDER) &&
                   !dictionaryService.isSubClass(nodeType, ContentModel.TYPE_SYSTEM_FOLDER);
		postActivity(nodeRef, isContainer ? ActivityType.FOLDER_LIKED : ActivityType.FILE_LIKED);
	}
	catch(RatingServiceException e)
	{
		throw new InvalidArgumentException(e.getMessage());
	}
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:19,代碼來源:LikesRatingScheme.java

示例6: afterPropertiesSet

import org.alfresco.service.cmr.rating.RatingServiceException; //導入依賴的package包/類
public void afterPropertiesSet() throws Exception
{
    if (this.minRating > this.maxRating)
    {
        StringBuilder msg = new StringBuilder();
        msg.append("Illegal rating limits for ").append(name)
           .append(". Min > Max. ")
           .append(minRating).append(" > ").append(maxRating);
        throw new RatingServiceException(msg.toString());
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:12,代碼來源:RatingSchemeImpl.java

示例7: afterPropertiesSet

import org.alfresco.service.cmr.rating.RatingServiceException; //導入依賴的package包/類
@Override
public void afterPropertiesSet() throws Exception
{
    if (ratingSchemeName == null)
    {
        throw new RatingServiceException("Illegal null ratingSchemeName in " + this.getClass().getSimpleName());
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:9,代碼來源:AbstractRatingRollupAlgorithm.java

示例8: applyRatingAs

import org.alfresco.service.cmr.rating.RatingServiceException; //導入依賴的package包/類
private void applyRatingAs(final NodeRef targetNode, final float rating, final String ratingSchemeName,
            String asUser) throws RatingServiceException
{

    String fau = AuthenticationUtil.getFullyAuthenticatedUser();
    try
    {
        AuthenticationUtil.setFullyAuthenticatedUser(asUser);
        RunAsWork<Void> applyRatingsAsWork = new RunAsWork<Void>()
        {

            @Override
            public Void doWork() throws Exception
            {
                ratingService.applyRating(targetNode,
                                          rating,
                                          ratingSchemeName);
                return null;
            }

        };
        AuthenticationUtil.runAs(applyRatingsAsWork,
                                 asUser);
    }
    finally
    {
        AuthenticationUtil.setFullyAuthenticatedUser(fau);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:30,代碼來源:VirtualRatingServiceExtensionTest.java

示例9: removeRating

import org.alfresco.service.cmr.rating.RatingServiceException; //導入依賴的package包/類
@Override
public void removeRating(NodeRef nodeRef)
{
	try
	{
		ratingService.removeRatingByCurrentUser(nodeRef, getRatingServiceName());
	}
	catch(RatingServiceException e)
	{
		throw new InvalidArgumentException(e.getMessage());
	}
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:13,代碼來源:LikesRatingScheme.java

示例10: applyRating

import org.alfresco.service.cmr.rating.RatingServiceException; //導入依賴的package包/類
@Override
public void applyRating(NodeRef nodeRef, Object rating)
{
	try
	{
		Float ratingServiceRating = getRatingServiceRating(rating);
		ratingService.applyRating(nodeRef, ratingServiceRating, getRatingServiceName());
	}
	catch(RatingServiceException e)
	{
		throw new InvalidArgumentException(e.getMessage());
	}
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:14,代碼來源:FiveStarRatingScheme.java


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