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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
package com.thomsonreuters.upa.valueadd.examples.consumer;

import com.thomsonreuters.upa.valueadd.examples.common.CommandLineParser;
import com.thomsonreuters.upa.valueadd.examples.common.ConnectionArg;
import com.thomsonreuters.upa.valueadd.examples.common.ConnectionArgsParser;

import java.util.List;

/**
 * Command line parser for the Value Add consumer application.
 */
class ConsumerCmdLineParser implements CommandLineParser
{
	private ConnectionArgsParser connectionArgsParser = new ConnectionArgsParser();
	private String backupHostname;
	private String backupPort;
	private String userName;
	private String passwd;
	private String userName2;
	private String passwd2;
	private String clientId;
	private boolean enableView;
	private boolean enablePost;
	private boolean enableOffpost;
	private boolean enableSnapshot;
	private String publisherId;
	private String publisherAddress;
	private int runtime = 600; // default runtime is 600 seconds
	private boolean enableXmlTracing;
	private boolean enableEncrypted;
	private boolean enableHttp;
	private boolean enableProxy;
	private boolean enableSessionMgnt;
	private String proxyHostname;
	private String proxyPort;
	private String proxyUsername = "";
	private String proxyPasswd = "";
	private String proxyDomain = "";
	private String krbFile = "";
	private String keystoreFile;
	private String keystorePasswd;
	private boolean cacheOption;
	private int cacheInterval;
	private int statisticInterval;
	//APIQA
	private String statisticFilter;
	//END APIQA
	private String authenticationToken;
	private String authenticationExtended;
	private String applicationId;
	
