001/*
002 * Copyright 2011-2013 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.sdk;
019
020import com.unboundid.scim.schema.ResourceDescriptor;
021
022import javax.servlet.http.HttpServletRequest;
023import java.net.URI;
024
025
026
027/**
028 * This class represents a SCIM Put Resource request to replace the contents
029 * of an existing resource.
030 */
031public final class PutResourceRequest extends ResourceReturningRequest
032{
033  /**
034   * The target resource ID.
035   */
036  private final String resourceID;
037
038  /**
039   * The new contents of the resource.
040   */
041  private final SCIMObject resourceObject;
042
043
044
045  /**
046   * Create a new SCIM Put Resource request from the provided information.
047   *
048   * @param baseURL              The base URL for the SCIM service.
049   * @param authenticatedUserID  The authenticated user name or {@code null} if
050   *                             the request is not authenticated.
051   * @param resourceDescriptor   The ResourceDescriptor associated with this
052   *                             request.
053   * @param resourceID           The target resource ID.
054   * @param resourceObject       The new contents of the resource.
055   * @param attributes           The set of requested attributes.
056   */
057  public PutResourceRequest(final URI baseURL,
058                            final String authenticatedUserID,
059                            final ResourceDescriptor resourceDescriptor,
060                            final String resourceID,
061                            final SCIMObject resourceObject,
062                            final SCIMQueryAttributes attributes)
063  {
064    super(baseURL, authenticatedUserID, resourceDescriptor, attributes);
065    this.resourceID          = resourceID;
066    this.resourceObject      = resourceObject;
067  }
068
069
070
071  /**
072   * Create a new SCIM Put Resource request from the provided information.
073   *
074   * @param baseURL              The base URL for the SCIM service.
075   * @param authenticatedUserID  The authenticated user name or {@code null} if
076   *                             the request is not authenticated.
077   * @param resourceDescriptor   The ResourceDescriptor associated with this
078   *                             request.
079   * @param resourceID           The target resource ID.
080   * @param resourceObject       The new contents of the resource.
081   * @param attributes           The set of requested attributes.
082   * @param httpServletRequest   The HTTP servlet request associated with this
083   *                             request or {@code null} if this request is not
084   *                             initiated by a servlet.
085   */
086  public PutResourceRequest(final URI baseURL,
087                            final String authenticatedUserID,
088                            final ResourceDescriptor resourceDescriptor,
089                            final String resourceID,
090                            final SCIMObject resourceObject,
091                            final SCIMQueryAttributes attributes,
092                            final HttpServletRequest httpServletRequest)
093  {
094    super(baseURL, authenticatedUserID, resourceDescriptor, attributes,
095          httpServletRequest);
096    this.resourceID          = resourceID;
097    this.resourceObject      = resourceObject;
098  }
099
100
101
102  /**
103   * Get the target resource ID.
104   *
105   * @return  The target resource ID.
106   */
107  public String getResourceID()
108  {
109    return resourceID;
110  }
111
112
113
114  /**
115   * Get the contents of the resource to be created.
116   *
117   * @return  The contents of the resource to be created.
118   */
119  public SCIMObject getResourceObject()
120  {
121    return resourceObject;
122  }
123}