@Override public void afterPropertiesSet() throws Exception { if (ratingSchemeName == null) { throw new RatingServiceException("Illegal null ratingSchemeName in " + this.getClass().getSimpleName()); } }
@Override public void afterPropertiesSet() throws Exception { if (ratingSchemeName == null) { throw new RatingServiceException("Illegal null ratingSchemeName in " + this.getClass().getSimpleName()); } }
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()); } }
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()); } }
if (ratingScheme == null) throw new RatingServiceException("Unrecognised rating scheme: " + ratingSchemeName); throw new RatingServiceException("Rating " + rating + " violates range for " + ratingScheme);
if (ratingScheme == null) throw new RatingServiceException("Unrecognised rating scheme: " + ratingSchemeName); throw new RatingServiceException("Rating " + rating + " violates range for " + ratingScheme);
@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; }
@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; }
@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()); }