Java Client SDK 3.10

Directory

Updated: July 18, 2024

This section is about how handling directories (and vocabularies) with Nuxeo Java Client.

Let's first retrieve directory manager to handle them:

DirectoryManager directoryManager = client.directoryManager();

Directory manager only have two APIs:

  • fetchDirectories to fetch all directories configured on Nuxeo Server
  • directory which takes a directory name and returns the directory entity

Create

DirectoryEntry entry = new DirectoryEntry();
entry.putIdProperty("foo");
entry.putLabelProperty("Foo");
directoryManager.directory("nature").createEntry(entry);

Fetch

APIs below are available to fetch directory entry:

  • fetchEntries which takes nothing
  • fetchEntries which takes currentPageIndex, pageSize, maxResult, sortBy and sortOrder
  • fetchEntry which takes an entry id

Let's fetch all entries:

DirectoryEntries entries = directoryManager.directory("nature").fetchEntries();
DirectoryEntry foo = entries.getDirectoryEntry("foo");

Let's fetch our entry:

DirectoryEntry foo = directoryManager.directory("nature").fetchEntry("foo");

Update

APIs below are available to update directory entry:

  • updateEntry which takes a directory entry

Let's update our entry:

Directory nature = directoryManager.directory("nature");
DirectoryEntry foo = nature.fetchEntry("foo");
foo.putLabelProperty("New Foo");
nature.updateEntry(foo);

As DirectoryEntry is a connectable entity and we get foo from client we can do the following:

DirectoryEntry foo = directoryManager.directory("nature").fetchEntry("foo");
foo.putLabelProperty("New Foo");
foo.update();

Delete

API below is available to delete directory entry:

  • deleteEntry which takes a directory entry id

Let's delete foo:

directoryManager.directory("nature").deleteEntry("foo");

As DirectoryEntry is a connectable entity and we get foo from client we can do the following:

DirectoryEntry foo = directoryManager.directory("nature").fetchEntry("foo");
foo.delete();