Package org.apache.wink.example.history.legacy

Examples of org.apache.wink.example.history.legacy.DefectBean


                                 @Context LinkBuilders linkProcessor,
                                 @Context UriInfo uriInfo) {

        // if content was not sent => there is no meaning for the defect, throw
        // exception.
        DefectBean defect = asset.getDefect();
        if (defect == null) {
            throw new WebApplicationException(
                                              new RuntimeException(
                                                                   "The content of the defect is missing"),
                                              Response.Status.BAD_REQUEST);
        }

        DataStore store = DataStore.getInstance();
        if (defect.getId() != null) {
            // undelete operation
            if (!store.isDefectDeleted(defect.getId())) {
                // the defect was already undeleted!
                // it's a conflict!
                return Response.status(Status.CONFLICT).build();
            }
            // this is undelete operation, there is no need to populate new id
        } else {
            // this is a new defect so generate an id
            defect.setId(store.getDefectUniqueId());
        }

        // validate that the user didn't send deleted=true by mistake
        defect.setDeleted(false);

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

        URI location = uriInfo.getAbsolutePathBuilder().segment(defect.getId()).build();
        return Response.created(location).entity(asset).build();
    }
View Full Code Here


                                 @MatrixParam(REVISION) @DefaultValue("-1") int defectRevision) {

        // create data object (populated with store data)
        DataStore store = DataStore.getInstance();
        String defectId = segment.getPath();
        DefectBean defect = store.getDefect(defectId);
        if (defectRevision != -1) {
            // get specific revision
            // even if the defect was deleted, it is returned
            defect = store.getDefect(defectId, defectRevision);
        }
View Full Code Here

        // obtain data object from the memory store
        // if the defect was deleted, it cannot be updated anymore.
        DataStore store = DataStore.getInstance();
        String defectId = segement.getPath();
        DefectBean defect = store.getDefect(defectId);
        if (defect == null) {
            throw new WebApplicationException(new RuntimeException("Defect " + defectId
                + " not found"), Response.Status.NOT_FOUND);
        }

        // validate that user didn't send deleted flag, since it will mark
        // defect as deleted.
        // to delete a defect, DELETE http method should be used
        defect = asset.getDefect();
        defect.setDeleted(false);

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

        // update defect legacy bean to the memory store
        store.putDefect(defectId, defect);

        return asset;
View Full Code Here

        // obtain data object from memory store
        // if the object was already deleted, null will be returned
        DataStore store = DataStore.getInstance();
        String defectId = segement.getPath();
        DefectBean defect = store.getDefect(defectId);
        if (defect == null) {
            throw new WebApplicationException(new RuntimeException("Defect " + defectId
                + " not found"), Response.Status.NOT_FOUND);
        }
View Full Code Here

TOP

Related Classes of org.apache.wink.example.history.legacy.DefectBean

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.