-
Notifications
You must be signed in to change notification settings - Fork 125
/
ExtensionHandler.java
138 lines (128 loc) · 5.73 KB
/
ExtensionHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.extension.handler;
import java.util.Collection;
import org.xwiki.component.annotation.Role;
import org.xwiki.extension.Extension;
import org.xwiki.extension.ExtensionException;
import org.xwiki.extension.InstallException;
import org.xwiki.extension.InstalledExtension;
import org.xwiki.extension.LocalExtension;
import org.xwiki.extension.UninstallException;
import org.xwiki.job.Request;
/**
* Handle extension related tasks depending of the type (install, uninstall, etc...).
*
* @version $Id$
* @since 4.0M1
*/
@Role
public interface ExtensionHandler
{
/**
* Install the provided local extension.
*
* @param localExtension the extension to install
* @param namespace the namespace where to install the extension
* @param request extra parameters
* @throws InstallException error when trying to install the extension
*/
void install(LocalExtension localExtension, String namespace, Request request) throws InstallException;
/**
* Uninstall the provided local extension.
*
* @param localExtension the extension to uninstall
* @param namespace the namespace from where to uninstall the extension
* @param request extra parameters
* @throws UninstallException error when trying to uninstall the extension
* @deprecated starting with 5.ORC1 use {@link #uninstall(InstalledExtension, String, Request)} instead
*/
@Deprecated
void uninstall(LocalExtension localExtension, String namespace, Request request) throws UninstallException;
/**
* Uninstall the provided local extension.
*
* @param localExtension the extension to uninstall
* @param namespace the namespace from where to uninstall the extension
* @param request extra parameters
* @throws UninstallException error when trying to uninstall the extension
* @since 5.0RC1
*/
void uninstall(InstalledExtension localExtension, String namespace, Request request) throws UninstallException;
/**
* Upgrade the provided local extension.
*
* @param previousLocalExtension the previous installed version of the extension
* @param newLocalExtension the extension to install
* @param namespace the namespace from where to uninstall the extension
* @param request extra parameters
* @throws InstallException error when trying to upgrade the extension
* @deprecated starting with 5.0RC1 use {@link #upgrade(Collection, LocalExtension, String, Request)}
*/
@Deprecated
void upgrade(LocalExtension previousLocalExtension, LocalExtension newLocalExtension, String namespace,
Request request) throws InstallException;
/**
* Upgrade the provided local extension.
*
* @param previousLocalExtensions the previous installed versions of the extension
* @param newLocalExtension the extension to install
* @param namespace the namespace from where to uninstall the extension
* @param request extra parameters
* @throws InstallException error when trying to upgrade the extension
* @since 5.0RC1
*/
void upgrade(Collection<InstalledExtension> previousLocalExtensions, LocalExtension newLocalExtension,
String namespace, Request request) throws InstallException;
/**
* Initialize the provided local extension (during application startup, re-initialization...).
*
* @param localExtension the extension to install
* @param namespace the namespace where to install the extension
* @throws ExtensionException error when trying to install the extension
*/
void initialize(LocalExtension localExtension, String namespace) throws ExtensionException;
/**
* Check if installing the passed extension is allowed.
* <p>
* It is generally used to do some non generic checking of whether or not it is possible to install the passed
* extension (not the right environment, not enough rights, etc.).
*
* @param extension the extension to install
* @param namespace the namespace from where to install
* @param request extra parameters
* @throws InstallException installing the extension will fail
* @since 4.2M2
*/
void checkInstall(Extension extension, String namespace, Request request) throws InstallException;
/**
* Check if uninstalling the passed extension is allowed.
* <p>
* It is generally used to do some non generic checking of whether or not it is possible to uninstall the passed
* extension (not the right environment, not enough rights, etc.).
*
* @param extension the extension to uninstall
* @param namespace the namespace from where to uninstall
* @param request extra parameters
* @throws UninstallException uninstalling the extension will fail
* @since 4.2M2
*/
void checkUninstall(InstalledExtension extension, String namespace, Request request) throws UninstallException;
}