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

File InstalledExtensionRepository.java

 

Coverage histogram

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

Code metrics

2
2
2
1
218
50
4
2
1
2
2

Classes

Class Line # Actions
InstalledExtensionRepository 47 2 0% 4 6
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.repository;
21   
22    import java.util.Collection;
23    import java.util.Map;
24   
25    import org.xwiki.component.annotation.Role;
26    import org.xwiki.extension.ExtensionDependency;
27    import org.xwiki.extension.ExtensionId;
28    import org.xwiki.extension.InstallException;
29    import org.xwiki.extension.InstalledExtension;
30    import org.xwiki.extension.LocalExtension;
31    import org.xwiki.extension.ResolveException;
32    import org.xwiki.extension.UninstallException;
33    import org.xwiki.extension.repository.result.IterableResult;
34    import org.xwiki.extension.repository.search.AdvancedSearchable;
35    import org.xwiki.extension.repository.search.ExtensionQuery;
36    import org.xwiki.extension.repository.search.SearchException;
37   
38    /**
39    * A repository containing installed extension.
40    * <p>
41    * It's generally a virtual repository since the actual extension are generally stored in the local repository.
42    *
43    * @version $Id: 125c8982a2a7d47fe44e427390efb843e4024a96 $
44    * @since 4.0M2
45    */
46    @Role
 
