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

File FarmDistributionJob.java

 

Coverage histogram

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

Code metrics

4
27
4
1
132
89
14
0.52
6.75
4
3.5

Classes

Class Line # Actions
FarmDistributionJob 48 27 0% 14 35
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;
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.FirstAdminUserStep;
35    import org.xwiki.extension.distribution.internal.job.step.FlavorDistributionStep;
36    import org.xwiki.extension.distribution.internal.job.step.OutdatedExtensionsDistributionStep;
37    import org.xwiki.extension.distribution.internal.job.step.WikisDefaultUIDistributionStep;
38    import org.xwiki.extension.distribution.internal.job.step.WikisFlavorDistributionStep;
39    import org.xwiki.text.StringUtils;
40   
41    /**
42    * @version $Id: 6d02c50e0c44cfe88e3b4c806a7589604f16b3f5 $
43    * @since 4.2M3
44    */
45    @Component
46    @Named("distribution")
47    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
 
48    public class FarmDistributionJob extends AbstractDistributionJob<DistributionRequest, FarmDistributionJobStatus>
49    {
 
50  0 toggle @Override
51    protected List<DistributionStep> createSteps()
52    {
53  0 List<DistributionStep> steps = new ArrayList<DistributionStep>(4);
54   
55    // Step 1: Create admin user if needed
56  0 try {
57  0 steps.add(
58    this.componentManager.<DistributionStep>getInstance(DistributionStep.class, FirstAdminUserStep.ID));
59    } catch (ComponentLookupException e) {
60  0 this.logger.error("Failed to get first admin step instance", e);
61    }
62   
63    // Step 2: Install/upgrade main wiki UI
64  0 ExtensionId mainUI = getUIExtensionId();
65  0 if (mainUI != null && StringUtils.isNotBlank(mainUI.getId())) {
66    // ... but only if the main extension ID is defined
67  0 try {
68  0 steps.add(this.componentManager.<DistributionStep>getInstance(DistributionStep.class,
69    DefaultUIDistributionStep.ID));
70    } catch (ComponentLookupException e) {
71  0 this.logger.error("Failed to get default UI step instance", e);
72    }
73    } else {
74    // Display the flavor step
75  0 try {
76  0 steps.add(this.componentManager.<DistributionStep>getInstance(DistributionStep.class,
77    FlavorDistributionStep.ID));
78    } catch (ComponentLookupException e) {
79  0 this.logger.error("Failed to get flavor step instance", e);
80    }
81    }
82   
83    // Step 3: Upgrade other wikis
84  0 ExtensionId wikiUI = this.distributionManager.getWikiUIExtensionId();
85  0 if (wikiUI != null && StringUtils.isNotBlank(wikiUI.getId())) {
86    // ... but only if the wiki extension ID is defined
87  0 try {
88  0 steps.add(this.componentManager.<DistributionStep>getInstance(DistributionStep.class,
89    WikisDefaultUIDistributionStep.ID));
90    } catch (ComponentLookupException e) {
91  0 this.logger.error("Failed to get all in one default UI step instance", e);
92    }
93    } else {
94    // Display the wikis flavor step
95  0 try {
96  0 steps.add(this.componentManager.<DistributionStep>getInstance(DistributionStep.class,
97    WikisFlavorDistributionStep.ID));
98    } catch (ComponentLookupException e) {
99  0 this.logger.error("Failed to get all in one flavor step instance", e);
100    }
101    }
102   
103    // Step 4: Upgrade outdated extensions
104  0 try {
105  0 steps.add(this.componentManager.<DistributionStep>getInstance(DistributionStep.class,
106    OutdatedExtensionsDistributionStep.ID));
107    } catch (ComponentLookupException e) {
108  0 this.logger.error("Failed to get outdated extensions step instance", e);
109    }
110   
111  0 return steps;
112    }
113   
 
114  0 toggle @Override
115    public DistributionJobStatus<?> getPreviousStatus()
116    {
117  0 return this.distributionManager.getPreviousFarmJobStatus();
118    }
119   
 
120  0 toggle @Override
121    public ExtensionId getUIExtensionId()
122    {
123  0 return this.distributionManager.getMainUIExtensionId();
124    }
125   
 
126  0 toggle @Override
127    protected FarmDistributionJobStatus createNewDistributionStatus(DistributionRequest request,
128    List<DistributionStep> steps)
129    {
130  0 return new FarmDistributionJobStatus(request, this.observationManager, this.loggerManager, steps);
131    }
132    }