public class UserAttributesContext extends Object implements AutoCloseable
A UserAttributeContext can be used with a try-with-resources statement to automate the saving, setting and restoring of userAttributes on an AGRepositoryConnection object. It is intended as an aid to help ensure a specific set of user attributes are not leaked outside the scope of their intended use.
Any request made between instantiation of this class and a call to the close() method will automatically have an x-user-attributes header added to each request sent to via the AGRepositoryConnection object passed as an argument to one of the constructors. While the context instance is live, and before close() is called, the AGRepositoryConnection can be use directly, or referenced via the `conn' field of the context itself.
See example25() for sample code demonstrating its use.
Modifier and Type | Field and Description |
---|---|
AGRepositoryConnection |
conn |
Constructor and Description |
---|
UserAttributesContext(AGRepositoryConnection connection,
org.json.JSONObject attrs)
Instantiate a UserAttributesContext object.
|
UserAttributesContext(AGRepositoryConnection connection,
String attrs)
Instantiate a UserAttributesContext object.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
restore, via conn.setUserAttributes() the user attributes that were defined on
the AGRepositoryConnection object passed to the constructor of this instance.
|
public AGRepositoryConnection conn
public UserAttributesContext(AGRepositoryConnection connection, String attrs)
connection,
- an instance of AGRepositoryConnectionattrs,
- a String representing a JSON object comprising a collection of
attribute/value pairs.public UserAttributesContext(AGRepositoryConnection connection, org.json.JSONObject attrs)
connection,
- an instance of AGRepositoryConnectionattrs,
- a JSONObject comprising a collection of attribute/value pairs.public void close()
close
in interface AutoCloseable
Copyright © 2024 Franz Inc.. All rights reserved.