The API changed significantly in Magnolia 4.5. The old CMS and CMS Utility tag libraries were also dropped. New cmsfn and stkfn templating support objects replace them. See Templating Proposal for example usage. The old JSP tags are in a JSP Templating module in case you need them.

These are the essential interfaces and classes in the Magnolia API. See also full API Javadoc.

Context

Context is an abstraction layer representing the environment of the current process which can be a request process, a scheduled task or a command execution in the workflow. The context provides access to the most important components such as hierarchy managers, current user, context attributes and parameters, response object and so on. The context is initialized at the beginning of each process. Context attributes will have a different meaning based on the environment. In case of a request, the attributes are request attributes and request parameters. Magnolia implements context using a thread-local class.

  • MgnlContext . This static helper class is the programmer's entry point to work with the current context.
    • getInstance() Returns the current context.
    • getUser() Returns the current user.
    • getJCRSession(String workspacename). Returns a JCR session to the provided workspace.
    • getAttribute(name) Returns a named context attribute. In case of a request, this can be a request parameter, request attribute or session attribute.
    • getWebContext() Returns the Web context if the current thread is processing a request.
    • getAggregationState().
  • WebContext . Context interface specialized for servlet requests; knows about HttpServletRequest and HttpServletResponse. Should be used as little as possible as it makes the calling code dependent on the servlet API. Use MgnlContext instead if possible.
    • getRequest() Returns the current servlet request object.
    • getResponse() Returns the current servlet response object.
  • UiContext . Represents a UI context and allows components, views and presenters to interact with the context that contains them.
  • AppContext . Provides functionality used by an app to interact with the Magnolia shell.

Aggregation state

  • AggregationState . Contains information about the current request and rendering process. It is mostly initialized by the Aggregator filter.
    • getOriginalURI() Original URI is the URI as requested by the client.
    • getCurrentURI() URI as mapped by Magnolia at a given point in processing. This value is for instance changed by the i18n filter, virtual URI mapping etc.
    • getMainContentNode() The content with which we start the rendering process. In general this is the page node.
    • getCurrentContentNode() The content that is processed at the moment. First this is typically the page, then a component and so on.

Session

  • Session  
    • getNode(java.lang.String absPath). Returns the node at the specified absolute path in the workspace.
    • getNodeByIdentifier(java.lang.String id) Returns the node specified by the given identifier.
    • save(). Validates all pending changes currently recorded in this Session.

Node

  • Node . Represents a node in the repository.
    • getNode(java.lang.String relPath).  Returns the node at relPath relative to this node.
    • getNodes() Returns all child nodes of this node accessible through the current Session.

    • getNodes(java.lang.String namePattern) Gets all child nodes of this node accessible through the current Session that match namePattern.

    • getProperty(java.lang.String relPath) Returns the property at relPath relative to this node.

    • setProperty(java.lang.String name, Value value) Sets the single-value property of this node called name to the specified value.

  • Property . A Property object represents the smallest granularity of content storage.
    • getLong()
    • getString()
    • getBinary()

Node types

  • Activatable
    • isActivated(javax.jcr.Node node) Returns true if the node has been activated.
  • Created
    • getCreated(javax.jcr.Node node) Returns the creation date of a node or null if creation date isn't set.

Module

  • ModuleRegistry . Holds instances and definitions of modules.

Templating

  • RenderingEngine . Entry point for the rendering.
    • render(javax.jcr.Node content, OutputProvider out) Renders the content with its assigned template.

    • render(javax.jcr.Node content, RenderableDefinition definition, Map<String,Object> contextObjects, OutputProvider out) Uses a specific RenderableDefinition to render the content and exposes the given context objects to the template script.

  • RenderableDefinition . Abstract rendering definition used for templates and components.
    • getName() Name of the template definition.
    • getRenderType() Defines the renderer to use. For instance JSP or Freemarker.
  • TemplateDefinition . A RenderableDefinition which supports editing in the page editor and can define their areas.
  • RenderingModel . The model used in the rendering process. It is instantiated for each rendering and ties the current content and rendering definition together. Concrete classes provide helper methods used in the template script. The execute method is executed before the rendering starts, a useful place to execute any business logic. The model is available in the template script under the named model.
    • getParent() Parent model. Most often the model of the page rendering.
    • getNode() The content node tied to this model.
    • getContent() Map representation of the content node tied to this model.
    • getDefinition() The renderable (template, area or component) tied to this model.

    • execute() Called after all properties were set.

  • Renderer . Responsible for generating the actual response from request data and a template. A typical JSP implementation will simply forward the request to the JSP through request dispatcher. You can bind a specific implementation to a template type.
    • render(RenderingContext ctx, Map<String,Object> contextObjects) Called by RenderingEngine after it has setup the RenderingContext.

  • RenderingContext . Provides all information needed in the rendering process.
  • ContentMap . Map based representation of JCR content. This class is used in template scripts to allow notations like content.<property name>. It first tries to read a property with name (key) and, if not present, checks for the presence of a child node. Special property names map to JCR methods:
    • @name
    • @id
    • @path
    • @level
    • @nodeType
  • TemplatingFunctions . An object that exposes methods useful for templates. The object is exposed to template scripts as cmsfn.
    • children(javax.jcr.Node content)
    • parent(javax.jcr.Node content)
    • isEditMode()
    • isPublicInstance()
    • language()
  • STKTemplatingFunctions . An object that exposes methods useful for STK templates.The object is exposed to template scripts as stkfn.
    • site()
    • theme()
    • siteRoot(javax.jcr.Node content)
    • getAsset(javax.jcr.Node content, String nodeDataPrefix)
    • getAssetLink(javax.jcr.Node content, String nodeDataPrefix, String variationName)
  • SiteNavigationModel . Component used in the rendering script (Freemarker, JSP) to display site navigation. Returned by STKTemplateModel.getNavigation().
  • NavigationItem . Element of a navigation tree. Used by STK navigation model.
  • SubNavigation . Navigation utility class. Used by navigationModel and navigationItem.
  • LinkUtil . Utility methods for link transformations and handling.
    • createLink(javax.jcr.Node node)
    • createAbsoluteLink(javax.jcr.Node node)
    • makePathRelative(String url, String absolutePath)
  • TemplateCategory Each template has a category like home, section or content.
  • Site Site configuration Java bean. Default site configuration merged with the user-defined site.
    • getI18n()
    • getTheme()
    • getVariations()

 

#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))
  • No labels