use of org.alfresco.rest.framework.resource.parameters.Params in project alfresco-remote-api by Alfresco.
the class SearchApiWebscriptTests method testPaging.
@Test
public void testPaging() throws Exception {
Params params = webscript.getParams(null, null, null, null);
// Defaults
assertNotNull(params.getPaging());
assertEquals(Paging.DEFAULT_MAX_ITEMS, params.getPaging().getMaxItems());
assertEquals(Paging.DEFAULT_SKIP_COUNT, params.getPaging().getSkipCount());
params = webscript.getParams(null, null, null, Paging.valueOf(4, 20));
assertEquals(20, params.getPaging().getMaxItems());
assertEquals(4, params.getPaging().getSkipCount());
}
use of org.alfresco.rest.framework.resource.parameters.Params in project alfresco-remote-api by Alfresco.
the class SearchApiWebscriptTests method testInclude.
@Test
public void testInclude() throws Exception {
Params params = webscript.getParams(null, null, null, null);
// Defaults
assertNotNull(params.getInclude());
assertEquals(0, params.getInclude().size());
params = webscript.getParams(null, null, Arrays.asList("name", "size"), null);
assertNotNull(params.getInclude());
assertEquals(2, params.getInclude().size());
}
use of org.alfresco.rest.framework.resource.parameters.Params in project alfresco-remote-api by Alfresco.
the class SearchApiWebscriptTests method testFilter.
@Test
public void testFilter() throws Exception {
Params params = webscript.getParams(null, null, null, null);
// Defaults
assertNotNull(params.getFilter());
params = webscript.getParams(null, null, Arrays.asList("name", "size"), null);
assertTrue("This isn't used until include is also specfied", params.getFilter().isAllowed("name"));
assertTrue("Anything is allowed if include hasn't been specfied", params.getFilter().isAllowed("horse"));
params = webscript.getParams(null, Arrays.asList("cat", "dog"), null, null);
assertTrue(params.getFilter().isAllowed("cat"));
assertTrue(params.getFilter().isAllowed("dog"));
assertFalse(params.getFilter().isAllowed("horse"));
params = webscript.getParams(null, Arrays.asList("cat", "dog"), Arrays.asList("name", "size"), null);
assertTrue(params.getFilter().isAllowed("cat"));
assertFalse(params.getFilter().isAllowed("horse"));
assertTrue("name and size should be automatically added to the filter list", params.getFilter().isAllowed("name"));
assertTrue("name and size should be automatically added to the filter list", params.getFilter().isAllowed("size"));
}
use of org.alfresco.rest.framework.resource.parameters.Params in project alfresco-remote-api by Alfresco.
the class ResourceWebScriptHelper method executeResource.
/**
* Executes a single related Resource. The results are added to list of embedded results used by
* the ExecutionResult object.
*
* @param api Api
* @param params Params
* @param uniqueEntityId String
* @param resourceKey String
* @param resource ResourceWithMetadata
* @return Object
*/
private Object executeResource(final Api api, Params params, final String uniqueEntityId, final String resourceKey, final ResourceWithMetadata resource) {
try {
BeanPropertiesFilter paramFilter = null;
final Object[] resultOfExecution = new Object[1];
Map<String, BeanPropertiesFilter> filters = params.getRelationsFilter();
if (filters != null) {
paramFilter = filters.get(resourceKey);
}
final Params executionParams = Params.valueOf(paramFilter, uniqueEntityId, params.getRequest());
final WithResponse callBack = new WithResponse(Status.STATUS_OK, ResponseWriter.DEFAULT_JSON_CONTENT, ResponseWriter.CACHE_NEVER);
// Read only because this only occurs for GET requests
Object result = executor.executeAction(resource, executionParams, callBack);
return processAdditionsToTheResponse(null, api, null, executionParams, result);
} catch (NotFoundException e) {
// ignore, cannot access the object so don't embed it
if (logger.isDebugEnabled()) {
logger.debug("Ignored error, cannot access the object so can't embed it ", e);
}
} catch (PermissionDeniedException e) {
// ignore, cannot access the object so don't embed it
if (logger.isDebugEnabled()) {
logger.debug("Ignored error, cannot access the object so can't embed it ", e);
}
} catch (Throwable throwable) {
logger.warn("Failed to execute a RelatedResource for " + resourceKey + " " + throwable.getMessage());
}
// default
return null;
}
use of org.alfresco.rest.framework.resource.parameters.Params in project records-management by Alfresco.
the class RMSiteEntityResourceUnitTest method deleteNonRMSite.
@Test
public void deleteNonRMSite() throws Exception {
String siteId = NON_RM_SITE_ID;
Params parameters = mock(Params.class);
when(parameters.getParameter(PERMANENT_PARAMETER)).thenReturn(null);
try {
rmSiteEntityResource.delete(siteId, parameters);
fail("Expected ecxeption as siteId was different than rm");
} catch (InvalidParameterException ex) {
assertEquals("The Deletion is supported only for siteId = rm.", ex.getMessage());
}
verify(mockedRMSites, never()).deleteRMSite(siteId, parameters);
}
Aggregations