Introduce AdminCheckResponse class 66/31566/6
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Fri, 5 Dec 2014 21:07:18 +0000 (22:07 +0100)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Mon, 15 Dec 2014 14:38:18 +0000 (15:38 +0100)
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
src/common/response/AdminCheckResponse.cpp [new file with mode: 0644]
src/common/response/AdminCheckResponse.h [new file with mode: 0644]
src/common/response/ResponseTaker.cpp
src/common/response/ResponseTaker.h
src/common/response/pointers.h
test/CMakeLists.txt

index f30d335..e01c325 100644 (file)
@@ -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 (file)
index 0000000..85ee425
--- /dev/null
@@ -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 <l.wojciechow@partner.samsung.com>
+ * @version     1.0
+ * @brief       This file implements admin check response class
+ */
+
+#include <memory>
+
+#include "AdminCheckResponse.h"
+
+namespace Cynara {
+
+void AdminCheckResponse::execute(ResponsePtr self, ResponseTakerPtr taker,
+                                 RequestContextPtr context) const {
+    taker->execute(context, std::dynamic_pointer_cast<AdminCheckResponse>(self));
+}
+
+} // namespace Cynara
diff --git a/src/common/response/AdminCheckResponse.h b/src/common/response/AdminCheckResponse.h
new file mode 100644 (file)
index 0000000..c2bbf30
--- /dev/null
@@ -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 <l.wojciechow@partner.samsung.com>
+ * @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 <types/PolicyResult.h>
+
+#include <request/pointers.h>
+#include <response/pointers.h>
+#include <response/Response.h>
+
+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_ */
index 0de4371..af47659 100644 (file)
 
 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();
 }
 
index 721dc2a..20296af 100644 (file)
@@ -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);
index c5fdb1d..5e26929 100644 (file)
@@ -27,6 +27,9 @@
 
 namespace Cynara {
 
+class AdminCheckResponse;
+typedef std::shared_ptr<AdminCheckResponse> AdminCheckResponsePtr;
+
 class AgentActionResponse;
 typedef std::shared_ptr<AgentActionResponse> AgentActionResponsePtr;
 
index 19b8f13..5bb0a7e 100644 (file)
@@ -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