Skip to content

Commit

Permalink
Merge release into master branch (#3371)
Browse files Browse the repository at this point in the history
  • Loading branch information
wb36499 authored Feb 4, 2025
2 parents 31abc0e + d7b1b59 commit 48747a8
Show file tree
Hide file tree
Showing 71 changed files with 1,809 additions and 798 deletions.
2 changes: 1 addition & 1 deletion NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ and their licenses, below. For information on the dependencies of these dependen
projects below.


Koryphe (uk.gov.gchq.koryphe:koryphe:2.5.2):
Koryphe (uk.gov.gchq.koryphe:koryphe:2.6.0):

- Apache License, Version 2.0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 Crown Copyright
* Copyright 2020-2025 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 All @@ -21,9 +21,11 @@
import uk.gov.gchq.koryphe.Summary;
import uk.gov.gchq.koryphe.predicate.KoryphePredicate;

import java.io.Serializable;

@Since("1.13.1")
@Summary("Predicate which never allows user access")
public class NoAccessUserPredicate extends KoryphePredicate<User> {
public class NoAccessUserPredicate extends KoryphePredicate<User> implements Serializable {
@Override
public boolean test(final User user) {
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 Crown Copyright
* Copyright 2020-2025 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 All @@ -13,16 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package uk.gov.gchq.gaffer.access.predicate.user;

import uk.gov.gchq.gaffer.user.User;
import uk.gov.gchq.koryphe.Since;
import uk.gov.gchq.koryphe.Summary;
import uk.gov.gchq.koryphe.predicate.KoryphePredicate;

import java.io.Serializable;

@Since("1.13.1")
@Summary("A predicate which always allows a user access")
public class UnrestrictedAccessUserPredicate extends KoryphePredicate<User> {
public class UnrestrictedAccessUserPredicate extends KoryphePredicate<User> implements Serializable {
@Override
public boolean test(final User user) {
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Crown Copyright
* Copyright 2024-2025 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 All @@ -25,6 +25,7 @@ public final class OtelUtil {
public static final String JOB_ID_ATTRIBUTE = "gaffer.jobId";
public static final String GRAPH_ID_ATTRIBUTE = "gaffer.graphId";
public static final String VIEW_ATTRIBUTE = "gaffer.view";
public static final String OP_OPTIONS_ATTRIBUTE = "gaffer.operation.options";
public static final String GREMLIN_QUERY_ATTRIBUTE = "gaffer.gremlin.query";

private static boolean openTelemetryActive = false;
Expand Down
5 changes: 3 additions & 2 deletions core/graph/src/main/java/uk/gov/gchq/gaffer/graph/Graph.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2024 Crown Copyright
* Copyright 2017-2025 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 @@ -320,10 +320,11 @@ private <O> GraphResult<O> _execute(final StoreExecuter<O> storeExecuter, final
// OpenTelemetry hooks
Span span = OtelUtil.startSpan(
this.getClass().getName(),
"Graph Request: " + clonedOpChain.toOverviewString());
"Graph Request: " + clonedContext.getJobId());
span.setAttribute(OtelUtil.GRAPH_ID_ATTRIBUTE, getGraphId());
span.setAttribute(OtelUtil.JOB_ID_ATTRIBUTE, clonedContext.getJobId());
span.setAttribute(OtelUtil.USER_ATTRIBUTE, clonedContext.getUser().getUserId());
span.setAttribute(OtelUtil.OP_OPTIONS_ATTRIBUTE, clonedOpChain.getOptions().toString());

O result = null;
// Sets the span to current so parent child spans are auto linked
Expand Down
78 changes: 33 additions & 45 deletions core/graph/src/test/java/uk/gov/gchq/gaffer/graph/GraphTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2024 Crown Copyright
* Copyright 2016-2025 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 @@ -342,7 +342,7 @@ public void shouldCreateNewContextInstanceWhenExecuteOperation(@Mock final Store

@Test
public void shouldCreateNewContextInstanceWhenExecuteOutputOperation(@Mock final Store store)
throws OperationException, IOException {
throws OperationException {
// Given
final Schema schema = new Schema();
given(store.getProperties()).willReturn(new StoreProperties());
Expand All @@ -365,7 +365,7 @@ public void shouldCreateNewContextInstanceWhenExecuteOutputOperation(@Mock final

@Test
public void shouldCreateNewContextInstanceWhenExecuteJob(@Mock final Store store)
throws OperationException, IOException {
throws OperationException {
// Given
final Schema schema = new Schema();
given(store.getProperties()).willReturn(new StoreProperties());
Expand Down Expand Up @@ -1065,7 +1065,7 @@ public void shouldNotSetGraphViewOnOperationWhenOperationIsNotAGet(@Mock final S
}

@Test
public void shouldThrowExceptionIfStoreClassPropertyIsNotSet() throws OperationException {
public void shouldThrowExceptionIfStoreClassPropertyIsNotSet() {
try {
new Graph.Builder()
.config(new GraphConfig.Builder()
Expand Down Expand Up @@ -1097,15 +1097,10 @@ public void shouldThrowExceptionIfGraphIdIsMissing() {
}

@Test
public void shouldThrowExceptionIfSchemaIsInvalid() throws OperationException {
public void shouldThrowExceptionIfSchemaIsInvalid() {
final StoreProperties storeProperties = new StoreProperties();
storeProperties.setStoreClass(TestStoreImpl.class.getName());
try {
new Graph.Builder()
.config(new GraphConfig.Builder()
.graphId(GRAPH_ID)
.build())
.addSchema(new Schema.Builder()
final Schema invalidSchema = new Schema.Builder()
.type("int", new TypeDefinition.Builder()
.clazz(Integer.class)
.aggregateFunction(new Sum())
Expand All @@ -1126,13 +1121,17 @@ public void shouldThrowExceptionIfSchemaIsInvalid() throws OperationException {
.vertex("string")
.property("p2", "int")
.build())
.build())
.build();
final GraphConfig config = new GraphConfig.Builder()
.graphId(GRAPH_ID)
.build();
assertThatExceptionOfType(SchemaException.class)
.isThrownBy(() -> new Graph.Builder()
.config(config)
.addSchema(invalidSchema)
.storeProperties(storeProperties)
.build();
fail("exception expected");
} catch (final SchemaException e) {
assertNotNull(e.getMessage());
}
.build())
.withMessageContaining("Schema is not valid");
}

@Test
Expand Down Expand Up @@ -1254,7 +1253,7 @@ private void writeToFile(final String schemaFile, final File dir) throws IOExcep
}

@Test
public void shouldThrowExceptionIfGraphIdIsInvalid(@Mock final StoreProperties properties) throws Exception {
void shouldThrowExceptionIfGraphIdIsInvalid(@Mock final StoreProperties properties) {
try {
new Graph.Builder()
.config(new GraphConfig.Builder()
Expand Down Expand Up @@ -1355,8 +1354,7 @@ public void shouldBuildGraphUsingGraphIdAndLookupSchema() throws Exception {

@Test
public void shouldAddHooksVarArgsAndGetGraphHooks(@Mock final GraphHook graphHook1,
@Mock final Log4jLogger graphHook2)
throws Exception {
@Mock final Log4jLogger graphHook2) {
// Given
final StoreProperties storeProperties = new StoreProperties();
storeProperties.setStoreClass(TestStoreImpl.class.getName());
Expand All @@ -1382,8 +1380,7 @@ public void shouldAddHooksVarArgsAndGetGraphHooks(@Mock final GraphHook graphHoo

@Test
public void shouldAddHookAndGetGraphHooks(@Mock final GraphHook graphHook1,
@Mock final Log4jLogger graphHook3)
throws Exception {
@Mock final Log4jLogger graphHook3) {
// Given
final StoreProperties storeProperties = new StoreProperties();
storeProperties.setStoreClass(TestStore.class.getName());
Expand Down Expand Up @@ -1417,8 +1414,7 @@ public void shouldAddHookAndGetGraphHooks(@Mock final GraphHook graphHook1,

@Test
public void shouldAddNamedViewResolverHookAfterNamedOperationResolver(@Mock final GraphHook graphHook1,
@Mock final Log4jLogger graphHook2)
throws Exception {
@Mock final Log4jLogger graphHook2) {
// Given
final StoreProperties storeProperties = new StoreProperties();
storeProperties.setStoreClass(TestStore.class.getName());
Expand Down Expand Up @@ -1511,7 +1507,7 @@ public void shouldAddHookFromPathAndGetGraphHooks() throws Exception {
}

@Test
public void shouldBuildGraphFromConfigFile() throws Exception {
void shouldBuildGraphFromConfigFile() {
// Given
final StoreProperties storeProperties = new StoreProperties();
storeProperties.setStoreClass(TestStoreImpl.class.getName());
Expand Down Expand Up @@ -1541,8 +1537,7 @@ public void shouldBuildGraphFromConfigFile() throws Exception {

@Test
public void shouldBuildGraphFromConfigAndMergeConfigWithExistingConfig(@Mock final GraphLibrary library1, @Mock final GraphLibrary library2,
@Mock final GraphHook hook1, @Mock final GraphHook hook2, @Mock final GraphHook hook3)
throws Exception {
@Mock final GraphHook hook1, @Mock final GraphHook hook2, @Mock final GraphHook hook3) {
// Given
final StoreProperties storeProperties = new StoreProperties();
storeProperties.setStoreClass(TestStoreImpl.class.getName());
Expand Down Expand Up @@ -1591,8 +1586,7 @@ public void shouldBuildGraphFromConfigAndMergeConfigWithExistingConfig(@Mock fin

@Test
public void shouldBuildGraphFromConfigAndOverrideFields(@Mock final GraphLibrary library1, @Mock final GraphLibrary library2,
@Mock final GraphHook hook1, @Mock final GraphHook hook2, @Mock final GraphHook hook3)
throws Exception {
@Mock final GraphHook hook1, @Mock final GraphHook hook2, @Mock final GraphHook hook3) {
// Given
final StoreProperties storeProperties = new StoreProperties();
storeProperties.setStoreClass(TestStoreImpl.class.getName());
Expand Down Expand Up @@ -1642,7 +1636,7 @@ public void shouldBuildGraphFromConfigAndOverrideFields(@Mock final GraphLibrary
}

@Test
public void shouldReturnClonedViewFromConfig() throws Exception {
void shouldReturnClonedViewFromConfig() {
// Given
final StoreProperties storeProperties = new StoreProperties();
storeProperties.setStoreClass(TestStoreImpl.class.getName());
Expand Down Expand Up @@ -1840,8 +1834,7 @@ public void shouldCorrectlySetViewForNestedOperationChain() throws OperationExce
}

@Test
public void shouldThrowExceptionOnExecuteWithANullContext(@Mock final OperationChain opChain)
throws OperationException {
void shouldThrowExceptionOnExecuteWithANullContext(@Mock final OperationChain opChain) {
// Given
final Context context = null;

Expand All @@ -1860,8 +1853,7 @@ public void shouldThrowExceptionOnExecuteWithANullContext(@Mock final OperationC
}

@Test
public void shouldThrowExceptionOnExecuteJobWithANullContext(@Mock final OperationChain opChain)
throws OperationException {
void shouldThrowExceptionOnExecuteJobWithANullContext(@Mock final OperationChain opChain) {
// Given
final Context context = null;

Expand All @@ -1880,8 +1872,7 @@ public void shouldThrowExceptionOnExecuteJobWithANullContext(@Mock final Operati
}

@Test
public void shouldThrowExceptionOnExecuteWithANullUser(@Mock final OperationChain opChain)
throws OperationException {
void shouldThrowExceptionOnExecuteWithANullUser(@Mock final OperationChain opChain) {
// Given
final User user = null;

Expand All @@ -1900,8 +1891,7 @@ public void shouldThrowExceptionOnExecuteWithANullUser(@Mock final OperationChai
}

@Test
public void shouldThrowExceptionOnExecuteJobWithANullUser(@Mock final OperationChain opChain)
throws OperationException {
void shouldThrowExceptionOnExecuteJobWithANullUser(@Mock final OperationChain opChain) {
// Given
final User user = null;

Expand All @@ -1920,8 +1910,7 @@ public void shouldThrowExceptionOnExecuteJobWithANullUser(@Mock final OperationC
}

@Test
public void shouldThrowExceptionOnExecuteJobUsingJobWithANullContext(@Mock final OperationChain opChain)
throws OperationException {
void shouldThrowExceptionOnExecuteJobUsingJobWithANullContext(@Mock final OperationChain opChain) {
// Given
final Context context = null;

Expand All @@ -1942,7 +1931,7 @@ public void shouldThrowExceptionOnExecuteJobUsingJobWithANullContext(@Mock final
}

@Test
public void shouldThrowExceptionOnExecuteJobUsingJobWithANullOperation() throws OperationException {
void shouldThrowExceptionOnExecuteJobUsingJobWithANullOperation() {
// Given
final Context context = new Context();

Expand All @@ -1963,7 +1952,7 @@ public void shouldThrowExceptionOnExecuteJobUsingJobWithANullOperation() throws
}

@Test
public void shouldThrowExceptionOnExecuteJobUsingJobWithANullJob() throws OperationException {
void shouldThrowExceptionOnExecuteJobUsingJobWithANullJob() {
// Given
final Context context = new Context();

Expand All @@ -1984,8 +1973,7 @@ public void shouldThrowExceptionOnExecuteJobUsingJobWithANullJob() throws Operat
}

@Test
public void shouldThrowExceptionOnExecuteJobUsingJobWithANullUser(@Mock final OperationChain opChain)
throws OperationException {
void shouldThrowExceptionOnExecuteJobUsingJobWithANullUser(@Mock final OperationChain opChain) {
// Given
final User user = null;

Expand Down Expand Up @@ -2744,7 +2732,7 @@ protected OperationHandler<? extends AddElements> getAddElementsHandler() {
}

@Override
protected OperationHandler<? extends DeleteElements> getDeleteElementsHandler() {
protected OutputOperationHandler<DeleteElements, Long> getDeleteElementsHandler() {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2024 Crown Copyright
* Copyright 2016-2025 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 @@ -86,7 +86,7 @@ protected OperationHandler<? extends AddElements> getAddElementsHandler() {
}

@Override
protected OperationHandler<? extends DeleteElements> getDeleteElementsHandler() {
protected OutputOperationHandler<DeleteElements, Long> getDeleteElementsHandler() {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2023 Crown Copyright
* Copyright 2017-2025 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 @@ -41,6 +41,7 @@
import uk.gov.gchq.koryphe.ValidationResult;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
Expand Down Expand Up @@ -153,6 +154,11 @@ public ValidationResult validate() {
return result;
}

@Override
public List<Operation> flatten() {
return Arrays.asList(this);
}

@JsonIgnore
public int getNumberOfGetEdgeOperations() {
return getNumberOfGetEdgeOperations(operations);
Expand All @@ -166,7 +172,7 @@ private int getNumberOfGetEdgeOperations(final Operation op) {
hops += getNumberOfGetEdgeOperations(((Operations<?>) op).getOperations());
} else if (op instanceof GetElements) {
final GetElements getElements = (GetElements) op;
if (null != getElements.getView() && getElements.getView().hasEdges()) {
if (null != getElements.getView() && (getElements.getView().hasEdges() || getElements.getView().isAllEdges())) {
hops += 1;
}
}
Expand All @@ -187,7 +193,7 @@ private int getNumberOfGetEdgeOperationsWithoutRepeats(final Operation op) {
hops += getNumberOfGetEdgeOperationsWithoutRepeats(((Operations<?>) op).getOperations());
} else if (op instanceof GetElements) {
final GetElements getElements = (GetElements) op;
if (null != getElements.getView() && getElements.getView().hasEdges()) {
if (null != getElements.getView() && (getElements.getView().hasEdges() || getElements.getView().isAllEdges())) {
hops += 1;
}
}
Expand Down
Loading

0 comments on commit 48747a8

Please sign in to comment.