1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.resources.app.availability; |
35 |
|
|
36 |
|
import info.magnolia.jcr.util.NodeTypes; |
37 |
|
import info.magnolia.jcr.util.NodeUtil; |
38 |
|
import info.magnolia.jcr.util.SessionUtil; |
39 |
|
import info.magnolia.resourceloader.Resource; |
40 |
|
import info.magnolia.resourceloader.ResourceOrigin; |
41 |
|
import info.magnolia.resourceloader.jcr.JcrResourceOrigin; |
42 |
|
import info.magnolia.resourceloader.layered.LayeredResource; |
43 |
|
|
44 |
|
import javax.inject.Inject; |
45 |
|
import javax.jcr.Node; |
46 |
|
import javax.jcr.RepositoryException; |
47 |
|
|
48 |
|
import org.slf4j.Logger; |
49 |
|
import org.slf4j.LoggerFactory; |
50 |
|
|
51 |
|
|
52 |
|
@link@link |
53 |
|
|
54 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
55 |
|
public class IsNotDeletedRule extends AbstractResourceAvailabilityRule { |
56 |
|
|
57 |
|
private static final Logger log = LoggerFactory.getLogger(IsNotDeletedRule.class); |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
0 |
@Inject... |
60 |
|
public IsNotDeletedRule(ResourceOrigin origin) { |
61 |
0 |
super(origin); |
62 |
|
} |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
64 |
0 |
@Override... |
65 |
|
protected boolean isAvailableFor(Resource itemId) { |
66 |
0 |
final LayeredResource layeredResource = (LayeredResource) itemId; |
67 |
0 |
if (layeredResource.getFirst().getOrigin() instanceof JcrResourceOrigin) { |
68 |
0 |
final String resourcePath = layeredResource.getFirst().getPath(); |
69 |
0 |
final Node node = SessionUtil.getNode(JcrResourceOrigin.RESOURCES_WORKSPACE, resourcePath); |
70 |
0 |
if (node != null) { |
71 |
0 |
try { |
72 |
0 |
return !NodeUtil.hasMixin(node, NodeTypes.Deleted.NAME); |
73 |
|
} catch (RepositoryException e) { |
74 |
0 |
log.warn("Error evaluating availability for node [{}], returning false: {}", NodeUtil.getPathIfPossible(node), e.getMessage()); |
75 |
|
} |
76 |
|
} |
77 |
|
} |
78 |
0 |
return true; |
79 |
|
} |
80 |
|
} |