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

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


        "text/csv"})
    public DefectsAsset getDefects(@QueryParam(FTS) String query,
                                   @QueryParam(SEVERIIY) String severity,
                                   @QueryParam(ASSIGNED_TO) String assignedTo) {

        DataStore store = DataStore.getInstance();

        // fill search parameters
        // the parameters may be absent, the SearchMap will do the filtering
        SearchMap searchParameters = new SearchMap();
        searchParameters.put(FTS, query);
        searchParameters.put(SEVERIIY, severity);
        searchParameters.put(ASSIGNED_TO, assignedTo);

        // get the defects that match the search criteria
        Collection<DefectBean> defects = store.getDefects(searchParameters);
        return new DefectsAsset(defects);
    }
View Full Code Here


    public Response createDefects(DefectsAsset defects,
                                  @Context LinkBuilders linkProcessor,
                                  @Context UriInfo uriInfo) {

        // add the defects to the defects store
        DataStore store = DataStore.getInstance();
        String id = null;
        for (DefectBean defect : defects.getDefects()) {
            id = store.getDefectUniqueId();
            defect.setId(id);
            store.putDefect(id, defect);
        }

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

            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

    public TestsAsset getTests(@Context LinkBuilders linkProcessor,
                               @Context UriInfo uriInfo,
                               @PathParam("defect") String defectId) {

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

        // create data object (populated with store data)
        DefectBean defect = store.getDefect(defectId);
        if (defect == null) {
            logger.error("Defect {} was not found", defectId);
            throw new WebApplicationException(Response.Status.NOT_FOUND);
        }
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.