Changeset 962 for trunk/zoo-project/zoo-kernel/server_internal.c
- Timestamp:
- Oct 21, 2020, 6:31:09 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/server_internal.c
r961 r962 952 952 free(res); 953 953 } 954 else 955 addToMap(statusInfo,"Status","Failed"); 954 else{ 955 addToMap(statusInfo,"Status","Failed"); 956 addToMap(statusInfo,"NotFound",pid); 957 } 956 958 free(fbkpid); 957 959 } … … 992 994 void runGetStatus(maps* conf,char* pid,char* req){ 993 995 map* r_inputs = getMapFromMaps (conf, "main", "tmpPath"); 996 map* e_type = getMapFromMaps (conf, "lenv", "executionType"); 994 997 char *sid=getStatusId(conf,pid); 995 998 if(sid==NULL){ 996 errorException (conf, _("The JobID from the request does not match any of the Jobs running on this server"), 997 "NoSuchJob", pid); 999 if(e_type==NULL || strncasecmp(e_type->value,"json",4)!=0) 1000 errorException (conf, _("The JobID from the request does not match any of the Jobs running on this server"), 1001 "NoSuchJob", pid); 1002 else{ 1003 setMapInMaps(conf,"lenv","error","true"); 1004 setMapInMaps(conf,"lenv","code","NoSuchJob"); 1005 setMapInMaps(conf,"lenv","message",_("The JobID from the request does not match any of the Jobs running on this server")); 1006 } 998 1007 }else{ 999 1008 map* statusInfo=createMap("JobID",pid); 1000 if(isRunning(conf,pid)>0){ 1009 if(isRunning(conf,pid)>0){ 1001 1010 if(strncasecmp(req,"GetResult",strlen(req))==0){ 1002 errorException (conf, _("The result for the requested JobID has not yet been generated. The service is currently running."), 1003 "ResultNotReady", pid); 1011 if(e_type==NULL || strncasecmp(e_type->value,"json",4)!=0) 1012 errorException (conf, _("The result for the requested JobID has not yet been generated. The service is currently running."), 1013 "ResultNotReady", pid); 1014 else{ 1015 setMapInMaps(conf,"lenv","error","true"); 1016 setMapInMaps(conf,"lenv","code","ResultNotReady"); 1017 setMapInMaps(conf,"lenv","message",_("The result for the requested JobID has not yet been generated. The service is currently running.")); 1018 } 1004 1019 return; 1005 1020 } 1006 else 1021 else{ 1007 1022 if(strncasecmp(req,"GetStatus",strlen(req))==0){ 1008 1023 addToMap(statusInfo,"Status","Running"); 1024 setMapInMaps(conf,"lenv","status","Running"); 1009 1025 char* tmpStr=_getStatus(conf,pid); 1010 1026 if(tmpStr!=NULL && strncmp(tmpStr,"-1",2)!=0){ … … 1015 1031 addToMap(statusInfo,"PercentCompleted",tmpStr1); 1016 1032 addToMap(statusInfo,"Message",tmpStr0); 1033 setMapInMaps(conf,"lenv","PercentCompleted",tmpStr1); 1034 setMapInMaps(conf,"lenv","Message",tmpStr0); 1017 1035 free(tmpStr0); 1018 1036 free(tmpStr1); 1019 1037 } 1020 1038 } 1039 } 1021 1040 } 1022 1041 else{ … … 1043 1062 if(strncasecmp(req,"GetStatus",strlen(req))==0){ 1044 1063 readFinalRes(conf,pid,statusInfo); 1064 if(e_type==NULL || strncasecmp(e_type->value,"json",4)==0){ 1065 map* pmStatus=getMap(statusInfo,"status"); 1066 if(pmStatus!=NULL) 1067 setMapInMaps(conf,"lenv","status",pmStatus->value); 1068 } 1045 1069 char* tmpStr=_getStatus(conf,pid); 1046 1070 if(tmpStr!=NULL && strncmp(tmpStr,"-1",2)!=0){ … … 1051 1075 addToMap(statusInfo,"PercentCompleted",tmpStr1); 1052 1076 addToMap(statusInfo,"Message",tmpStr0); 1077 setMapInMaps(conf,"lenv","PercentCompleted",tmpStr1); 1078 setMapInMaps(conf,"lenv","Message",tmpStr0); 1053 1079 free(tmpStr0); 1054 1080 free(tmpStr1); … … 1057 1083 } 1058 1084 free(sid); 1059 printStatusInfo(conf,statusInfo,req); 1085 if(e_type==NULL || strncasecmp(e_type->value,"json",4)!=0) 1086 printStatusInfo(conf,statusInfo,req); 1087 else 1088 setMapInMaps(conf,"lenv","error","false"); 1060 1089 freeMap(&statusInfo); 1061 1090 free(statusInfo); … … 1072 1101 void runDismiss(maps* conf,char* pid){ 1073 1102 map* r_inputs = getMapFromMaps (conf, "main", "tmpPath"); 1103 map* e_type = getMapFromMaps (conf, "lenv", "executionType"); 1074 1104 char *sid=getStatusId(conf,pid); 1075 1105 if(sid==NULL){ 1076 errorException (conf, _("The JobID from the request does not match any of the Jobs running on this server"), 1077 "NoSuchJob", pid); 1106 if(e_type==NULL || strncasecmp(e_type->value,"json",4)!=0) 1107 errorException (conf, _("The JobID from the request does not match any of the Jobs running on this server"), 1108 "NoSuchJob", pid); 1109 else{ 1110 setMapInMaps(conf,"lenv","error","true"); 1111 setMapInMaps(conf,"lenv","code","NoSuchJob"); 1112 setMapInMaps(conf,"lenv","message",_("The JobID from the request does not match any of the Jobs running on this server")); 1113 } 1114 return; 1078 1115 }else{ 1079 1116 // We should send the Dismiss request to the target host if it differs … … 1115 1152 sprintf(fileName,"%s/%s",r_inputs->value,dp->d_name); 1116 1153 if(zUnlink(fileName)!=0){ 1117 errorException (conf, 1118 _("The job cannot be removed, a file cannot be removed"), 1119 "NoApplicableCode", NULL); 1154 if(e_type==NULL || strncasecmp(e_type->value,"json",4)!=0) 1155 errorException (conf, 1156 _("The job cannot be removed, a file cannot be removed"), 1157 "NoApplicableCode", NULL); 1158 else{ 1159 setMapInMaps(conf,"lenv","error","true"); 1160 setMapInMaps(conf,"lenv","code","NoApplicableCode"); 1161 setMapInMaps(conf,"lenv","message",_("The job cannot be removed, a file cannot be removed")); 1162 } 1120 1163 return; 1121 1164 } 1122 } 1123 } 1124 } 1165 1166 } 1167 } 1168 } 1169 map* pmStatusFile=getMapFromMaps(conf,"lenv","file.statusFile"); 1170 if(pmStatusFile!=NULL && zUnlink(pmStatusFile->value)!=0){ 1171 if(e_type==NULL || strncasecmp(e_type->value,"json",4)!=0) 1172 errorException (conf, 1173 _("The job cannot be removed, a file cannot be removed"), 1174 "NoApplicableCode", NULL); 1175 else{ 1176 setMapInMaps(conf,"lenv","error","true"); 1177 setMapInMaps(conf,"lenv","code","NoApplicableCode"); 1178 setMapInMaps(conf,"lenv","message",_("The job cannot be removed, a file cannot be removed")); 1179 } 1180 return; 1181 } 1125 1182 #ifdef RELY_ON_DB 1126 1183 removeService(conf,pid); 1127 1184 #endif 1128 /* No need to call 7_1 when an execution is dismissed. 1129 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 1130 invokeCallback(conf,NULL,NULL,7,1); 1131 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 1132 */ 1133 map* statusInfo=createMap("JobID",pid); 1134 addToMap(statusInfo,"Status","Dismissed"); 1135 printStatusInfo(conf,statusInfo,"Dismiss"); 1136 free(statusInfo); 1185 if(e_type==NULL || strncasecmp(e_type->value,"json",4)!=0){ 1186 /* No need to call 7_1 when an execution is dismissed. 1187 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 1188 invokeCallback(conf,NULL,NULL,7,1); 1189 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 1190 */ 1191 map* statusInfo=createMap("JobID",pid); 1192 addToMap(statusInfo,"Status","Dismissed"); 1193 printStatusInfo(conf,statusInfo,"Dismiss"); 1194 free(statusInfo); 1195 }else{ 1196 setMapInMaps(conf,"lenv","error","false"); 1197 } 1137 1198 } 1138 1199 return; … … 1249 1310 } 1250 1311 1312 /** 1313 * Create a string containing the basic error message. 1314 * 1315 * @param pmConf the main configuration maps pointer 1316 * @return a new char* containing the error message (ressource should be freed) 1317 */ 1318 char* produceErrorMessage(maps* pmConf){ 1319 char *pacTmp; 1320 map *pmLenv=getMapFromMaps(pmConf,"lenv","message"); 1321 if(pmLenv!=NULL){ 1322 pacTmp=(char*)malloc((strlen(pmLenv->value)+strlen(_("Unable to run the Service. The message returned back by the Service was the following: "))+1)*sizeof(char)); 1323 sprintf(pacTmp,_("Unable to run the Service. The message returned back by the Service was the following: %s"),pmLenv->value); 1324 } 1325 else{ 1326 pacTmp=(char*)malloc((strlen(_("Unable to run the Service. No more information was returned back by the Service."))+1)*sizeof(char)); 1327 sprintf(pacTmp,"%s",_("Unable to run the Service. No more information was returned back by the Service.")); 1328 } 1329 return pacTmp; 1330 } 1331 1251 1332 #ifdef WIN32 1252 1333 /**
Note: See TracChangeset
for help on using the changeset viewer.