Package com.bitheads.braincloud.services
Class CustomEntityService
java.lang.Object
com.bitheads.braincloud.services.CustomEntityService
public class CustomEntityService extends Object
-
Constructor Summary
Constructors Constructor Description CustomEntityService(BrainCloudClient client) -
Method Summary
Modifier and Type Method Description voidcreateEntity(String entityType, String dataJson, String acl, long timeToLive, Boolean isOwned, IServerCallback callback)Method creates a new entity on the server.voiddeleteEntities(String entityType, String deleteCriteria, IServerCallback callback)deletes Entities based on the criteriavoiddeleteEntity(String entityType, String entityId, int version, IServerCallback callback)Deletes the specified custom entity on the server, enforcing ownership/ACL permissions.voiddeleteSingleton(String entityType, int version, IServerCallback callback)Deletes the specified custom entity singleton, owned by the session's user, for the specified entity type, on the server.voidgetCount(String entityType, String whereJson, IServerCallback callback)Counts the number of custom entities meeting the specified where clause, enforcing ownership/ACL permissions.voidgetEntityPage(String entityType, String context, IServerCallback callback)Retrieves first page of custom entities from the server based on the custom entity type and specified query context, enforcing ownership/ACL permissions.voidgetEntityPageOffset(String entityType, String context, int pageOffset, IServerCallback callback)Gets the page of custom entities from the server based on the encoded context and specified page offset, enforcing ownership/ACL permissions.voidgetPage(String entityType, int rowsPerPage, String searchJson, String sortJson, Boolean doCount, IServerCallback callback)Deprecated.Use getEntityPage instead - removal after October 26 2021voidgetPageOffset(String entityType, String context, int pageOffset, IServerCallback callback)Deprecated.Use getEntityPageOffset instead - removal after October 26 2021voidgetRandomEntitiesMatching(String entityType, String whereJson, int maxReturn, IServerCallback callback)Gets a list of up to maxReturn randomly selected custom entities from the server based on the entity type and where condition.voidincrementData(String entityType, String entityId, String fieldsJson, IServerCallback callback)Increments the specified fields by the specified amount within custom entity data on the server, enforcing ownership/ACL permissions.voidincrementSingletonData(String entityType, String fieldsJson, IServerCallback callback)Increments the specified fields of the singleton owned by the user by the specified amount within the custom entity data on the server.voidreadEntity(String entityType, String entityId, IServerCallback callback)Reads a custom entity, enforcing ownership/ACL permissions.voidreadSingleton(String entityType, IServerCallback callback)Reads the custom entity singleton owned by the session's user.voidupdateEntity(String entityType, String entityId, int version, String dataJson, String acl, long timeToLive, IServerCallback callback)Replaces the specified custom entity's data, and optionally updates the acl and expiry, on the server, enforcing current ownership/ACL permissions.voidupdateEntityFields(String entityType, String entityId, int version, String fieldsJson, IServerCallback callback)Replaces the specified custom entity's data, and optionally updates the acl and expiry, on the server, enforcing current ownership/ACL permissions.voidupdateEntityFieldsSharded(String entityType, String entityId, int version, String fieldsJson, String shardKeyJson, IServerCallback callback)Replaces the specified custom entity's data, and optionally updates the acl and expiry, on the server, enforcing current ownership/ACL permissions.voidupdateSingleton(String entityType, int version, String dataJson, String acl, long timeToLive, IServerCallback callback)Updates the singleton owned by the user for the specified custom entity type on the server, creating the singleton if it does not exist.voidupdateSingletonFields(String entityType, int version, String fieldsJson, IServerCallback callback)Partially updates the data, of the singleton owned by the user for the specified custom entity type, with the specified fields, on the server
-
Constructor Details
-
CustomEntityService
-
-
Method Details
-
createEntity
public void createEntity(String entityType, String dataJson, String acl, long timeToLive, Boolean isOwned, IServerCallback callback)Method creates a new entity on the server.- Parameters:
entityType- The entity type as defined by the userdataJson- The entity's data as a json Stringacl- The entity's access control list as json. A null acl implies default permissions which make the entity readable/writeable by only the player.timeToLive- The duration of time, in milliseconds, the custom entity should live before being expired. 0 indicates never expires.isOwned- Boolean to indicate whether the current user should be recorded as the owner of the object. If owned, the object will be automatically deleted if/when the user is deleted.callback- Callback.
-
deleteEntity
public void deleteEntity(String entityType, String entityId, int version, IServerCallback callback)Deletes the specified custom entity on the server, enforcing ownership/ACL permissions.- Parameters:
entityType- The entity type as defined by the userentityId- The id of the entity to deleteversion- The version of the entity to delete. Use -1 to indicate the newest versioncallback- Callback.
-
getCount
Counts the number of custom entities meeting the specified where clause, enforcing ownership/ACL permissions.- Parameters:
entityType- The entity type as defined by the userwhereJson- The where clause, as JSON object.callback- Callback.
-
getRandomEntitiesMatching
public void getRandomEntitiesMatching(String entityType, String whereJson, int maxReturn, IServerCallback callback)Gets a list of up to maxReturn randomly selected custom entities from the server based on the entity type and where condition.- Parameters:
entityType- The entity type as defined by the userwhereJson- mongo style query stringmaxReturn- max number of returnscallback- Callback.
-
getPage
@Deprecated public void getPage(String entityType, int rowsPerPage, String searchJson, String sortJson, Boolean doCount, IServerCallback callback)Deprecated.Use getEntityPage instead - removal after October 26 2021Retrieves first page of custom entities from the server based on the custom entity type and specified query context, enforcing ownership/ACL permissions.- Parameters:
entityType- The entity type as defined by the userrowsPerPage- Quantity of rows per pagesearchJson- Data to look forsortJson- Data to sort bydoCount- For collections with more than 1,000 records, it is recommended that doCount be set to false for better performance.callback- Callback.
-
getEntityPage
Retrieves first page of custom entities from the server based on the custom entity type and specified query context, enforcing ownership/ACL permissions.- Parameters:
entityType- The entity type as defined by the usercontext- A context object describing the desired paging behaviourcallback- Callback.
-
getPageOffset
@Deprecated public void getPageOffset(String entityType, String context, int pageOffset, IServerCallback callback)Deprecated.Use getEntityPageOffset instead - removal after October 26 2021Gets the page of custom entities from the server based on the encoded context and specified page offset, enforcing ownership/ACL permissions.- Parameters:
entityType- The entity type as defined by the usercontext- The context string returned from the server from a previous call to GetPage or GetPageOffsepageOffset- The positive or negative page offset to fetch. Uses the last page retrieved using the context string to determine a starting point.callback- Callback.
-
getEntityPageOffset
public void getEntityPageOffset(String entityType, String context, int pageOffset, IServerCallback callback)Gets the page of custom entities from the server based on the encoded context and specified page offset, enforcing ownership/ACL permissions.- Parameters:
entityType- The entity type as defined by the usercontext- The context string returned from the server from a previous call to GetPage or GetPageOffset.pageOffset- The positive or negative page offset to fetch. Uses the last page retrieved using the context string to determine a starting point.callback- Callback.
-
readEntity
Reads a custom entity, enforcing ownership/ACL permissions.- Parameters:
entityType- The entity type as defined by the userentityId- The id of custom entity being read.callback- Callback.
-
updateEntity
public void updateEntity(String entityType, String entityId, int version, String dataJson, String acl, long timeToLive, IServerCallback callback)Replaces the specified custom entity's data, and optionally updates the acl and expiry, on the server, enforcing current ownership/ACL permissions.- Parameters:
entityType- The entity type as defined by the userentityId- The id of custom entity being updated.version- Version of the custom entity being updated.dataJson- New custom data, as JSON, to replace existing custom data.acl- New access control list settings to replace existing acl. Optional, ignored if null.timeToLive- The duration of time, in milliseconds, the custom entity should live from now before being expired. Null indicates never expires. To indicate no change, use -1.callback- Callback.
-
updateEntityFields
public void updateEntityFields(String entityType, String entityId, int version, String fieldsJson, IServerCallback callback)Replaces the specified custom entity's data, and optionally updates the acl and expiry, on the server, enforcing current ownership/ACL permissions.- Parameters:
entityType- The entity type as defined by the userentityId- The id of custom entity being updated.version- Version of the custom entity being updated.fieldsJson- Specific fields, as JSON, to set within entity's custom data.callback- Callback.
-
updateEntityFieldsSharded
public void updateEntityFieldsSharded(String entityType, String entityId, int version, String fieldsJson, String shardKeyJson, IServerCallback callback)Replaces the specified custom entity's data, and optionally updates the acl and expiry, on the server, enforcing current ownership/ACL permissions.- Parameters:
entityType- The entity type as defined by the userentityId- The id of custom entity being updated.version- Version of the custom entity being updated.fieldsJson- Specific fields, as JSON, to set within entity's custom data.shardKeyJson- The shard key field(s) and value(s), as JSON, applicable to the entity being updated.callback- Callback.
-
deleteEntities
deletes Entities based on the criteria- Parameters:
entityType- The entity type as defined by the userdeleteCriteria- The delete criteria to be applied.callback- Callback.
-
deleteSingleton
Deletes the specified custom entity singleton, owned by the session's user, for the specified entity type, on the server.- Parameters:
entityType- The entity type as defined by the userversion- Version of the custom entity singleton being deleted.callback- Callback.
-
updateSingleton
public void updateSingleton(String entityType, int version, String dataJson, String acl, long timeToLive, IServerCallback callback)Updates the singleton owned by the user for the specified custom entity type on the server, creating the singleton if it does not exist. This operation results in the owned singleton's data being completely replaced by the passed in JSON object.- Parameters:
entityType- The entity type as defined by the userversion- Version of the custom entity singleton being updated.dataJson- The singleton entity's custom field data, as JSON.acl- The singleton entity's Access Control List as an object. A null ACL implies default permissions which make the entity readable by others.timeToLive- The duration of time, in milliseconds, the singleton custom entity should live before being expired. Null indicates never expires. Value of -1 indicates no change for updates.callback- Callback.
-
updateSingletonFields
public void updateSingletonFields(String entityType, int version, String fieldsJson, IServerCallback callback)Partially updates the data, of the singleton owned by the user for the specified custom entity type, with the specified fields, on the server- Parameters:
entityType- The entity type as defined by the userversion- Version of the custom entity singleton being updated.fieldsJson- Specific fields, as JSON, to set within singleton entity's custom data.callback- Callback.
-
incrementData
public void incrementData(String entityType, String entityId, String fieldsJson, IServerCallback callback)Increments the specified fields by the specified amount within custom entity data on the server, enforcing ownership/ACL permissions.- Parameters:
entityType- The entity type as defined by the userentityId- The id of custom entity being updated.fieldsJson- Specific fields, as JSON, within entity's custom data, with respective increment amount.callback- Callback.
-
readSingleton
Reads the custom entity singleton owned by the session's user.- Parameters:
entityType- The entity type as defined by the usercallback- Callback.
-
incrementSingletonData
Increments the specified fields of the singleton owned by the user by the specified amount within the custom entity data on the server.- Parameters:
entityType- The type of custom entity being updated.fieldsJson- Specific fields, as JSON, within entity's custom data with respective increment amount.callback- Callback.
-