public class Session extends EventProvider
Modifier and Type | Class and Description |
---|---|
static class |
Session.events |
static class |
Session.GisType
Gis type constants for @getBaseGisUrl call
|
Modifier and Type | Method and Description |
---|---|
int |
checkFeature(java.lang.String feature)
Check if billing service is available for given session
|
void |
checkItemsBilling(java.lang.Long[] items,
java.lang.String serviceName,
java.lang.Long accessFlags,
ResponseHandler callback)
Check collection of items for billing service and access level usage possibility
|
void |
createAuthHash(ResponseHandler callback)
Create authorization hash that can be used to create copy of session from any IP
|
void |
createResource(User creator,
java.lang.String name,
long dataFlags,
SearchResponseHandler callback)
Create new resource
|
void |
createUnit(User creator,
java.lang.String name,
long hwTypeId,
long dataFlags,
SearchResponseHandler callback)
Create new unit
|
void |
createUnitGroup(User creator,
java.lang.String name,
long dataFlags,
SearchResponseHandler callback)
Create new unit group
|
void |
createUser(User creator,
java.lang.String name,
java.lang.String password,
long dataFlags,
SearchResponseHandler callback)
Create new user
|
void |
deleteItem(Item item,
ResponseHandler callback)
Delete item, require ACL bit Item.accessFlag.deleteItem over item
Can't be deleted: current user, users that has other items created com them and billing accounts(resources).
|
void |
getAccountData(boolean fullInfo,
ResponseHandler callback)
Get account information for current user as JSON Object
|
java.lang.String |
getBaseGisUrl(Session.GisType gisType)
Get base URL for GIS service
|
java.lang.String |
getBaseUrl()
Get base URL for server
|
User |
getCurrUser()
Get current user
|
com.google.gson.JsonObject |
getFeatures()
Fetch available billing services for given session
|
com.google.gson.Gson |
getGson() |
void |
getHwCommands(java.lang.Long deviceTypeId,
java.lang.Long unitId,
ResponseHandler callback)
Get all available hardware type commands
|
void |
getHwTypes(java.lang.String filterType,
java.lang.Object[] filterValue,
java.lang.Boolean includeType,
ResponseHandler callback)
Get hardware types
|
java.lang.String |
getId()
Get events session ID
|
static Session |
getInstance() |
Item |
getItem(long itemId)
Get item com ID
|
java.util.Collection<Item> |
getItems()
Get all items
|
<T extends Item> |
getItems(java.lang.Class<T> itemClass)
Get collection of items of given Class
|
java.util.Collection<Item> |
getItems(Item.ItemType itemsType)
Get collection of items of given type
|
com.google.gson.JsonParser |
getJsonParser() |
MessagesLoader |
getMessagesLoader()
Get messages loader object for given session
|
Renderer |
getRenderer()
Get renderer object for given session
|
void |
getReportTables(ResponseHandler callback)
Get report tables available for current user as JSON Object
|
long |
getServerTime()
Get latest known server time
|
boolean |
initSession(java.lang.String baseUrl)
Initialize Wialon session
|
boolean |
isInitialized()
Check on initialize Wialon session
|
boolean |
isInternalGis() |
void |
listTokens(java.lang.String app,
ResponseHandler callback)
Get all available authorization tokens
|
void |
login(java.lang.String user,
java.lang.String password,
ResponseHandler callback)
Perform login to Wialon server.
|
void |
loginAuthHash(java.lang.String authHash,
ResponseHandler callback)
Perform login to Wialon server using authorization hash.
|
void |
loginToken(java.lang.String token,
ResponseHandler callback) |
void |
loginToken(java.lang.String token,
java.lang.String service,
ResponseHandler callback)
Perform login to Wialon server using authorization token.
|
void |
logout(int flags,
ResponseHandler callback) |
void |
logout(ResponseHandler callback)
Logout from Wialon server.
|
void |
resetPasswordPerform(User user,
java.lang.String code,
ResponseHandler callback)
Perform password reset for Wialon user.
|
void |
resetPasswordRequest(User user,
java.lang.String email,
java.lang.String emailFrom,
java.lang.String url,
java.lang.String lang,
ResponseHandler callback)
Request reset password for Wialon user.
|
void |
searchItem(long id,
long dataFlags,
SearchResponseHandler callback)
Search for item
|
void |
searchItems(SearchSpec searchSpec,
int forceRefresh,
long dataFlags,
int indexFrom,
int indexTo,
SearchResponseHandler callback)
Search for items
|
void |
sendSms(java.lang.String phoneNumber,
java.lang.String smsText,
ResponseHandler callback)
Send SMS, current user should have flag User.userFlag.canSendSMS and should have enough SMS messages available for account
|
boolean |
setEvtPollInterval(long interval)
Change event poll interval
|
void |
setInternalGis(boolean isEnabled) |
void |
updateDataFlags(UpdateSpec[] spec,
ResponseHandler callback)
Update data flags for items: load or unload items from current session, change their data flags
|
void |
updateItem(Item item,
com.google.gson.JsonObject itemData)
Update item data
|
void |
updateToken(java.lang.String callMode,
java.lang.String token,
ResponseHandler callback)
Create/Update/Delete authorization token
|
addListener, clearListeners, fireEvent, removeListener, removeListeners
public static Session getInstance()
public boolean isInternalGis()
public void setInternalGis(boolean isEnabled)
public com.google.gson.JsonParser getJsonParser()
public com.google.gson.Gson getGson()
public Item getItem(long itemId)
itemId
- {Integer} Item IDpublic java.util.Collection<Item> getItems(Item.ItemType itemsType)
itemsType
- {ItemType} Type of items to get, pass null to fetch all itemspublic <T extends Item> java.util.Collection<T> getItems(java.lang.Class<T> itemClass)
T
- TypeitemClass
- Class of itempublic java.util.Collection<Item> getItems()
public boolean initSession(java.lang.String baseUrl)
baseUrl
- public void login(java.lang.String user, java.lang.String password, ResponseHandler callback)
user
- {String} user namepassword
- {String} user passwordcallback
- {ResponseHandler} callback function that is called after loginpublic void loginAuthHash(java.lang.String authHash, ResponseHandler callback)
authHash
- authorization hashcallback
- callback function that is called after loginpublic void loginToken(java.lang.String token, ResponseHandler callback)
public void loginToken(java.lang.String token, java.lang.String service, ResponseHandler callback)
token
- authorization tokencallback
- callback function that is called after loginpublic void updateToken(java.lang.String callMode, java.lang.String token, ResponseHandler callback)
callMode
- operation mode with the authorization token (create/update/delete)token
- JSON object parameters with keys:
TODO:
h authorization token hash (only 'update'/'delete')
app application name for which was created token
at specifies time ranges token will be active (0 - activation current time)
dur proposed token validity duration in seconds (0 - unlimited duration)
fl mask for additional ACL restrictions
p additional JSON data
items limit access to only this collection of storage items
deleteAll delete all available tokens (only 'delete')public void listTokens(java.lang.String app, ResponseHandler callback)
app
- application name for which was created token, optionalcallback
- callback that get result of server operationpublic void logout(ResponseHandler callback)
callback
- {ResponseHandler} callback function that is called after logout: where zero is successpublic void logout(int flags, ResponseHandler callback)
public void createAuthHash(ResponseHandler callback)
callback
- {ResponseHandler} callback function that is called after login: {authHash: "XXX"}, where zero code is successpublic void searchItems(SearchSpec searchSpec, int forceRefresh, long dataFlags, int indexFrom, int indexTo, SearchResponseHandler callback)
searchSpec
- Search specification in form: {itemsType: "", propName: "", propValueMask: "", sortType: ""}
where itemsType: type of items to search for
propName - name of property for filtering, usually "sys_name"
propValueMask - value mask of property for filtering, asteriks can be used
propType[optional] - type of property, should be empty for simple properties, optional values are: "guid" - convert property value from id to GUID, "list" - search for ID in list property (e.g. unit in group), "propitemname" - search for prop item name, e.g. custom fields, sensors
sortType - name of property that will be used for sorting, if any, usually used "sys_name"forceRefresh
- if non-zero value used, skip any caching and perform operation in realtime (try to avoid passing 1 here)dataFlags
- what data-flags returned items should haveindexFrom
- starting index for returning result, for new searches use zero valueindexTo
- ending index for returning result, for new searches use ('max number of items to return'-1) valuecallback
- callback function that is called after remote call: callback(code, data),
where code: operation result code (zero is success)
data (result) consists of: {items: [], dataFlags: 0x10, totalItemsCount: 100, indexFrom: 0, indexTo: 9, searchSpec: {...}}public void searchItem(long id, long dataFlags, SearchResponseHandler callback)
id
- ID of item to search fordataFlags
- {Integer}: what data-flags returned item should havecallback
- {?Function} callback function that is called after remote call: callback(code, item)public void updateDataFlags(UpdateSpec[] spec, ResponseHandler callback)
spec
- {Object}
Specification of what to update in form [{type: "id|type|col", data: callback
- {ResponseHandler} callback function that is called after remote call: callback(code), where zero code is successpublic java.lang.String getId()
public Renderer getRenderer()
public MessagesLoader getMessagesLoader()
public boolean isInitialized()
public java.lang.String getBaseUrl()
public long getServerTime()
public User getCurrUser()
public boolean setEvtPollInterval(long interval)
interval
- value in milliseconds between 2000 - 120000 (2-120 seconds)public void getHwTypes(java.lang.String filterType, java.lang.Object[] filterValue, java.lang.Boolean includeType, ResponseHandler callback)
filterType
- filter type (name, id, type) or null to ignorefilterValue
- filter value String[] for filterType="name" or "type" and Long[] for filterType="id", pass null to ignoreincludeType
- Whether add type to hardware params, pass null to ignorecallback
- callback function that is called after remote callpublic void getHwCommands(java.lang.Long deviceTypeId, java.lang.Long unitId, ResponseHandler callback)
deviceTypeId
- ID of hw type to search forunitId
- ID of avl_unitcallback
- callback function that is called after remote callpublic com.google.gson.JsonObject getFeatures()
public int checkFeature(java.lang.String feature)
public void createUnit(User creator, java.lang.String name, long hwTypeId, long dataFlags, SearchResponseHandler callback)
creator
- user-creator, either current user nor one of its descendantsname
- unit namehwTypeId
- hardware type id, see getHwTypes() for full list of hw typesdataFlags
- which flags initially to returncallback
- callback function that is called after remote call with new Unit object, important: obj is not loaded into sessionpublic void createUser(User creator, java.lang.String name, java.lang.String password, long dataFlags, SearchResponseHandler callback)
creator
- user-creator, either current user nor one of its descendantsname
- unit namepassword
- user passworddataFlags
- which flags initially to returncallback
- callback function that is called after remote call with new User object, important: obj is not loaded into sessionpublic void createUnitGroup(User creator, java.lang.String name, long dataFlags, SearchResponseHandler callback)
creator
- user-creator, either current user nor one of its descendantsname
- unit group namedataFlags
- which flags initially to returncallback
- callback function that is called after remote call with new UnitGroup object, important: obj is not loaded into sessionpublic void createResource(User creator, java.lang.String name, long dataFlags, SearchResponseHandler callback)
creator
- user-creator, either current user nor one of its descendantsname
- resource namedataFlags
- which flags initially to returncallback
- callback function that is called after remote call with new Resource object, important: obj is not loaded into sessionpublic void updateItem(Item item, com.google.gson.JsonObject itemData)
item
- {Item} - itemitemData
- - object with data from serverpublic void deleteItem(Item item, ResponseHandler callback)
item
- itemcallback
- callback that will receive information about item deletionpublic void resetPasswordRequest(User user, java.lang.String email, java.lang.String emailFrom, java.lang.String url, java.lang.String lang, ResponseHandler callback)
user
- Wialon useremail
- user e-mailemailFrom
- E-Mail from which confirmation e-mail will be senturl
- url that will be in e-mail reset request, user will be pointed to: lang
- e-mail languagecallback
- callback function that is called after loginpublic void resetPasswordPerform(User user, java.lang.String code, ResponseHandler callback)
user
- Wialon usercode
- code generated com resetPasswordRequest request and sent to user com emailcallback
- callback function that is called after login and data.newPassword contain new passwordpublic void sendSms(java.lang.String phoneNumber, java.lang.String smsText, ResponseHandler callback)
phoneNumber
- phone number in international formatsmsText
- SMS message textcallback
- callback that will receive information about SMS send operationpublic void getAccountData(boolean fullInfo, ResponseHandler callback)
fullInfo
- return all billing account informationcallback
- function to call with result of remote call and data contain full account information.public void checkItemsBilling(java.lang.Long[] items, java.lang.String serviceName, java.lang.Long accessFlags, ResponseHandler callback)
items
- array of ID of items to checkserviceName
- billing service nameaccessFlags
- ACL flags to check forcallback
- function to call with result of remote call and data contain collection of items IDs that can be used for such billing service.public void getReportTables(ResponseHandler callback)
callback
- function to call with result of remote call and data contain full report tables information.public java.lang.String getBaseGisUrl(Session.GisType gisType)
gisType
- {GisType} type of GIS function: render, search, geocode