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

File WikiDistributionJob.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

2
16
4
1
101
64
9
0.56
4
4
2.25

Classes

Class Line # Actions
WikiDistributionJob 45 16 0% 9 6
0.7272727572.7%
 

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;
21   
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import javax.inject.Named;
26   
27    import org.xwiki.component.annotation.Component;
28    import org.xwiki.component.annotation.InstantiationStrategy;
29    import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
30    import org.xwiki.component.manager.ComponentLookupException;
31    import org.xwiki.extension.ExtensionId;
32    import org.xwiki.extension.distribution.internal.job.step.DefaultUIDistributionStep;
33    import org.xwiki.extension.distribution.internal.job.step.DistributionStep;
34    import org.xwiki.extension.distribution.internal.job.step.FlavorDistributionStep;
35    import org.xwiki.extension.distribution.internal.job.step.OutdatedExtensionsDistributionStep;
36    import org.xwiki.text.StringUtils;
37   
38    /**
39    * @version $Id: 1aecd7cf0f32cd2b8d60c8f33e0fbd7bc46b12bd $
40    * @since 5.0M1
41    */
42    @Component
43    @Named("wikidistribution")
44    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
 
45    public class WikiDistributionJob extends AbstractDistributionJob<DistributionRequest, WikiDistributionJobStatus>
46    {
 
47  3 toggle @Override
48    protected List<DistributionStep> createSteps()
49    {
50  3 List<DistributionStep> steps = new ArrayList<DistributionStep>(3);
51   
52    // Step 1: Install/upgrade the wiki UI
53  3 ExtensionId wikiUI = this.distributionManager.getWikiUIExtensionId();
54  3 if (wikiUI != null && StringUtils.isNotBlank(wikiUI.getId())) {
55    // ... but only if the wiki extension ID is defined
56  3 try {
57  3 steps.add(this.componentManager.<DistributionStep>getInstance(DistributionStep.class,
58    DefaultUIDistributionStep.ID));
59    } catch (ComponentLookupException e) {
60  0 this.logger.error("Failed to get default UI step instance", e);
61    }
62    } else {
63    // Display the wikis flavor step
64  0 try {
65  0 steps.add(this.componentManager.<DistributionStep>getInstance(DistributionStep.class,
66    FlavorDistributionStep.ID));
67    } catch (ComponentLookupException e) {
68  0 this.logger.error("Failed to get the flavor step instance", e);
69    }
70    }
71   
72    // Step 2: Upgrade outdated extensions
73  3 try {
74  3 steps.add(this.componentManager.<DistributionStep>getInstance(DistributionStep.class,
75    OutdatedExtensionsDistributionStep.ID));
76    } catch (ComponentLookupException e) {
77  0 this.logger.error("Failed to get outdated extensions step instance", e);
78    }
79   
80  3 return steps;
81    }
82   
 
83  15 toggle @Override
84    public DistributionJobStatus<?> getPreviousStatus()
85    {
86  15 return this.distributionManager.getPreviousWikiJobStatus(getRequest().getWiki());
87    }
88   
 
89  3 toggle @Override
90    public ExtensionId getUIExtensionId()
91    {
92  3 return this.distributionManager.getWikiUIExtensionId();
93    }
94   
 
95  3 toggle @Override
96    protected WikiDistributionJobStatus createNewDistributionStatus(DistributionRequest request,
97    List<DistributionStep> steps)
98    {
99  3 return new WikiDistributionJobStatus(request, this.observationManager, this.loggerManager, steps);
100    }
101    }