edu.wisc.trace.uch
Class UIPMListener

java.lang.Object
  extended by edu.wisc.trace.uch.UIPMListener
All Implemented Interfaces:
IUIPMListener

public class UIPMListener
extends Object
implements IUIPMListener

Implements the methods of IUIPMListener. Also maintain information about UIPMs and their session.

Version:
$Revision: 1.1 $
Author:
Parikshit Thakur & Team, Trace R&D Center

Constructor Summary
UIPMListener(UCH uch)
          Constructor.
 
Method Summary
 boolean addCompatibleUI(String targetId, List<String> socketNames, String protocolShortName, List<String> uris, Map<String,List<String>> protocolInfo)
          Tell the UCH to add a user interface item (advertised by the UIPM) to its UIList which is exposed to controllers on request.
 void addUriServiceContexts(String uri, List<Map<String,IProfile>> contexts)
          Called when the UIPM wants to add one or more contexts to a URI service.
 void closeSession(String sessionId)
          Closes a Session for the specified sessionId.
 List<String> getAvailableTargetIds(Map<String,IProfile> context)
          Get the identifiers of the available targets.
 List<Map<String,IProfile>> getContexts()
          Get currently open contexts.
 boolean getDependencyValue(String sessionId, String path, String dependency)
          Get the actual value of a dependency.
 String getDocument(String uri, String postData, Map<String,IProfile> context)
          Get specified document through HTTP GET or POST.
 String getElementRef(String sessionId, String path)
          Get the elementRef URI that points to a particular socket element/set.
 List<Set<String>> getIndices(String sessionId, List<String> eltIds, List<Integer> indexNos)
          Get Indices available on specific level of dimension of dimensional Element.
 String getIpAddress()
          Get the IP address of the UCH.
 IUCHStore getLocalUCHStore()
          Get the Local UCH Store.
 Map<String,String> getLocators(String targetName)
          Get a map of locatores containing locatorId and locatorType for a specified target Name.
 List<List<Map<String,List<String>>>> getResources(String sessionId, List<Map<String,List<String>>> resProps)
          Get resource from the UCH specified by Resource Properties.
 String getSocketDescriptionUri(String targetName, String socketName)
          Get the URI for retrieving the Socket Description of the specified targetName and socketName.
 String getSocketFriendlyName(String targetId, String socketName)
          Get Friendly Name of the Socket for the specified socketName and targetId.
 String getSocketName(String sessionId)
          Get the SocketName for the specified sessionId.
 List<String> getSocketNames(String targetName)
          Returns List of socket Names for the specified Target Name.
 List<Map<String,IProfile>> getTargetContexts(String targetId)
          Get list of contexts for which a target is available.
 String getTargetDescriptionUri(String targetName)
          Get the URI for retrieving the Target Description for the specified targetName.
 String getTargetName(String targetId)
          Get the name of a target for the specified targetId.
 Map<String,Object> getTargetProps(String targetId)
          Get the target Properties for the specified targetId.
 Map<String,String> getUCHProps()
          Get the UCH Properties.
 Map<String,String> getValues(String sessionId, List<String> paths, List<Boolean> includeSets)
          Returns a value/state of the specified socket elements.
 void invokeLocator(String targetId, String locatorId)
          Invoke the specified locator function of the specified targetId.
 boolean isElementAvailable(String targetId, String socketName, String elementId)
          Checks whether a given socketElement is available in the specified Socket of specified Target or not.
 boolean isImplemented(String functionName)
          Checks whether specified function is implemented or not.
 boolean isSessionResumable(String sessionId)
          Checks whether the given session can be resumed.
 boolean isSessionSuspendable(String sessionId)
          Check whether the given session can be suspended.
 Map<String,String> openSessionRequest(IUIPM uipm, String targetId, String socketName, Map<String,String> clientProps, Map<String,IProfile> context)
          Request for opening a session with the specified target and socket.
 void removeCompatibleUIs(List<String> uris)
          Tells the UCH to remove user interface URIs from the UIList that were previously added by addCompatibleUI().
 void removeUIPM(IUIPM uipm)
          Removes the specified uipm from the UCH.
 void removeUriServiceContexts(String uri, List<Map<String,IProfile>> contexts)
          Called when the UIPM wants to close one or more contexts to a URI service.
 boolean resumeSession(String sessionId)
          The target is requested to resume the given session.
 Map<String,List<String>> setValuesRequest(String sessionId, List<String> paths, List<String> operations, List<String> reqValues)
          The UIPM requests to change the target state in one or more operations on specified socket elements.
 String startUriService(IUIPM uipm, String scheme, int port, boolean portIsFlexible, String basePath, boolean basePathIsFlexible, List<Map<String,IProfile>> contexts)
          The UIPM requests the UCH to start servicing a URI which is made up of a given scheme, port, and base path.
 void stopUriService(String uri)
          The UIPM requests the UCH to stop servicing a URI that was requested to be serviced in a previous call to startUriService().
 long suspendSession(String sessionId, long suggestedTimeout)
          The target is requested to suspend the given session with a suggested timeout value.
 List<Map<String,String>> uploadResources(List<Map<String,List<String>>> props, List<String> resourceUri)
          Upload Resources on Resource Server.
 boolean validateValue(String sessionId, String path, String value)
          Checks whether value is valid or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UIPMListener

