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

File DefaultExtensionValidatorProvider.java

 

Coverage histogram

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

Code metrics

0
4
4
1
89
49
5
1.25
1
4
1.25

Classes

Class Line # Actions
DefaultExtensionValidatorProvider 46 4 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 98 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.handler.internal;
21   
22    import javax.inject.Inject;
23    import javax.inject.Provider;
24    import javax.inject.Singleton;
25   
26    import org.xwiki.component.annotation.Component;
27    import org.xwiki.component.manager.ComponentLookupException;
28    import org.xwiki.component.manager.ComponentManager;
29    import org.xwiki.component.phase.Initializable;
30    import org.xwiki.component.phase.InitializationException;
31    import org.xwiki.extension.Extension;
32    import org.xwiki.extension.InstallException;
33    import org.xwiki.extension.InstalledExtension;
34    import org.xwiki.extension.UninstallException;
35    import org.xwiki.extension.handler.ExtensionValidator;
36    import org.xwiki.job.Request;
37   
38    /**
39    * Make sure to always provide a validator.
40    *
41    * @version $Id: 3ff0a74b6af1f42cf7f08b1c04b12f2e6e96cffb $
42    * @since 4.2M2
43    */
44    @Component
45    @Singleton
 
46    public class DefaultExtensionValidatorProvider implements Provider<ExtensionValidator>, Initializable
47    {
48    /**
49    * Used to lookup the actual validator.
50    */
51    @Inject
52    private ComponentManager componentManager;
53   
54    /**
55    * The validator is kept in cache.
56    */
57    private ExtensionValidator defaultValidator;
58   
 
59  141 toggle @Override
60    public void initialize() throws InitializationException
61    {
62  141 try {
63  141 this.defaultValidator = this.componentManager.getInstance(ExtensionValidator.class);
64    } catch (ComponentLookupException e) {
65  107 this.defaultValidator = new ExtensionValidator()
66    {
 
67  75 toggle @Override
68    public void checkUninstall(InstalledExtension extension, String namespace, Request request)
69    throws UninstallException
70    {
71    // Valid
72    }
73   
 
74  171 toggle @Override
75    public void checkInstall(Extension extension, String namespace, Request request)
76    throws InstallException
77    {
78    // Valid
79    }
80    };
81    }
82    }
83   
 
84  352 toggle @Override
85    public ExtensionValidator get()
86    {
87  352 return this.defaultValidator;
88    }
89    }