Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ private Set<String> collectEffectiveCandidates(@NotNull Root r, @NotNull Iterabl
Tree cug = CugUtil.getCug(t);
PropertyState pNames = (cug == null) ? null : cug.getProperty(REP_PRINCIPAL_NAMES);
if (pNames != null) {
if (!Collections.disjoint(Collections.unmodifiableSet(SetUtils.toLinkedSet(principalNames)), Collections.unmodifiableSet(SetUtils.toLinkedSet(pNames.getValue(Type.STRINGS))))) {
if (!Collections.disjoint(ImmutableSet.copyOf(principalNames), ImmutableSet.copyOf(pNames.getValue(Type.STRINGS)))) {
candidates.add(path);
}
nestedCugPaths(cug).forEach(eval::add);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Set;
import org.apache.jackrabbit.guava.common.collect.ImmutableSet;
import org.apache.jackrabbit.oak.commons.PropertiesUtil;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.spi.security.authorization.cug.CugExclude;
import org.jetbrains.annotations.NotNull;
import org.osgi.service.component.annotations.Activate;
Expand Down Expand Up @@ -81,6 +80,6 @@ protected void modified(Map<String, Object> properties) {
}

private void setPrincipalNames(@NotNull Map<String, Object> properties) {
this.principalNames = Collections.unmodifiableSet(SetUtils.toLinkedSet(PropertiesUtil.toStringArray(properties.get("principalNames"), new String[0])));
this.principalNames = ImmutableSet.copyOf(PropertiesUtil.toStringArray(properties.get("principalNames"), new String[0]));
}
}
2 changes: 1 addition & 1 deletion oak-doc/src/site/markdown/security/user/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ implementation.
//------------------------------------------------< SCR Integration >---
@Activate
private void activate(Map<String, Object> properties) {
ids = Collections.unmodifiableSet(SetUtils.toLinkedSet(PropertiesUtil.toStringArray(properties.get("ids"), new String[0])));
ids = ImmutableSet.copyOf(PropertiesUtil.toStringArray(properties.get("ids"), new String[0]));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

import org.apache.jackrabbit.guava.common.collect.ImmutableSet;
import org.apache.jackrabbit.oak.commons.PerfLogger;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FilterDirectory;
Expand Down Expand Up @@ -333,7 +332,7 @@ private void removeDeletedFiles() throws IOException {

Set<String> filesToBeDeleted =
// Files present locally
SetUtils.toLinkedSet(local.listAll()).stream()
ImmutableSet.copyOf(local.listAll()).stream()
// but not in my view
.filter(name -> !remoteFiles.contains(name))
// and also older than a safe timestamp (deleteBeforeTS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.io.IOException;
import java.security.SecureRandom;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;

Expand Down Expand Up @@ -342,7 +341,7 @@ private Set<String> getListing(){
if (fileNames == null){
fileNames = directoryBuilder.getChildNodeNames();
}
Set<String> result = Collections.unmodifiableSet(SetUtils.toLinkedSet(fileNames));
Set<String> result = ImmutableSet.copyOf(fileNames);
PERF_LOGGER.end(start, 100, "Directory listing performed. Total {} files", result.size());
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.apache.jackrabbit.oak.plugins.index.lucene.property;

import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
Expand All @@ -32,7 +31,6 @@
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
Expand Down Expand Up @@ -70,7 +68,7 @@ public void validate() throws CommitFailedException {
String propertyRelativePath = e.getKey();
String value = e.getValue();
Iterable<String> indexedPaths = getIndexedPaths(propertyRelativePath, value);
Set<String> allPaths = Collections.unmodifiableSet(SetUtils.toLinkedSet(indexedPaths));
Set<String> allPaths = ImmutableSet.copyOf(indexedPaths);

//If more than one match found then filter out stale paths
if (allPaths.size() > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import org.apache.jackrabbit.guava.common.collect.ImmutableSet;
import org.apache.jackrabbit.oak.commons.PropertiesUtil;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
Expand Down Expand Up @@ -307,13 +306,13 @@ private static Set<?> convertToSet(@NotNull Object configProperty, @NotNull Clas
if (configProperty instanceof Set) {
return (Set) configProperty;
} else if (configProperty instanceof Collection<?>) {
return Collections.unmodifiableSet(SetUtils.toLinkedSet((Collection<?>) configProperty));
return ImmutableSet.copyOf((Collection<?>) configProperty);
} else if (configProperty.getClass().isArray()) {
return Collections.unmodifiableSet(SetUtils.toLinkedSet((Object[]) configProperty));
return ImmutableSet.copyOf((Object[]) configProperty);
} else {
String[] arr = PropertiesUtil.toStringArray(configProperty);
if (arr != null) {
return Collections.unmodifiableSet(SetUtils.toLinkedSet(arr));
return ImmutableSet.copyOf(arr);
} else {
String str = configProperty.toString();
log.warn("Unsupported target type {} for value {}", clazz.getName(), str);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import org.apache.jackrabbit.guava.common.collect.ImmutableSet;
import org.apache.jackrabbit.oak.api.AuthInfo;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -49,7 +48,7 @@ public AuthInfoImpl(@Nullable String userID, @Nullable Map<String, ?> attributes
@Nullable Iterable<? extends Principal> principals) {
this.userID = userID;
this.attributes = (attributes == null) ? Collections.emptyMap() : attributes;
this.principals = (principals == null) ? Collections.emptySet() : Collections.unmodifiableSet(SetUtils.toLinkedSet(principals));
this.principals = (principals == null) ? Collections.emptySet() : ImmutableSet.copyOf(principals);
}

public static AuthInfo createFromSubject(@NotNull Subject subject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.jackrabbit.guava.common.collect.ImmutableSet;
import org.apache.jackrabbit.guava.common.collect.Maps;

import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -66,7 +65,8 @@ public String getUserId(@NotNull Credentials credentials) {
public Map<String, ?> getAttributes(@NotNull Credentials credentials) {
if (credentials instanceof SimpleCredentials) {
final SimpleCredentials sc = (SimpleCredentials) credentials;
return Maps.asMap(Collections.unmodifiableSet(SetUtils.toLinkedSet(sc.getAttributeNames())), sc::getAttribute);
return Maps.asMap(ImmutableSet.copyOf(sc.getAttributeNames()),
input -> sc.getAttribute(input));
} else {
return Collections.emptyMap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.apache.jackrabbit.guava.common.collect.ImmutableSet;
import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry;
import org.apache.jackrabbit.api.security.authorization.PrivilegeCollection;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.plugins.value.jcr.PartialValueFactory;
import org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction;
Expand Down Expand Up @@ -77,7 +76,7 @@ public ACE(@Nullable Principal principal, @Nullable PrivilegeBits privilegeBits,
this.principal = principal;
this.privilegeBits = privilegeBits;
this.isAllow = isAllow;
this.restrictions = (restrictions == null) ? Collections.emptySet() : Collections.unmodifiableSet(SetUtils.toLinkedSet(restrictions));
this.restrictions = (restrictions == null) ? Collections.emptySet() : ImmutableSet.copyOf(restrictions);
this.namePathMapper = namePathMapper;
this.valueFactory = new PartialValueFactory(namePathMapper);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
import org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AccessControlConstants;
import org.apache.jackrabbit.oak.plugins.tree.TreeUtil;
Expand Down Expand Up @@ -71,7 +70,7 @@ public Set<RestrictionDefinition> getSupportedRestrictions(@Nullable String oakP
if (isUnsupportedPath(oakPath)) {
return Collections.emptySet();
} else {
return Collections.unmodifiableSet(SetUtils.toLinkedSet(supported.values()));
return ImmutableSet.copyOf(supported.values());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.namepath.NameMapper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -203,7 +202,7 @@ public Set<String> getPrivilegeNames(@Nullable PrivilegeBits privilegeBits) {
privilegeNames = bitsToNames.get(pb);
} else {
privilegeNames = collectPrivilegeNames(privilegesTree, pb);
bitsToNames.put(pb, Collections.unmodifiableSet(SetUtils.toLinkedSet(privilegeNames)));
bitsToNames.put(pb, ImmutableSet.copyOf(privilegeNames));
}
return privilegeNames;
}
Expand Down Expand Up @@ -252,7 +251,7 @@ public Iterable<String> getAggregatedPrivilegeNames(@NotNull String... privilege
return extractAggregatedPrivileges(Collections.singleton(privName));
}
} else {
Set<String> pNames = Collections.unmodifiableSet(SetUtils.toLinkedSet(privilegeNames));
Set<String> pNames = ImmutableSet.copyOf(privilegeNames);
if (NON_AGGREGATE_PRIVILEGES.containsAll(pNames)) {
return pNames;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.commons.collections.IterableUtils;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.commons.collections.StreamUtils;
import org.apache.jackrabbit.oak.composite.checks.NodeStoreChecks;
import org.apache.jackrabbit.oak.spi.commit.ChangeDispatcher;
Expand Down Expand Up @@ -294,7 +293,7 @@ public boolean release(String checkpoint) {
}

private String getPartialCheckpointName(MountedNodeStore nodeStore, String globalCheckpoint, Map<String, String> globalCheckpointProperties, boolean resolveByName) {
Set<String> validCheckpointNames = Collections.unmodifiableSet(SetUtils.toLinkedSet(nodeStore.getNodeStore().checkpoints()));
Set<String> validCheckpointNames = ImmutableSet.copyOf(nodeStore.getNodeStore().checkpoints());
String result = globalCheckpointProperties.get(CHECKPOINT_METADATA_MOUNT + nodeStore.getMount().getName());
if (result != null && validCheckpointNames.contains(result)) {
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

import static java.util.Objects.requireNonNull;

import java.util.Collections;
import java.util.Set;

import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ComponentPropertyType;
import org.osgi.service.component.annotations.ConfigurationPolicy;
Expand Down Expand Up @@ -83,13 +81,13 @@ public NodeTypeMountedNodeStoreChecker() {
public NodeTypeMountedNodeStoreChecker(String invalidNodeType, String errorLabel, String... excludedNodeTypes) {
this.invalidNodeType = invalidNodeType;
this.errorLabel = errorLabel;
this.excludedNodeTypes = Collections.unmodifiableSet(SetUtils.toLinkedSet(excludedNodeTypes));
this.excludedNodeTypes = ImmutableSet.copyOf(excludedNodeTypes);
}

protected void activate(ComponentContext ctx) {
invalidNodeType = requireNonNull(PropertiesUtil.toString(ctx.getProperties().get(INVALID_NODE_TYPE), null), INVALID_NODE_TYPE);
errorLabel = requireNonNull(PropertiesUtil.toString(ctx.getProperties().get(ERROR_LABEL), null), ERROR_LABEL);
excludedNodeTypes = Collections.unmodifiableSet(SetUtils.toLinkedSet(PropertiesUtil.toStringArray(ctx.getProperties().get(EXCLUDED_NODE_TYPES), new String[0])));
excludedNodeTypes = ImmutableSet.copyOf(PropertiesUtil.toStringArray(ctx.getProperties().get(EXCLUDED_NODE_TYPES), new String[0]));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -35,7 +34,6 @@
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.commons.collections.ListUtils;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeState;
import org.apache.jackrabbit.oak.plugins.migration.FilteringNodeState;
import org.apache.jackrabbit.oak.plugins.migration.NodeStateCopier;
Expand Down Expand Up @@ -71,6 +69,7 @@
import org.slf4j.LoggerFactory;

import static java.util.Objects.requireNonNull;
import static org.apache.jackrabbit.guava.common.collect.ImmutableSet.copyOf;
import static org.apache.jackrabbit.guava.common.collect.Sets.union;
import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
Expand Down Expand Up @@ -218,7 +217,7 @@ public void setCustomCommitHooks(List<CommitHook> customCommitHooks) {
* @param includes Paths to be included in the copy.
*/
public void setIncludes(@NotNull String... includes) {
this.includePaths = Collections.unmodifiableSet(SetUtils.toLinkedSet(requireNonNull(includes)));
this.includePaths = copyOf(requireNonNull(includes));
}

/**
Expand All @@ -228,7 +227,7 @@ public void setIncludes(@NotNull String... includes) {
* @param excludes Paths to be excluded from the copy.
*/
public void setExcludes(@NotNull String... excludes) {
this.excludePaths = Collections.unmodifiableSet(SetUtils.toLinkedSet(requireNonNull(excludes)));
this.excludePaths = copyOf(requireNonNull(excludes));
}

/**
Expand All @@ -238,7 +237,7 @@ public void setExcludes(@NotNull String... excludes) {
* @param merges Paths to be merged during copy.
*/
public void setMerges(@NotNull String... merges) {
this.mergePaths = Collections.unmodifiableSet(SetUtils.toLinkedSet(requireNonNull(merges)));
this.mergePaths = copyOf(requireNonNull(merges));
}

public void setFilterLongNames(boolean filterLongNames) {
Expand Down Expand Up @@ -473,7 +472,7 @@ private void copyWorkspace(NodeState sourceRoot, NodeBuilder targetRoot) {
}
excludes.add("/:async");

final Set<String> merges = union(Collections.unmodifiableSet(SetUtils.toLinkedSet(this.mergePaths)), Set.of("/jcr:system"));
final Set<String> merges = union(copyOf(this.mergePaths), Set.of("/jcr:system"));
NodeStateCopier.builder()
.include(includes)
.exclude(excludes.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.jackrabbit.oak.upgrade;

import static java.util.Objects.requireNonNull;
import static org.apache.jackrabbit.guava.common.collect.ImmutableSet.copyOf;
import static org.apache.jackrabbit.guava.common.collect.Sets.union;
import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
import static org.apache.jackrabbit.oak.plugins.migration.FilteringNodeState.ALL;
Expand All @@ -34,7 +35,6 @@
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
Expand Down Expand Up @@ -77,7 +77,6 @@
import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.commons.collections.SetUtils;
import org.apache.jackrabbit.oak.commons.conditions.Validate;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
Expand Down Expand Up @@ -322,7 +321,7 @@ public void setCustomCommitHooks(List<CommitHook> customCommitHooks) {
* @param includes Paths to be included in the copy.
*/
public void setIncludes(@NotNull String... includes) {
this.includePaths = Collections.unmodifiableSet(SetUtils.toLinkedSet(requireNonNull(includes)));
this.includePaths = copyOf(requireNonNull(includes));
}

/**
Expand All @@ -332,7 +331,7 @@ public void setIncludes(@NotNull String... includes) {
* @param excludes Paths to be excluded from the copy.
*/
public void setExcludes(@NotNull String... excludes) {
this.excludePaths = Collections.unmodifiableSet(SetUtils.toLinkedSet(requireNonNull(excludes)));
this.excludePaths = copyOf(requireNonNull(excludes));
}

/**
Expand All @@ -342,7 +341,7 @@ public void setExcludes(@NotNull String... excludes) {
* @param merges Paths to be merged during copy.
*/
public void setMerges(@NotNull String... merges) {
this.mergePaths = Collections.unmodifiableSet(SetUtils.toLinkedSet(requireNonNull(merges)));
this.mergePaths = copyOf(requireNonNull(merges));
}

/**
Expand Down Expand Up @@ -940,8 +939,8 @@ private PropertyDefinitionTemplate createPropertyDefinitionTemplate(ValueFactory
private String copyWorkspace(NodeState sourceRoot, NodeBuilder targetRoot, String workspaceName)
throws RepositoryException {
final Set<String> includes = calculateEffectiveIncludePaths(includePaths, sourceRoot);
final Set<String> excludes = union(Collections.unmodifiableSet(SetUtils.toLinkedSet(this.excludePaths)), Set.of("/jcr:system/jcr:versionStorage"));
final Set<String> merges = union(Collections.unmodifiableSet(SetUtils.toLinkedSet(this.mergePaths)), Set.of("/jcr:system"));
final Set<String> excludes = union(copyOf(this.excludePaths), Set.of("/jcr:system/jcr:versionStorage"));
final Set<String> merges = union(copyOf(this.mergePaths), Set.of("/jcr:system"));

logger.info("Copying workspace {} [i: {}, e: {}, m: {}]", workspaceName, includes, excludes, merges);

Expand All @@ -960,7 +959,7 @@ private String copyWorkspace(NodeState sourceRoot, NodeBuilder targetRoot, Strin

static Set<String> calculateEffectiveIncludePaths(Set<String> includePaths, NodeState sourceRoot) {
if (!includePaths.contains("/")) {
return Collections.unmodifiableSet(SetUtils.toLinkedSet(includePaths));
return copyOf(includePaths);
}

// include child nodes from source individually to avoid deleting other initialized content
Expand Down
Loading