public UIPMListener(UCH uch)
Constructor. Provide the reference of UCH to local variable.

Parameters:
uch - an Object of UCH
Method Detail

addCompatibleUI

public boolean addCompatibleUI(String targetId,
                               List<String> socketNames,
                               String protocolShortName,
                               List<String> uris,
                               Map<String,List<String>> protocolInfo)
                        throws UCHException
Description copied from interface: IUIPMListener
Tell the UCH to add a user interface item (advertised by the UIPM) to its UIList which is exposed to controllers on request.

Specified by:
addCompatibleUI in interface IUIPMListener
Parameters:
targetId - a String value of targetId
socketNames - a List<String> value of socketNames
protocolShortName - a String value of protocolShortName
uris - a List<String> value of uris
protocolInfo - a Map<String, List<String>> of protocol Information
Returns:
whether CompatibleUI is added or not.
Throws:
UCHException - an Object of UCHException
See Also:
IUIPMListener.addCompatibleUI(String, List, String, List, Map)

closeSession

public void closeSession(String sessionId)
Description copied from interface: IUIPMListener
Closes a Session for the specified sessionId.

Specified by:
closeSession in interface IUIPMListener
Parameters:
sessionId - a String value of sessionId
See Also:
IUIPMListener.closeSession(java.lang.String)

getAvailableTargetIds

public List<String> getAvailableTargetIds(Map<String,IProfile> context)
Description copied from interface: IUIPMListener
Get the identifiers of the available targets.

Specified by:
getAvailableTargetIds in interface IUIPMListener
Parameters:
context - a Map<String, IProfile> of user and controller profile
Returns:
List<String>
See Also:
IUIPMListener.getAvailableTargetIds(Map)

getDocument

public String getDocument(String uri,
                          String postData,
                          Map<String,IProfile> context)
                   throws UCHException
Description copied from interface: IUIPMListener
Get specified document through HTTP GET or POST.

Specified by:
getDocument in interface IUIPMListener
Parameters:
uri - a String value of URI
postData - a String value of postData
context - a Map<String, IProfile> of user and controller profile
Returns:
a String value of requested Document
Throws:
UCHException - an Object of UCHException
See Also:
IUIPMListener.getDocument(String, String, Map)

getIndices

public List<Set<String>> getIndices(String sessionId,
                                    List<String> eltIds,
                                    List<Integer> indexNos)
Description copied from interface: IUIPMListener
Get Indices available on specific level of dimension of dimensional Element.

Specified by:
getIndices in interface IUIPMListener
Parameters:
sessionId - a String value of sessionId
eltIds - a List<String> of elementIds
indexNos - a List<Integer> of indexNo
Returns:
a List<Set<Integer> of indices
See Also:
IUIPMListener.getIndices(String, List, List)

getIpAddress

