It's all about the answers!

Ask a question

Problem in checkin unresolved file in Changeset.


vikas v (15419) | asked Mar 09 '16, 3:40 a.m.
edited Mar 11 '16, 3:30 a.m. by Ralph Schoon (63.3k33646)
Hello,

   Want to checkin new or Updated file(present in Unresolved) into changeset using plain java api.

  i have wrote the following code for checkin file but it is now working for me.
  IFileItem fileItem = null;
        if(localChange.getTargetParent() != null) {
            fileItem = (IFileItem) IFileItem.ITEM_TYPE.createItem();
            fileItem.setParent(localChange.getTargetParent());
        } else {
            fileItem = (IFileItem) workspaceConnection.configuration(changeSet.getComponent())
                             .fetchPartialItem(localChange.getTarget(), null, null);
            fileItem = (IFileItem)fileItem.getWorkingCopy();
           
        }
        File testFile= new File(localChange.getPath().toString() );   
        fileItem.setName(testFile.getName());
       
                           
        FileLineDelimiter delimiter = FileLineDelimiter.LINE_DELIMITER_NONE;
        IFileContentManager contentManager = FileSystemCore.getContentManager(teamRepository);      
         
        byte[] byteArray = new byte[(int) testFile.length()];
        IFileContent storedContent = contentManager.storeContent(
                IFileContent.ENCODING_US_ASCII, delimiter,
                new VersionedContentManagerByteArrayInputStreamPovider(byteArray),null, null);

        fileItem.setContentType(IFileItem.CONTENT_TYPE_TEXT);
        fileItem.setContent(storedContent);
        fileItem.setFileTimestamp(new Date());
 
        // commit the change to workspace
        workspaceConnection.commit(changeSet ,
            Collections.singletonList(workspaceConnection.configurationOpFactory()
                .save(fileItem)), null);
        }

when i am running the following code, Unresolved file is added into change set but content remain same as old one.
 Please let me know whether i am going in right way? or some alternate step i have to take

Thanks in advance!!

Regards,
Vikas

2 answers



permanent link
Atul Kumar (1872329) | answered Mar 09 '16, 4:58 a.m.
Not sure, if refreshing the change-set after checking-in would help?

Comments
vikas v commented Mar 09 '16, 5:21 a.m.

After refreshing also, its not working.
Actually when i am adding file into changeset, file got added but content remain same as old(means changes not reflection into changeset)


permanent link
Ralph Schoon (63.3k33646) | answered Mar 09 '16, 5:38 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
My working code can be found here: https://rsjazz.wordpress.com/2013/10/15/extracting-an-archive-into-jazz-scm-using-the-plain-java-client-libraries/

Comments
vikas v commented Mar 11 '16, 2:08 a.m.

Hello,
  Thanks for info
  I done changes  according to your code, still files are visible in Unresolved state.

 In changeset file got added and also changes  but still it is visible in Unresolved state and even component goes "OUT OF SYNC".
 
Please let me know do you have any idea why it is happing..

Thanks and Regards,
Vikas
 


Ralph Schoon commented Mar 11 '16, 2:53 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Your description indicates that you use the API while being within the RTC Eclipse client or while the workspace is loaded otherwise. Please note, that a repository workspace is only supposed to be loaded and modified by one user. A repository workspace is not supposed to be modified by multiple users and loaded into different locations.


vikas v commented Mar 14 '16, 4:46 a.m.

Thanks for your suggestion.

Actually i am developing plain java application.
I have created one workspace with the help of eclipse client an load the project.
and then from my plain java application i have create the workspace connection of the loaded workspace with the help of Api client(which is running in some other workspace)  and trying to do following operation like Adding file in Change Set etc,

what i got to know with your comment like creating connection with the workspace help of Api client which was previously used by eclipse client for loading project,
Out of sync issue is due to this, am i right?

Please let me know if you have any work around for my use-case.

Thanks In advance!!

 

 


Ralph Schoon commented Mar 14 '16, 5:37 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Yes, the way you use the workspace causes these issues. First of all, whatever Eclipse shows (e.g. as unresolved) will be incorrect if you use the plain java API against the workspace loaded in Eclipse. Secondly, having it used from two sources (Eclipse/Plain Java) causes it to go out of sync.

I am not sure what you try to achieve, but https://rsjazz.wordpress.com/2013/10/15/extracting-an-archive-into-jazz-scm-using-the-plain-java-client-libraries/ shows a legal use case, in which case the data is actually stored in a zip file and not uncompressed on disk. It would be possible to uncompress on disk first and that would be pretty much your case. It would also possible to use the SCM commandline for this and avoid the whole plain java API.   

Your answer


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