It's all about the answers!

Ask a question

Restricting access for adding file/folder in a particular level of directories under components & Streams


Sudaraazhi Arivalagan (441728) | asked Oct 14 '14, 5:31 a.m.

Hi Ralph,

Please help on the requirement.

I need to avoid user to add file/folder into second level of component under Streams.

Example:

  • Project-Area
    • Source Control
      • Stream 1
      • Stream 2
      • Stream 3
        • Component 1
        • Component 2
        • Component 3
          • Folder 1
            • File 1
            • File 2
          • Folder 2
            • File 1
            • File 2

I want to restrict user not to add file/folder under components, but they should have rights to add file / folder into next level.

Shall i do this using IVersionHandle or IAncestorReport?

Thanks !!!

Sudar

Accepted answer


permanent link
SEC Servizi (97123660) | answered Oct 14 '14, 6:31 a.m.
I think you should use both, and others as well:
IVersionHandle versionableH = ...
IWorkspaceHandle wksH = ...
IComponentHandle componentH = ...
ServiceConfigurationProvider configProvider = ServiceConfigurationProvider.FACTORY.create(wksH, componentH);
IAncestorReport[] reports = scmService.configurationLocateAncestors(configProvider, new IVersionableHandle[]{ versionableH }, null, IRepositoryProgressMonitor.ITEM_FACTORY.createItem(monitor));
List<INameItemPair> segments = reports[0].getNameItemPairs();
if (segments.size() != 3) { // segments[0] is for root folder and always null.
throw new TeamRepositoryException("You can only add files in to 2nd level folders");
}
Cheers.
Sudaraazhi Arivalagan selected this answer as the correct answer

Comments
Martin Dam Pedersen commented Oct 15 '14, 8:00 a.m.

 Instead of throwing an exception you should probably create a IAdvisorInfo:


IAdvisorInfo problem = collector.createProblemInfo( "You can only add files in to 2nd level folders","You can only add files in to 2nd level folders","advisor.reject");
collector.addInfo(problem);


SEC Servizi commented Oct 15 '14, 8:07 a.m.

Sure you can, though it depends on where that snippet will be used.


Martin Dam Pedersen commented Oct 15 '14, 8:26 a.m.
Of-course... I should have noted that if the snippet was to be used in an advisor then createProblemInfo would be advisable :-)


Sudaraazhi Arivalagan commented Oct 16 '14, 3:03 a.m.

Thank you Servizi !!!


Sudaraazhi Arivalagan commented Oct 16 '14, 8:24 a.m.

Thank you Martin !!

One other answer



permanent link
Martin Dam Pedersen (1352814) | answered Oct 15 '14, 7:53 a.m.
 Is this question a duplicate of https://jazz.net/forum/questions/165423/controlling-addition-of-files-in-the-second-level-directory-of-rtc-components ? 

Just answered that one again.

Comments
Sudaraazhi Arivalagan commented Oct 16 '14, 3:05 a.m.

Yes Martin, I just wanted to describe my requirement in different manner.

Thank you !!

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.