Juan Carlos Picado Herrera avatar Juan Carlos Picado Herrera committed 4d950b5

Comments (0)

Files changed (4)

encuestame-business/src/main/java/org/encuestame/business/service/TweetPollService.java

      * @see org.encuestame.business.service.imp.ITweetPollService#getTweetPollById(java.lang.Long, org.encuestame.persistence.domain.security.UserAccount)
      */
     public TweetPoll getTweetPollById(final Long tweetPollId) throws EnMeNoResultsFoundException{
-        final TweetPoll tweetPoll = getTweetPollDao()
-                .getTweetPollByIdandUserId(
-                        tweetPollId,
-                        getUserAccount(getUserPrincipalUsername()).getAccount().getUid()
-                                );
+        return this.getTweetPollById(tweetPollId, getUserPrincipalUsername());
+    }
+
+    /*
+     *
+     */
+    public TweetPoll getTweetPollById(final Long tweetPollId, final String username) throws EnMeNoResultsFoundException {
+        TweetPoll tweetPoll = null;
+        if (username != null) {
+            tweetPoll = getTweetPollDao()
+                    .getTweetPollByIdandUserId(tweetPollId,
+                            getUserAccount(username).getAccount().getUid());
+        } else {
+            tweetPoll = getTweetPollDao().getTweetPollById(tweetPollId);
+        }
         if (tweetPoll == null) {
             log.error("tweet poll invalid with this id "+tweetPollId);
             throw new EnMeTweetPollNotFoundException("tweet poll invalid with this id "+tweetPollId);
      * @throws EnMeNoResultsFoundException
      */
     private TweetPoll getTweetPoll(final Long tweetPollId, final String username) throws EnMeNoResultsFoundException{
-        return getTweetPollById(tweetPollId);
+        return this.getTweetPollById(tweetPollId, username);
     }
 
     /**

encuestame-business/src/main/java/org/encuestame/business/service/imp/ITweetPollService.java

     TweetPoll getTweetPollById(final Long tweetPollId) throws EnMeTweetPollNotFoundException, EnMeNoResultsFoundException;
 
     /**
+     * Get tweetpoll by id and username
+     * @param tweetPollId tweetpoll id
+     * @param username username
+     * @return {@link TweetPoll}
+     * @throws EnMeNoResultsFoundException
+     */
+    public TweetPoll getTweetPollById(final Long tweetPollId, final String username) throws EnMeNoResultsFoundException;
+
+    /**
      * Get complete list of {@link TweetPollSwitch}/
      * @param tweetPoll {@link TweetPoll}.
      * @return resutls.

encuestame-mvc/src/main/java/org/encuestame/mvc/view/PictureProfileFactoryController.java

     public byte[] getPictureThumbnail(
             @PathVariable String username) throws EnMeNoResultsFoundException{
         byte[] bytes = {};
+        username = filterValue(username);
         try {
             bytes = getPictureService().getProfilePicture(username, PictureType.THUMBNAIL);
         } catch (FileNotFoundException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+            // if the user doesn't have picture.
+
         } catch (IOException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();

encuestame-mvc/src/main/java/org/encuestame/mvc/view/TweetPollController.java

         try {
             //id = filterValue(id);
             slug = filterValue(slug);
-            final TweetPoll tp = getTweetPollService().getTweetPollById(id); //TODO: add slug param.
+            final TweetPoll tp = getTweetPollService().getTweetPollById(id, null); //TODO: add slug param.
             model.addAttribute("tweetpoll", ConvertDomainBean.convertTweetPollToBean(tp));
             final List<TweetPollSwitch> answers = getTweetPollService().getTweetPollSwitch(tp);
             model.addAttribute("answers", answers);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.