Merged searchapi (5.2.1) to 5.2.N (5.2.1)

129774 gjames: SEARCH-113: Moving more api logic to helper classes, using a "trait" style


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@130165 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gethin James
2016-09-06 14:14:29 +00:00
parent ff2ce9d706
commit bfd32ef859
26 changed files with 1555 additions and 1303 deletions

View File

@@ -39,6 +39,8 @@ import org.alfresco.rest.framework.jacksonextensions.JacksonHelper.Writer;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Paging;
import org.alfresco.rest.framework.resource.parameters.Params;
import org.alfresco.rest.framework.tools.RecognizedParamsExtractor;
import org.alfresco.rest.framework.tools.ResponseWriter;
import org.alfresco.rest.framework.webscripts.ApiWebScript;
import org.alfresco.rest.framework.webscripts.ResourceWebScriptHelper;
import org.codehaus.jackson.JsonGenerationException;
@@ -56,7 +58,7 @@ import org.springframework.extensions.webscripts.WebScriptResponse;
* @author steveglover
*
*/
public class NetworksWebScriptGet extends ApiWebScript
public class NetworksWebScriptGet extends ApiWebScript implements RecognizedParamsExtractor, ResponseWriter
{
private Networks networks;
private ResourceWebScriptHelper helper;
@@ -82,12 +84,12 @@ public class NetworksWebScriptGet extends ApiWebScript
@Override
public Void execute() throws Throwable
{
final Paging paging = ResourceWebScriptHelper.findPaging(req);
final Paging paging = findPaging(req);
// apply content type
res.setContentType(Format.JSON.mimetype() + ";charset=UTF-8");
assistant.getJsonHelper().withWriter(res.getOutputStream(), new Writer()
assistant.getJsonHelper().withWriter(res.getOutputStream(), new Writer()
{
@Override
public void writeContents(JsonGenerator generator, ObjectMapper objectMapper)
@@ -102,7 +104,7 @@ public class NetworksWebScriptGet extends ApiWebScript
{
// TODO this is not ideal, but the only way to populate the embedded network entities (this would normally be
// done automatically by the api framework).
Object wrapped = helper.processAdditionsToTheResponse(res, Api.ALFRESCO_PUBLIC, NetworksEntityResource.NAME, Params.valueOf(personId, null, req), networkMember);
Object wrapped = helper.processAdditionsToTheResponse(res, Api.ALFRESCO_PUBLIC, NetworksEntityResource.NAME, Params.valueOf(personId, null, req), networkMember);
entities.add(wrapped);
}
@@ -114,13 +116,13 @@ public class NetworksWebScriptGet extends ApiWebScript
}
}, true, true);
}
catch (ApiException | WebScriptException apiException)
catch (ApiException | WebScriptException apiException)
{
assistant.renderException(apiException, res);
renderException(apiException, res, assistant);
}
catch (RuntimeException runtimeException)
{
assistant.renderException(runtimeException, res);
renderException(runtimeException, res, assistant);
}
}
}