public static void runExample(
DfaServices dfaServices, DfaSession session, String userRoleName, long subnetworkId,
long parentUserRoleId, long permission1Id, long permission2Id) throws Exception {
// Request the service.
UserRoleRemote service = dfaServices.get(session, UserRoleRemote.class);
// Create user role structure.
UserRole userRole = new UserRole();
userRole.setId(0);
userRole.setName(userRoleName);
userRole.setSubnetworkId(subnetworkId);
userRole.setParentUserRoleId(parentUserRoleId);
// Create a permission object to represent each permission this user role
// has.
Permission permission1 = new Permission();
permission1.setId(permission1Id);
Permission permission2 = new Permission();
permission2.setId(permission2Id);
Permission[] permissions = new Permission[] {permission1, permission2};
// Add the permissions to the user role.
userRole.setPermissions(permissions);
// Create user role.
UserRoleSaveResult userRoleSaveResult = service.saveUserRole(userRole);
// Display user role ID.
System.out.println("User role with ID \"" + userRoleSaveResult.getId()
+ "\" was created.");
}