Giter Site home page Giter Site logo

mgo's Introduction

mgo

webapp for mgo

Technologies used:

  • MongoDB to store a list of users in json format. There are no foreign key constraints in this application, and Java provides Jackson library to map json to Java object easily. I used maven to build the project and generate war file, then deploy it to Tomcat and make rest calls. I used Spring MVC to set up Restful web service calls.

  • To handle versioning, the base path for Rest call should be changed in the web.xml file when doing servlet mapping. In particular, I can add version number (i.e. v1, v2, e.t.c. from the properties file) to the servlet url pattern, such as:

    mgo /${version}

    The request mapping path in the controllers should be changed correspondingly to support newer version. The older controllers should be kept in the source too to still support the older version.

  • For pagination, I would create Pagination that stores total number of items (users), current page number, items per page, previous page, and next page. For each requested page to load, I would calculate the starting record number. The new method should be added to UserDao to retrieve a list of users starting from a specific record number, such as:

    userDao.listUsersByGender(String gender, Integer start, Integer limit), where limit is items per page.

  • Running instructions:

    1. Please install Java 1.6, Tomcat 7, latest MongoDB, maven 3, and Eclipse.

    2. Download source code from the following github link:

    https://github.com/yfurman/mgo.git

  1. Create a new project by importing all the source in your Eclipse environment.

  2. Start mongoDB on your machine.

  3. Go to your project folder and build it. Issue the following commmand:

    mvn clean install -DskipTests

    Note: you don't have to skip the tests, however, you should change the values to your own before running them. For example, in the DirectoryServiceImplTest the path /Users/eugenefurman/Documents might not exist on your hard drive.

  4. The mgo database contains User collection. Please run UserDaoImplTest.testAddUser(), changing username, password, role, and gender to different values in order to insert unique users. My program does not enforce username to be unique since this is not a production application, however, it should handle attempts to insert duplicate users.

  5. Run the following command to deploy built war file to your <tomcat_home>/webapps directory. Rename the war to mgo.war.

  6. Start tomcat.

  7. Here are the Rest calls for each different task.

    1. check status of running components (it is only able to test mongodb connection):

    2. list all users filtered by gender:

      grouping by does not seem to be relevant in this case, because we are not aggregating on anything, such as count, sum, date.

    3. list all files in the directory:

      if the provided path is not valid, it will log the exception and return empty list

    4. authenticate user

      Please enter username and password in the text fields (left to right), then click authenticate. Clicking on authenticate button generates ajax post request that sends json data consisting of username/password. This json object is mapped to the AuthParams Java object annotated by RequestBody in the UserController.

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.