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