public ProcessServiceBase(ProcessService processService, DefinitionService definitionService, RuntimeDataService runtimeDataService, KieServerRegistry context) { this.processService = processService; this.definitionService = definitionService; this.runtimeDataService = runtimeDataService; this.marshallerHelper = new MarshallerHelper(context); this.context = context; }
@Override public BaseQueryFilterSpec getQueryFilterSpec() { return marshallerHelper.unmarshal(payload, marshallingType, ProcessInstanceQueryFilterSpec.class); } };
public String saveContent(String containerId, Number taskId, String payload, String marshallingType) { containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue())); logger.debug("About to unmarshal task content parameters from payload: '{}'", payload); Map<String, Object> parameters = marshallerHelper.unmarshal(containerId, payload, marshallingType, Map.class); logger.debug("About to set content of a task with id '{}' with data {}", taskId, parameters); Long contentId = userTaskService.saveContent(containerId, taskId.longValue(), parameters); String response = marshallerHelper.marshal(containerId, marshallingType, contentId); return response; }
public String marshal(String marshallingFormat, Object entity) { MarshallingFormat format = getFormat(marshallingFormat); if (format == null) { throw new IllegalArgumentException("Unknown marshalling format " + marshallingFormat); } Marshaller marshaller = serverMarshallers.get(format); if (marshaller == null) { marshaller = MarshallerFactory.getMarshaller(getExtraClasses(registry), format, this.getClass().getClassLoader()); serverMarshallers.put(format, marshaller); } return marshaller.marshall(entity); }
public String getAttachmentContentById(String containerId, Number taskId, Number attachmentId, String marshallingType) { containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue())); Object attachment = userTaskService.getAttachmentContentById(containerId, taskId.longValue(), attachmentId.longValue()); if (attachment == null) { throw new IllegalStateException("No attachment found for id " + attachmentId + " for task " + taskId); } logger.debug("About to marshal task attachment with id '{}' {}", attachmentId, attachment); String response = marshallerHelper.marshal(containerId, marshallingType, attachment); return response; }
public String marshal(String containerId, String marshallingFormat, Object entity, ContainerLocator locator) { MarshallingFormat format = getFormat(marshallingFormat); if (format == null) { throw new IllegalArgumentException("Unknown marshalling format " + marshallingFormat); } KieContainerInstance containerInstance = registry.getContainer(containerId, locator); if (containerInstance == null) { throw new IllegalArgumentException("No container found for id " + containerId + " ."); } Marshaller marshaller = containerInstance.getMarshaller(format); if (marshaller == null) { throw new IllegalArgumentException("No marshaller found for format " + format); } return marshaller.marshall(entity); }
public String getProcessInstanceVariable(String containerId, Number processInstanceId, String varName, String marshallingType) { containerId = context.getContainerId(containerId, new ByProcessInstanceIdContainerLocator(processInstanceId.longValue())); Object variable = processService.getProcessInstanceVariable(containerId, processInstanceId.longValue(), varName); if (variable == null) { throw new IllegalStateException("Unable to find variable '"+ varName + "' within process instance with id " + processInstanceId); } logger.debug("About to marshal process variable with name '{}' {}", varName, variable); String response = marshallerHelper.marshal(containerId, marshallingType, variable); return response; }
public <T> T unmarshal(String data, String marshallingFormat, Class<T> unmarshalType) { if (data == null || data.isEmpty()) { return null; } MarshallingFormat format = getFormat(marshallingFormat); Marshaller marshaller = serverMarshallers.get(format); if (marshaller == null) { marshaller = MarshallerFactory.getMarshaller(getExtraClasses(registry), format, this.getClass().getClassLoader()); serverMarshallers.put(format, marshaller); } Object instance = marshaller.unmarshall(data, unmarshalType); if (instance instanceof Wrapped) { return (T) ((Wrapped) instance).unwrap(); } return (T) instance; }
public <T> T unmarshal(String containerId, String data, String marshallingFormat, Class<T> unmarshalType, ContainerLocator locator) { if (data == null || data.isEmpty()) { return null; } MarshallingFormat format = getFormat(marshallingFormat); KieContainerInstance containerInstance = registry.getContainer(containerId, locator); if (containerInstance == null || format == null) { throw new IllegalArgumentException("No container found for id " + containerId + " or unknown marshalling format " + marshallingFormat); } Marshaller marshaller = containerInstance.getMarshaller(format); if (marshaller == null) { throw new IllegalArgumentException("No marshaller found for format " + format); } Object instance = marshaller.unmarshall(data, unmarshalType); if (instance instanceof Wrapped) { return (T) ((Wrapped) instance).unwrap(); } return (T) instance; }
@Override public BaseQueryFilterSpec getQueryFilterSpec() { return marshallerHelper.unmarshal(payload, marshallingType, TaskQueryFilterSpec.class); }
public String addAttachment(String containerId, Number taskId, String userId, String name, String attachmentPayload, String marshallingType) { containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue())); logger.debug("About to unmarshal task attachment from payload: '{}'", attachmentPayload); Object attachment = marshallerHelper.unmarshal(containerId, attachmentPayload, marshallingType, Object.class); logger.debug("About to add attachment on a task with id '{}' with data {}", taskId, attachment); Long attachmentId = userTaskService.addAttachment(containerId, taskId.longValue(), getUser(userId), name, attachment); String response = marshallerHelper.marshal(containerId, marshallingType, attachmentId); return response; }
public ProcessAdminServiceBase(ProcessInstanceMigrationService processInstanceMigrationService, ProcessInstanceAdminService processInstanceAdminService, KieServerRegistry context) { this.processInstanceMigrationService = processInstanceMigrationService; this.processInstanceAdminService = processInstanceAdminService; this.marshallerHelper = new MarshallerHelper(context); this.context = context; }
public String getTaskOutputContentByTaskId(String containerId, Number taskId, String marshallingType) { containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue())); Map<String, Object> variables = userTaskService.getTaskOutputContentByTaskId(containerId, taskId.longValue()); logger.debug("About to marshal task '{}' output variables {}", taskId, variables); String response = marshallerHelper.marshal(containerId, marshallingType, variables); return response; }
public void updateRequestData(long requestId, String containerId, String payload, String marshallingType) { Map<String, Object> data = null; if (containerId != null && !containerId.isEmpty()) { logger.debug("About to unmarshal job data from payload: '{}' using container {} marshaller", payload, containerId); data = marshallerHelper.unmarshal(containerId, payload, marshallingType, Map.class); } else { logger.debug("About to unmarshal job data from payload: '{}' using server marshaller", payload); data = marshallerHelper.unmarshal(payload, marshallingType, Map.class); } logger.debug("About to update job's ( with id {}) data {}", requestId, data); executorService.updateRequestData(requestId, data); }
public String addCommentToCase(String containerId, String caseId, String author, List<String> restrictions, String comment, String marshallingType) { verifyContainerId(containerId, caseId); author = getUser(author); String actualComment = marshallerHelper.unmarshal(containerId, comment, marshallingType, String.class, new ByCaseIdContainerLocator(caseId)); logger.debug("Adding comment to case {} by {} with text '{}' with restrictions {}", caseId, author, actualComment, restrictions); String commentId = caseService.addCaseComment(caseId, author, actualComment, restrictions.toArray(new String[restrictions.size()])); return marshallerHelper.marshal(containerId, marshallingType, commentId); }
public CaseAdminServiceBase(CaseInstanceMigrationService caseInstanceMigrationService, KieServerRegistry context) { this.caseInstanceMigrationService = caseInstanceMigrationService; this.marshallerHelper = new MarshallerHelper(context); this.context = context; }
public String getProcessInstanceVariables(String containerId, Number processInstanceId, String marshallingType) { containerId = context.getContainerId(containerId, new ByProcessInstanceIdContainerLocator(processInstanceId.longValue())); Map<String, Object> variables = processService.getProcessInstanceVariables(containerId, processInstanceId.longValue()); logger.debug("About to marshal process variables {}", variables); String response = marshallerHelper.marshal(containerId, marshallingType, variables); return response; }
public void signal(String containerId, String signalName, String eventPayload, String marshallingType) { logger.debug("About to unmarshal event from payload: '{}'", eventPayload); Object event = marshallerHelper.unmarshal(containerId, eventPayload, marshallingType, Object.class); logger.debug("Calling signal '{}' on container {} and event {}", signalName, containerId, event); processService.signalEvent(containerId, signalName, event); }
public String notifyWhenNotStarted(String containerId, Number taskId, String timeExpression, String payload, String marshallingType) { logger.debug("About to unmarshall payload '{}' to EmailNotification (when not started) of task inputs", payload); containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue())); EmailNotification emailNotification = marshallerHelper.unmarshal(containerId, payload, marshallingType, EmailNotification.class, new ByTaskIdContainerLocator(taskId.longValue())); logger.debug("Email notification to be added to a task {} is {}", taskId, emailNotification); org.kie.internal.task.api.model.EmailNotification email = buildEmail(emailNotification); Long id = userTaskAdminService.notifyWhenNotStarted(containerId, taskId.longValue(), timeExpression, email); logger.debug("Email notification (when not started) {} added successfully to task {} to be fired after {}", emailNotification, taskId, timeExpression); String response = marshallerHelper.marshal(containerId, marshallingType, id, new ByTaskIdContainerLocator(taskId.longValue())); return response; }
public CommandResource(KieContainerCommandService delegate, KieServerRegistry registry) { this.delegate = delegate; this.registry = registry; this.marshallerHelper = new MarshallerHelper(registry); }