Example usage for com.google.gson GsonBuilder excludeFieldsWithoutExposeAnnotation

List of usage examples for com.google.gson GsonBuilder excludeFieldsWithoutExposeAnnotation

Introduction

In this page you can find the example usage for com.google.gson GsonBuilder excludeFieldsWithoutExposeAnnotation.

Prototype

public GsonBuilder excludeFieldsWithoutExposeAnnotation() 

Source Link

Document

Configures Gson to exclude all fields from consideration for serialization or deserialization that do not have the com.google.gson.annotations.Expose annotation.

Usage

From source file:com.paysafe.websample.DirectDebitSamplePaymentToken.java

License:Open Source License

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

    // Initiate a new instance of the DirectDebit Purchase Service
    //Initialize the PaysafeApiClient 

    PrintWriter out = response.getWriter();
    boolean wasSuccessfull = false;
    Purchases purchasesResponse = null;/*from www  .j  a  v a2s . com*/
    String radio = request.getParameter("account");
    if (radio.equals("ach")) {
        PaysafeApiClient apiClient = new PaysafeApiClient(this.apiKey, this.apiPassword, Environment.TEST,
                this.accountNumber);
        try {
            Purchases purchases = Purchases.builder().merchantRefNum(request.getParameter("merchantRefNum"))
                    .amount(Integer.parseInt(request.getParameter("amount"))).ach()
                    .paymentToken(request.getParameter("paymentToken")).payMethod(PayMethod.WEB).done().build();

            purchasesResponse = apiClient.directDebitService().submitPurchase(purchases);
            final GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.excludeFieldsWithoutExposeAnnotation();
            final Gson gson = gsonBuilder.create();

            out.println("response" + gson.toJson(purchasesResponse));

            wasSuccessfull = true;

        } catch (PaysafeException e) {
            // TODO Auto-generated catch block
            request.setAttribute("error", e.getMessage());
            out.println(e.getMessage());
        }

        request.setAttribute("purchases", purchasesResponse);

        // Create a new customerVault  request
        request.setAttribute("isPost", "true");
        request.setAttribute("currency", this.currencyCode);

        if (wasSuccessfull) {
            RequestDispatcher view = request.getRequestDispatcher("status.jsp");
            view.forward(request, response);
        } else {
            RequestDispatcher view = request.getRequestDispatcher("directDebitACHPurchase.jsp");
            view.forward(request, response);
        }

    }

    if (radio.equals("eft")) {
        PaysafeApiClient apiClient = new PaysafeApiClient(this.apiKey, this.apiPassword, Environment.TEST,
                "1001057670");
        try {
            Purchases purchases = Purchases.builder().merchantRefNum(request.getParameter("merchantRefNum"))
                    .amount(Integer.parseInt(request.getParameter("amount"))).eft()
                    .paymentToken(request.getParameter("paymentToken"))

                    .done().build();

            purchasesResponse = apiClient.directDebitService().submitPurchase(purchases);
            final GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.excludeFieldsWithoutExposeAnnotation();
            final Gson gson = gsonBuilder.create();

            out.println("response" + gson.toJson(purchasesResponse));
            wasSuccessfull = true;

        } catch (PaysafeException e) {
            // TODO Auto-generated catch block
            request.setAttribute("error", e.getMessage());
            out.println(e.getMessage());
        }

        request.setAttribute("purchases", purchasesResponse);

        // Create a new customerVault  request
        request.setAttribute("isPost", "true");
        request.setAttribute("currency", this.currencyCode);

        if (wasSuccessfull) {
            RequestDispatcher view = request.getRequestDispatcher("status.jsp");
            view.forward(request, response);
        } else {
            RequestDispatcher view = request.getRequestDispatcher("directDebitEFTPurchase.jsp");
            view.forward(request, response);
        }

    }
    if (radio.equals("sepa")) {
        PaysafeApiClient apiClient = new PaysafeApiClient(this.apiKey, this.apiPassword, Environment.TEST,
                "1001057620");
        try {
            Purchases purchases = Purchases.builder().merchantRefNum(request.getParameter("merchantRefNum"))
                    .amount(Integer.parseInt(request.getParameter("amount"))).sepa()
                    .paymentToken(request.getParameter("paymentToken"))

                    .done().build();

            purchasesResponse = apiClient.directDebitService().submitPurchase(purchases);
            final GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.excludeFieldsWithoutExposeAnnotation();
            final Gson gson = gsonBuilder.create();

            out.println("response" + gson.toJson(purchasesResponse));
            wasSuccessfull = true;

        } catch (PaysafeException e) {
            // TODO Auto-generated catch block
            request.setAttribute("error", e.getMessage());
            out.println(e.getMessage());
        }

        request.setAttribute("purchases", purchasesResponse);

        // Create a new customerVault  request
        request.setAttribute("isPost", "true");
        request.setAttribute("currency", this.currencyCode);

        if (wasSuccessfull) {
            RequestDispatcher view = request.getRequestDispatcher("status.jsp");
            view.forward(request, response);
        } else {
            RequestDispatcher view = request.getRequestDispatcher("directDebitSEPAPurchase.jsp");
            view.forward(request, response);
        }

    }
    if (radio.equals("bacs")) {
        PaysafeApiClient apiClient = new PaysafeApiClient(this.apiKey, this.apiPassword, Environment.TEST,
                "1001057660");
        try {
            Purchases purchases = Purchases.builder().merchantRefNum(request.getParameter("merchantRefNum"))
                    .amount(Integer.parseInt(request.getParameter("amount"))).bacs()
                    .paymentToken(request.getParameter("paymentToken"))

                    .done().build();

            purchasesResponse = apiClient.directDebitService().submitPurchase(purchases);
            final GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.excludeFieldsWithoutExposeAnnotation();
            final Gson gson = gsonBuilder.create();

            out.println("response" + gson.toJson(purchasesResponse));
            wasSuccessfull = true;

        } catch (PaysafeException e) {
            // TODO Auto-generated catch block
            request.setAttribute("error", e.getMessage());
            out.println(e.getMessage());
        }

        request.setAttribute("purchases", purchasesResponse);

        // Create a new customerVault  request
        request.setAttribute("isPost", "true");
        request.setAttribute("currency", this.currencyCode);

        if (wasSuccessfull) {
            RequestDispatcher view = request.getRequestDispatcher("status.jsp");
            view.forward(request, response);
        } else {
            RequestDispatcher view = request.getRequestDispatcher("directDebitBACSPurchase.jsp");
            view.forward(request, response);
        }

    }

}

