Skip to content

Commit

Permalink
You can now perform a simulation call without saving the service (all…
Browse files Browse the repository at this point in the history
…owing to tune the call before comit the change to the database)
  • Loading branch information
vertigo17 committed Feb 16, 2025
1 parent eeaae7e commit ac17b42
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 50 deletions.
1 change: 1 addition & 0 deletions source/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@
<excludes>
<exclude>src/main/webapp/dependencies/**</exclude>
<exclude>localdata/**</exclude>
<exclude>nb-configuration.xml</exclude>
</excludes>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
import org.cerberus.core.crud.service.IAppServiceService;
import org.cerberus.core.crud.service.ILogEventService;
import org.cerberus.core.service.appservice.IServiceService;
import org.cerberus.core.util.StringUtil;
import org.cerberus.core.util.answer.Answer;
import org.cerberus.core.util.answer.AnswerItem;
import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -168,6 +170,13 @@ public ResponseWrapper<String> call(
AnswerItem<AppService> ans = serviceService.callAPI(service, serviceCallDTO.getCountry(), serviceCallDTO.getEnvironment(), serviceCallDTO.getApplication(), serviceCallDTO.getSystem(),
serviceCallDTO.getTimeout(), serviceCallDTO.getKafkanb(), serviceCallDTO.getKafkaTime(), serviceCallDTO.getProps(), login);

// If the service to call is a temporary create service, we clean it right after the call.
if (service.contains(AppService.SERVICENAME_SIMULATIONCALL)) {
Answer ans1 = appServiceService.delete(
AppService.builder().service(service).build()
);
}

if (ans != null) {
try {
result.put("message", ans.getMessageDescription());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ public interface AppServiceMapperV001 {
@Mapping(source = "collection", target = "group")
AppServiceDTOV001 toDTO(AppService appService);

@InheritInverseConfiguration
@Mapping(source = "followingRedirection", target = "followRedir")
// @InheritInverseConfiguration
@Mapping(source = "followingRedirection", target = "isFollowRedir")
@Mapping(target = "kafkaFilterHeaderPath", ignore = true)
@Mapping(target = "kafkaFilterHeaderValue", ignore = true)
@Mapping(target = "avroEnable", ignore = true)
@Mapping(target = "isAvroEnable", ignore = true)
@Mapping(target = "schemaRegistryURL", ignore = true)
@Mapping(target = "avroEnableKey", ignore = true)
@Mapping(target = "isAvroEnableKey", ignore = true)
@Mapping(target = "avroSchemaKey", ignore = true)
@Mapping(target = "avroSchemaValue", ignore = true)
@Mapping(target = "avroEnableValue", ignore = true)
@Mapping(target = "isAvroEnableValue", ignore = true)
@Mapping(target = "parentContentService", ignore = true)
@Mapping(target = "proxyHost", ignore = true)
@Mapping(target = "proxyPort", ignore = true)
Expand All @@ -73,7 +73,10 @@ public interface AppServiceMapperV001 {
@Mapping(target = "bodyType", ignore = true)
@Mapping(target = "simulationParameters", ignore = true)
@Mapping(target = "authType", ignore = true)
@Mapping(target = "collection", ignore = true)
@Mapping(target = "authUser", ignore = true)
@Mapping(target = "contentList", ignore = true)
@Mapping(target = "headerList", ignore = true)
@Mapping(target = "authPassword", ignore = true)
@Mapping(target = "authAddTo", ignore = true)
@Mapping(target = "start", ignore = true)
Expand Down
21 changes: 17 additions & 4 deletions source/src/main/java/org/cerberus/core/crud/entity/AppService.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,23 @@

import java.sql.Timestamp;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
* Map la table Service
*
* @author cte
*/
@Data
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AppService {

private String service; // Name and reference of the service
Expand Down Expand Up @@ -71,10 +81,10 @@ public class AppService {
private String authAddTo;
private JSONObject simulationParameters;
private String description;
private String UsrCreated;
private Timestamp DateCreated;
private String UsrModif;
private Timestamp DateModif;
private String usrCreated;
private Timestamp dateCreated;
private String usrModif;
private Timestamp dateModif;

/**
* From here are data outside database model.
Expand Down Expand Up @@ -158,6 +168,9 @@ public class AppService {
public static final String AUTHTYPE_BASICAUTH = "Basic Auth";
public static final String AUTHADDTO_QUERYSTRING = "Query String";
public static final String AUTHADDTO_HEADERS = "Header";

public static final String SERVICENAME_SIMULATIONCALL = "$TMP";


public void addResponseHeaderList(AppServiceHeader object) {
this.responseHeaderList.add(object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2347,8 +2347,8 @@ public ArrayList<String> getSqlDocumentation() {
b.append(",('page_global','buttonLoad','','ru','Загрузить','',NULL)");
b.append(",('page_global','buttonLoad','','fr','Charger','',NULL)");
b.append(",('page_global','buttonLoad','','fa','بارگذاری','',NULL)");
b.append(",('page_global','buttonCall','','en','Save and Call','',NULL)");
b.append(",('page_global','buttonCall','','fr','Sauvegarder et Appeler','',NULL)");
b.append(",('page_global','buttonCall','','en','Call','',NULL)");
b.append(",('page_global','buttonCall','','fr','Appeler','',NULL)");
b.append(",('page_global','button_massAction','','en','Mass Action',NULL,NULL)");
b.append(",('page_global','button_massAction','','ru','Массовая операция',NULL,NULL)");
b.append(",('page_global','button_massAction','','fr','Action en masse',NULL,NULL)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ final void processRequest(final HttpServletRequest request, final HttpServletRes
// Parameter that are already controled by GUI (no need to decode) --> We SECURE them
// Parameter that needs to be secured --> We SECURE+DECODE them
String service = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(fileData.get("service"), null, charset);
String originalService = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(fileData.get("originalService"), null, charset);

String collection = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(fileData.get("collection"), "", charset);
String description = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(fileData.get("description"), "", charset);
String attachementurl = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(fileData.get("attachementurl"), "", charset);
Expand Down Expand Up @@ -197,6 +199,11 @@ final void processRequest(final HttpServletRequest request, final HttpServletRes
appService.setAuthUser(authUser);
appService.setAuthPassword(authPass);
appService.setAuthAddTo(authAddTo);
if (StringUtil.SECRET_STRING.equals(authPass)) {
AppService appServiceTmp = appServiceService.findAppServiceByKey(originalService);
authPass = appServiceTmp.getAuthPassword();
appService.setAuthPassword(authPass);
}
ans = appServiceService.create(appService);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, ans);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[square]
* Campaign execution can now be cancelled, paused and resumed #2211
* Allow basic authentication with only user or password.
* You can now perform a service simulation call without saving the service (allowing to tune the call before commit the change to the database)

*Warning to be considered before applying the version (deprecated features)*
[square]
Expand Down
18 changes: 9 additions & 9 deletions source/src/main/webapp/include/transversalobject/AppService.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h4 class="modal-title" id="editSoapLibraryModalLabel" name="editSoapLibraryFiel
<div class="form-group col-md-6 col-sm-12">
<label for="service" name="serviceField" class="col">Service</label>
<input type="text" class="form-control" name="service" id="service" aria-describedby="basic-editon1"> </input>
<input type="text" class="form-control input-sm" name="originalService" id="originalService" style="display:none;"/>
<input type="text" class="form-control" name="originalService" id="originalService" style="display:none;"/>
</div>
<div class="form-group col-md-4 col-sm-8">
<label for="type" name="typeField">Type</label>
Expand Down Expand Up @@ -58,10 +58,10 @@ <h4 class="modal-title" id="editSoapLibraryModalLabel" name="editSoapLibraryFiel
<input type="text" class="form-control" name="collection" id="collection"
aria-describedby="basic-editon1" autocomplete="off">
</div>
<div class="form-group form-group-sm col-md-6">
<div class="form-group col-md-6">
<label class="control-label" for="application" name="applicationField">Application</label>
<div class="input-group col-xs-12">
<select type="text" class="form-control input-sm" name="application" id="application" style="width:100%;"></select>
<select type="text" class="form-control" name="application" id="application" style="width:100%;"></select>
<span class="input-group-btn">
<button type="button" id="editApplication" class="btn btn-sm btn-default"><span class="glyphicon glyphicon-pencil"></span></button>
</span>
Expand Down Expand Up @@ -191,7 +191,7 @@ <h3 id ="dropzoneText"> Drag and drop Files <span class="glyphicon glyphicon-do
<div class="form-group form-group-sm col-sm-12">
<label class="control-label" for="parentContentService" name="parentContentServiceField">Parent Service</label>
<div class="input-group col-xs-12">
<select type="text" class="form-control input-sm" name="parentContentService" id="parentContentService" style="width:100%;"></select>
<select type="text" class="form-control" name="parentContentService" id="parentContentService" style="width:100%;"></select>
</div>
</div>
</div>
Expand Down Expand Up @@ -275,10 +275,10 @@ <h3 id ="dropzoneText"> Drag and drop Files <span class="glyphicon glyphicon-do
</div>
<div class="center marginTop25 tab-pane fade in" id="tabsEdit-7">
<div class="row" id="authTypeSection">
<div class="form-group form-group-sm col-md-6">
<div class="form-group col-md-6">
<label class="control-label" for="authType" name="authTypeField">Authorization Type</label>
<div class="input-group col-xs-12">
<select type="text" class="form-control input-sm" name="authType" id="authType" style="width:100%;"></select>
<select type="text" class="form-control" name="authType" id="authType" style="width:100%;"></select>
</div>
</div>
</div>
Expand All @@ -295,10 +295,10 @@ <h3 id ="dropzoneText"> Drag and drop Files <span class="glyphicon glyphicon-do
</div>
</div>
<div class="row" id="authAddToSection">
<div class="form-group form-group-sm col-md-6">
<div class="form-group col-md-6">
<label class="control-label" for="authAddTo" name="authAddToField">Add To</label>
<div class="input-group col-xs-12">
<select type="text" class="form-control input-sm" name="authAddTo" id="authAddTo" style="width:100%;"></select>
<select type="text" class="form-control" name="authAddTo" id="authAddTo" style="width:100%;"></select>
</div>
</div>
</div>
Expand Down Expand Up @@ -372,7 +372,6 @@ <h3 id ="dropzoneText"> Drag and drop Files <span class="glyphicon glyphicon-do
<button type="button" id="addSoapLibraryButton" class="btn btn-primary pull-right" name="buttonAdd">Add</button>
<button type="button" id="duplicateSoapLibraryButton" class="btn btn-primary pull-right" name="buttonDuplicate">Duplicate</button>
<button type="button" class="btn btn-default pull-right marginLeft5" data-dismiss="modal" name="buttonClose">Close</button>
<button type="button" id="callSoapLibraryButton" class="btn btn-primary pull-right" name="buttonCall">Save and Call</button>
</div>
</td>
</tr>
Expand All @@ -387,6 +386,7 @@ <h3 id ="dropzoneText"> Drag and drop Files <span class="glyphicon glyphicon-do
<li><a data-toggle="tab" class="marginTop10" href="#tabsSimul-2" id="tabSimulDetails" name="tabsSimul2">Response Details</a></li>
<li><a data-toggle="tab" class="marginTop10" href="#tabsSimul-3" id="tabSimulRequest" name="tabsSimul3">Request</a></li>
<li><a data-toggle="tab" class="marginTop10" href="#tabsSimul-5" id="tabSimulRequestDetails" name="tabsSimul5">Request Details</a></li>
<button type="button" id="callSoapLibraryButton" class="btn btn-primary pull-right marginTop10" name="buttonCall">Call</button>
</ul>
<div class="tab-content">
<div class="center marginTop25 tab-pane fade in" id="tabsSimul-1">
Expand Down
16 changes: 8 additions & 8 deletions source/src/main/webapp/js/pages/AppServiceList.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,35 +380,35 @@ function aoColumnsFunc(tableId) {
"sWidth": "200px",
"title": doc.getDocLabel("appservice", "description")
}, {
"sName": "srv.DateCreated",
"sName": "srv.dateCreated",
"visible": false,
"like": true,
"data": "DateCreated",
"data": "dateCreated",
"sWidth": "150px",
"title": doc.getDocOnline("transversal", "DateCreated"),
"mRender": function (data, type, oObj) {
return getDate(oObj["DateCreated"]);
}
}, {
"sName": "srv.UsrCreated",
"sName": "srv.usrCreated",
"visible": false,
"data": "UsrCreated",
"data": "usrCreated",
"sWidth": "70px",
"title": doc.getDocOnline("transversal", "UsrCreated")
}, {
"sName": "srv.DateModif",
"sName": "srv.dateModif",
"visible": false,
"like": true,
"data": "DateModif",
"data": "dateModif",
"sWidth": "150px",
"title": doc.getDocOnline("transversal", "DateModif"),
"mRender": function (data, type, oObj) {
return getDate(oObj["DateModif"]);
}
}, {
"sName": "srv.UsrModif",
"sName": "srv.usrModif",
"visible": false,
"data": "UsrModif",
"data": "usrModif",
"sWidth": "70px",
"title": doc.getDocOnline("transversal", "UsrModif")
}];
Expand Down
Loading

0 comments on commit ac17b42

Please sign in to comment.