use of uk.gov.gchq.gaffer.commonutil.exception.OverwritingException in project Gaffer by gchq.
the class GraphLibrary method checkPropertiesExist.
private boolean checkPropertiesExist(final String id, final StoreProperties properties) {
final StoreProperties existingProperties = _getProperties(id);
final boolean exists = null != existingProperties;
if (exists) {
if (!existingProperties.getProperties().equals(properties.getProperties())) {
throw new OverwritingException("propertiesId " + id + " already exists with a different store properties:\n" + "existing storeProperties:\n" + existingProperties.getProperties().toString() + "\nnew storeProperties:\n" + properties.getProperties().toString());
}
}
return exists;
}
use of uk.gov.gchq.gaffer.commonutil.exception.OverwritingException in project Gaffer by gchq.
the class FederatedGraphStorage method put.
/**
* places a graph into storage, protected by the given access.
* <p> GraphId can't already exist, otherwise {@link
* OverwritingException} is thrown.
* <p> Access can't be null otherwise {@link IllegalArgumentException} is
* thrown
*
* @param graph the graph to add to the storage.
* @param access access required to for the graph.
* @throws StorageException if unable to put arguments into storage
*/
public void put(final GraphSerialisable graph, final FederatedAccess access) throws StorageException {
if (graph != null) {
String graphId = graph.getDeserialisedConfig().getGraphId();
try {
if (null == access) {
throw new IllegalArgumentException(ACCESS_IS_NULL);
}
if (null != graphLibrary) {
graphLibrary.checkExisting(graphId, graph.getDeserialisedSchema(), graph.getDeserialisedProperties());
}
validateExisting(graph);
final Graph builtGraph = graph.getGraph();
if (isCacheEnabled()) {
addToCache(builtGraph, access);
}
Set<Graph> existingGraphs = storage.get(access);
if (null == existingGraphs) {
existingGraphs = Sets.newHashSet(builtGraph);
storage.put(access, existingGraphs);
} else {
existingGraphs.add(builtGraph);
}
} catch (final Exception e) {
throw new StorageException("Error adding graph " + graphId + " to storage due to: " + e.getMessage(), e);
}
} else {
throw new StorageException("Graph cannot be null");
}
}
Aggregations