![JAR search and dependency download from the Maven repository](/logo.png)
de.otto.jsonhome.registry.controller.RegistriesController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsonhome-registry Show documentation
Show all versions of jsonhome-registry Show documentation
Library used to write json-home registries for multiple json-home sources.
The newest version!
/* * Copyright 2012 Guido Steinacker * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package de.otto.jsonhome.registry.controller; import de.otto.jsonhome.annotation.Doc; import de.otto.jsonhome.annotation.Docs; import de.otto.jsonhome.annotation.Rel; import de.otto.jsonhome.registry.store.Registry; import de.otto.jsonhome.registry.store.RegistryRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.net.URI; import java.util.Map; import static de.otto.jsonhome.generator.UriBuilder.normalized; import static de.otto.jsonhome.registry.controller.RegistriesConverter.registriesToJson; import static de.otto.jsonhome.registry.controller.RegistryConverter.jsonToRegistry; import static de.otto.jsonhome.registry.controller.RegistryConverter.registryToJson; import static javax.servlet.http.HttpServletResponse.*; import static org.springframework.http.HttpStatus.BAD_REQUEST; /** * Controller responsible for requests to the
" } ), @Doc(rel = "/rel/jsonhome/registry", value = { "A registry of json-home documents:", "/registry
resource. * * @author Guido Steinacker * @since 15.09.12 */ @Controller @Docs({ @Doc(rel = "/rel/jsonhome/registries", value = {"The collection of known registries:", "{\n" + " \"self\" : \"http://example.org/registries\",\n" + " \"registries\" : [\n" + " {\n" + " \"href\" : \"http://example.org/registries/live\"\n" + " \"title\" : \"Home documents of the live environment\",\n" + " },\n" + " {\n" + " \"href\" : \"http://example.org/registries/test\n" + " \"title\" : \"Home documents of the testing environment\",\n" + " }\n" + " ]\n" + "}\n" + "
" }) }) public class RegistriesController { private static final Logger LOG = LoggerFactory.getLogger(RegistriesController.class); private RegistryRepository registryRepository; private URI applicationBaseUri; @Value("${jsonhome.applicationBaseUri}") public void setApplicationBaseUri(final String baseUri) { this.applicationBaseUri = normalized(baseUri).toUri(); LOG.info("ApplicationbaseUri is {}", applicationBaseUri.toString()); } /** * Injects the registry implementation used to store registry entries. * * @param registryRepository the Registry used by the controller. */ @Autowired public void setRegistryRepository(final RegistryRepository registryRepository) { this.registryRepository = registryRepository; } /** * Returns the registries as a list of URLs. * *{\n" + " \"name\" : \"live\",\n" + " \"title\" : \"Home documents of the live environment\",\n" + " \"self\" : \"http://example.org/registries/live\",\n" + " \"container\" : \"http://example.org/registries\",\n" + " \"service\" : [\n" + " {\n" + " \"href\" : \"http://example.org/foo/json-home\"\n" + " \"title\" : \"Home document of application foo\",\n" + " },\n" + " {\n" + " \"href\" : \"http://example.org/bar/json-home\n" + " \"title\" : \"Home document of application bar\",\n" + " }\n" + " ]\n" + "}\n" + "
* {@code * GET /registries * * { * "self" : "http://example.org/registries", * "registries" : [ * { "href" : "http://example.org/registries/live", "title" : "Live environment" }, * { "href" : "http://example.org/registries/test", "title" : "Testing environment" } * ] * } * } ** * HTTP status codes returned by this method: *
-
*
- 200 OK: if the resource was successfully returned. *
* {@code * GET /registries/live * * { * "name" : "live", * "title" : "Live environment", * "self" : "http://example.org/registries/live", * "container" : "http://example.org/registries", * "service" : [ * { * "title" : "Home document of application foo", * "href" : "http://example.org/foo/json-home" * }, * { * "title" : "Home document of application bar", * "href" : "http://example.org/bar/json-home * } * ] * } * } ** * The attributes 'name', 'self' and 'container' are added by the server and will be ignored during PUT operations. * * HTTP status codes returned by this method: *
-
*
- 200 OK: if the resource was found. *
- 404 NOT FOUND: if the document was not found. *
* {@code * PUT /registries/live * * { * "title" : "Live environment", * "service" : [ * { * "title" : "Home document of application foo", * "href" : "http://example.org/foo/json-home" * }, * { * "title" : "Home document of application bar", * "href" : "http://example.org/bar/json-home * } * ] * } * } ** * The server will add the following attributes to the document: 'name', 'self', 'container'. These attributes * are overwritten, if provided by the caller. * * HTTP status codes returned by this method: *
-
*
- 201 CREATED: if the resource was successfully created. *
- 204 NO CONTENT: if the resource was successfully updated. *
- 400 BAD REQUEST: if the document was syntactically incorrect. *
-
*
- 204 NO CONTENT: if the resource was successfully deleted or did not exist. *
© 2015 - 2025 Weber Informatics LLC | Privacy Policy