How to manage users and groups

[tab:Actions]

Requirements

In order to manage users and groups in THRON, the following conditions must be complied:

  • A business user must be used, and it needs the appropriate administrative permission to manage users and groups or the permission to create guest users/groups (permissions are set into Passport on THRON Dashboard); therefore its credentials must be used (username and password must be used to perform login and obtain a valid token).

 

Create business and guest users

Creating business users and groups requires the administrative permission to manage users and groups. If this condition is verified, you can use the service create of the package vusermanager  within xsso. The request must be properly filled with the desired userType according to permissions of the user who is making the request, as explained above.

Different user types are:

 

  • PLATFORM_USER: Business user, allowed to login in platform and use the services
  • PLATFORM_USER_GUEST: Guest user, allowed to login in platform and use the services. Remember that guest users have a limited set of allowed actions, they can only view content shared with them and interact with the business user who created them.

 

Username, password and email (of MVUserNotificationProperties) are required for platform users (PLATFORM_USER, PLATFORM_USER_GUEST). Username must be unique and it will be automatically converted to lower case.

 

Constraints for the email address are:

 

  • Allowed characters in the local part (before the "@"):
    • uppercase and lowercase Latin letters A to Z and a to z
    • digits 0 to 9
    • special characters !#$%&'*+-/=?^_`{|}~
    • dot ".", provided that it is not the first or last character and provided also that it does not appear consecutively
  • Allowed characters in the domain part (after the "@"):
    • uppercase and lowercase Latin letters A to Z and a to z
    • digits 0 to 9, provided that top-level domain names are not all-numeric
    • hyphen "-", provided that it is not the first or last character

 

Constraints for the username attribute are: 

 

  • can not contain §/$&#<>"?*:\|
  • can not contain spaces
  • can not start with _
  • can not start with !
  • max length = 50

 

Constraints for the password attribute:

  •  max length = 100

 

Moreover, you will have to make sure that the "userCapabilities" parameter is filled with the following capability: "CORE_USE_CONTENT".

You can use the following JSON, filling required parameters:


{
    "clientId": "",
    "newUser": {
        "username": "",
        "password": ""
    },
    "detail": {
        "contactType": "PERSON",
        "emails": [{
            "email": ""
        }],
        "phoneNumbers": [{
            "phoneNumber": ""
        }],
        "businessDetail": {
            "companyName": ""
        },
        "name": {
            "firstName": "",
            "lastName": ""
        }
    },
    "userParams": {
        "userPreferences": {
            "timeZoneId": "",
            "locale": "",
            "notificationProperty": {
                "email": "",
                "phoneNumber": "",
                "autoSubscribeToCategories": true
            }
        }
    },
    "userType": "",
    "userCapabilities": {
        "userRoles": [
            "CORE_USE_CONTENT"
        ]
    },
    "sendFirstAccessNotification": true
}    

Create business and guest groups

For creating groups into THRON platform you have to use the service createGroup of the package usersgroupmanager of xsso. You must fill the groupType parameter according to the type of group you wish to create: PLATFORM for a group of business users and PLATFORM_BLIND for a group of guest users. Once the group has been created it will be associated with a unique identifier which can be found in the response of the request and will be used to link users to that specific group through the service linkUserToGroup. Only business users can be linked to PLATFORM groups; PLATFORM_BLIND groups can have both business and guest users but they will not see each other so they can not collaborate (it is only for acl management), moreover, PLATFORM_BLIND groups do not have any capability nor role. To remove users from a specific group you can use the service unlinkUserToGroup.

 

Upgrade a user

Guest users can be upgraded to platform users at any time. In order to do that you must use the service upgradeUser which is in vusermanager package of xsso.

 

Update a user

Some user-related information can be update by invoking an updateUser request. Information that can be updated are:

  • email: the email address related to the user, it will be used to send notifications.
  • phoneNumber: the user's phone number.
  • companyName: the name of the company related to the user.
  • firstName: the user's first name.
  • lastName: the user's last name.
  • timeZoneId: the time zone of the user (GMT).
  • locale: the language on which notifications should be sent to the user's email address.
  • notifyBy: this parameter allows you to specify wether the user should receive email notifications. If this is the case you will have to fill it with the string "EMAIL"
  • autoSubscribeToCategories: when true, this parameter will allow the user to receive automatically notifications for content published in the folders he can access.

The URL of the request is structured as follows: 

<clientId>-view.thron.com/api/xsso/resources/vusermanager/updateUser/<clientId>/<username>

In the body of the request you can paste the following JSON, filling required parameters.


