Package com.github.jacek99.myapp.domain

Examples of com.github.jacek99.myapp.domain.Country


    @POST
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    @Produces(MediaType.APPLICATION_JSON)
    public Response add(@FormParam("countryCode") String countryCode, @FormParam("name") String name) {
        Country country = new Country();
        country.setCountryCode(countryCode);
        country.setName(name);
        dao.add(country);

        return RestUtils.getCreatedResponse(CountryResource.class, country, country.getCountryCode());
    }
View Full Code Here


    @PATCH
    @Path("/{countryCode}")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    public Response update(@PathParam("countryCode") String countryCode, @FormParam("name") String name) {
        Country country = dao.getExistingById(countryCode);
        if(name != null) {
            country.setName(name);
        }
        dao.update(country);
        return Response.noContent().build();
    }
View Full Code Here

    }

    @DELETE
    @Path("/{countryCode}")
    public Response delete(@PathParam("countryCode") String countryCode) {
        Country country = dao.getExistingById(countryCode);
        dao.delete(country.getCountryCode());
        return Response.noContent().build();
    }
View Full Code Here

    /**
     * throws exception if country not found for easy 404 error handling throughout app
     */
    public Country getExistingById(String countryCode) {
        Country country = getById(countryCode).orNull();
        if (country != null) {
            return country;
        } else {
            throw new NotFoundException("Country",countryCode);
        }
View Full Code Here

    @Secured(Authorities.ROLE_ADMIN)
    public void add(Country country) {
        entityValidator.validate(country,"countryCode");
        if (database.containsKey(country.getCountryCode())) {
            throw new ConflictException("Country","countryCode",country.getCountryCode());
        } else {
            database.put(country.getCountryCode(),country);
        }
    }
View Full Code Here

        Set<ConstraintViolation<E>> violations = v.validate(entity);
        if (violations.size() > 0) {
            ConstraintViolation   cv = getFirstContraintViolation(violations, idFieldName);
            //return first error
            throw new EntityConstraintViolationException(cv.getRootBeanClass().getSimpleName(),
                    cv.getPropertyPath().toString(),cv.getInvalidValue(),cv.getMessage());
        }
    }
View Full Code Here

    public Country getExistingById(String countryCode) {
        Country country = getById(countryCode).orNull();
        if (country != null) {
            return country;
        } else {
            throw new NotFoundException("Country",countryCode);
        }
    }
View Full Code Here

        for(Map.Entry<String,Object> entry : providers.entrySet()) {
            environment.addProvider(entry.getValue());
        }

        //last, but not least, let's link Spring to the embedded Jetty in Dropwizard
        environment.addServletListeners(new SpringContextLoaderListener(ctx));

        //activate Spring Security filter
        environment.addFilter(DelegatingFilterProxy.class,"/*").setName("springSecurityFilterChain");

    }
View Full Code Here

TOP

Related Classes of com.github.jacek99.myapp.domain.Country

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.