HCE Project PHP language client API bindings OOP style  1.1.1
Hierarchical Cluster Engine PHP Client Interface API OOP style
 All Classes Namespaces Files Functions Variables Pages
NodeManageResponse.inc.php
Go to the documentation of this file.
1 <?php
2 
14 namespace HCE\admin {
15 
16  require_once 'Constants.inc.php';
17 
25  protected $transportResponse = null;
26 
30  protected $error = 0;
31 
37  public function getResponse() {
38  return $this->transportResponse;
39  }
40 
48  public function setResponse($transportResponse) {
49  $this->transportResponse = $transportResponse;
50  }
51 
59  public function setErrorCode($errorCode) {
60  $this->error = $errorCode;
61  }
62 
68  public function getErrorCode() {
69  return $this->error;
70  }
71 
77  public function getResponseMessageBody($messageItem = 0) {
78  return $this->transportResponse->getResponseItemField ( $messageItem, 'body' );
79  }
80 
86  public function getResponseMessageId($messageItem = 0) {
87  return $this->transportResponse->getResponseItemField ( $messageItem, 'id' );
88  }
89 
95  public function getResponseMessageErrorCode($messageItem = 0) {
96  return $this->transportResponse->getResponseItemField ( $messageItem, 'error' );
97  }
98 
105  public function getResponseCommandFields($messageItem = 0) {
106  $ret = array (
107  NODE_MANAGE_RESPONSE_FIELD_STATUS => ERROR_OK
108  );
109 
110  if ($this->transportResponse->getResponseItemField ( $messageItem, 'error' )) {
111  $ret [NODE_MANAGE_RESPONSE_FIELD_STATUS] = ERROR_ERROR;
112  } else {
113  // Get raw body
114  $body = $this->transportResponse->getResponseItemField ( $messageItem, 'body' );
115  // Parse body
116  $parts = explode ( CMD_RESPONSE_DELIMITER, $body );
117  if ($parts [0] !== ERROR_OK) {
118  $ret [NODE_MANAGE_RESPONSE_FIELD_STATUS] = ERROR_ERROR;
119  } else {
120  $ret [NODE_MANAGE_RESPONSE_FIELD_STATUS] = ERROR_OK;
121  for($i = 1; $i < count ( $parts ); $i ++) {
122  $part = explode ( CMD_RESPONSE_ITEMS_DELIMITER, $parts [$i] );
123  $ret [$part [0]] = $part [1];
124  }
125  }
126  }
127 
128  return $ret;
129  }
130 
134  public function __construct($transportResponse = null) {
135  // Init transport respose
136  if ($transportResponse === null) {
137  $this->transportResponse = new \HCE\transport\Response ();
138  }
139  }
140 
144  public function __destruct() {
145  $this->transportResponse = NULL;
146  }
147  }
148 }
149 
150 ?>