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

File AbstractExtensionRepository.java

 

Coverage histogram

../../../../img/srcFileCovDistChart5.png
74% of files have more coverage

Code metrics

0
12
8
1
113
50
9
0.75
1.5
8
1.12

Classes

Class Line # Actions
AbstractExtensionRepository 31 12 0% 9 11
0.4545%
 

Contributing tests

This file is covered by 78 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.repository;
21   
22    import org.xwiki.extension.ExtensionId;
23    import org.xwiki.extension.ResolveException;
24   
25    /**
26    * Base class for {@link ExtensionRepository} implementations.
27    *
28    * @version $Id: b0334041708f2b5bc6d1d901f910ee516ce5e6d6 $
29    * @since 4.0M1
30    */
 
31    public abstract class AbstractExtensionRepository implements ExtensionRepository
32    {
33    /**
34    * @see #getDescriptor()
35    */
36    private ExtensionRepositoryDescriptor descriptor;
37   
38    /**
39    * Default constructor. Used by extended classes which can't set the id in there constructor but make sure it's set
40    * later or that {@link #getId()} is overwritten.
41    */
 
42  735 toggle protected AbstractExtensionRepository()
43    {
44   
45    }
46   
47    /**
48    * @param descriptor the repository descriptor
49    * @since 4.3M1
50    */
 
51  422 toggle protected AbstractExtensionRepository(ExtensionRepositoryDescriptor descriptor)
52    {
53  422 setDescriptor(descriptor);
54    }
55   
56    /**
57    * @param id the repository identifier
58    * @deprecated since 4.3M1 use {@link #AbstractExtensionRepository(ExtensionRepositoryDescriptor)} instead
59    */
 
60  0 toggle @Deprecated
61    protected AbstractExtensionRepository(ExtensionRepositoryId id)
62    {
63  0 setId(new ExtensionRepositoryId(id));
64    }
65   
66    /**
67    * @param descriptor the repository descriptor
68    * @since 4.3M1
69    */
 
70  1157 toggle protected void setDescriptor(ExtensionRepositoryDescriptor descriptor)
71    {
72  1157 this.descriptor = descriptor;
73    }
74   
75    /**
76    * @param id the repository identifier
77    * @deprecated since 4.3M1 use {@link #setDescriptor(ExtensionRepositoryDescriptor)} instead
78    */
 
79  0 toggle @Deprecated
80    protected void setId(ExtensionRepositoryId id)
81    {
82  0 this.descriptor = id;
83    }
84   
85    // ExtensionRepository
86   
 
87  2966 toggle @Override
88    public ExtensionRepositoryDescriptor getDescriptor()
89    {
90  2966 return this.descriptor;
91    }
92   
 
93  3 toggle @Override
94    public ExtensionRepositoryId getId()
95    {
96  3 return new ExtensionRepositoryId(this.descriptor);
97    }
98   
 
99  0 toggle @Override
100    public boolean exists(ExtensionId extensionId)
101    {
102  0 boolean exists;
103   
104  0 try {
105  0 resolve(extensionId);
106  0 exists = true;
107    } catch (ResolveException e) {
108  0 exists = false;
109    }
110   
111  0 return exists;
112    }
113    }