Package org.apache.wink.example.simpledefects.legacy

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


     * @return response with requested resource representation
     */
    @GET
    @Produces( {MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
    public DefectsAsset getDefects() {
        DataStore store = DataStore.getInstance();
        Collection<DefectBean> defects = store.getDefects();
        DefectsAsset asset = new DefectsAsset(defects);
        return asset;
    }
View Full Code Here


        // entries,
        // - in our case we use a helper method to generate a unique Id
        defect.setId(DataStore.getInstance().getDefectUniqueId());

        // add defect legacy bean to the memory store
        DataStore store = DataStore.getInstance();
        store.putDefect(defect.getId(), defect);

        // return status code 201 (created) with the created defect
        URI location = uriInfo.getAbsolutePathBuilder().segment(defect.getId()).build();
        return Response.status(Response.Status.CREATED).entity(asset).location(location)
            .tag(new EntityTag(String.valueOf(defect.hashCode()))).build();
View Full Code Here

    @GET
    @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML,
        MediaType.APPLICATION_JSON})
    public DefectAsset getDefect(@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);
        }
        // create a new instance of a defect asset
View Full Code Here

    public DefectAsset updateDefect(DefectAsset asset,
                                    @Context UriInfo uriInfo,
                                    @PathParam(DEFECT) String defectId) throws IOException {

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

        // verify the defect exists in the store
        DefectBean defect = store.getDefect(defectId);
        if (defect == null) {
            logger.error("Defect {} was not found", 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
        defect = asset.getDefect();
        defect.setId(defectId);
        // update defect legacy bean to the memory store
        store.putDefect(defect.getId(), defect);
        return asset;
    }
View Full Code Here

    @Produces( {MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON,
        MediaType.APPLICATION_XML})
    public DefectAsset deleteDefect(@Context UriInfo uriInfo, @PathParam(DEFECT) String defectId) {

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

        // obtain data object from memory store
        DefectBean defect = store.getDefect(defectId);
        if (defect == null) {
            logger.error("Defect {} was not found", defectId);
            throw new WebApplicationException(Response.Status.NOT_FOUND);
        }

        // remove defect legacy bean from memory store
        store.removeDefect(defect.getId());

        // create new asset and set defect bean that is being deleted as its
        // data object
        DefectAsset asset = new DefectAsset(defect);
        return asset;
View Full Code Here

     * @return response with requested resource representation
     */
    @GET
    @Produces( {MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
    public DefectsAsset getDefects() {
        DataStore store = DataStore.getInstance();
        Collection<DefectBean> defects = store.getDefects();
        DefectsAsset asset = new DefectsAsset(defects);
        return asset;
    }
View Full Code Here

        // entries,
        // - in our case we use a helper method to generate a unique Id
        defect.setId(DataStore.getInstance().getDefectUniqueId());

        // add defect legacy bean to the memory store
        DataStore store = DataStore.getInstance();
        store.putDefect(defect.getId(), defect);

        // return status code 201 (created) with the created defect
        URI location = uriInfo.getAbsolutePathBuilder().segment(defect.getId()).build();
        return Response.status(Response.Status.CREATED).entity(asset).location(location)
            .tag(new EntityTag(String.valueOf(defect.hashCode()))).build();
View Full Code Here

    @GET
    @Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML,
        MediaType.APPLICATION_JSON})
    public DefectAsset getDefect(@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);
        }
        // create a new instance of a defect asset
View Full Code Here

    public DefectAsset updateDefect(DefectAsset asset,
                                    @Context UriInfo uriInfo,
                                    @PathParam(DEFECT) String defectId) throws IOException {

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

        // verify the defect exists in the store
        DefectBean defect = store.getDefect(defectId);
        if (defect == null) {
            logger.error("Defect {} was not found", 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
        defect = asset.getDefect();
        defect.setId(defectId);
        // update defect legacy bean to the memory store
        store.putDefect(defect.getId(), defect);
        return asset;
    }
View Full Code Here

    @Produces( {MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON,
        MediaType.APPLICATION_XML})
    public DefectAsset deleteDefect(@Context UriInfo uriInfo, @PathParam(DEFECT) String defectId) {

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

        // obtain data object from memory store
        DefectBean defect = store.getDefect(defectId);
        if (defect == null) {
            logger.error("Defect {} was not found", defectId);
            throw new WebApplicationException(Response.Status.NOT_FOUND);
        }

        // remove defect legacy bean from memory store
        store.removeDefect(defect.getId());

        // create new asset and set defect bean that is being deleted as its
        // data object
        DefectAsset asset = new DefectAsset(defect);
        return asset;
View Full Code Here

TOP

Related Classes of org.apache.wink.example.simpledefects.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.