contentbox.models.content

Class ContentService

lucee.Component
    extended by cborm.models.BaseORMService
      extended by cborm.models.VirtualEntityService
        extended by contentbox.models.content.ContentService
Direct Known Subclasses:
ContentStoreService , EntryService , PageService

ContentBox - A Modular Content Platform Copyright since 2012 by Ortus Solutions, Corp www.ortussolutions.com/products/contentbox --- A generic content service for content objects

Class Attributes:
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : false
  •  
  • persistent : false
  •  
    Property Summary
    type property default serializable required
    any asyncManager


    • access = public
    • returntype = any
    • inject = coldbox:asyncManager
    true false
    any authorService


    • access = public
    • returntype = any
    • inject = authorService@contentbox
    true false
    any cacheBox


    • access = public
    • returntype = any
    • inject = cachebox
    true false
    any categoryService


    • access = public
    • returntype = any
    • inject = categoryService@contentbox
    true false
    any commentService


    • access = public
    • returntype = any
    • inject = commentService@contentbox
    true false
    any commentSubscriptionService


    • access = public
    • returntype = any
    • inject = CommentSubscriptionService@contentbox
    true false
    any contentStoreService


    • access = public
    • returntype = any
    • inject = contentStoreService@contentbox
    true false
    any contentVersionService


    • access = public
    • returntype = any
    • inject = contentVersionService@contentbox
    true false
    any customFieldService


    • access = public
    • returntype = any
    • inject = customFieldService@contentbox
    true false
    any dateUtil


    • access = public
    • returntype = any
    • inject = DateUtil@contentbox
    true false
    any entryService


    • access = public
    • returntype = any
    • inject = entryService@contentbox
    true false
    any log


    • access = public
    • returntype = any
    • inject = logbox:logger:{this}
    true false
    any pageService


    • access = public
    • returntype = any
    • inject = pageService@contentbox
    true false
    any relocationService


    • access = public
    • returntype = any
    • inject = RelocationService@contentbox
    true false
    any settingService


    • access = public
    • returntype = any
    • inject = id:settingService@contentbox
    true false
    any statsService


    • access = public
    • returntype = any
    • inject = statsService@contentbox
    true false
    any subscriberService


    • access = public
    • returntype = any
    • inject = subscriberService@contentbox
    true false
    any systemUtil


    • access = public
    • returntype = any
    • inject = SystemUtil@contentbox
    true false
    Constructor Summary
    init([any entityName='cbContent'])
          Constructor.
    Method Summary
    any addRelocation(BaseContent contentItem, string originalSlug)
         Adds a relocation for a content item.
    any bulkPublishStatus(any contentID, any status)
         Bulk Publish Status Updates.
    ContentService clearAllCaches([boolean async='false'])
         Clear all content caches.
    ContentService clearAllCategoryCountCaches([boolean async='false'])
         Clear all category content counts caches.
    ContentService clearAllPageWrapperCaches([boolean async='false'])
         Clear all page wrapper caches.
    ContentService clearAllSitemapCaches([boolean async='false'])
         Clear all sitemap caches.
    ContentService clearPageWrapper(any slug, [boolean async='false'])
         Clear a page wrapper cache for a specific content object.
    ContentService clearPageWrapperCaches(any slug, [boolean async='false'])
         Clear a specific page wrapper caches according to slug prefix.
    ContentService delete(any content)
         Delete a content object safely via hierarchies.
    any findBySlug(any slug, boolean showUnpublished='false', [string siteID=''])
         Find a published content object by slug and published unpublished flags, if not found it returns.
    array findExpiredContent([any author], [numeric max='0'], [numeric offset='0'], [string siteID=''])
         Get all the expired content in the system by filters.
    array findFuturePublishedContent([any author], [numeric max='0'], [numeric offset='0'], [string siteID=''])
         Get all the future published content in the system by filters.
    any findPublishedContent([numeric max='0'], [numeric offset='0'], [any searchTerm=''], [any category=''], [boolean asQuery='false'], [string sortOrder='publishedDate DESC'], [any parent], [string slugPrefix=''], [string siteID=''], [string properties], [string authorID=''], [any criteria], [string slugSearch=''])
         Find published content objects by different filters and output formats.
    array getAllFlatContent([any sortOrder='title asc'], [boolean isPublished], [boolean showInSearch], [string siteID=''], [string contentType=''])
         Returns an array of [contentID, title, slug, createdDate, modifiedDate] structures of all the content in the system.
    array getAllFlatSlugs()
         Returns an array of slugs of all the content objects in the system.
    array getAllForExport([any inData])
         Get all content for export as flat data.
    any getByIdOrSlugOrFail(any id)
         This utility tries to get the content type by id/slug or fails.
    any getIdBySlug(any slug, [string siteID=''])
         Get an id from a slug of a content object.
    array getLatestEdits([any author], [boolean isPublished], [numeric max='25'], [string siteID=''])
         Get latest edits according to criteria.
    private any getServiceByType(any type)
         Get the appropriate service by passed content type.
    array getTopCommentedContent([numeric max='5'], [string siteID=''])
         Get the top commented content entries.
    array getTopVisitedContent([numeric max='5'], [string siteID=''])
         Get the top visited content entries.
    numeric getTotalContentCount([any siteID=''], [any categoryId=''])
         Get the total content counts according to the passed filters.
    private any getUniqueSlugHash(string slug)
         Get a unique slug hash.
    string importFromData(any importData, [boolean override='false'], any importLog, [any site])
         Import data from an array of structures or a single structure of data.
    string importFromFile(any importFile, [boolean override='false'])
         Import data from a ContentBox JSON file.
    any importFromStruct(any contentData, any importLog, [any parent], [struct newContent='[runtime expression]'], any site, [boolean override='false'])
         Import a content object from a ContentBox JSON structure.
    boolean isSlugUnique(any slug, [any contentID=''], [string siteID=''], [string contentType=''])
         Verify an incoming slug is unique or not.
    any searchContent([any searchTerm=''], [numeric max='0'], [numeric offset='0'], [boolean asQuery='false'], [any sortOrder='publishedDate DESC'], [any isPublished='true'], [boolean searchActiveContent='true'], [string contentTypes=''], [any excludeIDs=''], [boolean showInSearch], [string siteID=''], [string propertyList])
         Searches published content with cool paramters, remember published content only.
    ContentService updateHits(any content, [boolean async='true'])
         Update a content's hits with some async flava.
     
    Methods inherited from class cborm.models.VirtualEntityService
    autoCast, convertIdValueToJavaType, convertValueToJavaType, count, countWhere, deleteAll, deleteByID, deleteByQuery, deleteWhere, evictCollection, executeQuery, exists, findAllWhere, findWhere, get, getAll, getEntityName, getKey, getOrFail, getPropertyNames, getTableName, idCast, list, new, newCriteria, onMissingMethod, setEntityName
     
    Methods inherited from class cborm.models.BaseORMService
    $transactioned, buildJavaProxy, clear, createService, evict, evictQueries, findAll, findByExample, findIt, findOrFail, getBeanPopulator, getDatasource, getDefaultAsQuery, getDirtyPropertyNames, getDynamicProcessor, getEntityGivenName, getEntityMetadata, getEventHandling, getKeyValue, getLogger, getORMEventHandler, getObjectPopulator, getOrm, getPropertyValues, getQueryCacheRegion, getRestrictions, getSessionStatistics, getStringBuilder, getUseQueryCaching, getUseTransactions, getWirebox, isDirty, isSessionDirty, merge, nullValue, populate, populateFromJson, populateFromQuery, populateFromXml, populateWithPrefix, refresh, save, saveAll, sessionContains, setDatasource, setDefaultAsQuery, setEventHandling, setLogger, setORM, setORMEventHandler, setQueryCacheRegion, setUseQueryCaching, setUseTransactions, setWirebox, when
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init([any entityName='cbContent'])

    Constructor

    Parameters:
    entityName - The content entity name to bind this service to.

    Property Detail

    asyncManager

    property any asyncManager

    Attributes:
    access - public
    required - false
    returntype - any
    inject - coldbox:asyncManager
    serializable - true

    authorService

    property any authorService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - authorService@contentbox
    serializable - true

    cacheBox

    property any cacheBox

    Attributes:
    access - public
    required - false
    returntype - any
    inject - cachebox
    serializable - true

    categoryService

    property any categoryService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - categoryService@contentbox
    serializable - true

    commentService

    property any commentService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - commentService@contentbox
    serializable - true

    commentSubscriptionService

    property any commentSubscriptionService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - CommentSubscriptionService@contentbox
    serializable - true

    contentStoreService

    property any contentStoreService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - contentStoreService@contentbox
    serializable - true

    contentVersionService

    property any contentVersionService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - contentVersionService@contentbox
    serializable - true

    customFieldService

    property any customFieldService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - customFieldService@contentbox
    serializable - true

    dateUtil

    property any dateUtil

    Attributes:
    access - public
    required - false
    returntype - any
    inject - DateUtil@contentbox
    serializable - true

    entryService

    property any entryService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - entryService@contentbox
    serializable - true

    log

    property any log

    Attributes:
    access - public
    required - false
    returntype - any
    inject - logbox:logger:{this}
    serializable - true

    pageService

    property any pageService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - pageService@contentbox
    serializable - true

    relocationService

    property any relocationService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - RelocationService@contentbox
    serializable - true

    settingService

    property any settingService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - id:settingService@contentbox
    serializable - true

    statsService

    property any statsService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - statsService@contentbox
    serializable - true

    subscriberService

    property any subscriberService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - subscriberService@contentbox
    serializable - true

    systemUtil

    property any systemUtil

    Attributes:
    access - public
    required - false
    returntype - any
    inject - SystemUtil@contentbox
    serializable - true

    Method Detail

    addRelocation

    public any addRelocation(BaseContent contentItem, string originalSlug)

    Adds a relocation for a content item

    Parameters:
    contentItem - the target to relocate to
    originalSlug - the URI from which to redirect

    bulkPublishStatus

    public any bulkPublishStatus(any contentID, any status)

    Bulk Publish Status Updates

    Parameters:
    contentID - The list or array of ID's to bulk update
    status - The status either 'publish' or 'draft'

    clearAllCaches

    public ContentService clearAllCaches([boolean async='false'])

    Clear all content caches

    Parameters:
    async - Run it asynchronously or not, defaults to false

    clearAllCategoryCountCaches

    public ContentService clearAllCategoryCountCaches([boolean async='false'])

    Clear all category content counts caches

    Parameters:
    async - Run it asynchronously or not, defaults to false

    clearAllPageWrapperCaches

    public ContentService clearAllPageWrapperCaches([boolean async='false'])

    Clear all page wrapper caches

    Parameters:
    async - Run it asynchronously or not, defaults to false

    clearAllSitemapCaches

    public ContentService clearAllSitemapCaches([boolean async='false'])

    Clear all sitemap caches

    Parameters:
    async - Run it asynchronously or not, defaults to false

    clearPageWrapper

    public ContentService clearPageWrapper(any slug, [boolean async='false'])

    Clear a page wrapper cache for a specific content object

    Parameters:
    slug - The slug to clear
    async - Run it asynchronously or not, defaults to false

    clearPageWrapperCaches

    public ContentService clearPageWrapperCaches(any slug, [boolean async='false'])

    Clear a specific page wrapper caches according to slug prefix

    Parameters:
    slug - The slug partial to clean on
    async - Run it asynchronously or not, defaults to false

    delete

    public ContentService delete(any content)

    Delete a content object safely via hierarchies

    Overrides:
    delete in class cborm.models.BaseORMService
    Parameters:
    content - the Content object to delete

    findBySlug

    public any findBySlug(any slug, boolean showUnpublished='false', [string siteID=''])

    Find a published content object by slug and published unpublished flags, if not found it returns a new content object

    Parameters:
    slug - The slug to search
    showUnpublished - To also show unpublished content, defaults to false.
    siteID - The site this slug belongs to
    Returns:
    The content object or a new unpersisted content object

    findExpiredContent

    public array findExpiredContent([any author], [numeric max='0'], [numeric offset='0'], [string siteID=''])

    Get all the expired content in the system by filters

    Parameters:
    author - The author filtering if passed.
    max - The maximum number of records to return
    offset - The pagination offset
    siteID - The site to filter on

    findFuturePublishedContent

    public array findFuturePublishedContent([any author], [numeric max='0'], [numeric offset='0'], [string siteID=''])

    Get all the future published content in the system by filters

    Parameters:
    author - The author filtering if passed.
    max - The maximum number of records to return
    offset - The pagination offset
    siteID - The site to filter on

    findPublishedContent

    public any findPublishedContent([numeric max='0'], [numeric offset='0'], [any searchTerm=''], [any category=''], [boolean asQuery='false'], [string sortOrder='publishedDate DESC'], [any parent], [string slugPrefix=''], [string siteID=''], [string properties], [string authorID=''], [any criteria], [string slugSearch=''])

    Find published content objects by different filters and output formats

    Parameters:
    max - The maximum number of records to paginate
    offset - The offset in the pagination
    searchTerm - The search term to search
    category - The category to filter the content on
    asQuery - Return as query or array of objects, defaults to array of objects
    sortOrder - how we need to sort the results
    parent - The parentID or parent entity to filter on, don't pass or pass an empty value to ignore, defaults to 'all'
    slugPrefix - If passed, this will do a hierarchical search according to this slug prefix. Remember that all hierarchical content's slug field contains its hierarchy: /products/awesome/product1. This prefix will be appended with a `/`
    siteID - If passed, filter by site id
    properties - The list of properties to project on instead of giving you full object graphs
    authorID - The authorID to filter on
    criteria - The criteria object to use if passed, else we create a new one.
    slugSearch - If passed, we will search for content items with this field as a full text search on slugs
    Returns:
    struct as { count, content }

    getAllFlatContent

    public array getAllFlatContent([any sortOrder='title asc'], [boolean isPublished], [boolean showInSearch], [string siteID=''], [string contentType=''])

    Returns an array of [contentID, title, slug, createdDate, modifiedDate] structures of all the content in the system

    Parameters:
    sortOrder - The sort ordering of the results
    isPublished - Show all content or true/false published content
    showInSearch - Show all content or true/false showInSearch flag
    siteID - The site id to use to filter on
    contentType
    Returns:
    Array of content data {contentID, title, slug, createdDate, modifiedDate}

    getAllFlatSlugs

    public array getAllFlatSlugs()

    Returns an array of slugs of all the content objects in the system.


    getAllForExport

    public array getAllForExport([any inData])

    Get all content for export as flat data

    Parameters:
    inData - The data to use for exporting, usually concrete implementtions can override this.

    getByIdOrSlugOrFail

    public any getByIdOrSlugOrFail(any id)

    This utility tries to get the content type by id/slug or fails

    Parameters:
    id
    Returns:
    The found entity
    Throws:
    EntityNotFound

    getIdBySlug

    public any getIdBySlug(any slug, [string siteID=''])

    Get an id from a slug of a content object

    Parameters:
    slug - The slug to search an ID for.
    siteID - The site this slug belongs to
    Returns:
    The id of the content object or empty string if not found

    getLatestEdits

    public array getLatestEdits([any author], [boolean isPublished], [numeric max='25'], [string siteID=''])

    Get latest edits according to criteria

    Parameters:
    author - The author object to use for retrieval
    isPublished - If passed, check if content is published or in draft mode. Else defaults to all states
    max - The maximum number of records to return
    siteID - The site to get edits from

    getServiceByType

    private any getServiceByType(any type)

    Get the appropriate service by passed content type. If an invalid type is passed, we return ourselves

    Parameters:
    type - The content type to detect

    getTopCommentedContent

    public array getTopCommentedContent([numeric max='5'], [string siteID=''])

    Get the top commented content entries

    Parameters:
    max - The maximum to retrieve, defaults to 5 entries
    siteID - The site to filter on

    getTopVisitedContent

    public array getTopVisitedContent([numeric max='5'], [string siteID=''])

    Get the top visited content entries

    Parameters:
    max - The maximum to retrieve, defaults to 5 entries
    siteID - The site to filter on

    getTotalContentCount

    public numeric getTotalContentCount([any siteID=''], [any categoryId=''])

    Get the total content counts according to the passed filters

    Parameters:
    siteID - The site to filter on
    categoryId - The category Id to filter on

    getUniqueSlugHash

    private any getUniqueSlugHash(string slug)

    Get a unique slug hash

    Parameters:
    slug - The slug to unique it

    importFromData

    public string importFromData(any importData, [boolean override='false'], any importLog, [any site])

    Import data from an array of structures or a single structure of data

    Parameters:
    importData - A struct or array of data to import
    override - Override content if found in the database, defaults to false
    importLog - The import log buffer
    site - If passed, we use this specific site, else we discover it via content data
    Returns:
    The console log of the import

    importFromFile

    public string importFromFile(any importFile, [boolean override='false'])

    Import data from a ContentBox JSON file. Returns the import log

    Parameters:
    importFile - The json file to import
    override - Override content if found in the database, defaults to false
    Returns:
    The console log of the import
    Throws:
    InvalidImportFormat

    importFromStruct

    public any importFromStruct(any contentData, any importLog, [any parent], [struct newContent='[runtime expression]'], any site, [boolean override='false'])

    Import a content object from a ContentBox JSON structure

    Parameters:
    contentData - The content structure inflated from JSON
    importLog - The string builder import log
    parent - If the inflated content object has a parent then it can be linked directly, no inflating necessary. Usually for recursions
    newContent - Map of new content by slug; useful for avoiding new content collisions with recusive relationships
    site - The site we are using for the content
    override - Are we overriding persisted data or not?
    Returns:
    The content object representing the struct

    isSlugUnique

    public boolean isSlugUnique(any slug, [any contentID=''], [string siteID=''], [string contentType=''])

    Verify an incoming slug is unique or not

    Parameters:
    slug - The slug to search for uniqueness
    contentID - Limit the search to the passed contentID usually for updates
    siteID - The site to filter on
    contentType - The content type uniqueness
    Returns:
    True if the slug is unique or false if it's already used

    searchContent

    public any searchContent([any searchTerm=''], [numeric max='0'], [numeric offset='0'], [boolean asQuery='false'], [any sortOrder='publishedDate DESC'], [any isPublished='true'], [boolean searchActiveContent='true'], [string contentTypes=''], [any excludeIDs=''], [boolean showInSearch], [string siteID=''], [string propertyList])

    Searches published content with cool paramters, remember published content only

    Parameters:
    searchTerm - The search term to search
    max - The maximum number of records to paginate
    offset - The offset in the pagination
    asQuery - Return as query or array of objects, defaults to array of objects
    sortOrder - The sorting of the search results, defaults to publishedDate DESC
    isPublished - Search for published, non-published or both content objects [true, false, 'all']
    searchActiveContent - Search only content titles or both title and active content. Defaults to both.
    contentTypes - Limit search to list of content types (comma-delimited). Leave blank to search all content types
    excludeIDs - List of IDs to exclude from search
    showInSearch - If true, it makes sure content has been stored as searchable, defaults to null, which means it searches no matter what this bit says
    siteID - The site ID to filter on
    propertyList - A list of properties to retrieve as a projection instead of array of objects
    Returns:
    struct = { content, count }

    updateHits

    public ContentService updateHits(any content, [boolean async='true'])

    Update a content's hits with some async flava

    Parameters:
    content - A content object or id to update the hits on
    async - Async or not