|
23 | 23 | import org.slf4j.LoggerFactory;
|
24 | 24 |
|
25 | 25 | /**
|
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. |
27 | 27 | * <p>
|
28 | 28 | * This class abstracts and streamlines the standard AEM and Sling APIs, which are often verbose and complex,
|
29 | 29 | * by providing a concise and developer-friendly interface for resource management tasks such as creation,
|
@@ -82,14 +82,6 @@ public boolean exists() {
|
82 | 82 | return get().isPresent();
|
83 | 83 | }
|
84 | 84 |
|
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 |
| - |
93 | 85 | public RepoResource ensureFolder() {
|
94 | 86 | return ensure(JcrResourceConstants.NT_SLING_FOLDER);
|
95 | 87 | }
|
@@ -265,19 +257,18 @@ public RepoResource copy(RepoResource target, boolean replace) {
|
265 | 257 | RepoResource targetParentResource = target.parent();
|
266 | 258 | if (!targetParentResource.exists()) {
|
267 | 259 | 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())); |
269 | 261 | }
|
270 | 262 | if (target.exists()) {
|
271 | 263 | if (replace) {
|
272 | 264 | target.delete();
|
273 | 265 | } 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; |
276 | 268 | }
|
277 | 269 | }
|
278 | 270 |
|
279 | 271 | ResourceUtils.copy(repo.getResourceResolver(), sourceResource.getPath(), target.getPath());
|
280 |
| - |
281 | 272 | repo.commit(String.format("copying resource from '%s' to '%s'", path, target.getPath()));
|
282 | 273 | LOG.info("Copied resource from '{}' to '{}'", path, target.getPath());
|
283 | 274 | return target;
|
@@ -311,8 +302,8 @@ public RepoResource move(RepoResource target, boolean replace) {
|
311 | 302 | if (replace) {
|
312 | 303 | target.delete();
|
313 | 304 | } 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; |
316 | 307 | }
|
317 | 308 | }
|
318 | 309 |
|
|
0 commit comments