CRecordGetApplicationListForUser

Get a list of applications that the user is allowed to launch.

This message belongs to the application factory collector API.

{
  "id": "25615f1c-5ada-4893-b551-8122f7def7f9",
  "name": "GET_APPLICATION_LIST_FOR_USER",
  "isService": "false",
  "namespaces": "",
  "description": "Fetches a list of applications that the user is allowed to launch.",
  "slots": [
    {
      "key": "sessionToken",
      "name": "SESSION_TOKEN",
      "direction": "REQUEST",
      "mandatory": "false",
      "type": "UUID",
      "description": "Optional: The session token."
    },
    {
      "key": "appList",
      "name": "APPLICATION_LIST",
      "direction": "ANSWER",
      "mandatory": "false",
      "type": "RECORD_ARRAY",
      "description": "The application list (maybe empty)."
    }
  ]
}

Example of use (after generating of the class CRecordGetApplicationListForUser):

  private void getApplicationListForUser(@Nullable final UUID aToken) throws CException
  {
      final IId microserviceId = CIdFactory.fromObject("NY_ApplicationFactoryCollector");
      final CEnvelope env = CEnvelope.forMicroService(microserviceId);

      final CRecord record = CRecordGetApplicationListForUser.create();
      if (aToken != null)
      {
          CRecordGetApplicationListForUser.setSessionToken(record,
                                                           aToken);
      }
      sendRequest(env,
                  record);
  }

The response message is handled by a message handler.

// in the constructor of your target
addMessageHandler(CRecordGetApplicationListForUser.ID,
                  this::asyncGetApplicationListForUser);
private boolean asyncGetApplicationListForUser(@NotNull final CEnvelope aEnvelope,
                                               @NotNull final CRecord aRecord)
{
    if (aEnvelope.isAnswer())
    {
        if (aEnvelope.getResultCode() == CResultCode.SUCCESS)
        {
            final CRecord[] applicationList = CRecordGetApplicationListForUser.getApplicationList(aRecord,
                                                                                                  null);
            if (applicationList != null)
            {
                // for each application record
                for (final CRecord app : applicationList)
                {
                    final UUID id = CRecordApplication.getId(app,
                                                             null);
                    final String name = CRecordApplication.getName(app,
                                                                   "");
                    final String shortDescription = CRecordApplication.getShortDescription(app,
                                                                                           "");
                    final String longDescription = CRecordApplication.getLongDescription(app,
                                                                                         "");
                    final CStringProperties properties = CRecordApplication.getProperties(app,
                                                                                          null);
                    final String[] permissions = CRecordApplication.getPermissions(app,
                                                                                   null);
                    // You can retrieve the image from the local file store by message,
                    // which will load it from the global file store.
                    final String icon = CRecordApplication.getIcon(app,
                                                                   "");
                    // ...
                }
            }
        }
        else
        {
            // ...
        }
        return true;
    }
    else
    {
        return false;
    }
}

nyssr.net - Innovative Distributed System