@RestResource(urlMapping='/OFSTaskFinish/*')
|
global with sharing class OFSTaskFinishRest {
|
@HttpPost
|
global static void doPost(Id Tid) {
|
system.debug('OFSTaskFinishRest.start');
|
RestResponse res = RestContext.response;
|
res.addHeader('Content-Type', 'application/json');
|
|
String jsonResponse;
|
|
List<Task> tlist = [select Id,Subject,OwnerId,Description,ActivityDate,QuoteIraiId__c,Status
|
from Task
|
where Id = :Tid];
|
if(tlist.size()<=0){
|
//TODO:
|
//error message:no event or wrong Id
|
res.statusCode = 200;
|
jsonResponse = '{"'+ System.Label.OFSErrorStatus +'": "'+ System.Label.OFSErrorFailure +'", "'+ System.Label.OFSErrorMessage +'": "No matching task was found"}';
|
res.responseBody = blob.valueOf(jsonResponse);
|
return;
|
|
}else{
|
tlist[0].Status = '完了';
|
|
try{
|
update tlist[0];
|
res.statusCode = 200;
|
jsonResponse = '{"'+ System.Label.OFSErrorStatus +'": "'+ System.Label.OFSErrorSuccess +'", "'+ System.Label.OFSErrorMessage +'": "'+ tlist[0].Id +'"}';
|
//jsonResponse = '{"status": "Success", "Message": "' + tlist[0].Id + '"}';
|
res.responseBody = blob.valueOf(jsonResponse);
|
return;
|
}catch ( Exception ex ) {
|
//TODO:
|
//error message:cannot update exception
|
res.statusCode = 200;
|
jsonResponse = '{"'+ System.Label.OFSErrorStatus +'": "'+ System.Label.OFSErrorFailure +'", "'+ System.Label.OFSErrorMessage +'": "'+ ex +'"}';
|
//jsonResponse = '{"status": "Failure", "Message": "' + ex + '"}';
|
res.responseBody = blob.valueOf(jsonResponse);
|
return;
|
}
|
}
|
}
|
}
|