public String getIpAddress()
Description copied from interface: IUIPMListener
Get the IP address of the UCH.

Specified by:
getIpAddress in interface IUIPMListener
Returns:
return a string value
See Also:
IUIPMListener.getIpAddress()

getLocalUCHStore

public IUCHStore getLocalUCHStore()
Description copied from interface: IUIPMListener
Get the Local UCH Store.

Specified by:
getLocalUCHStore in interface IUIPMListener
Returns:
an Object of IUCHStore
See Also:
IUIPMListener.getLocalUCHStore()

getLocators

public Map<String,String> getLocators(String targetName)
Description copied from interface: IUIPMListener
Get a map of locatores containing locatorId and locatorType for a specified target Name.

Specified by:
getLocators in interface IUIPMListener
Parameters:
targetName - a String value of targetName
Returns:
a Map<string, String> of LocatorID V/S Locator Type
See Also:
IUIPMListener.getLocators(String)

getResources

public List<List<Map<String,List<String>>>> getResources(String sessionId,
                                                         List<Map<String,List<String>>> resProps)
Description copied from interface: IUIPMListener
Get resource from the UCH specified by Resource Properties.

Specified by:
getResources in interface IUIPMListener
Parameters:
sessionId - a String value of sessionId
resProps - a Map<String, List<String>> of Resource Properties
Returns:
a List<List<Map<String, List<String>>>> value
See Also:
IUIPMListener.getResources(String, List)

getSocketDescriptionUri

public String getSocketDescriptionUri(String targetName,
                                      String socketName)
Description copied from interface: IUIPMListener
Get the URI for retrieving the Socket Description of the specified targetName and socketName.

Specified by:
getSocketDescriptionUri in interface IUIPMListener
Parameters:
targetName - a String value of targetName
socketName - a String value of socketName
Returns:
a String representing Socket Description URI
See Also:
IUIPMListener.getSocketDescriptionUri(java.lang.String, java.lang.String)

getSocketFriendlyName

public String getSocketFriendlyName(String targetId,
                                    String socketName)
Description copied from interface: IUIPMListener
Get Friendly Name of the Socket for the specified socketName and targetId.

Specified by:
getSocketFriendlyName in interface IUIPMListener
Parameters:
targetId - a String value of targetId
socketName - a String value of socketName
Returns:
a String value of Socket Friendly Name
See Also:
IUIPMListener.getSocketFriendlyName(java.lang.String, java.lang.String)

getSocketName

public String getSocketName(String sessionId)
Description copied from interface: IUIPMListener
Get the SocketName for the specified sessionId.

Specified by:
getSocketName in interface IUIPMListener
Parameters:
sessionId - a String value of sessionId
Returns:
a String of SocketName
See Also:
IUIPMListener.getSocketName(java.lang.String)

getSocketNames

public List<String> getSocketNames(String targetName)
Description copied from interface: IUIPMListener
Returns List of socket Names for the specified Target Name.

Specified by:
getSocketNames in interface IUIPMListener
Parameters:
targetName - a String value of targetName
Returns:
List<String>
See Also:
IUIPMListener.getSocketNames(java.lang.String)

getTargetDescriptionUri

public String getTargetDescriptionUri(String targetName)
Description copied from interface: IUIPMListener
Get the URI for retrieving the Target Description for the specified targetName.

Specified by:
getTargetDescriptionUri in interface IUIPMListener
Parameters:
targetName - a String value of targetName
Returns:
a Target Description URI String
See Also:
IUIPMListener.getTargetDescriptionUri(java.lang.String)

getTargetName

public String getTargetName(String targetId)
Description copied from interface: IUIPMListener
Get the name of a target for the specified targetId.

Specified by:
getTargetName in interface IUIPMListener
Parameters:
targetId - a String value of targetId
Returns:
a String
See Also:
IUIPMListener.getTargetName(java.lang.String)

getTargetProps

public Map<String,Object> getTargetProps(String targetId)
Description copied from interface: IUIPMListener
Get the target Properties for the specified targetId.

Specified by:
getTargetProps in interface IUIPMListener
Parameters:
targetId - a String value of targetId
Returns:
Map<String, Object>
See Also:
IUIPMListener.getTargetProps(java.lang.String)

