@Override
public void index(GraphObject entity, Object value) {
if (entity instanceof AbstractNode) {
NodeService nodeService = Services.getInstance().getService(NodeService.class);
AbstractNode node = (AbstractNode)entity;
Node dbNode = node.getNode();
for (NodeIndex indexName : nodeIndices()) {
Index<Node> index = nodeService.getNodeIndex(indexName);
if (index != null) {
try {
synchronized (index) {
index.remove(dbNode, dbName);
if (value != null && !StringUtils.isBlank(value.toString())) {
index.add(dbNode, dbName, value);
} else if (isIndexedWhenEmpty()) {
value = getValueForEmptyFields();
if (value != null) {
index.add(dbNode, dbName, value);
}
}
}
} catch (Throwable t) {
logger.log(Level.INFO, "Unable to index property with dbName {0} and value {1} of type {2} on {3}: {4}", new Object[] { dbName, value, this.getClass().getSimpleName(), entity, t } );
}
}
}
} else {
NodeService nodeService = Services.getInstance().getService(NodeService.class);
AbstractRelationship rel = (AbstractRelationship)entity;
Relationship dbRel = rel.getRelationship();
for (RelationshipIndex indexName : relationshipIndices()) {
Index<Relationship> index = nodeService.getRelationshipIndex(indexName);
if (index != null) {
try {
synchronized (index) {