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, not Name (see ContentPath).
- A document made in an application becomes a
DocumentReference there, to a
Document TM1 makes in Blobs with a timestamp in its name, such as
notes_20261122125939.txt. Its content goes through the reference
(content, upload). 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());
ContentService constructor | A service sending its requests through session. |
roots | GET Contents, streamed. |
get | GET of one entry. |
contents | A folder's entries, streamed. |
create | Makes an entry in a folder. |
delete | DELETE of an entry, and everything in it if it's a folder. |
containedBy | The folder an entry is in. |
localizedAttributes | LocalizedAttributes, streamed. |
copy | Copies an entry into a folder. |
move | Moves an entry into a folder. |
document | The document a reference refers to, in Blobs. |
content | A document's Content, streamed as it arrives. |
upload | Replaces a document's Content. |
ContentService(Tm1Session session)
A service sending its requests through session.
Parameters
session- the session
Flux<Entry> contents(ContentPath folder, ContentScope scope, ODataQuery query)
A folder's entries, streamed. References' objects come by a cast expand, such as
expand("tm1.CubeReference/Cube($select=Name)").
Parameters
folder- the folder
scope- its public or private entries
query- what to select, expand, filter and order
Returns
- the entries, each of its own kind
Flux<DataBuffer> content(ContentPath document)
A document's Content, streamed as it arrives. The path is a document
reference, or a document in Blobs. Each buffer is the subscriber's to
release, or to hand on, such as to DataBufferUtils.write.
Parameters
document- where it is
TM1 REST Navigation DocumentReference/Document