getUCHProps

public Map<String,String> getUCHProps()
Get the UCH Properties.

Specified by:
getUCHProps in interface IUIPMListener
Returns:
an object of Map<String, String> or UCH Properties

getValues

public Map<String,String> getValues(String sessionId,
                                    List<String> paths,
                                    List<Boolean> includeSets)
Description copied from interface: IUIPMListener
Returns a value/state of the specified socket elements.

Specified by:
getValues in interface IUIPMListener
Parameters:
sessionId - a String value of sessionId
paths - a List<String> of elementPath
includeSets - a List<Boolean> of includeSets
Returns:
a Map<String, String> of values
See Also:
IUIPMListener.getValues(String, List, List)

invokeLocator

public void invokeLocator(String targetId,
                          String locatorId)
Description copied from interface: IUIPMListener
Invoke the specified locator function of the specified targetId.

Specified by:
invokeLocator in interface IUIPMListener
Parameters:
targetId - a String value of TargetId
locatorId - a String value of LocatorId
See Also:
IUIPMListener.invokeLocator(String, String)

isElementAvailable

public boolean isElementAvailable(String targetId,
                                  String socketName,
                                  String elementId)
Description copied from interface: IUIPMListener
Checks whether a given socketElement is available in the specified Socket of specified Target or not.

Specified by:
isElementAvailable in interface IUIPMListener
Parameters:
targetId - a String value of targetId
socketName - a String value of socketName
elementId - a String value of eltId
Returns:
boolean whether specified socketElement is exists or not
See Also:
IUIPMListener.isElementAvailable(java.lang.String, java.lang.String, java.lang.String)

isImplemented

public boolean isImplemented(String functionName)
Description copied from interface: IUIPMListener
Checks whether specified function is implemented or not.

Specified by:
isImplemented in interface IUIPMListener
Parameters:
functionName - a String value of function Name
Returns:
whether the function is implemented or not
See Also:
IUIPMListener.isImplemented(java.lang.String)

openSessionRequest

public Map<String,String> openSessionRequest(IUIPM uipm,
                                             String targetId,
                                             String socketName,
                                             Map<String,String> clientProps,
                                             Map<String,IProfile> context)
Description copied from interface: IUIPMListener
Request for opening a session with the specified target and socket.

Specified by:
openSessionRequest in interface IUIPMListener
targetId - a String value of targetId
socketName - a String value of socketName
clientProps - Map<String,String>
context - a Map<String, IProfile> of user and controller profile
Returns:
Map<String,String>
See Also:
IUIPMListener.openSessionRequest(IUIPM, String, String, Map, Map)

removeCompatibleUIs

public void removeCompatibleUIs(List<String> uris)
                         throws UCHException
Description copied from interface: IUIPMListener
Tells the UCH to remove user interface URIs from the UIList that were previously added by addCompatibleUI().

Specified by:
removeCompatibleUIs in interface IUIPMListener
Parameters:
uris - a List<String> of URIs
Throws:
UCHException - an Object of UCHException
See Also:
IUIPMListener.removeCompatibleUIs(List)

removeUIPM

public void removeUIPM(IUIPM uipm)
Description copied from interface: IUIPMListener
Removes the specified uipm from the UCH.

Specified by:
removeUIPM in interface IUIPMListener
Parameters:
uipm - an Object of IUIPM
See Also:
IUIPMListener.removeUIPM(IUIPM)

setValuesRequest

public Map<String,List<String>> setValuesRequest(String sessionId,
                                                 List<String> paths,
                                                 List<String> operations,
                                                 List<String> reqValues)
Description copied from interface: IUIPMListener
The UIPM requests to change the target state in one or more operations on specified socket elements. The requested operations are coded as cross-indexed arrays of paths, operation identifiers and requested new values.

