JSMA contents

Overview

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.


Index

Methods

The JSMA contents provides the following methods:

content contents.create([options])

Creates a JSMA content with the specified options and returns it

Example

//create content
var content = contents.create({
  name : contentName,
  package : namespace.id,
  body : contentBody,
  type : "Widget",
  mimeType : "application/json"
});

Parameter options:object (optional)

Following values must be set, depending on the type:

  • All types:
    • name
    • namespace
  • Seite
    • mapping url
    • mime-type
  • Weiterleitung
    • (no further values needed)
  • Widget
    • mime-type
  • Template
    • (no further values needed)
  • Makro
    • mime-type
  • WebEvent
    • (no further values needed)
  • Dokumentation
    • (no further values needed)
  • Test
    • (no further values needed)
  • Universal
    • mime-type
  • SQL-Query
    • (no further values needed)
  • Sql-Command
    • (no further values needed)

content contents.current()

Returns the current content (JSMA content) of this request.

Example

var content = contents.current;

//found content
if (content) {
  var m = content.mapping;
  var prot = request.protocol;

  [...]
}

void contents.delete(content)

Deletes a JSMA content from the database (within the current users slice)

Slice aware

This entity is slice aware, which means that to use this facility:

  • there must be a logged in user in the context of the execution
  • this user must be currently within a slice
  • this user must have the necessary privileges to edit the entity (IFE → System → Benutzer → Roles → Content-Management)

Example

...
contents.delete(content);
...

Parameter content (required)

A JSMA content.

contents.find(query, [options])

Searches and retrieves a list of JSMA content from the Sphinx index.

Example

var entryContents = contents.find('@flex_attributes "rhino.catalog.entryName:' + referencedContent.name + '" "rhino.catalog.entryType:content"', { limit : 100 });
    
if (entryContents.length > 0) {

  [...]

}

Parameter query:string (required)

Parameter options:object (optional)

content contents.findById(id)

Retrieves a single JSMA content by id.

Avoid usage of findById

Ids 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.

Example

...
contents.findById(1); // => content
...

Parameter id:int (required)

The id of a content in the database.

content contents.findByName(name)

Retrieves a single JSMA content by exact name.

Example

...
var ignoredTestsContent = contents.findByName("zebra.IgnoredTests");
var ignoredTests = JSON.parse(ignoredTestsContent.content);
...

Parameter name (required)

The exact name of a content in the database.

content[] contents.findByRegex(reg, [options])

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.

Example

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"]
});

Parameter reg:string (required)

The regular expression without the leading and trailing slashes.

Parameter options:object (optional)

content contents.findByUuid(uuid)

Retrieves a single JSMA content by uuid.

Example

...
contents.findByUuid('uuid'); // => content
...

Parameter uuid:string (required)

string contents.render(input)

Renders the given input String like a Widget.

Example

...
contents.render('# {some.macro}'); // => 'rendered representation'
...

Parameter input:string (required)