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.steps; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Named; |
24 |
|
|
25 |
|
import org.xwiki.component.annotation.Component; |
26 |
|
import org.xwiki.component.annotation.InstantiationStrategy; |
27 |
|
import org.xwiki.component.descriptor.ComponentInstantiationStrategy; |
28 |
|
import org.xwiki.platform.wiki.creationjob.WikiCreationRequest; |
29 |
|
import org.xwiki.platform.wiki.creationjob.WikiCreationStep; |
30 |
|
import org.xwiki.platform.wiki.creationjob.WikiCreationException; |
31 |
|
import org.xwiki.wiki.descriptor.WikiDescriptor; |
32 |
|
import org.xwiki.wiki.descriptor.WikiDescriptorManager; |
33 |
|
import org.xwiki.wiki.manager.WikiManagerException; |
34 |
|
import org.xwiki.wiki.template.WikiTemplateManager; |
35 |
|
import org.xwiki.wiki.template.WikiTemplateManagerException; |
36 |
|
import org.xwiki.wiki.user.WikiUserManager; |
37 |
|
import org.xwiki.wiki.user.WikiUserManagerException; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
@version |
44 |
|
@since |
45 |
|
|
46 |
|
@Component |
47 |
|
@InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP) |
48 |
|
@Named("metadata") |
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 3 |
Complexity Density: 0.25 |
|
49 |
|
public class SaveWikiMetaDataStep implements WikiCreationStep |
50 |
|
{ |
51 |
|
@Inject |
52 |
|
private WikiDescriptorManager wikiDescriptorManager; |
53 |
|
|
54 |
|
@Inject |
55 |
|
private WikiTemplateManager wikiTemplateManager; |
56 |
|
|
57 |
|
@Inject |
58 |
|
private WikiUserManager wikiUserManager; |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 2 |
Complexity Density: 0.18 |
|
60 |
6 |
@Override... |
61 |
|
public void execute(WikiCreationRequest request) throws WikiCreationException |
62 |
|
{ |
63 |
6 |
try { |
64 |
6 |
String wikiId = request.getWikiId(); |
65 |
|
|
66 |
6 |
WikiDescriptor descriptor = wikiDescriptorManager.getById(wikiId); |
67 |
6 |
descriptor.setDescription(request.getDescription()); |
68 |
6 |
descriptor.setPrettyName(request.getPrettyName()); |
69 |
6 |
descriptor.setOwnerId(request.getOwnerId()); |
70 |
6 |
wikiDescriptorManager.saveDescriptor(descriptor); |
71 |
|
|
72 |
|
|
73 |
5 |
wikiTemplateManager.setTemplate(wikiId, request.isTemplate()); |
74 |
|
|
75 |
|
|
76 |
5 |
wikiUserManager.setUserScope(wikiId, request.getUserScope()); |
77 |
5 |
wikiUserManager.setMembershipType(wikiId, request.getMembershipType()); |
78 |
|
|
79 |
|
} catch (WikiManagerException | WikiTemplateManagerException | WikiUserManagerException e) { |
80 |
1 |
throw new WikiCreationException( |
81 |
|
String.format("Failed to set metadata to the wiki [%s].", request.getWikiId()), e); |
82 |
|
} |
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
10 |
@Override... |
86 |
|
public int getOrder() |
87 |
|
{ |
88 |
10 |
return 2000; |
89 |
|
} |
90 |
|
} |