Skip to content

Commit

Permalink
check if node exists
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Apr 20, 2017
1 parent bb3a30f commit 6cc9be7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/main/java/com/maxdemarzi/search/Search.java
Expand Up @@ -7,10 +7,7 @@
import com.maxdemarzi.users.Users;
import org.codehaus.jackson.map.ObjectMapper;
import org.neo4j.collection.primitive.PrimitiveLongIterator;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.*;
import org.neo4j.kernel.api.ReadOperations;
import org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException;
import org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException;
Expand Down Expand Up @@ -149,8 +146,15 @@ public Response getLatest(@QueryParam("limit") @DefaultValue("25") final Integer

int counter = 0;
while (counter < limit && highId > -1) {
Node post = db.getNodeById(highId);
highId--;
Node post;
try {
post = db.getNodeById(highId);
} catch (NotFoundException e) {
continue;
} finally {
highId--;
}

if (post.getLabels().iterator().next().name().equals(Labels.Post.name())) {
Long time = (Long) post.getProperty("time");
if (time < latest) {
Expand Down

0 comments on commit 6cc9be7

Please sign in to comment.