Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

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.

Accepted Solutions (0)

Answers (2)

Answers (2)

Avatar

Avatar
Boost 1
Level 1
ragulmsd
Level 1

Like

1 like

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
ragulmsd
Level 1

Like

1 like

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
ragulmsd
Level 1

09-10-2019

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

javax.jcr.nodetype.ConstraintViolationException: OakConstraint0027 error when migrating users and gr...

ConstraintViolationException (Content Repository for Java Technology API 1.0)

Happy Learning!

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