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.subapp.sitemapdetail; |
35 |
|
|
36 |
|
import info.magnolia.context.MgnlContext; |
37 |
|
import info.magnolia.module.googlesitemap.GoogleSiteMapConfiguration; |
38 |
|
import info.magnolia.ui.api.app.SubAppContext; |
39 |
|
import info.magnolia.ui.api.location.Location; |
40 |
|
import info.magnolia.ui.api.view.View; |
41 |
|
import info.magnolia.ui.contentapp.detail.DetailLocation; |
42 |
|
import info.magnolia.ui.framework.app.BaseSubApp; |
43 |
|
import info.magnolia.ui.vaadin.integration.jcr.JcrNodeAdapter; |
44 |
|
|
45 |
|
import javax.inject.Inject; |
46 |
|
import javax.jcr.Node; |
47 |
|
import javax.jcr.RepositoryException; |
48 |
|
|
49 |
|
import org.slf4j.Logger; |
50 |
|
import org.slf4j.LoggerFactory; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 7 |
Complexity Density: 0.44 |
|
55 |
|
public class SiteMapEditorSubApp extends BaseSubApp { |
56 |
|
|
57 |
|
private Logger log = LoggerFactory.getLogger(getClass()); |
58 |
|
|
59 |
|
private SiteMapEditorPresenter presenter; |
60 |
|
|
61 |
|
private String caption; |
62 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
63 |
0
|
@Inject... |
64 |
|
protected SiteMapEditorSubApp(SubAppContext subAppContext, SiteMapEditorPresenter presenter) { |
65 |
0
|
super(subAppContext, presenter.start()); |
66 |
0
|
this.presenter = presenter; |
67 |
|
} |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
|
69 |
0
|
@Override... |
70 |
|
public View start(Location location) { |
71 |
0
|
DetailLocation detailLocation = DetailLocation.wrap(location); |
72 |
0
|
super.start(detailLocation); |
73 |
0
|
setCaption(detailLocation); |
74 |
0
|
try { |
75 |
0
|
Node node = MgnlContext.getJCRSession(GoogleSiteMapConfiguration.WORKSPACE).getNode(detailLocation.getNodePath()); |
76 |
0
|
presenter.setSiteMapNode(new JcrNodeAdapter(node)); |
77 |
|
} catch (RepositoryException e) { |
78 |
0
|
log.warn("Could not retrieve item at path {} in workspace {}", detailLocation.getNodePath(), "google-sitemap"); |
79 |
|
} |
80 |
|
|
81 |
0
|
return getView(); |
82 |
|
} |
83 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
84 |
0
|
@Override... |
85 |
|
public String getCaption() { |
86 |
0
|
return caption; |
87 |
|
} |
88 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
89 |
0
|
public void setCaption(DetailLocation location) {... |
90 |
0
|
this.caption = presenter.getCaptionForLocation(location); |
91 |
|
} |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
93 |
0
|
@Override... |
94 |
|
public DetailLocation getCurrentLocation() { |
95 |
0
|
return DetailLocation.wrap(super.getCurrentLocation()); |
96 |
|
} |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
98 |
0
|
@Override... |
99 |
|
public boolean supportsLocation(Location location) { |
100 |
0
|
DetailLocation itemLocation = DetailLocation.wrap(location); |
101 |
0
|
String currentPath = getCurrentLocation().getNodePath(); |
102 |
0
|
return currentPath.equals(itemLocation.getNodePath()); |
103 |
|
} |
104 |
|
} |