diff --git a/include/caosdb/file_transmission/download_request_handler.h b/include/caosdb/file_transmission/download_request_handler.h index 2cdfbbca139cc184aa6f95d8dad35daef57f445b..c6ee1c36b67c637c8faad901f590a4eee318b7b5 100644 --- a/include/caosdb/file_transmission/download_request_handler.h +++ b/include/caosdb/file_transmission/download_request_handler.h @@ -1,3 +1,54 @@ +/* + * This file is a part of the CaosDB Project. + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + ********************************************************************************* + * + * This is derived work which is heavily based on + * https://github.com/NeiRo21/grpcpp-bidi-streaming, Commit + * cd9cb78e5d6d72806c2ec4c703e5e856b223dc96, Aug 10, 2020 + * + * The orginal work is licensed as + * + * > MIT License + * > + * > Copyright (c) 2019 NeiRo21 + * > + * > Permission is hereby granted, free of charge, to any person obtaining a + * > copy of this software and associated documentation files (the "Software"), + * > to deal in the Software without restriction, including without limitation + * > the rights to use, copy, modify, merge, publish, distribute, sublicense, + * > and/or sell copies of the Software, and to permit persons to whom the + * > Software is furnished to do so, subject to the following conditions: + * > + * > The above copyright notice and this permission notice shall be included in + * > all copies or substantial portions of the Software. + * > + * > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * > DEALINGS IN THE SOFTWARE. + */ +#ifndef CAOSDB_FILE_TRANSMISSION_DOWNLOAD_REQUEST_HANDLER_H +#define CAOSDB_FILE_TRANSMISSION_DOWNLOAD_REQUEST_HANDLER_H + #include "caosdb/entity.h" // for FileDescriptor #include "caosdb/entity/v1alpha1/main.grpc.pb.h" // for FileTransmissionS... #include "caosdb/entity/v1alpha1/main.pb.h" // for FileDownloadResponse @@ -66,3 +117,5 @@ protected: }; } // namespace caosdb::transaction + +#endif diff --git a/include/caosdb/file_transmission/file_error.h b/include/caosdb/file_transmission/file_error.h index b34d47f25f2eb28c2fb5b0df2a0bd3ccfe485c95..ae057be3ba47f894f8fdbc22adb6e6d56accdafd 100644 --- a/include/caosdb/file_transmission/file_error.h +++ b/include/caosdb/file_transmission/file_error.h @@ -1,4 +1,53 @@ -#pragma once +/* + * This file is a part of the CaosDB Project. + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + ********************************************************************************* + * + * This is derived work which is heavily based on + * https://github.com/NeiRo21/grpcpp-bidi-streaming, Commit + * cd9cb78e5d6d72806c2ec4c703e5e856b223dc96, Aug 10, 2020 + * + * The orginal work is licensed as + * + * > MIT License + * > + * > Copyright (c) 2019 NeiRo21 + * > + * > Permission is hereby granted, free of charge, to any person obtaining a + * > copy of this software and associated documentation files (the "Software"), + * > to deal in the Software without restriction, including without limitation + * > the rights to use, copy, modify, merge, publish, distribute, sublicense, + * > and/or sell copies of the Software, and to permit persons to whom the + * > Software is furnished to do so, subject to the following conditions: + * > + * > The above copyright notice and this permission notice shall be included in + * > all copies or substantial portions of the Software. + * > + * > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * > DEALINGS IN THE SOFTWARE. + */ +#ifndef CAOSDB_FILE_TRANSMISSION_FILE_ERROR_H +#define CAOSDB_FILE_TRANSMISSION_FILE_ERROR_H #include <stdexcept> #include <string> @@ -11,3 +60,5 @@ public: }; } // namespace caosdb::transaction + +#endif diff --git a/include/caosdb/file_transmission/file_reader.h b/include/caosdb/file_transmission/file_reader.h index 1e881eb237e5676511255c5de662008a877ffd1f..67c1247fa97cc43e28064b4e0da81812f41b231a 100644 --- a/include/caosdb/file_transmission/file_reader.h +++ b/include/caosdb/file_transmission/file_reader.h @@ -1,10 +1,58 @@ -#pragma once +/* + * This file is a part of the CaosDB Project. + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + ********************************************************************************* + * + * This is derived work which is heavily based on + * https://github.com/NeiRo21/grpcpp-bidi-streaming, Commit + * cd9cb78e5d6d72806c2ec4c703e5e856b223dc96, Aug 10, 2020 + * + * The orginal work is licensed as + * + * > MIT License + * > + * > Copyright (c) 2019 NeiRo21 + * > + * > Permission is hereby granted, free of charge, to any person obtaining a + * > copy of this software and associated documentation files (the "Software"), + * > to deal in the Software without restriction, including without limitation + * > the rights to use, copy, modify, merge, publish, distribute, sublicense, + * > and/or sell copies of the Software, and to permit persons to whom the + * > Software is furnished to do so, subject to the following conditions: + * > + * > The above copyright notice and this permission notice shall be included in + * > all copies or substantial portions of the Software. + * > + * > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * > DEALINGS IN THE SOFTWARE. + */ +#ifndef CAOSDB_FILE_TRANSMISSION_FILE_READER_H +#define CAOSDB_FILE_TRANSMISSION_FILE_READER_H #include <boost/filesystem/fstream.hpp> // for ifstream #include <boost/filesystem/operations.hpp> // for exists #include <boost/filesystem/path.hpp> // for path #include <fstream> // for ifstream, size_t -#include <memory> // for shared_ptr #include <string> // for string namespace caosdb::transaction { @@ -37,3 +85,5 @@ private: }; } // namespace caosdb::transaction + +#endif diff --git a/include/caosdb/file_transmission/file_writer.h b/include/caosdb/file_transmission/file_writer.h index a300eab18de9164b6dad939ab4fa713f17fdc457..801d74b9547951d2a3b86ed4b333bfb4b7035aa9 100644 --- a/include/caosdb/file_transmission/file_writer.h +++ b/include/caosdb/file_transmission/file_writer.h @@ -1,8 +1,56 @@ -#pragma once +/* + * This file is a part of the CaosDB Project. + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + ********************************************************************************* + * + * This is derived work which is heavily based on + * https://github.com/NeiRo21/grpcpp-bidi-streaming, Commit + * cd9cb78e5d6d72806c2ec4c703e5e856b223dc96, Aug 10, 2020 + * + * The orginal work is licensed as + * + * > MIT License + * > + * > Copyright (c) 2019 NeiRo21 + * > + * > Permission is hereby granted, free of charge, to any person obtaining a + * > copy of this software and associated documentation files (the "Software"), + * > to deal in the Software without restriction, including without limitation + * > the rights to use, copy, modify, merge, publish, distribute, sublicense, + * > and/or sell copies of the Software, and to permit persons to whom the + * > Software is furnished to do so, subject to the following conditions: + * > + * > The above copyright notice and this permission notice shall be included in + * > all copies or substantial portions of the Software. + * > + * > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * > DEALINGS IN THE SOFTWARE. + */ +#ifndef CAOSDB_FILE_TRANSMISSION_FILE_WRITER_H +#define CAOSDB_FILE_TRANSMISSION_FILE_WRITER_H #include <boost/filesystem/path.hpp> // for path #include <fstream> // for ofstream -#include <memory> // for shared_ptr #include <string> // for string namespace caosdb::transaction { @@ -29,3 +77,5 @@ private: }; } // namespace caosdb::transaction + +#endif diff --git a/include/caosdb/file_transmission/register_file_upload_handler.h b/include/caosdb/file_transmission/register_file_upload_handler.h index 0d41b947eebf92b50ac6b33b97f0dc67bf6bad9c..17a42c0a2a2cf1d591048abb6e4c8b329bfd008c 100644 --- a/include/caosdb/file_transmission/register_file_upload_handler.h +++ b/include/caosdb/file_transmission/register_file_upload_handler.h @@ -1,4 +1,54 @@ -#pragma once +/* + * This file is a part of the CaosDB Project. + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + ********************************************************************************* + * + * This is derived work which is heavily based on + * https://github.com/NeiRo21/grpcpp-bidi-streaming, Commit + * cd9cb78e5d6d72806c2ec4c703e5e856b223dc96, Aug 10, 2020 + * + * The orginal work is licensed as + * + * > MIT License + * > + * > Copyright (c) 2019 NeiRo21 + * > + * > Permission is hereby granted, free of charge, to any person obtaining a + * > copy of this software and associated documentation files (the "Software"), + * > to deal in the Software without restriction, including without limitation + * > the rights to use, copy, modify, merge, publish, distribute, sublicense, + * > and/or sell copies of the Software, and to permit persons to whom the + * > Software is furnished to do so, subject to the following conditions: + * > + * > The above copyright notice and this permission notice shall be included in + * > all copies or substantial portions of the Software. + * > + * > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * > DEALINGS IN THE SOFTWARE. + */ +#ifndef CAOSDB_FILE_TRANSMISSION_REGISTER_FILE_UPLOAD_H +#define CAOSDB_FILE_TRANSMISSION_REGISTER_FILE_UPLOAD_H + #include "caosdb/entity/v1alpha1/main.grpc.pb.h" // for FileTransmissionS... #include "caosdb/entity/v1alpha1/main.pb.h" // for FileDownloadResponse #include "caosdb/handler_interface.h" // for HandlerTag, Handl... @@ -30,7 +80,6 @@ public: protected: void handleNewCallState() override; - void handleReceivingFileState() override; HandlerTag tag_; @@ -44,3 +93,5 @@ protected: }; } // namespace caosdb::transaction + +#endif diff --git a/include/caosdb/file_transmission/upload_request_handler.h b/include/caosdb/file_transmission/upload_request_handler.h index 440f8b56de691cf48da103be554c9429024d3d4a..54621d12ba7d67d374037ecdb1f1259662071319 100644 --- a/include/caosdb/file_transmission/upload_request_handler.h +++ b/include/caosdb/file_transmission/upload_request_handler.h @@ -1,3 +1,54 @@ +/* + * This file is a part of the CaosDB Project. + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + ********************************************************************************* + * + * This is derived work which is heavily based on + * https://github.com/NeiRo21/grpcpp-bidi-streaming, Commit + * cd9cb78e5d6d72806c2ec4c703e5e856b223dc96, Aug 10, 2020 + * + * The orginal work is licensed as + * + * > MIT License + * > + * > Copyright (c) 2019 NeiRo21 + * > + * > Permission is hereby granted, free of charge, to any person obtaining a + * > copy of this software and associated documentation files (the "Software"), + * > to deal in the Software without restriction, including without limitation + * > the rights to use, copy, modify, merge, publish, distribute, sublicense, + * > and/or sell copies of the Software, and to permit persons to whom the + * > Software is furnished to do so, subject to the following conditions: + * > + * > The above copyright notice and this permission notice shall be included in + * > all copies or substantial portions of the Software. + * > + * > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * > DEALINGS IN THE SOFTWARE. + */ +#ifndef CAOSDB_FILE_TRANSMISSION_UPLOAD_REQUEST_HANDLER_H +#define CAOSDB_FILE_TRANSMISSION_UPLOAD_REQUEST_HANDLER_H + #include "caosdb/entity.h" // for FileDescriptor #include "caosdb/entity/v1alpha1/main.grpc.pb.h" // for FileTransmissionS... #include "caosdb/entity/v1alpha1/main.pb.h" // for FileUploadRequest @@ -74,3 +125,5 @@ protected: }; } // namespace caosdb::transaction + +#endif diff --git a/include/caosdb/transaction_handler.h b/include/caosdb/transaction_handler.h index 69df4f0b370c5cdcc9515a916e36c1c899fd3397..0a7154d03dfbde19284807d1e1f40998c89e1de0 100644 --- a/include/caosdb/transaction_handler.h +++ b/include/caosdb/transaction_handler.h @@ -30,7 +30,6 @@ public: protected: virtual void handleNewCallState() override; - virtual void handleReceivingFileState() override; HandlerTag tag_; diff --git a/include/caosdb/unary_rpc_handler.h b/include/caosdb/unary_rpc_handler.h index a8f83c19885a17c7ed9434d4752a27831b8642e4..6955504a2baea38cb0bd8075bdca2d20c9f8a52a 100644 --- a/include/caosdb/unary_rpc_handler.h +++ b/include/caosdb/unary_rpc_handler.h @@ -1,4 +1,54 @@ -#pragma once +/* + * This file is a part of the CaosDB Project. + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + ********************************************************************************* + * + * This is derived work which is heavily based on + * https://github.com/NeiRo21/grpcpp-bidi-streaming, Commit + * cd9cb78e5d6d72806c2ec4c703e5e856b223dc96, Aug 10, 2020 + * + * The orginal work is licensed as + * + * > MIT License + * > + * > Copyright (c) 2019 NeiRo21 + * > + * > Permission is hereby granted, free of charge, to any person obtaining a + * > copy of this software and associated documentation files (the "Software"), + * > to deal in the Software without restriction, including without limitation + * > the rights to use, copy, modify, merge, publish, distribute, sublicense, + * > and/or sell copies of the Software, and to permit persons to whom the + * > Software is furnished to do so, subject to the following conditions: + * > + * > The above copyright notice and this permission notice shall be included in + * > all copies or substantial portions of the Software. + * > + * > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * > DEALINGS IN THE SOFTWARE. + */ +#ifndef CAOSDB_UNARY_RPC_HANDLER_H +#define CAOSDB_UNARY_RPC_HANDLER_H + #include "caosdb/handler_interface.h" // for HandlerTag, Handl... #include "caosdb/transaction_status.h" // for TransactionStatus #include <grpcpp/impl/codegen/client_context.h> // for ClientContext @@ -24,10 +74,9 @@ public: protected: virtual void handleNewCallState() = 0; - virtual void handleReceivingFileState() = 0; void handleCallCompleteState(); - enum class CallState { NewCall, ReceivingFile, CallComplete }; + enum class CallState { NewCall, CallComplete }; CallState state_; grpc::CompletionQueue *completion_queue; @@ -36,3 +85,5 @@ protected: }; } // namespace caosdb::transaction + +#endif diff --git a/src/caosdb/file_transmission/download_request_handler.cpp b/src/caosdb/file_transmission/download_request_handler.cpp index 68dfff32c7cae61b41c1b70aeef51b8530b6a11e..fb36ca5b46cbf2c4f08c2c06bc9faf6b00e038be 100644 --- a/src/caosdb/file_transmission/download_request_handler.cpp +++ b/src/caosdb/file_transmission/download_request_handler.cpp @@ -1,3 +1,51 @@ +/* + * This file is a part of the CaosDB Project. + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + ********************************************************************************* + * + * This is derived work which is heavily based on + * https://github.com/NeiRo21/grpcpp-bidi-streaming, Commit + * cd9cb78e5d6d72806c2ec4c703e5e856b223dc96, Aug 10, 2020 + * + * The orginal work is licensed as + * + * > MIT License + * > + * > Copyright (c) 2019 NeiRo21 + * > + * > Permission is hereby granted, free of charge, to any person obtaining a + * > copy of this software and associated documentation files (the "Software"), + * > to deal in the Software without restriction, including without limitation + * > the rights to use, copy, modify, merge, publish, distribute, sublicense, + * > and/or sell copies of the Software, and to permit persons to whom the + * > Software is furnished to do so, subject to the following conditions: + * > + * > The above copyright notice and this permission notice shall be included in + * > all copies or substantial portions of the Software. + * > + * > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * > DEALINGS IN THE SOFTWARE. + */ #include "caosdb/file_transmission/download_request_handler.h" #include "caosdb/logging.h" // for CAOSDB_LOG_TRACE #include "caosdb/protobuf_helper.h" // for get_arena @@ -91,6 +139,7 @@ void DownloadRequestHandler::handleNewCallState() { rpc_ = stub_->PrepareAsyncFileDownload(&ctx_, *request_, cq_); + transaction_status = TransactionStatus::EXECUTING(); state_ = CallState::SendingRequest; rpc_->StartCall(tag_); CAOSDB_LOG_TRACE(logger_name) diff --git a/src/caosdb/file_transmission/file_reader.cpp b/src/caosdb/file_transmission/file_reader.cpp index 5251af1faadb878e47e56f589196659800808442..2df58c9accbde99c9bc908ed7f80ceef7685b573 100644 --- a/src/caosdb/file_transmission/file_reader.cpp +++ b/src/caosdb/file_transmission/file_reader.cpp @@ -1,3 +1,51 @@ +/* + * This file is a part of the CaosDB Project. + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + ********************************************************************************* + * + * This is derived work which is heavily based on + * https://github.com/NeiRo21/grpcpp-bidi-streaming, Commit + * cd9cb78e5d6d72806c2ec4c703e5e856b223dc96, Aug 10, 2020 + * + * The orginal work is licensed as + * + * > MIT License + * > + * > Copyright (c) 2019 NeiRo21 + * > + * > Permission is hereby granted, free of charge, to any person obtaining a + * > copy of this software and associated documentation files (the "Software"), + * > to deal in the Software without restriction, including without limitation + * > the rights to use, copy, modify, merge, publish, distribute, sublicense, + * > and/or sell copies of the Software, and to permit persons to whom the + * > Software is furnished to do so, subject to the following conditions: + * > + * > The above copyright notice and this permission notice shall be included in + * > all copies or substantial portions of the Software. + * > + * > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * > DEALINGS IN THE SOFTWARE. + */ #include "caosdb/file_transmission/file_reader.h" #include "caosdb/file_transmission/file_error.h" // for FileIOError #include <boost/filesystem/path.hpp> // for path diff --git a/src/caosdb/file_transmission/file_writer.cpp b/src/caosdb/file_transmission/file_writer.cpp index 314928ed2e84d5a01908c9aec42ebea8390d77be..73b604d4255b213d015e010ea987fdb6a9918f6c 100644 --- a/src/caosdb/file_transmission/file_writer.cpp +++ b/src/caosdb/file_transmission/file_writer.cpp @@ -1,3 +1,51 @@ +/* + * This file is a part of the CaosDB Project. + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + ********************************************************************************* + * + * This is derived work which is heavily based on + * https://github.com/NeiRo21/grpcpp-bidi-streaming, Commit + * cd9cb78e5d6d72806c2ec4c703e5e856b223dc96, Aug 10, 2020 + * + * The orginal work is licensed as + * + * > MIT License + * > + * > Copyright (c) 2019 NeiRo21 + * > + * > Permission is hereby granted, free of charge, to any person obtaining a + * > copy of this software and associated documentation files (the "Software"), + * > to deal in the Software without restriction, including without limitation + * > the rights to use, copy, modify, merge, publish, distribute, sublicense, + * > and/or sell copies of the Software, and to permit persons to whom the + * > Software is furnished to do so, subject to the following conditions: + * > + * > The above copyright notice and this permission notice shall be included in + * > all copies or substantial portions of the Software. + * > + * > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * > DEALINGS IN THE SOFTWARE. + */ #include "caosdb/file_transmission/file_writer.h" #include "caosdb/file_transmission/file_error.h" // for FileIOError #include <boost/filesystem/path.hpp> // for path diff --git a/src/caosdb/file_transmission/register_file_upload_handler.cpp b/src/caosdb/file_transmission/register_file_upload_handler.cpp index 2661756cdc565516a7ec6dfa74fde36bf2f1cc7e..b2020223f1c79f69e77b1e0950bac1c8f1220986 100644 --- a/src/caosdb/file_transmission/register_file_upload_handler.cpp +++ b/src/caosdb/file_transmission/register_file_upload_handler.cpp @@ -1,3 +1,51 @@ +/* + * This file is a part of the CaosDB Project. + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + ********************************************************************************* + * + * This is derived work which is heavily based on + * https://github.com/NeiRo21/grpcpp-bidi-streaming, Commit + * cd9cb78e5d6d72806c2ec4c703e5e856b223dc96, Aug 10, 2020 + * + * The orginal work is licensed as + * + * > MIT License + * > + * > Copyright (c) 2019 NeiRo21 + * > + * > Permission is hereby granted, free of charge, to any person obtaining a + * > copy of this software and associated documentation files (the "Software"), + * > to deal in the Software without restriction, including without limitation + * > the rights to use, copy, modify, merge, publish, distribute, sublicense, + * > and/or sell copies of the Software, and to permit persons to whom the + * > Software is furnished to do so, subject to the following conditions: + * > + * > The above copyright notice and this permission notice shall be included in + * > all copies or substantial portions of the Software. + * > + * > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * > DEALINGS IN THE SOFTWARE. + */ #include "caosdb/file_transmission/register_file_upload_handler.h" #include "caosdb/logging.h" // for CAOSDB_LOG_TRACE #include <boost/log/core/record.hpp> // for record @@ -33,6 +81,4 @@ void RegisterFileUploadHandler::handleNewCallState() { << "Leave RegisterFileUploadHandler::handleNewCallState"; } -void RegisterFileUploadHandler::handleReceivingFileState() {} - } // namespace caosdb::transaction diff --git a/src/caosdb/file_transmission/upload_request_handler.cpp b/src/caosdb/file_transmission/upload_request_handler.cpp index 7cf31c0304540e1f86df7624a0318dfb84d6db91..27926bfaabe4dd18feca80f191ff496573196e52 100644 --- a/src/caosdb/file_transmission/upload_request_handler.cpp +++ b/src/caosdb/file_transmission/upload_request_handler.cpp @@ -1,3 +1,51 @@ +/* + * This file is a part of the CaosDB Project. + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + ********************************************************************************* + * + * This is derived work which is heavily based on + * https://github.com/NeiRo21/grpcpp-bidi-streaming, Commit + * cd9cb78e5d6d72806c2ec4c703e5e856b223dc96, Aug 10, 2020 + * + * The orginal work is licensed as + * + * > MIT License + * > + * > Copyright (c) 2019 NeiRo21 + * > + * > Permission is hereby granted, free of charge, to any person obtaining a + * > copy of this software and associated documentation files (the "Software"), + * > to deal in the Software without restriction, including without limitation + * > the rights to use, copy, modify, merge, publish, distribute, sublicense, + * > and/or sell copies of the Software, and to permit persons to whom the + * > Software is furnished to do so, subject to the following conditions: + * > + * > The above copyright notice and this permission notice shall be included in + * > all copies or substantial portions of the Software. + * > + * > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * > DEALINGS IN THE SOFTWARE. + */ #include "caosdb/file_transmission/upload_request_handler.h" #include "caosdb/logging.h" // for CAOSDB_LOG_ERROR #include "caosdb/protobuf_helper.h" // for get_arena diff --git a/src/caosdb/transaction_handler.cpp b/src/caosdb/transaction_handler.cpp index 61b69a2e52d9c675d78c96e37329ae57f8cda04d..cf020af35bf56b2e68da11a92b0961995397f2fd 100644 --- a/src/caosdb/transaction_handler.cpp +++ b/src/caosdb/transaction_handler.cpp @@ -1,13 +1,15 @@ #include "caosdb/transaction_handler.h" -#include "caosdb/logging.h" // for CAOSDB_LOG_TRACE -#include <boost/log/core/record.hpp> // for record -#include <boost/log/sources/record_ostream.hpp> // for basic_record_... -#include <boost/preprocessor/seq/limits/enum_256.hpp> // for BOOST_PP_SEQ_... -#include <boost/preprocessor/seq/limits/size_256.hpp> // for BOOST_PP_SEQ_... -#include <exception> // IWYU pragma: keep +#include "caosdb/logging.h" // for CAOSDB_LOG_TRACE +#include <boost/log/core/record.hpp> // for record +#include <boost/log/detail/attachable_sstream_buf.hpp> // for basic_ostring... +#include <boost/log/sources/record_ostream.hpp> // for basic_record_... +#include <boost/preprocessor/seq/limits/enum_256.hpp> // for BOOST_PP_SEQ_... +#include <boost/preprocessor/seq/limits/size_256.hpp> // for BOOST_PP_SEQ_... +#include <exception> // IWYU pragma: keep // IWYU pragma: no_include <bits/exception.h> #include <grpcpp/impl/codegen/async_unary_call.h> // for ClientAsyncRes... #include <grpcpp/impl/codegen/completion_queue.h> // for CompletionQueue +#include <iosfwd> // for streamsize namespace caosdb::transaction { @@ -35,8 +37,4 @@ void EntityTransactionHandler::handleNewCallState() { << "Leave EntityTransactionHandler::handleNewCallState"; } -void EntityTransactionHandler::handleReceivingFileState() { - // TODO(tf) remove -} - } // namespace caosdb::transaction diff --git a/src/caosdb/unary_rpc_handler.cpp b/src/caosdb/unary_rpc_handler.cpp index 060f4c0dc4009afccd6420cb9856cb13a30006e5..4d1e1cf618ef119278b02fdc3657d17482a87601 100644 --- a/src/caosdb/unary_rpc_handler.cpp +++ b/src/caosdb/unary_rpc_handler.cpp @@ -1,3 +1,51 @@ +/* + * This file is a part of the CaosDB Project. + * Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + * Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + ********************************************************************************* + * + * This is derived work which is heavily based on + * https://github.com/NeiRo21/grpcpp-bidi-streaming, Commit + * cd9cb78e5d6d72806c2ec4c703e5e856b223dc96, Aug 10, 2020 + * + * The orginal work is licensed as + * + * > MIT License + * > + * > Copyright (c) 2019 NeiRo21 + * > + * > Permission is hereby granted, free of charge, to any person obtaining a + * > copy of this software and associated documentation files (the "Software"), + * > to deal in the Software without restriction, including without limitation + * > the rights to use, copy, modify, merge, publish, distribute, sublicense, + * > and/or sell copies of the Software, and to permit persons to whom the + * > Software is furnished to do so, subject to the following conditions: + * > + * > The above copyright notice and this permission notice shall be included in + * > all copies or substantial portions of the Software. + * > + * > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * > DEALINGS IN THE SOFTWARE. + */ #include "caosdb/unary_rpc_handler.h" #include "caosdb/logging.h" // for CAOSDB_LOG_TRACE #include "caosdb/status_code.h" // for GENERIC_RPC_E... @@ -21,8 +69,6 @@ bool UnaryRpcHandler::OnNext(bool ok) { if (ok) { if (state_ == CallState::NewCall) { this->handleNewCallState(); - } else if (state_ == CallState::ReceivingFile) { - this->handleReceivingFileState(); } else if (state_ == CallState::CallComplete) { this->handleCallCompleteState(); return false;