use of org.alfresco.rest.framework.resource.parameters.Parameters in project records-management by Alfresco.
the class RMSiteEntityResourceUnitTest method updateNonRMSite.
@Test
public void updateNonRMSite() throws Exception {
String siteId = NON_RM_SITE_ID;
Params parameters = mock(Params.class);
RMSite site = new RMSite();
site.setTitle("New Title");
site.setDescription("New Description");
try {
rmSiteEntityResource.update(siteId, site, parameters);
fail("Expected ecxeption as siteId was different than rm");
} catch (InvalidParameterException ex) {
assertEquals("The Update is supported only for siteId = rm.", ex.getMessage());
}
verify(mockedRMSites, never()).updateRMSite(any(String.class), any(SiteUpdate.class), any(Parameters.class));
}
use of org.alfresco.rest.framework.resource.parameters.Parameters in project records-management by Alfresco.
the class RMSiteEntityResourceUnitTest method updateRMSiteGuid.
@Test
public void updateRMSiteGuid() throws Exception {
String siteId = RM_SITE_ID;
Params parameters = mock(Params.class);
RMSite site = new RMSite();
site.setTitle("New Title");
site.setDescription("New Description");
site.setGuid("newGUID");
try {
rmSiteEntityResource.update(siteId, site, parameters);
fail("Expected ecxeption as rm site guid cannot be changed.");
} catch (InvalidArgumentException ex) {
assertEquals("Site update does not support field: guid", ex.getMsgId());
}
verify(mockedRMSites, never()).updateRMSite(any(String.class), any(SiteUpdate.class), any(Parameters.class));
}
use of org.alfresco.rest.framework.resource.parameters.Parameters in project records-management by Alfresco.
the class RMSiteEntityResourceUnitTest method updateRMSiteRole.
@Test
public void updateRMSiteRole() throws Exception {
String siteId = RM_SITE_ID;
Params parameters = mock(Params.class);
RMSite site = new RMSite();
site.setTitle("New Title");
site.setDescription("New Description");
site.setRole("newRole");
try {
rmSiteEntityResource.update(siteId, site, parameters);
fail("Expected ecxeption as rm site role cannot be changed.");
} catch (InvalidArgumentException ex) {
assertEquals("Site update does not support field: role", ex.getMsgId());
}
verify(mockedRMSites, never()).updateRMSite(any(String.class), any(SiteUpdate.class), any(Parameters.class));
}
use of org.alfresco.rest.framework.resource.parameters.Parameters in project alfresco-remote-api by Alfresco.
the class GroupsImpl method getGroupsByPersonId.
@Override
public CollectionWithPagingInfo<Group> getGroupsByPersonId(String requestedPersonId, Parameters parameters) {
// Canonicalize the person ID, performing -me- alias substitution.
final String personId = people.validatePerson(requestedPersonId);
// Non-admins can only access their own data
// TODO: this is also in PeopleImpl.update(personId,personInfo) - refactor?
boolean isAdmin = authorityService.hasAdminAuthority();
String currentUserId = AuthenticationUtil.getFullyAuthenticatedUser();
if (!isAdmin && !currentUserId.equalsIgnoreCase(personId)) {
// The user is not an admin user and is not attempting to retrieve *their own* details.
throw new PermissionDeniedException();
}
Query q = parameters.getQuery();
Boolean isRootParam = null;
String zoneFilter = null;
if (q != null) {
GroupsQueryWalker propertyWalker = new GroupsQueryWalker();
QueryHelper.walk(q, propertyWalker);
isRootParam = propertyWalker.getIsRoot();
List<String> zonesParam = propertyWalker.getZones();
if (zonesParam != null) {
validateZonesParam(zonesParam);
zoneFilter = zonesParam.get(0);
}
}
final List<String> includeParam = parameters.getInclude();
Paging paging = parameters.getPaging();
// Retrieve sort column. This is limited for now to sort column due to
// v0 api implementation. Should be improved in the future.
Pair<String, Boolean> sortProp = getGroupsSortProp(parameters);
// Get all the authorities for a user, including but not limited to, groups.
Set<String> userAuthorities = runAsSystem(() -> authorityService.getAuthoritiesForUser(personId));
final Set<String> rootAuthorities = getAllRootAuthorities(AuthorityType.GROUP);
// Filter, transform and sort the list of user authorities into
// a suitable list of AuthorityInfo objects.
final String finalZoneFilter = zoneFilter;
final Boolean finalIsRootParam = isRootParam;
List<AuthorityInfo> groupAuthorities = userAuthorities.stream().filter(a -> a.startsWith(AuthorityType.GROUP.getPrefixString())).filter(a -> isRootPredicate(finalIsRootParam, rootAuthorities, a)).filter(a -> zonePredicate(a, finalZoneFilter)).map(this::getAuthorityInfo).sorted(new AuthorityInfoComparator(sortProp.getFirst(), sortProp.getSecond())).collect(Collectors.toList());
PagingResults<AuthorityInfo> pagingResult = Util.wrapPagingResults(paging, groupAuthorities);
// Create response.
final List<AuthorityInfo> page = pagingResult.getPage();
int totalItems = pagingResult.getTotalResultCount().getFirst();
// Transform the page of results into Group objects
List<Group> groups = page.stream().map(authority -> getGroup(authority, includeParam, rootAuthorities)).collect(Collectors.toList());
return CollectionWithPagingInfo.asPaged(paging, groups, pagingResult.hasMoreItems(), totalItems);
}
use of org.alfresco.rest.framework.resource.parameters.Parameters in project alfresco-remote-api by Alfresco.
the class QuickShareLinksImpl method getRendition.
@Override
public Rendition getRendition(String sharedId, String renditionId) {
checkEnabled();
checkValidShareId(sharedId);
try {
Pair<String, NodeRef> pair = quickShareService.getTenantNodeRefFromSharedId(sharedId);
String networkTenantDomain = pair.getFirst();
final NodeRef nodeRef = pair.getSecond();
return TenantUtil.runAsSystemTenant(() -> {
Parameters params = getParamsWithCreatedStatus();
return renditions.getRendition(nodeRef, renditionId, params);
}, networkTenantDomain);
} catch (InvalidSharedIdException ex) {
logger.warn("Unable to find: " + sharedId);
throw new EntityNotFoundException(sharedId);
} catch (InvalidNodeRefException inre) {
logger.warn("Unable to find: " + sharedId + " [" + inre.getNodeRef() + "]");
throw new EntityNotFoundException(sharedId);
}
}
Aggregations