It's all about the answers!

Ask a question

how to add an advisor on stream custom attribute modifications?


Nicolas Bros (295) | asked Aug 23 '21, 8:36 a.m.
Hello,

I am trying to code an operation advisor to detect modifications of custom attribute on a stream, in order to validate the custom property values and prevent saving the stream if invalid or forbidden values are added.

I have currently written the following advisor:
public class EIModifyStreamAdvisor extends AbstractService implements IOperationAdvisor {

    private static final Log LOGGER = LogFactory.getLog(EIModifyStreamAdvisor.class);
    private static final String PROBLEM_TYPE = "ei.rtcext.build.service.advisors.eiModifyStreamAdvisor";

    @Override
    public void run(final AdvisableOperation operation, final IProcessConfigurationElement advisorConfiguration, final IAdvisorInfoCollector collector,
            final IProgressMonitor monitor) throws TeamRepositoryException {

        // (...) test property (...)
        collector.addInfo(
                collector.createProblemInfo("Property must not be modified", "Property '" + propertyName + "' must not be changed manually", PROBLEM_TYPE));
    }
}

registered this advisor through the extension point:

   <extension point="com.ibm.team.process.service.operationAdvisors">
      <operationAdvisor
            class="ei.rtcext.build.service.advisors.EIModifyStreamAdvisor"
            id="ei.rtcext.build.service.advisors.eiModifyStreamAdvisor"
            name="[EI]Validate Modified Properties On Stream"
            operationId="com.ibm.team.scm.server.modifyStream">
         <description>
            [EI]Prevent stream save when properties have been wrongly modified.
         </description>
         <extensionService
               componentId="ei.rtcext.build"
               implementationClass="ei.rtcext.build.service.advisors.EIModifyStreamAdvisor">
            <prerequisites>
                <requiredService interface="com.ibm.team.scm.common.IScmService"/>
            </prerequisites>
         </extensionService>
      </operationAdvisor>
   </extension>
and added it to my process:
<operation final="true" id="com.ibm.team.scm.server.modifyStream">
  <preconditions>
    <precondition description="Prevent stream save when properties have been wrongly modified." id="ei.rtcext.build.service.advisors.eiModifyStreamAdvisor" name="[EI]Validate Modified Properties On Stream" optional="false"/>
  </preconditions>
</operation>
My advisor is called when modifying the stream name or description for example, but not when adding or changing a custom property.

I looked in com.ibm.team.scm.service.internal.ScmService#setWorkspaceCustomAttributes, and it seems to me that RTC directly modifies the custom attributes on the stream in a transaction without first calling preconditions or advisors.

Version: RTC 6.0.6.1


Comments
1
Geoffrey Clemm commented Aug 23 '21, 10:21 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

If you don't get a response on the forum, I'd suggest filing a defect with IBM support. 


1
Ralph Schoon commented Aug 23 '21, 10:33 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

it is absolutely possible that this is the case. If you need such kind of capabilities, I would suggest to create an enhancement. 

Be the first one to answer this question!


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.