001/* 002 * Copyright 2013-2016 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 018package com.unboundid.scim.wink; 019 020import com.unboundid.scim.sdk.SCIMException; 021import com.unboundid.scim.sdk.SCIMResponse; 022 023import javax.ws.rs.GET; 024import javax.ws.rs.Path; 025import javax.ws.rs.Produces; 026import javax.ws.rs.core.MediaType; 027import javax.ws.rs.core.Response; 028 029 030 031/** 032 * Default content for the SCIM service base URL. 033 */ 034@Path("") 035public class RootResource extends AbstractStaticResource 036{ 037 /** 038 * Create a new JAX-RS resource. 039 * 040 * @param application The SCIM JAX-RS application associated with this 041 * resource. 042 */ 043 public RootResource(final SCIMApplication application) 044 { 045 } 046 047 048 049 /** 050 * Create a SCIM response for the SCIM service base URL. 051 * @return A SCIM response. 052 */ 053 private SCIMResponse getResponse() 054 { 055 return SCIMException.createException( 056 200, 057 "You have accessed the SCIM service base URL. You must append " + 058 "a SCIM endpoint name to the URL to access SCIM resources (e.g. " + 059 "/Schemas, /Users)"); 060 } 061 062 063 064 /** 065 * Implement the GET operation to return JSON format. 066 * 067 * @return The response to the request. 068 */ 069 @GET 070 @Produces(MediaType.APPLICATION_JSON) 071 public Response doJsonGet() 072 { 073 final SCIMResponse response = getResponse(); 074 Response.ResponseBuilder builder = Response.ok(); 075 076 setResponseEntity(builder, MediaType.APPLICATION_JSON_TYPE, response); 077 return builder.build(); 078 } 079 080 081 082 /** 083 * Implement the GET operation to return XML format. 084 * 085 * @return The response to the request. 086 */ 087 @GET 088 @Produces(MediaType.APPLICATION_XML) 089 public Response doXmlGet() 090 { 091 final SCIMResponse response = getResponse(); 092 Response.ResponseBuilder builder = Response.ok(); 093 094 setResponseEntity(builder, MediaType.APPLICATION_XML_TYPE, response); 095 return builder.build(); 096 } 097}