1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.extension.job.internal

File InstallPlanJob.java

 

Coverage histogram

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

Code metrics

4
15
3
1
90
49
5
0.33
5
3
1.67

Classes

Class Line # Actions
InstallPlanJob 41 15 0% 5 2
0.9090909490.9%
 

Contributing tests

This file is covered by 99 tests. .

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.job.internal;
21   
22    import java.util.Collection;
23    import java.util.LinkedHashMap;
24    import java.util.Map;
25   
26    import javax.inject.Named;
27   
28    import org.xwiki.component.annotation.Component;
29    import org.xwiki.extension.ExtensionId;
30    import org.xwiki.extension.job.InstallRequest;
31    import org.xwiki.job.Request;
32   
33    /**
34    * Create an Extension installation plan.
35    *
36    * @version $Id: 6390f350a35c53be416cbc79c122a79aacda9815 $
37    * @since 4.0M1
38    */
39    @Component
40    @Named(InstallPlanJob.JOBTYPE)
 
41    public class InstallPlanJob extends AbstractInstallPlanJob<InstallRequest>
42    {
43    /**
44    * The id of the job.
45    */
46    public static final String JOBTYPE = "installplan";
47   
 
48  890 toggle @Override
49    public String getType()
50    {
51  890 return JOBTYPE;
52    }
53   
 
54  187 toggle @Override
55    protected InstallRequest castRequest(Request request)
56    {
57  187 InstallRequest installRequest;
58  187 if (request instanceof InstallRequest) {
59  187 installRequest = (InstallRequest) request;
60    } else {
61  0 installRequest = new InstallRequest(request);
62    }
63   
64  187 return installRequest;
65    }
66   
 
67  187 toggle @Override
68    protected void runInternal() throws Exception
69    {
70  187 Map<ExtensionId, Collection<String>> extensionsByNamespace =
71    new LinkedHashMap<ExtensionId, Collection<String>>();
72   
73  187 Collection<ExtensionId> extensions = getRequest().getExtensions();
74   
75  187 for (ExtensionId extensionId : extensions) {
76  199 if (getRequest().hasNamespaces()) {
77  118 Collection<String> namespaces = getRequest().getNamespaces();
78   
79  118 for (String namespace : namespaces) {
80  119 addExtensionToProcess(extensionsByNamespace, extensionId, namespace);
81    }
82    } else {
83  81 addExtensionToProcess(extensionsByNamespace, extensionId, null);
84    }
85    }
86   
87    // Start the actual plan creation
88  187 start(extensionsByNamespace);
89    }
90    }