1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.url.internal; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Named; |
24 |
|
|
25 |
|
import org.xwiki.component.manager.ComponentLookupException; |
26 |
|
import org.xwiki.component.manager.ComponentManager; |
27 |
|
import org.xwiki.component.util.DefaultParameterizedType; |
28 |
|
import org.xwiki.resource.ResourceReference; |
29 |
|
import org.xwiki.resource.ResourceReferenceSerializer; |
30 |
|
import org.xwiki.resource.SerializeResourceReferenceException; |
31 |
|
import org.xwiki.resource.UnsupportedResourceReferenceException; |
32 |
|
import org.xwiki.url.ExtendedURL; |
33 |
|
|
34 |
|
|
35 |
|
@link |
36 |
|
|
37 |
|
@version |
38 |
|
@since |
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 3 |
Complexity Density: 0.43 |
|
40 |
|
public abstract class AbstractExtendedURLResourceReferenceSerializer |
41 |
|
implements ResourceReferenceSerializer<ResourceReference, ExtendedURL> |
42 |
|
{ |
43 |
|
@Inject |
44 |
|
@Named("context") |
45 |
|
private ComponentManager componentManager; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
@param |
51 |
|
@param |
52 |
|
@return |
53 |
|
@throws |
54 |
|
@throws |
55 |
|
|
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 3 |
Complexity Density: 0.43 |
|
57 |
25717 |
public ExtendedURL serialize(ResourceReference reference, String formatId)... |
58 |
|
throws SerializeResourceReferenceException, UnsupportedResourceReferenceException |
59 |
|
{ |
60 |
|
|
61 |
|
|
62 |
25717 |
ResourceReferenceSerializer<ResourceReference, ExtendedURL> serializer; |
63 |
25717 |
try { |
64 |
25717 |
serializer = this.componentManager.getInstance(new DefaultParameterizedType(null, |
65 |
|
ResourceReferenceSerializer.class, reference.getClass(), ExtendedURL.class), formatId); |
66 |
|
} catch (ComponentLookupException e) { |
67 |
|
|
68 |
|
|
69 |
25714 |
try { |
70 |
25715 |
serializer = this.componentManager.getInstance(new DefaultParameterizedType(null, |
71 |
|
ResourceReferenceSerializer.class, reference.getClass(), ExtendedURL.class)); |
72 |
|
} catch (ComponentLookupException cle) { |
73 |
1 |
throw new UnsupportedResourceReferenceException(String.format( |
74 |
|
"Failed to find serializer for Resource Reference [%s] and URL format [%s]", reference, formatId), |
75 |
|
cle); |
76 |
|
} |
77 |
|
} |
78 |
|
|
79 |
25716 |
return serializer.serialize(reference); |
80 |
|
} |
81 |
|
} |