|
78 | 78 | import org.labkey.api.view.UnauthorizedException; |
79 | 79 | import org.labkey.api.webdav.WebdavResource; |
80 | 80 | import org.labkey.api.webdav.WebdavService; |
81 | | -import org.labkey.skylinetoolsstore.model.Rating; |
82 | 81 | import org.labkey.skylinetoolsstore.model.SkylineTool; |
83 | 82 | import org.labkey.skylinetoolsstore.view.SkylineToolDetails; |
84 | 83 | import org.labkey.skylinetoolsstore.view.SkylineToolStoreUrls; |
@@ -613,7 +612,8 @@ else if (!getContainer().hasPermission(getUser(), InsertPermission.class)) |
613 | 612 | @Override |
614 | 613 | public void addNavTrail(NavTree root) |
615 | 614 | { |
616 | | - root.addChild(getToolStoreNav(getContainer())).addChild("Upload Tool", getURL()); |
| 615 | + root.addChild(getToolStoreNav(getContainer())); |
| 616 | + root.addChild("Upload Tool", getURL()); |
617 | 617 | } |
618 | 618 |
|
619 | 619 | public ActionURL getURL() |
@@ -645,151 +645,6 @@ private void redirectToToolStoreContainer(SkylineTool tool, ActionURL originalUr |
645 | 645 | } |
646 | 646 | } |
647 | 647 |
|
648 | | - @RequiresNoPermission |
649 | | - public class SubmitRatingAction extends AbstractController implements PermissionCheckable |
650 | | - { |
651 | | - private static final String NO_TITLE = "You did not enter a valid title."; |
652 | | - private static final String NO_RATING = "You did not submit a valid rating. Ratings must be between 1 and 5."; |
653 | | - private static final String NO_REVIEW = "You did not submit a valid review."; |
654 | | - private static final String ALREADY_REVIEWED = "You have already left a review for this tool."; |
655 | | - |
656 | | - public SubmitRatingAction() |
657 | | - { |
658 | | - } |
659 | | - |
660 | | - @Override |
661 | | - protected ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception |
662 | | - { |
663 | | - final User user = getUser(); |
664 | | - final String toolIdString = httpServletRequest.getParameter("toolId"); |
665 | | - int toolId = (toolIdString != null && !toolIdString.isEmpty()) ? Integer.parseInt(toolIdString) : -1; |
666 | | - |
667 | | - final String ratingIdString = httpServletRequest.getParameter("ratingId"); |
668 | | - int ratingId; |
669 | | - try { |
670 | | - ratingId = (ratingIdString != null && !ratingIdString.isEmpty()) ? Integer.parseInt(ratingIdString) : -1; |
671 | | - } catch(Exception e) { |
672 | | - return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null); |
673 | | - } |
674 | | - Rating rating = (ratingId < 0) ? null : RatingManager.get().getRatingById(ratingId); |
675 | | - final SkylineTool tool = SkylineToolsStoreManager.get().getTool((toolId >= 0) ? toolId : rating.getToolId()); |
676 | | - |
677 | | - final String ratingValueString = httpServletRequest.getParameter("value"); |
678 | | - final int ratingValue; |
679 | | - try { |
680 | | - ratingValue = Integer.parseInt(ratingValueString); |
681 | | - } catch(Exception e) { |
682 | | - return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null); |
683 | | - } |
684 | | - final String ratingTitle = httpServletRequest.getParameter("title"); |
685 | | - final String review = httpServletRequest.getParameter("review"); |
686 | | - |
687 | | - if (ratingId < 0 && RatingManager.get().userLeftRating(tool.getIdentifier(), getUser())) |
688 | | - { |
689 | | - getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form", |
690 | | - ALREADY_REVIEWED); |
691 | | - getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "hideForm", |
692 | | - true); |
693 | | - } |
694 | | - else if (ratingTitle == null || ratingTitle.isEmpty()) |
695 | | - { |
696 | | - getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form", |
697 | | - NO_TITLE); |
698 | | - } |
699 | | - else if (ratingValue < 1 || ratingValue > 5) |
700 | | - { |
701 | | - getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form", |
702 | | - NO_RATING); |
703 | | - } |
704 | | - else if (review == null || review.isEmpty()) |
705 | | - { |
706 | | - getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "form", |
707 | | - NO_REVIEW); |
708 | | - } |
709 | | - else if (user.isGuest()) |
710 | | - { |
711 | | - throw new Exception(); |
712 | | - } |
713 | | - else if (tool == null || (ratingId >= 0 && rating == null)) |
714 | | - { |
715 | | - throw new Exception(); |
716 | | - } |
717 | | - else |
718 | | - { |
719 | | - if (rating == null) |
720 | | - { |
721 | | - // Adding new rating |
722 | | - rating = new Rating(ratingValue, review, toolId, ratingTitle); |
723 | | - rating.setContainer(getContainer().getId()); |
724 | | - RatingManager.get().insertRating(user, rating); |
725 | | - } |
726 | | - else |
727 | | - { |
728 | | - // Editing existing rating |
729 | | - if (rating.getCreatedBy() != user.getUserId() && !getUser().hasSiteAdminPermission()) |
730 | | - { |
731 | | - throw new Exception(); |
732 | | - } |
733 | | - rating.setTitle(ratingTitle); |
734 | | - rating.setRating(ratingValue); |
735 | | - rating.setReview(review); |
736 | | - RatingManager.get().editRating(rating, user); |
737 | | - } |
738 | | - return HttpView.redirect(SkylineToolStoreUrls.getToolDetailsUrl(tool)); |
739 | | - } |
740 | | - |
741 | | - if (toolId >= 0) |
742 | | - getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "toolId", toolId); |
743 | | - if (ratingId >= 0) |
744 | | - getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "ratingId", ratingId); |
745 | | - if (ratingTitle != null) |
746 | | - getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "formTitle", ratingTitle); |
747 | | - getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "formValue", ratingValue); |
748 | | - if (review != null) |
749 | | - getViewContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "formReview", review); |
750 | | - |
751 | | - return new JspView<>("/org/labkey/skylinetoolsstore/view/SkylineRating.jsp", null); |
752 | | - } |
753 | | - |
754 | | - @Override |
755 | | - public void checkPermissions() throws UnauthorizedException |
756 | | - { |
757 | | - |
758 | | - } |
759 | | - } |
760 | | - |
761 | | - @RequiresNoPermission |
762 | | - public class DeleteRatingAction extends AbstractController implements PermissionCheckable |
763 | | - { |
764 | | - public DeleteRatingAction() |
765 | | - { |
766 | | - } |
767 | | - |
768 | | - @Override |
769 | | - public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception |
770 | | - { |
771 | | - int id = NumberUtils.toInt(httpServletRequest.getParameter("id"), -1); |
772 | | - int user = getUser().getUserId(); |
773 | | - final Rating rating = RatingManager.get().getRatingById(id); |
774 | | - if(rating != null) |
775 | | - { |
776 | | - if (user == rating.getCreatedBy() || getUser().hasSiteAdminPermission()) |
777 | | - RatingManager.get().deleteRating(id); |
778 | | - else |
779 | | - throw new Exception(); |
780 | | - } |
781 | | - |
782 | | - final SkylineTool tool = SkylineToolsStoreManager.get().getTool(rating.getToolId()); |
783 | | - return HttpView.redirect(SkylineToolStoreUrls.getToolDetailsUrl(tool)); |
784 | | - } |
785 | | - |
786 | | - @Override |
787 | | - public void checkPermissions() throws UnauthorizedException |
788 | | - { |
789 | | - |
790 | | - } |
791 | | - } |
792 | | - |
793 | 648 | @RequiresNoPermission |
794 | 649 | public class InsertSupplementAction extends AbstractController implements PermissionCheckable |
795 | 650 | { |
@@ -948,7 +803,6 @@ public boolean handlePost(IdForm idForm, BindException errors) throws Exception |
948 | 803 | // TODO: Should be in a transaction |
949 | 804 | for (SkylineTool toDelete : SkylineToolsStoreManager.get().getToolsByIdentifier(tool.getIdentifier())) |
950 | 805 | { |
951 | | - RatingManager.get().deleteRatingsByToolId(toDelete.getRowId()); |
952 | 806 | ContainerManager.delete(toDelete.lookupContainer(), getUser()); |
953 | 807 | } |
954 | 808 |
|
@@ -1027,7 +881,6 @@ public ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, |
1027 | 881 | if (tools.length == 1) |
1028 | 882 | throw new Exception(); |
1029 | 883 |
|
1030 | | - RatingManager.get().deleteRatingsByToolId(tool.getRowId()); |
1031 | 884 | ContainerManager.delete(tools[0].lookupContainer(), getUser()); |
1032 | 885 |
|
1033 | 886 | if (tools.length > 1) |
@@ -1088,7 +941,12 @@ else if (toolLsid != null && |
1088 | 941 | // Cookie expires after 1 day |
1089 | 942 | final int expires = 24 * 60 * 60; |
1090 | 943 |
|
1091 | | - SkylineToolsStoreManager.get().recordToolDownload(tool); |
| 944 | + // Download counter is an incidental write on a GET action — use ignoreSqlUpdates() |
| 945 | + // to avoid the dev-mode mutating SQL assertion (like auditing writes) |
| 946 | + try (var ignored = SpringActionController.ignoreSqlUpdates()) |
| 947 | + { |
| 948 | + SkylineToolsStoreManager.get().recordToolDownload(tool); |
| 949 | + } |
1092 | 950 |
|
1093 | 951 | DateFormat df = new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss 'GMT'", Locale.US); |
1094 | 952 | Calendar calendar = Calendar.getInstance(); |
|
0 commit comments