CRecordFileRegistryGetFileInfo

With it, we retrieve information about available files. The key to the files is the provided relative path of the desired file.

This message is part of the The File Registry API API.

{
  "id": "18124fad-2724-4d9f-bc85-1b835fde5a8d",
  "name": "FILE_REGISTRY_GET_FILE_INFO",
  "description": "Get information about a file from the file registry.",
  "slots": [
    {
      "key": "path",
      "name": "PATH",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING",
      "description": "The relative path of the file."
    },
    {
      "key": "rec",
      "name": "FILE_INFO",
      "direction": "ANSWER",
      "mandatory": "false",
      "type": "RECORD_ARRAY",
      "description": "The information about files in the file registry.\nRecords are from type FILE_REGISTRY_FILE_INFO"
    }
  ]
}

Message Arguments

Key Name Direction Mandatory Type Description
path PATH REQUEST true STRING The relative path of the file.
rec FILE_INFO ANSWER false RECORD_ARRAY The information about files in the file registry.
Records are from type FILE_REGISTRY_FILE_INFO

Usage

Send a request to the FileRegistry microservice.

final IId microServiceId = CIdFactory.fromObject("file.registry");
final CEnvelope env = CEnvelope.forMicroService(microServiceId);

final CRecord record = CRecordFileRegistryGetFileInfo.create();
CRecordFileRegistryGetFileInfo.setPath(record,
                                       "lib\junit-4.10.jar");
sendRequest(env,
            record);

Receive the response.

// in constructor:
addMessageHandler(CRecordFileRegistryGetFileInfo.ID,
                  this::asyncGetFileInfo);

// fetch microservice data from reply
private boolean asyncGetFileInfo(@NotNull final CEnvelope aEnvelope,
                                 @NotNull final CRecord aRecord)
{
    if (aEnvelope.isAnswer())
    {
        if (aEnvelope.getResult()
                     .hasSuccess())
        {
            final CRecord[] arr = CRecordFileRegistryGetFileInfo.getFileInfo(aRecord,
                                                                             null);
            if (arr != null)
            {
                for (final CRecord rec : arr)
                {
                    final String path = CRecordFileRegistryFileInfo.getPath(rec,
                                                                            null);
                    final String hash = CRecordFileRegistryFileInfo.getHash(rec,
                                                                            null);
                    final Instant timeOfLastModification = CRecordFileRegistryFileInfo.getTimeOfLastModification(rec,
                                                                                                                 null);
                    final CTargetAddress sourceAddress = CRecordFileRegistryFileInfo.getSourceAddress(rec,
                                                                                                      null);

                    //...
                }
            }
        }
        return true;
    }
    else
    {
        return false;
    }
}

Record Usage

In nyssr.net, we typically don't exchange interfaces between projects. Instead, we use platform-independent Records to describe message formats.

One or more descriptions of these Records are stored in the JSON or XML format as record.json or record.xml within a directory. The Record Generator, an included Swing tool, generates helper classes from these files. These classes can then be used to type-safely write or read messages.

See also