The jsma contents provides access to the all contents (JSMA content) in the instance.
What can JSMA contents do for me?You could use the JSMA contents to find and manipulate a JSMA content. |
The JSMA contents provides the following methods:
Creates a JSMA content with the specified options and returns it
//create content var content = contents.create({ name : contentName, package : namespace.id, body : contentBody, type : "Widget", mimeType : "application/json" }); |
Following values must be set, depending on the type:
Returns the current content (JSMA content) of this request.
var content = contents.current; //found content if (content) { var m = content.mapping; var prot = request.protocol; [...] } |
Deletes a JSMA content from the database (within the current users slice)
This entity is slice aware, which means that to use this facility:
|
... contents.delete(content); ... |
A JSMA content.
Searches and retrieves a list of JSMA content from the Sphinx index.
var entryContents = contents.find('@flex_attributes "rhino.catalog.entryName:' + referencedContent.name + '" "rhino.catalog.entryType:content"', { limit : 100 }); if (entryContents.length > 0) { [...] } |
Retrieves a single JSMA content by id.
Avoid usage of findByIdIds change whenever a package is reimported. So please avoid using ids whenever possible. Also delivering contents to users by id might make it possible for users to flip through the files (and by that see contents of others possibly) by changing the ids in requests. |
... contents.findById(1); // => content ... |
The id of a content in the database.
Retrieves a single JSMA content by exact name.
... var ignoredTestsContent = contents.findByName("zebra.IgnoredTests"); var ignoredTests = JSON.parse(ignoredTestsContent.content); ... |
The exact name of a content in the database.
Retrieves a list of JSMA content by a SQL-compatible regular expression that is matched on the name column of the contents in the database.
var catalogRootPackage = portals.current.get("rhino.catalog.CatalogRootPackage"); var regex = catalogRootPackage; regex = regex.replace(/\./i, "\\."); regex = "^" + regex + "\\..*" + filter + ".*$"; var childContents = contents.findByRegex(regex, { limit : 10000, types : ["widget"] }); |
The regular expression without the leading and trailing slashes.
Retrieves a single JSMA content by uuid.
... contents.findByUuid('uuid'); // => content ... |
Renders the given input String like a Widget.
... contents.render('# {some.macro}'); // => 'rendered representation' ... |