Package com.dottydingo.service.endpoint.context

Examples of com.dottydingo.service.endpoint.context.EndpointResponse


{
    @Override
    protected void executePhase(HyperionContext phaseContext) throws Exception
    {
        EndpointRequest request = phaseContext.getEndpointRequest();
        EndpointResponse response = phaseContext.getEndpointResponse();

        EntityPlugin plugin = phaseContext.getEntityPlugin();
        List<Serializable> ids = plugin.getKeyConverter().covertKeys(phaseContext.getId());
        if(ids.size() != 1)
            throw new BadRequestException("A single ID must be provided.");

        Integer start = getIntegerParameter("start",request);
        Integer limit = getIntegerParameter("limit",request);

        if(start != null && start < 1)
            throw new BadRequestException("The start parameter must be greater than zero.");

        if(limit != null && limit < 1)
            throw new BadRequestException("The limit parameter must be greater than zero.");

        PersistenceContext persistenceContext = buildPersistenceContext(phaseContext);

        PersistenceOperations operations = persistenceContext.getEntityPlugin().getPersistenceOperations();
        QueryResult<HistoryEntry> entries = operations.getHistory(ids.get(0),start,limit,persistenceContext);

        HistoryResponse historyResponse = new HistoryResponse();
        historyResponse.setEntries(entries.getItems());
        historyResponse.setTotalCount(entries.getTotalCount());
        historyResponse.setStart(entries.getStart());
        historyResponse.setResponseCount(entries.getResponseCount());

        phaseContext.setResult(historyResponse);

        response.setResponseCode(200);
    }
View Full Code Here


    @Override
    protected void executePhase(HyperionContext phaseContext) throws Exception
    {
        EndpointRequest request = phaseContext.getEndpointRequest();
        EndpointResponse response = phaseContext.getEndpointResponse();

        Integer start = getIntegerParameter("start",request);
        Integer limit = getIntegerParameter("limit",request);

        String query = request.getFirstParameter("query");
        String sort = request.getFirstParameter("sort");

        if(start != null && start < 1)
            throw new BadRequestException("The start parameter must be greater than zero.");

        if(limit != null && limit < 1)
            throw new BadRequestException("The limit parameter must be greater than zero.");

        if(limit == null)
            limit = configuration.getDefaultLimit();

        if(limit > configuration.getMaxLimit())
            throw new BadRequestException(String.format("The limit parameter can not be greater than %d.",configuration.getMaxLimit()));

        PersistenceContext persistenceContext = buildPersistenceContext(phaseContext);
        QueryResult queryResult = phaseContext.getEntityPlugin().getPersistenceOperations().query(query, start, limit, sort, persistenceContext);

        EntityResponse entityResponse = new EntityResponse();
        entityResponse.setEntries(queryResult.getItems());
        entityResponse.setResponseCount(queryResult.getResponseCount());
        entityResponse.setStart(queryResult.getStart());
        entityResponse.setTotalCount(queryResult.getTotalCount());

        phaseContext.setResult(entityResponse);

        response.setResponseCode(200);


    }
View Full Code Here

TOP

Related Classes of com.dottydingo.service.endpoint.context.EndpointResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.