{
    "update": {
        "detail": {
            "contactType": "PERSON",
            "emails": [{
                "email": ""
            }],
            "phoneNumbers": [{
                "phoneNumber": ""
            }],
            "businessDetail": {
                "companyName": ""
            },
            "name": {
                "firstName": "",
                "lastName": ""
            }
        },
        "userPreferences": {
            "timeZoneId": "",
            "locale": "",
            "notificationProperty": {
                "email": "",
                "phoneNumber": "",
                "notifyBy": ["EMAIL"],
                "autoSubscribeToCategories": true
            }
        }
    }
}    

When updating a user's preferences, please remember to include all the parameters into the request, otherwise all those omitted will be overwritten.

Note: User's permissions can not be updated via API. For security and control-related reasons, only THRON Dashboard allows to manage user's permissions.

Remove a user

When in THRON you want to delete a user you need to consider that all content and folders owned by the user you are going to delete will have to be migrated to another user. Also the username of the user who will be removed can not be used anymore; this happens because every user action is stored in THRON Audit and must be available at any time, thus username must be unique. The service used for removing users is migrateUserStuff which can be found in dashboard package of xadmin. The request includes three parameters

  • userId1: username of the user to delete
  • userId2: username of the user inheriting content and folders
  • removeUserId1: a boolean parameter to be set “true” if you want to delete the user

 

Remove a group

The removal operation of groups within THRON must be done with special care, because all the permissions inherited by users will be lost with the removal of the group. The service to be used is removeGroup which is included in the package usersgroupmanager of xsso.

[/tab] [tab:Code Samples] [dropdown:REST - CREATING A USER]

You can test this functionality in our Developer Center. In the body of the request you can paste the following JSON. Remember to fill required parameters.


{
    "clientId": "",
    "newUser": {
        "username": "",
        "password": ""
    },
    "detail": {

        "gender": "",

        "addresses": [{
            "addressCategory": "",
            "street": "",
            "pobox": "",
            "localArea": "",
            "city": "",
            "area": "",
            "postcode": "",
            "country": "",
            "primary": false
        }],
        "phoneNumbers": [{
            "phoneCategory": "",
            "phoneNumber": ""
        }],
        "emails": [{
            "emailCategory": "",
            "email": ""
        }],

        "name": {

            "firstName": "",
            "lastName": ""
        }

    },
    "userParams": {
        "userPreferences": {
            "timeZoneId": "",
            "locale": "",
            "notificationProperty": {
                "email": "",
                "phoneNumber": "",
                "autoSubscribeToCategories": false
            }
        }
    },
    "userType": "",
    "sendFirstAccessNotification": false
}    

[/dropdown] [dropdown:REST - UPDATING A USER]

You can test this functionality in our Developer Center. In the body of the request you can paste the following JSON. Remember to fill required parameters.


{
    "update": {

        "userPreferences": {
            "timeZoneId": "",
            "locale": "",
            "notificationProperty": {
                "email": "",
                "phoneNumber": "",
                "autoSubscribeToCategories": false
            }
        },
        "detail": {

            "gender": "",

            "addresses": [{
                "addressCategory": "",
                "street": "",
                "city": "",
                "area": "",
                "postcode": "",
                "country": "",
                "primary": false
            }],

            "phoneNumbers": [{
                "phoneCategory": "",
                "phoneNumber": ""
            }],
            "emails": [{
                "emailCategory": "",
                "email": ""
            }],

            "name": {
                "firstName": "",
                "lastName": ""

            }

        }

    }
}    

[/dropdown] [dropdown:REST - REMOVING A USER]

You can test this functionality in our Developer Center. In the body of the request you can paste the following JSON. Remember to fill required parameters.


{
    "clientId": "",
    "userId1": "",
    "userId2": "",
    "removeUserId1": false
}    

[/dropdown] [dropdown:REST - CREATING A GROUP]

You can test this functionality in our Developer Center. In the body of the request you can paste the following JSON. Remember to fill required parameters. 


{
    "clientId": "",
    "usersGroup": {
        "groupType": "",
        "name": "",
        "active": true,
        "description": ""
    }
}

[/dropdown] [dropdown:REST - UPDATING A GROUP]

You can test this functionality in our Developer Center. In the body of the request you can paste the following JSON. Remember to fill required parameters.


{
    "update": {
        "name": "",
        "description": "",
        "active": false
    }
}

[/dropdown] [dropdown:REST - REMOVING A GROUP]

You can test this functionality in our Developer Center. In the body of the request you can paste the following JSON. Remember to fill required parameters. 


{
    "clientId": "",
    "groupId": "",
    "force": false
}

[/dropdown] [dropdown:PHP - CREATING A USER]


<?php

