Repository
Overview
Module
- package:
org.eclipse.dirigible.sdk.platform - source: platform/Repository.java
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:
createResourcelets you tag a resource with a MIME type up front. - Native variants:
*Nativeoverloads takebyte[]directly to avoid string encoding. - Pattern search:
findwalks a sub-tree and returns matches against a regex.
Example Usage
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.
javapublic static IResource getResource(String path);
Parameter Type Description 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.
javapublic static IResource createResource(String path, String content, String contentType);
Parameter Type Description 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.
javapublic static IResource createResourceNative(String path, byte[] content, String contentType);
Parameter Type Description 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.
javapublic static IResource updateResource(String path, String content);
Parameter Type Description 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.
javapublic static IResource updateResourceNative(String path, byte[] content);
Parameter Type Description 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.
javapublic static void deleteResource(String path);
Parameter Type Description pathStringThe repository path of the resource. Returns
- Type:
void
getCollection()
Looks up a collection (folder) at the given repository path.
javapublic static ICollection getCollection(String path);
Parameter Type Description 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.
javapublic static ICollection createCollection(String path);
Parameter Type Description pathStringThe repository path of the new collection. Returns
- Type:
ICollection- Description: The created collection.
deleteCollection()
Removes a collection from the repository.
javapublic static void deleteCollection(String path);
Parameter Type Description pathStringThe repository path of the collection. Returns
- Type:
void
find()
Walks the repository sub-tree at path and returns entries matching the regex pattern.
javapublic static String find(String path, String pattern) throws IOException;
Parameter Type Description pathStringThe root path to walk. patternStringA regular expression matched against entries. Returns
- Type:
String- Description: A JSON-serialized list of matching paths.