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 2008 Sun Microsystems, Inc. 015 * Portions Copyright 2013-2015 ForgeRock AS. 016 */ 017package org.opends.server.replication.plugin; 018 019 020import org.forgerock.opendj.ldap.ByteString; 021import org.opends.server.types.Control; 022import org.opends.server.types.DirectoryException; 023import org.opends.server.controls.ControlDecoder; 024import org.forgerock.opendj.io.ASN1Writer; 025 026import java.io.IOException; 027 028 029/** 030 * This class implements the Sun-defined replication repair control. 031 * This control can be used to modify the content of a replicated database 032 * on a single server without impacting the other servers that are replicated 033 * with this server. 034 * It also allows to modify attributes like entryuuid and ds-sync-hist that 035 * are normally not modifiable from an external connection. 036 */ 037public class ReplicationRepairRequestControl extends Control 038{ 039 /** 040 * ControlDecoder implementation to decode this control from a ByteString. 041 */ 042 private static final class Decoder 043 implements ControlDecoder<ReplicationRepairRequestControl> 044 { 045 /** {@inheritDoc} */ 046 public ReplicationRepairRequestControl decode(boolean isCritical, 047 ByteString value) 048 throws DirectoryException 049 { 050 return new ReplicationRepairRequestControl(isCritical); 051 } 052 053 /** {@inheritDoc} */ 054 public String getOID() 055 { 056 return OID_REPLICATION_REPAIR_CONTROL; 057 } 058 059 } 060 061 /** 062 * The Control Decoder that can be used to decode this control. 063 */ 064 public static final ControlDecoder<ReplicationRepairRequestControl> DECODER = 065 new Decoder(); 066 067 /** 068 * The OID of the Replication repair Control. 069 */ 070 public static final String 071 OID_REPLICATION_REPAIR_CONTROL = "1.3.6.1.4.1.26027.1.5.2"; 072 073 /** 074 * Creates a new instance of the replication repair request control with the 075 * default settings. 076 */ 077 public ReplicationRepairRequestControl() 078 { 079 super(OID_REPLICATION_REPAIR_CONTROL, false); 080 081 } 082 083 /** 084 * Creates a new instance of the replication repair control with the 085 * provided information. 086 * 087 * @param isCritical Indicates whether support for this control should be 088 * considered a critical part of the client processing. 089 */ 090 public ReplicationRepairRequestControl(boolean isCritical) 091 { 092 super(OID_REPLICATION_REPAIR_CONTROL, isCritical); 093 094 } 095 096 /** 097 * Writes this control value to an ASN.1 writer. The value (if any) must be 098 * written as an ASN1OctetString. 099 * 100 * @param writer The ASN.1 writer to use. 101 * @throws IOException If a problem occurs while writing to the stream. 102 */ 103 @Override 104 protected void writeValue(ASN1Writer writer) throws IOException { 105 // No value element 106 } 107 108 /** 109 * Appends a string representation of this replication repair request control 110 * to the provided buffer. 111 * 112 * @param buffer The buffer to which the information should be appended. 113 */ 114 @Override 115 public void toString(StringBuilder buffer) 116 { 117 buffer.append("ReplicationRepairRequestControl()"); 118 } 119} 120