001package gov.nist.secauto.oscal.lib.model; 002 003import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValue; 004import gov.nist.secauto.metaschema.binding.model.annotations.AllowedValues; 005import gov.nist.secauto.metaschema.binding.model.annotations.BoundAssembly; 006import gov.nist.secauto.metaschema.binding.model.annotations.BoundField; 007import gov.nist.secauto.metaschema.binding.model.annotations.BoundFieldValue; 008import gov.nist.secauto.metaschema.binding.model.annotations.BoundFlag; 009import gov.nist.secauto.metaschema.binding.model.annotations.GroupAs; 010import gov.nist.secauto.metaschema.binding.model.annotations.IndexHasKey; 011import gov.nist.secauto.metaschema.binding.model.annotations.KeyField; 012import gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly; 013import gov.nist.secauto.metaschema.binding.model.annotations.ValueConstraints; 014import gov.nist.secauto.metaschema.model.common.JsonGroupAsBehavior; 015import gov.nist.secauto.metaschema.model.common.constraint.IConstraint; 016import gov.nist.secauto.metaschema.model.common.datatype.adapter.DateTimeWithTZAdapter; 017import gov.nist.secauto.metaschema.model.common.datatype.adapter.TokenAdapter; 018import gov.nist.secauto.metaschema.model.common.datatype.adapter.UriAdapter; 019import gov.nist.secauto.metaschema.model.common.datatype.adapter.UuidAdapter; 020import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultiline; 021import gov.nist.secauto.metaschema.model.common.datatype.markup.MarkupMultilineAdapter; 022import gov.nist.secauto.metaschema.model.common.util.ObjectUtils; 023import java.lang.Override; 024import java.lang.String; 025import java.net.URI; 026import java.time.ZonedDateTime; 027import java.util.LinkedList; 028import java.util.List; 029import java.util.UUID; 030import org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle; 031import org.apache.commons.lang3.builder.ReflectionToStringBuilder; 032 033/** 034 * An action applied by a role within a given party to the content. 035 */ 036@MetaschemaAssembly( 037 formalName = "Action", 038 description = "An action applied by a role within a given party to the content.", 039 name = "action", 040 metaschema = OscalMetadataMetaschema.class 041) 042@ValueConstraints( 043 allowedValues = { 044 @AllowedValues(level = IConstraint.Level.ERROR, target = "./system/@value", allowOthers = true, values = @AllowedValue(value = "http://csrc.nist.gov/ns/oscal", description = "This value identifies action types defined in the NIST OSCAL namespace.")), 045 @AllowedValues(level = IConstraint.Level.ERROR, target = "./type[has-oscal-namespace('http://csrc.nist.gov/ns/oscal')]/@value", values = {@AllowedValue(value = "approval", description = "An approval of a document instance's content."), @AllowedValue(value = "request-changes", description = "A request from the responisble party or parties to change the content.")}) 046 }, 047 indexHasKey = { 048 @IndexHasKey(level = IConstraint.Level.ERROR, target = "responsible-party", indexName = "index-metadata-role-id", keyFields = @KeyField(target = "@role-id")), 049 @IndexHasKey(level = IConstraint.Level.ERROR, target = "responsible-party", indexName = "index-metadata-party-uuid", keyFields = @KeyField(target = "party-uuid")) 050 } 051) 052public class Action { 053 @BoundFlag( 054 formalName = "Action Universally Unique Identifier", 055 description = "A unique identifier that can be used to reference this defined action elsewhere in an OSCAL document. A UUID should be consistently used for a given location across revisions of the document.", 056 useName = "uuid", 057 required = true, 058 typeAdapter = UuidAdapter.class 059 ) 060 private UUID _uuid; 061 062 @BoundFlag( 063 formalName = "Action Occurrence Date", 064 description = "The date and time when the action occurred.", 065 useName = "date", 066 typeAdapter = DateTimeWithTZAdapter.class 067 ) 068 private ZonedDateTime _date; 069 070 @BoundFlag( 071 formalName = "Action Type", 072 description = "The type of action documented by the assembly, such as an approval.", 073 useName = "type", 074 required = true, 075 typeAdapter = TokenAdapter.class 076 ) 077 private String _type; 078 079 @BoundFlag( 080 formalName = "Action Type System", 081 description = "Specifies the action type system used.", 082 useName = "system", 083 required = true, 084 typeAdapter = UriAdapter.class, 085 remarks = "Provides a means to segment the value space for the `type`, so that different organizations and individuals can assert control over the allowed `action`'s `type`. This allows the semantics associated with a given `type` to be defined on an organization-by-organization basis.\n" 086 + "\n" 087 + "An organization MUST use a URI that they have control over. e.g., a domain registered to the organization in a URI, a registered uniform resource names (URN) namespace." 088 ) 089 private URI _system; 090 091 @BoundAssembly( 092 formalName = "Property", 093 description = "An attribute, characteristic, or quality of the containing object expressed as a namespace qualified name/value pair.", 094 useName = "prop", 095 maxOccurs = -1 096 ) 097 @GroupAs( 098 name = "props", 099 inJson = JsonGroupAsBehavior.LIST 100 ) 101 private List<Property> _props; 102 103 @BoundAssembly( 104 formalName = "Link", 105 description = "A reference to a local or remote resource, that has a specific relation to the containing object.", 106 useName = "link", 107 maxOccurs = -1 108 ) 109 @GroupAs( 110 name = "links", 111 inJson = JsonGroupAsBehavior.LIST 112 ) 113 private List<Link> _links; 114 115 @BoundAssembly( 116 formalName = "Responsible Party", 117 description = "A reference to a set of persons and/or organizations that have responsibility for performing the referenced role in the context of the containing object.", 118 useName = "responsible-party", 119 maxOccurs = -1 120 ) 121 @GroupAs( 122 name = "responsible-parties", 123 inJson = JsonGroupAsBehavior.LIST 124 ) 125 private List<ResponsibleParty> _responsibleParties; 126 127 @BoundField( 128 formalName = "Remarks", 129 description = "Additional commentary about the containing object.", 130 useName = "remarks" 131 ) 132 @BoundFieldValue( 133 typeAdapter = MarkupMultilineAdapter.class 134 ) 135 private MarkupMultiline _remarks; 136 137 public Action() { 138 } 139 140 public UUID getUuid() { 141 return _uuid; 142 } 143 144 public void setUuid(UUID value) { 145 _uuid = value; 146 } 147 148 public ZonedDateTime getDate() { 149 return _date; 150 } 151 152 public void setDate(ZonedDateTime value) { 153 _date = value; 154 } 155 156 public String getType() { 157 return _type; 158 } 159 160 public void setType(String value) { 161 _type = value; 162 } 163 164 public URI getSystem() { 165 return _system; 166 } 167 168 public void setSystem(URI value) { 169 _system = value; 170 } 171 172 public List<Property> getProps() { 173 return _props; 174 } 175 176 public void setProps(List<Property> value) { 177 _props = value; 178 } 179 180 /** 181 * Add a new {@link Property} item to the underlying collection. 182 * @param item the item to add 183 * @return {@code true} 184 */ 185 public boolean addProp(Property item) { 186 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 187 if (_props == null) { 188 _props = new LinkedList<>(); 189 } 190 return _props.add(value); 191 } 192 193 /** 194 * Remove the first matching {@link Property} item from the underlying collection. 195 * @param item the item to remove 196 * @return {@code true} if the item was removed or {@code false} otherwise 197 */ 198 public boolean removeProp(Property item) { 199 Property value = ObjectUtils.requireNonNull(item,"item cannot be null"); 200 return _props == null ? false : _props.remove(value); 201 } 202 203 public List<Link> getLinks() { 204 return _links; 205 } 206 207 public void setLinks(List<Link> value) { 208 _links = value; 209 } 210 211 /** 212 * Add a new {@link Link} item to the underlying collection. 213 * @param item the item to add 214 * @return {@code true} 215 */ 216 public boolean addLink(Link item) { 217 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 218 if (_links == null) { 219 _links = new LinkedList<>(); 220 } 221 return _links.add(value); 222 } 223 224 /** 225 * Remove the first matching {@link Link} item from the underlying collection. 226 * @param item the item to remove 227 * @return {@code true} if the item was removed or {@code false} otherwise 228 */ 229 public boolean removeLink(Link item) { 230 Link value = ObjectUtils.requireNonNull(item,"item cannot be null"); 231 return _links == null ? false : _links.remove(value); 232 } 233 234 public List<ResponsibleParty> getResponsibleParties() { 235 return _responsibleParties; 236 } 237 238 public void setResponsibleParties(List<ResponsibleParty> value) { 239 _responsibleParties = value; 240 } 241 242 /** 243 * Add a new {@link ResponsibleParty} item to the underlying collection. 244 * @param item the item to add 245 * @return {@code true} 246 */ 247 public boolean addResponsibleParty(ResponsibleParty item) { 248 ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null"); 249 if (_responsibleParties == null) { 250 _responsibleParties = new LinkedList<>(); 251 } 252 return _responsibleParties.add(value); 253 } 254 255 /** 256 * Remove the first matching {@link ResponsibleParty} item from the underlying collection. 257 * @param item the item to remove 258 * @return {@code true} if the item was removed or {@code false} otherwise 259 */ 260 public boolean removeResponsibleParty(ResponsibleParty item) { 261 ResponsibleParty value = ObjectUtils.requireNonNull(item,"item cannot be null"); 262 return _responsibleParties == null ? false : _responsibleParties.remove(value); 263 } 264 265 public MarkupMultiline getRemarks() { 266 return _remarks; 267 } 268 269 public void setRemarks(MarkupMultiline value) { 270 _remarks = value; 271 } 272 273 @Override 274 public String toString() { 275 return new ReflectionToStringBuilder(this, MultilineRecursiveToStringStyle.MULTI_LINE_STYLE).toString(); 276 } 277}