Skip to content

Commit

Permalink
upstream: b=main,r=ae9113926f7ee00a3ff6d0ffaf832b93313957aa,t=2024-01…
Browse files Browse the repository at this point in the history
…-12-1342-44199
  • Loading branch information
sonatype-zion committed Jan 12, 2024
1 parent f7f2622 commit ac2016a
Show file tree
Hide file tree
Showing 119 changed files with 1,988 additions and 8,497 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ public interface FeatureFlags

String REACT_PRIVILEGES_NAMED = "${nexus.react.privileges:-false}";

String REACT_PRIVILEGES_MODAL_ENABLED = "nexus.react.privileges.modal.enabled";

String REACT_PRIVILEGES_MODAL_NAMED = "${nexus.react.privileges.modal.enabled:-false}";

/**
* Feature flag to determine if we should include the repository sizes feature
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ public void toSql(final SelectorConfiguration selectorConfiguration, final Selec
}

@Override
public void toSql(
public <T> void toSql(
final SelectorConfiguration selectorConfiguration,
final SelectorSqlBuilder sqlBuilder,
final CselToSql cselToSql) throws SelectorEvaluationException
final T sqlBuilder,
final CselToSql<T> cselToSql) throws SelectorEvaluationException
{
try {
selectorCache.get(selectorConfiguration).toSql(sqlBuilder, cselToSql);
Expand Down Expand Up @@ -327,10 +327,10 @@ public SelectorConfiguration newSelectorConfiguration() {

@Override
public SelectorConfiguration newSelectorConfiguration(
String name,
String type,
String description,
Map<String, ?> attributes)
final String name,
final String type,
final String description,
final Map<String, ?> attributes)
{
SelectorConfiguration selectorConfiguration = store.newSelectorConfiguration();
selectorConfiguration.setName(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import org.sonatype.nexus.datastore.mybatis.handlers.PasswordCharacterArrayTypeHandler;
import org.sonatype.nexus.datastore.mybatis.handlers.PrincipalCollectionTypeHandler;
import org.sonatype.nexus.datastore.mybatis.handlers.SetTypeHandler;
import org.sonatype.nexus.datastore.mybatis.handlers.TokenizingTypeHandler;
import org.sonatype.nexus.security.PasswordHelper;
import org.sonatype.nexus.transaction.TransactionIsolation;

Expand Down Expand Up @@ -289,7 +290,7 @@ public void register(final Class<? extends DataAccess> accessType) {
}

@Override
public void unregister(Class<? extends DataAccess> accessType) {
public void unregister(final Class<? extends DataAccess> accessType) {
// unregistration of custom access types is not supported
}

Expand Down Expand Up @@ -447,6 +448,7 @@ private void registerCommonTypeHandlers() {
register(new PasswordCharacterArrayTypeHandler(passwordHelper));
register(new PrincipalCollectionTypeHandler());
registerDetached(new EncryptedStringTypeHandler()); // detached so it doesn't apply to all Strings
registerDetached(new TokenizingTypeHandler()); // detached so it doesn't apply to all Strings

// enable automatic encryption of sensitive JSON fields in the config store
sensitiveAttributeFilter = buildSensitiveAttributeFilter(mybatisConfig);
Expand Down Expand Up @@ -536,7 +538,7 @@ private void registerDataAccessMapper(final Class<? extends DataAccess> accessTy
* Searches the directly declared interfaces for one annotated with {@link SchemaTemplate}.
*/
@Nullable
private Class<?> findTemplateType(Class<? extends DataAccess> accessType) {
private Class<?> findTemplateType(final Class<? extends DataAccess> accessType) {
for (Class<?> candidate : accessType.getInterfaces()) {
if (candidate.isAnnotationPresent(SchemaTemplate.class)) {
return candidate;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Sonatype Nexus (TM) Open Source Version
* Copyright (c) 2008-present Sonatype, Inc.
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
*
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/
package org.sonatype.nexus.datastore.mybatis.handlers;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.stream.Collectors;

import com.google.common.collect.Iterables;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;

/**
* Simplistic tokenizer which splits strings using the following characters: . - /
*/
public class TokenizingTypeHandler
extends BaseTypeHandler<Collection<String>>
{
private static final String SEPARATOR = " ";

@Override
public void setNonNullParameter(
final PreparedStatement ps,
final int parameterIndex,
final Collection<String> parameter,
final JdbcType jdbcType) throws SQLException
{
ps.setString(parameterIndex, tokenize(toString(parameter)));
}

private static String tokenize(final String token) {
return token.replaceAll("[.-/]", SEPARATOR);
}

private static String toString(final Collection<String> values) {
if (values.isEmpty()) {
return "";
}
else if (values.size() == 1) {
return Iterables.getOnlyElement(values);
}
return values.stream().collect(Collectors.joining(SEPARATOR));
}

@Override
public Collection<String> getNullableResult(final ResultSet rs, final String columnName) throws SQLException {
throw new UnsupportedOperationException();
}

@Override
public Collection<String> getNullableResult(final ResultSet rs, final int columnIndex) throws SQLException {
throw new UnsupportedOperationException();
}

@Override
public Collection<String> getNullableResult(final CallableStatement cs, final int columnIndex) throws SQLException {
throw new UnsupportedOperationException();
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit ac2016a

Please sign in to comment.