本文整理匯總了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());
}
示例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;
}
示例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.");
}
示例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;
}
});
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
示例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);
}
}
示例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());
}
}
示例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());
}
}