Package org.apache.wink.example.qadefect.legacy

Examples of org.apache.wink.example.qadefect.legacy.DataStore


            logger.error("The content of the defect is missing");
            throw new WebApplicationException(Response.Status.BAD_REQUEST);
        }

        // add the defect to the defects store and set it a new ID
        DataStore store = DataStore.getInstance();
        String id = store.getDefectUniqueId();
        DefectBean defect = asset.getDefect();
        defect.setId(id);
        store.putDefect(id, defect);

        // return the defect and set the status code to created (201)
        URI location = uriInfo.getAbsolutePathBuilder().segment(id).build();
        return Response.created(location).entity(asset).build();
    }
View Full Code Here


    @Produces( {MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON,
        MediaType.APPLICATION_XML, MediaType.TEXT_HTML})
    public DefectAsset getDefect(@PathParam("defect") String defectId) {
        // fetch the defect bean from the store, throw 404 in case it does not
        // exist
        DataStore store = DataStore.getInstance();
        DefectBean defect = store.getDefect(defectId);
        if (defect == null) {
            logger.info("Defect {} does not exist", defectId);
            throw new WebApplicationException(Response.Status.NOT_FOUND);
        }
View Full Code Here

    @Path(DEFECT_ATTACHMENT_PATH)
    @GET
    @Produces( {MediaTypeUtils.IMAGE_JPEG})
    public InputStream getDefectAttachement(@PathParam("defect") String defectId) {

        DataStore store = DataStore.getInstance();

        // create data object (populated with store data)
        DefectBean defect = store.getDefect(defectId);
        if (defect == null) {
            logger.info("Defect {} does not exist", defectId);
            throw new WebApplicationException(Response.Status.NOT_FOUND);
        }
View Full Code Here

        MediaType.APPLICATION_XML})
    public DefectAsset updateDefect(DefectAsset asset,
                                    @Context LinkBuilders linkProcessor,
                                    @PathParam("defect") String defectId) {

        DataStore store = DataStore.getInstance();
        // verify Defect exist in the store, return 404 otherwise
        DefectBean bean = store.getDefect(defectId);
        if (bean == null) {
            logger.info("Defect {} does not exist", defectId);
            throw new WebApplicationException(Response.Status.NOT_FOUND);
        }

        // set Id in the resources data for cases that element <id> is missing
        // in the request body
        DefectBean defect = asset.getDefect();
        defect.setId(defectId);

        // update defect legacy bean to the store
        store.putDefect(defectId, defect);
        return asset;
    }
View Full Code Here

    @Path(DEFECT_PATH)
    @DELETE
    @Produces( {MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON,
        MediaType.APPLICATION_XML})
    public DefectAsset deleteDefect(@PathParam("defect") String defectId) {
        DataStore store = DataStore.getInstance();
        DefectBean defect = store.getDefect(defectId);
        store.removeDefect(defectId);
        return new DefectAsset(defect);
    }
View Full Code Here

    @GET
    @Produces( {MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
    public TestsAsset getTests(@Context UriInfo uriInfo) {

        // initialize the memory store
        DataStore store = DataStore.getInstance();

        // create data object (populated with store data)
        Collection<TestBean> tests = store.getTests();
        if (tests == null) {
            logger.error("No tests found");
            throw new WebApplicationException(Response.Status.NOT_FOUND);
        }
        return new TestsAsset(tests);
View Full Code Here

    @Produces( {MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON,
        MediaType.APPLICATION_XML})
    public TestAsset getTest(@PathParam("test") String testId) {

        // initialize memory store
        DataStore store = DataStore.getInstance();

        // create data object (populated with store data)
        TestBean test = store.getTest(testId);
        if (test == null) {
            logger.error("Test {} was not found", testId);
            throw new WebApplicationException(Response.Status.NOT_FOUND);
        }
View Full Code Here

TOP

Related Classes of org.apache.wink.example.qadefect.legacy.DataStore

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.