1 21 22 package org.apache.derby.impl.store.raw.data; 23 24 import org.apache.derby.iapi.services.io.StoredFormatIds; 25 import org.apache.derby.iapi.services.sanity.SanityManager; 26 import org.apache.derby.iapi.store.raw.Compensation; 27 import org.apache.derby.iapi.store.raw.Transaction; 28 import org.apache.derby.iapi.store.raw.Undoable; 29 import org.apache.derby.iapi.store.raw.Loggable; 30 import org.apache.derby.iapi.store.raw.data.RawContainerHandle; 31 import org.apache.derby.iapi.store.raw.xact.RawTransaction; 32 import org.apache.derby.iapi.store.raw.log.LogInstant; 33 import org.apache.derby.iapi.store.raw.ContainerKey; 34 import org.apache.derby.iapi.error.StandardException; 35 36 import org.apache.derby.iapi.util.ByteArray; 37 38 import java.io.ObjectOutput ; 39 import java.io.ObjectInput ; 40 import java.io.IOException ; 41 import org.apache.derby.iapi.services.io.LimitObjectInput; 42 43 65 public class EncryptContainerOperation implements Undoable 66 { 67 68 private ContainerKey containerId; 69 70 protected EncryptContainerOperation(RawContainerHandle hdl) 71 throws StandardException 72 { 73 containerId = hdl.getId(); 74 } 75 76 79 80 public EncryptContainerOperation() { super(); } 82 83 public void writeExternal(ObjectOutput out) throws IOException 84 { 85 containerId.writeExternal(out); 86 } 87 88 public void readExternal(ObjectInput in) 89 throws IOException , ClassNotFoundException 90 { 91 containerId = ContainerKey.read(in); 92 } 93 94 95 98 99 106 public ByteArray getPreparedLog() 107 { 108 return (ByteArray) null; 109 } 110 111 public void releaseResource(Transaction tran) 112 { 113 } 115 116 119 public int group() 120 { 121 return Loggable.RAWSTORE; 122 } 123 124 125 132 public boolean needsRedo(Transaction xact) 133 throws StandardException 134 { 135 return false; 139 } 140 141 142 145 public int getTypeFormatId() { 146 return StoredFormatIds.LOGOP_ENCRYPT_CONTAINER; 147 } 148 149 150 158 public final void doMe(Transaction tran, LogInstant instant, 159 LimitObjectInput in) 160 throws StandardException 161 { 162 163 168 releaseResource(tran); 169 } 170 171 172 179 public void undoMe(Transaction tran) throws StandardException 180 { 181 BaseDataFileFactory bdff = 183 (BaseDataFileFactory) ((RawTransaction) tran).getDataFactory(); 184 EncryptData ed = new EncryptData(bdff); 185 ed.restoreContainer(containerId); 186 releaseResource(tran); 187 188 } 189 190 198 public Compensation generateUndo(Transaction tran, LimitObjectInput in) 199 throws StandardException 200 { 201 return new EncryptContainerUndoOperation(this); 202 } 203 204 205 public String toString() 206 { 207 if (SanityManager.DEBUG) 208 { 209 return "Encrypt container " + containerId; 210 } 211 212 return null; 213 } 214 } 215 | Popular Tags |