java.lang.Object
net.pincette.jes.Command
Some command utilities.
- Since:
- 3.0
- Author:
- Werner Donné
-
Method Summary
Modifier and TypeMethodDescriptionstatic JsonObjectcreateCommand(String type, String id, String name) Creates a command without data.static JsonObjectBuildercreateCommandBuilder(String type, String id, String name) Creates a command builder without data.static JsonObjectBuildercreateCommandBuilderFor(JsonObject json, String name) Creates a command builder which takes over the fields_type,_idand_jwtfromjson.static JsonObjectcreateCommandFor(JsonObject json, String name) Creates a command which takes over the fields_type,_idand_jwtfromjson.static booleanhasError(JsonObject json) Checks ifjsonis marked with an error, which means the field_erroris set totrue.static booleanisAllowed(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.static booleanisCommand(JsonObject json) Checks ifjsonis a command.static booleanisCommand(JsonObject command, String name) Checks if thecommandhas thename.
-
Method Details
-
createCommand
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
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
Creates a command which takes over the fields_type,_idand_jwtfromjson.- Parameters:
json- the aggregate or event.name- the name of the command.- Returns:
- The new command.
- Since:
- 1.0
-
createCommandBuilderFor
Creates a command builder which takes over the fields_type,_idand_jwtfromjson.- Parameters:
json- the aggregate or event.name- the name of the command.- Returns:
- The new command.
- Since:
- 1.0
-
hasError
Checks ifjsonis marked with an error, which means the field_erroris set totrue.- 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
Checks ifjsonis a command. This means it has the fields_id,_typeand_command.- Parameters:
json- the given object.- Returns:
- The check report.
- Since:
- 1.0
- See Also:
-
isCommand
Checks if thecommandhas thename.- Parameters:
command- the given command.name- the name to be checked.- Returns:
- The check report.
- Since:
- 1.0
-