/** * Robust relative path concatenation. * @param paths relative paths * @return the concatenated path * @deprecated Since Oak 1.3.10. Please use {@link PathUtils#concatRelativePaths(String...)} instead. */ public static String joinPaths(String... paths) { return PathUtils.concatRelativePaths(paths); }
@Test public void testConcatRelativePaths() { assertNull(PathUtils.concatRelativePaths("", "", "")); assertNull(PathUtils.concatRelativePaths()); assertEquals("a/b/c", PathUtils.concatRelativePaths("a", "b", "c")); assertEquals("a/b/c", PathUtils.concatRelativePaths("a", "b/c")); assertEquals("a/b/c", PathUtils.concatRelativePaths("a/b/c", "")); assertEquals("a/b/c", PathUtils.concatRelativePaths("a/b", "c")); assertEquals("a/b/c", PathUtils.concatRelativePaths("/", "a", "", "b/c/")); }
/** * Creates a new repository group for the given external one. * Note that this method only creates the authorizable but does not perform any synchronization. * * @param externalGroup the external group * @return the repository group * @throws RepositoryException if an error occurs */ @NotNull protected Group createGroup(@NotNull ExternalGroup externalGroup) throws RepositoryException { Principal principal = new PrincipalImpl(externalGroup.getPrincipalName()); Group group = userManager.createGroup( externalGroup.getId(), principal, PathUtils.concatRelativePaths(config.group().getPathPrefix(), externalGroup.getIntermediatePath()) ); setExternalId(group, externalGroup); return group; }
/** * Creates a new repository user for the given external one. * Note that this method only creates the authorizable but does not perform any synchronization. * * @param externalUser the external user * @return the repository user * @throws RepositoryException if an error occurs */ @NotNull protected User createUser(@NotNull ExternalUser externalUser) throws RepositoryException { Principal principal = new PrincipalImpl(externalUser.getPrincipalName()); String authId = config.user().isApplyRFC7613UsernameCaseMapped() ? java.text.Normalizer.normalize(externalUser.getId().toLowerCase(), java.text.Normalizer.Form.NFKC) : externalUser.getId(); User user = userManager.createUser( authId, null, principal, PathUtils.concatRelativePaths(config.user().getPathPrefix(), externalUser.getIntermediatePath()) ); setExternalId(user, externalUser); return user; }