Revision ffd154e6

b/src/com/rackspace/cloud/loadbalancer/api/client/Node.java
11 11
	private String condition;
12 12
	private String status;
13 13
	private String weight;
14
	private Boolean isExternalNode;
14 15
	
15 16
	public String getId() {
16 17
		return id;
......
64 65
		return serialVersionUID;
65 66
	}
66 67
	
68
	public boolean isExternalNode(){
69
		return isExternalNode;
70
	}
71
	
72
	public void setIsExternalNode(boolean external){
73
		isExternalNode = external;
74
	}
75
	
67 76
}
b/src/com/rackspacecloud/android/AddMoreNodesActivity.java
490 490
		return "";
491 491
	}
492 492

  
493
	private boolean isCloudServerIp(String address){
493
	private boolean ipInList(String address){
494 494
		for(Server s : possibleNodes){
495 495
			if(serverHasIp(s, address)){
496 496
				return true;
......
573 573
			 * If the ip is from a cloud server, alert to user
574 574
			 * so they can select it from there
575 575
			 */	
576
			if(!isCloudServerIp(node.getAddress())){
576
			if(!ipInList(node.getAddress())){
577 577

  
578 578
				if(positionOfNode >= 0){
579 579
					nodesToAdd.remove(positionOfNode);
......
588 588
				possibleNodes.add(server);
589 589
				setServerList(possibleNodes);
590 590
			} else {
591
				showAlert("Error", "This IP belongs to a cloud server: \"" + getNameFromIp(node.getAddress()) 
592
						+ "\", please select it from the list.");
591
				String name = getNameFromIp(node.getAddress());
592
				if(name.equals("External Node")){
593
					showAlert("Error", "This IP has already been added as an external node, please edit" +
594
					"it from the list.");
595
				} else {
596
					showAlert("Error", "This IP belongs to a cloud server: \"" + getNameFromIp(node.getAddress()) 
597
							+ "\", please edit it from the list.");
598
				}
593 599
			}
594 600
		}
595 601
		printTheNodes();
b/src/com/rackspacecloud/android/AddNodesActivity.java
68 68
				nodes = new ArrayList<Node>();
69 69
			}
70 70
		}
71
		
71

  
72 72
		if (state != null && state.containsKey("lastCheckedPos")){
73 73
			lastCheckedPos = (Integer) state.getSerializable("lastCheckedPos");
74 74
		}
75
		
75

  
76 76
		if (state != null && state.containsKey("positionOfNode")){
77 77
			positionOfNode = (Integer) state.getSerializable("positionOfNode");
78 78
		}
......
146 146
					String[] ipAddresses = getAllIpsOfServer(server);
147 147

  
148 148
					Node node = getNodeFromServer(server);
149
					
149

  
150 150
					positionOfNode = findNodePosition(node);
151 151
					lastCheckedPos = position;
152
					
152

  
153 153
					Intent viewIntent = new Intent(getContext(), AddNodeActivity.class);
154 154
					viewIntent.putExtra("ipAddresses", ipAddresses);
155 155
					viewIntent.putExtra("name", server.getName());
......
162 162
					startActivityForResult(viewIntent, ADD_NODE_CODE);
163 163
				}
164 164
			} else {
165
			//When clicked on an external node
166
			Server server = possibleNodes.get(position);
167
			Node node = getNodeFromServer(server);
168
			positionOfNode = findNodePosition(node);
169
			lastCheckedPos = position;
170
			Intent viewIntent = new Intent(getContext(), AddExternalNodeActivity.class);
171
			if(node != null){
172
				viewIntent.putExtra("node", node);
173
			}
174
			//weighted is false, because on initial node add
175
			//weight is not option
176
			viewIntent.putExtra("weighted", false);
177
			startActivityForResult(viewIntent, ADD_EXTERNAL_NODE_CODE);
165
				//When clicked on an external node
166
				Server server = possibleNodes.get(position);
167
				Node node = getNodeFromServer(server);
168
				positionOfNode = findNodePosition(node);
169
				lastCheckedPos = position;
170
				Intent viewIntent = new Intent(getContext(), AddExternalNodeActivity.class);
171
				if(node != null){
172
					viewIntent.putExtra("node", node);
173
				}
174
				//weighted is false, because on initial node add
175
				//weight is not option
176
				viewIntent.putExtra("weighted", false);
177
				startActivityForResult(viewIntent, ADD_EXTERNAL_NODE_CODE);
178 178
			}
179 179
		}
180 180
	}
181
	
181

  
182 182
	//return the location of node in nodes
183 183
	//if it is no in there then -1
184 184
	private int findNodePosition(Node node){
......
327 327

  
328 328
	//returns true if address is an address of
329 329
	//one of the users cloud servers
330
	private boolean isCloudServerIp(String address){
330
	private boolean ipInList(String address){
331 331
		for(Server s : possibleNodes){
332
			if(serverHasIp(s, address)){
332
			if(serverHasIp(s, address) && !s.getName().equals("External Node")){
333 333
				return true;
334 334
			}
335 335
		}
......
430 430

  
431 431
	//removes a node with ip of address from nodes
432 432
	//if one doesnt exists doesn nothing
433
	/*private void removeNodeWithIp(String address){
433
	private void removeNodeWithIp(String address){
434 434
		for(int i = 0; i < nodes.size(); i++){
435 435
			Node n = nodes.get(i);
436 436
			if(n.getAddress().equals(address)){
......
438 438
				break;
439 439
			}
440 440
		}
441
	}*/
441
	}
442 442

  
443 443
	protected void onActivityResult(int requestCode, int resultCode, Intent data){	
444 444
		int pos = lastCheckedPos;
......
454 454
				if(positionOfNode >= 0){
455 455
					nodes.remove(positionOfNode);
456 456
				}
457
				
457

  
458 458
				Node node = new Node();
459 459
				node.setAddress(data.getStringExtra("nodeIp"));
460 460
				node.setCondition(data.getStringExtra("nodeCondition"));
......
488 488
			 * If the ip is from a cloud server, alert to user
489 489
			 * so they can select it from there
490 490
			 */	
491
			if(!isCloudServerIp(node.getAddress())){
492
				
491
			if(!ipInList(node.getAddress())){
492

  
493 493
				if(positionOfNode >= 0){
494 494
					nodes.remove(positionOfNode);
495 495
				}
496
				
496

  
497 497
				nodes.add(node);
498 498
				//Add it to server list so it display in the listview
499 499
				Server server = new Server();
......
503 503
				possibleNodes.add(server);
504 504
				setServerList(possibleNodes);
505 505
			} else {
506
				showAlert("Error", "This IP belongs to a cloud server: \"" + getNameFromIp(node.getAddress()) 
507
						+ "\", please select it from the list.");
506
				String name = getNameFromIp(node.getAddress());
507
				if(name.equals("External Node")){
508
					showAlert("Error", "This IP has already been added as an external node, please edit" +
509
					"it from the list.");
510
				} else {
511
					showAlert("Error", "This IP belongs to a cloud server: \"" + getNameFromIp(node.getAddress()) 
512
							+ "\", please edit it from the list.");
513
				}
508 514
			}
509 515
		}
510 516
		printTheNodes();

Also available in: Unified diff