Fix problem with access permissions and make better wording for the new servlet PROT-10-new-controller
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Mon, 16 Dec 2013 12:30:11 +0000 (12:30 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Mon, 16 Dec 2013 12:30:11 +0000 (12:30 +0000)
server/compbio/controllers/SSFeaturesController.java
webapp/view/query/SSFeatures.jsp
webapp/view/reportSSFeatures.jsp
webapp/view/support/Blocked.jsp
webapp/view/support/Denied.jsp
webapp/view/support/Notimplemented.jsp

index 27015bb..f8e5d66 100644 (file)
@@ -1,6 +1,5 @@
 package compbio.controllers;
 
-import java.util.List;
 import java.util.Map;
 
 import org.springframework.stereotype.Controller;
@@ -8,8 +7,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
-import compbio.cassandra.ProteinBean;
-import compbio.cassandra.TotalByCounterBean;
 import compbio.statistic.CassandraRequester;
 
 /**
@@ -26,61 +23,60 @@ import compbio.statistic.CassandraRequester;
 @RequestMapping("/features")
 public class SSFeaturesController extends BasicController {
 
-               @RequestMapping(value = "query", method = RequestMethod.GET)
-               public String formCounterQuery(Map<String, Object> model) {
-                       model.put("username", getPrincipalName());
-                       model.put("type", 'E');
-                       model.put("value", 80);
+       @RequestMapping(value = "query", method = RequestMethod.GET)
+       public String formCounterQuery(Map<String, Object> model) {
+               model.put("username", getPrincipalName());
+               model.put("type", 'E');
+               model.put("value", 50);
+               return "query/SSFeatures";
+       }
+
+       @RequestMapping(value = "features/results", method = RequestMethod.GET)
+       public String countSequences(@RequestParam("TypeFeatures") String typeFeature, @RequestParam("Percent") String percent,
+                       Map<String, Object> model) {
+               model.put("username", getPrincipalName());
+               final long startTime = System.currentTimeMillis();
+
+               if (percent.equals("")) {
+                       model.put("error", "The value must not be empty");
+                       model.put("type", typeFeature);
+                       model.put("value", percent);
                        return "query/SSFeatures";
                }
-                       
-               @RequestMapping(value = "features/results", method = RequestMethod.GET)
-               public String countSequences(@RequestParam("TypeFeatures") String typeFeature, @RequestParam("Percent") String percent,Map<String, Object> model) {
-                       model.put("username", getPrincipalName());
-                       final long startTime = System.currentTimeMillis();
-
-                       if (percent.equals("")) {
-                               model.put("error", "The value must not be empty");
-                               model.put("type", typeFeature);
-                               model.put("value", percent);
-                               return "query/SSFeatures";
-                       }
 
-                       int realpercent;
-                       try {
-                               realpercent = Integer.parseInt(percent.trim());
-                       } catch (NumberFormatException e) {
-                               model.put("error", "The value must be an integer number");
-                               model.put("value", percent);
-                               return "query/SSFeatures";
-                       }
+               int realpercent;
+               try {
+                       realpercent = Integer.parseInt(percent.trim());
+               } catch (NumberFormatException e) {
+                       model.put("error", "The value must be an integer number");
+                       model.put("value", percent);
+                       return "query/SSFeatures";
+               }
 
-                       if (realpercent < 1) {
-                               model.put("error", "The value must be greater than 0");
-                               model.put("value", percent);
-                               return "query/SSFeatures";
-                       }
-                       
-                       if (realpercent > 100) {
-                               model.put("error", "The value must be less than 100");
-                               model.put("value", percent);
-                               return "query/SSFeatures";
-                       }
+               if (realpercent < 1) {
+                       model.put("error", "The value must be greater than 0");
+                       model.put("value", percent);
+                       return "query/SSFeatures";
+               }
 
-                       CassandraRequester cr = new CassandraRequester();
-                       Map<String, String> r = cr.readProteinsPrediction(typeFeature, realpercent);
-                       model.put("results", r);
-                       model.put("njobs", 0);
-                       if (null != r) {
-                               model.put("njobs", r.size());
-                       }
-                       final long endTime = System.currentTimeMillis();
-                       model.put("timeExecution", (endTime - startTime));
-                       model.put("feature", typeFeature);
-                       model.put("percent", realpercent);
-                       return "reportSSFeatures";
+               if (realpercent > 100) {
+                       model.put("error", "The value must be less than 100");
+                       model.put("value", percent);
+                       return "query/SSFeatures";
                }
 
-       
+               CassandraRequester cr = new CassandraRequester();
+               Map<String, String> r = cr.readProteinsPrediction(typeFeature, realpercent);
+               model.put("results", r);
+               model.put("njobs", 0);
+               if (null != r) {
+                       model.put("njobs", r.size());
+               }
+               final long endTime = System.currentTimeMillis();
+               model.put("timeExecution", (endTime - startTime));
+               model.put("feature", typeFeature);
+               model.put("percent", realpercent);
+               return "reportSSFeatures";
+       }
 
 }
index 59cdc1c..be793c8 100644 (file)
 
        <div class="panel panel-default">
                <div class="panel-heading">
-                       <div style="font-weight:bold;">Proteins with features</div>
+                       <div style="font-weight:bold;">Protein Secondary Structure statistics</div>
                </div>
                <div class="panel-body">
                        <form method="get" action="${query}">
-                       <div class="col-xs-2"> <!-- make the field shorter -->
+                       <div class="col-xs-3"> <!-- make the field shorter -->
                        <c:choose>
                        <c:when test="${error == null}">
                        <div class="form-group">
-                               <label for="TypeFeatures">Type of SS feature </label>
+                               <label for="TypeFeatures">Secondary Structure Feature </label>
                                <select name = TypeFeatures>
-                                        <option value="H">H</option>
-                                        <option value="E">E</option>
+                                        <option value="H">Helix</option>
+                                        <option value="E">Beta Sheet</option>
                                </select>       
-                               <label for="SSFeatureValue">Percent of SS feature </label>
+                               <label for="SSFeatureValue">Fraction the feature in the protein</label>
                                <input class="form-control" type="text" name="Percent" value ="${value}" id="SSFeatureValue">
                        </div>
                        </c:when>
index 2d885f7..7aae5d0 100644 (file)
 
        <div class="panel panel-default">
        <div class="panel-heading">
-               <div style="font-weight:bold;">Jobs Statistics</div>
+               <div style="font-weight:bold;">Protein Secondary Structure Feature Statistics</div>
        </div>
        <div class="panel-body">
 
                <c:choose>
                <c:when test="${njobs == 0}">
-                       <p>No proteins with features ${feature} more then ${percent} % found</p>
+                       <p>No proteins with feature ${feature} more then ${percent}% of the protein sequence found</p>
                </c:when>
                <c:otherwise>
-                       <p>${njobs} proteins with features ${feature} more then ${percent} % found</p>
+                       <p>${njobs} proteins with feature ${feature} more then ${percent}% of the protein sequence found</p>
                        <div class="table-responsive">
                        <table class="table table-striped table-hover table-bordered">
                        <thead>
index 405c921..d017c09 100644 (file)
@@ -1,25 +1,22 @@
-<%@ page language="java" contentType="text/html; charset=UTF-8"
-       pageEncoding="UTF-8"%>
+<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
 <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
-<%@page import="java.util.ArrayList"%>
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
 
 <html>
 <jsp:include page="../fragments/header.jsp" />
 <body>
        <div class="container">
-               <c:choose>
-                       <c:when test="${permissions == 'user_role'}">
-                               <jsp:include page="../fragments/mainmenu.jsp" />
-                       </c:when>
-                       <c:otherwise>
-                               <jsp:include page="../fragments/publicmenu.jsp" />
-                       </c:otherwise>
-               </c:choose>
+               <sec:authorize access="hasAnyRole('ROLE_ADMIN','ROLE_USER')">
+                       <jsp:include page="../fragments/mainmenu.jsp" />
+               </sec:authorize>
+               <sec:authorize access="!hasAnyRole('ROLE_ADMIN','ROLE_USER')">
+                       <jsp:include page="../fragments/publicmenu.jsp" />
+               </sec:authorize>
 
                <div class="panel panel-default">
                        <div class="panel-heading">
index bcb306c..0a27337 100644 (file)
@@ -1,25 +1,22 @@
-<%@ page language="java" contentType="text/html; charset=UTF-8"
-       pageEncoding="UTF-8"%>
+<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
 <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
-<%@page import="java.util.ArrayList"%>
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
 
 <html>
 <jsp:include page="../fragments/header.jsp" />
 <body>
        <div class="container">
-               <c:choose>
-                       <c:when test="${permissions == 'user_role'}">
-                               <jsp:include page="../fragments/mainmenu.jsp" />
-                       </c:when>
-                       <c:otherwise>
-                               <jsp:include page="../fragments/publicmenu.jsp" />
-                       </c:otherwise>
-               </c:choose>
+               <sec:authorize access="hasAnyRole('ROLE_ADMIN','ROLE_USER')">
+                       <jsp:include page="../fragments/mainmenu.jsp" />
+               </sec:authorize>
+               <sec:authorize access="!hasAnyRole('ROLE_ADMIN','ROLE_USER')">
+                       <jsp:include page="../fragments/publicmenu.jsp" />
+               </sec:authorize>
 
                <div class="panel panel-default">
                        <div class="panel-heading">
index 1eb2bd0..2afcd43 100644 (file)
@@ -1,25 +1,22 @@
-<%@ page language="java" contentType="text/html; charset=UTF-8"
-       pageEncoding="UTF-8"%>
+<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
 <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
-<%@page import="java.util.ArrayList"%>
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
 
 <html>
 <jsp:include page="../fragments/header.jsp" />
 <body>
        <div class="container">
-               <c:choose>
-                       <c:when test="${permissions == 'user_role'}">
-                               <jsp:include page="../fragments/mainmenu.jsp" />
-                       </c:when>
-                       <c:otherwise>
-                               <jsp:include page="../fragments/publicmenu.jsp" />
-                       </c:otherwise>
-               </c:choose>
+               <sec:authorize access="hasAnyRole('ROLE_ADMIN','ROLE_USER')">
+                       <jsp:include page="../fragments/mainmenu.jsp" />
+               </sec:authorize>
+               <sec:authorize access="!hasAnyRole('ROLE_ADMIN','ROLE_USER')">
+                       <jsp:include page="../fragments/publicmenu.jsp" />
+               </sec:authorize>
 
                <div class="panel panel-default">
                        <div class="panel-heading">