Skip to content

Repository

Overview

Module

Mutable access to the Dirigible repository — resources (files), collections (folders), copies and moves, content-typed creates and updates. Returns the platform's IResource / ICollection domain types so callers can chain further operations (lock, version, set properties).

The "repository" here is the on-disk Dirigible store (see IRepository / IRepositoryStructure), not a JPA repository or a Git repository. For workspace-scoped operations (per-user folders under /users/<u>/workspace/<proj>) prefer Workspace; for the read-only public registry view prefer Registry.

Key Features

  • Resource CRUD: Create, read, update, and delete files with either text or binary content.
  • Collection CRUD: Create and delete folder-like collections.
  • Content typing: createResource lets you tag a resource with a MIME type up front.
  • Native variants: *Native overloads take byte[] directly to avoid string encoding.
  • Pattern search: find walks a sub-tree and returns matches against a regex.

Example Usage

java
import org.eclipse.dirigible.repository.api.ICollection;
import org.eclipse.dirigible.repository.api.IResource;
import org.eclipse.dirigible.sdk.platform.Repository;

// Create a new text resource under the repository:
IResource res = Repository.createResource(
    "/registry/public/demo/notes/intro.txt",
    "hello",
    "text/plain"
);

// Update its content later:
Repository.updateResource(
    "/registry/public/demo/notes/intro.txt",
    "hello world"
);

// Create a collection (folder):
ICollection col = Repository.createCollection("/registry/public/demo/notes/2026");

// Search for resources by name pattern:
String matches = Repository.find("/registry/public/demo", ".*\\.txt$");

Methods

getResource()

Looks up a resource (file) at the given repository path.

java
public static IResource getResource(String path);
ParameterTypeDescription
pathStringThe repository path to the resource.

Returns

  • Type: IResource
  • Description: The platform resource domain object, or a wrapper that reports exists() == false.

createResource()

Creates a new resource with text content and the given MIME content type.

java
public static IResource createResource(String path, String content, String contentType);
ParameterTypeDescription
pathStringThe repository path of the new resource.
contentStringThe text content.
contentTypeStringThe MIME content type to record (e.g. "text/plain").

Returns

  • Type: IResource
  • Description: The created resource.

createResourceNative()

Creates a new resource with binary content and the given MIME content type.

java
public static IResource createResourceNative(String path, byte[] content, String contentType);
ParameterTypeDescription
pathStringThe repository path of the new resource.
contentbyte[]The raw bytes to store.
contentTypeStringThe MIME content type to record.

Returns

  • Type: IResource
  • Description: The created resource.

updateResource()

Replaces the text content of an existing resource.

java
public static IResource updateResource(String path, String content);
ParameterTypeDescription
pathStringThe repository path of the resource.
contentStringThe new text content.

Returns

  • Type: IResource
  • Description: The updated resource.

updateResourceNative()

Replaces the binary content of an existing resource.

java
public static IResource updateResourceNative(String path, byte[] content);
ParameterTypeDescription
pathStringThe repository path of the resource.
contentbyte[]The new raw bytes.

Returns

  • Type: IResource
  • Description: The updated resource.

deleteResource()

Removes a resource from the repository.

java
public static void deleteResource(String path);
ParameterTypeDescription
pathStringThe repository path of the resource.

Returns

  • Type: void

getCollection()

Looks up a collection (folder) at the given repository path.

java
public static ICollection getCollection(String path);
ParameterTypeDescription
pathStringThe repository path of the collection.

Returns

  • Type: ICollection
  • Description: The platform collection domain object, or a wrapper that reports exists() == false.

createCollection()

Creates a new collection (folder) at the given repository path.

java
public static ICollection createCollection(String path);
ParameterTypeDescription
pathStringThe repository path of the new collection.

Returns

  • Type: ICollection
  • Description: The created collection.

deleteCollection()

Removes a collection from the repository.

java
public static void deleteCollection(String path);
ParameterTypeDescription
pathStringThe repository path of the collection.

Returns

  • Type: void

find()

Walks the repository sub-tree at path and returns entries matching the regex pattern.

java
public static String find(String path, String pattern) throws IOException;
ParameterTypeDescription
pathStringThe root path to walk.
patternStringA regular expression matched against entries.

Returns

  • Type: String
  • Description: A JSON-serialized list of matching paths.

Released under the EPL-2.0 License.