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

File DefaultWikiPropertyGroupManager.java

 

Coverage histogram

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

Code metrics

2
12
2
1
76
44
4
0.33
6
2
2

Classes

Class Line # Actions
DefaultWikiPropertyGroupManager 42 12 0% 4 1
0.937593.8%
 

Contributing tests

No tests hitting this source file were found.

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.wiki.internal.descriptor.properties;
21   
22    import java.util.Map;
23   
24    import javax.inject.Inject;
25    import javax.inject.Singleton;
26   
27    import org.slf4j.Logger;
28    import org.xwiki.component.annotation.Component;
29    import org.xwiki.wiki.descriptor.WikiDescriptor;
30    import org.xwiki.wiki.properties.WikiPropertyGroup;
31    import org.xwiki.wiki.properties.WikiPropertyGroupException;
32    import org.xwiki.wiki.properties.WikiPropertyGroupProvider;
33   
34    /**
35    * Default implementation for WikiPropertyGroupManager.
36    *
37    * @since 5.3M2
38    * @version $Id :$
39    */
40    @Component
41    @Singleton
 
42    public class DefaultWikiPropertyGroupManager implements WikiPropertyGroupManager
43    {
44    @Inject
45    private Map<String, WikiPropertyGroupProvider> propertyGroupProviders;
46   
47    @Inject
48    private Logger logger;
49   
 
50  105 toggle @Override
51    public void loadForDescriptor(WikiDescriptor descriptor) throws WikiPropertyGroupException
52    {
53  105 String wikiId = descriptor.getId();
54  105 for (String propertyGroupName : propertyGroupProviders.keySet()) {
55  16 WikiPropertyGroupProvider provider = propertyGroupProviders.get(propertyGroupName);
56  16 try {
57  16 descriptor.addPropertyGroup(provider.get(wikiId));
58    } catch (WikiPropertyGroupException e) {
59  0 logger.warn(String.format("Unable to load property groups [%s].", propertyGroupName), e);
60    }
61    }
62    }
63   
 
64  8 toggle @Override
65    public void saveForDescriptor(WikiDescriptor descriptor) throws WikiPropertyGroupException
66    {
67  8 String wikiId = descriptor.getId();
68  8 for (String propertyGroupName : propertyGroupProviders.keySet()) {
69  8 WikiPropertyGroup group = descriptor.getPropertyGroup(propertyGroupName);
70  8 if (group != null) {
71  4 WikiPropertyGroupProvider provider = propertyGroupProviders.get(propertyGroupName);
72  4 provider.save(group, wikiId);
73    }
74    }
75    }
76    }