Skip to content

Commit

Permalink
#1 initial swagger artifacts in
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed Jul 17, 2018
1 parent c46aa0d commit 5c2a32b
Show file tree
Hide file tree
Showing 16 changed files with 111 additions and 125 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.irods.jargon.irodsext.mdtemplate.service;
package org.irods.jargon.irodsext.mdtemplate;

import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
import com.fasterxml.jackson.databind.util.ISO8601Utils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.irods.jargon.irodsext.mdtemplate.service;
package org.irods.jargon.irodsext.mdtemplate;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.ExitCodeGenerator;
Expand All @@ -10,7 +10,7 @@

@SpringBootApplication
@EnableSwagger2
@ComponentScan(basePackages = { "org.irods.jargon.irodsext.mdtemplate.service", "org.irods.jargon.irodsext.mdtemplate.service.api" })
@ComponentScan(basePackages = { "org.irods.jargon.irodsext.mdtemplate", "org.irods.jargon.irodsext.mdtemplate.api" })
public class Swagger2SpringBoot implements CommandLineRunner {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.irods.jargon.irodsext.mdtemplate.service.api;
package org.irods.jargon.irodsext.mdtemplate.api;

@javax.annotation.Generated(value = "org.irods.jargon.irodsext.mdtemplate.service.codegen.languages.SpringCodegen", date = "2018-07-16T19:45:57.555Z")
@javax.annotation.Generated(value = "org.irods.jargon.irodsext.mdtemplate.codegen.languages.SpringCodegen", date = "2018-07-16T19:45:57.555Z")

public class ApiException extends Exception{
private int code;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.irods.jargon.irodsext.mdtemplate.service.api;
package org.irods.jargon.irodsext.mdtemplate.api;

import java.io.IOException;

import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;

@javax.annotation.Generated(value = "org.irods.jargon.irodsext.mdtemplate.service.codegen.languages.SpringCodegen", date = "2018-07-16T19:45:57.555Z")
@javax.annotation.Generated(value = "org.irods.jargon.irodsext.mdtemplate.codegen.languages.SpringCodegen", date = "2018-07-16T19:45:57.555Z")

public class ApiOriginFilter implements javax.servlet.Filter {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.irods.jargon.irodsext.mdtemplate.service.api;
package org.irods.jargon.irodsext.mdtemplate.api;

import javax.xml.bind.annotation.XmlTransient;

@javax.annotation.Generated(value = "org.irods.jargon.irodsext.mdtemplate.service.codegen.languages.SpringCodegen", date = "2018-07-16T19:45:57.555Z")
@javax.annotation.Generated(value = "org.irods.jargon.irodsext.mdtemplate.codegen.languages.SpringCodegen", date = "2018-07-16T19:45:57.555Z")

@javax.xml.bind.annotation.XmlRootElement
public class ApiResponseMessage {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.irods.jargon.irodsext.mdtemplate.service.api;
package org.irods.jargon.irodsext.mdtemplate.api;

@javax.annotation.Generated(value = "org.irods.jargon.irodsext.mdtemplate.service.codegen.languages.SpringCodegen", date = "2018-07-16T19:45:57.555Z")
@javax.annotation.Generated(value = "org.irods.jargon.irodsext.mdtemplate.codegen.languages.SpringCodegen", date = "2018-07-16T19:45:57.555Z")

public class NotFoundException extends ApiException {
private int code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
package org.irods.jargon.irodsext.mdtemplate.service.api;
package org.irods.jargon.irodsext.mdtemplate.api;

import io.swagger.annotations.*;

import org.irods.jargon.irodsext.mdtemplate.service.model.Element;
import org.irods.jargon.irodsext.mdtemplate.service.model.Template;
import org.irods.jargon.metadatatemplate.model.MDTemplate;
import org.irods.jargon.metadatatemplate.model.MDTemplateElement;
import org.springframework.http.ResponseEntity;
Expand All @@ -25,7 +23,7 @@
import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;
@javax.annotation.Generated(value = "org.irods.jargon.irodsext.mdtemplate.service.codegen.languages.SpringCodegen", date = "2018-07-16T19:45:57.555Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2018-07-17T12:26:03.800Z")

@Api(value = "template", description = "the template API")
public interface TemplateApi {
Expand All @@ -36,7 +34,7 @@ public interface TemplateApi {
@RequestMapping(value = "/template/{guid}/element",
produces = { "application/xml", "application/json" },
method = RequestMethod.POST)
ResponseEntity<Void> addElement(@ApiParam(value = "unique object task name",required=true) @PathVariable("guid") Integer guid,@ApiParam(value = "Created Element object" ,required=true ) @Valid @RequestBody Element body);
ResponseEntity<Void> addElement(@ApiParam(value = "unique object task name",required=true) @PathVariable("guid") Integer guid,@ApiParam(value = "Created Element object" ,required=true ) @Valid @RequestBody MDTemplateElement body);


@ApiOperation(value = "Add a new Template", nickname = "addTemplate", notes = "Adding a new metadata template", tags={ "Templates", })
Expand All @@ -46,7 +44,7 @@ public interface TemplateApi {
produces = { "application/xml", "application/json" },
consumes = { "application/json", "application/xml" },
method = RequestMethod.POST)
ResponseEntity<Void> addTemplate(@ApiParam(value = "Template object that needs to be added to the system" ,required=true ) @Valid @RequestBody Template templateData);
ResponseEntity<Void> addTemplate(@ApiParam(value = "Template object that needs to be added to the system" ,required=true ) @Valid @RequestBody MDTemplate templateData);


@ApiOperation(value = "Delete Element", nickname = "deleteElement", notes = "", tags={ "Element", })
Expand Down Expand Up @@ -76,12 +74,12 @@ public interface TemplateApi {
@RequestMapping(value = "/template/{guid}",
produces = { "application/json" },
method = RequestMethod.GET)
ResponseEntity<MDTemplate> findTemplateByGuid(@ApiParam(value = "pass an a guid to get template",required=true) @PathVariable("guid") String guid);
ResponseEntity<Void> findTemplateByGuid(@ApiParam(value = "pass an a guid to get template",required=true) @PathVariable("guid") String guid);


@ApiOperation(value = "Get Element by guid", nickname = "getElementByGuid", notes = "", response = Element.class, tags={ "Element", })
@ApiOperation(value = "Get Element by guid", nickname = "getElementByGuid", notes = "", response = MDTemplateElement.class, tags={ "Element", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Element.class),
@ApiResponse(code = 200, message = "successful operation", response = MDTemplateElement.class),
@ApiResponse(code = 400, message = "Invalid guid supplied"),
@ApiResponse(code = 404, message = "Element not found") })
@RequestMapping(value = "/template/{guid}/element/{guid}",
Expand All @@ -97,7 +95,7 @@ public interface TemplateApi {
@RequestMapping(value = "/template/{guid}/element/{guid}",
produces = { "application/xml", "application/json" },
method = RequestMethod.PUT)
ResponseEntity<Void> updateElement(@ApiParam(value = "Element that need to be updated",required=true) @PathVariable("guid") Integer guid,@ApiParam(value = "Updated Element object" ,required=true ) @Valid @RequestBody Element body);
ResponseEntity<Void> updateElement(@ApiParam(value = "Element that need to be updated",required=true) @PathVariable("guid") Integer guid,@ApiParam(value = "Updated Element object" ,required=true ) @Valid @RequestBody MDTemplateElement body);


@ApiOperation(value = "Update an existing Template", nickname = "updateTemplate", notes = "", tags={ "Templates", })
Expand All @@ -109,6 +107,6 @@ public interface TemplateApi {
produces = { "application/xml", "application/json" },
consumes = { "application/json", "application/xml" },
method = RequestMethod.PUT)
ResponseEntity<Void> updateTemplate(@ApiParam(value = "Template object that needs to be added to the system" ,required=true ) @Valid @RequestBody Template templateData);
ResponseEntity<Void> updateTemplate(@ApiParam(value = "Template object that needs to be added to the system" ,required=true ) @Valid @RequestBody MDTemplate templateData);

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package org.irods.jargon.irodsext.mdtemplate.service.api;
package org.irods.jargon.irodsext.mdtemplate.api;


import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.*;

import org.irods.jargon.irodsext.mdtemplate.service.model.Element;
import org.irods.jargon.irodsext.mdtemplate.service.model.Template;
import org.irods.jargon.irodsext.mdtemplate.service.service.IrodsSampleTemplateService;
import org.irods.jargon.metadatatemplate.model.MDTemplate;
import org.irods.jargon.metadatatemplate.model.MDTemplateElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
Expand All @@ -24,8 +23,7 @@
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
@javax.annotation.Generated(value = "org.irods.jargon.irodsext.mdtemplate.service.codegen.languages.SpringCodegen", date = "2018-07-16T19:45:57.555Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2018-07-17T12:26:03.800Z")

@Controller
public class TemplateApiController implements TemplateApi {
Expand All @@ -35,80 +33,71 @@ public class TemplateApiController implements TemplateApi {
private final ObjectMapper objectMapper;

private final HttpServletRequest request;

@Autowired
public IrodsSampleTemplateService irodsSampleTemplateService;

@org.springframework.beans.factory.annotation.Autowired
public TemplateApiController(ObjectMapper objectMapper, HttpServletRequest request) {
this.objectMapper = objectMapper;
this.request = request;
}

public ResponseEntity<Void> addElement(@ApiParam(value = "unique object task name",required=true) @PathVariable("guid") Integer guid,@ApiParam(value = "Created Element object" ,required=true ) @Valid @RequestBody Element body) {
public ResponseEntity<Void> addElement(@ApiParam(value = "unique object task name",required=true) @PathVariable("guid") Integer guid,@ApiParam(value = "Created Element object" ,required=true ) @Valid @RequestBody MDTemplateElement body) {
String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
}

public ResponseEntity<Void> addTemplate(@ApiParam(value = "Template object that needs to be added to the system" ,required=true ) @Valid @RequestBody Template templateData) {
public ResponseEntity<Void> addTemplate(@ApiParam(value = "Template object that needs to be added to the system" ,required=true ) @Valid @RequestBody MDTemplate templateData) {
String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
}

public ResponseEntity<Void> deleteElement(@ApiParam(value = "The Element that needs to be deleted",required=true) @PathVariable("guid") Integer guid) {
@Override
public ResponseEntity<Void> deleteElement(@ApiParam(value = "The Element that needs to be deleted",required=true) @PathVariable("guid") Integer guid) {
String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
}

public ResponseEntity<Void> deleteTemplate(@ApiParam(value = "template guid to delete",required=true) @PathVariable("guid") Long guid) {
@Override
public ResponseEntity<Void> deleteTemplate(@ApiParam(value = "template guid to delete",required=true) @PathVariable("guid") Long guid) {
String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
}

public ResponseEntity<Template> findTemplateByGuid(@ApiParam(value = "pass an a guid to get template",required=true) @PathVariable("guid") String guid) {
String accept = request.getHeader("Accept");
Template template = new Template();

// MdTemplate mdTemplate = adstractMetadataService.findTemplateByUUID(UUID.fromString(guid));
//guid = "9f089439-9665-4464-929b-2704d765b588";
template = irodsSampleTemplateService.findTemplateByUUID (UUID.fromString(guid));

System.out.println("Template Searched is :: " + template.getTemplateName());
if(template != null)
return ResponseEntity.accepted().body(template);
else
return new ResponseEntity<Template>(HttpStatus.NOT_IMPLEMENTED);
@Override
public ResponseEntity<Void> findTemplateByGuid(@ApiParam(value = "pass an a guid to get template",required=true) @PathVariable("guid") String guid) {
String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
}

public ResponseEntity<Element> getElementByGuid(@ApiParam(value = "The Element that needs to be fetched. ",required=true) @PathVariable("guid") Integer guid) {
@Override
public ResponseEntity<MDTemplateElement> getElementByGuid(@ApiParam(value = "The Element that needs to be fetched. ",required=true) @PathVariable("guid") Integer guid) {
String accept = request.getHeader("Accept");
if (accept != null && accept.contains("application/xml")) {
try {
return new ResponseEntity<Element>(objectMapper.readValue("<Element> <id>123456789</id> <attribute>aeiou</attribute> <defaultValue>aeiou</defaultValue> <attributeUnit>aeiou</attributeUnit> <type>aeiou</type> <required>true</required> <options>aeiou</options> <access_type>aeiou</access_type> <validationExp>aeiou</validationExp> <guid>aeiou</guid></Element>", Element.class), HttpStatus.NOT_IMPLEMENTED);
return new ResponseEntity<MDTemplateElement>(objectMapper.readValue("<MDTemplateElement> <guid>aeiou</guid> <name>aeiou</name> <defaultValue>aeiou</defaultValue> <type>aeiou</type> <required>true</required> <options>aeiou</options> <access_type>aeiou</access_type> <validationExp>aeiou</validationExp> <cardinalityMin>123</cardinalityMin> <cardinalityMax>123</cardinalityMax></MDTemplateElement>", MDTemplateElement.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) {
log.error("Couldn't serialize response for content type application/xml", e);
return new ResponseEntity<Element>(HttpStatus.INTERNAL_SERVER_ERROR);
return new ResponseEntity<MDTemplateElement>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}

if (accept != null && accept.contains("application/json")) {
try {
return new ResponseEntity<Element>(objectMapper.readValue("{ \"attributeUnit\" : \"attributeUnit\", \"access_type\" : \"access_type\", \"defaultValue\" : \"defaultValue\", \"elements\" : [ null, null ], \"options\" : \"options\", \"guid\" : \"guid\", \"id\" : 1, \"attribute\" : \"attribute\", \"type\" : \"type\", \"required\" : true, \"validationExp\" : \"validationExp\"}", Element.class), HttpStatus.NOT_IMPLEMENTED);
return new ResponseEntity<MDTemplateElement>(objectMapper.readValue("{ \"access_type\" : \"access_type\", \"defaultValue\" : \"defaultValue\", \"elements\" : [ null, null ], \"name\" : \"name\", \"options\" : \"options\", \"guid\" : \"guid\", \"cardinalityMin\" : 1, \"cardinalityMax\" : 5, \"type\" : \"type\", \"required\" : true, \"validationExp\" : \"validationExp\"}", MDTemplateElement.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) {
log.error("Couldn't serialize response for content type application/json", e);
return new ResponseEntity<Element>(HttpStatus.INTERNAL_SERVER_ERROR);
return new ResponseEntity<MDTemplateElement>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}

return new ResponseEntity<Element>(HttpStatus.NOT_IMPLEMENTED);
return new ResponseEntity<MDTemplateElement>(HttpStatus.NOT_IMPLEMENTED);
}

public ResponseEntity<Void> updateElement(@ApiParam(value = "Element that need to be updated",required=true) @PathVariable("guid") Integer guid,@ApiParam(value = "Updated Element object" ,required=true ) @Valid @RequestBody Element body) {
public ResponseEntity<Void> updateElement(@ApiParam(value = "Element that need to be updated",required=true) @PathVariable("guid") Integer guid,@ApiParam(value = "Updated Element object" ,required=true ) @Valid @RequestBody MDTemplateElement body) {
String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
}

public ResponseEntity<Void> updateTemplate(@ApiParam(value = "Template object that needs to be added to the system" ,required=true ) @Valid @RequestBody Template templateData) {
public ResponseEntity<Void> updateTemplate(@ApiParam(value = "Template object that needs to be added to the system" ,required=true ) @Valid @RequestBody MDTemplate templateData) {
String accept = request.getHeader("Accept");
return new ResponseEntity<Void>(HttpStatus.NOT_IMPLEMENTED);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.irods.jargon.irodsext.mdtemplate.service.configuration;
package org.irods.jargon.irodsext.mdtemplate.configuration;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonTokenId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.irods.jargon.irodsext.mdtemplate.service.configuration;
package org.irods.jargon.irodsext.mdtemplate.configuration;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.irods.jargon.irodsext.mdtemplate.service.configuration;
package org.irods.jargon.irodsext.mdtemplate.configuration;

import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand Down
Loading

0 comments on commit 5c2a32b

Please sign in to comment.