Package com.portal.bas
Class PInfranetAppControllerImpl
java.lang.Object
com.portal.bas.PInfranetAppControllerImpl
- All Implemented Interfaces:
PInfranetAppController
,PInfranetConnection
,CMConnectionListener
,Remote
- Direct Known Subclasses:
PInfranetConnectionImpl
public class PInfranetAppControllerImpl
extends Object
implements PInfranetConnection, PInfranetAppController, CMConnectionListener
PInfranetAppControllerImpl
is the implementation of
PInfranetAppController
and PInfranetConnection
interfaces.
See that class for more details on usage and purpose.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInitializes this application controller without a connection pool.Initialize PInfranetAppContollerImpl using an existing PortalContext -
Method Summary
Modifier and TypeMethodDescriptionvoid
close
(boolean logout) Closes the connection to the Portal server.void
cmreconnected
(CMConnectionEvent event) Implementation for CMConnectionListener.createController
(String controllerClass) Registers the client portion of a component with the server.createNewModel
(String type) Creates a new, empty data model.Duplicates the application controller.duplicate
(PortalContext ctx) Duplicates the application controller, but instead of opening a new connection to Portal uses the one passed in.Gets the application name.Get the client application's locale.Returns the current connection context.Get the internal PortalContext.getEventListener
(Object handle) Gets an event listener, given a handle generated bypostEventListener
.getModelField
(PModelHandle data, String desc) Gets a field from a model.Gets any other data sent by the client application.boolean
getPermissionFor
(String componentName) Gets permission to use a component.Gets aPPermission
object.getRestrictionOn
(String fieldSpecification) Gets the restrictions for a field.Gets the user's UI preferences.boolean
Returns true if Portal is brand-enabled.void
Logsuser
into the Portal server specified byurl
.Looks up a controller for a given component.postEventListener
(Object src, EventListener l) Posts anEventListener
and returns a handle for it.void
registerApp
(String appName, Locale locale, Object data) Registers the application with the server.void
registerComponent
(PRemoteComponent comp, String controllerClass) Deprecated.void
registerController
(PControllerBean comp, PControllerImpl impl) Registers the client portion of a component with the server.void
Releases the connection retrieved bygetConnection()
.void
Release the PortalContext to the pool if one exists.void
removeEventListener
(Object handle) Removes a posted event listener.void
Save user preferences Properties object to PIN_FLD_USER_PREFS field in /service/admin_client.void
setBrandContext
(Poid brandPoid) Sets the brand scope of this user session to the account represented bybrandPoid
.void
setConnection
(PCachedContext conn) Sets a connection object for application use.void
setModelField
(PModelHandle data, String desc, Object val) Sets a field in a model to a new value.void
setUserPreferences
(Properties userPrefs) Deprecated.Don't pass a Properties object explicitly.protected void
storeUserPrefs
(Properties userPrefs) Save preferences Properties object to PIN_FLD_USER_PREFS field in /service/admin_client.void
A utility method that retrieves message information from anEBufException
, and uses it to build aPInfranetException
, which is then thrown.void
Deprecated.As of Release 6.1, replaced byunregisterController
.void
Unregisters a component.void
Unregisters the client portion of a component's controller with the server.void
Reverts the brand scope of this user session to the account of the user who logged in.void
verifyAndSwitchToUser
(String user, String password, String service) Calls Portal to authenticateuser
, and sets the brand scope of this session touser
's account if authentication succeeds.
-
Field Details
-
mCompMap
-
-
Constructor Details
-
PInfranetAppControllerImpl
Initializes this application controller without a connection pool.- Throws:
RemoteException
-
PInfranetAppControllerImpl
Initialize PInfranetAppContollerImpl using an existing PortalContext- Parameters:
PortalContext
- whose connection to Portal BAS will use internally. Note that the PortalContext is reset to its default values after being used.- Throws:
Exception
-
-
Method Details
-
duplicate
Duplicates the application controller, but instead of opening a new connection to Portal uses the one passed in. It is not the same as cloning, because the new and original application controllers share most features. It makes a shallow copy of the application controller that contains unique contexts.- Specified by:
duplicate
in interfacePInfranetAppController
- Parameters:
ctx
- The connection to be used by the new PInfranetAppController- Throws:
RemoteException
- thrown for errors
-
duplicate
Duplicates the application controller. It is not the same as cloning, because the new and original application controllers share most features. It makes a shallow copy of the application controller that contains unique contexts.- Specified by:
duplicate
in interfacePInfranetAppController
- Returns:
- A duplicate application controller.
- Throws:
RemoteException
- thrown for errors
-
login
Logsuser
into the Portal server specified byurl
.- Specified by:
login
in interfacePInfranetConnection
- Parameters:
user
- the usernamepassword
- user's passwordurl
- a string containing connection information in URL format, e.g., pcp://host:port- Throws:
RemoteException
- if login fails.
-
close
Closes the connection to the Portal server.- Specified by:
close
in interfacePInfranetConnection
- Parameters:
logout
- if true, logs out before closing the connection- Throws:
RemoteException
- thrown for errors- Since:
- Release 6.2
-
getPermissionFor
Gets permission to use a component.- Specified by:
getPermissionFor
in interfacePInfranetConnection
- Parameters:
componentName
- the name of the component to get permissions for- Returns:
- True, if permitted; false otherwise.
- Throws:
RemoteException
- thrown for errors
-
getRestrictionOn
Gets the restrictions for a field.- Specified by:
getRestrictionOn
in interfacePInfranetConnection
- Parameters:
fieldSpecification
- aString
with the field's specification- Returns:
- A
PRestriction
object. - Throws:
RemoteException
- thrown for errors
-
registerApp
Registers the application with the server. This gives the server-side components access to the application name and client locale.- Specified by:
registerApp
in interfacePInfranetConnection
- Parameters:
appName
- the application namelocale
- the client's localedata
- other application-specific data- Throws:
RemoteException
- thrown for errors
-
createController
Registers the client portion of a component with the server.- Specified by:
createController
in interfacePInfranetConnection
- Parameters:
controllerClass
- the class name of the component's controller- Returns:
- A controller.
- Throws:
RemoteException
- thrown in case of failure
-
registerComponent
Deprecated.As of Release 6.1, replaced bycreateController
andregisterController
.Registers the client portion of a component with the server.- Specified by:
registerComponent
in interfacePInfranetConnection
- Parameters:
comp
- the component to registercontrollerClass
- the class name of the component controller- Throws:
RemoteException
- thrown in case of failure
-
unregisterComponent
Deprecated.As of Release 6.1, replaced byunregisterController
.Unregisters a component.- Specified by:
unregisterComponent
in interfacePInfranetConnection
- Parameters:
comp
- the component to unregister- Throws:
RemoteException
- thrown in case of failure
-
registerController
Registers the client portion of a component with the server. This essentially sends the stub back to the server.registerController
is used to associate the RMI stub class with the actual implementation class, which gets the implementation later when the stub is passed as a parameter. This is useful in implementing remote event listeners.The framework calls this automatically when a new controller is created.
- Specified by:
registerController
in interfacePInfranetAppController
- Parameters:
comp
- a remote component stubimpl
- the component to register- Throws:
RemoteException
- thrown in case of failure
-
unregisterController
Unregisters a component. This frees it for garbage collection.- Specified by:
unregisterController
in interfacePInfranetAppController
- Parameters:
impl
- the component to unregister- Throws:
RemoteException
- thrown in case of failure
-
createNewModel
Creates a new, empty data model.- Specified by:
createNewModel
in interfacePInfranetConnection
- Parameters:
type
- aString
that defines the type of model to create- Returns:
- A new model handle.
- Throws:
RemoteException
- thrown for errors
-
getModelField
Gets a field from a model. This version returns aPModelHandle
only for a field that is itself a model. Use this method when the returned field data will be sent to the client. For compound specifications, an object array is returned.- Specified by:
getModelField
in interfacePInfranetConnection
- Parameters:
data
- the model from which to get a fielddesc
- a description of which field(s) to get- Returns:
- The contents of the field. This is an Integer,
BigDecimal, Date, Double, byte array, String,
or
PModelHandle
. - Throws:
RemoteException
- thrown for errors
-
setModelField
Sets a field in a model to a new value. This version handles the case where the new value is aPModelHandle
.- Specified by:
setModelField
in interfacePInfranetConnection
- Parameters:
data
- the model to set a field indesc
- a description of which field to setval
- the new value to be set- Throws:
RemoteException
- thrown for errors
-
getUserPreferences
Gets the user's UI preferences. If user preferences have already been cached in this class, that instance is returned. Otherwise data from thePIN_FLD_USER_PREFS
field in/service/admin_client
is returned.- Specified by:
getUserPreferences
in interfacePInfranetConnection
- Returns:
- A
Properties
object that contains the user's preferences, or null for errors or if no preferences were retrieved from the server. - Throws:
RemoteException
- thrown for errors
-
saveUserPreferences
Save user preferences Properties object to PIN_FLD_USER_PREFS field in /service/admin_client. Saves the object managed by this class that is retrieved using getUserPreferences() method. Always use this preferred method to save user prefs.- Specified by:
saveUserPreferences
in interfacePInfranetConnection
- Throws:
RemoteException
-
setUserPreferences
Deprecated.Don't pass a Properties object explicitly. Use saveUserPreferences() instead and have this class manage the preferences.Saves changes to the user's UI preferencesProperties
object to thePIN_FLD_USER_PREFS
field in/service/admin_client
.- Specified by:
setUserPreferences
in interfacePInfranetConnection
- Parameters:
userPrefs
- theProperties
object that contains the user's preferences; must not be null- Throws:
RemoteException
- thrown for errors
-
cmreconnected
Implementation for CMConnectionListener. Sets the cached scope to the reset connection- Specified by:
cmreconnected
in interfaceCMConnectionListener
-
storeUserPrefs
Save preferences Properties object to PIN_FLD_USER_PREFS field in /service/admin_client. This actually writes it to the db.- Parameters:
A
- non-null Properties object containing the users preferences.- Throws:
RemoteException
-
lookupController
Looks up a controller for a given component.- Specified by:
lookupController
in interfacePInfranetAppController
- Parameters:
comp
- a remote component stub- Returns:
- The controller, if any, associated with the component.
- Throws:
RemoteException
- thrown for errors
-
postEventListener
Posts anEventListener
and returns a handle for it. This is used for passing events, where the events are passed on the server side but the listeners are registered on the client side.- Specified by:
postEventListener
in interfacePInfranetAppController
- Parameters:
src
- the source of the eventl
- anEventListener
- Returns:
- A handle to pass to the client.
- Throws:
RemoteException
- thrown for errors
-
getEventListener
Gets an event listener, given a handle generated bypostEventListener
.- Specified by:
getEventListener
in interfacePInfranetAppController
- Parameters:
handle
- a token generated by thepostEventListener
class- Returns:
- The posted listener for the handle, or null.
- Throws:
RemoteException
- thrown for errors
-
removeEventListener
Removes a posted event listener.- Specified by:
removeEventListener
in interfacePInfranetAppController
- Parameters:
handle
- the event listener's handle
-
setConnection
Sets a connection object for application use.- Specified by:
setConnection
in interfacePInfranetAppController
- Parameters:
conn
- a new, cached context object- Throws:
RemoteException
- thrown for errors
-
getConnection
Returns the current connection context. May be null if no connection to Portal has been made. For every call togetConnection()
there must be a corresponding call toreleaseConnection()
.- Specified by:
getConnection
in interfacePInfranetAppController
- Returns:
- A
PCachedContext
object, or null. - Throws:
RemoteException
- thrown for errors- See Also:
-
releaseConnection
Releases the connection retrieved bygetConnection()
. For every call togetConnection()
there must be a corresponding call toreleaseConnection()
. This method doesn't do anything if there is no connection pool.- Specified by:
releaseConnection
in interfacePInfranetAppController
- Parameters:
ctx
- the connection to be released.- Throws:
RemoteException
- See Also:
-
getContext
Get the internal PortalContext. This is a semi-private function and MUST only be used by classes that want to cache Portal data and intentionally bypass the BAS cache.- Specified by:
getContext
in interfacePInfranetConnection
- Returns:
- The portal context used internally.
- See Also:
-
releaseContext
Release the PortalContext to the pool if one exists.- Specified by:
releaseContext
in interfacePInfranetConnection
- Parameters:
ctx
- the portal context to be released.- See Also:
-
isBrandingEnabled
Returns true if Portal is brand-enabled.- Specified by:
isBrandingEnabled
in interfacePInfranetAppController
- Throws:
RemoteException
-
verifyAndSwitchToUser
public void verifyAndSwitchToUser(String user, String password, String service) throws RemoteException Calls Portal to authenticateuser
, and sets the brand scope of this session touser
's account if authentication succeeds.- Specified by:
verifyAndSwitchToUser
in interfacePInfranetAppController
- Parameters:
user
- the usernamepassword
-service
- the service type, e.g., "/service/email"- Throws:
RemoteException
- if authentication fails.
-
getServiceHandle
- Specified by:
getServiceHandle
in interfacePInfranetAppController
- Throws:
RemoteException
-
getAccountHandle
- Specified by:
getAccountHandle
in interfacePInfranetAppController
- Throws:
RemoteException
-
setBrandContext
Sets the brand scope of this user session to the account represented bybrandPoid
.- Specified by:
setBrandContext
in interfacePInfranetAppController
- Parameters:
brandPoid
- thePoid
of a user account- Throws:
RemoteException
-
unsetBrandContext
Reverts the brand scope of this user session to the account of the user who logged in.- Throws:
RemoteException
-
getPermissions
Gets aPPermission
object.- Specified by:
getPermissions
in interfacePInfranetAppController
- Returns:
- A
PPermission
object. - Throws:
RemoteException
- thrown for remote errors
-
getAppName
Gets the application name.- Specified by:
getAppName
in interfacePInfranetAppController
- Returns:
- A
String
that contains the application name. - Throws:
RemoteException
- thrown for errors
-
getClientLocale
Get the client application's locale.- Specified by:
getClientLocale
in interfacePInfranetAppController
- Returns:
- The client's locale.
- Throws:
RemoteException
- thrown for errors
-
getOtherData
Gets any other data sent by the client application.- Specified by:
getOtherData
in interfacePInfranetAppController
- Returns:
- An object that contains application-specific data.
- Throws:
RemoteException
- thrown for errors
-
throwInfranetException
A utility method that retrieves message information from anEBufException
, and uses it to build aPInfranetException
, which is then thrown.- Parameters:
e
- anEBufException
- Throws:
PInfranetException
- thrown for Portal errors
-
unregisterControllers
public void unregisterControllers()Unregisters the client portion of a component's controller with the server. This frees it for garbage collection.- Specified by:
unregisterControllers
in interfacePInfranetAppController
-
createController
andregisterController
.