Skip to content

Commit

Permalink
BZ-1001527 - Fix for serialization of jbpm-audit commands (cherry pic…
Browse files Browse the repository at this point in the history
…ked from commit 99707cf)
  • Loading branch information
Marco Rietveld committed Sep 26, 2013
1 parent 0acb6c5 commit d895133
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@
import org.drools.core.command.runtime.rule.FireAllRulesCommand;
import org.drools.core.command.runtime.rule.InsertObjectCommand;
import org.drools.core.command.runtime.rule.UpdateCommand;
import org.jbpm.process.audit.command.ClearHistoryLogsCommand;
import org.jbpm.process.audit.command.FindActiveProcessInstancesCommand;
import org.jbpm.process.audit.command.FindNodeInstancesCommand;
import org.jbpm.process.audit.command.FindProcessInstanceCommand;
import org.jbpm.process.audit.command.FindProcessInstancesCommand;
import org.jbpm.process.audit.command.FindSubProcessInstancesCommand;
import org.jbpm.process.audit.command.FindVariableInstancesCommand;
import org.jbpm.services.task.commands.*;

public class AcceptedCommands {

private static Set<Class> acceptedCommands = new HashSet<Class>();
static {

acceptedCommands.add(AbortWorkItemCommand.class);
acceptedCommands.add(CompleteWorkItemCommand.class);
acceptedCommands.add(GetWorkItemCommand.class);
Expand Down Expand Up @@ -73,6 +79,15 @@ public class AcceptedCommands {
acceptedCommands.add(StopTaskCommand.class);
acceptedCommands.add(SuspendTaskCommand.class);

// audit commands
acceptedCommands.add(ClearHistoryLogsCommand.class);
acceptedCommands.add(FindActiveProcessInstancesCommand.class);
acceptedCommands.add(FindNodeInstancesCommand.class);
acceptedCommands.add(FindProcessInstanceCommand.class);
acceptedCommands.add(FindProcessInstancesCommand.class);
acceptedCommands.add(FindSubProcessInstancesCommand.class);
acceptedCommands.add(FindVariableInstancesCommand.class);

acceptedCommands = Collections.unmodifiableSet(acceptedCommands);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;

import org.drools.core.command.GetVariableCommand;
import org.drools.core.command.runtime.*;
import org.drools.core.command.runtime.process.*;
import org.drools.core.command.runtime.rule.*;
import org.jbpm.process.audit.command.ClearHistoryLogsCommand;
import org.jbpm.process.audit.command.FindActiveProcessInstancesCommand;
import org.jbpm.process.audit.command.FindNodeInstancesCommand;
import org.jbpm.process.audit.command.FindProcessInstanceCommand;
import org.jbpm.process.audit.command.FindProcessInstancesCommand;
import org.jbpm.process.audit.command.FindSubProcessInstancesCommand;
import org.jbpm.process.audit.command.FindVariableInstancesCommand;
import org.jbpm.services.task.commands.*;
import org.kie.api.command.Command;

Expand All @@ -32,64 +40,34 @@ public class JaxbCommandsRequest {
@XmlSchemaType(name = "int")
private Integer version = 1;

// This list should match the list in AcceptedCommands
@XmlElements({
@XmlElement(name = "abort-process-instance", type = AbortProcessInstanceCommand.class),
@XmlElement(name = "abort-work-item", type = AbortWorkItemCommand.class),
@XmlElement(name = "complete-work-item", type = CompleteWorkItemCommand.class),
@XmlElement(name = "create-correlated-process-instance", type = CreateCorrelatedProcessInstanceCommand.class),
@XmlElement(name = "create-process-instance", type = CreateProcessInstanceCommand.class),
@XmlElement(name = "get-process-event-listeners", type = GetProcessEventListenersCommand.class),
@XmlElement(name = "get-process-instance", type = GetProcessInstanceCommand.class),
@XmlElement(name = "abort-work-item", type = AbortWorkItemCommand.class),
@XmlElement(name = "get-workitem", type = GetWorkItemCommand.class),

@XmlElement(name = "abort-process-instance", type = AbortProcessInstanceCommand.class),
@XmlElement(name = "get-process-ids", type = GetProcessIdsCommand.class),
@XmlElement(name = "get-process-instance-by-correlation-key", type = GetProcessInstanceByCorrelationKeyCommand.class),
@XmlElement(name = "get-process-instance", type = GetProcessInstanceCommand.class),
@XmlElement(name = "get-process-instances", type = GetProcessInstancesCommand.class),
@XmlElement(name = "get-workitem", type = GetWorkItemCommand.class),
@XmlElement(name = "register-workitem-handler", type = RegisterWorkItemHandlerCommand.class),
@XmlElement(name = "set-process-instance-vars", type = SetProcessInstanceVariablesCommand.class),
@XmlElement(name = "signal-event", type = SignalEventCommand.class),
@XmlElement(name = "start-correlated-process", type = StartCorrelatedProcessCommand.class),
@XmlElement(name = "start-process", type = StartProcessCommand.class),
@XmlElement(name = "start-process-instance", type = StartProcessInstanceCommand.class),

@XmlElement(name = "agenda-group-set-focus", type = AgendaGroupSetFocusCommand.class),
@XmlElement(name = "clear-activation-group", type = ClearActivationGroupCommand.class),
@XmlElement(name = "clear-agenda", type = ClearAgendaCommand.class),
@XmlElement(name = "clear-agenda-group", type = ClearAgendaGroupCommand.class),
@XmlElement(name = "clear-ruleflow-group", type = ClearRuleFlowGroupCommand.class),
@XmlElement(name = "delete", type = DeleteCommand.class),
@XmlElement(name = "fire-all-rules", type = FireAllRulesCommand.class),
@XmlElement(name = "fire-until-halt", type = FireUntilHaltCommand.class),
@XmlElement(name = "from-external-fact-handle", type = FromExternalFactHandleCommand.class),
@XmlElement(name = "get-agenda-event-listeners", type = GetAgendaEventListenersCommand.class),
@XmlElement(name = "get-entry-point", type = GetEntryPointCommand.class),
@XmlElement(name = "get-entry-points", type = GetEntryPointsCommand.class),
@XmlElement(name = "get-fact-handle", type = GetFactHandleCommand.class),
@XmlElement(name = "get-fact-handles", type = GetFactHandlesCommand.class),
@XmlElement(name = "get-object", type = GetObjectCommand.class),
@XmlElement(name = "get-objects", type = GetObjectsCommand.class),
@XmlElement(name = "get-working-memory-event-listeners", type = GetWorkingMemoryEventListenersCommand.class),
@XmlElement(name = "halt", type = HaltCommand.class),
@XmlElement(name = "insert-elements", type = InsertElementsCommand.class),
@XmlElement(name = "insert-object", type = InsertObjectCommand.class),
@XmlElement(name = "insert-object-in-entry-point", type = InsertObjectInEntryPointCommand.class),
@XmlElement(name = "modify", type = ModifyCommand.class),
@XmlElement(name = "query", type = QueryCommand.class),
@XmlElement(name = "update", type = UpdateCommand.class),

@XmlElement(name = "destroy-session", type = DestroySessionCommand.class),
@XmlElement(name = "dispose", type = DisposeCommand.class),
@XmlElement(name = "get-calendars", type = GetCalendarsCommand.class),
@XmlElement(name = "get-channels", type = GetChannelsCommand.class),
@XmlElement(name = "get-environment", type = GetEnvironmentCommand.class),

@XmlElement(name = "get-variable", type = GetVariableCommand.class),
@XmlElement(name = "get-fact-count", type = GetFactCountCommand.class),
@XmlElement(name = "get-global", type = GetGlobalCommand.class),
@XmlElement(name = "get-globals", type = GetGlobalsCommand.class),
@XmlElement(name = "get-id", type = GetIdCommand.class),
@XmlElement(name = "get-knowledge-base", type = GetKnowledgeBaseCommand.class),
@XmlElement(name = "kbuilder-set-property", type = KBuilderSetPropertyCommand.class),
@XmlElement(name = "register-channel", type = RegisterChannelCommand.class),
@XmlElement(name = "remove-event-listener", type = RemoveEventListenerCommand.class),
@XmlElement(name = "set-global", type = SetGlobalCommand.class),
@XmlElement(name = "unregister-channel", type = UnregisterChannelCommand.class),


@XmlElement(name = "delete", type = DeleteCommand.class),
@XmlElement(name = "fire-all-rules", type = FireAllRulesCommand.class),
@XmlElement(name = "insert-object", type = InsertObjectCommand.class),
@XmlElement(name = "update", type = UpdateCommand.class),

// task
@XmlElement(name = "activate-task", type = ActivateTaskCommand.class),
@XmlElement(name = "add-task", type = AddTaskCommand.class),
@XmlElement(name = "claim-next-available-task", type = ClaimNextAvailableTaskCommand.class),
Expand All @@ -114,7 +92,17 @@ public class JaxbCommandsRequest {
@XmlElement(name = "skip-task", type = SkipTaskCommand.class),
@XmlElement(name = "start-task", type = StartTaskCommand.class),
@XmlElement(name = "stop-task", type = StopTaskCommand.class),
@XmlElement(name = "suspend-task", type = SuspendTaskCommand.class) })
@XmlElement(name = "suspend-task", type = SuspendTaskCommand.class),

// audit
@XmlElement(name = "clear-history-logs", type = ClearHistoryLogsCommand.class),
@XmlElement(name = "find-active-process-instances", type = FindActiveProcessInstancesCommand.class),
@XmlElement(name = "find-node-instances", type = FindNodeInstancesCommand.class),
@XmlElement(name = "find-process-instance", type = FindProcessInstanceCommand.class),
@XmlElement(name = "find-process-instances", type = FindProcessInstancesCommand.class),
@XmlElement(name = "find-subprocess-instances", type = FindSubProcessInstancesCommand.class),
@XmlElement(name = "find-variable-instances", type = FindVariableInstancesCommand.class)
})
protected List<Command<?>> commands;

public JaxbCommandsRequest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import java.io.ByteArrayInputStream;
import java.io.StringWriter;
import java.util.ArrayList;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;

import org.kie.services.client.api.command.AcceptedCommands;
import org.kie.services.client.serialization.jaxb.impl.JaxbHistoryLogList;
import org.kie.services.client.serialization.jaxb.impl.JaxbOtherResponse;
import org.kie.services.client.serialization.jaxb.impl.JaxbProcessInstanceListResponse;
import org.kie.services.client.serialization.jaxb.impl.JaxbProcessInstanceResponse;
Expand All @@ -19,7 +22,7 @@
// TODO: Add object version checking
public class JaxbSerializationProvider {

private static Class<?> [] jaxbClasses = {
static Class<?> [] jaxbClasses = {
JaxbCommandsRequest.class,
JaxbCommandsResponse.class,
JaxbVariablesResponse.class,
Expand All @@ -28,10 +31,12 @@ public class JaxbSerializationProvider {
JaxbProcessInstanceWithVariablesResponse.class,
JaxbProcessInstanceListResponse.class,
JaxbWorkItem.class,
JaxbOtherResponse.class
JaxbOtherResponse.class,
JaxbHistoryLogList.class
};

public static String convertJaxbObjectToString(Object object) throws JAXBException {

Marshaller marshaller = JAXBContext.newInstance(jaxbClasses).createMarshaller();
StringWriter stringWriter = new StringWriter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public List<AbstractJaxbHistoryObject> getHistoryLogList() {
lazyInitResponseList();
return historyLogList;
}

public void setHistoryLogList(List<AbstractJaxbHistoryObject> list) {
this.historyLogList = list;
}

private void lazyInitResponseList() {
if( this.historyLogList == null ) {
Expand Down
Loading

0 comments on commit d895133

Please sign in to comment.