From source file:com.paysafe.websample.DirectDebitStandaloneSamplePaymentToken.java

License:Open Source License

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

    // Initiate a new instance of the DirectDebit StandaloneCredit Service
    //Initialize the PaysafeApiClient
    PrintWriter out = response.getWriter();
    boolean wasSuccessfull = false;
    StandaloneCredits standaloneCreditsResponse = null;
    String radio = request.getParameter("account");
    if (radio.equals("ach")) {
        PaysafeApiClient apiClient = new PaysafeApiClient(this.apiKey, this.apiPassword, Environment.TEST,
                this.accountNumber);
        try {//from   w  w  w . j a v a 2  s.c  om
            StandaloneCredits standaloneCredits = StandaloneCredits.builder()
                    .merchantRefNum(request.getParameter("merchantRefNum"))
                    .amount(Integer.parseInt(request.getParameter("amount"))).ach()
                    .paymentToken(request.getParameter("paymentToken")).payMethod(PayMethod.WEB).done().build();

            standaloneCreditsResponse = apiClient.directDebitService()
                    .submitStandaloneCredit(standaloneCredits);
            final GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.excludeFieldsWithoutExposeAnnotation();
            final Gson gson = gsonBuilder.create();

            out.println("response" + gson.toJson(standaloneCreditsResponse));

            wasSuccessfull = true;

        } catch (PaysafeException e) {
            // TODO Auto-generated catch block
            request.setAttribute("error", e.getMessage());
        }

        request.setAttribute("standaloneCredits", standaloneCreditsResponse);

        // Create a new directdebit request
        request.setAttribute("isPost", "true");
        request.setAttribute("currency", this.currencyCode);

        if (wasSuccessfull) {
            RequestDispatcher view = request.getRequestDispatcher("status.jsp");
            view.forward(request, response);
        } else {
            RequestDispatcher view = request.getRequestDispatcher("directDebitACHStandaloneCredit.jsp");
            view.forward(request, response);
        }

    }

    if (radio.equals("eft")) {
        PaysafeApiClient apiClient = new PaysafeApiClient(this.apiKey, this.apiPassword, Environment.TEST,
                "1001057670");
        try {
            StandaloneCredits standaloneCredits = StandaloneCredits.builder()
                    .merchantRefNum(request.getParameter("merchantRefNum"))
                    .amount(Integer.parseInt(request.getParameter("amount"))).eft()
                    .paymentToken(request.getParameter("paymentToken"))

                    .done().build();

            standaloneCreditsResponse = apiClient.directDebitService()
                    .submitStandaloneCredit(standaloneCredits);
            final GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.excludeFieldsWithoutExposeAnnotation();
            final Gson gson = gsonBuilder.create();

            out.println("response" + gson.toJson(standaloneCreditsResponse));
            wasSuccessfull = true;

        } catch (PaysafeException e) {
            // TODO Auto-generated catch block
            request.setAttribute("error", e.getMessage());
        }

        request.setAttribute("standaloneCredits", standaloneCreditsResponse);

        // Create a new directdebit request
        request.setAttribute("isPost", "true");
        request.setAttribute("currency", this.currencyCode);

    }
    if (radio.equals("bacs")) {
        PaysafeApiClient apiClient = new PaysafeApiClient(this.apiKey, this.apiPassword, Environment.TEST,
                "1001057660");
        try {
            StandaloneCredits standaloneCredits = StandaloneCredits.builder()
                    .merchantRefNum(request.getParameter("merchantRefNum"))
                    .amount(Integer.parseInt(request.getParameter("amount"))).bacs()
                    .paymentToken(request.getParameter("paymentToken"))

                    .done().build();

            standaloneCreditsResponse = apiClient.directDebitService()
                    .submitStandaloneCredit(standaloneCredits);
            final GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.excludeFieldsWithoutExposeAnnotation();
            final Gson gson = gsonBuilder.create();

            out.println("response" + gson.toJson(standaloneCreditsResponse));
            wasSuccessfull = true;

        } catch (PaysafeException e) {
            // TODO Auto-generated catch block
            request.setAttribute("error", e.getMessage());
        }

        request.setAttribute("standaloneCredits", standaloneCreditsResponse);

        // Create a new directdebit request
        request.setAttribute("isPost", "true");
        request.setAttribute("currency", this.currencyCode);

    }

}

