Package com.sequenceiq.cloudbreak.controller

Source Code of com.sequenceiq.cloudbreak.controller.AmazonSnsController

package com.sequenceiq.cloudbreak.controller;

import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sequenceiq.cloudbreak.domain.SnsRequest;
import com.sequenceiq.cloudbreak.service.stack.connector.aws.SnsMessageHandler;
import com.sequenceiq.cloudbreak.service.stack.connector.aws.SnsMessageParser;

@Controller
@RequestMapping("sns")
public class AmazonSnsController {

    @Autowired
    private SnsMessageParser snsMessageParser;

    @Autowired
    private SnsMessageHandler snsMessageHandler;

    @RequestMapping(method = RequestMethod.POST)
    @ResponseBody
    public ResponseEntity<String> receiveSnsMessage(@RequestBody String request) {
        try {
            SnsRequest snsRequest = snsMessageParser.parseRequest(request);
            snsMessageHandler.handleMessage(snsRequest);
            return new ResponseEntity<>(HttpStatus.OK);
        } catch (IOException e) {
            throw new InternalServerException("Failed to parse Amazon SNS message.", e);
        }
    }
}
TOP

Related Classes of com.sequenceiq.cloudbreak.controller.AmazonSnsController

TOP
Copyright © 2018 www.massapi.com. 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.