/** * This method checks whether self-rating is allowed for the specified rating scheme. * If self-rating is allowed in the specified scheme, then the cm:creator of a node can apply a rating, * otherwise they cannot. * * @param ratingSchemeName the rating scheme bean name. * @return <code>true</code> if users can rate their own content, else <code>false</code>. */ public boolean isSelfRatingAllowed(String ratingSchemeName) { return ratingService.getRatingScheme(ratingSchemeName).isSelfRatingAllowed(); }
/** * This method checks whether self-rating is allowed for the specified rating scheme. * If self-rating is allowed in the specified scheme, then the cm:creator of a node can apply a rating, * otherwise they cannot. * * @param ratingSchemeName the rating scheme bean name. * @return <code>true</code> if users can rate their own content, else <code>false</code>. */ public boolean isSelfRatingAllowed(String ratingSchemeName) { return ratingService.getRatingScheme(ratingSchemeName).isSelfRatingAllowed(); }
@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()); }
@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()); }