public class ExtensionForcedUser extends ExtensionAdaptor implements ContextPanelFactory, HttpSenderListener, ContextDataFactory
Modifier and Type | Field and Description |
---|---|
static String |
NAME
The NAME of the extension.
|
Constructor and Description |
---|
ExtensionForcedUser()
Instantiates a new forced user extension.
|
Modifier and Type | Method and Description |
---|---|
void |
discardContext(Context ctx) |
void |
discardContexts() |
void |
exportContextData(Context ctx,
org.apache.commons.configuration.Configuration config)
Export the Context data into the given configuration
|
String |
getAuthor()
Gets the author of the extension.
|
AbstractContextPropertiesPanel |
getContextPanel(Context context) |
List<Class<? extends Extension>> |
getDependencies()
Gets the list of
Extension s that this extension depends on. |
User |
getForcedUser(int contextId)
Gets the forced user for a context.
|
int |
getListenerOrder()
Gets the order of when this listener should be notified.
|
int |
getOrder() |
String |
getUIName()
By default returns the name returned by
getName() . |
protected ExtensionUserManagement |
getUserManagementExtension() |
void |
hook(ExtensionHook extensionHook)
Called during extension's initialisation to allow to add new functionality to core
components.
|
void |
importContextData(Context ctx,
org.apache.commons.configuration.Configuration config)
Import the Context data from the given configuration
|
boolean |
isForcedUserModeEnabled() |
void |
loadContextData(Session session,
Context context)
Loads the Context data from the given session.
|
void |
onHttpRequestSend(HttpMessage msg,
int initiator,
HttpSender sender)
Notifies the listener that a new request was received from the client and is ready to be
forwarded to the server.
|
void |
onHttpResponseReceive(HttpMessage msg,
int initiator,
HttpSender sender)
Notifies the listener that a new response was received from the server and is ready to be
forwarded to the client.
|
void |
persistContextData(Session session,
Context context)
Save the Context data into the given session.
|
void |
setForcedUser(int contextId,
int userId)
Sets the forced user for a context, based on the user id.
|
void |
setForcedUser(int contextId,
User user)
Sets the forced user for a context.
|
protected void |
setForcedUserModeEnabled(boolean forcedUserModeEnabled) |
boolean |
supportsDb(String type)
No database tables used, so all supported
|
canUnload, databaseOpen, destroy, getActiveActions, getAddOn, getDescription, getExtensionMenu, getExtensionView, getI18nPrefix, getMessages, getModel, getName, getUnsavedResources, getView, hasView, init, initModel, initView, initXML, isCore, isDepreciated, isEnabled, optionsLoaded, postInit, postInstall, setAddOn, setDescription, setEnabled, setI18nPrefix, setMessages, setName, setOrder, start, stop, supportsLowMemory, unload
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getURL, getVersion
public static final String NAME
public ExtensionForcedUser()
public String getUIName()
ExtensionAdaptor
getName()
.getUIName
in interface Extension
getUIName
in class ExtensionAdaptor
null
ExtensionAdaptor.getName()
public void hook(ExtensionHook extensionHook)
Extension
hook
in interface Extension
hook
in class ExtensionAdaptor
extensionHook
- the hook to add the components.protected void setForcedUserModeEnabled(boolean forcedUserModeEnabled)
protected ExtensionUserManagement getUserManagementExtension()
public boolean isForcedUserModeEnabled()
public void setForcedUser(int contextId, User user)
contextId
- the context iduser
- the userpublic void setForcedUser(int contextId, int userId) throws IllegalStateException
contextId
- the context iduserId
- the user idIllegalStateException
- if no user was found that matches the provided id.public User getForcedUser(int contextId)
contextId
- the context idpublic List<Class<? extends Extension>> getDependencies()
Extension
Extension
s that this extension depends on.getDependencies
in interface Extension
getDependencies
in class ExtensionAdaptor
null
) if none.public AbstractContextPropertiesPanel getContextPanel(Context context)
getContextPanel
in interface ContextPanelFactory
public int getOrder()
getOrder
in interface Extension
getOrder
in class ExtensionAdaptor
public String getAuthor()
Extension
Since 2.9.0 defaults to the author of the add-on, if set, otherwise an empty string.
public void discardContexts()
discardContexts
in interface ContextPanelFactory
public void discardContext(Context ctx)
discardContext
in interface ContextPanelFactory
public int getListenerOrder()
HttpSenderListener
The listeners are ordered in a natural order, the greater the order the later it will be notified.
Note: If two or more listeners have the same order, the order that those listeners will be notified is undefined.
getListenerOrder
in interface HttpSenderListener
int
with the value of the order that this listener should be notified
aboutpublic void onHttpRequestSend(HttpMessage msg, int initiator, HttpSender sender)
HttpSenderListener
The HttpMessage
msg
can be modified (only the request should be modified).
If the return value is true
the message may be forwarded and the following
listeners will be notified, if the value is false
the message will not be
forwarded and no more listeners will be notified.
Note: In the presence of more than one listener there are no guarantees that:
HttpMessage
msg
is equal to the one forwarded to the server, as the
following listeners may modify it;
true
, as the following listeners may return false
.
int
initiator
as defined in the HttpSender
class.
onHttpRequestSend
in interface HttpSenderListener
msg
- the HttpMessage
that may be forwarded to the serverinitiator
- the ID of the entity that's sending the messagesender
- the sender of the messagepublic void onHttpResponseReceive(HttpMessage msg, int initiator, HttpSender sender)
HttpSenderListener
The HttpMessage
msg
can be modified (only the response should be
modified). If the return value is true
the message may be forwarded and the
following listeners will be notified, if the value is false
the message will
not be forwarded and no more listeners will be notified.
Note: In the presence of more than one listener there are no guarantees that:
HttpMessage
msg
is equal to the one forwarded to the client, as the
following listeners may modify it;
true
, as the following listeners may return false
.
int
initiator
as defined in the HttpSender
class.
onHttpResponseReceive
in interface HttpSenderListener
msg
- the HttpMessage
that may be forwarded to the clientinitiator
- the ID of the entity that's sending the messagesender
- the sender of the messagepublic void loadContextData(Session session, Context context)
ContextDataFactory
loadContextData
in interface ContextDataFactory
session
- the session to load from, not null
.context
- the context to load into, not null
.public void persistContextData(Session session, Context context)
ContextDataFactory
persistContextData
in interface ContextDataFactory
session
- the session to persist into, not null
.context
- the context to persist from, not null
.public void exportContextData(Context ctx, org.apache.commons.configuration.Configuration config)
ContextDataFactory
exportContextData
in interface ContextDataFactory
ctx
- the context to export, not null
.config
- the Configuration
where to export the context data, not null
.public void importContextData(Context ctx, org.apache.commons.configuration.Configuration config)
ContextDataFactory
importContextData
in interface ContextDataFactory
ctx
- the context to import the context data toconfig
- the Configuration
containing the context data, not null
.public boolean supportsDb(String type)
supportsDb
in interface Extension
supportsDb
in class ExtensionAdaptor
type
- the db typeDatabase.getType()