[ https://issues.apache.org/jira/browse/SLING-10236?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17307258#comment-17307258 ]
Bertrand Delacretaz commented on SLING-10236: --------------------------------------------- I'm not sure why you need to recreate the original repoinit statements, is the goal to include them in error reports, or do you use them for validation? If it's for error reports, we might attach the original repoinit script to the list of Operations that the parser produces (maybe using a do-nothing operation for that purpose) and attach contextual information (input line and column numbers assuming javacc provides that info) to be able to generate meaningful error messages. I see that in SLING-10219 the goal is to allow only principal-based authorization. Another option for doing that might be to pass a set of options to the parser, to cause it to fail when certain statements are encountered. If you look at the [parser grammar|https://github.com/apache/sling-org-apache-sling-repoinit-parser/blob/master/src/main/javacc/RepoInitGrammar.jjt], it would be easy to cause some of the productions that are about ACLs (setAclPrincipals, setAclPrincipalBased, setAclPaths, setAclRepository) to fail based on options passed to the parser. I agree that recreating the original statements is not hard but it's extra code and I think the above options are much cleaner, what do you think? > Introduce Operation.asRepoInitString > ------------------------------------ > > Key: SLING-10236 > URL: https://issues.apache.org/jira/browse/SLING-10236 > Project: Sling > Issue Type: Improvement > Components: Repoinit > Reporter: Angela Schreiber > Priority: Major > Time Spent: 20m > Remaining Estimate: 0h > > for SLING-10219 (and maybe other use cases too) it would be great if > {{org.apache.sling.repoinit.parser.operations.Operation}} would come with a > {{asRepoInitString}} method that would allow to obtain the original repo-init > statements. > I was checking if {{toString}} would allow to extract that (with a bit of > extra effort) but unfortunately the default implementation is: > {code} > public String toString() { > return this.getClass().getSimpleName() + " " + > this.getParametersDescription(); > } > {code} > and {{getParametersDescription}} isn't implemented in a consistent way and in > some cases doesn't reveal all information needed. > further more even the {{toString}} method isn't consistent across the various > operation implementations (e.g. {{RegisterPrivilege.toString}} actually > coming close to the original statement and not including the simple class > name) -- This message was sent by Atlassian Jira (v8.3.4#803005)