Search in sources :

Example 6 with IRobotService

use of org.cerberus.crud.service.IRobotService in project cerberus-source by cerberustesting.

the class ReadRobot method findRobotByKeyTech.

private AnswerItem findRobotByKeyTech(Integer id, ApplicationContext appContext, boolean userHasPermissions) throws JSONException, CerberusException {
    AnswerItem item = new AnswerItem();
    JSONObject object = new JSONObject();
    IRobotService libService = appContext.getBean(IRobotService.class);
    // finds the project
    AnswerItem answer = libService.readByKeyTech(id);
    if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {
        // if the service returns an OK message then we can get the item and convert it to JSONformat
        Robot lib = (Robot) answer.getItem();
        if (lib != null) {
            // hide the password to the view
            lib.setHostPassword(null);
        }
        JSONObject response = convertRobotToJSONObject(lib);
        object.put("contentTable", response);
    }
    object.put("hasPermissions", userHasPermissions);
    item.setItem(object);
    item.setResultMessage(answer.getResultMessage());
    return item;
}
Also used : JSONObject(org.json.JSONObject) AnswerItem(org.cerberus.util.answer.AnswerItem) Robot(org.cerberus.crud.entity.Robot) IRobotService(org.cerberus.crud.service.IRobotService)

Aggregations

Robot (org.cerberus.crud.entity.Robot)6 IRobotService (org.cerberus.crud.service.IRobotService)6 CerberusException (org.cerberus.exception.CerberusException)5 JSONObject (org.json.JSONObject)5 IOException (java.io.IOException)4 ServletException (javax.servlet.ServletException)4 ILogEventService (org.cerberus.crud.service.ILogEventService)4 MessageEvent (org.cerberus.engine.entity.MessageEvent)4 AnswerItem (org.cerberus.util.answer.AnswerItem)4 ApplicationContext (org.springframework.context.ApplicationContext)4 RobotCapability (org.cerberus.crud.entity.RobotCapability)3 Answer (org.cerberus.util.answer.Answer)3 JSONException (org.json.JSONException)3 PolicyFactory (org.owasp.html.PolicyFactory)3 Gson (com.google.gson.Gson)2 HashMap (java.util.HashMap)2 List (java.util.List)2 PrintWriter (java.io.PrintWriter)1 Timestamp (java.sql.Timestamp)1 DateFormat (java.text.DateFormat)1