MNT-24637 PMD fixes.

This commit is contained in:
Tom Page
2024-10-04 15:54:57 +01:00
parent 3b027c6c36
commit 093b3281fb

View File

@@ -40,8 +40,6 @@ import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
@@ -91,8 +89,6 @@ import org.alfresco.util.Pair;
*/ */
public class FavouritesImpl implements Favourites public class FavouritesImpl implements Favourites
{ {
private static final Log logger = LogFactory.getLog(FavouritesImpl.class);
private static final List<String> ALLOWED_INCLUDES = List.of(PARAM_INCLUDE_PROPERTIES, PARAM_INCLUDE_ASPECTNAMES, PARAM_INCLUDE_ALLOWABLEOPERATIONS); private static final List<String> ALLOWED_INCLUDES = List.of(PARAM_INCLUDE_PROPERTIES, PARAM_INCLUDE_ASPECTNAMES, PARAM_INCLUDE_ALLOWABLEOPERATIONS);
private People people; private People people;
@@ -141,7 +137,7 @@ public class FavouritesImpl implements Favourites
private Target getTarget(PersonFavourite personFavourite, Parameters parameters) private Target getTarget(PersonFavourite personFavourite, Parameters parameters)
{ {
Target target = null; Target target;
NodeRef nodeRef = personFavourite.getNodeRef(); NodeRef nodeRef = personFavourite.getNodeRef();
Type type = personFavourite.getType(); Type type = personFavourite.getType();
if (type.equals(Type.FILE)) if (type.equals(Type.FILE))
@@ -183,12 +179,12 @@ public class FavouritesImpl implements Favourites
final List<String> paramsInclude = parameters.getInclude(); final List<String> paramsInclude = parameters.getInclude();
if (!Collections.disjoint(paramsInclude, ALLOWED_INCLUDES)) if (!Collections.disjoint(paramsInclude, ALLOWED_INCLUDES))
{ {
final List<String> includes = ALLOWED_INCLUDES.stream().filter(a -> paramsInclude.contains(a)).collect(Collectors.toList()); final List<String> includes = ALLOWED_INCLUDES.stream().filter(paramsInclude::contains).collect(Collectors.toList());
// get node representation with only properties included // get node representation with only properties included
Node node = nodes.getFolderOrDocument(personFavourite.getNodeRef(), null, null, includes, null); Node node = nodes.getFolderOrDocument(personFavourite.getNodeRef(), null, null, includes, null);
// Create a map from node properties excluding properties already in this Favorite // Create a map from node properties excluding properties already in this Favorite
Map<String, Object> filteredNodeProperties = filterProps(node.getProperties(), EXCLUDED_PROPS); Map<String, Object> filteredNodeProperties = filterProps(node.getProperties(), EXCLUDED_PROPS);
if (filteredNodeProperties.size() > 0 && paramsInclude.contains(PARAM_INCLUDE_PROPERTIES)) if (!filteredNodeProperties.isEmpty() && paramsInclude.contains(PARAM_INCLUDE_PROPERTIES))
{ {
fav.setProperties(filteredNodeProperties); fav.setProperties(filteredNodeProperties);
} }
@@ -217,7 +213,7 @@ public class FavouritesImpl implements Favourites
private CollectionWithPagingInfo<Favourite> wrap(Paging paging, PagingResults<PersonFavourite> personFavourites, Parameters parameters) private CollectionWithPagingInfo<Favourite> wrap(Paging paging, PagingResults<PersonFavourite> personFavourites, Parameters parameters)
{ {
final List<PersonFavourite> page = personFavourites.getPage(); final List<PersonFavourite> page = personFavourites.getPage();
final List<Favourite> list = new AbstractList<Favourite>() { final List<Favourite> list = new AbstractList<>() {
@Override @Override
public Favourite get(int index) public Favourite get(int index)
{ {
@@ -371,7 +367,7 @@ public class FavouritesImpl implements Favourites
List<Pair<FavouritesService.SortFields, Boolean>> sortProps = getSortProps(parameters); List<Pair<FavouritesService.SortFields, Boolean>> sortProps = getSortProps(parameters);
final Set<Type> filteredByClientQuery = new HashSet<Type>(); final Set<Type> filteredByClientQuery = new HashSet<>();
Set<Type> filterTypes = FavouritesService.Type.ALL_FILTER_TYPES; // Default all Set<Type> filterTypes = FavouritesService.Type.ALL_FILTER_TYPES; // Default all
// filterType is of the form 'target.<site|file|folder>' // filterType is of the form 'target.<site|file|folder>'
@@ -389,7 +385,7 @@ public class FavouritesImpl implements Favourites
{ {
if (filteredByClient != null) if (filteredByClient != null)
{ {
int idx = filteredByClient.lastIndexOf("/"); int idx = filteredByClient.lastIndexOf('/');
if (idx == -1 || idx == filteredByClient.length()) if (idx == -1 || idx == filteredByClient.length())
{ {
throw new InvalidArgumentException(); throw new InvalidArgumentException();
@@ -404,7 +400,7 @@ public class FavouritesImpl implements Favourites
} }
}); });
if (filteredByClientQuery.size() > 0) if (!filteredByClientQuery.isEmpty())
{ {
filterTypes = filteredByClientQuery; filterTypes = filteredByClientQuery;
} }
@@ -438,7 +434,7 @@ public class FavouritesImpl implements Favourites
{ {
List<Pair<FavouritesService.SortFields, Boolean>> sortProps = new ArrayList<>(); List<Pair<FavouritesService.SortFields, Boolean>> sortProps = new ArrayList<>();
List<SortColumn> sortCols = parameters.getSorting(); List<SortColumn> sortCols = parameters.getSorting();
if ((sortCols != null) && (sortCols.size() > 0)) if (sortCols != null && !sortCols.isEmpty())
{ {
for (SortColumn sortCol : sortCols) for (SortColumn sortCol : sortCols)
{ {
@@ -451,7 +447,7 @@ public class FavouritesImpl implements Favourites
{ {
throw new InvalidArgumentException("Invalid sort field: " + sortCol.column); throw new InvalidArgumentException("Invalid sort field: " + sortCol.column);
} }
sortProps.add(new Pair<>(sortField, (sortCol.asc ? Boolean.TRUE : Boolean.FALSE))); sortProps.add(new Pair<>(sortField, sortCol.asc ? Boolean.TRUE : Boolean.FALSE));
} }
} }
else else