Skip to content

Commit f44a1ce

Browse files
Skipping while repo copy/move
1 parent 15f0f94 commit f44a1ce

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

core/src/main/java/dev/vml/es/acm/core/repo/RepoResource.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.slf4j.LoggerFactory;
2424

2525
/**
26-
* A fluent, active-record-style wrapper for Sling resources, simplifying common repository operations.
26+
* A fluent wrapper for Sling/JCR resources, simplifying common repository operations.
2727
* <p>
2828
* This class abstracts and streamlines the standard AEM and Sling APIs, which are often verbose and complex,
2929
* by providing a concise and developer-friendly interface for resource management tasks such as creation,
@@ -82,14 +82,6 @@ public boolean exists() {
8282
return get().isPresent();
8383
}
8484

85-
public boolean existsStrict(String path) {
86-
try {
87-
return repo.getSession().nodeExists(path);
88-
} catch (Exception e) {
89-
throw new RepoException(String.format("Resource at path '%s' cannot be checked for existence!", path), e);
90-
}
91-
}
92-
9385
public RepoResource ensureFolder() {
9486
return ensure(JcrResourceConstants.NT_SLING_FOLDER);
9587
}
@@ -265,19 +257,18 @@ public RepoResource copy(RepoResource target, boolean replace) {
265257
RepoResource targetParentResource = target.parent();
266258
if (!targetParentResource.exists()) {
267259
throw new RepoException(String.format(
268-
"Cannot copy resource '%s' to '%s' as target parent does not exist!", path, target.getPath()));
260+
"Cannot copy resource from '%s' to '%s' as target parent does not exist!", path, target.getPath()));
269261
}
270262
if (target.exists()) {
271263
if (replace) {
272264
target.delete();
273265
} else {
274-
throw new RepoException(String.format(
275-
"Cannot copy resource '%s' to '%s' as it already exists!", path, target.getPath()));
266+
LOG.info("Skipped copying resource from '{}' to '{}' as it already exists", path, target.getPath());
267+
return target;
276268
}
277269
}
278270

279271
ResourceUtils.copy(repo.getResourceResolver(), sourceResource.getPath(), target.getPath());
280-
281272
repo.commit(String.format("copying resource from '%s' to '%s'", path, target.getPath()));
282273
LOG.info("Copied resource from '{}' to '{}'", path, target.getPath());
283274
return target;
@@ -311,8 +302,8 @@ public RepoResource move(RepoResource target, boolean replace) {
311302
if (replace) {
312303
target.delete();
313304
} else {
314-
throw new RepoException(String.format(
315-
"Cannot move resource '%s' to '%s' as it already exists!", path, target.getPath()));
305+
LOG.info("Skipped moving resource from '{}' to '{}' as it already exists", path, target.getPath());
306+
return target;
316307
}
317308
}
318309

0 commit comments

Comments
 (0)