Skip to content

Commit

Permalink
Fix CacheMapUtil configurations (#10513)
Browse files Browse the repository at this point in the history
* Fix CacheMapUtil configurations

* fix InActiveCacheMapUtil

* Fix Oauth config
  • Loading branch information
haynescd authored Jan 5, 2024
1 parent 607e71a commit ed92a2b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@

package org.cbioportal.persistence.cachemaputil;

import java.util.Map;
import org.cbioportal.model.CancerStudy;
import org.cbioportal.model.MolecularProfile;
import org.cbioportal.model.SampleList;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
// This implementation of the CacheMapUtils is instantiated on portals where all uses can access any study.
@ConditionalOnProperty(name = "security.method_authorization_enabled", havingValue = "false", matchIfMissing = true)
public class InactiveCacheMapUtil implements CacheMapUtil {

// Since user-permission evaluation is not needed when this bean is present, throw an error when it is accessed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

import java.util.Map;

//@Component
@Component
// Instantiate when user authorization is active and spring-managed implementation is needed
@ConditionalOnExpression("${security.method_authorization_enabled:false} and ${cache.cache-map-utils.spring-managed:false}")
public class SpringManagedCacheMapUtil implements CacheMapUtil {

private static final Logger LOG = LoggerFactory.getLogger(SpringManagedCacheMapUtil.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
// Instantiate when user authorization is active and spring-managed implementation is not needed
@ConditionalOnExpression("${security.method_authorization_enabled:false} and !${cache.cache-map-utils.spring-managed:false}")
public class StaticRefCacheMapUtil implements CacheMapUtil {

private static final Logger LOG = LoggerFactory.getLogger(StaticRefCacheMapUtil.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class MethodSecurityConfig {
@Value("${always_show_study_group:}")
private String alwaysShowCancerStudyGroup;

@Qualifier("staticRefCacheMapUtil")
@Autowired
private CacheMapUtil cacheMapUtil;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.cbioportal.service.impl;

import java.util.stream.Collectors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.cbioportal.persistence.StudyRepository;
Expand All @@ -10,12 +9,12 @@
import org.cbioportal.service.CacheService;
import org.cbioportal.service.exception.CacheOperationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Component
public class CacheServiceImpl implements CacheService {
Expand All @@ -25,7 +24,6 @@ public class CacheServiceImpl implements CacheService {
@Autowired(required = false)
private CacheManager cacheManager;

@Qualifier("staticRefCacheMapUtil")
@Autowired
private CacheMapUtil cacheMapUtil;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@
package org.cbioportal.web.util;

import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.cbioportal.model.AlterationFilter;
Expand Down Expand Up @@ -76,17 +67,23 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.servlet.HandlerInterceptor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public class InvolvedCancerStudyExtractorInterceptor implements HandlerInterceptor {

@Autowired
private UniqueKeyExtractor uniqueKeyExtractor;

private ObjectMapper objectMapper = new ObjectMapper();

@Qualifier("staticRefCacheMapUtil")
@Autowired
private CacheMapUtil cacheMapUtil;

Expand Down

0 comments on commit ed92a2b

Please sign in to comment.