Commit bfbf551b authored by Guillaume Jimenez's avatar Guillaume Jimenez

Added better session management. Fixed pass/fail flags. Fusion only for

ROS1
parent c6cb61bc
......@@ -8,6 +8,7 @@
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="
......@@ -22,7 +23,9 @@
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
......@@ -135,6 +138,8 @@
<!-- <context:property-placeholder location="file:///C:/nuclia.properties"/> -->
<context:property-placeholder location="file:///opt/nuclia/conf/nuclia.properties"/>
</beans>
......
......@@ -32,4 +32,8 @@
<location>/500</location>
</error-page>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
\ No newline at end of file
......@@ -14,8 +14,6 @@ import org.aspectj.lang.reflect.MethodSignature;
import org.owasp.html.HtmlPolicyBuilder;
import org.owasp.html.PolicyFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;
......@@ -46,12 +44,15 @@ public class AOPAspect {
@Pointcut("loginController() || errorController()")
private void loginOrErrorController() {}
@Pointcut("execution(* utsw.bicf.nucliavault.controller.api.APIController.*(..))")
private void apiController() {
}
public void checkUserPermission(JoinPoint joinPoint, Model model, HttpSession httpSession) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
boolean isAjax = method.getAnnotation(ResponseBody.class) != null;
Object[] args = joinPoint.getArgs();
// HttpSession httpSession = null;
// Model model = null;
......@@ -66,7 +67,7 @@ public class AOPAspect {
// }
if (httpSession != null && model != null) {
NucliaUser user = (NucliaUser) httpSession.getAttribute("user");
NucliaUser user = ControllerUtil.getSessionUser(httpSession);
model.addAttribute("isAjax", isAjax);
if (user == null) {
model.addAttribute("isAllowed", false);
......@@ -118,7 +119,7 @@ public class AOPAspect {
}
}
@Around("controllerPackage() && !loginOrErrorController()")
@Around("controllerPackage() && !loginOrErrorController() && !apiController()")
public Object handleUserPermission(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
Object[] args = proceedingJoinPoint.getArgs();
HttpSession httpSession = null;
......
......@@ -128,5 +128,5 @@ public class AdminController {
}
return ajaxResponse.createObjectJSON();
}
}
......@@ -7,12 +7,23 @@ import java.util.Date;
import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import org.springframework.ui.Model;
import utsw.bicf.nucliavault.model.NucliaUser;
public class ControllerUtil {
private static long timestamp = new Date().getTime();
public static NucliaUser getSessionUser(HttpSession httpSession) {
NucliaUser user = null;
if (httpSession.getAttribute("user") instanceof NucliaUser) {
user = (NucliaUser) httpSession.getAttribute("user");
}
return user;
}
public static String initializeModel(Model model, ServletContext servletContext) throws IOException {
model.addAttribute("componentFiles", ControllerUtil.getAllComponents(servletContext));
......
......@@ -101,8 +101,9 @@ public class APIController {
@RequestMapping("/outputPipelineResultUrls")
@ResponseBody
public String outputAllPipelineResultUrls(HttpServletRequest request, Model model, @RequestParam String token,
public String outputAllPipelineResultUrls(HttpServletRequest request, HttpSession session, Model model, @RequestParam String token,
@RequestHeader(value = "User-Agent") String userAgent) throws ParseException, IOException {
session.setAttribute("user", "API User from outputAllPipelineResultUrls");
// check that token is valid
Token theToken = pipelineDAO.getPipelineToken(token);
if (theToken == null) {
......@@ -116,14 +117,16 @@ public class APIController {
conn.close();
response.setMessage("Results: ");
ResponseAPI rAPI = modelDAO.getResponseAPI();
session.invalidate();
return response.createResponse(userAgent, rAPI.getShowError(), rAPI.getShowInfo());
}
@RequestMapping("/addPipelineResults")
@ResponseBody
public String addPipelineResults(Model model, @RequestParam String token,
public String addPipelineResults(HttpSession session, Model model, @RequestParam String token,
@RequestHeader(value = "User-Agent") String userAgent, @RequestParam String subjectName,
@RequestParam String sampleName, @RequestParam String runName, @RequestParam String baitPool) throws ParseException, IOException {
session.setAttribute("user", "API User from addPipelineResults");
// check that token is valid
Token theToken = pipelineDAO.getPipelineToken(token);
if (theToken == null) {
......@@ -133,13 +136,15 @@ public class APIController {
APIResponse response = new APIResponse();
response.setMessage("Adding Pipeline Results to Sample: " + sampleName);
pipelineDAO.fetchNewData(response, subjectName, sampleName, runName, baitPool);
session.invalidate();
return response.createResponse(userAgent, true, true);
}
@RequestMapping("/addPipelineResultsWithProp")
@ResponseBody
public String addPipelineResultsWithProp(Model model, @RequestParam String token,
public String addPipelineResultsWithProp(HttpSession session, Model model, @RequestParam String token,
@RequestHeader(value = "User-Agent") String userAgent, @RequestParam String propFilePath) {
session.setAttribute("user", "API User from addPipelineResultsWithProp");
try {
// check that token is valid
Token theToken = pipelineDAO.getPipelineToken(token);
......@@ -169,17 +174,20 @@ public class APIController {
pipelineDAO2.fetchNewData(response, props);
}
session.invalidate();
return response.createResponse(userAgent, true, true);
} catch (Exception e) {
e.printStackTrace();
}
session.invalidate();
return "An error occured when importing from this file: " + propFilePath + ". Look at tomcat logs to know more.";
}
@RequestMapping("/addPipelineResultsSomatic")
@ResponseBody
public String addPipelineResultsSomatic(Model model, @RequestParam String token,
public String addPipelineResultsSomatic(HttpSession session, Model model, @RequestParam String token,
@RequestHeader(value = "User-Agent") String userAgent, @RequestParam String filePath) {
session.setAttribute("user", "API User from addPipelineResultsSomatic");
try {
// check that token is valid
Token theToken = pipelineDAO.getPipelineToken(token);
......@@ -203,16 +211,19 @@ public class APIController {
pipelineDAO2.fetchSomaticData(response, somaticFile);
}
session.invalidate();
return response.createResponse(userAgent, true, true);
} catch (Exception e) {
e.printStackTrace();
}
session.invalidate();
return "An error occured when importing from this file: " + filePath + ". Look at tomcat logs to know more.";
}
@RequestMapping("/syncWithClaritySQL")
@ResponseBody
public String syncWithClaritySQL(Model model, @RequestParam String token, @RequestHeader(value = "User-Agent") String userAgent) throws ParseException, IOException, ClassNotFoundException {
public String syncWithClaritySQL(HttpSession session, Model model, @RequestParam String token, @RequestHeader(value = "User-Agent") String userAgent) throws ParseException, IOException, ClassNotFoundException {
session.setAttribute("user", "API User from syncWithClaritySQL");
Token theToken = clarityDAO.getClarityToken(token);
if (theToken == null) {
return "You are not allowed to run this servlet.";
......@@ -231,6 +242,7 @@ public class APIController {
response.setMessage("Sync results at " + LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + ": ");
ResponseAPI rAPI = modelDAO.getResponseAPI();
session.invalidate();
return response.createResponse(userAgent, rAPI.getShowError(), rAPI.getShowInfo());
}
......@@ -247,7 +259,8 @@ public class APIController {
*/
@RequestMapping("/orderId")
@ResponseBody
public String orderId(Model model, @RequestParam String token, @RequestParam String caseNb) throws ParseException, IOException, ClassNotFoundException {
public String orderId(HttpSession session, Model model, @RequestParam String token, @RequestParam String caseNb) throws ParseException, IOException, ClassNotFoundException {
session.setAttribute("user", "API User from orderId");
Token theToken = pipelineDAO.getAnswerToken(token);
if (theToken == null) {
return "You are not allowed to run this servlet.";
......@@ -265,6 +278,7 @@ public class APIController {
response.setMessage(subject.getSubjectId() + "");
response.setSuccess(true);
}
session.invalidate();
return response.createObjectJSON();
}
......@@ -282,6 +296,7 @@ public class APIController {
@ResponseBody
public String getTumorCoverageFromAPI(Model model, HttpSession session,
@RequestParam String token, @RequestParam String sampleLabId) throws JsonProcessingException {
session.setAttribute("user", "API User from getTumorCoverageFromAPI");
AjaxResponse response = new AjaxResponse();
Token theToken = pipelineDAO2.getAnswerToken(token);
if (theToken == null) {
......@@ -344,6 +359,7 @@ public class APIController {
covStats.setRawPctOver100X(rawPctOver100X);
covStats.setDedupAvgDepth(dedupAvgDepth);
covStats.setDedupPctOver100X(dedupPctOver100X);
session.invalidate();
return covStats.createObjectJSON();
}
......@@ -363,6 +379,7 @@ public class APIController {
@RequestParam String token, @RequestParam String projectId,
@RequestHeader(value = "User-Agent") String userAgent,
@RequestParam(defaultValue="false") boolean prettyPrint) throws JsonProcessingException {
session.setAttribute("user", "API User from getSampleAndRunIds");
AjaxResponse response = new AjaxResponse();
Token theToken = pipelineDAO2.getPipelineToken(token);
if (theToken == null) {
......@@ -409,6 +426,7 @@ public class APIController {
ProjectSampleAndRunIds result = new ProjectSampleAndRunIds(
subject,
nDnaSampleInfosBySampleId.values(), tDnaSampleInfosBySampleId.values(), tRnaSampleInfosBySampleId.values());
session.invalidate();
if (prettyPrint) {
return result.createPrettyObjectJSON(userAgent);
}
......@@ -451,6 +469,7 @@ public class APIController {
@RequestParam String runId,
@RequestHeader(value = "User-Agent") String userAgent,
@RequestParam(defaultValue="false") boolean prettyPrint) throws JsonProcessingException {
session.setAttribute("user", "API User from hasAnalysisSample");
AjaxResponse response = new AjaxResponse();
Token theToken = pipelineDAO2.getPipelineToken(token);
if (theToken == null) {
......@@ -498,7 +517,7 @@ public class APIController {
return "true";
}
}
session.invalidate();
return "false";
}
......
......@@ -27,13 +27,15 @@ public class ControlFusionExpansionTableSummary extends Summary<ControlFusionExp
List<ControlFusion> fusions = modelDAO.getControlFusionForSeqRunId(seqRunId);
Map<String, ControlFusion> uniqueFusions = new HashMap<String, ControlFusion>();
for (ControlFusion f : fusions) {
String fusionName = f.getFusionName().replaceAll("-", "").replaceAll("ROS1", "") + f.getSample().getSampleId();
ControlFusion existingFusion = uniqueFusions.get(fusionName);
if (existingFusion == null) {
uniqueFusions.put(fusionName, f);
}
else if (f.getRnaReads() > existingFusion.getRnaReads()) {
uniqueFusions.put(fusionName, f);
if (f.getFusionName().contains("ROS1")) { //only care about ROS1 fusions
String fusionName = f.getFusionName().replaceAll("-", "").replaceAll("ROS1", "") + f.getSample().getSampleId();
ControlFusion existingFusion = uniqueFusions.get(fusionName);
if (existingFusion == null) {
uniqueFusions.put(fusionName, f);
}
else if (f.getRnaReads() > existingFusion.getRnaReads()) {
uniqueFusions.put(fusionName, f);
}
}
}
fusions = new ArrayList<ControlFusion>();
......
......@@ -677,6 +677,7 @@ public class SampleDetails {
passableValues.add(libDnaTotalYieldValue); //
passableValues.add(libDnaMeanAvgSizeValue); //
passableValues.add(hybDnaMeanFragSizeValue); //
passableValues.add(libRnaInputHybValue); //
passableValues.add(seqSampleQ30Value); //
passableValues.add(pctOnTargetValue);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment