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

File UninstallPlanJob.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

10
23
3
1
104
62
8
0.35
7.67
3
2.67

Classes

Class Line # Actions
UninstallPlanJob 41 23 0% 8 2
0.944444494.4%
 

Contributing tests

This file is covered by 37 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.ArrayList;
23    import java.util.Collection;
24   
25    import javax.inject.Named;
26   
27    import org.xwiki.component.annotation.Component;
28    import org.xwiki.extension.ExtensionId;
29    import org.xwiki.extension.InstalledExtension;
30    import org.xwiki.extension.job.UninstallRequest;
31    import org.xwiki.job.Request;
32   
33    /**
34    * Create an Extension uninstallation plan.
35    *
36    * @version $Id: f9d7c98811300d90642b994f5047c4ca9a5c96c8 $
37    * @since 4.0M1
38    */
39    @Component
40    @Named(UninstallPlanJob.JOBTYPE)
 
41    public class UninstallPlanJob extends AbstractExtensionPlanJob<UninstallRequest>
42    {
43    /**
44    * The id of the job.
45    */
46    public static final String JOBTYPE = "uninstallplan";
47   
 
48  363 toggle @Override
49    public String getType()
50    {
51  363 return JOBTYPE;
52    }
53   
 
54  60 toggle @Override
55    protected UninstallRequest castRequest(Request request)
56    {
57  60 UninstallRequest uninstallRequest;
58  60 if (request instanceof UninstallRequest) {
59  60 uninstallRequest = (UninstallRequest) request;
60    } else {
61  0 uninstallRequest = new UninstallRequest(request);
62    }
63   
64  60 return uninstallRequest;
65    }
66   
 
67  60 toggle @Override
68    protected void runInternal() throws Exception
69    {
70  60 Collection<ExtensionId> extensions = getRequest().getExtensions();
71   
72  60 this.progressManager.pushLevelProgress(extensions.size(), this);
73   
74  60 try {
75  60 for (ExtensionId extensionId : extensions) {
76  60 this.progressManager.startStep(this);
77   
78  60 if (extensionId.getVersion() != null) {
79  42 InstalledExtension installedExtension = this.installedExtensionRepository.resolve(extensionId);
80   
81  41 if (getRequest().hasNamespaces()) {
82  15 uninstallExtension(installedExtension, getRequest().getNamespaces(), this.extensionTree, true);
83  26 } else if (installedExtension.getNamespaces() != null) {
84    // Duplicate the namespace list to avoid ConcurrentModificationException
85  6 uninstallExtension(installedExtension,
86    new ArrayList<String>(installedExtension.getNamespaces()), this.extensionTree, true);
87    } else {
88  20 uninstallExtension(installedExtension, (String) null, this.extensionTree, true);
89    }
90    } else {
91  18 if (getRequest().hasNamespaces()) {
92  16 uninstallExtension(extensionId.getId(), getRequest().getNamespaces(), this.extensionTree, true);
93    } else {
94  2 uninstallExtension(extensionId.getId(), (String) null, this.extensionTree, true);
95    }
96    }
97   
98  55 this.progressManager.endStep(this);
99    }
100    } finally {
101  60 this.progressManager.popLevelProgress(this);
102    }
103    }
104    }