org.xwiki.extension.repository.internal.installed
Class DefaultInstalledExtensionRepository

java.lang.Object
  extended by org.xwiki.extension.repository.AbstractExtensionRepository
      extended by org.xwiki.extension.repository.internal.local.AbstractCachedExtensionRepository<DefaultInstalledExtension>
          extended by org.xwiki.extension.repository.internal.installed.DefaultInstalledExtensionRepository
All Implemented Interfaces:
Initializable, ExtensionRepository, InstalledExtensionRepository, Searchable

@Component
@Singleton
public class DefaultInstalledExtensionRepository
extends AbstractCachedExtensionRepository<DefaultInstalledExtension>
implements InstalledExtensionRepository, Initializable

Default implementation of InstalledExtensionRepository.

Since:
4.0M2

Field Summary
 
Fields inherited from class org.xwiki.extension.repository.internal.local.AbstractCachedExtensionRepository
extensions, extensionsVersions
 
Constructor Summary
DefaultInstalledExtensionRepository()
           
 
Method Summary
 int countExtensions()
           
 Map<String,Collection<InstalledExtension>> getBackwardDependencies(ExtensionId extensionId)
          Get all backward dependencies by namespace for the provided installed extension.
 Collection<InstalledExtension> getBackwardDependencies(String feature, String namespace)
          Get provided installed extension backward dependencies in the provided namespace.
 InstalledExtension getInstalledExtension(ExtensionId extensionId)
          Return extension descriptor from the repository.
 InstalledExtension getInstalledExtension(String feature, String namespace)
          Return the installed extension associated to the provided feature for the provided namespace (or root namespace since namespaces inherit from root).
 Collection<InstalledExtension> getInstalledExtensions()
           
 Collection<InstalledExtension> getInstalledExtensions(String namespace)
          Return all the extensions available for the provided namespace.
 void initialize()
          Method called by the Component Manager when the component is created for the first time (i.e.
 InstalledExtension installExtension(LocalExtension extension, String namespace, boolean dependency)
          Indicate that the provided extension is installed in the provided namespace.
 void uninstallExtension(InstalledExtension extension, String namespace)
          Indicate that the provided extension is uninstalled from provided namespace.
 
Methods inherited from class org.xwiki.extension.repository.internal.local.AbstractCachedExtensionRepository
addCachedExtension, addCachedExtensionVersion, exists, removeCachedExtension, resolve, resolve, resolveVersions, search
 
Methods inherited from class org.xwiki.extension.repository.AbstractExtensionRepository
getDescriptor, getId, setDescriptor, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xwiki.extension.repository.InstalledExtensionRepository
resolve, resolve
 
Methods inherited from interface org.xwiki.extension.repository.ExtensionRepository
exists, getDescriptor, getId, resolveVersions
 
Methods inherited from interface org.xwiki.extension.repository.search.Searchable
search
 

Constructor Detail

DefaultInstalledExtensionRepository

public DefaultInstalledExtensionRepository()
Method Detail

initialize

public void initialize()
                throws InitializationException
Description copied from interface: Initializable
Method called by the Component Manager when the component is created for the first time (i.e. when it's looked up for the first time or if the component is specified as being loaded on startup). If the component instantiation strategy is singleton then this method is called only once during the lifecycle of the Component Manager. Otherwise the component is created at each lookup and thus this method is called at each lookup too.

Specified by:
initialize in interface Initializable
Throws:
InitializationException - if an error happens during a component's initialization

countExtensions

public int countExtensions()
Specified by:
countExtensions in interface InstalledExtensionRepository
Returns:
the number of local extensions

getInstalledExtensions

public Collection<InstalledExtension> getInstalledExtensions(String namespace)
Description copied from interface: InstalledExtensionRepository
Return all the extensions available for the provided namespace. This also include root extension since namespaces inherit from root.

Note that InstalledExtensionRepository.getInstalledExtensions() return all the extensions installed in all namespaces while InstalledExtensionRepository.getInstalledExtensions(String) with null return only those that are globally available.

Specified by:
getInstalledExtensions in interface InstalledExtensionRepository
Parameters:
namespace - the namespace where to search for installed extensions, null mean installed in all namespaces (root namespace)
Returns:
all the local extensions installed in the provided namespace, an empty collection if none could be found

getInstalledExtensions

public Collection<InstalledExtension> getInstalledExtensions()
Specified by:
getInstalledExtensions in interface InstalledExtensionRepository
Returns:
all installed local extensions, an empty collection if none could be found

getInstalledExtension

public InstalledExtension getInstalledExtension(ExtensionId extensionId)
Description copied from interface: InstalledExtensionRepository
Return extension descriptor from the repository. If the extension can't be found null is returned.

Specified by:
getInstalledExtension in interface InstalledExtensionRepository
Parameters:
extensionId - the extension identifier
Returns:
the found extension descriptor or null if none could be found

getInstalledExtension

public InstalledExtension getInstalledExtension(String feature,
                                                String namespace)
Description copied from interface: InstalledExtensionRepository
Return the installed extension associated to the provided feature for the provided namespace (or root namespace since namespaces inherit from root).

Specified by:
getInstalledExtension in interface InstalledExtensionRepository
Parameters:
feature - the extension id or provided feature (virtual extension)
namespace - the namespace where the extension is installed, null mean installed in all namespaces (root namespace)
Returns:
the extension, null if none could be found

installExtension

public InstalledExtension installExtension(LocalExtension extension,
                                           String namespace,
                                           boolean dependency)
                                    throws InstallException
Description copied from interface: InstalledExtensionRepository
Indicate that the provided extension is installed in the provided namespace.

Specified by:
installExtension in interface InstalledExtensionRepository
Parameters:
extension - the extension to install
namespace - the namespace in which the extension is installed
dependency - indicate if the extension is stored as a dependency of another one
Returns:
the new InstalledExtension
Throws:
InstallException - error when trying to install provided extension

uninstallExtension

public void uninstallExtension(InstalledExtension extension,
                               String namespace)
                        throws UninstallException
Description copied from interface: InstalledExtensionRepository
Indicate that the provided extension is uninstalled from provided namespace.

Extension is never removed form the local repository. It's just namespace related informations.

Specified by:
uninstallExtension in interface InstalledExtensionRepository
Parameters:
extension - the extension to uninstall
namespace - the namespace from which the extension is uninstalled
Throws:
UninstallException - error when trying to uninstall provided extension

getBackwardDependencies

public Collection<InstalledExtension> getBackwardDependencies(String feature,
                                                              String namespace)
                                                       throws ResolveException
Description copied from interface: InstalledExtensionRepository
Get provided installed extension backward dependencies in the provided namespace.

Only look at the backward dependencies in the provided namespace. To get all the dependencies of a root extension (namespace=null) across namespaces use InstalledExtensionRepository.getBackwardDependencies(ExtensionId) instead.

Specified by:
getBackwardDependencies in interface InstalledExtensionRepository
Parameters:
feature - the extension unique identifier
namespace - the namespace where to search for backward dependencies
Returns:
the backward dependencies, an empty collection of none could be found
Throws:
ResolveException - error when searching for backward dependencies

getBackwardDependencies

public Map<String,Collection<InstalledExtension>> getBackwardDependencies(ExtensionId extensionId)
                                                                   throws ResolveException
Description copied from interface: InstalledExtensionRepository
Get all backward dependencies by namespace for the provided installed extension.

Specified by:
getBackwardDependencies in interface InstalledExtensionRepository
Parameters:
extensionId - the extension identifier
Returns:
the extension backward dependencies in all namespaces
Throws:
ResolveException - error when searching for extension backward dependencies