use of org.alfresco.rest.framework.resource.parameters.Params 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.Params 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.Params in project alfresco-remote-api by Alfresco.
the class QuickShareLinksImpl method getParamsWithCreatedStatus.
private Parameters getParamsWithCreatedStatus() {
String filterStatusCreated = "(" + Renditions.PARAM_STATUS + "='" + Rendition.RenditionStatus.CREATED + "')";
Query whereQuery = getWhereClause(filterStatusCreated);
Params.RecognizedParams recParams = new Params.RecognizedParams(null, null, null, null, null, null, whereQuery, null, false);
Parameters params = Params.valueOf(recParams, null, null, null);
return params;
}
use of org.alfresco.rest.framework.resource.parameters.Params in project alfresco-remote-api by Alfresco.
the class SearchApiWebscript method execute.
@Override
public void execute(WebScriptRequest webScriptRequest, WebScriptResponse webScriptResponse) throws IOException {
try {
// Turn JSON into a Java object respresentation
SearchQuery searchQuery = extractJsonContent(webScriptRequest, assistant.getJsonHelper(), SearchQuery.class);
// Parse the parameters
Params params = getParams(webScriptRequest, searchQuery.getFields(), searchQuery.getInclude(), searchQuery.getPaging());
// Make a copy of the request
SearchRequestContext searchRequestContext = SearchRequestContext.from(searchQuery);
// Turn the SearchQuery json into the Java SearchParameters object
SearchParameters searchParams = searchMapper.toSearchParameters(params, searchQuery, searchRequestContext);
// Call searchService
ResultSet results = searchService.query(searchParams);
// Turn solr results into JSON
CollectionWithPagingInfo<Node> resultJson = resultMapper.toCollectionWithPagingInfo(params, searchRequestContext, searchQuery, results);
// Post-process the request and pass in params, eg. params.getFilter()
Object toRender = helper.processAdditionsToTheResponse(null, null, null, params, resultJson);
// Write response
setResponse(webScriptResponse, DEFAULT_SUCCESS);
renderJsonResponse(webScriptResponse, toRender, assistant.getJsonHelper());
} catch (Exception exception) {
renderException(exception, webScriptResponse, assistant);
}
}
use of org.alfresco.rest.framework.resource.parameters.Params in project alfresco-remote-api by Alfresco.
the class SearchApiWebscript method getParams.
/**
* Gets the Params object, parameters come from the SearchQuery json not the request
* @param webScriptRequest
* @param searchQuery
* @return Params
*/
protected Params getParams(WebScriptRequest webScriptRequest, List<String> fields, List<String> include, Paging paging) {
if (paging == null) {
paging = Paging.DEFAULT;
}
BeanPropertiesFilter filter = null;
if (fields != null && !fields.isEmpty()) {
List<String> selectList = new ArrayList<>(fields.size());
selectList.addAll(fields);
if (include != null && !include.isEmpty()) {
selectList.addAll(include);
}
filter = getFilter("", selectList);
}
Params.RecognizedParams recognizedParams = new Params.RecognizedParams(null, paging, filter, null, include, null, null, null, false);
return Params.valueOf(null, recognizedParams, null, webScriptRequest);
}
Aggregations