


I am trying to tag an asset programmatically but I get an exception.
TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
Tag tag = tagManager.resolve("/etc/tags/fppc/tag1");
Tag[] tags = {tag};
Resource assetResource = resourceResolver.getResource("/content/dam/fppc/Desert.jpg");
tagManager.setTags(assetResource, tags);
Caused by: java.lang.RuntimeException: error while setting tags for '/content/dam/fppc/Desert.jpg'
javax.jcr.nodetype.ConstraintViolationException: No matching property definition: cq:tags = [fppc:tag1]
I get the tag when I resolve it. I am also able to get the name of the tag by using tag.getName(). This exception is a bit confusing.
Any help is appreciated.
Views
Replies
Sign in to like this content
Total Likes
vishalv75424481 wrote...
I am trying to tag an asset programmatically but I get an exception.
TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
Tag tag = tagManager.resolve("/etc/tags/fppc/tag1");
Tag[] tags = {tag};
Resource assetResource = resourceResolver.getResource("/content/dam/fppc/Desert.jpg");
tagManager.setTags(assetResource, tags);
Caused by: java.lang.RuntimeException: error while setting tags for '/content/dam/fppc/Desert.jpg'
javax.jcr.nodetype.ConstraintViolationException: No matching property definition: cq:tags = [fppc:tag1]
I get the tag when I resolve it. I am also able to get the name of the tag by using tag.getName(). This exception is a bit confusing.
Any help is appreciated.
Some help please....
Views
Replies
Sign in to like this content
Total Likes
ConstraintViolation Exception is thrown when an action would violate a constraint on repository structure. For example, when an attempt is made to persistently add an item to a node that would violate that node's node type.
Refer these documents
ConstraintViolationException (Content Repository for Java Technology API 1.0)
Happy Learning!
Views
Replies
Sign in to like this content
Total Likes