Add ListRequest - new class for listing policies 44/31044/3
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Sat, 29 Nov 2014 14:40:09 +0000 (15:40 +0100)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Wed, 10 Dec 2014 19:03:14 +0000 (20:03 +0100)
Introduced class wraps a request for policies list that can be sent
by admin of cynara. Request contains name of bucket that should be
searched and a policy key filter.

Change-Id: Ie12b8e5d3d997655bf5c4b8356d71ac5817dbb7f

src/common/CMakeLists.txt
src/common/request/ListRequest.cpp [new file with mode: 0644]
src/common/request/ListRequest.h [new file with mode: 0644]
src/common/request/RequestTaker.cpp
src/common/request/RequestTaker.h
src/common/request/pointers.h

index a8e0632..893d146 100644 (file)
@@ -45,6 +45,7 @@ SET(COMMON_SOURCES
     ${COMMON_PATH}/request/CancelRequest.cpp
     ${COMMON_PATH}/request/CheckRequest.cpp
     ${COMMON_PATH}/request/InsertOrUpdateBucketRequest.cpp
+    ${COMMON_PATH}/request/ListRequest.cpp
     ${COMMON_PATH}/request/RemoveBucketRequest.cpp
     ${COMMON_PATH}/request/RequestTaker.cpp
     ${COMMON_PATH}/request/SetPoliciesRequest.cpp
diff --git a/src/common/request/ListRequest.cpp b/src/common/request/ListRequest.cpp
new file mode 100644 (file)
index 0000000..f8e261e
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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/list/ListRequest.cpp
+ * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version     1.0
+ * @brief       This file implements policies list request class
+ */
+
+#include <memory>
+
+#include <request/RequestTaker.h>
+
+#include "ListRequest.h"
+
+namespace Cynara {
+
+void ListRequest::execute(RequestPtr self, RequestTakerPtr taker, RequestContextPtr context) const {
+    taker->execute(context, std::dynamic_pointer_cast<ListRequest>(self));
+}
+
+} // namespace Cynara
diff --git a/src/common/request/ListRequest.h b/src/common/request/ListRequest.h
new file mode 100644 (file)
index 0000000..069ea4a
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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/list/ListRequest.h
+ * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
+ * @version     1.0
+ * @brief       This file defines policies list request class
+ */
+
+#ifndef SRC_COMMON_REQUEST_LISTREQUEST_H_
+#define SRC_COMMON_REQUEST_LISTREQUEST_H_
+
+#include <types/PolicyBucketId.h>
+#include <types/PolicyKey.h>
+
+#include <request/pointers.h>
+#include <request/Request.h>
+
+namespace Cynara {
+
+class ListRequest : public Request {
+private:
+    PolicyBucketId m_bucket;
+    PolicyKey m_filter;
+
+public:
+    ListRequest(const PolicyBucketId &bucket, const PolicyKey &filter,
+                ProtocolFrameSequenceNumber sequenceNumber) :
+        Request(sequenceNumber), m_bucket(bucket), m_filter(filter) {
+    }
+
+    virtual ~ListRequest() {};
+
+    const PolicyBucketId &bucket(void) const {
+        return m_bucket;
+    }
+
+    const PolicyKey &filter(void) const {
+        return m_filter;
+    }
+
+    virtual void execute(RequestPtr self, RequestTakerPtr taker, RequestContextPtr context) const;
+};
+
+} // namespace Cynara
+
+#endif /* SRC_COMMON_REQUEST_LISTREQUEST_H_ */
index f46d428..bc6c7a1 100644 (file)
@@ -54,6 +54,10 @@ void RequestTaker::execute(RequestContextPtr context UNUSED,
     throw NotImplementedException();
 }
 
+void RequestTaker::execute(RequestContextPtr context UNUSED, ListRequestPtr request UNUSED) {
+    throw NotImplementedException();
+}
+
 void RequestTaker::execute(RequestContextPtr context UNUSED,
                            RemoveBucketRequestPtr request UNUSED) {
     throw NotImplementedException();
index f190e69..c36b5c9 100644 (file)
@@ -37,6 +37,7 @@ public:
     virtual void execute(RequestContextPtr context, AgentRegisterRequestPtr request);
     virtual void execute(RequestContextPtr context, CancelRequestPtr request);
     virtual void execute(RequestContextPtr context, CheckRequestPtr request);
+    virtual void execute(RequestContextPtr context, ListRequestPtr request);
     virtual void execute(RequestContextPtr context, InsertOrUpdateBucketRequestPtr request);
     virtual void execute(RequestContextPtr context, RemoveBucketRequestPtr request);
     virtual void execute(RequestContextPtr context, SetPoliciesRequestPtr request);
index 19429a9..d984c99 100644 (file)
@@ -45,6 +45,9 @@ typedef std::shared_ptr<CheckRequest> CheckRequestPtr;
 class InsertOrUpdateBucketRequest;
 typedef std::shared_ptr<InsertOrUpdateBucketRequest> InsertOrUpdateBucketRequestPtr;
 
+class ListRequest;
+typedef std::shared_ptr<ListRequest> ListRequestPtr;
+
 class RemoveBucketRequest;
 typedef std::shared_ptr<RemoveBucketRequest> RemoveBucketRequestPtr;