Package org.damour.base.client.objects

Examples of org.damour.base.client.objects.UserThumb


      if (!SecurityHelper.doesUserHavePermission(session.get(), authUser, permissibleObject, PERM.READ)) {
        throw new SimpleMessageException("User is not authorized to set thumbs on this content.");
      }

      UserThumb userThumb = ThumbHelper.getUserThumb(session.get(), permissibleObject, authUser, getVoterGUID());
      // check if thumb already exists
      if (userThumb != null) {
        // TODO: consider changing the vote
        // simply subtract the previous amount and decrement the numRatingVotes and redivide
        throw new SimpleMessageException("Already voted.");
      }

      if (like) {
        permissibleObject.setNumUpVotes(permissibleObject.getNumUpVotes() + 1);
      } else {
        permissibleObject.setNumDownVotes(permissibleObject.getNumDownVotes() + 1);
      }
      session.get().save(permissibleObject);

      userThumb = new UserThumb();
      userThumb.setPermissibleObject(permissibleObject);
      userThumb.setLikeThumb(like);
      userThumb.setVoter(authUser);
      userThumb.setVoterGUID(getVoterGUID());

      session.get().save(userThumb);
      tx.commit();
      return userThumb;
    } catch (Throwable t) {
View Full Code Here

TOP

Related Classes of org.damour.base.client.objects.UserThumb

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.