From source file:com.paysafe.websample.ThreeDSecureSimpleServlet.java

License:Open Source License

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

    PaysafeApiClient apiClient = new PaysafeApiClient(this.apiKey, this.apiPassword, Environment.TEST,
            this.accountNumber);

    PrintWriter out = response.getWriter();

    String threedsecure = request.getParameter("threed_secure");

    if (threedsecure.equals("submit_enroll")) {

        try {/*from  ww w. j  a  va 2  s.  c  o m*/

            EnrollmentChecks responses = EnrollmentChecks.builder()
                    .merchantRefNum(request.getParameter("merchant_Ref_Number")).amount(99999999)
                    .currency(request.getParameter("currency")).customerIp("204.91.0.12")
                    .userAgent(
                            "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36")
                    .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*;q=0.8")
                    .merchantUrl("https://www.merchant.com").card().cardNum("4107857757053670").cardExpiry()
                    .month(10).year(2018).done().done().build();

            EnrollmentChecks enroll_responses;

            enroll_responses = apiClient.threeDSecureService().submit(responses);
            out.println("-------" + enroll_responses.getId());
            final GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.excludeFieldsWithoutExposeAnnotation();
            final Gson gson = gsonBuilder.create();

            out.println("response" + gson.toJson(enroll_responses));
        } catch (PaysafeException e) {
            e.printStackTrace();
            out.println(e.getMessage());
        }

    }

    if (threedsecure.equals("authentication_request")) {
        try {
            EnrollmentChecks enroll_response = EnrollmentChecks.builder()
                    .merchantRefNum(request.getParameter("merchantRefNum")).amount(99999999)
                    .currency(request.getParameter("USD")).customerIp("204.91.0.12")
                    .userAgent(
                            "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36")
                    .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
                    .merchantUrl(request.getParameter("https://www.merchant.com")).card()
                    .cardNum("4107857757053670").cardExpiry().month(10).year(2018).done().done().build();
            enroll_response.setId(Id.create("390d8d32-cff5-4887-a96f-554fed7e1722", EnrollmentChecks.class));

            Authentications auth_response = (Authentications.builder()
                    .merchantRefNum(java.util.UUID.randomUUID().toString())
                    .paRes("eJzNWEeT20qS/isKzZEhwRCOL6iegAdIGAKEv7yAI7whDGF+/YDdUqtXodiYXc1heGFVVmZWmsqvKnH851yVnx5x12dN/e0z9BX8/CmuwybK6uTbZ9PgvhCf//lyNNIujplrHI5d/HKU4773k/hTFn373BUL+BX8Cv0dBkn/6KoBhP6GEAw+oHsIQ//GDgcEh/5Goc8vxwupx/2r0D9eh9/Z9gj0BcMIbOP4bsfLZsZX+Aj8mG4bdmHq18PL0Q/vlKi8IAf4AIJH4Pv0WMWdyLxgBEQckE3wbXoEfspdxueo34yfs+jFhU91uPeWwNEm+Uoma6wt1j73aY38dgSeHMfIH+IXGIQwEIWgTyD+Fwr/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49Jhd0HleZa4tx4wvp2brlhdcnZPx3Lphk0oL3rssrAYaVZ/iHEech0KX98gYVrvNSF6P8mhv6VbmOFiL7RPGnnbJTo1aUvQRgrmFBQBHqpghTiGYJDCOW0zmmIn2rXR2jP3i5uuG08l2WZHbmzPachGZk/C82nRQpSiX5Xh15bXGDXa7fT3wakaNjB8PHhRpnCzy5TOfwlVmEw+cEu9O/m/8jRMXkfFf3K2Iv+LB9OSJ2GnzldwsuhG/dgHc9y5gw33O5uv6sktm8DTCmu2PW8Ig8z7yS3rW8HUPCF0aPWgAxUTDJ5cY7HcH74QIMnCyCJ+HE8FKLgdHpM3UdwkxIQACpVoXVGRzYR8TlkW9bMI1d7CHPFU532/pTFKYWzN2vpQBrOhJKm/anEOtjdc5Ci7bod/6UgRo9VaxMXYQZ0LcYS5yr1ddCCkwWM9glmt19HDwM+Kn4OCYnUDOzc4uuscaCx5YOAlx3rpwnlOm7UYpRgAis2RwEBy8JfzVkkeFrA9nREJbD23ciOTXAAOuDzECgcVVg2SXnqA4OWQwVo0Lt5QwgU1NJA7AzIVjWhN4HSAjr1YgjVzylIJuwZA1A+W3wzmCd9rvXqDAz74ZeO+lf3bZr58KX79pPj9vffzW+S94Sffj")
                    .enrollmentId(enroll_response.getId()).build());

            auth_response = apiClient.threeDSecureService().submit(auth_response);
            out.println("-------" + auth_response.getId());
            final GsonBuilder gsonBuilder1 = new GsonBuilder();
            gsonBuilder1.excludeFieldsWithoutExposeAnnotation();
            final Gson gson1 = gsonBuilder1.create();
            out.println("response" + gson1.toJson(auth_response));

        } catch (PaysafeException e) {

            e.printStackTrace();
            out.println(e.getMessage());
        }
    }

}

