Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

PropertyConstraintException for 'scm create changeset'

When trying to create a changeset using the command line interface (scm) I got


com.ibm.team.repository.common.validation.PropertyConstraintException: Validation errors for item: type = ChangeSet, itemId = [UUID ...]
at com.ibm.team.scm.common.internal.util.ValidationUtils.checkPropertyConstraints(ValidationUtils.java:33)
at com.ibm.team.scm.service.internal.operations.CreateChangeSetOperation.run(CreateChangeSetOperation.java:70)
at com.ibm.team.scm.service.internal.ScmService$16.run(ScmService.java:794)
at com.ibm.team.scm.service.internal.AbstractScmService$3.run(AbstractScmService.java:574)
...


The comment for the changeset is auto-generated and long (1033 lines, 44538 characters). Could that be the reason for the exception? I have seen this exception several times and always long comments were involved. For short comments I have not seen the exception yet. Is there a limit to the length of change set comments? I could not find a documented limit so far, but I might have looked in the wrong places.

Thanks,

Daniel

0 votes



3 answers

Permanent link
Well, I suppose that Java code won't really help for the command line, but at least I can confirm that would be why you can't save a change set.

But here's a non-internal way on how to truncate it yourself the Java way:


...
String shorterComment = truncate(IChangeSet.ITEM_TYPE, IChangeSet.COMMENT_PROPERTY, longComment);


public static String truncate(IType type, String propertyName, String value) {
if (value == null)
return value;
IStatus status= IItemValidator.INSTANCE.validateAttribute(type, propertyName, value);
if (status instanceof IStringSizeConstraintErrorStatus) {
long maxSize= ((IStringSizeConstraintErrorStatus) status).getMaxSize();
//max size is in number of bytes and substring is in number of characters.
//First do a rough truncation so truncate to maxBytes. i.e. #chars >= #bytes >= maxSize.
String truncated= value.substring(0, (int) Math.min(value.length(), maxSize));
//Here, #chars may be <maxSize> maxSize.
//incrementally cut down the length of the string until #bytes <maxSize> 0 && status instanceof IStringSizeConstraintErrorStatus);

return truncated;
}
return value;
}

private static String endAtWordBoundary(String string) {
int space= string.lastIndexOf(' ');
if (space > 0)
return string.substring(0, space);
if (string.length() > 1)
return string.substring(0, string.length() - 1);
return "";
}

1 vote


Permanent link
...The comment for the changeset is auto-generated and long (1033 lines, 44538 characters).
...
Thanks,

Daniel


Yes, that is the issue. I don't recall offhand what the max byte size is for the change set comment property, but you can use this helper method to provide you with the longest possible comment that is valid (it will only truncate if it needs to)

String shorterComment = com.ibm.team.scm.common.internal.util.ValidationUtils.truncate(IChangeSet.ITEM_TYPE, IChangeSet.COMMENT_PROPERTY, longComment);

0 votes


Permanent link
Thanks a lot! That was very helpful. I used your code snippet to figure out that the maximum length for a comment on my RTC instance is 32768 characters. I can now use this limit to trim my comments for the command line interface.

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,952

Question asked: Mar 28 '12, 11:40 a.m.

Question was seen: 5,769 times

Last updated: Dec 10 '12, 3:21 a.m.

Confirmation Cancel Confirm