Skip to content

Commit

Permalink
Remove Account.enforceGdpr obsolete field (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpanchyk authored May 4, 2020
1 parent 151c679 commit 0ac5a89
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ public Future<BidResponse> holdAuction(AuctionContext context) {
final List<SeatBid> storedResponse = new ArrayList<>();
final BidderAliases aliases = aliases(requestExt);
final String publisherId = account.getId();
final Boolean isGdprEnforced = account.getEnforceGdpr();
final ExtRequestTargeting targeting = targeting(requestExt);
final BidRequestCacheInfo cacheInfo = bidRequestCacheInfo(targeting, requestExt);
final boolean debugEnabled = isDebugEnabled(bidRequest, requestExt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public TcfDefinerService(GdprConfig gdprConfig,
this.tcf2Service = Objects.requireNonNull(tcf2Service);
this.eeaCountries = Objects.requireNonNull(eeaCountries);
this.geoLocationService = geoLocationService;
this.bidderCatalog = bidderCatalog;
this.bidderCatalog = Objects.requireNonNull(bidderCatalog);
this.metrics = Objects.requireNonNull(metrics);
}

Expand Down Expand Up @@ -130,7 +130,7 @@ private <T> Future<TcfResponse<T>> resultForInternal(
BiFunction<TCString, String, Future<TcfResponse<T>>> tcf2Strategy,
BiFunction<String, String, Future<TcfResponse<T>>> gdprStrategy) {

if (isGdprDisabled(gdprEnabled, accountGdprConfig)) {
if (!isGdprEnabled(accountGdprConfig)) {
return allowAllTcfResponseCreator.apply(null);
}

Expand All @@ -139,10 +139,10 @@ private <T> Future<TcfResponse<T>> resultForInternal(
dispatchToService(gdprInfoWithCountry, allowAllTcfResponseCreator, tcf2Strategy, gdprStrategy));
}

private boolean isGdprDisabled(Boolean gdprEnabled, AccountGdprConfig accountGdprConfig) {
private boolean isGdprEnabled(AccountGdprConfig accountGdprConfig) {
return accountGdprConfig != null && accountGdprConfig.getEnabled() != null
? BooleanUtils.isFalse(accountGdprConfig.getEnabled())
: BooleanUtils.isFalse(gdprEnabled);
? accountGdprConfig.getEnabled()
: gdprEnabled;
}

private Future<GdprInfoWithCountry<String>> toGdprInfo(
Expand Down Expand Up @@ -225,7 +225,7 @@ private <T> Future<TcfResponse<T>> createAllowAllTcfResponse(Set<T> keys, String
return Future.succeededFuture(TcfResponse.of(false, allowAll(keys), country));
}

private TcfResponse<Integer> createVendorIdTcfResponse(
private static TcfResponse<Integer> createVendorIdTcfResponse(
Collection<VendorPermission> vendorPermissions, String country) {

return TcfResponse.of(
Expand All @@ -237,7 +237,7 @@ private TcfResponse<Integer> createVendorIdTcfResponse(
country);
}

private TcfResponse<String> createBidderNameTcfResponse(
private static TcfResponse<String> createBidderNameTcfResponse(
Collection<VendorPermission> vendorPermissions, String country) {

return TcfResponse.of(
Expand All @@ -261,7 +261,9 @@ private Future<TcfResponse<String>> bidderNameResultFromGdpr(
.map(vendorPermissions -> gdprResponseToTcfResponse(vendorPermissions, bidderToVendorId, country));
}

private Map<String, Integer> resolveBidderToVendorId(Set<String> bidderNames, VendorIdResolver vendorIdResolver) {
private static Map<String, Integer> resolveBidderToVendorId(
Set<String> bidderNames, VendorIdResolver vendorIdResolver) {

final Map<String, Integer> bidderToVendorId = new HashMap<>();
bidderNames.forEach(bidderName -> bidderToVendorId.put(bidderName, vendorIdResolver.resolve(bidderName)));
return bidderToVendorId;
Expand Down Expand Up @@ -306,7 +308,7 @@ private static boolean inScope(GdprInfoWithCountry<?> gdprInfo) {
return Objects.equals(gdprInfo.getGdpr(), GDPR_ONE);
}

private TCString decodeTcString(GdprInfoWithCountry<String> gdprInfo) {
private static TCString decodeTcString(GdprInfoWithCountry<String> gdprInfo) {
try {
return TCString.decode(gdprInfo.getConsent());
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public JdbcApplicationSettings(JdbcClient jdbcClient,
@Override
public Future<Account> getAccountById(String accountId, Timeout timeout) {
return jdbcClient.executeQuery("SELECT uuid, price_granularity, banner_cache_ttl, video_cache_ttl,"
+ " events_enabled, enforce_gdpr, tcf_config, analytics_sampling_factor FROM accounts_account"
+ " events_enabled, tcf_config, analytics_sampling_factor FROM accounts_account"
+ " where uuid = ? LIMIT 1",
Collections.singletonList(accountId),
result -> mapToModelOrError(result, row -> Account.builder()
Expand All @@ -106,9 +106,8 @@ public Future<Account> getAccountById(String accountId, Timeout timeout) {
.bannerCacheTtl(row.getInteger(2))
.videoCacheTtl(row.getInteger(3))
.eventsEnabled(row.getBoolean(4))
.enforceGdpr(row.getBoolean(5))
.gdpr(toAccountTcfConfig(row.getString(6)))
.analyticsSamplingFactor(row.getInteger(7))
.gdpr(toAccountTcfConfig(row.getString(5)))
.analyticsSamplingFactor(row.getInteger(6))
.build()),
timeout)
.compose(result -> failedIfNull(result, accountId, "Account"));
Expand Down Expand Up @@ -149,6 +148,14 @@ private static <T> Future<T> failedIfNull(T value, String id, String errorPrefix
: Future.failedFuture(new PreBidException(String.format("%s not found: %s", errorPrefix, id)));
}

private AccountGdprConfig toAccountTcfConfig(String tcfConfig) {
try {
return tcfConfig != null ? mapper.decodeValue(tcfConfig, AccountGdprConfig.class) : null;
} catch (DecodeException e) {
throw new PreBidException(e.getMessage());
}
}

/**
* Runs a process to get stored requests by a collection of ids from database
* and returns {@link Future&lt;{@link StoredDataResult }&gt;}.
Expand Down Expand Up @@ -237,12 +244,4 @@ private static String parameterHolders(int paramsSize) {
? "NULL"
: IntStream.range(0, paramsSize).mapToObj(i -> "?").collect(Collectors.joining(","));
}

private AccountGdprConfig toAccountTcfConfig(String tcfConfig) {
try {
return tcfConfig != null ? mapper.decodeValue(tcfConfig, AccountGdprConfig.class) : null;
} catch (DecodeException e) {
throw new PreBidException(e.getMessage());
}
}
}
3 changes: 0 additions & 3 deletions src/main/java/org/prebid/server/settings/model/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public class Account {

Boolean eventsEnabled;

Boolean enforceGdpr;

AccountGdprConfig gdpr;

Integer analyticsSamplingFactor;
Expand All @@ -29,4 +27,3 @@ public static Account empty(String id) {
.build();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public void getAccountByIdShouldReturnPresentAccount() {
+ "bannerCacheTtl: '100',"
+ "videoCacheTtl : '100',"
+ "eventsEnabled: 'true',"
+ "enforceGdpr: 'true',"
+ "gdpr: {"
+ "enabled: true,"
+ "purposes: {"
Expand Down Expand Up @@ -109,7 +108,6 @@ public void getAccountByIdShouldReturnPresentAccount() {
.bannerCacheTtl(100)
.videoCacheTtl(100)
.eventsEnabled(true)
.enforceGdpr(true)
.gdpr(AccountGdprConfig.builder()
.enabled(true)
.purposes(Purposes.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public static void beforeClass() throws SQLException {
connection = DriverManager.getConnection(JDBC_URL);
connection.createStatement().execute("CREATE TABLE accounts_account (id SERIAL PRIMARY KEY, "
+ "uuid varchar(40) NOT NULL, price_granularity varchar(6), granularityMultiplier numeric(9,3), "
+ "banner_cache_ttl INT, video_cache_ttl INT, events_enabled BIT, enforce_gdpr BIT, "
+ "tcf_config varchar(512), analytics_sampling_factor INT);");
+ "banner_cache_ttl INT, video_cache_ttl INT, events_enabled BIT, tcf_config varchar(512), "
+ "analytics_sampling_factor INT);");
connection.createStatement().execute("CREATE TABLE s2sconfig_config (id SERIAL PRIMARY KEY, uuid varchar(40) "
+ "NOT NULL, config varchar(512));");
connection.createStatement().execute("CREATE TABLE stored_requests (id SERIAL PRIMARY KEY, reqid varchar(40) "
Expand All @@ -116,9 +116,9 @@ public static void beforeClass() throws SQLException {
connection.createStatement().execute("CREATE TABLE one_column_table (id SERIAL PRIMARY KEY, reqid varchar(40)"
+ " NOT NULL);");
connection.createStatement().execute("insert into accounts_account "
+ "(uuid, price_granularity, banner_cache_ttl, video_cache_ttl, events_enabled, enforce_gdpr, "
+ "tcf_config, analytics_sampling_factor)"
+ " values ('accountId','med', 100, 100, TRUE, TRUE, '{\"enabled\": true}', 1);");
+ "(uuid, price_granularity, banner_cache_ttl, video_cache_ttl, events_enabled, tcf_config, "
+ "analytics_sampling_factor)"
+ " values ('accountId','med', 100, 100, TRUE, '{\"enabled\": true}', 1);");
connection.createStatement().execute("insert into s2sconfig_config (uuid, config)"
+ " values ('adUnitConfigId', 'config');");
connection.createStatement().execute("insert into stored_requests (reqid, requestData) values ('1','value1');");
Expand Down Expand Up @@ -169,7 +169,6 @@ public void getAccountByIdShouldReturnAccountWithAllFieldsPopulated(TestContext
.videoCacheTtl(100)
.analyticsSamplingFactor(1)
.eventsEnabled(true)
.enforceGdpr(true)
.gdpr(AccountGdprConfig.builder()
.enabled(true)
.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ accounts:
- id: 2763
- id: 5001
eventsEnabled: true
enforceGdpr: true
configs:
- id: 14062
config: >
Expand Down

0 comments on commit 0ac5a89

Please sign in to comment.