modified locking

This commit is contained in:
fgerlits 2004-10-20 06:15:26 +00:00
parent ee413579a4
commit 7c23b18f91
13 changed files with 66 additions and 56 deletions

View File

@ -14,7 +14,7 @@ Development Loan Fund</a>, under the GNU <a
href="http://www.gnu.org/licenses/gpl.html">GPL</a>.<br>
<ul>
<li>Author: $Author: fgerlits $</li>
<li>Version: $Revision: 1.5 $</li>
<li>Version: $Revision: 1.6 $</li>
<li>Location: $Source:
/home/cvs/livesupport/doc/model/Scheduler/index.html,v $</li>
</ul>
@ -2558,7 +2558,7 @@ in the Playlist store.<br>
<tr>
<td valign="top"><b>Name</b><br>
</td>
<td colspan="2" rowspan="1" valign="top">displayPlaylists<br>
<td colspan="2" rowspan="1" valign="top">displayPlayLog<br>
()<br>
: Play log<br>
</td>

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.7 $
Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $
------------------------------------------------------------------------------*/
@ -71,7 +71,7 @@ using namespace boost::posix_time;
* the playlist.
*
* @author $Author: fgerlits $
* @version $Revision: 1.7 $
* @version $Revision: 1.8 $
*/
class Playlist : public Configurable
{
@ -212,27 +212,26 @@ class Playlist : public Configurable
}
/**
* Test whether the playlist is locked for editing.
* Test whether the playlist is locked for editing or playing.
*
* @return true if playlist is currently being edited;
* false if not, or if the editing has been suspended
* because the playlist is being played
* @return true if the playlist is currently being edited or
* played; false otherwise
*/
bool
getIsLockedForEditing() const throw ()
isLocked() const throw ()
{
return isLockedForEditing && !isLockedForPlaying;
return isLockedForEditing || isLockedForPlaying;
}
/**
* Test whether the playlist is locked for playing.
* Test whether the playlist is currently available for editing.
*
* @return true if playlist is locked, false if not
* @return true if the playlist is available, false otherwise
*/
bool
getIsLockedForPlaying() const throw ()
canBeEdited() const throw ()
{
return isLockedForPlaying;
return isLockedForEditing && !isLockedForPlaying;
}
/**

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.7 $
Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
@ -148,19 +148,25 @@ void
PlaylistTest :: lockTest(void)
throw (CPPUNIT_NS::Exception)
{
CPPUNIT_ASSERT(!playlist->isLocked());
CPPUNIT_ASSERT(!playlist->canBeEdited());
CPPUNIT_ASSERT(playlist->setLockedForEditing(true));
CPPUNIT_ASSERT(playlist->isLocked());
CPPUNIT_ASSERT(playlist->canBeEdited());
CPPUNIT_ASSERT(!playlist->setLockedForEditing(true));
CPPUNIT_ASSERT(playlist->setLockedForEditing(false));
CPPUNIT_ASSERT(playlist->setLockedForPlaying(true));
CPPUNIT_ASSERT(!playlist->setLockedForPlaying(true));
CPPUNIT_ASSERT(playlist->setLockedForPlaying(false));
CPPUNIT_ASSERT(playlist->setLockedForEditing(true));
CPPUNIT_ASSERT(playlist->setLockedForPlaying(true));
CPPUNIT_ASSERT(playlist->isLocked());
CPPUNIT_ASSERT(!playlist->canBeEdited());
CPPUNIT_ASSERT(!playlist->setLockedForEditing(true));
CPPUNIT_ASSERT(!playlist->setLockedForEditing(false));
CPPUNIT_ASSERT(!playlist->setLockedForPlaying(true));
CPPUNIT_ASSERT(playlist->setLockedForPlaying(false));
CPPUNIT_ASSERT(!playlist->setLockedForEditing(true));
CPPUNIT_ASSERT(playlist->isLocked());
CPPUNIT_ASSERT(playlist->canBeEdited());
CPPUNIT_ASSERT(playlist->setLockedForEditing(false));
}

View File

@ -21,7 +21,7 @@
#
#
# Author : $Author: fgerlits $
# Version : $Revision: 1.15 $
# Version : $Revision: 1.16 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
#
# @configure_input@
@ -127,7 +127,9 @@ SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \
${TMP_DIR}/RemoveAudioClipFromPlaylistMethod.o \
${TMP_DIR}/ValidatePlaylistMethod.o \
${TMP_DIR}/DisplayAudioClipMethod.o \
${TMP_DIR}/DisplayAudioClipsMethod.o
${TMP_DIR}/DisplayAudioClipsMethod.o \
${TMP_DIR}/RevertEditedPlaylistMethod.o \
${TMP_DIR}/SavePlaylistMethod.o
SCHEDULER_EXE_OBJS = ${SCHEDULER_OBJS} \
${TMP_DIR}/main.o
@ -158,6 +160,8 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \
${TMP_DIR}/ValidatePlaylistMethodTest.o \
${TMP_DIR}/DisplayAudioClipMethodTest.o \
${TMP_DIR}/DisplayAudioClipsMethodTest.o \
${TMP_DIR}/SavePlaylistMethodTest.o \
${TMP_DIR}/RevertEditedPlaylistMethodTest.o \
${TMP_DIR}/TestRunner.o
TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} -lcppunit -ldl

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -148,7 +148,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
return;
}
if (!playlist->getIsLockedForEditing()) {
if (!playlist->canBeEdited()) {
XmlRpcTools::markError(errorId+6,
"playlist has not been opened for editing",
returnValue);

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -157,6 +157,4 @@ CreatePlaylistMethodTest :: firstTest(void)
// should not allow to open the same playlist for editing again
method->execute(parameter, result);
CPPUNIT_ASSERT((int) result["errorCode"] == 105);
CPPUNIT_ASSERT((const std::string) result["errorMessage"] ==
"could not open playlist for editing (already open?)");
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/Attic/DeletePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -106,7 +106,17 @@ DeletePlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
scf = StorageClientFactory::getInstance();
storage = scf->getStorageClient();
if (!storage->existsPlaylist(id)) {
Ptr<Playlist>::Ref playlist;
try {
playlist = storage->getPlaylist(id);
}
catch (std::invalid_argument &e) {
// TODO: mark error
returnValue = XmlRpc::XmlRpcValue(false);
return;
}
if (playlist->isLocked()) {
// TODO: mark error
returnValue = XmlRpc::XmlRpcValue(false);
return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -122,26 +122,20 @@ OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & parameters,
scf = StorageClientFactory::getInstance();
storage = scf->getStorageClient();
if (!storage->existsPlaylist(id)) {
XmlRpcTools::markError(errorId+3, "playlist does not exist",
returnValue);
return;
}
Ptr<Playlist>::Ref playlist;
try {
playlist = storage->getPlaylist(id);
}
catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+4, "could not load playlist",
XmlRpcTools::markError(errorId+4, "playlist not found",
returnValue);
return;
}
if (!playlist->setLockedForEditing(true)) {
XmlRpcTools::markError(errorId+5,
"could not open playlist for editing (already open?)",
returnValue);
"could not open playlist",
returnValue);
return;
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.4 $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h,v $
------------------------------------------------------------------------------*/
@ -90,14 +90,13 @@ using namespace LiveSupport::Core;
* </ul>
* The possible error codes are:
* <ul>
* <li>101 - invalid argument format</li>
* <li>102 - argument is not a playlist ID</li>
* <li>103 - playlist does not exist</li>
* <li>104 - could not load playlist</li>
* <li>105 - could not open playlist for editing (already open?)</li>
* <li>101 - invalid argument format </li>
* <li>102 - argument is not a playlist ID </li>
* <li>104 - playlist not found </li>
* <li>105 - could not open playlist </li>
* </ul>
* @author $Author: fgerlits $
* @version $Revision: 1.4 $
* @version $Revision: 1.5 $
*/
class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod
{

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx,v $
------------------------------------------------------------------------------*/
@ -157,9 +157,9 @@ OpenPlaylistForEditingMethodTest :: firstTest(void)
// no such playlist
method->execute(parameter, result);
CPPUNIT_ASSERT((int) result["errorCode"] == 103);
CPPUNIT_ASSERT((int) result["errorCode"] == 104);
CPPUNIT_ASSERT((const std::string) result["errorMessage"] ==
"playlist does not exist");
"playlist not found");
parameter.clear();
result.clear();
parameter["playlistId"] = 1;
@ -168,6 +168,6 @@ OpenPlaylistForEditingMethodTest :: firstTest(void)
method->execute(parameter, result);
CPPUNIT_ASSERT((int) result["errorCode"] == 105);
CPPUNIT_ASSERT((const std::string) result["errorMessage"] ==
"could not open playlist for editing (already open?)");
"could not open playlist");
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -143,7 +143,7 @@ RemoveAudioClipFromPlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
return;
}
if (!playlist->getIsLockedForEditing()) {
if (!playlist->canBeEdited()) {
XmlRpcTools::markError(errorId+5,
"playlist has not been opened for editing",
returnValue);

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.1 $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@ -132,7 +132,7 @@ ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
return;
}
if (!playlist->getIsLockedForEditing()) {
if (!playlist->canBeEdited()) {
XmlRpcTools::markError(errorId+4,
"playlist has not been opened for editing",
returnValue);