Skip to content

Commit

Permalink
Fix bad request being returned for correct service type
Browse files Browse the repository at this point in the history
The partial index rebuild endpoint would return 400 for
valid service types. This fixes that, and also some
checkstyle issues.
  • Loading branch information
Arnei committed Aug 8, 2024
1 parent 975d985 commit c7db6c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,18 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -982,8 +993,8 @@ public void repopulate(DataType dataType) throws IndexRebuildException {
updatedEventData = getEventUpdateFunctionOnlyAcl(snapshot, orgId, snapshotSystemUser)
.apply(updatedEventData);
} else {
throw new IndexRebuildException(dataType + " is not a supported data type. " +
"Accepted values are " + Arrays.toString(getSupportedDataTypes()) + ".");
throw new IndexRebuildException(dataType + " is not a supported data type. "
+ "Accepted values are " + Arrays.toString(getSupportedDataTypes()) + ".");
}
updatedEventRange.add(updatedEventData.get());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public Response partiallyRebuildIndexByType(
IndexProducer indexProducer = indexRebuildService.getIndexProducer(service);

DataType dataType = EnumUtils.getEnum(DataType.class, dataTypeStr);
if (dataType == null || indexProducer.dataTypeSupported(dataType)) {
if (dataType == null || !indexProducer.dataTypeSupported(dataType)) {
return R.badRequest("The given path param for data type was invalid.");
}

Expand Down

0 comments on commit c7db6c4

Please sign in to comment.