2019-01-29 Fred Gleason <fredg@paravelsystems.com>

* Fixed a bug in the 'EditCut' web API call that caused attempts
	to clear the 'START_DAYPART' and 'END_DAYPART' fields to return
	an error.
This commit is contained in:
Fred Gleason 2019-01-29 16:32:06 -05:00
parent 0b472716d6
commit efa4999fa2
5 changed files with 70 additions and 50 deletions

View File

@ -18432,3 +18432,7 @@
'RDXmlDate()', 'RDXmlTime()', 'RDXmlDateTime()' and
'RDXmlTimeZoneSuffix()' functions from 'lib/rdweb.[cpp|h].
* Added a 'dateparse_test' test harness.
2019-01-29 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in the 'EditCut' web API call that caused attempts
to clear the 'START_DAYPART' and 'END_DAYPART' fields to return
an error.

View File

@ -1239,7 +1239,7 @@
Set Start Date/Time
</entry>
<entry>
Optional, RFC-822 format
Optional, RFC-822 or XML xs:dateTime format
</entry>
</row>
<row>
@ -1250,7 +1250,7 @@
Set End Date/Time
</entry>
<entry>
Optional, RFC-822 format
Optional, RFC-822 or XML xs:dateTime format
</entry>
</row>
<row>
@ -1338,7 +1338,7 @@
Set Start daypart time
</entry>
<entry>
Optional, RFC-822 format
Optional, XML xs:time format
</entry>
</row>
<row>
@ -1349,7 +1349,7 @@
Set End daypart time
</entry>
<entry>
Optional, RFC-822 format
Optional, XML xs:time format
</entry>
</row>
<row>

View File