Specified by:
setValuesRequest in interface IUIPMListener
Parameters:
sessionId - a String value of sessionId
paths - List<String> a List of elementPaths
operations - List<String> a List of operations (allowed operations are "S", "A", "R", "I" or "K" )
reqValues - List<String> a List of Requested Values
Returns:
Map<String, List<String>> a Map of set Values
See Also:
IUIPMListener.setValuesRequest(java.lang.String, java.util.List, java.util.List, java.util.List)

uploadResources

public List<Map<String,String>> uploadResources(List<Map<String,List<String>>> props,
                                                List<String> resourceUri)
Description copied from interface: IUIPMListener
Upload Resources on Resource Server.

Specified by:
uploadResources in interface IUIPMListener
Parameters:
props - an Object of List<Map<String, List<String>>>
resourceUri - an Object of List<String>
Returns:
an Object of Map<String, String>
See Also:
IUIPMListener.uploadResources(List, List)

startUriService

public String startUriService(IUIPM uipm,
                              String scheme,
                              int port,
                              boolean portIsFlexible,
                              String basePath,
                              boolean basePathIsFlexible,
                              List<Map<String,IProfile>> contexts)
                       throws UCHException
Description copied from interface: IUIPMListener
The UIPM requests the UCH to start servicing a URI which is made up of a given scheme, port, and base path. If successful, the UCH will forward all messages that have this URI as its base, to controllerRequest().

Specified by:
startUriService in interface IUIPMListener
Parameters:
uipm - an IUIPM object
scheme - a String value of schema
port - a port no
portIsFlexible - a boolean value
basePath - a String value of basePath
basePathIsFlexible - a boolean value
contexts - a List<Map<String, IProfile>> of user and controller profile map
Returns:
a String value of URI
Throws:
UCHException - an Object of UCHException
See Also:
IUIPMListener.startUriService(IUIPM, String, int, boolean, String, boolean, List)

stopUriService

public void stopUriService(String uri)
                    throws UCHException
Description copied from interface: IUIPMListener
The UIPM requests the UCH to stop servicing a URI that was requested to be serviced in a previous call to startUriService().

Specified by:
stopUriService in interface IUIPMListener
Parameters:
uri - a String value of URI
Throws:
UCHException - an Object of UCHException
See Also:
IUIPMListener.stopUriService(java.lang.String)

getDependencyValue

public boolean getDependencyValue(String sessionId,
                                  String path,
                                  String dependency)
                           throws UCHNotImplementedException
Description copied from interface: IUIPMListener
Get the actual value of a dependency. If IUIPMListener does not support this functionality then UCHNotImplementedException is thrown by this function.

Specified by:
getDependencyValue in interface IUIPMListener
Parameters:
sessionId - a String value of sessionId
path - a String value of path
dependency - a String value of dependency
Returns:
whether the dependency is true or false.
Throws:
UCHNotImplementedException - an Object of UCHNotImplementedException
See Also:
IUIPMListener.getDependencyValue(String, String, String)

getElementRef

public String getElementRef(String sessionId,
                            String path)
                     throws UCHNotImplementedException
Description copied from interface: IUIPMListener
Get the elementRef URI that points to a particular socket element/set. If IUIPMListener does not support this functionality then UCHNotImplementedException is thrown by this function.

Specified by:
getElementRef in interface IUIPMListener
Parameters:
sessionId - a String value of sessionId
path - a String value of path
Returns:
a String value of elementRef
Throws:
UCHNotImplementedException - an Object of UCHNotImplementedException
See Also:
IUIPMListener.getElementRef(String, String)

isSessionResumable

public boolean isSessionResumable(String sessionId)
                           throws UCHNotImplementedException
Description copied from interface: IUIPMListener
Checks whether the given session can be resumed. If IUIPMListener does not support this functionality then UCHNotImplementedException is thrown by this function.

Specified by:
isSessionResumable in interface IUIPMListener
Parameters:
sessionId - a String value of sessionId
Returns:
whether the given session can be resumed or not
Throws:
UCHNotImplementedException - an Object of UCHNotImplementedException
See Also:
IUIPMListener.isSessionResumable(String)

isSessionSuspendable

public boolean isSessionSuspendable(String sessionId)
                             throws UCHNotImplementedException
