i5.las2peer.services.two.Two.java Source code

Java tutorial

Introduction

Here is the source code for i5.las2peer.services.two.Two.java

Source

package i5.las2peer.services.two;

import java.net.HttpURLConnection;

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.Consumes;

import com.fasterxml.jackson.core.JsonProcessingException;

import i5.las2peer.api.Service;
import i5.las2peer.restMapper.HttpResponse;
import i5.las2peer.restMapper.MediaType;
import i5.las2peer.restMapper.RESTMapper;
import i5.las2peer.restMapper.annotations.ContentParam;
import i5.las2peer.restMapper.annotations.Version;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Contact;
import io.swagger.annotations.Info;
import io.swagger.annotations.License;
import io.swagger.annotations.SwaggerDefinition;
import io.swagger.jaxrs.Reader;
import io.swagger.models.Swagger;
import io.swagger.util.Json;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;

/**
 * 
 * Zweiter Service
 * 
 * This microservice was generated by the CAE (Community Application Editor). If you edit it, please
 * make sure to keep the general structure of the file and only add the body of the methods provided
 * in this main file. Private methods are also allowed, but any "deeper" functionality should be
 * outsourced to (imported) classes.
 * 
 */
@Path("")
@Version("0.2") // this annotation is used by the XML mapper
@Api
@SwaggerDefinition(info = @Info(title = "Zweiter Service", version = "0.2", description = "A LAS2peer microservice generated by the CAE.", termsOfService = "none", contact = @Contact(name = "test", email = "CAEAddress@gmail.com"), license = @License(name = "BSD", url = "https://github.com/cae-development/microservice-Zweiter-Service/blob/master/LICENSE.txt")))
public class Two extends Service {

    public Two() {
        // read and set properties values
        setFieldValues();

    }

    // //////////////////////////////////////////////////////////////////////////////////////
    // Service methods.
    // //////////////////////////////////////////////////////////////////////////////////////

    /**
     * 
     * test
     * 
     *
     * 
     * @return HttpResponse  
     * 
     */
    @GET
    @Path("/test")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.TEXT_PLAIN)
    @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "testJson") })
    @ApiOperation(value = "test", notes = " ")
    public HttpResponse test() {

        // testJson
        boolean testJson_condition = true;
        if (testJson_condition) {
            JSONObject testResult = new JSONObject();
            HttpResponse testJson = new HttpResponse(testResult.toJSONString(), HttpURLConnection.HTTP_OK);
            return testJson;
        }
        return null;
    }

    // //////////////////////////////////////////////////////////////////////////////////////
    // Methods required by the LAS2peer framework.
    // //////////////////////////////////////////////////////////////////////////////////////

    /**
     * 
     * This method is needed for every RESTful application in LAS2peer. Please don't change.
     * 
     * @return the mapping
     * 
     */
    public String getRESTMapping() {
        String result = "";
        try {
            result = RESTMapper.getMethodsAsXML(this.getClass());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

}