Search in sources :

Example 1 with RequiresFeature

use of eu.europa.ec.fisheries.uvms.rest.security.RequiresFeature in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogRestResource method getPollStatus.

@POST
@Consumes(value = { MediaType.APPLICATION_JSON })
@Produces(value = { MediaType.APPLICATION_JSON })
@Path(value = "/poll")
@RequiresFeature(UnionVMSFeature.viewExchange)
public ResponseDto getPollStatus(PollQuery query) {
    try {
        log.info("Get ExchangeLog status for Poll in rest layer:{}", query);
        Date from = DateUtils.stringToDate(query.getStatusFromDate());
        Date to = DateUtils.stringToDate(query.getStatusToDate());
        List<ExchangeLogStatusType> response = serviceLayer.getExchangeStatusHistoryList(query.getStatus(), TypeRefType.POLL, from, to);
        return new ResponseDto(response, RestResponseCode.OK);
    } catch (Exception e) {
        log.error("[ Error when getting config search fields. {}] {}", query, e.getMessage());
        return ErrorHandler.getFault(e);
    }
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) ResponseDto(eu.europa.ec.fisheries.uvms.exchange.rest.dto.ResponseDto) Date(java.util.Date) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) RequiresFeature(eu.europa.ec.fisheries.uvms.rest.security.RequiresFeature)

Example 2 with RequiresFeature

use of eu.europa.ec.fisheries.uvms.rest.security.RequiresFeature in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogRestResource method getPollStatus.

@GET
@Consumes(value = { MediaType.APPLICATION_JSON })
@Produces(value = { MediaType.APPLICATION_JSON })
@Path(value = "/poll/{typeRefGuid}")
@RequiresFeature(UnionVMSFeature.viewExchange)
public ResponseDto getPollStatus(@PathParam("typeRefGuid") String typeRefGuid) {
    try {
        log.info("Get ExchangeLog status for Poll by typeRefGuid:{}", typeRefGuid);
        ExchangeLogStatusType response = serviceLayer.getExchangeStatusHistory(TypeRefType.POLL, typeRefGuid, request.getRemoteUser());
        return new ResponseDto(response, RestResponseCode.OK);
    } catch (Exception e) {
        log.error("[ Error when getting config search fields. {} ] {}", typeRefGuid, e.getMessage());
        return ErrorHandler.getFault(e);
    }
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) ResponseDto(eu.europa.ec.fisheries.uvms.exchange.rest.dto.ResponseDto) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) RequiresFeature(eu.europa.ec.fisheries.uvms.rest.security.RequiresFeature)

Example 3 with RequiresFeature

use of eu.europa.ec.fisheries.uvms.rest.security.RequiresFeature in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogRestResource method getLogListByCriteria.

/**
 * @responseMessage 200 [Success]
 * @responseMessage 500 [Error]
 *
 * @summary Get a list of all exchangeLogs by search criterias
 */
@POST
@Consumes(value = { MediaType.APPLICATION_JSON })
@Produces(value = { MediaType.APPLICATION_JSON })
@Path("/list")
@RequiresFeature(UnionVMSFeature.viewExchange)
public ResponseDto getLogListByCriteria(final ExchangeListQuery query) {
    log.info("Get list invoked in rest layer:{}", query);
    try {
        // TODO query in swagger
        GetLogListByQueryResponse response = serviceLayer.getExchangeLogList(query);
        ListQueryResponse exchangeLogList = ExchangeLogMapper.mapToQueryResponse(response);
        return new ResponseDto(exchangeLogList, RestResponseCode.OK);
    } catch (Exception ex) {
        log.error("[ Error when geting log list. {} ] {} ", query, ex.getMessage());
        return ErrorHandler.getFault(ex);
    }
}
Also used : GetLogListByQueryResponse(eu.europa.ec.fisheries.schema.exchange.source.v1.GetLogListByQueryResponse) ResponseDto(eu.europa.ec.fisheries.uvms.exchange.rest.dto.ResponseDto) ListQueryResponse(eu.europa.ec.fisheries.uvms.exchange.rest.dto.exchange.ListQueryResponse) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) RequiresFeature(eu.europa.ec.fisheries.uvms.rest.security.RequiresFeature)

Aggregations

ResponseDto (eu.europa.ec.fisheries.uvms.exchange.rest.dto.ResponseDto)3 RequiresFeature (eu.europa.ec.fisheries.uvms.rest.security.RequiresFeature)3 Consumes (javax.ws.rs.Consumes)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)2 POST (javax.ws.rs.POST)2 GetLogListByQueryResponse (eu.europa.ec.fisheries.schema.exchange.source.v1.GetLogListByQueryResponse)1 ListQueryResponse (eu.europa.ec.fisheries.uvms.exchange.rest.dto.exchange.ListQueryResponse)1 Date (java.util.Date)1 GET (javax.ws.rs.GET)1