001/* 002 * Copyright 2012-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.sdk; 019 020 021 022import com.unboundid.scim.schema.ResourceDescriptor; 023 024 025 026/** 027 * This class must be extended to handle the content of a bulk operation. 028 */ 029public abstract class BulkContentHandler 030{ 031 /** 032 * Handles the value of failOnErrors. 033 * 034 * @param failOnErrors The number of errors that the Service Provider will 035 * accept before the operation is terminated and an 036 * error response is returned. 037 */ 038 public void handleFailOnErrors(final int failOnErrors) 039 { 040 // No implementation by default. 041 } 042 043 044 045 /** 046 * Handle an individual operation. 047 * 048 * @param opIndex The index of the operation. 049 * @param bulkOperation The individual operation within the bulk operation. 050 * 051 * @throws SCIMException If an error occurs that prevents processing of the 052 * entire bulk content. 053 * @throws BulkException If an error occurs while processing the individual 054 * operation within the bulk operation. 055 */ 056 public void handleOperation(final int opIndex, 057 final BulkOperation bulkOperation) 058 throws BulkException, SCIMException 059 { 060 // No implementation by default. 061 } 062 063 064 065 /** 066 * Handle an exception encountered when processing an individual operation. 067 * 068 * @param opIndex The index of the operation. 069 * @param bulkException The exception encountered when processing an 070 * individual operation within the bulk operation. 071 * 072 * @return {@code true} if operations should continue to be provided, 073 * or {@code false} if the remaining operations are of no interest. 074 * 075 * @throws SCIMException If an error occurs that prevents processing of the 076 * entire bulk content. 077 */ 078 public boolean handleException(final int opIndex, 079 final BulkException bulkException) 080 throws SCIMException 081 { 082 throw bulkException.getCause(); 083 } 084 085 086 087 /** 088 * Retrieve the resource descriptor for a given endpoint. 089 * 090 * @param endpoint A SCIM resource endpoint. 091 * 092 * @return The resource descriptor for this endpoint, or {@code null} if the 093 * endpoint is unknown. 094 */ 095 public ResourceDescriptor getResourceDescriptor(final String endpoint) 096 { 097 // Null implementation by default. 098 return null; 099 } 100 101 102 103 /** 104 * Transform a data value. This method may be used to resolve bulkId 105 * references to resource IDs. 106 * 107 * @param opIndex The index of the bulk operation containing the data value. 108 * @param value The value to be transformed. 109 * 110 * @return The transformed value. 111 */ 112 public String transformValue(final int opIndex, final String value) 113 { 114 // No-op by default. 115 return value; 116 } 117}