Tagging assets programmatically

Avatar

Avatar
Validate 10
Level 1
vishalv75424481
Level 1

Likes

0 likes

Total Posts

26 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
View profile

Avatar
Validate 10
Level 1
vishalv75424481
Level 1

Likes

0 likes

Total Posts

26 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
View profile
vishalv75424481
Level 1

15-10-2015

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.

View Entire Topic

Avatar

Avatar
Validate 10
Level 1
vishalv75424481
Level 1

Likes

0 likes

Total Posts

26 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
View profile

Avatar
Validate 10
Level 1
vishalv75424481
Level 1

Likes

0 likes

Total Posts

26 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
View profile
vishalv75424481
Level 1

15-10-2015

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....