From 9d23f4c4f14c40ede6a97d710f139d8a4827b355 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Fri, 10 Nov 2017 11:48:23 -0600 Subject: [PATCH] Fix #60 by ensuring we are loading existing resources instead of calling "create()" on them again. --- .gitignore | 3 +++ .../lambdora/service/aws/BinaryServiceImpl.java | 5 +++++ .../lambdora/service/aws/ContainerServiceImpl.java | 7 +++++++ .../service/aws/FedoraResourceServiceBase.java | 11 ++++++++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c253c00..25a619f 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,8 @@ target *.war *.ear +# Don't ignore gradle-wrapper distributed in project +!/gradle/wrapper/gradle-wrapper.jar + # Serverless directories .serverless diff --git a/lambdora-service/src/main/java/org/fcrepo/lambdora/service/aws/BinaryServiceImpl.java b/lambdora-service/src/main/java/org/fcrepo/lambdora/service/aws/BinaryServiceImpl.java index f2fe602..c3d9bff 100644 --- a/lambdora-service/src/main/java/org/fcrepo/lambdora/service/aws/BinaryServiceImpl.java +++ b/lambdora-service/src/main/java/org/fcrepo/lambdora/service/aws/BinaryServiceImpl.java @@ -25,4 +25,9 @@ public BinaryServiceImpl(final ResourceTripleDao dao) { protected FedoraBinary create(final URI identifier) { return new FedoraBinaryImpl(identifier, getResourceTripleDao()); } + + @Override + protected FedoraBinary load(final URI identifier) { + return new FedoraBinaryImpl(identifier, getResourceTripleDao()); + } } diff --git a/lambdora-service/src/main/java/org/fcrepo/lambdora/service/aws/ContainerServiceImpl.java b/lambdora-service/src/main/java/org/fcrepo/lambdora/service/aws/ContainerServiceImpl.java index b06fdde..3f25a5a 100644 --- a/lambdora-service/src/main/java/org/fcrepo/lambdora/service/aws/ContainerServiceImpl.java +++ b/lambdora-service/src/main/java/org/fcrepo/lambdora/service/aws/ContainerServiceImpl.java @@ -76,6 +76,13 @@ protected Container create(final URI identifier) { return new ContainerImpl(identifier, dao); } + @Override + protected Container load(final URI identifier) { + LOGGER.debug("Load: {}", identifier); + final ResourceTripleDao dao = getResourceTripleDao(); + return new ContainerImpl(identifier, dao); + } + /** * Get system generated triples for this resource * @param identifier resource URI diff --git a/lambdora-service/src/main/java/org/fcrepo/lambdora/service/aws/FedoraResourceServiceBase.java b/lambdora-service/src/main/java/org/fcrepo/lambdora/service/aws/FedoraResourceServiceBase.java index a2ef96d..eb7e9eb 100644 --- a/lambdora-service/src/main/java/org/fcrepo/lambdora/service/aws/FedoraResourceServiceBase.java +++ b/lambdora-service/src/main/java/org/fcrepo/lambdora/service/aws/FedoraResourceServiceBase.java @@ -34,7 +34,7 @@ public boolean exists(final URI identifier) { @Override public T find(final URI identifier) { if (exists(identifier)) { - return create(identifier); + return load(identifier); } else { return null; } @@ -63,4 +63,13 @@ protected ResourceTripleDao getResourceTripleDao() { * @return */ abstract protected T create(final URI identifier); + + + /** + * load existing resource + * + * @param identifier + * @return + */ + abstract protected T load(final URI identifier); }