mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-17 14:21:39 +00:00
Merge pull request #3357 from Alfresco/fix/MNT-24146
Backport MNT 24146 changes
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Remote API
|
* Alfresco Remote API
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2017 Alfresco Software Limited
|
* Copyright (C) 2005 - 2025 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -25,6 +25,20 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.api.impl;
|
package org.alfresco.rest.api.impl;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.AbstractList;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.query.PagingRequest;
|
import org.alfresco.query.PagingRequest;
|
||||||
import org.alfresco.query.PagingResults;
|
import org.alfresco.query.PagingResults;
|
||||||
@@ -75,19 +89,6 @@ import org.alfresco.service.cmr.usage.ContentUsageService;
|
|||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.AbstractList;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Centralises access to people services and maps between representations.
|
* Centralises access to people services and maps between representations.
|
||||||
@@ -106,8 +107,7 @@ public class PeopleImpl implements People
|
|||||||
private static final List<QName> EXCLUDED_ASPECTS = Arrays.asList();
|
private static final List<QName> EXCLUDED_ASPECTS = Arrays.asList();
|
||||||
private static final List<QName> EXCLUDED_PROPS = Arrays.asList();
|
private static final List<QName> EXCLUDED_PROPS = Arrays.asList();
|
||||||
private static final int USERNAME_MAXLENGTH = 100;
|
private static final int USERNAME_MAXLENGTH = 100;
|
||||||
private static final String[] RESERVED_AUTHORITY_PREFIXES =
|
private static final String[] RESERVED_AUTHORITY_PREFIXES = {
|
||||||
{
|
|
||||||
PermissionService.GROUP_PREFIX,
|
PermissionService.GROUP_PREFIX,
|
||||||
PermissionService.ROLE_PREFIX
|
PermissionService.ROLE_PREFIX
|
||||||
};
|
};
|
||||||
@@ -269,8 +269,7 @@ public class PeopleImpl implements People
|
|||||||
{
|
{
|
||||||
nodeProps.remove(ContentModel.PROP_PERSONDESC);
|
nodeProps.remove(ContentModel.PROP_PERSONDESC);
|
||||||
|
|
||||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public Void doWork() throws Exception
|
public Void doWork() throws Exception
|
||||||
{
|
{
|
||||||
@@ -416,7 +415,6 @@ public class PeopleImpl implements People
|
|||||||
nodeService.deleteNode(avatarOrigNodeRef);
|
nodeService.deleteNode(avatarOrigNodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a full representation of a person.
|
* Get a full representation of a person.
|
||||||
*
|
*
|
||||||
@@ -459,8 +457,7 @@ public class PeopleImpl implements People
|
|||||||
final List<PersonService.PersonInfo> page = pagingResult.getPage();
|
final List<PersonService.PersonInfo> page = pagingResult.getPage();
|
||||||
int totalItems = pagingResult.getTotalResultCount().getFirst();
|
int totalItems = pagingResult.getTotalResultCount().getFirst();
|
||||||
final String personId = AuthenticationUtil.getFullyAuthenticatedUser();
|
final String personId = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||||
List<Person> people = new AbstractList<Person>()
|
List<Person> people = new AbstractList<Person>() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public Person get(int index)
|
public Person get(int index)
|
||||||
{
|
{
|
||||||
@@ -513,8 +510,7 @@ public class PeopleImpl implements People
|
|||||||
processPersonProperties(personId, nodeProps);
|
processPersonProperties(personId, nodeProps);
|
||||||
// TODO this needs to be run as admin but should we do this here?
|
// TODO this needs to be run as admin but should we do this here?
|
||||||
final String pId = personId;
|
final String pId = personId;
|
||||||
Boolean enabled = AuthenticationUtil.runAsSystem(new RunAsWork<Boolean>()
|
Boolean enabled = AuthenticationUtil.runAsSystem(new RunAsWork<Boolean>() {
|
||||||
{
|
|
||||||
public Boolean doWork() throws Exception
|
public Boolean doWork() throws Exception
|
||||||
{
|
{
|
||||||
return authenticationService.getAuthenticationEnabled(pId);
|
return authenticationService.getAuthenticationEnabled(pId);
|
||||||
@@ -627,16 +623,14 @@ public class PeopleImpl implements People
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the description to a content file and store the content URL in
|
* Write the description to a content file and store the content URL in ContentModel.PROP_PERSONDESC
|
||||||
* ContentModel.PROP_PERSONDESC
|
|
||||||
*
|
*
|
||||||
* @param description
|
* @param description
|
||||||
* @param nodeRef
|
* @param nodeRef
|
||||||
*/
|
*/
|
||||||
private void savePersonDescription(final String description, final NodeRef nodeRef)
|
private void savePersonDescription(final String description, final NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public Void doWork() throws Exception
|
public Void doWork() throws Exception
|
||||||
{
|
{
|
||||||
@@ -718,7 +712,7 @@ public class PeopleImpl implements People
|
|||||||
Boolean isEnabled = person.isEnabled();
|
Boolean isEnabled = person.isEnabled();
|
||||||
if (isEnabled != null)
|
if (isEnabled != null)
|
||||||
{
|
{
|
||||||
if (isAdminAuthority(personIdToUpdate))
|
if (!isEnabled && isAdminAuthority(personIdToUpdate))
|
||||||
{
|
{
|
||||||
throw new PermissionDeniedException("Admin authority cannot be disabled.");
|
throw new PermissionDeniedException("Admin authority cannot be disabled.");
|
||||||
}
|
}
|
||||||
@@ -768,9 +762,9 @@ public class PeopleImpl implements People
|
|||||||
// The person service only allows admin users to set the properties by default.
|
// The person service only allows admin users to set the properties by default.
|
||||||
if (!properties.isEmpty())
|
if (!properties.isEmpty())
|
||||||
{
|
{
|
||||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() {
|
||||||
{
|
@Override
|
||||||
@Override public Void doWork() throws Exception
|
public Void doWork() throws Exception
|
||||||
{
|
{
|
||||||
personService.setPersonProperties(personIdToUpdate, properties, false);
|
personService.setPersonProperties(personIdToUpdate, properties, false);
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user