@Test public void testInvalidService() { final KieServerControllerServiceResponse response = service.executeCommand(new KieServerControllerDescriptorCommand("service", "method")); assertNotNull(response); assertEquals(FAILURE, response.getType()); }
@Override public KieServerControllerServiceResponse executeCommand(final KieServerControllerDescriptorCommand command) { if (command == null) { return new KieServerControllerServiceResponse(ResponseType.FAILURE, "Command can not be null"); } try { Object result = null; Object handler = null; if (SpecManagementService.class.getName().equals(command.getService())) { handler = specManagementService; } else if (RuntimeManagementService.class.getName().equals(command.getService())) { handler = runtimeManagementService; } else if (RuleCapabilitiesService.class.getName().equals(command.getService())) { handler = ruleCapabilitiesService; } else { throw new IllegalStateException("Unable to find handler for " + command.getService() + " service"); } LOGGER.debug("Service handler: {}", handler); LOGGER.debug("Command arguments size: {}", command.getArguments().size()); List<Object> arguments = new ArrayList<>(); for (Object arg : command.getArguments()) { LOGGER.debug("Before :: Argument with type {} and value {}", arg == null ? "null" : arg.getClass(), arg); if (arg instanceof Wrapped) { arg = ((Wrapped) arg).unwrap(); } LOGGER.debug("After :: Argument with type {} and value {}", arg == null ? "null" : arg.getClass(), arg); arguments.add(arg); } LOGGER.debug("About to execute {} operation on {} with args {}", command.getMethod(), handler, arguments); result = MethodUtils.invokeMethod(handler, command.getMethod(), arguments.toArray()); LOGGER.debug("Handler {} returned response {}", handler, result); return new KieServerControllerServiceResponse(ResponseType.SUCCESS, "", result); } catch (InvocationTargetException e) { LOGGER.error("Failed to invoke service method", e); return new KieServerControllerServiceResponse(ResponseType.FAILURE, e.getTargetException().getMessage()); } catch (Throwable e) { LOGGER.error("Error while processing {} command", command, e); return new KieServerControllerServiceResponse(ResponseType.FAILURE, e.getMessage()); } }
KieServerMgmtCommandServiceImpl implements KieServerMgmtCommandService { @Override public KieServerControllerServiceResponse executeCommand(final KieServerControllerDescriptorCommand command) { if (command == null) { return new KieServerControllerServiceResponse(ResponseType.FAILURE, "Command can not be null"); } try { Object result = null; Object handler = null; if (SpecManagementService.class.getName().equals(command.getService())) { handler = specManagementService; } else if (RuntimeManagementService.class.getName().equals(command.getService())) { handler = runtimeManagementService; } else if (RuleCapabilitiesService.class.getName().equals(command.getService())) { handler = ruleCapabilitiesService; } else { throw new IllegalStateException("Unable to find handler for " + command.getService() + " service"); } LOGGER.debug("Service handler: {}", handler); LOGGER.debug("Command arguments size: {}", command.getArguments().size()); List<Object> arguments = new ArrayList<>(); for (Object arg : command.getArguments()) { LOGGER.debug("Before :: Argument with type {} and value {}", arg == null ? "null" : arg.getClass(), arg); if (arg instanceof Wrapped) { arg = ((Wrapped) arg).unwrap(); } LOGGER.debug("After :: Argument with type {} and value {}", arg == null ? "null" : arg.getClass(), arg); arguments.add(arg); } LOGGER.debug("About to execute {} operation on {} with args {}", command.getMethod(), handler, arguments); result = MethodUtils.invokeMethod(handler, command.getMethod(), arguments.toArray()); LOGGER.debug("Handler {} returned response {}", handler, result); return new KieServerControllerServiceResponse(ResponseType.SUCCESS, "", result); } catch (InvocationTargetException e) { LOGGER.error("Failed to invoke service method", e); return new KieServerControllerServiceResponse(ResponseType.FAILURE, e.getTargetException().getMessage()); } catch (Throwable e) { LOGGER.error("Error while processing {} command", command, e); return new KieServerControllerServiceResponse(ResponseType.FAILURE, e.getMessage()); } } }
KieServerMgmtCommandServiceImpl implements KieServerMgmtCommandService { @Override public KieServerControllerServiceResponse executeCommand(final KieServerControllerDescriptorCommand command) { if (command == null) { return new KieServerControllerServiceResponse(ResponseType.FAILURE, "Command can not be null"); } try { Object result = null; Object handler = null; if (SpecManagementService.class.getName().equals(command.getService())) { handler = specManagementService; } else if (RuntimeManagementService.class.getName().equals(command.getService())) { handler = runtimeManagementService; } else if (RuleCapabilitiesService.class.getName().equals(command.getService())) { handler = ruleCapabilitiesService; } else { throw new IllegalStateException("Unable to find handler for " + command.getService() + " service"); } LOGGER.debug("Service handler: {}", handler); LOGGER.debug("Command arguments size: {}", command.getArguments().size()); List<Object> arguments = new ArrayList<>(); for (Object arg : command.getArguments()) { LOGGER.debug("Before :: Argument with type {} and value {}", arg == null ? "null" : arg.getClass(), arg); if (arg instanceof Wrapped) { arg = ((Wrapped) arg).unwrap(); } LOGGER.debug("After :: Argument with type {} and value {}", arg == null ? "null" : arg.getClass(), arg); arguments.add(arg); } LOGGER.debug("About to execute {} operation on {} with args {}", command.getMethod(), handler, arguments); result = MethodUtils.invokeMethod(handler, command.getMethod(), arguments.toArray()); LOGGER.debug("Handler {} returned response {}", handler, result); return new KieServerControllerServiceResponse(ResponseType.SUCCESS, "", result); } catch (InvocationTargetException e) { LOGGER.error("Failed to invoke service method", e); return new KieServerControllerServiceResponse(ResponseType.FAILURE, e.getTargetException().getMessage()); } catch (Throwable e) { LOGGER.error("Error while processing {} command", command, e); return new KieServerControllerServiceResponse(ResponseType.FAILURE, e.getMessage()); } } private  KieServerMgmtCommandServiceImpl(); }
KieServerMgmtCommandServiceImpl implements KieServerMgmtCommandService { @Override public KieServerControllerServiceResponse executeCommand(final KieServerControllerDescriptorCommand command) { if (command == null) { return new KieServerControllerServiceResponse(ResponseType.FAILURE, "Command can not be null"); } try { Object result = null; Object handler = null; if (SpecManagementService.class.getName().equals(command.getService())) { handler = specManagementService; } else if (RuntimeManagementService.class.getName().equals(command.getService())) { handler = runtimeManagementService; } else if (RuleCapabilitiesService.class.getName().equals(command.getService())) { handler = ruleCapabilitiesService; } else { throw new IllegalStateException("Unable to find handler for " + command.getService() + " service"); } LOGGER.debug("Service handler: {}", handler); LOGGER.debug("Command arguments size: {}", command.getArguments().size()); List<Object> arguments = new ArrayList<>(); for (Object arg : command.getArguments()) { LOGGER.debug("Before :: Argument with type {} and value {}", arg == null ? "null" : arg.getClass(), arg); if (arg instanceof Wrapped) { arg = ((Wrapped) arg).unwrap(); } LOGGER.debug("After :: Argument with type {} and value {}", arg == null ? "null" : arg.getClass(), arg); arguments.add(arg); } LOGGER.debug("About to execute {} operation on {} with args {}", command.getMethod(), handler, arguments); result = MethodUtils.invokeMethod(handler, command.getMethod(), arguments.toArray()); LOGGER.debug("Handler {} returned response {}", handler, result); return new KieServerControllerServiceResponse(ResponseType.SUCCESS, "", result); } catch (InvocationTargetException e) { LOGGER.error("Failed to invoke service method", e); return new KieServerControllerServiceResponse(ResponseType.FAILURE, e.getTargetException().getMessage()); } catch (Throwable e) { LOGGER.error("Error while processing {} command", command, e); return new KieServerControllerServiceResponse(ResponseType.FAILURE, e.getMessage()); } } private  KieServerMgmtCommandServiceImpl(); static KieServerMgmtCommandServiceImpl getInstance(); void setTemplateStorage(final KieServerTemplateStorage templateStorage); void setNotificationService(final NotificationService notificationService); @Override KieServerControllerServiceResponse executeCommand(final KieServerControllerDescriptorCommand command); }
KieServerMgmtCommandServiceImpl implements KieServerMgmtCommandService { @Override public KieServerControllerServiceResponse executeCommand(final KieServerControllerDescriptorCommand command) { if (command == null) { return new KieServerControllerServiceResponse(ResponseType.FAILURE, "Command can not be null"); } try { Object result = null; Object handler = null; if (SpecManagementService.class.getName().equals(command.getService())) { handler = specManagementService; } else if (RuntimeManagementService.class.getName().equals(command.getService())) { handler = runtimeManagementService; } else if (RuleCapabilitiesService.class.getName().equals(command.getService())) { handler = ruleCapabilitiesService; } else { throw new IllegalStateException("Unable to find handler for " + command.getService() + " service"); } LOGGER.debug("Service handler: {}", handler); LOGGER.debug("Command arguments size: {}", command.getArguments().size()); List<Object> arguments = new ArrayList<>(); for (Object arg : command.getArguments()) { LOGGER.debug("Before :: Argument with type {} and value {}", arg == null ? "null" : arg.getClass(), arg); if (arg instanceof Wrapped) { arg = ((Wrapped) arg).unwrap(); } LOGGER.debug("After :: Argument with type {} and value {}", arg == null ? "null" : arg.getClass(), arg); arguments.add(arg); } LOGGER.debug("About to execute {} operation on {} with args {}", command.getMethod(), handler, arguments); result = MethodUtils.invokeMethod(handler, command.getMethod(), arguments.toArray()); LOGGER.debug("Handler {} returned response {}", handler, result); return new KieServerControllerServiceResponse(ResponseType.SUCCESS, "", result); } catch (InvocationTargetException e) { LOGGER.error("Failed to invoke service method", e); return new KieServerControllerServiceResponse(ResponseType.FAILURE, e.getTargetException().getMessage()); } catch (Throwable e) { LOGGER.error("Error while processing {} command", command, e); return new KieServerControllerServiceResponse(ResponseType.FAILURE, e.getMessage()); } } private  KieServerMgmtCommandServiceImpl(); static KieServerMgmtCommandServiceImpl getInstance(); void setTemplateStorage(final KieServerTemplateStorage templateStorage); void setNotificationService(final NotificationService notificationService); @Override KieServerControllerServiceResponse executeCommand(final KieServerControllerDescriptorCommand command);  }