Giter Club home page Giter Club logo

introsde2017-assignment-2-client's Introduction

Giulio Dallatorre [email protected] Worked alone My server is at https://introsde-assignment-2-dallator.herokuapp.com

My project tries to follow the principles of eXtreme Programming, thus I did refactored whenever possible and extracted methods to avoid duplicated code. The client works on jersey 2 which also gives an automatic marshalling and unmarshalling from/to classes provided there are libraries recognized as valid parsers for that kind of stream. The client object is generared fresh at every request, the response is always buffered in memory and uses the same entities from the server, except the persistence methods have been removed. Printing is done tru the superclass ClientEvaluation and I did my best to extract all the useful informations from the webtarget and the repsonse. The result is printed on a Writer (file) while the result header is also printed on console. Based on the response payload mediaType I did used 2 methods to pretty print XML and JSON, ORG.json is used as json formatter, apache xerces as XML formatter. The server is pretty much standard except the merging of persons in the persistence unit, there I do check if I'm creating a person which is essentially a copy of another existing one, it will update the existing one. Person.java line 110.

The client essentially does a sequential number of calls twice, differentiating them via a global valiable that defines the MediaType to marshal and the accepted one, from XML to JSON... and the Writer is also refreshed to write the log on a new file. The server divides the services in 3 categories:

  • Initializer /database_init which initializes the database with the sample data required
  • ActivityResource /activity_types which only accepts a get, and returns the activity types
  • PersonResource /person which is resposible for handling all the requests coming based on /person The responses are created using a ResponseBuilder, and the data is automatically marshalled/unmarshalled. I had to implement some wrapper classes in order to have the correct output as per specifications (return the list of activity types). These objects only contain a List of the wrapped objects.

just run ant execute.client to compile and run the client

I did implemented an exception mapper on the server, which catches every jersey WebApplicationException and returns them to the client with the same error code, but with the added stacktrace. Debugging was a nightmare without this. If the exception does not come from the application a INTERNAL_SERVER_ERROR is thrown with the "cause". If such an error comes to the cluent with no apparent stacktrace or with DAO initialization failure it means that the heroku app has hanged and needs a restart.

introsde2017-assignment-2-client's People

Contributors

dallatorretdu avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.