It's all about the answers!

Ask a question

how to get after state name

silencehill wu (5022532) | asked Nov 13 '12, 10:20 a.m.

Now I am writing a server precondition using RTC-SDK.

When a source file renamed to the other name, I want to get it new name.

For example, a source file was named to, and then deliver the change to the stream.

So In my server deliver precondition trigger, how can I use IChange to get the name?

I have try below source:

//I found RENAME value is 4, but change.kind()  get 6, so I assume change.kind()= MODIFIED(2) + RENAME(4) = 6, and

// the rename kind will get in the if condition statement.

if (change.kind() == IChange.MODIFIED || change.kind() == (IChange.MODIFIED + IChange.RENAME)) {
     IVersionableHandle versionableHandle = change.afterState();
     ServiceConfigurationProvider configProvider = ServiceConfigurationProvider.FACTORY.create(
       data.getDestWorkspace(), changeSet.getComponent());
     IVersionable item = (IVersionable) scmService.fetchState(versionableHandle, null, null);
     IAncestorReport reports[] = scmService.configurationLocateAncestors(
       configProvider, new IVersionableHandle[] {versionableHandle}, null, null);

    String path = toFullPath(item, reports[0].getNameItemPairs()) 

     IAdvisorInfo info = collector.createProblemInfo(
       "Deliver of rename or modified  files is prohibited",
       "The file " + toFullPath(item, reports[0].getNameItemPairs()) + " is not allowed to be modified or deleted.",

private String toFullPath(IVersionable versionable, List<INameItemPair> segments) {
        StringBuffer path = new StringBuffer();
        if(segments.isEmpty()) {
         return versionable.getName();
        for (INameItemPair nameItemPair : segments) {
         if(path.length() != 0) {
         // ignore the root folder which doesn't have a name
         if(nameItemPair.getName() != null)
        return path.toString();

question 1:

I found whatever I used  versionableHandle = change.afterState(); or change.beforeState(), the path always return to me, I do not know why. So, How can I get name?

question 2:

the function toFullPath only can get full path in MODIFIED and DELETED kind. If kind =ADD kind, segments.isEmpty()) will be true, so full path can not be get when ADD kind. So, How can I get Test2 or Test3 full path?

This two question confuse me so long! Please give me some advise.

silencehill wu commented Nov 13 '12, 10:28 a.m.

For question 2 addition:

 for example, path is 

  In actual, I can get  when kind = DELETE or MODIFED. But when kind= ADD, I only get  So how I can get when kind = ADD

Jia Jia Li commented Nov 13 '12, 10:35 a.m.

I have asked the same question here question


Be the first one to answer this question!

Register or to post your answer.