Add instructions to invoke the linter and code formatter plugins to the README and...
[aai/schema-service.git] / aai-schema-service / src / main / java / org / onap / aai / schemaservice / nodeschema / NodeSchemaResource.java
index 4eccd71..9c1f894 100644 (file)
@@ -8,7 +8,7 @@
  * 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
+ * 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,
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
+
 package org.onap.aai.schemaservice.nodeschema;
 
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.restcore.HttpMethod;
-import org.onap.aai.restcore.RESTAPI;
-import org.onap.aai.schemaservice.nodeschema.validation.AAISchemaValidationException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.StringUtils;
+import java.util.Optional;
 
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
@@ -34,7 +30,13 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
-import java.util.Optional;
+
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.restcore.HttpMethod;
+import org.onap.aai.restcore.RESTAPI;
+import org.onap.aai.schemaservice.nodeschema.validation.AAISchemaValidationException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
 
 @Path("/v1")
 public class NodeSchemaResource extends RESTAPI {
@@ -46,27 +48,25 @@ public class NodeSchemaResource extends RESTAPI {
     @Autowired
     public NodeSchemaResource(NodeSchemaService nodeSchemaService, SchemaVersions schemaVersions) {
         this.nodeSchemaService = nodeSchemaService;
-        this.schemaVersions    = schemaVersions;
+        this.schemaVersions = schemaVersions;
     }
 
     @GET
     @Path("/nodes")
-    @Produces({ "application/xml"})
+    @Produces({"application/xml"})
     public Response retrieveSchema(@QueryParam("version") String version,
-                                   @Context HttpHeaders headers,
-                                   @Context UriInfo info)
-    {
+        @Context HttpHeaders headers, @Context UriInfo info) {
         Response response;
         Optional<String> optionalSchema = nodeSchemaService.fetch(version);
         try {
 
-            if(StringUtils.isEmpty(version)){
+            if (StringUtils.isEmpty(version)) {
                 throw new AAIException("AAI_3050");
             }
 
             SchemaVersion schemaVersion = new SchemaVersion(version);
 
-            if(!schemaVersions.getVersions().contains(schemaVersion)){
+            if (!schemaVersions.getVersions().contains(schemaVersion)) {
                 throw new AAIException("AAI_3018", version);
             }
 
@@ -76,12 +76,14 @@ public class NodeSchemaResource extends RESTAPI {
 
             response = Response.ok(optionalSchema.get()).build();
 
-        } catch(AAIException ex){
+        } catch (AAIException ex) {
             response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, ex);
-        } catch(AAISchemaValidationException ex){
-            response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, new AAIException("AAI_3051", version));
-        } catch(Exception ex){
-            response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, new AAIException("AAI_4000"));
+        } catch (AAISchemaValidationException ex) {
+            response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET,
+                new AAIException("AAI_3051", version));
+        } catch (Exception ex) {
+            response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET,
+                new AAIException("AAI_4000"));
         }
 
         return response;