1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.extension.distribution.internal.job.step

File FirstAdminUserStep.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

6
8
2
1
84
43
6
0.75
4
2
3

Classes

Class Line # Actions
FirstAdminUserStep 44 8 0% 6 16
0.00%
 

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.extension.distribution.internal.job.step;
21   
22    import javax.inject.Inject;
23    import javax.inject.Named;
24    import javax.inject.Provider;
25   
26    import org.slf4j.Logger;
27    import org.xwiki.component.annotation.Component;
28    import org.xwiki.component.annotation.InstantiationStrategy;
29    import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
30   
31    import com.xpn.xwiki.XWikiContext;
32    import com.xpn.xwiki.XWikiException;
33    import com.xpn.xwiki.plugin.rightsmanager.RightsManager;
34   
35    /**
36    * Register a new owner if no user exist.
37    *
38    * @version $Id: d2b5ee0f0073d708fb444bb34dfdffd55f66b0b5 $
39    * @since 8.0RC1
40    */
41    @Component
42    @Named(FirstAdminUserStep.ID)
43    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
 
44    public class FirstAdminUserStep extends AbstractDistributionStep
45    {
46    /**
47    * The identifier of the step.
48    */
49    public static final String ID = "firstadminuser";
50   
51    @Inject
52    private transient Logger logger;
53   
54    @Inject
55    private transient Provider<XWikiContext> xcontextProvider;
56   
57    /**
58    * Default constructor.
59    */
 
60  0 toggle public FirstAdminUserStep()
61    {
62  0 super(ID);
63    }
64   
 
65  0 toggle @Override
66    public void prepare()
67    {
68  0 if (getState() == null) {
69  0 setState(State.COMPLETED);
70   
71  0 if (isMainWiki()) {
72  0 try {
73  0 if (RightsManager.getInstance().countAllGlobalUsersOrGroups(true, null,
74    this.xcontextProvider.get()) == 0) {
75    // If there is no user register one
76  0 setState(null);
77    }
78    } catch (XWikiException e) {
79  0 this.logger.error("Failed to count global users", e);
80    }
81    }
82    }
83    }
84    }