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

File DefaultUIDistributionStep.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

6
9
2
1
74
39
6
0.67
4.5
2
3

Classes

Class Line # Actions
DefaultUIDistributionStep 41 9 0% 6 3
0.823529482.4%
 

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   
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.extension.ExtensionId;
29    import org.xwiki.extension.InstalledExtension;
30    import org.xwiki.extension.repository.InstalledExtensionRepository;
31   
32    /**
33    * Install the default UI extension of the wiki.
34    *
35    * @version $Id: b68dd44a7c47b639c2ecb094dc977b40fa2df015 $
36    * @since 5.0RC1
37    */
38    @Component
39    @Named(DefaultUIDistributionStep.ID)
40    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
 
41    public class DefaultUIDistributionStep extends AbstractDistributionStep
42    {
43    public static final String ID = "extension.defaultui";
44   
45    @Inject
46    private transient InstalledExtensionRepository installedRepository;
47   
 
48  3 toggle public DefaultUIDistributionStep()
49    {
50  3 super(ID);
51    }
52   
 
53  4 toggle @Override
54    public void prepare()
55    {
56  4 if (getState() == null) {
57  1 setState(State.COMPLETED);
58   
59  1 String namespace = getNamespace();
60   
61  1 ExtensionId extensionUI = this.distributionJob.getStatus().getDistributionExtensionUI();
62   
63    // Only if the UI is not already installed
64  1 if (extensionUI != null) {
65  1 InstalledExtension installedExtension =
66    this.installedRepository.getInstalledExtension(extensionUI.getId(), namespace);
67  1 if (installedExtension == null
68    || !installedExtension.getId().getVersion().equals(extensionUI.getVersion())) {
69  0 setState(null);
70    }
71    }
72    }
73    }
74    }