added browse() function to WebStorageClient
This commit is contained in:
parent
79caff8787
commit
27b7e34dde
6 changed files with 224 additions and 18 deletions
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.12 $
|
Version : $Revision: 1.13 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientInterface.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -66,7 +66,7 @@ using namespace Core;
|
||||||
* An interface for storage clients.
|
* An interface for storage clients.
|
||||||
*
|
*
|
||||||
* @author $Author: fgerlits $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.12 $
|
* @version $Revision: 1.13 $
|
||||||
*/
|
*/
|
||||||
class StorageClientInterface
|
class StorageClientInterface
|
||||||
{
|
{
|
||||||
|
@ -377,6 +377,23 @@ class StorageClientInterface
|
||||||
throw (XmlRpcException)
|
throw (XmlRpcException)
|
||||||
= 0;
|
= 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Browse for metadata values.
|
||||||
|
*
|
||||||
|
* @param sessionId the session ID from the authentication client
|
||||||
|
* @param metadataType the type of metadata to browse for
|
||||||
|
* @param searchCriteria an object containing the search criteria
|
||||||
|
* @return a vector containing the metadata values found
|
||||||
|
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||||
|
* call.
|
||||||
|
*/
|
||||||
|
virtual Ptr<std::vector<Glib::ustring> >::Ref
|
||||||
|
browse(Ptr<SessionId>::Ref sessionId,
|
||||||
|
Ptr<Glib::ustring>::Ref metadata,
|
||||||
|
Ptr<SearchCriteria>::Ref searchCriteria)
|
||||||
|
throw (XmlRpcException)
|
||||||
|
= 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of audio clip IDs found by the search method.
|
* Return the list of audio clip IDs found by the search method.
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.31 $
|
Version : $Revision: 1.32 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -85,8 +85,8 @@ using namespace LiveSupport::Core;
|
||||||
* <!ATTLIST testStorage tempFiles CDATA #REQUIRED >
|
* <!ATTLIST testStorage tempFiles CDATA #REQUIRED >
|
||||||
* </code></pre>
|
* </code></pre>
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.31 $
|
* @version $Revision: 1.32 $
|
||||||
*/
|
*/
|
||||||
class TestStorageClient :
|
class TestStorageClient :
|
||||||
virtual public Configurable,
|
virtual public Configurable,
|
||||||
|
@ -525,6 +525,26 @@ class TestStorageClient :
|
||||||
Ptr<SearchCriteria>::Ref searchCriteria)
|
Ptr<SearchCriteria>::Ref searchCriteria)
|
||||||
throw (XmlRpcException);
|
throw (XmlRpcException);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Browse for metadata values. Not implemented; always returns 0.
|
||||||
|
*
|
||||||
|
* @param sessionId the session ID from the authentication client
|
||||||
|
* @param metadataType the type of metadata to browse for
|
||||||
|
* @param searchCriteria an object containing the search criteria
|
||||||
|
* @return a vector containing the metadata values found
|
||||||
|
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||||
|
* call.
|
||||||
|
*/
|
||||||
|
virtual Ptr<std::vector<Glib::ustring> >::Ref
|
||||||
|
browse(Ptr<SessionId>::Ref sessionId,
|
||||||
|
Ptr<Glib::ustring>::Ref metadataType,
|
||||||
|
Ptr<SearchCriteria>::Ref searchCriteria)
|
||||||
|
throw (XmlRpcException)
|
||||||
|
{
|
||||||
|
Ptr<std::vector<Glib::ustring> >::Ref null;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of audio clip IDs found by the search method.
|
* Return the list of audio clip IDs found by the search method.
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.38 $
|
Version : $Revision: 1.39 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -245,6 +245,39 @@ static const std::string searchAudioClipCountParamName = "audioClipCnt";
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
static const std::string searchPlaylistCountParamName = "playlistCnt";
|
static const std::string searchPlaylistCountParamName = "playlistCnt";
|
||||||
|
|
||||||
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: browse */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the search method on the storage server
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string browseMethodName
|
||||||
|
= "locstor.browseCategory";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the session ID parameter in the input structure
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string browseSessionIdParamName = "sessid";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the metadata type parameter in the input structure
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string browseMetadataParamName = "category";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the search criteria parameter in the input structure
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string browseCriteriaParamName = "criteria";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the list of metadata values parameter returned by the method
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string browseResultParamName = "results";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the count parameter returned by the method
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string browseResultCountParamName = "cnt";
|
||||||
|
|
||||||
|
|
||||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ playlist methods */
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ playlist methods */
|
||||||
|
|
||||||
|
@ -2093,6 +2126,80 @@ WebStorageClient :: search(Ptr<SessionId>::Ref sessionId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Browse for metadata values.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<std::vector<Glib::ustring> >::Ref
|
||||||
|
WebStorageClient :: browse(Ptr<SessionId>::Ref sessionId,
|
||||||
|
Ptr<Glib::ustring>::Ref metadataType,
|
||||||
|
Ptr<SearchCriteria>::Ref searchCriteria)
|
||||||
|
throw (XmlRpcException)
|
||||||
|
{
|
||||||
|
XmlRpcValue parameters;
|
||||||
|
XmlRpcValue result;
|
||||||
|
|
||||||
|
XmlRpcClient xmlRpcClient(storageServerName.c_str(), storageServerPort,
|
||||||
|
storageServerPath.c_str(), false);
|
||||||
|
|
||||||
|
parameters.clear();
|
||||||
|
parameters[browseSessionIdParamName]
|
||||||
|
= sessionId->getId();
|
||||||
|
parameters[browseMetadataParamName]
|
||||||
|
= std::string(*metadataType);
|
||||||
|
parameters[browseCriteriaParamName]
|
||||||
|
= *searchCriteria;
|
||||||
|
|
||||||
|
result.clear();
|
||||||
|
if (!xmlRpcClient.execute(browseMethodName.c_str(),
|
||||||
|
parameters, result)) {
|
||||||
|
xmlRpcClient.close();
|
||||||
|
std::string eMsg = "cannot execute XML-RPC method '";
|
||||||
|
eMsg += browseMethodName;
|
||||||
|
eMsg += "'";
|
||||||
|
throw XmlRpcCommunicationException(eMsg);
|
||||||
|
}
|
||||||
|
xmlRpcClient.close();
|
||||||
|
|
||||||
|
if (xmlRpcClient.isFault()) {
|
||||||
|
std::stringstream eMsg;
|
||||||
|
eMsg << "XML-RPC method '"
|
||||||
|
<< browseMethodName
|
||||||
|
<< "' returned error message:\n"
|
||||||
|
<< result;
|
||||||
|
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! result.hasMember(browseResultParamName)
|
||||||
|
|| result[browseResultParamName].getType()
|
||||||
|
!= XmlRpcValue::TypeArray) {
|
||||||
|
std::stringstream eMsg;
|
||||||
|
eMsg << "XML-RPC method '"
|
||||||
|
<< browseMethodName
|
||||||
|
<< "' returned unexpected value:\n"
|
||||||
|
<< result;
|
||||||
|
throw XmlRpcMethodResponseException(eMsg.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
XmlRpcValue metadataValues = result[browseResultParamName];
|
||||||
|
Ptr<std::vector<Glib::ustring> >::Ref
|
||||||
|
results(new std::vector<Glib::ustring>);
|
||||||
|
|
||||||
|
for (int i=0; i < metadataValues.size(); i++) {
|
||||||
|
if (metadataValues[i].getType() != XmlRpcValue::TypeString) {
|
||||||
|
std::stringstream eMsg;
|
||||||
|
eMsg << "Non-string metadata value returned by XML-RPC method '"
|
||||||
|
<< browseMethodName
|
||||||
|
<< "':\n"
|
||||||
|
<< result;
|
||||||
|
throw XmlRpcMethodResponseException(eMsg.str());
|
||||||
|
}
|
||||||
|
results->push_back(Glib::ustring(metadataValues[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Return a list of all playlists in the storage.
|
* Return a list of all playlists in the storage.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.25 $
|
Version : $Revision: 1.26 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -95,8 +95,8 @@ using namespace LiveSupport::Core;
|
||||||
* <!ATTLIST location path CDATA #REQUIRED >
|
* <!ATTLIST location path CDATA #REQUIRED >
|
||||||
* </code></pre>
|
* </code></pre>
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.25 $
|
* @version $Revision: 1.26 $
|
||||||
*/
|
*/
|
||||||
class WebStorageClient :
|
class WebStorageClient :
|
||||||
virtual public Configurable,
|
virtual public Configurable,
|
||||||
|
@ -521,6 +521,22 @@ class WebStorageClient :
|
||||||
Ptr<SearchCriteria>::Ref searchCriteria)
|
Ptr<SearchCriteria>::Ref searchCriteria)
|
||||||
throw (XmlRpcException);
|
throw (XmlRpcException);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Browse for metadata values.
|
||||||
|
*
|
||||||
|
* @param sessionId the session ID from the authentication client
|
||||||
|
* @param metadataType the type of metadata to browse for
|
||||||
|
* @param searchCriteria an object containing the search criteria
|
||||||
|
* @return a vector containing the metadata values found
|
||||||
|
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||||
|
* call.
|
||||||
|
*/
|
||||||
|
virtual Ptr<std::vector<Glib::ustring> >::Ref
|
||||||
|
browse(Ptr<SessionId>::Ref sessionId,
|
||||||
|
Ptr<Glib::ustring>::Ref metadataType,
|
||||||
|
Ptr<SearchCriteria>::Ref searchCriteria)
|
||||||
|
throw (XmlRpcException);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of playlist IDs found by the search method.
|
* Return the list of playlist IDs found by the search method.
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.40 $
|
Version : $Revision: 1.41 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -709,6 +709,43 @@ WebStorageClientTest :: searchTest(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Browse test.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
WebStorageClientTest :: browseTest(void)
|
||||||
|
throw (CPPUNIT_NS::Exception)
|
||||||
|
{
|
||||||
|
CPPUNIT_ASSERT_NO_THROW(
|
||||||
|
wsc->reset()
|
||||||
|
);
|
||||||
|
|
||||||
|
Ptr<SessionId>::Ref sessionId;
|
||||||
|
CPPUNIT_ASSERT_NO_THROW(
|
||||||
|
sessionId = authentication->login("root", "q")
|
||||||
|
);
|
||||||
|
CPPUNIT_ASSERT(sessionId);
|
||||||
|
|
||||||
|
Ptr<Glib::ustring>::Ref metadata(new Glib::ustring("dc:title"));
|
||||||
|
Ptr<SearchCriteria>::Ref criteria(new SearchCriteria());
|
||||||
|
Ptr<std::vector<Glib::ustring> >::Ref values;
|
||||||
|
CPPUNIT_ASSERT_NO_THROW(
|
||||||
|
values = wsc->browse(sessionId, metadata, criteria)
|
||||||
|
);
|
||||||
|
CPPUNIT_ASSERT(values);
|
||||||
|
CPPUNIT_ASSERT(values->size() >= 6);
|
||||||
|
|
||||||
|
metadata.reset(new Glib::ustring("dcterms:extent"));
|
||||||
|
criteria.reset(new SearchCriteria("all", "dc:title", "=", "one"));
|
||||||
|
CPPUNIT_ASSERT_NO_THROW(
|
||||||
|
values = wsc->browse(sessionId, metadata, criteria)
|
||||||
|
);
|
||||||
|
CPPUNIT_ASSERT(values);
|
||||||
|
CPPUNIT_ASSERT(values->size() >= 1);
|
||||||
|
CPPUNIT_ASSERT((*values)[0] == Glib::ustring("00:00:11.000000"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Testing getAllPlaylists() and getAllAudioClips().
|
* Testing getAllPlaylists() and getAllAudioClips().
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.10 $
|
Version : $Revision: 1.11 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClientTest.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -63,8 +63,8 @@ using namespace LiveSupport::Authentication;
|
||||||
/**
|
/**
|
||||||
* Unit test for the UploadPlaylistMetohd class.
|
* Unit test for the UploadPlaylistMetohd class.
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.10 $
|
* @version $Revision: 1.11 $
|
||||||
* @see WebStorageClient
|
* @see WebStorageClient
|
||||||
*/
|
*/
|
||||||
class WebStorageClientTest : public BaseTestMethod
|
class WebStorageClientTest : public BaseTestMethod
|
||||||
|
@ -77,6 +77,7 @@ class WebStorageClientTest : public BaseTestMethod
|
||||||
CPPUNIT_TEST(audioClipTest);
|
CPPUNIT_TEST(audioClipTest);
|
||||||
CPPUNIT_TEST(searchTest);
|
CPPUNIT_TEST(searchTest);
|
||||||
CPPUNIT_TEST(getAllTest);
|
CPPUNIT_TEST(getAllTest);
|
||||||
|
CPPUNIT_TEST(browseTest);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -148,6 +149,14 @@ class WebStorageClientTest : public BaseTestMethod
|
||||||
void
|
void
|
||||||
getAllTest(void) throw (CPPUNIT_NS::Exception);
|
getAllTest(void) throw (CPPUNIT_NS::Exception);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Testing browse().
|
||||||
|
*
|
||||||
|
* @exception CPPUNIT_NS::Exception on test failures.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
browseTest(void) throw (CPPUNIT_NS::Exception);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue