1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.platform.wiki.creationjob.internal.steps

File SaveWikiMetaDataStep.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
12
2
1
90
51
3
0.25
6
2
1.5

Classes

Class Line # Actions
SaveWikiMetaDataStep 49 12 0% 3 0
1.0100%
 

Contributing tests

This file is covered by 4 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
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    * Component that save the metadata of the wiki (pretty name, description, etc...) as well as the configuration (user
41    * scope, membership type, etc...).
42    *
43    * @version $Id: 15e10ad2253fa07246a4a8491a8df9d1a896fc50 $
44    * @since 7.0M2
45    */
46    @Component
47    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
48    @Named("metadata")
 
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   
 
60  6 toggle @Override
61    public void execute(WikiCreationRequest request) throws WikiCreationException
62    {
63  6 try {
64  6 String wikiId = request.getWikiId();
65    // Meta data about the wiki
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    // Meta data about the templates
73  5 wikiTemplateManager.setTemplate(wikiId, request.isTemplate());
74   
75    // Meta data about the users
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   
 
85  10 toggle @Override
86    public int getOrder()
87    {
88  10 return 2000;
89    }
90    }