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

File Extension.java

 

Coverage histogram

../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

2
8
4
1
392
80
5
0.62
2
4
1.25

Classes

Class Line # Actions
Extension 37 8 0% 5 14
0.00%
 

Contributing tests

No tests hitting this source file were found.

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;
21   
22    import java.util.ArrayList;
23    import java.util.Collection;
24    import java.util.Collections;
25    import java.util.List;
26    import java.util.Map;
27   
28    import org.xwiki.extension.repository.ExtensionRepository;
29    import org.xwiki.extension.repository.ExtensionRepositoryDescriptor;
30   
31    /**
32    * Represent an extension.
33    *
34    * @version $Id: 23285b469ff4e5c1ea0590c44db32df25656d632 $
35    * @since 4.0M1
36    */
 
37    public interface Extension extends Comparable<Extension>
38    {
39    /**
40    * @see #getRepository()
41    * @since 7.0RC1
42    */
43    String FIELD_REPOSITORY = "repository";
44   
45    /**
46    * @see #getId()
47    * @since 7.0RC1
48    */
49    String FIELD_ID = "id";
50   
51    /**
52    * @see #getId()
53    * @since 7.0RC1
54    */
55    String FIELD_VERSION = "version";
56   
57    /**
58    * @see #getFeatures()
59    * @since 7.0RC1
60    * @deprecated since 9.0RC1/8.4.2, use {@link #FIELD_FEATURE} instead
61    */
62    String FIELD_FEATURE = "feature";
63   
64    /**
65    * @see #getFeatures()
66    * @since 7.0RC1
67    * @deprecated since 9.0RC1/8.4.2, use {@link #FIELD_FEATURES} instead
68    */
69    String FIELD_FEATURES = "features";
70   
71    /**
72    * @see #getFeatures()
73    * @since 9.0RC1
74    * @since 8.4.2
75    */
76    String FIELD_EXTENSIONFEATURE = "extensionfeature";
77   
78    /**
79    * @see #getFeatures()
80    * @since 9.0RC1
81    * @since 8.4.2
82    */
83    String FIELD_EXTENSIONFEATURES = "extensionfeatures";
84   
85    /**
86    * @see #getSummary()
87    * @since 7.0RC1
88    */
89    String FIELD_SUMMARY = "summary";
90   
91    /**
92    * @see #getDescription()
93    * @since 7.0RC1
94    */
95    String FIELD_DESCRIPTION = "description";
96   
97    /**
98    * @see #getAuthors()
99    * @since 7.0RC1
100    */
101    String FIELD_AUTHOR = "author";
102   
103    /**
104    * @see #getAuthors()
105    * @since 7.0RC1
106    */
107    String FIELD_AUTHORS = "authors";
108   
109    /**
110    * @see #getCategory()
111    * @since 7.0RC1
112    */
113    String FIELD_CATEGORY = "category";
114   
115    /**
116    * @see #getLicenses()
117    * @since 7.0RC1
118    */
119    String FIELD_LICENSE = "license";
120   
121    /**
122    * @see #getLicenses()
123    * @since 7.0RC1
124    */
125    String FIELD_LICENSES = "licenses";
126   
127    /**
128    * @see #getName()
129    * @since 7.0RC1
130    */
131    String FIELD_NAME = "name";
132   
133    /**
134    * @see #getType()
135    * @since 7.0RC1
136    */
137    String FIELD_TYPE = "type";
138   
139    /**
140    * @see #getWebSite()
141    * @since 7.0RC1
142    */
143    String FIELD_WEBSITE = "website";
144   
145    /**
146    * @see #getAllowedNamespaces()
147    * @since 8.3M1
148    */
149    String FIELD_NAMESPACES = "namespaces";
150   
151    /**
152    * @see #getAllowedNamespaces()
153    * @since 8.0M1
154    */
155    String FIELD_ALLOWEDNAMESPACE = "allowednamespace";
156   
157    /**
158    * @see #getAllowedNamespaces()
159    * @since 8.0M1
160    */
161    String FIELD_ALLOWEDNAMESPACES = "allowednamespaces";
162   
163    /**
164    * @see #getScm()
165    * @since 7.0RC1
166    */
167    String FIELD_SCM = "scm";
168   
169    /**
170    * @see #getRepositories()
171    * @since 7.3M1
172    */
173    String FIELD_REPOSITORIES = "repositories";
174   
175    /**
176    * @see #getProperties()
177    * @since 7.4.3
178    * @since 8.0.1
179    * @since 8.1M1
180    */
181    String FIELD_PROPERTIES = "properties";
182   
183    /**
184    * @see #getIssueManagement()
185    * @since 9.0RC1
186    * @since 8.4.2
187    */
188    String FIELD_ISSUEMANAGEMENT = "issuemanagement";
189   
190    /**
191    * @see #getManagedDependencies()
192    * @since 9.0RC1
193    * @since 8.4.2
194    */
195    String FIELD_MANAGEDDEPENDENCIES = "manageddependencies";
196   
197    /**
198    * @see #getDependencies()
199    * @since 9.0RC1
200    * @since 8.4.2
201    */
202    String FIELD_DEPENDENCIES = "dependencies";
203   
204    /**
205    * Prefix to use for custom properties names in external systems (Maven, etc).
206    *
207    * @since 8.3M1
208    */
209    String IKEYPREFIX = "xwiki.extension.";
210   
211    /**
212    * Get an extension field (name, summary, id, etc.) by name. Fallback on properties.
213    *
214    * @param <T> type of the field value
215    * @param fieldName the field name;
216    * @return the field value or null if none could be found
217    * @since 7.0RC1
218    */
219    <T> T get(String fieldName);
220   
221    /**
222    * @return the id/version combination which makes the extension unique
223    */
224    ExtensionId getId();
225   
226    /**
227    * Indicate in an extension a list of provided "functionalities". Then when resolving extensions dependencies they
228    * can be matched in this list.
229    *
230    * @return the extension ids also provided by this extension, an empty collection if there is none
231    * @deprecated since 8.0M1, use {@link #getExtensionFeatures()} instead
232    */
233    @Deprecated
234    Collection<String> getFeatures();
235   
236    /**
237    * Indicate in an extension a list of provided "functionalities". Then when resolving extensions dependencies they
238    * can be matched in this list.
239    *
240    * @return the {@link ExtensionId}s also provided by this extension, an empty collection if there is none
241    * @since 8.0M1
242    */
 
243  0 toggle default Collection<ExtensionId> getExtensionFeatures()
244    {
245  0 Collection<String> features = getFeatures();
246  0 List<ExtensionId> extensionFeatures = new ArrayList<ExtensionId>(features.size());
247  0 for (String feature : features) {
248  0 extensionFeatures.add(new ExtensionId(feature, getId().getVersion()));
249    }
250   
251  0 return extensionFeatures;
252    }
253   
254    /**
255    * Return the {@link ExtensionId} object that matches the passed feature id.
256    *
257    * @param featureId the id of the feature
258    * @return the {@link ExtensionId} associated to the passed id
259    * @since 8.0M1
260    */
 
261  0 toggle default ExtensionId getExtensionFeature(String featureId)
262    {
263  0 return getFeatures().contains(featureId) ? new ExtensionId(featureId, getId().getVersion()) : null;
264    }
265   
266    /**
267    * @return the type of the extension
268    */
269    String getType();
270   
271    /**
272    * @return the display name of the extension
273    */
274    String getName();
275   
276    /**
277    * @return the license of the extension, an empty collection if there is none
278    */
279    Collection<ExtensionLicense> getLicenses();
280   
281    /**
282    * @return a short description of the extension
283    */
284    String getSummary();
285   
286    /**
287    * @return a description of the extension
288    */
289    String getDescription();
290   
291    /**
292    * @return an URL for the extension website
293    */
294    String getWebSite();
295   
296    /**
297    * @return the extension authors, an empty collection if there is none
298    */
299    Collection<ExtensionAuthor> getAuthors();
300   
301    /**
302    * @return the namespaces where it's allowed to install this extension
303    * @since 8.0M1
304    */
 
305  0 toggle default Collection<String> getAllowedNamespaces()
306    {
307  0 return Collections.emptyList();
308    }
309   
310    /**
311    * @return the dependencies of the extension, an empty collection if there is none
312    */
313    Collection<ExtensionDependency> getDependencies();
314   
315    /**
316    * Managed dependencies are used to override transitive dependencies (usually the version of this transitive
317    * dependency).
318    *
319    * @return the managed dependencies, empty list if there is none
320    * @since 8.1M1
321    */
 
322  0 toggle default Collection<ExtensionDependency> getManagedDependencies()
323    {
324  0 return Collections.emptyList();
325    }
326   
327    /**
328    * Return extension file descriptor. Also allows to get the content of the file.
329    *
330    * @return the file of the extension
331    */
332    ExtensionFile getFile();
333   
334    /**
335    * @return the repository of the extension
336    */
337    ExtensionRepository getRepository();
338   
339    /**
340    * @return informations related to extensions's source control management
341    * @since 6.3M1
342    */
343    ExtensionScm getScm();
344   
345    /**
346    * @return informations related to extension's issues management
347    * @since 6.3M1
348    */
349    ExtensionIssueManagement getIssueManagement();
350   
351    /**
352    * @return the category of the extension
353    * @since 7.0M2
354    */
355    String getCategory();
356   
357    /**
358    * @return the custom repositories provided by the extension (usually to resolve dependencies)
359    * @since 7.3M1
360    */
361    Collection<ExtensionRepositoryDescriptor> getRepositories();
362   
363    // Custom properties
364   
365    /**
366    * Extends {@link Extension} standard properties.
367    * <p>
368    * Theses are generally provided by specific repositories. For example a maven repository will provide group and
369    * artifacts ids.
370    *
371    * @return the properties
372    */
373    Map<String, Object> getProperties();
374   
375    /**
376    * @param <T> type of the property value
377    * @param key the property key
378    * @return the property value
379    */
380    <T> T getProperty(String key);
381   
382    /**
383    * Get a property.
384    *
385    * @param <T> type of the property value
386    * @param key the property key
387    * @param def the value to return if no property is associated to the provided key
388    * @return the property value or <code>default</code> of the property is not found
389    * @see #getProperty(String)
390    */
391    <T> T getProperty(String key, T def);
392    }