import org.springframework.beans.factory.annotation.Autowired;
-@Path("cps")
+
+@Path("v1")
public class RestController {
@Autowired
* @return a http response code.
*/
@POST
- @Path("upload-yang-model-file")
+ @Path("/upload-yang-model-file")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public final Response uploadYangModelFile(@FormDataParam("file") File uploadedFile) throws IOException {
final SchemaContext schemaContext = cpService.parseAndValidateModel(fileToParse);
cpService.storeSchemaContext(schemaContext);
return Response.status(Status.OK).entity("Yang File Parsed").build();
- } catch (YangParserException e) {
+ } catch (final YangParserException e) {
return Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build();
- } catch (Exception e) {
+ } catch (final Exception e) {
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
}
* @return a http response code.
*/
@POST
- @Path("upload-yang-json-data-file")
+ @Path("/upload-yang-json-data-file")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public final Response uploadYangJsonDataFile(@FormDataParam("file") String uploadedFile) {
final int persistenceObjectId = cpService.storeJsonStructure(uploadedFile);
return Response.status(Status.OK).entity("Object stored in CPS with identity: " + persistenceObjectId)
.build();
- } catch (JsonSyntaxException e) {
+ } catch (final JsonSyntaxException e) {
return Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build();
- } catch (Exception e) {
+ } catch (final Exception e) {
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
}
* @return a HTTP response.
*/
@GET
- @Path("json-object/{id}")
+ @Path("/json-object/{id}")
public final Response getJsonObjectById(@PathParam("id") int jsonObjectId) {
try {
return Response.status(Status.OK).entity(cpService.getJsonById(jsonObjectId)).build();
- } catch (PersistenceException e) {
+ } catch (final PersistenceException e) {
return Response.status(Status.NOT_FOUND).entity(e.getMessage()).build();
- } catch (Exception e) {
+ } catch (final Exception e) {
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
}
originalFile.renameTo(renamedFile);
return renamedFile;
}
-}
-
-
-
-
+}
\ No newline at end of file