47    public interface InstalledExtensionRepository extends ExtensionRepository, AdvancedSearchable
48    {
49    /**
50    * @return the number of local extensions
51    */
52    int countExtensions();
53   
54    /**
55    * Return the installed extension associated to the provided feature for the provided namespace (or root namespace
56    * since namespaces inherit from root).
57    *
58    * @param feature the extension id or provided feature (virtual extension)
59    * @param namespace the namespace where the extension is installed, null mean installed in all namespaces (root
60    * namespace)
61    * @return the extension, null if none could be found
62    */
63    InstalledExtension getInstalledExtension(String feature, String namespace);
64   
65    /**
66    * @return all installed local extensions, an empty collection if none could be found
67    */
68    Collection<InstalledExtension> getInstalledExtensions();
69   
70    /**
71    * Return all the extensions available for the provided namespace. This also include root extension since namespaces
72    * inherit from root.
73    * <p>
74    * Note that {@link #getInstalledExtensions()} return all the extensions installed in all namespaces while
75    * {@link #getInstalledExtensions(String)} with <code>null</code> return only those that are globally available.
76    *
77    * @param namespace the namespace where to search for installed extensions, null mean installed in all namespaces
78    * (root namespace)
79    * @return all the local extensions installed in the provided namespace, an empty collection if none could be found
80    */
81    Collection<InstalledExtension> getInstalledExtensions(String namespace);
82   
83    /**
84    * Indicate that the provided extension is installed in the provided namespace.
85    *
86    * @param extension the extension to install
87    * @param namespace the namespace in which the extension is installed
88    * @param dependency indicate if the extension is stored as a dependency of another one
89    * @return the new {@link InstalledExtension}
90    * @throws InstallException error when trying to install provided extension
91    */
92    InstalledExtension installExtension(LocalExtension extension, String namespace, boolean dependency)
93    throws InstallException;
94   
95    /**
96    * Indicate that the provided extension is installed in the specified namespace with the given properties.
97    *
98    * @param extension the extension to install
99    * @param namespace the namespace in which the extension is installed
100    * @param dependency indicate if the installed extension is stored as a dependency of another extension
101    * @param properties the custom properties to set on the installed extension for the specified namespace
102    * @return the new {@link InstalledExtension}
103    * @throws InstallException error when trying to install provided extension
104    * @since 7.0M2
105    */
106    InstalledExtension installExtension(LocalExtension extension, String namespace, boolean dependency,
107    Map<String, Object> properties) throws InstallException;
108   
109    /**
110    * Return extension descriptor from the repository. If the extension can't be found <code>null</code> is returned.
111    *
112    * @param extensionId the extension identifier
113    * @return the found extension descriptor or null if none could be found
114    * @since 4.2RC1
115    */
116    InstalledExtension getInstalledExtension(ExtensionId extensionId);
117   
118    /**
119    * Indicate that the provided extension is uninstalled from provided namespace.
120    * <p>
121    * Extension is never removed form the local repository. It's just namespace related informations.
122    *
123    * @param extension the extension to uninstall
124    * @param namespace the namespace from which the extension is uninstalled
125    * @throws UninstallException error when trying to uninstall provided extension
126    */
127    void uninstallExtension(InstalledExtension extension, String namespace) throws UninstallException;
128   
129    /**
130    * Get provided installed extension backward dependencies in the provided namespace.
131    * <p>
132    * Only look at the backward dependencies in the provided namespace. To get all the dependencies of a root extension
133    * (namespace=null) across namespaces use {@link #getBackwardDependencies(ExtensionId)} instead.
134    *
135    * @param feature the extension unique identifier
136    * @param namespace the namespace where to search for backward dependencies
137    * @return the backward dependencies, an empty collection of none could be found
138    * @throws ResolveException error when searching for backward dependencies
139    */
140    Collection<InstalledExtension> getBackwardDependencies(String feature, String namespace) throws ResolveException;
141   
142    /**
143    * Get all backward dependencies by namespace for the provided installed extension.
144    *
145    * @param extensionId the extension identifier
146    * @return the extension backward dependencies in all namespaces
147    * @throws ResolveException error when searching for extension backward dependencies
148    */
149    Map<String, Collection<InstalledExtension>> getBackwardDependencies(ExtensionId extensionId)
150    throws ResolveException;
151   
152    // ExtensionRepository
153   
154    @Override
155    InstalledExtension resolve(ExtensionDependency extensionDependency) throws ResolveException;
156   
157    @Override
158    InstalledExtension resolve(ExtensionId extensionId) throws ResolveException;
159   
160    // Search
161   
162    /**
163    * Search installed extensions based of the provided pattern and only in the passed namespace.
164    * <p>
165    * The pattern is a simple character chain.
166    *
167    * @param pattern the pattern to search
168    * @param namespace the namespace where to search
169    * @param offset the offset from where to start returning search results
170    * @param nb the maximum number of search results to return
171    * @return the found extensions descriptors, empty list if nothing could be found
172    * @throws SearchException error when trying to search provided pattern
173    * @since 5.3M1
174    */
175    IterableResult<InstalledExtension> searchInstalledExtensions(String pattern, String namespace, int offset, int nb)
176    throws SearchException;
177   
178    /**
179    * Search installed extensions based of the provided query and only in the passed namespace.
180    *
181    * @param namespace the namespace where to search
182    * @param query the extension query used to filter and order the result
183    * @return the found extensions descriptors, empty list if nothing could be found
184    * @throws SearchException error when trying to search provided pattern
185    * @since 7.0M2
186    */
187    IterableResult<InstalledExtension> searchInstalledExtensions(String namespace, ExtensionQuery query)
188    throws SearchException;
189   
190    /**
191    * Search installed extensions based of the provided query.
192    *
193    * @param query the extension query used to filter and order the result
194    * @return the found extensions descriptors, empty list if nothing could be found
195    * @throws SearchException error when trying to search provided pattern
196    * @since 8.1RC1
197    */
 
198  0 toggle default IterableResult<InstalledExtension> searchInstalledExtensions(ExtensionQuery query) throws SearchException
199    {
200  0 return searchInstalledExtensions((String) null, query);
201    }
202   
203    /**
204    * Search installed extensions based of the provided query and only in the passed namespaces.
205    *
206    * @param namespaces the namespaces where to search
207    * @param query the extension query used to filter and order the result
208    * @return the found extensions descriptors, empty list if nothing could be found
209    * @throws SearchException error when trying to search provided pattern
210    * @since 8.1RC1
211    */
 
212  0 toggle default IterableResult<InstalledExtension> searchInstalledExtensions(Collection<String> namespaces,
213    ExtensionQuery query) throws SearchException
214    {
215  0 return searchInstalledExtensions(
216  0 namespaces != null && !namespaces.isEmpty() ? namespaces.iterator().next() : null, query);
217    }
218    }