| | |
| | | import org.forgerock.api.models.Services; |
| | | import org.forgerock.api.models.Update; |
| | | import org.forgerock.http.ApiProducer; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.json.JsonPointer; |
| | | import org.forgerock.json.JsonValue; |
| | |
| | | private volatile Boolean hasSubTypesWithSubResources = null; |
| | | /** The set of actions supported by this resource and its sub-types. */ |
| | | private final Set<Action> supportedActions = new HashSet<>(); |
| | | private LocalizableMessage description; |
| | | |
| | | Resource(final String id) { |
| | | this.id = id; |
| | | } |
| | | |
| | | /** |
| | | * Sets the description of this resource. |
| | | * |
| | | * @param description |
| | | * the description of this resource |
| | | */ |
| | | public void description(LocalizableMessage description) { |
| | | this.description = description; |
| | | } |
| | | |
| | | /** |
| | | * Returns the resource ID of this resource. |
| | | * |
| | | * @return The resource ID of this resource. |
| | |
| | | |
| | | org.forgerock.api.models.Resource.Builder resource = org.forgerock.api.models.Resource. |
| | | resource() |
| | | .title(id) |
| | | .description(toLS(description)) |
| | | .resourceSchema(schemaRef("#/definitions/" + id)) |
| | | .mvccSupported(isMvccSupported()); |
| | | |
| | |
| | | return ApiDescription.apiDescription() |
| | | .id("unused").version("unused") |
| | | .definitions(definitions()) |
| | | .paths(getPaths()) |
| | | .errors(errors()) |
| | | .build(); |
| | | } |
| | |
| | | ApiDescription collectionApi(boolean isReadOnly) { |
| | | org.forgerock.api.models.Resource.Builder resource = org.forgerock.api.models.Resource. |
| | | resource() |
| | | .title(id) |
| | | .description(toLS(description)) |
| | | .resourceSchema(schemaRef("#/definitions/" + id)) |
| | | .mvccSupported(isMvccSupported()); |
| | | |
| | |
| | | return definitions.build(); |
| | | } |
| | | |
| | | private LocalizableString toLS(LocalizableMessage msg) { |
| | | if (msg != null) { |
| | | if (msg.resourceName() != null) { |
| | | return new LocalizableString("i18n:" + msg.resourceName() + "#" /* TODO + msg.getKey() */); |
| | | } |
| | | return new LocalizableString(msg.toString()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Returns the api description that describes a resource with sub resources. |
| | | * |