@@ -0,0 +1,2596 @@
+/*%0A * Copyright 2016 Gustavo Pacheco %3Cryctabo@gmail.com%3E.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage co.edu.unicartagena.platf.rest.resources;%0A%0Aimport co.edu.unicartagena.platf.entity.Document;%0Aimport co.edu.unicartagena.platf.service.DocumentService;%0Aimport co.edu.unicartagena.platf.service.DocumentServiceImpl;%0A%0Aimport java.net.URI;%0Aimport java.util.List;%0A%0Aimport javax.ws.rs.Consumes;%0Aimport javax.ws.rs.DELETE;%0Aimport javax.ws.rs.GET;%0Aimport javax.ws.rs.POST;%0Aimport javax.ws.rs.PUT;%0Aimport javax.ws.rs.Path;%0Aimport javax.ws.rs.PathParam;%0Aimport javax.ws.rs.Produces;%0Aimport javax.ws.rs.core.Context;%0Aimport javax.ws.rs.core.MediaType;%0Aimport javax.ws.rs.core.Response;%0Aimport javax.ws.rs.core.UriInfo;%0A%0A/**%0A *%0A * @author Gustavo Pacheco %3Cryctabo@gmail.com%3E%0A * @version 1.0-SNAPSHOT%0A */%0A@Path(%22documents%22)%0A@Produces(MediaType.APPLICATION_JSON)%0A@Consumes(MediaType.APPLICATION_JSON)%0Apublic class DocumentResource %7B%0A    %0A    DocumentService service = DocumentServiceImpl.getInstance();%0A    %0A    @GET%0A    public List%3CDocument%3E getAllDocuments() %7B%0A        return service.getAll();%0A    %7D%0A    %0A    @GET%0A    @Path(%22%7BdocumentId%7D%22)%0A    public Document getDocument(@PathParam(%22documentId%22) Integer id) %7B%0A        return service.get(id);%0A    %7D%0A    %0A    @POST%0A    public Response addNewDocument(Document document, @Context UriInfo uriInfo) %7B%0A        Document newDocument = service.add(document);%0A        String newId = String.valueOf(newDocument.getId());%0A        URI uri = uriInfo.getAbsolutePathBuilder()%0A                .path(DocumentResource.class)%0A                .path(newId)%0A                .build();%0A        return Response.created(uri)%0A                .entity(newDocument)%0A                .build();%0A    %7D%0A    %0A    @PUT%0A    @Path(%22%7BdocumentId%7D%22)%0A    public Document updateDocument(@PathParam(%22documentId%22) Integer id,%0A            Document document) %7B%0A        return service.update(id, document);%0A    %7D%0A    %0A    @DELETE%0A    @Path(%22%7BdocumentId%7D%22)%0A    public Document deleteDocument(@PathParam(%22documentId%22) Integer id) %7B%0A        return service.remove(id);%0A    %7D%0A    %0A%7D%0A

Create resource for documents