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