1 package org.bitrepository.commandline.eventhandler;
2
3 import org.bitrepository.client.eventhandler.OperationEvent;
4 import org.bitrepository.commandline.output.OutputHandler;
5 import org.bitrepository.common.settings.Settings;
6 import org.bitrepository.common.utils.Base16Utils;
7 import org.bitrepository.modify.replacefile.conversation.ReplaceFileCompletePillarEvent;
8
9
10
11
12
13 public class ReplaceFileEventHandler extends CompleteEventAwaiter {
14
15
16
17
18
19
20 public ReplaceFileEventHandler(Settings settings, OutputHandler outputHandler) {
21 super(settings, outputHandler);
22 }
23
24 @Override
25 public void handleComponentComplete(OperationEvent event) {
26 if(!(event instanceof ReplaceFileCompletePillarEvent)) {
27 output.warn("ReplaceFileEventHandler received a component complete, which is not a "
28 + ReplaceFileCompletePillarEvent.class.getName());
29 }
30
31 ReplaceFileCompletePillarEvent pillarEvent = (ReplaceFileCompletePillarEvent) event;
32 StringBuilder componentText = new StringBuilder();
33 if(pillarEvent.getChecksumForReplacedFile() != null) {
34 componentText.append("Checksum for replaced file: "
35 + Base16Utils.decodeBase16(pillarEvent.getChecksumForReplacedFile().getChecksumValue()) + "\t");
36 }
37
38 if(pillarEvent.getChecksumForNewFile() != null) {
39 componentText.append("Checksum for new file: "
40 + Base16Utils.decodeBase16(pillarEvent.getChecksumForNewFile().getChecksumValue()) + "\t");
41 }
42
43 if(componentText.length() != 0) {
44 output.resultLine(pillarEvent.getContributorID() + " : \t" + componentText.toString());
45 }
46 }
47 }