Forum Discussion

kaushal_1's avatar
kaushal_1
New Contributor
12 years ago

Path of the file uploaded in the server (for static analysis)

Hi,

I am trying to integrate the static analysis with CodeCollaborator. In sequence of this i have written a trigger which gets executed when a review is created. This trigger will invoke PMD, with intention to do a static analysis of the file (which is uploaded for review). I would like to know if there is a mechanism to figure out the path of the file which got uploaded. 

While checking the internal structure i found that the files got uploaded under "CodeCollaborator Server\tomcat\collaborator-content-cache\...", but with some wage name like "2353b70deb259e6b72f04de0d0a3b476".



Can you please suggest how can we achieve this, is there any API which we can use. 



Regards,

Kaushal

2 Replies

  • Hi,



    To answer your question, you can find this path using the md5 of the file that you just uploaded. One way to retrieve the md5 from code collaborator is using the review-xml command, with the --xpath //artifact option to just retrieve the uploaded artifacts for the review:



    ccollab admin review-xml <review-id> --xpath //artifact



    You will get an output like this:



    <artifact changelistId="1" changelistScmId="" lines="644" lines-added="11" lines-changed="0" lines-deleted="0" versionId="10">

                    <path>path/to/file/in/review</path>

                    <md5sum>21c25ec1efd7fb9f1e24168cdaf55e05</md5sum>

                    <change-type>M</change-type>

                    <scmVersion>c7a568c</scmVersion>

                    <scm config-a="diffs" config-b="scm-system" id="3" type="none"/>

                    <prev-path>prev/path/to/file/in/review</prev-path>

                    <prev-md5sum>b100599b9c4aa8e3ecb5ab8e6e514b6e</prev-md5sum>

                    <prev-change-type>M</prev-change-type>

                    <prev-scmVersion>a7a0bb6</prev-scmVersion>

                    <num-comments>0</num-comments>

                    <num-defects>0</num-defects>

    </artifact>



    Then you can use the md5sum matching the original file path (in <path>) to locate the file in your file system. You will need to use a command line tool in order to find it (such as find in linux, or dir in Windows), as it might be under several subdirectories.



    But, if you really want the file content you can simply use the versionId and call:



    ccollab admin wget /data/server?versionid=<version id>



    In the example above you can do



    ccollab admin wget /data/server?versionid=10



    And that should retrieve the contents of that file.



    These commands are described here: http://support.smartbear.com/viewarticle/25602/



    Let us know if you have additional questions,



    Luis Luna

    SmartBear Software

    Technical Support






  • kaushal_1's avatar
    kaushal_1
    New Contributor
    Hi,



    We used the "wget" command to fetch the files (for a particular reviewId "ccollab admin wget /data/server?versionid=<version
    id>"), exactly as suggested by Luis Luna, and it worked for us.

    It seems that we can utilize "wget" for a lot of different things (while working on command line ccollab), so it will be nice if you could improve the documentation (http://support.smartbear.com/viewarticle/25602/) for this (with more sample usage).



    I appreciate the help.



    Regards,

    Kaushal