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

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ 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. * the playlist.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.7 $ * @version $Revision: 1.8 $
*/ */
class Playlist : public Configurable 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; * @return true if the playlist is currently being edited or
* false if not, or if the editing has been suspended * played; false otherwise
* because the playlist is being played
*/ */
bool 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 bool
getIsLockedForPlaying() const throw () canBeEdited() const throw ()
{ {
return isLockedForPlaying; return isLockedForEditing && !isLockedForPlaying;
} }
/** /**

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -148,19 +148,25 @@ void
PlaylistTest :: lockTest(void) PlaylistTest :: lockTest(void)
throw (CPPUNIT_NS::Exception) throw (CPPUNIT_NS::Exception)
{ {
CPPUNIT_ASSERT(!playlist->isLocked());
CPPUNIT_ASSERT(!playlist->canBeEdited());
CPPUNIT_ASSERT(playlist->setLockedForEditing(true)); CPPUNIT_ASSERT(playlist->setLockedForEditing(true));
CPPUNIT_ASSERT(playlist->isLocked());
CPPUNIT_ASSERT(playlist->canBeEdited());
CPPUNIT_ASSERT(!playlist->setLockedForEditing(true)); CPPUNIT_ASSERT(!playlist->setLockedForEditing(true));
CPPUNIT_ASSERT(playlist->setLockedForEditing(false));
CPPUNIT_ASSERT(playlist->setLockedForPlaying(true)); CPPUNIT_ASSERT(playlist->setLockedForPlaying(true));
CPPUNIT_ASSERT(!playlist->setLockedForPlaying(true)); CPPUNIT_ASSERT(playlist->isLocked());
CPPUNIT_ASSERT(playlist->setLockedForPlaying(false)); CPPUNIT_ASSERT(!playlist->canBeEdited());
CPPUNIT_ASSERT(!playlist->setLockedForEditing(true));
CPPUNIT_ASSERT(playlist->setLockedForEditing(true));
CPPUNIT_ASSERT(playlist->setLockedForPlaying(true));
CPPUNIT_ASSERT(!playlist->setLockedForEditing(false)); CPPUNIT_ASSERT(!playlist->setLockedForEditing(false));
CPPUNIT_ASSERT(!playlist->setLockedForPlaying(true));
CPPUNIT_ASSERT(playlist->setLockedForPlaying(false)); 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 $ # 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 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
# #
# @configure_input@ # @configure_input@
@ -127,7 +127,9 @@ SCHEDULER_OBJS = ${TMP_DIR}/SignalDispatcher.o \
${TMP_DIR}/RemoveAudioClipFromPlaylistMethod.o \ ${TMP_DIR}/RemoveAudioClipFromPlaylistMethod.o \
${TMP_DIR}/ValidatePlaylistMethod.o \ ${TMP_DIR}/ValidatePlaylistMethod.o \
${TMP_DIR}/DisplayAudioClipMethod.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} \ SCHEDULER_EXE_OBJS = ${SCHEDULER_OBJS} \
${TMP_DIR}/main.o ${TMP_DIR}/main.o
@ -158,6 +160,8 @@ TEST_RUNNER_OBJS = ${SCHEDULER_OBJS} \
${TMP_DIR}/ValidatePlaylistMethodTest.o \ ${TMP_DIR}/ValidatePlaylistMethodTest.o \
${TMP_DIR}/DisplayAudioClipMethodTest.o \ ${TMP_DIR}/DisplayAudioClipMethodTest.o \
${TMP_DIR}/DisplayAudioClipsMethodTest.o \ ${TMP_DIR}/DisplayAudioClipsMethodTest.o \
${TMP_DIR}/SavePlaylistMethodTest.o \
${TMP_DIR}/RevertEditedPlaylistMethodTest.o \
${TMP_DIR}/TestRunner.o ${TMP_DIR}/TestRunner.o
TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} -lcppunit -ldl TEST_RUNNER_LIBS = ${SCHEDULER_EXE_LIBS} -lcppunit -ldl

View File

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

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ 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 // should not allow to open the same playlist for editing again
method->execute(parameter, result); method->execute(parameter, result);
CPPUNIT_ASSERT((int) result["errorCode"] == 105); 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 $ 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 $ 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(); scf = StorageClientFactory::getInstance();
storage = scf->getStorageClient(); 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 // TODO: mark error
returnValue = XmlRpc::XmlRpcValue(false); returnValue = XmlRpc::XmlRpcValue(false);
return; return;

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ 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(); scf = StorageClientFactory::getInstance();
storage = scf->getStorageClient(); storage = scf->getStorageClient();
if (!storage->existsPlaylist(id)) {
XmlRpcTools::markError(errorId+3, "playlist does not exist",
returnValue);
return;
}
Ptr<Playlist>::Ref playlist; Ptr<Playlist>::Ref playlist;
try { try {
playlist = storage->getPlaylist(id); playlist = storage->getPlaylist(id);
} }
catch (std::invalid_argument &e) { catch (std::invalid_argument &e) {
XmlRpcTools::markError(errorId+4, "could not load playlist", XmlRpcTools::markError(errorId+4, "playlist not found",
returnValue); returnValue);
return; return;
} }
if (!playlist->setLockedForEditing(true)) { if (!playlist->setLockedForEditing(true)) {
XmlRpcTools::markError(errorId+5, XmlRpcTools::markError(errorId+5,
"could not open playlist for editing (already open?)", "could not open playlist",
returnValue); returnValue);
return; return;
} }

View File

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

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethodTest.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -157,9 +157,9 @@ OpenPlaylistForEditingMethodTest :: firstTest(void)
// no such playlist // no such playlist
method->execute(parameter, result); method->execute(parameter, result);
CPPUNIT_ASSERT((int) result["errorCode"] == 103); CPPUNIT_ASSERT((int) result["errorCode"] == 104);
CPPUNIT_ASSERT((const std::string) result["errorMessage"] == CPPUNIT_ASSERT((const std::string) result["errorMessage"] ==
"playlist does not exist"); "playlist not found");
parameter.clear(); parameter.clear();
result.clear(); result.clear();
parameter["playlistId"] = 1; parameter["playlistId"] = 1;
@ -168,6 +168,6 @@ OpenPlaylistForEditingMethodTest :: firstTest(void)
method->execute(parameter, result); method->execute(parameter, result);
CPPUNIT_ASSERT((int) result["errorCode"] == 105); CPPUNIT_ASSERT((int) result["errorCode"] == 105);
CPPUNIT_ASSERT((const std::string) result["errorMessage"] == 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 $ 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 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -143,7 +143,7 @@ RemoveAudioClipFromPlaylistMethod :: execute(XmlRpc::XmlRpcValue & parameters,
return; return;
} }
if (!playlist->getIsLockedForEditing()) { if (!playlist->canBeEdited()) {
XmlRpcTools::markError(errorId+5, XmlRpcTools::markError(errorId+5,
"playlist has not been opened for editing", "playlist has not been opened for editing",
returnValue); returnValue);

View File

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