Skip to content

Commit

Permalink
Changes related to download group
Browse files Browse the repository at this point in the history
  • Loading branch information
kalletlak committed Jul 19, 2023
1 parent a3794f7 commit 22efd9c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
42 changes: 30 additions & 12 deletions core/src/main/java/org/mskcc/cbio/portal/util/GlobalProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@
import java.util.List;
import java.util.Properties;

import org.apache.commons.lang.StringUtils;
import org.cbioportal.security.spring.authentication.PortalUserDetails;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import org.springframework.util.ResourceUtils;
Expand Down Expand Up @@ -362,6 +364,10 @@ public static String parseUrl(String url)
@Value("${frontend.url.runtime:}")
public void setFrontendUrlRuntime(String property) { frontendUrlRuntime = property; }

private static String downloadGroup;
@Value("${download_group:}") // default is empty string
public void setDownloadGroup(String property) { downloadGroup = property; }

private static Logger LOG = LoggerFactory.getLogger(GlobalProperties.class);
private static ConfigPropertyResolver portalProperties = new ConfigPropertyResolver();
private static Properties mavenProperties = initializeProperties(MAVEN_PROPERTIES_FILE_NAME);
Expand Down Expand Up @@ -1264,18 +1270,30 @@ public static String getOncoKbToken() {
}

public static String getDownloadControl() {
String downloadControlOption = getProperty("skin.hide_download_controls");
/*
skin.hide_download_controls return_value
true hide
false show
data data
null/empty show
*/
switch ((downloadControlOption != null) ? downloadControlOption.trim().toLowerCase() : "false") {
case "true" : return "hide";
case "data" : return "data";
default: return "show";
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

if (authentication != null &&
StringUtils.isNotEmpty(downloadGroup) &&
authentication.getAuthorities().contains(new SimpleGrantedAuthority(downloadGroup))) {
return "show";
} else {
String downloadControlOption = getProperty("skin.hide_download_controls");
/*
skin.hide_download_controls return_value
true hide
false show
data data
null/empty show
*/
switch ((downloadControlOption != null) ? downloadControlOption.trim().toLowerCase() : "false") {
case "true":
return "hide";
case "data":
return "data";
case "false":
default:
return "show";
}
}
}
}
2 changes: 1 addition & 1 deletion portal/src/main/webapp/config_service.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
obj.put("oncoKbTokenDefined", !StringUtils.isEmpty(GlobalProperties.getOncoKbToken()));
obj.put("sessionServiceEnabled", !StringUtils.isEmpty(GlobalProperties.getSessionServiceUrl()));
obj.put("skin_hide_download_controls", GlobalProperties.getDownloadControl());
out.println(obj.toJSONString());
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/portal.properties.EXAMPLE
Original file line number Diff line number Diff line change
Expand Up @@ -433,4 +433,6 @@ persistence.cache_type=no-cache

# Set StudyDownloadLinkUrl
# Allows download links within DataSets Tab (See Portal.Properties documentation for more info)
# study_download_url=
# study_download_url=

# download_group=

0 comments on commit 22efd9c

Please sign in to comment.