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.module.googlesitemap.app.actions.availability; |
35 |
|
|
36 |
|
import info.magnolia.jcr.util.NodeUtil; |
37 |
|
import info.magnolia.module.googlesitemap.SiteMapNodeTypes; |
38 |
|
import info.magnolia.ui.api.availability.AvailabilityRule; |
39 |
|
import info.magnolia.ui.vaadin.integration.jcr.JcrItemId; |
40 |
|
import info.magnolia.ui.vaadin.integration.jcr.JcrItemUtil; |
41 |
|
|
42 |
|
import java.util.Collection; |
43 |
|
|
44 |
|
import javax.jcr.Item; |
45 |
|
import javax.jcr.Node; |
46 |
|
import javax.jcr.RepositoryException; |
47 |
|
|
48 |
|
import org.slf4j.Logger; |
49 |
|
import org.slf4j.LoggerFactory; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
|
|
| 82.4% |
Uncovered Elements: 3 (17) |
Complexity: 8 |
Complexity Density: 0.8 |
|
54 |
|
public class VirtualUriMappingEditingEnabledRule implements AvailabilityRule { |
55 |
|
|
56 |
|
private Logger log = LoggerFactory.getLogger(getClass()); |
57 |
|
|
|
|
| 81.2% |
Uncovered Elements: 3 (16) |
Complexity: 8 |
Complexity Density: 0.8 |
|
58 |
3 |
@Override... |
59 |
|
public boolean isAvailable(Collection<?> itemIds) { |
60 |
3 |
try { |
61 |
3 |
if (itemIds != null && itemIds.size() > 0) { |
62 |
3 |
Object firstId = itemIds.iterator().next(); |
63 |
3 |
if (firstId instanceof JcrItemId) { |
64 |
3 |
JcrItemId items = (JcrItemId)firstId; |
65 |
3 |
Item item = JcrItemUtil.getJcrItem(items); |
66 |
3 |
if (item != null && item.isNode() && NodeUtil.isNodeType((Node) item, SiteMapNodeTypes.SiteMap.NAME)) { |
67 |
2 |
return (SiteMapNodeTypes.SiteMap.isVirtualUriMappingIncluded((Node) item)); |
68 |
|
} |
69 |
|
} |
70 |
|
} |
71 |
|
} catch (RepositoryException e) { |
72 |
0 |
log.debug("Error occurred while checking virtual uri mapping availability check ", e.getMessage()); |
73 |
|
|
74 |
|
} |
75 |
1 |
return false; |
76 |
|
} |
77 |
|
|
78 |
|
} |