001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2006-2008 Sun Microsystems, Inc. 025 * Portions Copyright 2014-2015 ForgeRock AS 026 */ 027package org.opends.server.types; 028 029import java.util.List; 030 031import org.forgerock.i18n.LocalizableMessage; 032import org.forgerock.opendj.ldap.ResultCode; 033import org.opends.server.api.plugin.PluginResult.OperationResult; 034 035/** 036 * This class defines a data structure that holds information about 037 * the result of processing by a synchronization provider. 038 */ 039@org.opends.server.types.PublicAPI( 040 stability=org.opends.server.types.StabilityLevel.VOLATILE, 041 mayInstantiate=false, 042 mayExtend=false, 043 mayInvoke=true) 044public interface SynchronizationProviderResult extends OperationResult 045{ 046 /** Defines a continue processing synchronization provider result. */ 047 public class ContinueProcessing implements SynchronizationProviderResult 048 { 049 @Override 050 public ResultCode getResultCode() 051 { 052 return null; 053 } 054 055 @Override 056 public DN getMatchedDN() 057 { 058 return null; 059 } 060 061 @Override 062 public List<String> getReferralURLs() 063 { 064 return null; 065 } 066 067 @Override 068 public boolean continueProcessing() 069 { 070 return true; 071 } 072 073 @Override 074 public LocalizableMessage getErrorMessage() 075 { 076 return null; 077 } 078 079 @Override 080 public String toString() 081 { 082 return getClass().getSimpleName(); 083 } 084 } 085 086 /** Defines a stop processing synchronization provider result. */ 087 public class StopProcessing implements SynchronizationProviderResult 088 { 089 /** The result code for this result. */ 090 private final ResultCode resultCode; 091 private final LocalizableMessage errorMessage; 092 /** The matched DN for this result. */ 093 private final DN matchedDN; 094 /** The set of referral URLs for this result. */ 095 private final List<String> referralURLs; 096 097 /** 098 * Construct a new stop processing synchronization provider result. 099 * 100 * @param resultCode 101 * The result code for this result. 102 * @param errorMessage 103 * An message explaining why processing should stop. 104 * @param matchedDN 105 * The matched DN for this result. 106 * @param referralURLs 107 * The set of referral URLs for this result. 108 */ 109 public StopProcessing(ResultCode resultCode, LocalizableMessage errorMessage, 110 DN matchedDN, List<String> referralURLs) 111 { 112 this.errorMessage = errorMessage; 113 this.matchedDN = matchedDN; 114 this.resultCode = resultCode; 115 this.referralURLs = referralURLs; 116 } 117 118 /** 119 * Construct a new stop processing synchronization provider result. 120 * 121 * @param resultCode 122 * The result code for this result. 123 * @param errorMessage 124 * An message explaining why processing should stop. 125 */ 126 public StopProcessing(ResultCode resultCode, LocalizableMessage errorMessage) 127 { 128 this.errorMessage = errorMessage; 129 this.resultCode = resultCode; 130 this.matchedDN = null; 131 this.referralURLs = null; 132 } 133 134 @Override 135 public ResultCode getResultCode() 136 { 137 return resultCode; 138 } 139 140 @Override 141 public DN getMatchedDN() 142 { 143 return matchedDN; 144 } 145 146 @Override 147 public List<String> getReferralURLs() 148 { 149 return referralURLs; 150 } 151 152 @Override 153 public boolean continueProcessing() 154 { 155 return false; 156 } 157 158 @Override 159 public LocalizableMessage getErrorMessage() 160 { 161 return errorMessage; 162 } 163 164 @Override 165 public String toString() 166 { 167 StringBuilder sb = new StringBuilder(getClass().getSimpleName()) 168 .append("(resultCode=").append(resultCode) 169 .append(", errorMessage=").append(errorMessage); 170 if (matchedDN != null) 171 { 172 sb.append(", matchedDN=").append(matchedDN); 173 } 174 if (referralURLs != null && !referralURLs.isEmpty()) 175 { 176 sb.append(", referralURLs=").append(referralURLs); 177 } 178 sb.append(")"); 179 return sb.toString(); 180 } 181 } 182}