//#########################################
//CONFIG
//#########################################
//token 
$tokenTHRON                      = 'TOKEN';
// client 
$client_idTHRON                  = 'CLIENTID';
//info user
$nameUser                        = "NAME";
$surnameUser                     = "SURNAME";
$usernameUser                    = $nameUser . "." . $surnameUser;
$passwordUser                    = "PASSWORD";
$userTypeUser                    = 'PLATFORM_USER_GUEST'; //use PLATFORM_USER for normal users
$sendFirstAccessNotificationUser = false;
$timeZoneIdUser                  = "GMT+1";
$localeUser                      = "LOCALE"; //IT or EN
$genderUser                      = 'MALE'; //'MALE' or 'FEMALE'
//address
$addressCategoryUser             = "HOME"; //HOME/WORK/...    
$streetUser                      = "";
$cityUser                        = "";
$areaUser                        = "";
$postcodeUser                    = "";
$countryUser                     = "";
$primaryUser                     = true;
//phone
$phoneCategoryUser               = "HOME"; //HOME/WORK/...    
$phoneNumberUser                 = "";
//email    
$emailCategoryUser               = "HOME"; //HOME/WORK/...    
$emailUser                       = ""; //email user
//init


//#########################################
//MAIN
//#########################################    

$url = ("http://" . $client_idTHRON . "-view.thron.com/api/xsso/resources/vusermanager/create");

$body = array(
    'clientId' => $client_idTHRON,
    'userType' => $userTypeUser, //use PLATFORM_USER for normal users
    "sendFirstAccessNotification" => $sendFirstAccessNotificationUser,
    'userParams' => array(
        'userPreferences' => array(
            'timeZoneId' => $timeZoneIdUser,
            'locale' => $localeUser,
            'notificationProperty' => array(
                "email" => $emailUser,
                "phoneNumber" => $phoneNumberUser
            )
        )
    ),
    'detail' => array(
        "gender" => $genderUser,
        "addresses" => array(
            array(
                "addressCategory" => $addressCategoryUser,
                "street" => $streetUser,
                "city" => $cityUser,
                "area" => $areaUser,
                "postcode" => $postcodeUser,
                "country" => $countryUser,
                "primary" => $primaryUser
            )
        ),
        "phoneNumbers" => array(
            array(
                "phoneCategory" => $phoneCategoryUser,
                "phoneNumber" => $phoneNumberUser
                
            )
        ),
        'name' => array(
            'firstName' => $nameUser,
            'lastName' => $surnameUser
        ),
        'emails' => array(
            'emailCategory' => $emailCategoryUser,
            'email' => $emailUser
        )
    ),
    'newUser' => array(
        'username' => $usernameUser,
        'password' => $passwordUser
    )
);

$header = array(
    'X-TOKENID: ' . $tokenTHRON,
    "Content-Type: application/json"
);

$request = json_encode($body);
//    echo $request;
$curl    = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);

$curlRes     = curl_exec($curl);
//echo $curlRes;
$curlResInfo = curl_getinfo($curl);
curl_close($curl);

$resHeadersString = substr($curlRes, 0, $curlResInfo['header_size']);
$resBody          = substr($curlRes, $curlResInfo['header_size']);
$response         = json_decode($resBody);

echo ("<br>CREATE  USER");
var_dump($response);
var_dump($resBody);
?>    

[/dropdown] [dropdown:PHP - UPDATING A USER]


<?php

//#########################################
//CONFIG
//#########################################
//token 
$tokenTHRON     = 'TOKEN';
// client 
$client_idTHRON = 'CLIENTID';
//id group               
$nameUser       = "NAME";
$surnameUser    = "SURNAME";
$usernameUser   = $nameUser . "." . $surnameUser;

$genderUser     = 'MALE'; //['MALE' or 'FEMALE'
$timeZoneIdUser = "GMT+1";
$localeUser     = "LOCALE"; //IT or EN

//address
$addressCategoryUser = "HOME"; //HOME/WORK/...    
$streetUser          = "";
$cityUser            = "";
$areaUser            = "";
$postcodeUser        = "";
$countryUser         = "";
$primaryUser         = true;
//phone
$phoneCategoryUser   = "HOME"; //HOME/WORK/...    
$phoneNumberUser     = "";
//email    
$emailCategoryUser   = "HOME"; //HOME/WORK/...    
$emailUser           = ""; //email
//init


//#########################################
//MAIN
//#########################################    

$url = ("http://" . $client_idTHRON . "-view.thron.com/api/xsso/resources/vusermanager/updateUser/" . $client_idTHRON . "/" . $usernameUser);

$body = array(
    "update" => array(
        
        "userPreferences" => array(
            "timeZoneId" => $timeZoneIdUser,
            "locale" => $localeUser,
            "notificationProperty" => array(
                "phoneNumber" => $phoneNumberUser,
                "email" => $emailUser
            )
        ),
        "detail" => array(
            "gender" => $genderUser,
            "addresses" => array(
                array(
                    "addressCategory" => $addressCategoryUser,
                    "street" => $streetUser,
                    "city" => $cityUser,
                    "area" => $areaUser,
                    "postcode" => $postcodeUser,
                    "country" => $countryUser,
                    "primary" => $primaryUser
                )
            ),
            
            "phoneNumbers" => array(
                array(
                    "phoneCategory" => $phoneCategoryUser,
                    "phoneNumber" => $phoneNumberUser
                )
            ),
            "emails" => array(
                array(
                    "emailCategory" => $emailCategoryUser,
                    "email" => $emailUser
                )
            ),
            
            "name" => array(
                "firstName" => $nameUser,
                "lastName" => $surnameUser
            )
        )
    )
);

