1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.platform.wiki.creationjob.internal; |
21 |
|
|
22 |
|
import java.util.Arrays; |
23 |
|
|
24 |
|
import javax.inject.Inject; |
25 |
|
import javax.inject.Singleton; |
26 |
|
|
27 |
|
import org.xwiki.component.annotation.Component; |
28 |
|
import org.xwiki.component.manager.ComponentLookupException; |
29 |
|
import org.xwiki.component.manager.ComponentManager; |
30 |
|
import org.xwiki.extension.ExtensionId; |
31 |
|
import org.xwiki.extension.job.InstallRequest; |
32 |
|
import org.xwiki.extension.job.internal.InstallJob; |
33 |
|
import org.xwiki.job.Job; |
34 |
|
import org.xwiki.model.reference.DocumentReference; |
35 |
|
import org.xwiki.platform.wiki.creationjob.WikiCreationException; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
43 |
|
@Component(roles = ExtensionInstaller.class) |
44 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 2 |
Complexity Density: 0.2 |
|
45 |
|
public class ExtensionInstaller |
46 |
|
{ |
47 |
|
private static final String PROPERTY_USERREFERENCE = "user.reference"; |
48 |
|
|
49 |
|
private static final DocumentReference SUPERADMIN_REFERENCE = new DocumentReference("xwiki", "XWiki", "superadmin"); |
50 |
|
|
51 |
|
@Inject |
52 |
|
private ComponentManager componentManager; |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
@param |
58 |
|
@param |
59 |
|
@throws |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0.2 |
|
61 |
3 |
public void installExtension(String wikiId, ExtensionId extensionId) throws WikiCreationException... |
62 |
|
{ |
63 |
3 |
try { |
64 |
|
|
65 |
3 |
InstallRequest installRequest = new InstallRequest(); |
66 |
3 |
installRequest.setId(Arrays.asList(WikiCreationJob.JOB_ID_PREFIX, "install", wikiId)); |
67 |
3 |
installRequest.addExtension(extensionId); |
68 |
3 |
installRequest.addNamespace("wiki:" + wikiId); |
69 |
|
|
70 |
3 |
installRequest.setProperty(PROPERTY_USERREFERENCE, SUPERADMIN_REFERENCE); |
71 |
3 |
InstallJob job = componentManager.getInstance(Job.class, InstallJob.JOBTYPE); |
72 |
2 |
job.initialize(installRequest); |
73 |
2 |
job.run(); |
74 |
|
} catch (ComponentLookupException e) { |
75 |
1 |
throw new WikiCreationException(String.format("Failed to install the extension [%s] on the wiki [%s].", |
76 |
|
extensionId.toString(), wikiId), e); |
77 |
|
} |
78 |
|
} |
79 |
|
} |