karlpauls commented on a change in pull request #50: URL: https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/50#discussion_r556662870
########## File path: src/test/resources/org/apache/sling/feature/cpconverter/accesscontrol/asd/not/.content.xml ########## @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with this + work for additional information regarding copyright ownership. The ASF + licenses this file to You under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + License for the specific language governing permissions and limitations under + the License. +--> +<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal" + jcr:mixinTypes="[rep:AccessControllable]" + jcr:primaryType="any:Type"/> Review comment: I wanted to underline that we don't check but I agree that is confusing - I'll use nt:unstructured ########## File path: src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/DefaultAclManager.java ########## @@ -164,49 +166,43 @@ public void reset() { privilegeDefinitions = null; } - private void addPaths(@NotNull List<AccessControlEntry> authorizations, @NotNull List<VaultPackageAssembler> packageAssemblers, @NotNull Formatter formatter) { - if (authorizations.isEmpty()) { - return; - } - - Set<RepoPath> paths = new TreeSet<>(); - for (AccessControlEntry authorization : authorizations) { - RepoPath rp = authorization.getRepositoryPath(); - // exclude special paths: user/group home nodes and subtrees therein, repository-level marker path - if (!(rp.isRepositoryPath())) { - addPath(authorization.getRepositoryPath(), paths); - } - } - - for (RepoPath path : paths) { - String type = computePathType(path, packageAssemblers); - - formatter.format("create path (%s) %s%n", type, path); - } - } - - private static @NotNull String computePathType(@NotNull RepoPath path, @NotNull List<VaultPackageAssembler> packageAssemblers) { + private static @Nullable String computePathWithTypes(@NotNull RepoPath path, @NotNull List<VaultPackageAssembler> packageAssemblers) { path = new RepoPath(PlatformNameFormat.getPlatformPath(path.toString())); - for (VaultPackageAssembler packageAssembler: packageAssemblers) { - File currentDir = packageAssembler.getEntry(path.toString()); - - if (currentDir.exists()) { - File currentContent = new File(currentDir, CONTENT_XML_FILE_NAME); - if (currentContent.exists()) { - try (FileInputStream input = new FileInputStream(currentContent)) { - return new PrimaryTypeParser(DEFAULT_TYPE).parse(input); + boolean type = false; + String current = ""; + for (String part : path.toString().substring(1).split("/")) { + current += current.isEmpty() ? part : "/" + part; + for (VaultPackageAssembler packageAssembler : packageAssemblers) { + File currentContent = packageAssembler.getEntry(current + "/" + CONTENT_XML_FILE_NAME); + if (currentContent.isFile()) { + String primary; + String mixin; + try (FileInputStream input = new FileInputStream(currentContent); + FileInputStream input2 = new FileInputStream(currentContent)) { + primary = new PrimaryTypeParser(DEFAULT_TYPE).parse(input); Review comment: yup ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
