@Override public InputStream getInputStream() { try { return fs.open(this.path); } catch (IOException ex) { throw new SecureGraphException("Could not open: " + this.path, ex); } } }
public Class getValueType() { try { return Class.forName(valueType); } catch (ClassNotFoundException e) { throw new SecureGraphException("Could not get type: " + valueType); } }
private String getPropertyNameFromColumnQualifier(String columnQualifier) { int i = columnQualifier.indexOf(ElementMutationBuilder.VALUE_SEPARATOR); if (i < 0) { throw new SecureGraphException("Invalid property column qualifier"); } return columnQualifier.substring(0, i); }
void markPropertyHiddenInternal(Property property, Visibility visibility) { if (property instanceof MutableProperty) { ((MutableProperty) property).addHiddenVisibility(visibility); } else { throw new SecureGraphException("Could not mark property hidden. Must be of type " + MutableProperty.class.getName()); } }
private static String[] getElasticSearchLocations(GraphConfiguration config) { String esLocationsString = config.getString(GraphConfiguration.SEARCH_INDEX_PROP_PREFIX + "." + CONFIG_ES_LOCATIONS, null); if (esLocationsString == null) { throw new SecureGraphException(GraphConfiguration.SEARCH_INDEX_PROP_PREFIX + "." + CONFIG_ES_LOCATIONS + " is a required configuration parameter"); } LOGGER.info("Using elastic search locations: " + esLocationsString); return esLocationsString.split(","); }
public void alterEdgeLabel(String edgeId, String newEdgeLabel) { InMemoryEdge edge = this.edges.get(edgeId); if (edge == null) { throw new SecureGraphException("Could not find edge " + edgeId); } edge.setLabel(newEdgeLabel); } }
void markPropertyVisibleInternal(Property property, Visibility visibility) { if (property instanceof MutableProperty) { ((MutableProperty) property).removeHiddenVisibility(visibility); } else { throw new SecureGraphException("Could not mark property visible. Must be of type " + MutableProperty.class.getName()); } }
protected BatchWriter getWriterFromElementType(Element element) { if (element instanceof Vertex) { return getVerticesWriter(); } else if (element instanceof Edge) { return getEdgesWriter(); } else { throw new SecureGraphException("Unexpected element type: " + element.getClass().getName()); } }
@Override protected void setup() { super.setup(); if (accumuloGraphVersion == null) { setMetadata(METADATA_ACCUMULO_GRAPH_VERSION_KEY, METADATA_ACCUMULO_GRAPH_VERSION); } else if (!METADATA_ACCUMULO_GRAPH_VERSION.equals(accumuloGraphVersion)) { throw new SecureGraphException("Invalid accumulo graph version. Expected " + METADATA_ACCUMULO_GRAPH_VERSION + " found " + accumuloGraphVersion); } }
public String readToString() { try { return StreamUtils.toString(getInputStream()); } catch (IOException e) { throw new SecureGraphException("Could not read streaming property value into string", e); } }
@Test public void testNullPropertyValue() { try { graph.prepareVertex("v1", VISIBILITY_EMPTY) .setProperty("prop1", null, VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); throw new SecureGraphException("expected null check"); } catch (NullPointerException ex) { assertTrue(ex.getMessage().contains("prop1")); } }
@Test public void testNullPropertyValue() { try { graph.prepareVertex("v1", VISIBILITY_EMPTY) .setProperty("prop1", null, VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); throw new SecureGraphException("expected null check"); } catch (NullPointerException ex) { assertTrue(ex.getMessage().contains("prop1")); } }
@Override public PropertyDefinition define() { PropertyDefinition propertyDefinition = super.define(); try { getSearchIndex().addPropertyDefinition(propertyDefinition); } catch (IOException e) { throw new SecureGraphException("Could not add property definition to search index", e); } setMetadata(METADATA_DEFINE_PROPERTY_PREFIX + propertyName, propertyDefinition); return propertyDefinition; } };
protected void doBulkRequest(BulkRequest bulkRequest) { BulkResponse response = getClient().bulk(bulkRequest).actionGet(); if (response.hasFailures()) { for (BulkItemResponse bulkResponse : response) { if (bulkResponse.isFailed()) { LOGGER.error("Failed to index " + bulkResponse.getId() + " (message: " + bulkResponse.getFailureMessage() + ")"); } } throw new SecureGraphException("Could not add element."); } }
public IndexInfo addPropertiesToIndex(Element element, Iterable<Property> properties) { try { String indexName = getIndexName(element); IndexInfo indexInfo = ensureIndexCreatedAndInitialized(indexName, getConfig().isStoreSourceData()); for (Property property : properties) { addPropertyToIndex(indexInfo, property); } return indexInfo; } catch (IOException e) { throw new SecureGraphException("Could not add properties to index", e); } }
public IndexInfo addPropertiesToIndex(Element element, Iterable<Property> properties) { try { String indexName = getIndexName(element); IndexInfo indexInfo = ensureIndexCreatedAndInitialized(indexName, getConfig().isStoreSourceData()); for (Property property : properties) { addPropertyToIndex(indexInfo, property); } return indexInfo; } catch (IOException e) { throw new SecureGraphException("Could not add properties to index", e); } }
public String createJsonForElement(Graph graph, Element element, Authorizations authorizations) { try { String indexName = getIndexName(element); IndexInfo indexInfo = ensureIndexCreatedAndInitialized(indexName, getConfig().isStoreSourceData()); return buildJsonContentFromElement(graph, indexInfo, element, authorizations).string(); } catch (Exception e) { throw new SecureGraphException("Could not create JSON for element", e); } }
@Override public void addElementToBulkRequest(Graph graph, BulkRequest bulkRequest, IndexInfo indexInfo, Element element, Authorizations authorizations) { try { XContentBuilder json = buildJsonContentFromElement(graph, indexInfo, element, authorizations); IndexRequest indexRequest = new IndexRequest(indexInfo.getIndexName(), ELEMENT_TYPE, element.getId()).source(json); bulkRequest.add(indexRequest); } catch (IOException ex) { throw new SecureGraphException("Could not add element to bulk request", ex); } }
@SuppressWarnings("unchecked") private <T extends Element> Iterable<T> getIterableFromElementType(ElementType elementType, EnumSet<FetchHint> fetchHints) throws SecureGraphException { switch (elementType) { case VERTEX: return (Iterable<T>) getGraph().getVertices(fetchHints, getParameters().getAuthorizations()); case EDGE: return (Iterable<T>) getGraph().getEdges(fetchHints, getParameters().getAuthorizations()); default: throw new SecureGraphException("Unexpected element type: " + elementType); } } }
@Override public void clearData() { try { this.connector.tableOperations().deleteRows(getDataTableName(), null, null); this.connector.tableOperations().deleteRows(getEdgesTableName(), null, null); this.connector.tableOperations().deleteRows(getVerticesTableName(), null, null); this.connector.tableOperations().deleteRows(getMetadataTableName(), null, null); getSearchIndex().clearData(); } catch (Exception ex) { throw new SecureGraphException("Could not delete rows", ex); } }