@ -255,6 +255,9 @@ bool RDFormPost::getValue(const QString &name,QDate *date,bool *ok)
return false;
}
if(str.length()==0) {
if(ok!=NULL) {
*ok=true;
}
*date=QDate();
}
else {
@ -275,6 +278,9 @@ bool RDFormPost::getValue(const QString &name,QTime *time,bool *ok)
return false;
}
if(str.length()==0) {
if(ok!=NULL) {
*ok=true;
}
*time=QTime();
}
else {

View File

@ -461,17 +461,17 @@ void Xport::AddCut()
// Verify Post
//
if(!xport_post->getValue("CART_NUMBER",&cart_number)) {
XmlExit("Missing CART_NUMBER",400);
XmlExit("Missing CART_NUMBER",400,"carts.cpp",LINE_NUMBER);
}
//
// Verify User Perms
//
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404);
XmlExit("No such cart",404,"carts.cpp",LINE_NUMBER);
}
if(!rda->user()->editAudio()) {
XmlExit("Forbidden",404);
XmlExit("Forbidden",404,"carts.cpp",LINE_NUMBER);
}
//
@ -480,11 +480,11 @@ void Xport::AddCut()
cart=new RDCart(cart_number);
if(!cart->exists()) {
delete cart;
XmlExit("No such cart",404);
XmlExit("No such cart",404,"carts.cpp",LINE_NUMBER);
}
if((cut_number=cart->addCut(0,0,2))<0) {
delete cart;
XmlExit("No new cuts available",500);
XmlExit("No new cuts available",500,"carts.cpp",LINE_NUMBER);
}
printf("Content-type: application/xml\n");
printf("Status: 200\n\n");
@ -515,14 +515,14 @@ void Xport::ListCuts()
// Verify Post
//
if(!xport_post->getValue("CART_NUMBER",&cart_number)) {
XmlExit("Missing CART_NUMBER",400);
XmlExit("Missing CART_NUMBER",400,"carts.cpp",LINE_NUMBER);
}
//
// Verify User Perms
//
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404);
XmlExit("No such cart",404,"carts.cpp",LINE_NUMBER);
}
//
@ -555,17 +555,17 @@ void Xport::ListCut()
// Verify Post
//
if(!xport_post->getValue("CART_NUMBER",&cart_number)) {
XmlExit("Missing CART_NUMBER",400);
XmlExit("Missing CART_NUMBER",400,"carts.cpp",LINE_NUMBER);
}
if(!xport_post->getValue("CUT_NUMBER",&cut_number)) {
XmlExit("Missing CUT_NUMBER",400);
XmlExit("Missing CUT_NUMBER",400,"carts.cpp",LINE_NUMBER);
}
//
// Verify User Perms
//
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404);
XmlExit("No such cart",404,"carts.cpp",LINE_NUMBER);
}
//
@ -574,7 +574,7 @@ void Xport::ListCut()
cut=new RDCut(cart_number,cut_number);
if(!cut->exists()) {
delete cut;
XmlExit("No such cut",404);
XmlExit("No such cut",404,"carts.cpp",LINE_NUMBER);
}
printf("Content-type: application/xml\n");
printf("Status: 200\n\n");
@ -627,20 +627,20 @@ void Xport::EditCut()
// Verify Post
//
if(!xport_post->getValue("CART_NUMBER",&cart_number)) {
XmlExit("Missing CART_NUMBER",400);
XmlExit("Missing CART_NUMBER",400,"carts.cpp",LINE_NUMBER);
}
if(!xport_post->getValue("CUT_NUMBER",&cut_number)) {
XmlExit("Missing CUT_NUMBER",400);
XmlExit("Missing CUT_NUMBER",400,"carts.cpp",LINE_NUMBER);
}
//
// Verify User Perms
//
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404);
XmlExit("No such cart",404,"carts.cpp",LINE_NUMBER);
}
if(!rda->user()->editAudio()) {
XmlExit("Forbidden",404);
XmlExit("Forbidden",404,"carts.cpp",LINE_NUMBER);
}
//
@ -649,42 +649,45 @@ void Xport::EditCut()
if((use_start_datetime=xport_post->
getValue("START_DATETIME",&start_datetime,&ok))) {
if(!ok) {
XmlExit("invalid START_DATETIME",400);
XmlExit("invalid START_DATETIME",400,"carts.cpp",LINE_NUMBER);
}
}
if((use_end_datetime=xport_post->
getValue("END_DATETIME",&end_datetime,&ok))) {
if(!ok) {
XmlExit("invalid END_DATETIME",400);
XmlExit("invalid END_DATETIME",400,"carts.cpp",LINE_NUMBER);
}
}
if(use_start_datetime!=use_end_datetime) {
XmlExit("both DATETIME values must be set together",400);
XmlExit("both DATETIME values must be set together",400,"carts.cpp",
LINE_NUMBER);
}
if(use_start_datetime&&(start_datetime>end_datetime)) {
XmlExit("START_DATETIME is later than END_DATETIME",400);
XmlExit("START_DATETIME is later than END_DATETIME",400,"carts.cpp",
LINE_NUMBER);
}
if((use_start_daypart=xport_post->
getValue("START_DAYPART",&start_daypart,&ok))) {
if(!ok) {
XmlExit("invalid START_DAYPART",400);
XmlExit("invalid START_DAYPART",400,"carts.cpp",LINE_NUMBER);
}
}
if((use_end_daypart=xport_post->
getValue("END_DAYPART",&end_daypart,&ok))) {
if(!ok) {
XmlExit("invalid END_DAYPART",400);
XmlExit("invalid END_DAYPART",400,"carts.cpp",LINE_NUMBER);
}
}
if(use_start_daypart!=use_end_daypart) {
XmlExit("both DAYPART values must be set together",400);
XmlExit("both DAYPART values must be set together",400,"carts.cpp",
LINE_NUMBER);
}
cut=new RDCut(cart_number,cut_number);
if(!cut->exists()) {
delete cut;
XmlExit("No such cut",404);
XmlExit("No such cut",404,"carts.cpp",LINE_NUMBER);
}
//
@ -701,24 +704,27 @@ void Xport::EditCut()
if((use_fadeup_point=xport_post->
getValue("FADEUP_POINT",&fadeup_point,&ok))) {
if(!ok) {
XmlExit("invalid FADEUP_POINT",400);
XmlExit("invalid FADEUP_POINT",400,"carts.cpp",LINE_NUMBER);
}
if(fadeup_point>end_points[1]) {
XmlExit("FADEUP_POINT exceeds length of cart",400);
XmlExit("FADEUP_POINT exceeds length of cart",400,"carts.cpp",
LINE_NUMBER);
}
}
if((use_fadedown_point=xport_post->
getValue("FADEDOWN_POINT",&fadedown_point,&ok))) {
if(!ok) {
XmlExit("invalid FADEDOWN_POINT",400);
XmlExit("invalid FADEDOWN_POINT",400,"carts.cpp",LINE_NUMBER);
}
if(fadeup_point>end_points[1]) {
XmlExit("FADEDOWN_POINT exceeds length of cart",400);
XmlExit("FADEDOWN_POINT exceeds length of cart",400,"carts.cpp",
LINE_NUMBER);
}
}
if(use_fadeup_point&&use_fadedown_point&&
(fadeup_point>=0)&&(fadedown_point>=0)&&(fadeup_point>fadedown_point)) {
XmlExit("FADEUP_POINT is greater than FADEDOWN_POINT",400);
XmlExit("FADEUP_POINT is greater than FADEDOWN_POINT",400,"carts.cpp",
LINE_NUMBER);
}
//
@ -726,7 +732,7 @@ void Xport::EditCut()
//
if((use_weight=xport_post->getValue("WEIGHT",&weight,&ok))) {
if((!ok)||(weight<0)) {
XmlExit("invalid WEIGHT",400);
XmlExit("invalid WEIGHT",400,"carts.cpp",LINE_NUMBER);
}
}
@ -876,31 +882,35 @@ void Xport::CheckPointerValidity(int ptr_values[2],bool use_ptrs[2],
return;
}
if(!start_ok) {
XmlExit("invalid "+type+"START_POINT",400);
XmlExit("invalid "+type+"START_POINT",400,"carts.cpp",LINE_NUMBER);
}
if(!end_ok) {
XmlExit("invalid "+type+"END_POINT",400);
XmlExit("invalid "+type+"END_POINT",400,"carts.cpp",LINE_NUMBER);
}
if(use_ptrs[0]!=use_ptrs[1]) {
XmlExit("both "+type+"*_POINT values must be set together",400);
XmlExit("both "+type+"*_POINT values must be set together",400,"carts.cpp",
LINE_NUMBER);
}
if(use_ptrs[0]) {
if(((ptr_values[0]<0)&&(ptr_values[1]>=0))||
((ptr_values[0]>=0)&&(ptr_values[1]<0))) {
XmlExit("inconsistent "+type+"*_POINT values",400);
XmlExit("inconsistent "+type+"*_POINT values",400,"carts.cpp",
LINE_NUMBER);
}
}
if(ptr_values[0]>=0) {
if(ptr_values[0]>ptr_values[1]) {
XmlExit(type+"START_POINT greater than "+type+"END_POINT",400);
XmlExit(type+"START_POINT greater than "+type+"END_POINT",400,
"carts.cpp",LINE_NUMBER);
}
if((max_value>0)&&((unsigned)ptr_values[1]>max_value)) {
XmlExit(type+"END_POINT exceeds length of cut",400);
XmlExit(type+"END_POINT exceeds length of cut",400,"carts.cpp",
LINE_NUMBER);
}
}
else {
if(max_value==0) {
XmlExit("End markers cannot be removed",400);
XmlExit("End markers cannot be removed",400,"carts.cpp",LINE_NUMBER);
}
else {
ptr_values[0]=-1;
@ -920,20 +930,20 @@ void Xport::RemoveCut()
// Verify Post
//
if(!xport_post->getValue("CART_NUMBER",&cart_number)) {
XmlExit("Missing CART_NUMBER",400);
XmlExit("Missing CART_NUMBER",400,"carts.cpp",LINE_NUMBER);
}
if(!xport_post->getValue("CUT_NUMBER",&cut_number)) {
XmlExit("Missing CUT_NUMBER",400);
XmlExit("Missing CUT_NUMBER",400,"carts.cpp",LINE_NUMBER);
}
//
// Verify User Perms
//
if(!rda->user()->cartAuthorized(cart_number)) {
XmlExit("No such cart",404);
XmlExit("No such cart",404,"carts.cpp",LINE_NUMBER);
}
if(!rda->user()->editAudio()) {
XmlExit("Forbidden",404);
XmlExit("Forbidden",404,"carts.cpp",LINE_NUMBER);
}
//
@ -942,12 +952,12 @@ void Xport::RemoveCut()
cart=new RDCart(cart_number);
if(!cart->exists()) {
delete cart;
XmlExit("No such cart",404);
XmlExit("No such cart",404,"carts.cpp",LINE_NUMBER);
}
if(!cart->removeCut(NULL,NULL,RDCut::cutName(cart_number,cut_number),
rda->config())) {
delete cart;
XmlExit("No such cut",404);
XmlExit("No such cut",404,"carts.cpp",LINE_NUMBER);
}
SendNotification(RDNotification::CartType,RDNotification::ModifyAction,
QVariant(cart->number()));

View File

@ -76,14 +76,14 @@
</tr>
<tr>
<td align="right">START_DATETIME:</td>
<td><input type="text" name="START_DATETIME" id="START_DATETIME" size="32" maxlength="30"></td>
<td><input type="text" name="START_DATETIME" id="START_DATETIME" size="32" maxlength="31">&nbsp;[RFC822 or XML xs:dateTime]</td>
<td><input type="checkbox" id="USE_START_DATETIME"></td>
<td>Modify</td>
</tr>
<tr>
<tr>
<td align="right">END_DATETIME:</td>
<td><input type="text" name="END_DATETIME" id="END_DATETIME" size="32" maxlength="30"></td>
<td><input type="text" name="END_DATETIME" id="END_DATETIME" size="32" maxlength="31">&nbsp;[RFC822 or XML xs:dateTime]</td>
<td><input type="checkbox" id="USE_END_DATETIME"></td>
<td>Modify</td>
</tr>
@ -131,14 +131,14 @@
</tr>
<tr>
<td align="right">START DAYPART:</td>
<td><input type="text" name="START_DAYPART" id="START_DAYPART" size="32" maxlength="30"></td>
<td><input type="text" name="START_DAYPART" id="START_DAYPART" size="32" maxlength="30">&nbsp;[XML xs:time]</td>
<td><input type="checkbox" id="USE_START_DAYPART"></td>
<td>Modify</td>
</tr>
<tr>
<tr>
<td align="right">END DAYPART:</td>
<td><input type="text" name="END_DAYPART" id="END_DAYPART" size="32" maxlength="30"></td>
<td><input type="text" name="END_DAYPART" id="END_DAYPART" size="32" maxlength="30">&nbsp;[XML xs:time]</td>
<td><input type="checkbox" id="USE_END_DAYPART"></td>
<td>Modify</td>
</tr>