Unable to Remove Tags and Categories With Local Staging in Portal 6.2

Since the release of Liferay Portal 6.2 users have been able to publish the deletion of major entities. This includes the removal of Web Content Articles, Documents and Media files, etc. However, for Tags and Categories, Staging in Liferay 6.2 offers limited support only, which means that deleting them is not supported. With Remote Staging this is not a significant issue, as users can manually remove them from the Live Site, but with Local Staging, users don't have direct control over the content in Live.

Steps to Reproduce

  1. Create a Site with a single page.
  2. Enable Local Staging on your Site.
  3. In Site Administration, create a Vocabulary.
  4. Create two Categories.
  5. Create two Tags.
  6. Create a Web Content Article, and in the "Categorization" tab, select all Categories and Tags.
  7. Place a Tags Navigation and a Categories Navigation portlet on your page.
  8. Check that your Categories and Tags appear in the portlets.
  9. Publish to Live with default settings.
  10. Check that your Categories and Tags are also present on the Live Site.
  11. Remove a Tag and a Category from the Staging Site.
  12. Publish to Live with default settings.
  13. Check the Tags and Categories on the Live Site again.

Result

The Live Site still contains both Categories and both Tags.

Resolution

If you need to delete the categorization in a particular asset (Tags or Categories), you could delete this relation from Live by editing the asset in Staging and publishing the new version.

If you need to remove a Tag or Category completely, you can use the attached Groovy scripts below to search and remove it. By default the script will only search for the entity to confirm that it exists, but once it is found, you can repeat the execution after changing the script to safeMode=false. This way the searched Tag or Category with related Subcategories will be deleted from Live.​

To use any of the scripts you need to customize the value of the next variables inside it:

  • String siteName = "Guest"; Name of the Site in which the Tag or Category was created.
  • long companyId = 12345; Instance ID of the Company where the Site was created, you can get it from Control Panel > Configuration > Portal instances
  • (For Categories) String categoryName = "Test Category"; Name of the Category that you want to delete.
  • (For Categories) String vocabularyName = "Topic"; Name of the Vocabulary in where the Category was created.
  • (For Tags) String tagName = "tag 1"; Name of the Tag that you want to delete.
  • def safeMode = true; True value doesn't delete the Category, only displays it. The Category will be deleted if you execute the script again with false value.

To execute the script, navigate toControl Panel > Configuration > Server Administration > Script, set the language to groovy, and execute the script.

Additional Information

See attachments below.

In the next Liferay Portal release, users will be able to publish the removal of Tags and Categories as well: LPS-55909.

这篇文章有帮助吗?
0 人中有 0 人觉得有帮助