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.imaging.parameters; |
35 |
|
|
36 |
|
import info.magnolia.context.MgnlContext; |
37 |
|
import info.magnolia.imaging.ImagingRuntimeException; |
38 |
|
import info.magnolia.imaging.ParameterProvider; |
39 |
|
import info.magnolia.imaging.ParameterProviderFactory; |
40 |
|
import info.magnolia.imaging.util.PathSplitter; |
41 |
|
|
42 |
|
import javax.jcr.ItemNotFoundException; |
43 |
|
import javax.jcr.NoSuchWorkspaceException; |
44 |
|
import javax.jcr.PathNotFoundException; |
45 |
|
import javax.jcr.RepositoryException; |
46 |
|
import javax.jcr.Session; |
47 |
|
import javax.servlet.http.HttpServletRequest; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
@param |
54 |
|
@deprecated@link |
55 |
|
|
56 |
|
@Deprecated |
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.38 |
|
57 |
|
public abstract class AbstractWorkspaceAndUuidParameterProviderFactory<PT> implements ParameterProviderFactory<HttpServletRequest, PT> { |
58 |
|
|
59 |
|
private boolean trimExtension = true; |
60 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.38 |
|
61 |
0 |
@Override... |
62 |
|
public ParameterProvider<PT> newParameterProviderFor(HttpServletRequest request) { |
63 |
0 |
String pathInfo = request.getPathInfo(); |
64 |
0 |
if (pathInfo == null) { |
65 |
0 |
throw new ImagingRuntimeException("Can't determine node, no pathInfo is available for uri " + request.getRequestURI()); |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
0 |
final PathSplitter pathSplitter = new PathSplitter(pathInfo, trimExtension); |
71 |
0 |
if (pathSplitter.count() < 2) { |
72 |
0 |
throw new ImagingRuntimeException("Can't determine node from pathInfo: " + pathInfo); |
73 |
|
|
74 |
|
} |
75 |
0 |
final String workspaceName = pathSplitter.skipTo(1); |
76 |
0 |
final String uuid = pathSplitter.skipTo(2); |
77 |
|
|
78 |
0 |
try { |
79 |
0 |
final Session session = MgnlContext.getJCRSession(workspaceName); |
80 |
0 |
return newParameterProviderForUuid(session, uuid); |
81 |
|
} catch (NoSuchWorkspaceException | ItemNotFoundException | PathNotFoundException e) { |
82 |
0 |
throw new ImagingRuntimeException("Can't load source from " + uuid + " from workspace " + workspaceName, e); |
83 |
|
} catch (RepositoryException e) { |
84 |
0 |
throw new RuntimeException("Can't load source from " + uuid + " from workspace " + workspaceName, e); |
85 |
|
} |
86 |
|
} |
87 |
|
|
88 |
|
abstract protected ParameterProvider<PT> newParameterProviderForUuid(Session session, String uuid) throws RepositoryException; |
89 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
90 |
|
public void setTrimExtension(boolean trimExtension) {... |
91 |
|
this.trimExtension = trimExtension; |
92 |
|
} |
93 |
|
|
94 |
|
} |