diff --git a/core/store/src/main/java/uk/gov/gchq/gaffer/store/Store.java b/core/store/src/main/java/uk/gov/gchq/gaffer/store/Store.java index 68deb0d403b..fd424247754 100644 --- a/core/store/src/main/java/uk/gov/gchq/gaffer/store/Store.java +++ b/core/store/src/main/java/uk/gov/gchq/gaffer/store/Store.java @@ -199,7 +199,6 @@ */ public abstract class Store { private static final Logger LOGGER = LoggerFactory.getLogger(Store.class); - public static final String ADD_GRAPH_DECLARATIONS = "gaffer.federatedstore.addgraph.declarations"; private final Class requiredParentSerialiserClass; private final Map, OperationHandler> operationHandlers = new LinkedHashMap<>(); protected final List opChainOptimisers = new ArrayList<>(); @@ -1102,15 +1101,6 @@ private void addConfiguredOperationHandlers() { addOperationHandler(definition.getOperation(), definition.getHandler()); } } - - if (properties.containsKey(ADD_GRAPH_DECLARATIONS)) { - final String json = properties.get(ADD_GRAPH_DECLARATIONS); - final OperationDeclarations operationDeclarations = OperationDeclarations.fromJson(json); - for (final OperationDeclaration definition : operationDeclarations.getOperations()) { - addOperationHandler(definition.getOperation(), definition.getHandler()); - } - } - } protected void startCacheServiceLoader(final StoreProperties properties) { diff --git a/core/store/src/main/java/uk/gov/gchq/gaffer/store/StoreProperties.java b/core/store/src/main/java/uk/gov/gchq/gaffer/store/StoreProperties.java index 90c4f77c7b6..e49391e98fc 100644 --- a/core/store/src/main/java/uk/gov/gchq/gaffer/store/StoreProperties.java +++ b/core/store/src/main/java/uk/gov/gchq/gaffer/store/StoreProperties.java @@ -61,6 +61,7 @@ public class StoreProperties implements Cloneable { public static final String STORE_PROPERTIES_CLASS = "gaffer.store.properties.class"; public static final String OPERATION_DECLARATIONS = "gaffer.store.operation.declarations"; + public static final String OPERATION_DECLARATIONS_JSON = "gaffer.store.operation.declarations.json"; public static final String JOB_TRACKER_ENABLED = "gaffer.store.job.tracker.enabled"; @@ -275,18 +276,21 @@ public void merge(final StoreProperties properties) { */ @JsonIgnore public OperationDeclarations getOperationDeclarations() { - OperationDeclarations declarations = null; + OperationDeclarations.Builder declarations = new OperationDeclarations.Builder(); final String declarationsPaths = get(StoreProperties.OPERATION_DECLARATIONS); if (null != declarationsPaths) { - declarations = OperationDeclarations.fromPaths(declarationsPaths); + OperationDeclarations.fromPaths(declarationsPaths).getOperations() + .forEach(d -> declarations.declaration(d)); } - if (null == declarations) { - declarations = new OperationDeclarations.Builder().build(); + if (containsKey(OPERATION_DECLARATIONS_JSON)) { + final String json = get(OPERATION_DECLARATIONS_JSON); + OperationDeclarations.fromJson(json).getOperations() + .forEach(d -> declarations.declaration(d)); } - return declarations; + return declarations.build(); } public String getStoreClass() { diff --git a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedAddGraphHandlerTest.java b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedAddGraphHandlerTest.java index 81693f6bd92..879e24768b3 100644 --- a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedAddGraphHandlerTest.java +++ b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedAddGraphHandlerTest.java @@ -61,7 +61,7 @@ import static uk.gov.gchq.gaffer.federatedstore.FederatedGraphStorage.USER_IS_ATTEMPTING_TO_OVERWRITE; import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.SCHEMA_EDGE_BASIC_JSON; import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.loadSchemaFromJson; -import static uk.gov.gchq.gaffer.store.Store.ADD_GRAPH_DECLARATIONS; +import static uk.gov.gchq.gaffer.store.StoreProperties.OPERATION_DECLARATIONS_JSON; import static uk.gov.gchq.gaffer.user.StoreUser.authUser; import static uk.gov.gchq.gaffer.user.StoreUser.blankUser; import static uk.gov.gchq.gaffer.user.StoreUser.testUser; @@ -443,7 +443,7 @@ public void shouldAddGraphWithHandler() throws Exception { final AccumuloProperties clone = PROPERTIES.clone(); - clone.set(ADD_GRAPH_DECLARATIONS, new String(JSONSerialiser.serialise(new OperationDeclarations.Builder() + clone.set(OPERATION_DECLARATIONS_JSON, new String(JSONSerialiser.serialise(new OperationDeclarations.Builder() .declaration(new OperationDeclaration.Builder() .handler(new TestErrorHandler()) .operation(GetAllElements.class)