Skip to content

Commit

Permalink
Merge pull request #1389 from angelicaochoa/darwin-fix
Browse files Browse the repository at this point in the history
Darwin patient view updates
  • Loading branch information
ao508 authored Jun 24, 2016
2 parents a9d4ef8 + 91ac408 commit 19c94bc
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@
public class CheckDarwinAccessMain {

public static class CheckDarwinAccess {
private static String DARWIN_AUTH_URL = GlobalProperties.getDarwinAuthCheckUrl();
private static String DARWIN_RESPONSE_URL = GlobalProperties.getDarwinResponseUrl();
private static String DARWIN_AUTHORITY = GlobalProperties.getDarwinAuthority();
private static String CIS_USER = GlobalProperties.getCisUser();
private static String darwinAuthUrl = GlobalProperties.getDarwinAuthCheckUrl();
private static String darwinResponseUrl = GlobalProperties.getDarwinResponseUrl();
private static String darwinAuthority = GlobalProperties.getDarwinAuthority();
private static String cisUser = GlobalProperties.getCisUser();

public static String checkAccess(HttpServletRequest request) {
CancerStudy cancerStudy = (CancerStudy)request.getAttribute(PatientView.CANCER_STUDY);
Expand All @@ -83,14 +83,14 @@ public static String checkAccess(HttpServletRequest request) {
}

public static String getResponse(String cancerStudy, String userName, String patientId){
if (!DARWIN_AUTHORITY.equals(cancerStudy) || CIS_USER.equals(userName)) return "";
if (!darwinAuthority.equals(cancerStudy) || cisUser.equals(userName)) return "";

RestTemplate restTemplate = new RestTemplate();
HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = getRequestEntity(userName, patientId);
ResponseEntity<DarwinAccess> responseEntity = restTemplate.exchange(DARWIN_AUTH_URL, HttpMethod.POST, requestEntity, DarwinAccess.class);
ResponseEntity<DarwinAccess> responseEntity = restTemplate.exchange(darwinAuthUrl, HttpMethod.POST, requestEntity, DarwinAccess.class);
String darwinResponse = responseEntity.getBody().getDarwinAuthResponse();

return darwinResponse.equals("valid")?DARWIN_RESPONSE_URL+patientId:"";
return darwinResponse.equals("valid")?darwinResponseUrl+patientId:"";
}

private static HttpEntity<LinkedMultiValueMap<String, Object>> getRequestEntity(String userName, String patientId) {
Expand All @@ -100,7 +100,7 @@ private static HttpEntity<LinkedMultiValueMap<String, Object>> getRequestEntity(
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
return new HttpEntity<LinkedMultiValueMap<String, Object>>(map, headers);
}
}
}

public static class DarwinAccess {
Expand Down
45 changes: 27 additions & 18 deletions core/src/main/java/org/mskcc/cbio/portal/util/GlobalProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package org.mskcc.cbio.portal.util;

import com.mysql.jdbc.StringUtils;
import org.mskcc.cbio.portal.servlet.QueryBuilder;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -722,35 +723,43 @@ public static String getDbVersion() {
}

public static String getDarwinAuthCheckUrl() {
String darwinAuthUrl = properties.getProperty(DARWIN_AUTH_URL);
if (darwinAuthUrl == null || darwinAuthUrl.isEmpty()) {
return "";
String darwinAuthUrl = "";
try{
darwinAuthUrl = properties.getProperty(DARWIN_AUTH_URL).trim();
}
return darwinAuthUrl.trim();
catch (NullPointerException e){}

return darwinAuthUrl;
}

public static String getDarwinResponseUrl() {
String darwinResponseUrl = properties.getProperty(DARWIN_RESPONSE_URL);
if (darwinResponseUrl == null || darwinResponseUrl.isEmpty()) {
return "";
String darwinResponseUrl = "";
try{
darwinResponseUrl = properties.getProperty(DARWIN_RESPONSE_URL).trim();
}
return darwinResponseUrl.trim();
catch (NullPointerException e) {}

return darwinResponseUrl;
}

public static String getDarwinAuthority() {
String darwinAuthority = properties.getProperty(DARWIN_AUTHORITY);
if (darwinAuthority == null || darwinAuthority.isEmpty()) {
return "";
public static String getDarwinAuthority() {
String darwinAuthority = "";
try{
darwinAuthority = properties.getProperty(DARWIN_AUTHORITY).trim();
}
return darwinAuthority.trim();
catch (NullPointerException e) {}

return darwinAuthority;
}

public static String getCisUser() {
String cisUser = properties.getProperty(CIS_USER).trim();
if (cisUser == null || cisUser.isEmpty()) {
return "";
}
return cisUser;
String cisUser = "";
try{
cisUser = properties.getProperty(CIS_USER).trim();
}
catch (NullPointerException e) {}

return cisUser;
}

public static void main(String[] args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ function outputClinicalData() {
row += "</a></span><span id='topbar-cancer-study' style='text-align: right; float: right'>" + formatCancerStudyInfo(55)+ "</span>";
if (darwinAccessUrl !== null && darwinAccessUrl !== '') {
//add link to darwin
row += "&nbsp;<a target='_blank' href='"+darwinAccessUrl+"'><font color='green'><b>DARWIN</b></font></a>";
row += "&nbsp;<a target='_blank' href='"+darwinAccessUrl+"'><img src='images/darwin_logo.png'/></a>";
}
row += "<br />";
$("#clinical_div").append(row);
Expand Down
Binary file added portal/src/main/webapp/images/darwin_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 19c94bc

Please sign in to comment.