From source file:com.pte.liquid.relay.marshaller.json.JsonMarshaller.java

License:Apache License

public JsonMarshaller() {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.excludeFieldsWithoutExposeAnnotation();
    gsonBuilder.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    gson = gsonBuilder.create();//www  .  j  av a2  s  . co  m

}

From source file:com.remediatetheflag.global.messages.MessageGenerator.java

License:Apache License

public static void sendExerciseInfoMessageWithHints(AvailableExercise exercise, HttpServletResponse response) {
    GsonBuilder builder = new GsonBuilder();
    Gson gson = builder.excludeFieldsWithoutExposeAnnotation().create();
    String json = gson.toJson(exercise);
    send(json, response);//from   ww w  .ja  va2s  .  c  om
}

From source file:com.ropr.model.Contact.java

public String toJSON() {
    final GsonBuilder builder = new GsonBuilder();
    builder.excludeFieldsWithoutExposeAnnotation();
    final Gson gson = builder.create();
    String json = gson.toJson(this);
    return json;/* w w w.  j  av a2s.co  m*/
}

From source file:com.ropr.model.Contact.java

public static Contact fromJSON(String json) {
    final GsonBuilder builder = new GsonBuilder();
    builder.excludeFieldsWithoutExposeAnnotation();
    final Gson gson = builder.create();
    Contact u = gson.fromJson(json, Contact.class);
    return u;// www  . j a v  a2s .  c  o  m
}

From source file:com.ropr.model.Device.java

public static Device fromJSON(String json) {
    final GsonBuilder builder = new GsonBuilder();
    builder.excludeFieldsWithoutExposeAnnotation();
    final Gson gson = builder.create();
    Device u = gson.fromJson(json, Device.class);
    return u;//from   ww  w.j  a v  a  2  s . c o  m
}

From source file:com.ropr.model.Message.java

public static Message fromJSON(String json) {
    final GsonBuilder builder = new GsonBuilder();
    builder.excludeFieldsWithoutExposeAnnotation();
    final Gson gson = builder.create();
    Message u = gson.fromJson(json, Message.class);
    return u;/*w w  w.jav  a  2  s  .  co  m*/
}

From source file:com.ropr.model.User.java

public static User fromJSON(String json) {
    final GsonBuilder builder = new GsonBuilder();
    builder.excludeFieldsWithoutExposeAnnotation();
    final Gson gson = builder.create();
    User u = gson.fromJson(json, User.class);
    return u;/*from ww  w .j  ava  2 s .c  om*/
}