Skip to content

Commit 9610899

Browse files
committed
Refactor
1 parent 6975689 commit 9610899

3 files changed

Lines changed: 17 additions & 29 deletions

File tree

src/main/java/org/prebid/server/settings/CachingApplicationSettings.java

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public Future<StoredDataResult<String>> getStoredData(String accountId,
127127
Set<String> impIds,
128128
Timeout timeout) {
129129

130-
return getStoredDataFromCacheOrDelegate(cache, accountId, requestIds, impIds, timeout, delegate::getStoredData);
130+
return getFromCacheOrDelegate(cache, accountId, requestIds, impIds, timeout, delegate::getStoredData);
131131
}
132132

133133
@Override
@@ -136,8 +136,7 @@ public Future<StoredDataResult<String>> getAmpStoredData(String accountId,
136136
Set<String> impIds,
137137
Timeout timeout) {
138138

139-
return getStoredDataFromCacheOrDelegate(
140-
ampCache, accountId, requestIds, impIds, timeout, delegate::getAmpStoredData);
139+
return getFromCacheOrDelegate(ampCache, accountId, requestIds, impIds, timeout, delegate::getAmpStoredData);
141140
}
142141

143142
@Override
@@ -146,8 +145,7 @@ public Future<StoredDataResult<String>> getVideoStoredData(String accountId,
146145
Set<String> impIds,
147146
Timeout timeout) {
148147

149-
return getStoredDataFromCacheOrDelegate(
150-
videoCache, accountId, requestIds, impIds, timeout, delegate::getVideoStoredData);
148+
return getFromCacheOrDelegate(videoCache, accountId, requestIds, impIds, timeout, delegate::getVideoStoredData);
151149
}
152150

153151
@Override
@@ -156,16 +154,15 @@ public Future<StoredDataResult<Profile>> getProfiles(String accountId,
156154
Set<String> impIds,
157155
Timeout timeout) {
158156

159-
return getStoredDataFromCacheOrDelegate(
160-
profileCache, accountId, requestIds, impIds, timeout, delegate::getProfiles);
157+
return getFromCacheOrDelegate(profileCache, accountId, requestIds, impIds, timeout, delegate::getProfiles);
161158
}
162159

163-
private static <T> Future<StoredDataResult<T>> getStoredDataFromCacheOrDelegate(SettingsCache<T> cache,
164-
String accountId,
165-
Set<String> requestIds,
166-
Set<String> impIds,
167-
Timeout timeout,
168-
StoredDataFetcher<T> retriever) {
160+
private static <T> Future<StoredDataResult<T>> getFromCacheOrDelegate(SettingsCache<T> cache,
161+
String accountId,
162+
Set<String> requestIds,
163+
Set<String> impIds,
164+
Timeout timeout,
165+
StoredDataFetcher<T> retriever) {
169166

170167
// empty string account ID doesn't make sense
171168
final String normalizedAccountId = StringUtils.stripToNull(accountId);
@@ -174,11 +171,11 @@ private static <T> Future<StoredDataResult<T>> getStoredDataFromCacheOrDelegate(
174171
final Map<String, Set<StoredItem<T>>> impCache = cache.getImpCache();
175172

176173
final Set<String> missedRequestIds = new HashSet<>();
177-
final Map<String, T> storedIdToRequest = getStoredDataFromCacheOrAddMissedIds(
174+
final Map<String, T> storedIdToRequest = getFromCacheOrAddMissedIds(
178175
normalizedAccountId, requestIds, requestCache, missedRequestIds);
179176

180177
final Set<String> missedImpIds = new HashSet<>();
181-
final Map<String, T> storedIdToImp = getStoredDataFromCacheOrAddMissedIds(
178+
final Map<String, T> storedIdToImp = getFromCacheOrAddMissedIds(
182179
normalizedAccountId, impIds, impCache, missedImpIds);
183180

184181
if (missedRequestIds.isEmpty() && missedImpIds.isEmpty()) {
@@ -209,10 +206,10 @@ private static <T> Future<StoredDataResult<T>> getStoredDataFromCacheOrDelegate(
209206
});
210207
}
211208

212-
private static <T> Map<String, T> getStoredDataFromCacheOrAddMissedIds(String accountId,
213-
Set<String> ids,
214-
Map<String, Set<StoredItem<T>>> cache,
215-
Set<String> missedIds) {
209+
private static <T> Map<String, T> getFromCacheOrAddMissedIds(String accountId,
210+
Set<String> ids,
211+
Map<String, Set<StoredItem<T>>> cache,
212+
Set<String> missedIds) {
216213

217214
final Map<String, T> idToStoredItem = new HashMap<>(ids.size());
218215

src/main/java/org/prebid/server/settings/helper/StoredItemResolver.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ private StoredItemResolver() {
3131
* <p>
3232
* - Otherwise, reject stored item as if there hadn't been match.
3333
*/
34-
public static <T> StoredItem<T> resolve(String type,
35-
String accountId,
36-
String id,
37-
Set<StoredItem<T>> storedItems) {
38-
34+
public static <T> StoredItem<T> resolve(String type, String accountId, String id, Set<StoredItem<T>> storedItems) {
3935
if (CollectionUtils.isEmpty(storedItems)) {
4036
throw new PreBidException("No stored %s found for id: %s".formatted(type, id));
4137
}

src/main/java/org/prebid/server/settings/model/AccountProfilesConfig.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ public class AccountProfilesConfig {
88

99
Integer limit;
1010

11-
// TODO: need confirmation to move property
12-
// TODO: Decide
13-
// - skip all profiles on any invalid
14-
// - skip only invalid
15-
// TODO: metrics
1611
@JsonAlias("fail-on-unknown")
1712
Boolean failOnUnknown;
1813
}

0 commit comments

Comments
 (0)