$header = array(
    'X-TOKENID: ' . $tokenTHRON,
    "Content-Type: application/json"
);

$request = json_encode($body);
//    echo $request;
$curl    = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);

$curlRes     = curl_exec($curl);
//echo $curlRes;
$curlResInfo = curl_getinfo($curl);
curl_close($curl);

$resHeadersString = substr($curlRes, 0, $curlResInfo['header_size']);
$resBody          = substr($curlRes, $curlResInfo['header_size']);
$response         = json_decode($resBody);

echo ("<br>UPDATE USER<br>");

var_dump($response);

?>    

[/dropdown] [dropdown:PHP - REMOVING A USER]


<?php

//#########################################
//CONFIG
//#########################################
//token 
$tokenTHRON     = 'TOKEN';
// client 
$client_idTHRON = 'CLIENTID';
//id group               
$nameUser1      = "USERNAME";
$nameUser2      = "USERNAME ASSIGN CONTENT";
$removeUserId1  = true;


//#########################################
//MAIN
//#########################################    

$url = ("http://" . $client_idTHRON . "-view.thron.com/api/xadmin/resources/dashboard/migrateUserStuff");

$body = array(
    "clientId" => $client_idTHRON,
    "userId1" => $nameUser1,
    "userId2" => $nameUser2,
    "removeUserId1" => $removeUserId1
    
);

$header = array(
    'X-TOKENID: ' . $tokenTHRON,
    "Content-Type: application/json"
);

$request = json_encode($body);
//    echo $request;
$curl    = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);

$curlRes     = curl_exec($curl);
//echo $curlRes;
$curlResInfo = curl_getinfo($curl);
curl_close($curl);

$resHeadersString = substr($curlRes, 0, $curlResInfo['header_size']);
$resBody          = substr($curlRes, $curlResInfo['header_size']);
$response         = json_decode($resBody);
echo ("<br>remove USER<br>");
var_dump($response);

?>    

[/dropdown] [dropdown:PHP - CREATING A GROUP]


<?php
//#########################################
//CONFIG
//#########################################
//token 
$tokenTHRON            = 'TOKEN';
// client 
$client_idTHRON        = 'CLIENTID';
// group name
$groupNameTHRON        = 'GROUP NAME';
// description group
$groupDescriptionTHRON = ' GROUP DESCRIPTION';
// type group
$groupTypeTHRON        = 'PLATFORM_BLIND'; //groupType (string) = ['PLATFORM' or 'PLATFORM_BLIND' or 'SHARED_CONTACTS' or 'PRIVATE'],

//#########################################
//MAIN
//#########################################    


$url  = ("http://" . $client_idTHRON . "-view.thron.com/api/xsso/resources/usersgroupmanager/createGroup");
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    "Content-Type: application/json",
    'X-TOKENID: ' . $tokenTHRON
));
curl_setopt($curl, CURLOPT_POST, 1);

//Constraints: groupCapabilities can be applied only to PLATFORM groups (no to private or blind groups)
$body = array(
    "clientId" => $client_idTHRON,
    'usersGroup' => array(
        'groupType' => $groupTypeTHRON, //PLATFORM (for platform users) and PLATFORM_BLIND (for guest users)
        "name" => $groupNameTHRON,
        "description" => $groupDescriptionTHRON,
        "active" => true
    )
);

curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($body));
$curlResponse     = curl_exec($curl);
$curlResponseInfo = curl_getinfo($curl);
curl_close($curl);

$responseHeadersString = substr($curlResponse, 0, $curlResponseInfo['header_size']);
$responseBody          = substr($curlResponse, $curlResponseInfo['header_size']);
$response              = json_decode($responseBody, true);
//#########################################
//output
echo ("<br>CREATE GROUP");
print_r($response);    

[/dropdown] [dropdown:PHP - UPDATING A GROUP]


<?php
//#########################################
//CONFIG
//#########################################
//token 
$tokenTHRON            = 'TOKEN';
// client 
$client_idTHRON        = 'CLIENTID';
//id group
$idGroupTHRON          = 'GROUP ID';
// group name
$groupNameTHRON        = 'GROUP NAME';
// description group
$groupDescriptionTHRON = 'GROUP DESCRIPTION';


//#########################################
//MAIN
//#########################################    


