Skip to content

Conversation

@vladak
Copy link
Member

@vladak vladak commented Nov 22, 2021

This change makes it possible to configure bug/review links on per project level. Due to the way de-serialization of the Project objects works (setters are not called for unspecified properties), the getters have to be equipped with null checks and fall back to the global configuration. The code in completeWithDefaults() is used only when adding new projects in the indexer.

https://github.com/oracle/opengrok/wiki/Per-project-configuration will have to be updated.

Sample configuration:

<?xml version="1.0" encoding="UTF-8"?>
<java version="11.0.4" class="java.beans.XMLDecoder">
 <object class="org.opengrok.indexer.configuration.Configuration" id="Configuration0">

  <void property="projectsEnabled">
   <boolean>true</boolean>
  </void>

   <void property="projects">
     <void method="put">
      <string>one</string>
      <object class="org.opengrok.indexer.configuration.Project">
       <void property="handleRenamedFiles">
        <boolean>true</boolean>
       </void>
       <void property="historyEnabled">
        <boolean>true</boolean>
       </void>
       <void property="indexed">
        <boolean>true</boolean>
       </void>
       <void property="name">
        <string>one</string>
       </void>
       <void property="path">
        <string>/one</string>
       </void>
       <void property="bugPage">
        <string>http://example.com/foobar</string>
       </void>
       <void property="mergeCommitsEnabled">
        <boolean>false</boolean>
       </void>
      </object>
     </void>
   </void>

 </object>
</java>

@vladak vladak added the webapp web application label Nov 22, 2021
@vladak vladak merged commit 76b5929 into oracle:master Nov 22, 2021
@vladak vladak deleted the bug_review_conf_per_project branch November 22, 2021 15:30
@vladak
Copy link
Member Author

vladak commented Nov 22, 2021

When updating a configuration of a staging machine with the changes in order to set JDK bug links, I ran into an old issue with per project workflow (#2147). First thing I added the XML snippet with bugPage/bugPattern into read-only configuration and ran opengrok-projadm to merge it with the current configuration in the web app. This resulted in the Project objects disappearing from the configuration.

Luckily, thanks to the easily accessible ZFS snapshots (in the hidden by default .zfs directory) and the script wrapping opengrok-projadm that creates the snapshots whenever it is run, I was able to recover valid configuration quickly - otherwise I'd have to run the indexer for all projects.

When working with the per project workflow, the correct way is to modify the properties (once the project is added) like so:

curl -X PUT -d 'https://bugs.openjdk.java.net/browse/JDK-' http://localhost:8080/source/api/v1/projects/jdk8u/property/bugPage
curl -X PUT -d '([1-9][0-9]{6,7})' http://localhost:8080/source/api/v1/projects/jdk8u/property/bugPattern

and then grab the configuration from the web app and make it persistent while also putting project specific configuration to read-only configuration that would say:

  <!-- comment out after initial full reindex: https://github.com/oracle/opengrok/issues/2147 -->
  <!--
  <void property="projects">

     <void method="put">
      <string>jdk8u</string>
      <object class="org.opengrok.indexer.configuration.Project">
       <void property="bugPage">
        <string>https://bugs.openjdk.java.net/browse/JDK-</string>
       </void>
       <void property="bugPattern">
        <string>\b([1-9][0-9]{6,7})\b</string>
       </void>
      </object>
    </void>

  </void>
  -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

webapp web application

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants