Class Command

java.lang.Object
net.pincette.jes.Command

public class Command extends Object
Some command utilities.
Since:
3.0
Author:
Werner Donné
  • Method Details

    • createCommand

      public static JsonObject createCommand(String type, String id, String name)
      Creates a command without data.
      Parameters:
      type - the aggregate type.
      id - the ID of the aggregate instance.
      name - the name of the command.
      Returns:
      The JSON representation of the command.
      Since:
      1.0
    • createCommandBuilder

      public static JsonObjectBuilder createCommandBuilder(String type, String id, String name)
      Creates a command builder without data. You can then add more fields to it.
      Parameters:
      type - the aggregate type.
      id - the ID of the aggregate instance.
      name - the name of the command.
      Returns:
      The JSON builder.
      Since:
      1.0
    • createCommandFor

      public static JsonObject createCommandFor(JsonObject json, String name)
      Creates a command which takes over the fields _type, _id and _jwt from json.
      Parameters:
      json - the aggregate or event.
      name - the name of the command.
      Returns:
      The new command.
      Since:
      1.0
    • createCommandBuilderFor

      public static JsonObjectBuilder createCommandBuilderFor(JsonObject json, String name)
      Creates a command builder which takes over the fields _type, _id and _jwt from json.
      Parameters:
      json - the aggregate or event.
      name - the name of the command.
      Returns:
      The new command.
      Since:
      1.0
    • hasError

      public static boolean hasError(JsonObject json)
      Checks if json is marked with an error, which means the field _error is set to true.
      Parameters:
      json - the given object, usually a command.
      Returns:
      The check report.
      Since:
      1.0
      See Also:
    • isAllowed

      public static boolean isAllowed(JsonObject currentState, JsonObject command, boolean breakingTheGlass)
      Checks whether or not the given command is allowed for the given aggregate, based on the _acl field in the aggregate.
      Parameters:
      currentState - the given aggregate.
      command - the given command.
      breakingTheGlass - when set this overrules the _acl field. This should only be used with auditing turned on.
      Returns:
      Whether the command can go through or not.
      Since:
      1.0.1
    • isCommand

      public static boolean isCommand(JsonObject json)
      Checks if json is a command. This means it has the fields _id, _type and _command.
      Parameters:
      json - the given object.
      Returns:
      The check report.
      Since:
      1.0
      See Also:
    • isCommand

      public static boolean isCommand(JsonObject command, String name)
      Checks if the command has the name.
      Parameters:
      command - the given command.
      name - the name to be checked.
      Returns:
      The check report.
      Since:
      1.0