001 /*
002 * Copyright 2012 UnboundID Corp.
003 *
004 * This program is free software; you can redistribute it and/or modify
005 * it under the terms of the GNU General Public License (GPLv2 only)
006 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
007 * as published by the Free Software Foundation.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012 * GNU General Public License for more details.
013 *
014 * You should have received a copy of the GNU General Public License
015 * along with this program; if not, see <http://www.gnu.org/licenses>.
016 */
017
018 package com.unboundid.scim.wink;
019
020 import com.unboundid.scim.sdk.SCIMBackend;
021
022 import javax.servlet.ServletContext;
023 import javax.ws.rs.Consumes;
024 import javax.ws.rs.POST;
025 import javax.ws.rs.Path;
026 import javax.ws.rs.Produces;
027 import javax.ws.rs.core.Context;
028 import javax.ws.rs.core.HttpHeaders;
029 import javax.ws.rs.core.MediaType;
030 import javax.ws.rs.core.Response;
031 import javax.ws.rs.core.SecurityContext;
032 import javax.ws.rs.core.UriInfo;
033 import java.io.InputStream;
034
035
036
037 /**
038 * This class is a JAX-RS resource for the Bulk operation, where JSON
039 * content type is specified in the URL path.
040 */
041 @Path("Bulk.json")
042 public class JSONBulkResource extends AbstractBulkResource
043 {
044 /**
045 * Create a new instance of the bulk resource.
046 *
047 * @param application The SCIM JAX-RS application associated with this
048 * resource.
049 * @param bulkResourceStats The resource stats for the bulk operation
050 * end-point.
051 * @param backend The SCIMBackend to use to process individual
052 * operations within a bulk operation.
053 */
054 public JSONBulkResource(final SCIMApplication application,
055 final ResourceStats bulkResourceStats,
056 final SCIMBackend backend)
057 {
058 super(application, bulkResourceStats, backend);
059 }
060
061
062
063 /**
064 * Implement the POST operation consuming and producing JSON format.
065 *
066 * @param inputStream The content to be consumed.
067 * @param servletContext The servlet context for the request.
068 * @param securityContext The security context for the request.
069 * @param headers The request headers.
070 * @param uriInfo The URI info for the request.
071 *
072 * @return The response to the request.
073 */
074 @POST
075 @Consumes(MediaType.APPLICATION_JSON)
076 @Produces(MediaType.APPLICATION_JSON)
077 public Response doJsonJsonPost(final InputStream inputStream,
078 @Context final ServletContext servletContext,
079 @Context final SecurityContext securityContext,
080 @Context final HttpHeaders headers,
081 @Context final UriInfo uriInfo)
082 {
083 final RequestContext requestContext =
084 new RequestContext(servletContext, securityContext, headers, uriInfo,
085 MediaType.APPLICATION_JSON_TYPE,
086 MediaType.APPLICATION_JSON_TYPE);
087 return postBulk(requestContext, inputStream);
088 }
089 }