	@Override
	public boolean parseArgs(String[] args)
	{
	    try
	    {
    		int argsCount = 0;
    		
    		while (argsCount < args.length)
    		{
    			if (connectionArgsParser.isStart(args, argsCount))
    			{
    				if ("-segmentedMulticast".equals(args[argsCount]))
    				{
    					// consumer does not currently handle multicast
    					return false;
    				}
    
    				if ((argsCount = connectionArgsParser.parse(args, argsCount)) < 0)
    				{
    					// error
    					System.out.println("\nError parsing connection arguments...\n");
    					return false;
    				}
    			}
    			else if ("-bc".equals(args[argsCount]))
    			{
    				if (args[argsCount+1].contains(":"))
    				{
    					String[] tokens = args[++argsCount].split(":");
    					if (tokens.length == 2)
    					{
    						backupHostname = tokens[0];
    						backupPort = tokens[1];
    						++argsCount;
    					}
    					else
    					{
    						// error
    						System.out.println("\nError parsing backup connection arguments...\n");
    						return false;
    					}
    				}
    				else
    				{
    					// error
    					System.out.println("\nError parsing backup connection arguments...\n");
    					return false;
    				}
    			}
    			else if ("-uname".equals(args[argsCount]))
    			{
    				userName = args[++argsCount];
    				++argsCount;
    			}
    			else if ("-passwd".equals(args[argsCount]))
    			{
    				passwd = args[++argsCount];
    				++argsCount;
    			}
    			else if ("-uname2".equals(args[argsCount]))
    			{
    				userName2 = args[++argsCount];
    				++argsCount;
    			}
    			else if ("-passwd2".equals(args[argsCount]))
    			{
    				passwd2 = args[++argsCount];
    				++argsCount;
    			}
    			else if ("-sessionMgnt".equals(args[argsCount]))
    			{
    				enableSessionMgnt = true;
    				++argsCount;	
    			}
    			else if ("-clientId".equals(args[argsCount]))
    			{
    				clientId = args[++argsCount];
    				++argsCount;
    			}
    			else if ("-view".equals(args[argsCount]))
    			{
    				enableView =  true;
    				++argsCount;				
    			}
    			else if ("-post".equals(args[argsCount]))
    			{
    				enablePost =  true;
    				++argsCount;								
    			}
    			else if ("-offpost".equals(args[argsCount]))
    			{
    				enableOffpost =  true;
    				++argsCount;								
    			}
    			else if ("-publisherInfo".equals(args[argsCount]))		
    			{
    				String value = args[++argsCount];
    		        if (value!= null) 
    		        {
    		        	String [] pieces = value.split(",");
    		        		
    		        	if( pieces.length > 1 )
    		            {
    		        		publisherId = pieces[0];
    		            		
    		        		publisherAddress = pieces[1];        		
    		            }  
    		        	else
    		        	{
    		                System.out.println("Error loading command line arguments for publisherInfo [id, address]:\t");  
    		                return false;       		        		        		
    		        	}
    		        }			
    		        ++argsCount;
    			}									
    			else if ("-snapshot".equals(args[argsCount]))
    			{
    				enableSnapshot =  true;
    				++argsCount;								
    			}
    			else if ("-runtime".equals(args[argsCount]))
    			{
    				runtime = Integer.parseInt(args[++argsCount]);
    				++argsCount;				
    			}
    			else if ("-x".equals(args[argsCount]))
    			{
    				enableXmlTracing =  true;
    				++argsCount;								
    			}
    			else if ("-connectionType".equals(args[argsCount]))
    			{
    				// will overwrite connectionArgsParser's connectionList's connectionType based on the flag
    				String connectionType = args[++argsCount];
    				++argsCount;
    				if (connectionType.equals("encrypted"))
    				{
    					enableEncrypted = true;
    				}
    				else if (connectionType.equals("http"))
    				{
    					enableHttp = true;
    				}
    			}
    			else if ("-keyfile".equals(args[argsCount]))
    			{
    				keystoreFile = argsCount < (args.length-1) ? args[++argsCount] : null;
    				++argsCount;				
    			}	
    			else if ("-keypasswd".equals(args[argsCount]))
    			{
    				keystorePasswd = argsCount < (args.length-1) ? args[++argsCount] : null;
    				++argsCount;				
    			}
    			else if ("-proxy".equals(args[argsCount]))
    			{
    				enableProxy =  true;
    				++argsCount;								
    			}
    			else if ("-ph".equals(args[argsCount]))
    			{
    				proxyHostname = args[++argsCount];
    				++argsCount;				
    			}	
    			else if ("-pp".equals(args[argsCount]))
    			{
    				proxyPort = argsCount < (args.length-1) ? args[++argsCount] : null;
    				++argsCount;				
    			}			
    			else if ("-plogin".equals(args[argsCount]))
    			{
    				proxyUsername = args[++argsCount];
    				++argsCount;				
    			}	
    			else if ("-ppasswd".equals(args[argsCount]))
    			{
    				proxyPasswd = argsCount < (args.length-1) ? args[++argsCount] : null;
    				++argsCount;				
    			}			
    			else if ("-pdomain".equals(args[argsCount]))
    			{
    				proxyDomain = argsCount < (args.length-1) ? args[++argsCount] : null;
    				++argsCount;				
    			}	
    			else if ("-krbfile".equals(args[argsCount]))
    			{
    				krbFile = argsCount < (args.length-1) ? args[++argsCount] : null;
    				++argsCount;				
    			}	
    			else if ("-cache".equals(args[argsCount]))
    			{
    				cacheOption =  true;
    				++argsCount;								
    			}
    			else if ("-cacheInterval".equals(args[argsCount]))
    			{
    				cacheInterval = Integer.parseInt(args[++argsCount]);
    				++argsCount;
    			}
    			else if ("-statisticInterval".equals(args[argsCount]))
    			{
    				statisticInterval = Integer.parseInt(args[++argsCount]);
    				++argsCount;
    			}
    			//APIQA
    			else if ("-statisticFilter".equals(args[argsCount]))
    			{
    				statisticFilter = argsCount < (args.length-1) ? args[++argsCount] : null;
    				++argsCount;				
    			}
    			//END APIQA
    			else if ("-at".equals(args[argsCount]))
    			{
    				authenticationToken = args[++argsCount];
    				++argsCount;
    			}
    			else if ("-ax".equals(args[argsCount]))
    			{
    				authenticationExtended = args[++argsCount];
    				++argsCount;
    			}
    			else if ("-aid".equals(args[argsCount]))
    			{
    				applicationId = args[++argsCount];
    				++argsCount;
    			}
    			else // unrecognized command line argument
    			{
    				System.out.println("\nUnrecognized command line argument...\n");
    				return false;
    			}			
    		}
        }
        catch (Exception e)
        {
            System.out.println("\nInvalid command line arguments...");
            return false;
        }
		
		return true;
	}

	String backupHostname()
	{
		return backupHostname;
	}

	String backupPort()
	{
		return backupPort;
	}

	List<ConnectionArg> connectionList()
	{
		return connectionArgsParser.connectionList();
	}

	String userName()
	{
		return userName;
	}
	
	String userName2()
	{
		return userName2;
	}

	boolean enableView()
	{
		return enableView;
	}

	String passwd()
	{
		return passwd;
	}
	
	String passwd2()
	{
		return passwd2;
	}
	
	String clientId()
	{
		return clientId;
	}
	
	boolean enableSessionMgnt()
	{
		return enableSessionMgnt;
	}
	
	boolean enablePost()
	{
		return enablePost;
	}

	boolean enableOffpost()
	{
		return enableOffpost;
	}

    String publisherId()
    {
    	return publisherId;
    }
    
    String publisherAddress()
    {
    	return publisherAddress;
    }
    
	boolean enableSnapshot()
	{
		return enableSnapshot;
	}

	int runtime()
	{
		return runtime;
	}
	
	boolean enableXmlTracing()
	{
		return enableXmlTracing;
	}

	boolean enableEncrypted()
	{
		return enableEncrypted;
	}
	
	boolean enableHttp()
	{
		return enableHttp;
	}

	boolean enableProxy()
	{
		return enableProxy;
	}	
	
	String proxyHostname()
	{
		return proxyHostname;
	}

	String proxyPort()
	{
		return proxyPort;
	}	
	
	String proxyUsername()
	{
		return proxyUsername;
	}

	String proxyPassword()
	{
		return proxyPasswd;
	}	
		
	String proxyDomain()
	{
		return proxyDomain;
	}

	String krbFile()
	{
		return krbFile;
	}	
	
	String keyStoreFile()
	{
		return keystoreFile;
	}

	String keystorePassword()
	{
		return keystorePasswd;
	}	
		
    boolean cacheOption()
	{
		return cacheOption;
	}
	
	int cacheInterval()
	{
		return cacheInterval;
	}
	
	int statisticInterval()
	{
		return statisticInterval;
	}
	String statisticFilter()
	{
		return statisticFilter;
	}
	
	//APIQA
	String authenticationToken()
	{
		return authenticationToken;
	}
	//END APIQA
	String authenticationExtended()
	{
		return authenticationExtended;
	}
	
	String applicationId()
	{
		return applicationId;
	}
	
	@Override
	public void printUsage()
	{
		System.out.println("Usage: Consumer or\nConsumer [-c <hostname>:<port> <service name> <domain>:<item name>,...] [-bc <hostname>:<port>] [-uname <LoginUsername>] [-view] [-post] [-offpost] [-snapshot] [-runtime <seconds>]" +
				"\n -c specifies a connection to open and a list of items to request or use for queue messaging:\n" +
				"\n     hostname:        Hostname of provider to connect to" +
				"\n     port:            Port of provider to connect to" +
				"\n     service:         Name of service to request items from on this connection" +
				"\n     domain:itemName: Domain and name of an item to request" +
				"\n         A comma-separated list of these may be specified." +
				"\n         The domain may be any of: mp(MarketPrice), mbo(MarketByOrder), mbp(MarketByPrice), yc(YieldCurve), sl(SymbolList)" +
				"\n         The domain may also be any of the private stream domains: mpps(MarketPrice PS), mbops(MarketByOrder PS), mbpps(MarketByPrice PS), ycps(YieldCurve PS)" +
				"\n         Example Usage: -c localhost:14002 DIRECT_FEED mp:TRI,mp:GOOG,mpps:FB,mbo:MSFT,mbpps:IBM,sl" +
				"\n           (for SymbolList requests, a name can be optionally specified)\n" +
				"\n     -qSourceName (optional) specifies the source name for queue messages (if specified, configures consumer to receive queue messages)\n" +
                "\n     -qDestName (optional) specifies the destination name for queue messages (if specified, configures consumer to send queue messages to this name, multiple instances may be specified)\n" +
				"\n     -tunnel (optional) enables consumer to open tunnel stream and send basic text messages" +
                "\n     -tsServiceName (optional) specifies the service name for queue messages (if not specified, the service name specified in -c/-tcp is used)\n" +
				"\n     -tsAuth (optional) causes consumer to request authentication when opening a tunnel stream. This applies to both basic tunnel streams and those for queue messaging.\n" +
				"\n     -tsDomain (optional) specifes the domain a consumer uses when opening a tunnel stream. This applies to both basic tunnel streams and those for queue messaging.\n" +
				"\n -bc specifies a backup connection that is attempted if the primary connection fails\n" +
				"\n -uname changes the username used when logging into the provider\n" +
				"\n -passwd changes the password used when logging into the provider\n" +
				//APIQA
				"\n -uname2 changes the username used when logging into the provider\n" +
				"\n -passwd2 changes the password used when logging into the provider\n" +
				//END APIQA
		        "\n -clientId specifies a unique ID for application making the request to EDP token service, also known as AppKey generated using an AppGenerator.\n" +
				"\n -sessionMgnt enables the session management in the Reactor\n" +
				"\n -view specifies each request using a basic dynamic view\n" +
				"\n -post specifies that the application should attempt to send post messages on the first requested Market Price item\n" +
				"\n -offpost specifies that the application should attempt to send post messages on the login stream (i.e., off-stream)\n" +
		        "\n -publisherInfo specifies that the application should add user provided publisher Id and publisher ipaddress when posting\n" +       				
				"\n -snapshot specifies each request using non-streaming\n"  +
		        "\n -connectionType specifies the connection type that the connection should use (possible values are: 'socket', 'http', 'encrypted')\n" +		        
                "\n -proxy specifies that proxy is used for connectionType of http or encrypted\n" + 
		        "\n -ph specifies proxy server host name\n" + 
		        "\n -pp specifies roxy port number\n" +          
		        "\n -plogin specifies user name on proxy server\n" +
		        "\n -ppasswd specifies password on proxy server\n" + 
		        "\n -pdomain specifies proxy server domain\n" + 
		        "\n -krbfile specifies KRB File location and name\n" +
		        "\n -keyfile specifies keystore file location and name\n" + 
		        "\n -keypasswd specifies keystore password\n" +       
		        "\n       Example Usage for proxy with http/encryption:  -proxy -ph hostname1.com -pp 8080 -plogin David.Smith -ppasswd hello1 -pdomain workplace.com\n" +
		        "\n                                                     -krbfile C:\\Kerberos\\krb5.conf -keyfile C:\\Certificates\\cert1.jks -keypasswd keypass1 \n" + 		        
  				"\n -x provides an XML trace of messages\n" +
  				"\n -cache will store all open items in cache and periodically dump contents\n" +
  				"\n -cacheInterval number of seconds between displaying cache contents, must greater than 0\n" +
  				"\n -statisticInterval number of seconds between displaying reactor channel statistics, must greater than 0\n" +
  				"\n -statisticFilter valid value are READ / WRITE / PING\n" +
  				"\n -runtime adjusts the running time of the application" +
				"\n -at Specifies the Authentication Token. If this is present, the login user name type will be Login.UserIdTypes.AUTHN_TOKEN" +
				"\n -ax Specifies the Authentication Extended information" +
				"\n -aid Specifies the Application ID");
	}
}