$url  = ("http://" . $client_idTHRON . "-view.thron.com/api/xsso/resources/usersgroupmanager/update/" . $client_idTHRON . "/" . $idGroupTHRON);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    "Content-Type: application/json",
    'X-TOKENID: ' . $tokenTHRON
));
curl_setopt($curl, CURLOPT_POST, true);

//Constraints: groupCapabilities can be applied only to PLATFORM groups (no to private or blind groups)
$body = array(
    'update' => array(
        "name" => $groupNameTHRON,
        "description" => $groupDescriptionTHRON,
        "active" => true
    )
);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($body));
$curlResponse     = curl_exec($curl);
$curlResponseInfo = curl_getinfo($curl);
curl_close($curl);

$responseHeadersString = substr($curlResponse, 0, $curlResponseInfo['header_size']);
$responseBody          = substr($curlResponse, $curlResponseInfo['header_size']);
$response              = json_decode($responseBody, true);
//#########################################
//output
echo ("<br>UPDATE GROUP<br>");
print_r($response);

?>    

[/dropdown] [dropdown:PHP - REMOVING A GROUP]


<?php
//#########################################
//CONFIG
//#########################################
//token 
$tokenTHRON     = 'TOKEN';
// client 
$client_idTHRON = 'CLIENTID';
//id group
$idGroupTHRON   = 'GROUP ID';
$forceRemove    = true; //force (boolean): if force equals true, the service remove the group without checking if the userGroup is linked to other users

//#########################################
//MAIN
//#########################################    


$url  = ("http://" . $client_idTHRON . "-view.thron.com/api/xsso/resources/usersgroupmanager/removeGroup");
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    "Content-Type: application/json",
    'X-TOKENID: ' . $tokenTHRON
));
curl_setopt($curl, CURLOPT_POST, true);

//Constraints: groupCapabilities can be applied only to PLATFORM groups (no to private or blind groups)
$body = array(
    
    "clientId" => $client_idTHRON,
    "groupId" => $idGroupTHRON,
    "active" => $forceRemove
    
);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($body));
$curlResponse     = curl_exec($curl);
$curlResponseInfo = curl_getinfo($curl);
curl_close($curl);

$responseHeadersString = substr($curlResponse, 0, $curlResponseInfo['header_size']);
$responseBody          = substr($curlResponse, $curlResponseInfo['header_size']);
$response              = json_decode($responseBody, true);
//#########################################
//output
echo ("<br>REMOVE GROUP<br>");
print_r($response);

?>    

[/dropdown] [dropdown:JAVA - CREATING A USER]


import it.newvision.nvp.identity.model.*;
import it.newvision.nvp.identity.services.model.request.MVUserManagercreateReq;
import it.newvision.nvp.identity.services.model.vusers.MResponseVUserCreate;
import it.newvision.nvp.identity.services.model.vusers.MVUserParams;
import it.newvision.nvp.identity.services.rest.JVUserManagerClient;
import org.codehaus.jackson.map.ObjectMapper;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by THRON s.p.a. on 18/12/14.
 */
public class createUser {

