Skip to content

Adapting html interface to zeroeq changes#128

Merged
rdumusc merged 16 commits intoBlueBrain:masterfrom
ppodhajski:feature/nonblocking
Apr 6, 2017
Merged

Adapting html interface to zeroeq changes#128
rdumusc merged 16 commits intoBlueBrain:masterfrom
ppodhajski:feature/nonblocking

Conversation

@ppodhajski
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread tests/cpp/CMakeLists.txt Outdated
core/JsonOptionsTests.cpp
core/LoggingUtilityTest.cpp
core/RestCommandTests.cpp
core/RestWindowsTests.cpp
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphab order

Comment thread tests/cpp/core/RestWindowsTests.cpp Outdated
, _contentFilters( filters )
{
}
#define BOOST_TEST_MODULE WebInterfaceTest
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RestWindowsTests (same as file name)

Comment thread tests/cpp/core/RestWindowsTests.cpp Outdated

auto future = windowsContent.getWindowInfo( std::string(), std::string( ));
auto response = future.get();
BOOST_CHECK( response.code == 200 );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer BOOST_CHECK_EQUAL( a, b ) when comparing two values

Comment thread tests/cpp/core/RestWindowsTests.cpp Outdated

const auto uuid = window->getID().toString().replace( _regex, "" );

sleep(2);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Comment thread tests/cpp/core/RestWindowsTests.cpp Outdated
ContentWindowPtr window( new ContentWindow( content ));
displayGroup->addContentWindow( window );

auto future = windowsContent.getWindowInfo( std::string(), std::string( ));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also check the payload and headers (content type) for all requests

Comment thread tide/master/rest/RestWindows.cpp Outdated
const auto url = _getThumbnailUri( *window );
const QString uri = window->getContent().get()->getURI();
_httpServer.handleGET(url.toStdString(), [uri] ()
QtConcurrent::run( QThreadPool::globalInstance(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that QThreadPool::globalInstance() is the default, it can be omitted (also remove the include)

Comment thread tide/master/rest/RestWindows.cpp Outdated
QtConcurrent::run( QThreadPool::globalInstance(),
[this, window]()
{
const QString& uri = window->getContent().get()->getURI();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no .get()

Comment thread tide/master/rest/RestWindows.h Outdated
#define RESTWINDOWS_H

#include <servus/serializable.h> // base class
#include "zeroeq/http/response.h"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use <> for non-local includes and move after local includes

Comment thread tide/master/rest/RestWindows.h Outdated
/** @return the string used as an endpoint by REST interface. */
std::string getTypeName() const final;
/**
* Expose the list of windows to REST Interface
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update comment, add name and doc to the two parameters

*/
RestWindows( zeroeq::http::Server& server,
const DisplayGroup& displayGroup );
RestWindows( const DisplayGroup& displayGroup );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update doc, server was removed from the params

Comment thread tests/cpp/core/FileReceiverTests.cpp Outdated
DisplayGroupPtr displayGroup( new DisplayGroup( wallSize ));
FileReceiver fileReceiver;

bool open;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= false, otherwise the check is unpredictable ;-)

Comment thread tests/cpp/core/RestWindowsTests.cpp Outdated
response = future.get();
BOOST_CHECK( response.payload == _getThumbnail() );
BOOST_CHECK( response.code == 200 );
BOOST_CHECK_EQUAL( response.code, 204 );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be a 404 for a window that has been removed? Otherwise the client will keep asking for it?

Comment thread tide/master/rest/FileReceiver.cpp Outdated
auto filePath = QString::fromStdString( path );
if( !_preparedPaths.contains( filePath ))
return _makeResponse( http::Code::FORBIDDEN, "info",
"uploaded not prepared" );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo upload

Comment thread tide/master/rest/FileReceiver.cpp Outdated
const std::string& payload )
{

auto filePath = QString::fromStdString( path );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const?

Comment thread tide/master/rest/FileReceiver.cpp Outdated
const bool success = openPromise->get_future().get();

_server.remove( "tide/upload/" + path );
_preparedPaths.removeOne( filePath );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be moved right after file.close(), no need to wait for open() to succeed if it is removed always

Comment thread tide/master/rest/FileSystemQuery.h Outdated
* Expose the content of a directory to REST Interface
* List the content of a directory to be exposed to REST Interface
*
* @param pathPoint the path of a directory to list
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing @return

Comment thread tide/master/rest/RestWindows.cpp Outdated
const auto endpointSplit = endpoint.split( "/" );
if( endpointSplit.size() == 2 && endpointSplit[1] == "thumbnail")
{
const auto uuid = endpointSplit[0];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto&

Comment thread tide/master/rest/RestWindows.h Outdated
/**
* Expose the list of windows to REST Interface
*
* @param path the url part including window uuid and action
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing @return

QFile file( imageUri );
file.open( QIODevice::ReadOnly );
auto payload = file.readAll().toStdString();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could also already check that open is false until here:
BOOST_REQUIRE_EQUAL( open, false );

Comment thread tide/master/rest/FileReceiver.h Outdated
/**
* Prepare an upload of a file via REST Interface.
*
* @param payload the name of a file client wants to upload.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@return missing

@ppodhajski ppodhajski force-pushed the feature/nonblocking branch 4 times, most recently from 44dd10b to f8e8fd8 Compare March 27, 2017 07:47
@ppodhajski ppodhajski force-pushed the feature/nonblocking branch 3 times, most recently from 1d98dad to e3dbe6a Compare March 28, 2017 11:44
@ppodhajski ppodhajski force-pushed the feature/nonblocking branch from e3dbe6a to 551172b Compare March 28, 2017 13:27
@rdumusc
Copy link
Copy Markdown

rdumusc commented Apr 5, 2017

still need to fix travis build: https://travis-ci.org/BlueBrain/Tide/jobs/218908492

@ppodhajski ppodhajski force-pushed the feature/nonblocking branch from 72887b2 to aff37ee Compare April 6, 2017 08:36
@rdumusc rdumusc merged commit 2c2e9d9 into BlueBrain:master Apr 6, 2017
@ppodhajski ppodhajski deleted the feature/nonblocking branch May 4, 2017 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants