From c71c10a540191e8905dc6c1215b5b676dc3819d8 Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Fri, 5 Dec 2014 22:07:18 +0100 Subject: [PATCH] Introduce AdminCheckResponse class AdminCheckResponse is class for responses to AdminCheckRequests. It differs from CheckResponse as it contains additional information about existence of start bucket. Start bucket is BucketId provided by AdminCheckRequest from which policy search is started. Change-Id: I9858cfdb8a0acc0016a080eb850bbc65ec081a98 --- src/common/CMakeLists.txt | 1 + src/common/response/AdminCheckResponse.cpp | 34 +++++++++++++++++ src/common/response/AdminCheckResponse.h | 61 ++++++++++++++++++++++++++++++ src/common/response/ResponseTaker.cpp | 11 +++++- src/common/response/ResponseTaker.h | 1 + src/common/response/pointers.h | 3 ++ test/CMakeLists.txt | 1 + 7 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 src/common/response/AdminCheckResponse.cpp create mode 100644 src/common/response/AdminCheckResponse.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index f30d335..e01c325 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -50,6 +50,7 @@ SET(COMMON_SOURCES ${COMMON_PATH}/request/RequestTaker.cpp ${COMMON_PATH}/request/SetPoliciesRequest.cpp ${COMMON_PATH}/request/SignalRequest.cpp + ${COMMON_PATH}/response/AdminCheckResponse.cpp ${COMMON_PATH}/response/AgentActionResponse.cpp ${COMMON_PATH}/response/AgentRegisterResponse.cpp ${COMMON_PATH}/response/CancelResponse.cpp diff --git a/src/common/response/AdminCheckResponse.cpp b/src/common/response/AdminCheckResponse.cpp new file mode 100644 index 0000000..85ee425 --- /dev/null +++ b/src/common/response/AdminCheckResponse.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file src/common/response/AdminCheckResponse.cpp + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file implements admin check response class + */ + +#include + +#include "AdminCheckResponse.h" + +namespace Cynara { + +void AdminCheckResponse::execute(ResponsePtr self, ResponseTakerPtr taker, + RequestContextPtr context) const { + taker->execute(context, std::dynamic_pointer_cast(self)); +} + +} // namespace Cynara diff --git a/src/common/response/AdminCheckResponse.h b/src/common/response/AdminCheckResponse.h new file mode 100644 index 0000000..c2bbf30 --- /dev/null +++ b/src/common/response/AdminCheckResponse.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file src/common/response/AdminCheckResponse.h + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file defines response class for admin check request + */ + +#ifndef SRC_COMMON_RESPONSE_ADMINCHECKRESPONSE_H_ +#define SRC_COMMON_RESPONSE_ADMINCHECKRESPONSE_H_ + +#include + +#include +#include +#include + +namespace Cynara { + +class AdminCheckResponse : public Response { +public: + AdminCheckResponse(const PolicyResult &result, bool bucketValid, + ProtocolFrameSequenceNumber sequenceNumber) : + Response(sequenceNumber), m_result(result), m_bucketValid(bucketValid) { + } + + virtual ~AdminCheckResponse() {} + + virtual void execute(ResponsePtr self, ResponseTakerPtr taker, + RequestContextPtr context) const; + + const PolicyResult &result(void) const { + return m_result; + } + + bool isBucketValid(void) const { + return m_bucketValid; + } + +private: + const PolicyResult m_result; + bool m_bucketValid; +}; + +} // namespace Cynara + +#endif /* SRC_COMMON_RESPONSE_ADMINCHECKRESPONSE_H_ */ diff --git a/src/common/response/ResponseTaker.cpp b/src/common/response/ResponseTaker.cpp index 0de4371..af47659 100644 --- a/src/common/response/ResponseTaker.cpp +++ b/src/common/response/ResponseTaker.cpp @@ -28,11 +28,18 @@ namespace Cynara { -void ResponseTaker::execute(RequestContextPtr context UNUSED, AgentActionResponsePtr response UNUSED) { +void ResponseTaker::execute(RequestContextPtr context UNUSED, + AdminCheckResponsePtr response UNUSED) { throw NotImplementedException(); } -void ResponseTaker::execute(RequestContextPtr context UNUSED, AgentRegisterResponsePtr response UNUSED) { +void ResponseTaker::execute(RequestContextPtr context UNUSED, + AgentActionResponsePtr response UNUSED) { + throw NotImplementedException(); +} + +void ResponseTaker::execute(RequestContextPtr context UNUSED, + AgentRegisterResponsePtr response UNUSED) { throw NotImplementedException(); } diff --git a/src/common/response/ResponseTaker.h b/src/common/response/ResponseTaker.h index 721dc2a..20296af 100644 --- a/src/common/response/ResponseTaker.h +++ b/src/common/response/ResponseTaker.h @@ -33,6 +33,7 @@ public: ResponseTaker() = default; virtual ~ResponseTaker() {}; + virtual void execute(RequestContextPtr context, AdminCheckResponsePtr response); virtual void execute(RequestContextPtr context, AgentActionResponsePtr response); virtual void execute(RequestContextPtr context, AgentRegisterResponsePtr response); virtual void execute(RequestContextPtr context, CancelResponsePtr response); diff --git a/src/common/response/pointers.h b/src/common/response/pointers.h index c5fdb1d..5e26929 100644 --- a/src/common/response/pointers.h +++ b/src/common/response/pointers.h @@ -27,6 +27,9 @@ namespace Cynara { +class AdminCheckResponse; +typedef std::shared_ptr AdminCheckResponsePtr; + class AgentActionResponse; typedef std::shared_ptr AgentActionResponsePtr; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 19b8f13..5bb0a7e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -34,6 +34,7 @@ SET(CYNARA_SOURCES_FOR_TESTS ${CYNARA_SRC}/common/request/RemoveBucketRequest.cpp ${CYNARA_SRC}/common/request/RequestTaker.cpp ${CYNARA_SRC}/common/request/SetPoliciesRequest.cpp + ${CYNARA_SRC}/common/response/AdminCheckResponse.cpp ${CYNARA_SRC}/common/response/CheckResponse.cpp ${CYNARA_SRC}/common/response/CodeResponse.cpp ${CYNARA_SRC}/common/response/ListResponse.cpp -- 2.7.4