Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

how to add an advisor on stream custom attribute modifications?

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

0 votes

Comments

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

1 vote

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

1 vote


Be the first one to answer this question!

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

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 11,081

Question asked: Aug 23 '21, 8:36 a.m.

Question was seen: 1,534 times

Last updated: Aug 23 '21, 10:33 a.m.

Confirmation Cancel Confirm