CRecordGetApplicationListForUser

The CRecordGetApplicationListForUser message retrieves a list of applications that the user is allowed to start.

This message belongs to the application factory collector API.
The Application Collector Service is located in the plugin NY_ApplicationFactoryCollectorPlugIn.

{
  "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": "1",
      "name": "PLATFORM",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING",
      "description": "The platform on which the application is to run."
    },
    {
      "key": "10",
      "name": "APPLICATION_LIST",
      "direction": "ANSWER",
      "mandatory": "false",
      "type": "RECORD_ARRAY",
      "description": "The application list (maybe empty)."
    }
  ]
}

Arguments

The request also requires the session token, from which the rights of the current user are derived.

  • PLATTFORM: The UI platform for which the application was designed. The SWING and WEB platforms are currently supported.
  • APPLICATION_LIST: Response: The list of applications that the user is allowed to start and that match the given platform type.

Usage

Sending the message

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

private void getApplicationListForUser(final byte[] aToken) throws CException
{
    // The message is sent to the AppCollector microservice.
    final IId microserviceId = CIdFactory.fromObject("NY_ApplicationFactoryCollector");
    final CEnvelope env = CEnvelope.forMicroService(microserviceId);
    env.setSessionToken(aToken);

    final CRecord record = CRecordGetApplicationListForUser.create();
    CRecordGetApplicationListForUser.setPlatform(record,
                                                 "WEB"");
    sendRequest(env,
                record);
}

Dealing with the response

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;
    }
}

See also: