1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.bitrepository.access.getfile.conversation;
26
27 import org.bitrepository.access.getfile.selectors.FastestPillarSelectorForGetFile;
28 import org.bitrepository.bitrepositorymessages.IdentifyPillarsForGetFileRequest;
29 import org.bitrepository.client.conversation.ConversationContext;
30 import org.bitrepository.client.conversation.GeneralConversationState;
31 import org.bitrepository.client.conversation.IdentifyingState;
32 import org.bitrepository.client.conversation.selector.SelectedComponentInfo;
33
34
35
36
37
38 public class IdentifyingPillarsForGetFile extends IdentifyingState {
39 private final GetFileConversationContext context;
40
41
42
43
44
45 public IdentifyingPillarsForGetFile(GetFileConversationContext context) {
46 super(context.getContributors());
47 this.context = context;
48 context.getMonitor().markAsFailedOnContributorFailure(false);
49 if (context.getContributors().size() > 1) {
50 setSelector(new FastestPillarSelectorForGetFile());
51 }
52 }
53
54 @Override
55 public GeneralConversationState getOperationState() {
56 return new GettingFile(context, getSelectedPillar());
57
58 }
59
60 @Override
61 protected void sendRequest() {
62 IdentifyPillarsForGetFileRequest msg = new IdentifyPillarsForGetFileRequest();
63 initializeMessage(msg);
64 msg.setDestination(context.getSettings().getCollectionDestination());
65 msg.setFileID(context.getFileID());
66 context.getMessageSender().sendMessage(msg);
67 context.getMonitor().identifyRequestSent("Identifying pillars for GetFile");
68
69 }
70
71 @Override
72 protected ConversationContext getContext() {
73 return context;
74 }
75
76 @Override
77 protected String getPrimitiveName() {
78 return "IdentifyPillarsForGetFile";
79 }
80
81
82
83
84 private SelectedComponentInfo getSelectedPillar() {
85 return getSelector().getSelectedComponents().iterator().next();
86 }
87 }