 public static void main(String[] args) {

  /*SETUP FILE*/
  String clientId = "CLIENTID";
  String tokenID = "TOKEN";
  //user
  String nameUser = "NAME";
  String surnameUser = "SURNAME";
  String usernameUser = nameUser + "." + surnameUser;
  String passwordUser = "PASSWORD";
  MEUserType userTypeUser = MEUserType.PLATFORM_USER_GUEST; //use PLATFORM_USER for normal users
  boolean endFirstAccessNotificationUser = false;
  String timeZoneIdUser = "GMT+1";
  String localeUser = "LOCALE"; //IT or EN

  MEGender genderUser = MEGender.MALE; //['MALE' or 'FEMALE'
  //address
  String addressCategoryUser = "HOME"; //HOME/WORK/...
  String streetUser = "";
  String cityUser = "";
  String areaUser = "";
  String postcodeUser = "";
  String countryUser = "";
  boolean primaryUser = true;
  //phone
  String phoneCategoryUser = "HOME"; //HOME/WORK/...
  String phoneNumberUser = "";
  //email
  String emailCategoryUser = "HOME"; //HOME/WORK/...
  String emailUser = ""; //EMAIL

  //MAIN
  //init object
  ObjectMapper mapper = new ObjectMapper();
  try {

   JVUserManagerClient usersManager = new JVUserManagerClient("http://" + clientId + "-view.thron.com/api/xsso/resources");
   //param
   MVUserManagercreateReq param = new MVUserManagercreateReq();
   MAddress address = new MAddress();
   MCredentialFull newUser = new MCredentialFull();
   MVUserDetail userDetail = new MVUserDetail();
   List < MAddress > arrAddress = new ArrayList < MAddress > ();
   List < MPhoneAddress > arrPhone = new ArrayList < MPhoneAddress > ();
   List < MMailAddress > arrEmails = new ArrayList < MMailAddress > ();
   MMailAddress emails = new MMailAddress();
   MPhoneAddress phone = new MPhoneAddress();
   MFullName fullName = new MFullName();
   MVUserParams userParam = new MVUserParams();
   MVUserPreferences userPreferences = new MVUserPreferences();
   MVUserNotificationProperties userNotificationProperties = new MVUserNotificationProperties();

   //set param
   //user
   newUser.setPassword(passwordUser);
   newUser.setUsername(usernameUser);
   // Detatil
   userDetail.setGender(genderUser);
   //Address
   address.setAddressCategory(addressCategoryUser);
   address.setStreet(streetUser);
   address.setCity(cityUser);
   address.setArea(areaUser);
   address.setPostcode(postcodeUser);
   address.setCountry(countryUser);
   address.setPrimary(primaryUser);

   arrAddress.add(address);
   //set arra
   userDetail.setAddresses(arrAddress);
   //phone
   phone.setPhoneCategory(phoneCategoryUser);
   phone.setPhoneNumber(phoneNumberUser);
   arrPhone.add(phone);
   userDetail.setPhoneNumbers(arrPhone);
   //set name
   fullName.setFirstName(nameUser);
   fullName.setLastName(surnameUser);
   userDetail.setName(fullName);
   //emails
   emails.setEmail(emailUser);
   emails.setEmailCategory(emailCategoryUser);
   arrEmails.add(emails);
   userDetail.setEmails(arrEmails);
   //set param
   param.setClientId(clientId);
   param.setNewUser(newUser);
   param.setDetail(userDetail);

   //send email first access
   param.setSendFirstAccessNotification(endFirstAccessNotificationUser);
   //userType
   param.setUserType(userTypeUser);

   userPreferences.setLocale(localeUser);
   userPreferences.setTimeZoneId(timeZoneIdUser);

   userNotificationProperties.setPhoneNumber(phoneNumberUser);
   userNotificationProperties.setEmail(emailUser);
   userPreferences.setNotificationProperty(userNotificationProperties);
   userParam.setUserPreferences(userPreferences);
   param.setUserParams(userParam);

   // param
   //execute
   MResponseVUserCreate ris = usersManager.create(tokenID, param, null);
   //RESULT THRON
   System.out.println(mapper.writeValueAsString(ris));

  } catch (Exception e) {
   //error file THRON
   System.out.println(e);
  }

 }
}    

[/dropdown] [dropdown:JAVA - UPDATING A USER]


import it.newvision.nvp.identity.model.*;
import it.newvision.nvp.identity.services.model.request.MVUserManagerupdateUserReq;
import it.newvision.nvp.identity.services.model.vusers.MVUserUpdate;
import it.newvision.nvp.identity.services.rest.JVUserManagerClient;
import it.newvision.nvp.identity.services.model.vusers.MResponseVUser;
import org.codehaus.jackson.map.ObjectMapper;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by THRON s.p.a. on 18/12/14.
 */
public class updateUser {

 public static void main(String[] args) {
  /*SETUP FILE*/
  String clientId = "CLIENTID";
  String tokenID = "TOKEN";
  //user
  String nameUser = "NAME";
  String surnameUser = "SURNAME";
  String usernameUser = nameUser + "." + surnameUser;
  //gender
  MEGender genderUser = MEGender.MALE; //'MALE' or 'FEMALE'
  //address
  String addressCategoryUser = "HOME"; //HOME/WORK/...
  String streetUser = "";
  String cityUser = "";
  String areaUser = "";
  String postcodeUser = "";
  String countryUser = "";
  boolean primaryUser = true;
  //phone
  String phoneCategoryUser = "HOME"; //HOME/WORK/...
  String phoneNumberUser = "";
  //email
  String emailCategoryUser = "HOME"; //HOME/WORK/...
  String emailUser = ""; //email user
  //MAIN
  //init object
  ObjectMapper mapper = new ObjectMapper();
  try {
   JVUserManagerClient usersManager = new JVUserManagerClient("http://" + clientId + "-view.thron.com/api/xsso/resources");
   //param
   MVUserManagerupdateUserReq param = new MVUserManagerupdateUserReq();
   MVUserUpdate userUpdateM = new MVUserUpdate();
   MVUserDetail userDetail = new MVUserDetail();
   MAddress address = new MAddress();
   MMailAddress mailAddress = new MMailAddress();
   List < MMailAddress > arrMailAddress = new ArrayList < MMailAddress > ();
   MPhoneAddress phoneAddress = new MPhoneAddress();
   List < MPhoneAddress > arrPhoneAddress = new ArrayList < MPhoneAddress > ();
   List < MAddress > arrAddress = new ArrayList < MAddress > ();
   MVUserPreferences userPreferences = new MVUserPreferences();
   MVUserNotificationProperties userNotificationProperties = new MVUserNotificationProperties();

   //set param
   arrAddress.add(address);
   address.setAddressCategory(addressCategoryUser);
   address.setStreet(streetUser);
   address.setCity(cityUser);
   address.setArea(areaUser);
   address.setPostcode(postcodeUser);
   address.setCountry(countryUser);
   address.setPrimary(primaryUser);

   MEGender gender = genderUser;

   mailAddress.setEmail(emailUser);
   mailAddress.setEmailCategory(emailCategoryUser);

   arrMailAddress.add(mailAddress);

   MFullName fullName = new MFullName();
   fullName.setFirstName(nameUser);
   fullName.setLastName(surnameUser);

   phoneAddress.setPhoneCategory(phoneCategoryUser);
   phoneAddress.setPhoneNumber(phoneNumberUser);

   arrPhoneAddress.add(phoneAddress);

   userNotificationProperties.setPhoneNumber(phoneNumberUser);
   userNotificationProperties.setEmail(emailUser);
   userPreferences.setNotificationProperty(userNotificationProperties);

   userDetail.setAddresses(arrAddress);
   userDetail.setGender(gender);
   userDetail.setEmails(arrMailAddress);
   userDetail.setName(fullName);
   userDetail.setPhoneNumbers(arrPhoneAddress);
   userUpdateM.setDetail(userDetail);
   userUpdateM.setUserPreferences(userPreferences);
   param.setUpdate(userUpdateM);

   //execute
   MResponseVUser ris = usersManager.updateUser(tokenID, clientId, usernameUser, param, null);

   //RESULT THRON
   System.out.println(mapper.writeValueAsString(ris));
  } catch (Exception e) {
   //error file THRON
   System.out.println(e);
  }

 }
}    

