1. Project Clover database Tue Dec 20 2016 21:24:09 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
22
3
1
102
61
8
0.36
7.33
3
2.67

Classes

Class Line # Actions
UninstallPlanJob 41 22 0% 8 2
0.9428571594.3%
 

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: e314026bf675e631e034c038c9cd998d4125e48a $
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  293 toggle @Override
49    public String getType()
50    {
51  293 return JOBTYPE;
52    }
53   
 
54  58 toggle @Override
55    protected UninstallRequest castRequest(Request request)
56    {
57  58 UninstallRequest uninstallRequest;
58  58 if (request instanceof UninstallRequest) {
59  58 uninstallRequest = (UninstallRequest) request;
60    } else {
61  0 uninstallRequest = new UninstallRequest(request);
62    }
63   
64  58 return uninstallRequest;
65    }
66   
 
67  58 toggle @Override
68    protected void runInternal() throws Exception
69    {
70  58 Collection<ExtensionId> extensions = getRequest().getExtensions();
71   
72  58 this.progressManager.pushLevelProgress(extensions.size(), this);
73   
74  58 try {
75  58 for (ExtensionId extensionId : extensions) {
76  58 this.progressManager.startStep(this);
77   
78  58 if (extensionId.getVersion() != null) {
79  40 InstalledExtension installedExtension = this.installedExtensionRepository.resolve(extensionId);
80   
81  39 if (getRequest().hasNamespaces()) {
82  15 uninstallExtension(installedExtension, getRequest().getNamespaces(), this.extensionTree, true);
83  24 } 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  18 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    } finally {
99  58 this.progressManager.popLevelProgress(this);
100    }
101    }
102    }