Description copied from interface: IUIPMListener
Check whether the given session can be suspended. If IUIPMListener does not support this functionality then UCHNotImplementedException is thrown by this function.

Specified by:
isSessionSuspendable in interface IUIPMListener
Parameters:
sessionId - a String value of sessionId
Returns:
whether the given session can be suspended or not
Throws:
UCHNotImplementedException - an Object of UCHNotImplementedException
See Also:
IUIPMListener.isSessionSuspendable(String)

resumeSession

public boolean resumeSession(String sessionId)
                      throws UCHNotImplementedException
Description copied from interface: IUIPMListener
The target is requested to resume the given session. If IUIPMListener does not support this functionality then UCHNotImplementedException is thrown by this function.

Specified by:
resumeSession in interface IUIPMListener
Parameters:
sessionId - a String value of sessionId
Returns:
whether request for resume session is granted or not
Throws:
UCHNotImplementedException - an Object of UCHNotImplementedException
See Also:
IUIPMListener.resumeSession(String)

suspendSession

public long suspendSession(String sessionId,
                           long suggestedTimeout)
                    throws UCHNotImplementedException
Description copied from interface: IUIPMListener
The target is requested to suspend the given session with a suggested timeout value. If IUIPMListener does not support this functionality then UCHNotImplementedException is thrown by this function.

Specified by:
suspendSession in interface IUIPMListener
Parameters:
sessionId - a String value of sessionId
suggestedTimeout - a long value
Returns:
a long value of timeOut
Throws:
UCHNotImplementedException - an Object of UCHNotImplementedException
See Also:
IUIPMListener.suspendSession(String, long)

validateValue

public boolean validateValue(String sessionId,
                             String path,
                             String value)
                      throws UCHNotImplementedException
Description copied from interface: IUIPMListener
Checks whether value is valid or not. If IUIPMListener does not support this functionality then UCHNotImplementedException is thrown by this function.

Specified by:
validateValue in interface IUIPMListener
Parameters:
sessionId - a String value of sessionId
path - a String value of path
value - a String value
Returns:
whether the value is valid or not.
Throws:
UCHNotImplementedException - an Object of UCHNotImplementedException
See Also:
IUIPMListener.validateValue(String, String, String)

addUriServiceContexts

public void addUriServiceContexts(String uri,
                                  List<Map<String,IProfile>> contexts)
                           throws UCHException
Description copied from interface: IUIPMListener
Called when the UIPM wants to add one or more contexts to a URI service.

Specified by:
addUriServiceContexts in interface IUIPMListener
Parameters:
uri - a String value of URI
contexts - a List<Map<String, IProfile>> of user and controller profile map
Throws:
UCHException - an Object of UCHException
See Also:
IUIPMListener.addUriServiceContexts(String, List)

removeUriServiceContexts

public void removeUriServiceContexts(String uri,
                                     List<Map<String,IProfile>> contexts)
                              throws UCHException
Description copied from interface: IUIPMListener
Called when the UIPM wants to close one or more contexts to a URI service.

Specified by:
removeUriServiceContexts in interface IUIPMListener
Parameters:
uri - a String value of URI
contexts - a List<Map<String, IProfile>> of user and controller profile map
Throws:
UCHException - an Object of UCHException
See Also:
IUIPMListener.removeUriServiceContexts(String, List)

getContexts

public List<Map<String,IProfile>> getContexts()
Description copied from interface: IUIPMListener
Get currently open contexts.

Specified by:
getContexts in interface IUIPMListener
Returns:
a List<Map<String, IProfile>> of user and controller profile map
See Also:
IUIPMListener.getContexts()

getTargetContexts

public List<Map<String,IProfile>> getTargetContexts(String targetId)
Description copied from interface: IUIPMListener
Get list of contexts for which a target is available.

Specified by:
getTargetContexts in interface IUIPMListener
Parameters:
targetId - a String value of targetId
Returns:
a List<Map<String, IProfile>> of user and controller profile map
See Also:
IUIPMListener.getTargetContexts(String)


Copyright © 2006-2008 Trace R&D Center, University of Wisconsin-Madison. All Rights Reserved.