[/dropdown] [dropdown:JAVA - REMOVING A USER]


import org.codehaus.jackson.map.ObjectMapper;
import it.newvision.nvp.xadmin.services.model.request.MDashboardmigrateUserStuffReq;
import it.newvision.nvp.xadmin.services.model.utils.MResponseDashboard;
import it.newvision.nvp.xadmin.services.rest.JDashboardClient;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by THRON s.p.a. on 18/12/14.
 */
public class removeUser {

 public static void main(String[] args) {
  /*       SETUP FILE        */
  String clientId = "CLIENTID";
  String tokenID = "TOKEN";
  //user
  String usernameUserRemove = "USERNAME";
  String usernameUserAssign = "USERNAME ASSIGN CONTENT";
  //MAIN
  //init object
  ObjectMapper mapper = new ObjectMapper();
  try {
   // param
   JDashboardClient removeUser = new JDashboardClient("http://" + clientId + "-view.thron.com/api/xadmin/resources");
   MDashboardmigrateUserStuffReq removeUserProp = new MDashboardmigrateUserStuffReq();
   //set param
   removeUserProp.setClientId(clientId);
   removeUserProp.setUserId1(usernameUserRemove);
   removeUserProp.setUserId2(usernameUserAssign);
   removeUserProp.setRemoveUserId1(true);
   //execute
   MResponseDashboard ris = removeUser.migrateUserStuff(tokenID, removeUserProp, null);

   //RESULT THRON
   System.out.println(mapper.writeValueAsString(ris));
  } catch (Exception e) {
   //error file THRON
   System.out.println(e);
  }

 }
}

[/dropdown] [dropdown:JAVA - CREATING A GROUP]


import org.codehaus.jackson.map.ObjectMapper;
import it.newvision.nvp.xadmin.services.model.request.MDashboardmigrateUserStuffReq;
import it.newvision.nvp.xadmin.services.model.utils.MResponseDashboard;
import it.newvision.nvp.xadmin.services.rest.JDashboardClient;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by THRON s.p.a. on 18/12/14.
 */
public class removeUser {

