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.groovy.console; |
35 |
|
|
36 |
|
import info.magnolia.cms.core.Content; |
37 |
|
import info.magnolia.cms.core.HierarchyManager; |
38 |
|
import info.magnolia.cms.util.HierarchyManagerUtil; |
39 |
|
import info.magnolia.cms.util.HierarchyManagerWrapper; |
40 |
|
import info.magnolia.context.Context; |
41 |
|
import info.magnolia.context.ContextDecorator; |
42 |
|
import info.magnolia.context.DefaultRepositoryStrategy; |
43 |
|
import info.magnolia.context.JCRSessionStrategy; |
44 |
|
import info.magnolia.context.SystemContext; |
45 |
|
import info.magnolia.context.SystemRepositoryStrategy; |
46 |
|
import info.magnolia.context.UserContext; |
47 |
|
import info.magnolia.jcr.RuntimeRepositoryException; |
48 |
|
import info.magnolia.jcr.wrapper.NodeWrappingDelegateSessionWrapper; |
49 |
|
import info.magnolia.module.groovy.support.nodes.MgnlGroovyJCRNode; |
50 |
|
import info.magnolia.module.groovy.support.nodes.MgnlGroovyNode; |
51 |
|
import info.magnolia.objectfactory.Components; |
52 |
|
import info.magnolia.repository.RepositoryManager; |
53 |
|
|
54 |
|
import java.io.Serializable; |
55 |
|
|
56 |
|
import javax.jcr.LoginException; |
57 |
|
import javax.jcr.Node; |
58 |
|
import javax.jcr.RepositoryException; |
59 |
|
import javax.jcr.Session; |
60 |
|
|
61 |
|
|
62 |
|
@link@link |
63 |
|
|
|
|
| 7.7% |
Uncovered Elements: 24 (26) |
Complexity: 8 |
Complexity Density: 0.44 |
|
64 |
|
public class MgnlGroovyConsoleContext extends ContextDecorator { |
65 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
66 |
|
private static final class InternalHierarchyManagerWrapper extends |
67 |
|
HierarchyManagerWrapper { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
68 |
0 |
private InternalHierarchyManagerWrapper(HierarchyManager wrappedHM) {... |
69 |
0 |
super(wrappedHM); |
70 |
|
} |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
72 |
0 |
@Override... |
73 |
|
protected Content wrap(Content content) { |
74 |
0 |
return new MgnlGroovyNode(content); |
75 |
|
} |
76 |
|
} |
77 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
78 |
|
private static final class InternalJCRSessionWrapper extends |
79 |
|
NodeWrappingDelegateSessionWrapper { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
0 |
private InternalJCRSessionWrapper(Session session) {... |
81 |
0 |
super(session); |
82 |
|
} |
83 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
84 |
0 |
@Override... |
85 |
|
protected Node wrapNode(Node node) { |
86 |
0 |
return new MgnlGroovyJCRNode(node); |
87 |
|
} |
88 |
|
|
89 |
|
} |
90 |
|
|
91 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
|
private static final class SerializableRepositoryStrategy extends DefaultRepositoryStrategy implements Serializable { |
93 |
|
private static final long serialVersionUID = 1L; |
94 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
95 |
0 |
public SerializableRepositoryStrategy(UserContext context) {... |
96 |
0 |
super(Components.getComponent(RepositoryManager.class), context); |
97 |
|
} |
98 |
|
} |
99 |
|
|
100 |
|
private static final long serialVersionUID = 1L; |
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
8 |
public MgnlGroovyConsoleContext(Context ctx) {... |
103 |
8 |
super(ctx); |
104 |
|
} |
105 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
106 |
0 |
@Override... |
107 |
|
public JCRSessionStrategy getRepositoryStrategy() { |
108 |
|
|
109 |
0 |
JCRSessionStrategy strategy = super.getRepositoryStrategy(); |
110 |
0 |
if (strategy == null) { |
111 |
|
|
112 |
|
|
113 |
0 |
if (SystemContext.class.isAssignableFrom(ctx.getClass())) { |
114 |
0 |
strategy = new SystemRepositoryStrategy(Components.getComponent(RepositoryManager.class)); |
115 |
|
} else { |
116 |
0 |
strategy = new SerializableRepositoryStrategy((UserContext) ctx); |
117 |
|
} |
118 |
0 |
setRepositoryStrategy(strategy); |
119 |
|
} |
120 |
0 |
return strategy; |
121 |
|
} |
122 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
123 |
0 |
@Override... |
124 |
|
public HierarchyManager getHierarchyManager(String workspaceName) { |
125 |
0 |
Session session; |
126 |
0 |
try { |
127 |
0 |
session = getRepositoryStrategy().getSession(workspaceName); |
128 |
|
} catch (RepositoryException e) { |
129 |
0 |
throw new RuntimeRepositoryException(e); |
130 |
|
} |
131 |
0 |
return new InternalHierarchyManagerWrapper(HierarchyManagerUtil.asHierarchyManager(session)); |
132 |
|
} |
133 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
134 |
0 |
@Override... |
135 |
|
public Session getJCRSession(String workspaceName) throws LoginException, RepositoryException { |
136 |
0 |
Session session; |
137 |
0 |
try { |
138 |
0 |
session = getRepositoryStrategy().getSession(workspaceName); |
139 |
|
} catch (RepositoryException e) { |
140 |
0 |
throw new RuntimeRepositoryException(e); |
141 |
|
} |
142 |
0 |
return new InternalJCRSessionWrapper(session); |
143 |
|
} |
144 |
|
} |