Manages tags in Content Services.

Class members

Methods

  • addTag(nodeId: string, tagName: string): Observable<TagEntry>
    Adds a tag to a node.
    • nodeId: string - ID of the target node
    • tagName: string - Name of the tag to add
    • Returns Observable<TagEntry> - TagEntry object (defined in JS-API) with details of the new tag
  • assignTagsToNode(nodeId: string, tags: TagBody[]): Observable<TagPaging|TagEntry>
    Assign tags to node. If tag is new then tag is also created additionally, if tag already exists then it is just assigned.
    • nodeId: string - Id of node to which tags should be assigned.
    • tags: TagBody[] - List of tags to create and assign or just assign if they already exist.
    • Returns Observable<TagPaging|TagEntry> - Just linked tags to node or single tag if linked only one tag.
  • createTags(tags: TagBody[]): Observable<TagEntry[]>
    Creates tags.
  • deleteTag(tagId: string): Observable<void>
    Deletes a tag with tagId. This will cause the tag to be removed from all nodes. You must have admin rights to delete a tag.
    • tagId: string - of the tag to be deleted
    • Returns Observable<void> - Null object when the operation completes
  • findTagByName(name: string): Observable<TagEntry>
    Find tag which name matches exactly to passed name.
    • name: string - Value for name which should be used during finding exact tag.
    • Returns Observable<TagEntry> - Found tag which name matches exactly to passed name.
  • getAllTheTags(opts?: any, includedCounts?: boolean): Observable<TagPaging>
    Gets a list of all the tags already defined in the repository.
    • opts: any - (Optional) Options supported by JS-API
    • includedCounts: boolean - (Optional) True if count field should be included in response object for each tag, false otherwise.
    • Returns Observable<TagPaging> - TagPaging object (defined in JS-API) containing the tags
  • getTagsByNodeId(nodeId: string): Observable<TagPaging>
    Gets a list of tags added to a node.
    • nodeId: string - ID of the target node
    • Returns Observable<TagPaging> - TagPaging object (defined in JS-API) containing the tags
  • removeTag(nodeId: string, tag: string): Observable<void>
    Removes a tag from a node.
    • nodeId: string - ID of the target node
    • tag: string - Name of the tag to remove
    • Returns Observable<void> - Null object when the operation completes
  • searchTags(name: string, sorting: Function = { orderBy: 'tag', direction: 'asc' }, includedCounts?: boolean, skipCount: number = 0, maxItems?: number): Observable<TagPaging>
    Find tags which name contains searched name.
    • name: string - Value for name which should be used during searching tags.
    • sorting: Function - Object which configures sorting. OrderBy field specifies field used for sorting, direction specified ascending or descending direction. Default sorting is ascending by tag field.
    • includedCounts: boolean - (Optional) True if count field should be included in response object for each tag, false otherwise.
    • skipCount: number - Specify how many first results should be skipped. Default 0.
    • maxItems: number - (Optional) Specify max number of returned tags. Default is specified by UserPreferencesService.
    • Returns Observable<TagPaging> - Found tags which name contains searched name.
  • updateTag(tagId: string, tagBody: TagBody): Observable<TagEntry>
    Update a tag
    • tagId: string - The identifier of a tag.
    • tagBody: TagBody - The updated tag.
    • Returns Observable<TagEntry> - Updated tag.

Details

Content Services supports tagging of file and folder nodes to assist with searches. A tag is a short text string added to an item, rather like a hashtag in social media.

Usually, it is wise to let the user see a list of existing tags and let them choose one by clicking. If they type a tag name with incorrect spelling then it will be treated as a new tag, even though that was not intended. Use getAllTheTags to find all tags in the repository when you need to construct a list like this.

See the Tags API in the Alfresco JS API for more information about the types returned by Tag service methods and for the implementation of the REST API the service is based on.

See also

© 2023 Alfresco Software, Inc. All Rights Reserved.