Skip to content

Commit 4cff64f

Browse files
committed
Update README.md
1 parent 1a2bf7c commit 4cff64f

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,9 @@ client
737737
###Attributes service
738738
Attributes, also called profile attributes, are name-value pairs associated with a user, organization or server. Certain advanced features such as Domain security and OLAP access grants use profile attributes in addition to roles to grant certain permissions. Unlike roles, attributes are not pre-defined, and thus any attribute name can be assigned any value at any time.
739739
Attributes service provides methods for reading, writing, and deleting attributes on any given holder (server, organization or user account). All attribute operations apply to a single specific holder; there are no operations for reading or searching attributes from multiple holders.
740-
Because the holder id is used in the URL, this service can operate only on holders whose ID is less than 100 characters long and does not contain spaces or special symbols. In addition, both attribute names and attribute values being written with this service are limited to 255 characters and may not be empty (null) or not contain only whitespace characters.
740+
As the holder's id is used in the URL, this service can operate only on holders whose ID is less than 100 characters long and does not contain spaces or special symbols. In addition, both attribute names and attribute values being written with this service are limited to 255 characters and may not be empty (null) or not contain only whitespace characters.
741741
####Viewing User Attributes
742-
The code below retrieves single attribute defined for the user:
742+
The code below allow you to retrieve single attribute defined for the user:
743743
```java
744744
HypermediaAttribute userAttribute = session
745745
.attributesService()
@@ -786,22 +786,21 @@ The code below retrieves the list of attributes defined for the user.
786786
HypermediaAttribute userAttribute = session
787787
.attributesService()
788788
.forUser("jasperadmin")
789-
.attribute("attributeName")
789+
.attribute("attributeName", "attributeName1", "attributeName2")
790790
.get()
791791
.getEntity();
792792
```
793-
794793
If user belong to organization you may specify organization:
795794
```java
796795
HypermediaAttribute userAttribute = session
797796
.attributesService()
798797
.forOrganization("organization_1")
799798
.forUser("jasperadmin")
800-
.attribute(attribute.getName())
799+
.allAttributes()
801800
.get()
802801
.getEntity();
803802
```
804-
You can get the list of attributes that includes the name and value of each attribute:
803+
You can get the list of all attributes that includes the name and value of each attribute:
805804
```java
806805
List<HypermediaAttribute> attributes = session
807806
.attributesService()
@@ -830,11 +829,19 @@ serverAttributes.setProfileAttributes(asList(new HypermediaAttribute(new ClientU
830829
```
831830

832831
Be careful with definition of attribute names because the server uses different strategies for creating or updating attributes depending on list of attribute names, list of attributes and existing attributes on the server:
833-
1. if requested attribute name in `attributes()` method matches with attribute name of object defined in `createOrUpdate()` method and the attribute does not exist on the server it will be *created* on the server;
834-
2. if requested attribute name in `attributes()` method matches with attribute name of object defined in `createOrUpdate()` method and the attribute exists on the server it will be *updated* on the server;
835-
3. if requested attribute name in `attributes()` method does not match with any attribute names of object defined in `createOrUpdate()` method and the attribute exists on the server it will be *deleted* on the server;
832+
1. if requested attributes' names in `attributes()` method matches with attribute name of object defined in `createOrUpdate()` method and the attribute does not exist on the server it will be *created* on the server;
833+
2. if requested attributes' names in `attributes()` method matches with attribute name of object defined in `createOrUpdate()` method and the attribute exists on the server it will be *updated* on the server;
834+
3. if requested attributes' names in `attributes()` method does not match with any attribute names of object defined in `createOrUpdate()` method and the attribute exists on the server it will be *deleted* on the server;
836835
4. if requested attribute in `createOrUpdate()` method method does not match with any attribute names in `attributes()` it will be *ignored* and will not be sent to the server;
837-
836+
5. if requested list of attributes' names in `attributes()` method is empty or you use `allAttributes()` method and pass attributes in `createOrUpdate()` method - the existing attributes on the server it will be complitely *replaced* with passed ones:
837+
```java
838+
session
839+
.attributesService()
840+
.forOrganization("organization_1")
841+
.forUser("jasperadmin")
842+
.allAttributes()
843+
.createOrUpdate(serverAttributes);
844+
```
838845
The second way of using the attributes service is adding or replacing individual attribute:
839846
```java
840847
HypermediaAttribute attribute = new HypermediaAttribute();

0 commit comments

Comments
 (0)