 public static void main(String[] args) {
  /*       SETUP FILE        */
  String clientId = "CLIENTID";
  String tokenID = "TOKEN";
  //userimport it.newvision.nvp.identity.model.MEGroupType;
  import it.newvision.nvp.identity.services.model.request.MUsersGroupManagercreateGroupReq;
  import it.newvision.nvp.identity.services.model.usersgroup.MGroupInitData;
  import it.newvision.nvp.identity.services.model.usersgroup.MResponseCreateUsersGroup;
  import it.newvision.nvp.identity.services.rest.JUsersGroupManagerClient;
  import org.codehaus.jackson.map.ObjectMapper;

  import java.util.ArrayList;
  import java.util.List;


  /**
   * Created by THRON s.p.a. on 18/12/14.
   */
  public class createGroup {

   public static void main(String[] args) {

    /*SETUP FILE*/
    String clientId = "CLIENTID";
    String tokenID = "TOKEN";

    // group name
    String groupNameTHRON = "GROUP NAME";
    // description group
    String groupDescriptionTHRON = " GROUP DESCRIPTION";
    // type group
    MEGroupType groupTypeTHRON = MEGroupType.PLATFORM_BLIND; //groupType (string) = ['PLATFORM' or 'PLATFORM_BLIND' or 'SHARED_CONTACTS' or 'PRIVATE'],
    //MAIN
    //init object
    ObjectMapper mapper = new ObjectMapper();
    try {

     JUsersGroupManagerClient usersGroupManager = new JUsersGroupManagerClient("http://" + clientId + "-view.thron.com/api/xsso/resources");
     //set param
     MUsersGroupManagercreateGroupReq param = new MUsersGroupManagercreateGroupReq();
     MGroupInitData paramMGroupInitData = new MGroupInitData();
     // param
     paramMGroupInitData.setName(groupNameTHRON);
     paramMGroupInitData.setDescription(groupDescriptionTHRON);
     paramMGroupInitData.setGroupType(groupTypeTHRON);
     param.setClientId(clientId);
     param.setUsersGroup(paramMGroupInitData);
     //execute
     MResponseCreateUsersGroup ris = usersGroupManager.createGroup(tokenID, param, null);
     //RESULT THRON
     System.out.println(mapper.writeValueAsString(ris));
    } catch (Exception e) {
     //error file THRON
     System.out.println(e);
    }

   }
  }

 }
}
    

[/dropdown] [dropdown:JAVA - UPDATING A GROUP]


import it.newvision.nvp.identity.services.model.request.MUsersGroupManagerupdateReq;
import it.newvision.nvp.identity.services.model.usersgroup.MResponseUsersGroup;
import it.newvision.nvp.identity.services.model.usersgroup.MUserGroupUpdate;
import it.newvision.nvp.identity.services.rest.JUsersGroupManagerClient;
import org.codehaus.jackson.map.ObjectMapper;


/**
 * Created by THRON s.p.a. on 18/12/14.
 */
public class updateGroup {

 public static void main(String[] args) {

  /*SETUP FILE*/
  String clientId = "CLIENTID";
  String tokenID = "TOKEN";
  String groupIDTHRON = "GROUP ID";
  // group name
  String groupNameTHRON = "GROUP NAME";
  // description group
  String groupDescriptionTHRON = " GROUP DESCRIPTION";

  //MAIN
  //init object
  ObjectMapper mapper = new ObjectMapper();
  try {
   JUsersGroupManagerClient usersGroupManager = new JUsersGroupManagerClient("http://" + clientId + "-view.thron.com/api/xsso/resources");
   //set param
   MUsersGroupManagerupdateReq param = new MUsersGroupManagerupdateReq();
   MUserGroupUpdate setValueUpdate = new MUserGroupUpdate();
   // param
   setValueUpdate.setName(groupNameTHRON);
   setValueUpdate.setDescription(groupDescriptionTHRON);
   param.setUpdate(setValueUpdate);
   //execute
   MResponseUsersGroup ris = usersGroupManager.update(tokenID, clientId, groupIDTHRON, param, null);
   //RESULT THRON
   System.out.println(mapper.writeValueAsString(ris));

  } catch (Exception e) {
   //error file THRON
   System.out.println(e);
  }

 }
}    

[/dropdown] [dropdown:JAVA - REMOVING A GROUP]


import it.newvision.nvp.identity.services.model.request.MUsersGroupManagerremoveGroupReq;
import it.newvision.nvp.identity.services.model.usersgroup.MResponseUsersGroup;
import it.newvision.nvp.identity.services.rest.JUsersGroupManagerClient;
import org.codehaus.jackson.map.ObjectMapper;


/**
 * Created by THRON s.p.a. on 18/12/14.
 */
public class removeGroup {

 public static void main(String[] args) {

  /*SETUP FILE*/
  String clientId = "CLIENTID";
  String tokenID = "TOKEN";
  String groupIDTHRON = "GROUP ID";
  boolean groupForceRemoveTHRON = false;

  //MAIN
  //init object
  ObjectMapper mapper = new ObjectMapper();
  try {

   JUsersGroupManagerClient usersGroupManager = new JUsersGroupManagerClient("http://" + clientId + "-view.thron.com/api/xsso/resources");
   // param
   MUsersGroupManagerremoveGroupReq param = new MUsersGroupManagerremoveGroupReq();
   //set param
   param.setClientId(clientId);
   param.setForce(groupForceRemoveTHRON);
   param.setGroupId(groupIDTHRON);
   //execute
   MResponseUsersGroup ris = usersGroupManager.removeGroup(tokenID, param, null);
   //RESULT THRON
   System.out.println(mapper.writeValueAsString(ris));

  } catch (Exception e) {
   //error file THRON
   System.out.println(e);
  }

 }
}    

[/dropdown] [/tab]

Was this article helpful?
0 out of 0 found this helpful

Have any question?

Open a ticket
Comments