From 76799f1ae53ed60940b6376597686f9dd60153b4 Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Thu, 17 Jul 2014 15:36:05 +0200 Subject: [PATCH] Add 3 new Request classes for administrating Cynara Three added classes are: InsertOrUpdateBucketRequest - for inserting new bucket or modyfying default policy of existing one; RemoveBucketRequest - for removing bucket; SetPoliciesRequest - for modification of policies (adding, updating, removing). RequestTaker class has been extended with new execute() methods for processing newly added Request objects. Proper shared pointers definitions were added in request/pointers.h for supporting new Request types. Change-Id: I0a94eb9ce8326da4ccb9bd078d3a90b6bef25bfa --- src/common/CMakeLists.txt | 3 + src/common/request/InsertOrUpdateBucketRequest.cpp | 34 +++++++++++ src/common/request/InsertOrUpdateBucketRequest.h | 61 ++++++++++++++++++++ src/common/request/RemoveBucketRequest.cpp | 34 +++++++++++ src/common/request/RemoveBucketRequest.h | 54 +++++++++++++++++ src/common/request/RequestTaker.cpp | 14 +++++ src/common/request/RequestTaker.h | 3 + src/common/request/SetPoliciesRequest.cpp | 34 +++++++++++ src/common/request/SetPoliciesRequest.h | 67 ++++++++++++++++++++++ src/common/request/pointers.h | 9 +++ 10 files changed, 313 insertions(+) create mode 100644 src/common/request/InsertOrUpdateBucketRequest.cpp create mode 100644 src/common/request/InsertOrUpdateBucketRequest.h create mode 100644 src/common/request/RemoveBucketRequest.cpp create mode 100644 src/common/request/RemoveBucketRequest.h create mode 100644 src/common/request/SetPoliciesRequest.cpp create mode 100644 src/common/request/SetPoliciesRequest.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 9e7cece..39b9e47 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -32,7 +32,10 @@ SET(COMMON_SOURCES ${COMMON_PATH}/protocol/ProtocolSerialization.cpp ${COMMON_PATH}/protocol/ProtocolSignal.cpp ${COMMON_PATH}/request/CheckRequest.cpp + ${COMMON_PATH}/request/InsertOrUpdateBucketRequest.cpp + ${COMMON_PATH}/request/RemoveBucketRequest.cpp ${COMMON_PATH}/request/RequestTaker.cpp + ${COMMON_PATH}/request/SetPoliciesRequest.cpp ${COMMON_PATH}/request/SignalRequest.cpp ${COMMON_PATH}/response/CheckResponse.cpp ${COMMON_PATH}/response/ResponseTaker.cpp diff --git a/src/common/request/InsertOrUpdateBucketRequest.cpp b/src/common/request/InsertOrUpdateBucketRequest.cpp new file mode 100644 index 0000000..47900bc --- /dev/null +++ b/src/common/request/InsertOrUpdateBucketRequest.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 InsertOrUpdateBucketRequest.cpp + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file implements request class for inserting or updating policy bucket + */ + +#include + +#include "InsertOrUpdateBucketRequest.h" + +namespace Cynara { + +void InsertOrUpdateBucketRequest::execute(RequestPtr self, RequestTakerPtr taker, + RequestContextPtr context) const { + taker->execute(context, std::dynamic_pointer_cast(self)); +} + +} // namespace Cynara diff --git a/src/common/request/InsertOrUpdateBucketRequest.h b/src/common/request/InsertOrUpdateBucketRequest.h new file mode 100644 index 0000000..b166d71 --- /dev/null +++ b/src/common/request/InsertOrUpdateBucketRequest.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 InsertOrUpdateBucketRequest.h + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file defines request class for inserting or updating policy bucket + */ + +#ifndef SRC_COMMON_REQUEST_INSERTORUPDATEBUCKETREQUEST_H_ +#define SRC_COMMON_REQUEST_INSERTORUPDATEBUCKETREQUEST_H_ + +#include +#include + +#include +#include +#include + +namespace Cynara { + +class InsertOrUpdateBucketRequest : public Request { +private: + PolicyBucketId m_bucketId; + PolicyResult m_result; + +public: + InsertOrUpdateBucketRequest(const PolicyBucketId &bucketId, const PolicyResult &result, + ProtocolFrameSequenceNumber sequenceNumber) : + Request(sequenceNumber), m_bucketId(bucketId), m_result(result) { + } + + virtual ~InsertOrUpdateBucketRequest() = default; + + const PolicyBucketId &bucketId(void) const { + return m_bucketId; + } + + const PolicyResult &result(void) const { + return m_result; + } + + virtual void execute(RequestPtr self, RequestTakerPtr taker, RequestContextPtr context) const; +}; + +} // namespace Cynara + +#endif /* SRC_COMMON_REQUEST_INSERTORUPDATEBUCKETREQUEST_H_ */ diff --git a/src/common/request/RemoveBucketRequest.cpp b/src/common/request/RemoveBucketRequest.cpp new file mode 100644 index 0000000..69a2652 --- /dev/null +++ b/src/common/request/RemoveBucketRequest.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 RemoveBucketRequest.cpp + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file implements request class for bucket removal + */ + +#include + +#include "RemoveBucketRequest.h" + +namespace Cynara { + +void RemoveBucketRequest::execute(RequestPtr self, RequestTakerPtr taker, + RequestContextPtr context) const { + taker->execute(context, std::dynamic_pointer_cast(self)); +} + +} // namespace Cynara diff --git a/src/common/request/RemoveBucketRequest.h b/src/common/request/RemoveBucketRequest.h new file mode 100644 index 0000000..ff49a43 --- /dev/null +++ b/src/common/request/RemoveBucketRequest.h @@ -0,0 +1,54 @@ +/* + * 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 RemoveBucketRequest.h + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file defines request class for bucket removal + */ + +#ifndef SRC_COMMON_REQUEST_REMOVEBUCKETREQUEST_H_ +#define SRC_COMMON_REQUEST_REMOVEBUCKETREQUEST_H_ + +#include + +#include +#include +#include + +namespace Cynara { + +class RemoveBucketRequest : public Request { +private: + PolicyBucketId m_bucketId; + +public: + RemoveBucketRequest(const PolicyBucketId &bucketId, ProtocolFrameSequenceNumber sequenceNumber) + : Request(sequenceNumber), m_bucketId(bucketId) { + } + + virtual ~RemoveBucketRequest() = default; + + const PolicyBucketId &bucketId(void) const { + return m_bucketId; + } + + virtual void execute(RequestPtr self, RequestTakerPtr taker, RequestContextPtr context) const; +}; + +} // namespace Cynara + +#endif /* SRC_COMMON_REQUEST_REMOVEBUCKETREQUEST_H_ */ diff --git a/src/common/request/RequestTaker.cpp b/src/common/request/RequestTaker.cpp index 4ed8e7f..843c80e 100644 --- a/src/common/request/RequestTaker.cpp +++ b/src/common/request/RequestTaker.cpp @@ -33,6 +33,20 @@ void RequestTaker::execute(RequestContextPtr context UNUSED, CheckRequestPtr req throw NotImplementedException(); } +void RequestTaker::execute(RequestContextPtr context UNUSED, + InsertOrUpdateBucketRequestPtr request UNUSED) { + throw NotImplementedException(); +} + +void RequestTaker::execute(RequestContextPtr context UNUSED, + RemoveBucketRequestPtr request UNUSED) { + throw NotImplementedException(); +} + +void RequestTaker::execute(RequestContextPtr context UNUSED, SetPoliciesRequestPtr request UNUSED) { + throw NotImplementedException(); +} + void RequestTaker::execute(RequestContextPtr context UNUSED, SignalRequestPtr request UNUSED) { throw NotImplementedException(); } diff --git a/src/common/request/RequestTaker.h b/src/common/request/RequestTaker.h index 1739ba6..0c3ff7d 100644 --- a/src/common/request/RequestTaker.h +++ b/src/common/request/RequestTaker.h @@ -33,6 +33,9 @@ public: virtual ~RequestTaker() = default; virtual void execute(RequestContextPtr context, CheckRequestPtr request); + virtual void execute(RequestContextPtr context, InsertOrUpdateBucketRequestPtr request); + virtual void execute(RequestContextPtr context, RemoveBucketRequestPtr request); + virtual void execute(RequestContextPtr context, SetPoliciesRequestPtr request); virtual void execute(RequestContextPtr context, SignalRequestPtr request); }; diff --git a/src/common/request/SetPoliciesRequest.cpp b/src/common/request/SetPoliciesRequest.cpp new file mode 100644 index 0000000..e2bfb6f --- /dev/null +++ b/src/common/request/SetPoliciesRequest.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 SetPoliciesRequest.cpp + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file implements request class for modifying policies + */ + +#include + +#include "SetPoliciesRequest.h" + +namespace Cynara { + +void SetPoliciesRequest::execute(RequestPtr self, RequestTakerPtr taker, + RequestContextPtr context) const { + taker->execute(context, std::dynamic_pointer_cast(self)); +} + +} // namespace Cynara diff --git a/src/common/request/SetPoliciesRequest.h b/src/common/request/SetPoliciesRequest.h new file mode 100644 index 0000000..d876ad1 --- /dev/null +++ b/src/common/request/SetPoliciesRequest.h @@ -0,0 +1,67 @@ +/* + * 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 SetPoliciesRequest.h + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file defines request class for modifying policies + */ + +#ifndef SRC_COMMON_REQUEST_SETPOLICIESREQUEST_H_ +#define SRC_COMMON_REQUEST_SETPOLICIESREQUEST_H_ + +#include +#include + +#include +#include +#include + +#include +#include +#include + +namespace Cynara { + +class SetPoliciesRequest : public Request { +private: + std::map> m_insertOrUpdatePolicies; + std::map> m_removePolicies; + +public: + SetPoliciesRequest(const std::map> &insertOrUpdatePolicies, + const std::map> &removePolicies, + ProtocolFrameSequenceNumber sequenceNumber) : + Request(sequenceNumber), m_insertOrUpdatePolicies(insertOrUpdatePolicies), + m_removePolicies(removePolicies) { + } + + virtual ~SetPoliciesRequest() = default; + + const std::map> &policiesToBeInsertedOrUpdated(void) const { + return m_insertOrUpdatePolicies; + } + + const std::map> &policiesToBeRemoved(void) const { + return m_removePolicies; + } + + virtual void execute(RequestPtr self, RequestTakerPtr taker, RequestContextPtr context) const; +}; + +} // namespace Cynara + +#endif /* SRC_COMMON_REQUEST_SETPOLICIESREQUEST_H_ */ diff --git a/src/common/request/pointers.h b/src/common/request/pointers.h index b3c22e7..e04603e 100644 --- a/src/common/request/pointers.h +++ b/src/common/request/pointers.h @@ -30,6 +30,12 @@ namespace Cynara { class CheckRequest; typedef std::shared_ptr CheckRequestPtr; +class InsertOrUpdateBucketRequest; +typedef std::shared_ptr InsertOrUpdateBucketRequestPtr; + +class RemoveBucketRequest; +typedef std::shared_ptr RemoveBucketRequestPtr; + class Request; typedef std::shared_ptr RequestPtr; @@ -39,6 +45,9 @@ typedef std::shared_ptr RequestContextPtr; class RequestTaker; typedef std::shared_ptr RequestTakerPtr; +class SetPoliciesRequest; +typedef std::shared_ptr SetPoliciesRequestPtr; + class SignalRequest; typedef std::shared_ptr SignalRequestPtr; -- 2.7.4