Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CacheMapUtil configurations #10513

Merged
merged 3 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
haynescd marked this conversation as resolved.
Show resolved Hide resolved
@Autowired
private CacheMapUtil cacheMapUtil;

Expand Down
Loading