Class ContentService
java.lang.Object
io.skipcheck.tm1.client.service.content.ContentService
The contents tree, where Planning Analytics keeps applications: folders, documents,
links, and references to cubes, dimensions, subsets, views, processes and chores.
Entries are addressed by
ContentPath.
What TM1 (11.8) does here that you might not expect:
- Entries are found by
ID, notName(seeContentPath). - A document made in an application becomes a
DocumentReferencethere, to aDocumentTM1 makes inBlobswith a timestamp in its name, such asnotes_20261122125939.txt. Its content goes through the reference (content(ContentPath),upload(ContentPath, Publisher)). A copy of the reference refers to the same document; deleting a reference leaves the document while another refers to it. - Entries can't be changed: TM1 refuses a PATCH ("PATCH not supported on this resource"), so there's no update. To rename one, copy it with a new name and delete the original.
Build an application: a folder, a link and a cube reference:
// An application: a folder with a link and a reference to a cube
ContentPath planning = ContentPath.applications().child("Planning");
return tm1.contents()
.create(ContentPath.applications(), ContentScope.PUBLIC, FolderPatch.builder().name("Planning").build())
.then(tm1.contents()
.create(planning, ContentScope.PUBLIC,
LinkPatch.builder().name("Guide").url("https://example.com/planning-guide").build()))
.then(tm1.contents()
.create(planning, ContentScope.PUBLIC,
CubeReferencePatch.builder()
.name("Sales")
.bindCube(ODataPath.of("Cubes").key("Sales"))
.build()));
Upload a document from a file:
// A document made in an application is a reference to one TM1 keeps in Blobs; the
// reference, as create returns it, is where its content goes
ContentPath planning = ContentPath.applications().child("Planning");
return tm1.contents()
.create(planning, ContentScope.PUBLIC, DocumentPatch.builder().name("notes.txt").build())
.flatMap(reference -> tm1.contents()
.upload(planning.child(reference),
// read again if the session has to log in again
DataBufferUtils.read(file, DefaultDataBufferFactory.sharedInstance, 8192)));
Download a document's content to a file:
// Streamed to the file, never held whole
ContentPath notes = ContentPath.applications().child("Planning").child("notes.txt.blob");
return DataBufferUtils.write(tm1.contents().content(notes), file);
List the cubes an application refers to:
// The cubes an application refers to, by a cast expand
return tm1.contents()
.contents(ContentPath.applications().child("Planning"), ContentScope.PUBLIC,
ODataQuery.none().expand("tm1.CubeReference/Cube($select=Name)"))
.ofType(CubeReference.class)
.mapNotNull(reference -> reference.cube() == null ? null : reference.cube().name());
-
Constructor Summary
ConstructorsConstructorDescriptionContentService(Tm1Session session) A service sending its requests throughsession. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Folder> containedBy(ContentPath entry, ODataQuery query) ContainedBy: the folder an entry is in.reactor.core.publisher.Flux<DataBuffer> content(ContentPath document) A document'sContent, streamed as it arrives.reactor.core.publisher.Flux<Entry> contents(ContentPath folder, ContentScope scope, ODataQuery query) A folder's entries, streamed.reactor.core.publisher.Mono<Entry> copy(ContentPath entry, ContentPath target, ContentScope scope, @Nullable String name) tm1.Copy: copies an entry into a folder.reactor.core.publisher.Mono<Entry> create(ContentPath folder, ContentScope scope, EntryPatch entry) Makes an entry in a folder: aFolderPatch,DocumentPatch,LinkPatchor a reference, such as aCubeReferencePatchwithbindCube(ODataPath.of("Cubes").key("Sales")).reactor.core.publisher.Mono<Void> delete(ContentPath entry) DELETEof an entry, and everything in it if it's a folder.reactor.core.publisher.Mono<Document> document(ContentPath reference, ODataQuery query) Document: the document a reference refers to, inBlobs.reactor.core.publisher.Mono<Entry> get(ContentPath entry, ODataQuery query) GETof one entry.reactor.core.publisher.Flux<LocalizedAttributes> localizedAttributes(ContentPath entry, ODataQuery query) LocalizedAttributes, streamed: an entry's attributes in each locale.reactor.core.publisher.Mono<Entry> move(ContentPath entry, ContentPath target, ContentScope scope, @Nullable String name) tm1.Move: moves an entry into a folder.reactor.core.publisher.Flux<Entry> roots(ODataQuery query) GET Contents, streamed: the root folders,ApplicationsandBlobs.reactor.core.publisher.Mono<Void> upload(ContentPath document, org.reactivestreams.Publisher<DataBuffer> content) Replaces a document'sContent.
-
Constructor Details
-
ContentService
A service sending its requests throughsession.- Parameters:
session- the session
-
-
Method Details
-
roots
@Tm1Endpoint("EntitySet Contents") public reactor.core.publisher.Flux<Entry> roots(ODataQuery query) GET Contents, streamed: the root folders,ApplicationsandBlobs.- Parameters:
query- what to select, expand, filter and order- Returns:
- the roots
-
get
@Tm1Endpoint("EntitySet Contents") public reactor.core.publisher.Mono<Entry> get(ContentPath entry, ODataQuery query) GETof one entry. A reference's object comes by a cast expand, such asexpand("tm1.CubeReference/Cube").- Parameters:
entry- where it isquery- what to select and expand- Returns:
- the entry, of its own kind (
Folder,Link,CubeReference…), or aTm1NotFoundExceptionif there's none
-
contents
@Tm1Endpoint("Navigation Folder/Contents") @Tm1Endpoint("Navigation Folder/PrivateContents") @Tm1Endpoint("Navigation ChoreReference/Chore") @Tm1Endpoint("Navigation CubeReference/Cube") @Tm1Endpoint("Navigation DimensionReference/Dimension") @Tm1Endpoint("Navigation ProcessReference/Process") @Tm1Endpoint("Navigation SubsetReference/Subset") @Tm1Endpoint("Navigation ViewReference/View") public reactor.core.publisher.Flux<Entry> contents(ContentPath folder, ContentScope scope, ODataQuery query) A folder's entries, streamed. References' objects come by a cast expand, such asexpand("tm1.CubeReference/Cube($select=Name)").- Parameters:
folder- the folderscope- its public or private entriesquery- what to select, expand, filter and order- Returns:
- the entries, each of its own kind
-
create
@Tm1Endpoint("Navigation Folder/Contents") @Tm1Endpoint("Navigation Folder/PrivateContents") public reactor.core.publisher.Mono<Entry> create(ContentPath folder, ContentScope scope, EntryPatch entry) Makes an entry in a folder: aFolderPatch,DocumentPatch,LinkPatchor a reference, such as aCubeReferencePatchwithbindCube(ODataPath.of("Cubes").key("Sales")). A document made outsideBlobscomes back as aDocumentReference, with an empty document behind it;upload(ContentPath, Publisher)gives it content.- Parameters:
folder- the folderscope- whether it's public or privateentry- the entry- Returns:
- the entry as made, with the
IDto find it by
-
delete
@Tm1Endpoint("EntitySet Contents") public reactor.core.publisher.Mono<Void> delete(ContentPath entry) DELETEof an entry, and everything in it if it's a folder.- Parameters:
entry- where it is- Returns:
- completes when it's gone
-
containedBy
@Tm1Endpoint("Navigation Entry/ContainedBy") public reactor.core.publisher.Mono<Folder> containedBy(ContentPath entry, ODataQuery query) ContainedBy: the folder an entry is in.- Parameters:
entry- where it isquery- what to select- Returns:
- the folder
-
localizedAttributes
@Tm1Endpoint("Navigation Entry/LocalizedAttributes") public reactor.core.publisher.Flux<LocalizedAttributes> localizedAttributes(ContentPath entry, ODataQuery query) LocalizedAttributes, streamed: an entry's attributes in each locale.- Parameters:
entry- where it isquery- what to select and filter- Returns:
- the localized attributes
-
copy
@Tm1Endpoint("Action Entry/Copy") public reactor.core.publisher.Mono<Entry> copy(ContentPath entry, ContentPath target, ContentScope scope, @Nullable String name) tm1.Copy: copies an entry into a folder. A copied document reference refers to the same document.- Parameters:
entry- where it istarget- the folder to copy it toscope- whether the copy is public or privatename- the copy's name, ornullto keep the entry's- Returns:
- the copy
-
move
@Tm1Endpoint("Action Entry/Move") public reactor.core.publisher.Mono<Entry> move(ContentPath entry, ContentPath target, ContentScope scope, @Nullable String name) tm1.Move: moves an entry into a folder.- Parameters:
entry- where it istarget- the folder to move it toscope- whether it's public or private therename- its new name, ornullto keep it- Returns:
- the entry where it is now
-
document
@Tm1Endpoint("Navigation DocumentReference/Document") public reactor.core.publisher.Mono<Document> document(ContentPath reference, ODataQuery query) Document: the document a reference refers to, inBlobs.- Parameters:
reference- where theDocumentReferenceisquery- what to select- Returns:
- the document, with its
SizeandLastUpdated
-
content
@Tm1Endpoint("Navigation DocumentReference/Document") public reactor.core.publisher.Flux<DataBuffer> content(ContentPath document) A document'sContent, streamed as it arrives. The path is a document reference, or a document inBlobs. Each buffer is the subscriber's to release, or to hand on, such as toDataBufferUtils.write.- Parameters:
document- where it is- Returns:
- the bytes
-
upload
@Tm1Endpoint("Navigation DocumentReference/Document") public reactor.core.publisher.Mono<Void> upload(ContentPath document, org.reactivestreams.Publisher<DataBuffer> content) Replaces a document'sContent. The path is a document reference, or a document inBlobs. TM1 (11.8) refuses a chunked upload, so the content is gathered and sent with its length: it's held in memory whole while it's sent. If the session has to log in again,contentis subscribed again, so it should be one that can be, such asDataBufferUtils.readof a file.- Parameters:
document- where it iscontent- the bytes- Returns:
- completes when they're written
-