Skip to content

Commit

Permalink
gh-2705: Cherry pick new spring endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
t92549 committed Jul 11, 2022
1 parent 1f8b743 commit ab54847
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 Crown Copyright
* Copyright 2020-2022 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,6 +31,7 @@
import uk.gov.gchq.gaffer.rest.model.OperationDetail;
import uk.gov.gchq.gaffer.store.Context;
import uk.gov.gchq.koryphe.serialisation.json.SimpleClassNameIdResolver;
import uk.gov.gchq.koryphe.util.ReflectionUtil;

import java.util.HashSet;
import java.util.Set;
Expand All @@ -53,10 +54,19 @@ public Set<Class <? extends Operation>> getSupportedOperations() {
}

public Set<OperationDetail> getSupportedOperationDetails() {
Set<Class<? extends Operation>> supportedOperationClasses = getSupportedOperations();
return getSupportedOperationDetails(false);
}

public Set<OperationDetail> getSupportedOperationDetails(final boolean includeUnsupported) {
Set<Class<? extends Operation>> operationClasses;
if (includeUnsupported) {
operationClasses = new HashSet(ReflectionUtil.getSubTypes(Operation.class));
} else {
operationClasses = getSupportedOperations();
}
Set<OperationDetail> operationDetails = new HashSet<>();

for (final Class<? extends Operation> clazz : supportedOperationClasses) {
for (final Class<? extends Operation> clazz : operationClasses) {
try {
operationDetails.add(new OperationDetail(clazz, getNextOperations(clazz), generateExampleJson(clazz)));
} catch (final IllegalAccessException | InstantiationException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ public interface IOperationController {
)
Set<OperationDetail> getAllOperationDetails();

@RequestMapping(
method = GET,
path = "/details/all",
produces = APPLICATION_JSON_VALUE
)
@ApiOperation(
value = "Returns the details of every operation",
response = OperationDetail.class,
responseContainer = "Set"
)
Set<OperationDetail> getAllOperationDetailsIncludingUnsupported();

@RequestMapping(
method = GET,
value = "{className}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public Set<OperationDetail> getAllOperationDetails() {
return getSupportedOperationDetails();
}

@Override
public Set<OperationDetail> getAllOperationDetailsIncludingUnsupported() {
return getSupportedOperationDetails(true);
}

@Override
public OperationDetail getOperationDetails(@PathVariable("className") @ApiParam(name = "className", value = "The Operation class") final String className) {
try {
Expand Down

0 comments on commit ab54847

Please sign in to comment.