* org.apache.hadoop.hbase.rest.parser.IHBaseRestParser#getRowUpdateDescriptor
* (byte[], byte[][])
*/
public RowUpdateDescriptor getRowUpdateDescriptor(byte[] input,
byte[][] pathSegments) throws HBaseRestException {
RowUpdateDescriptor rud = new RowUpdateDescriptor();
rud.setTableName(Bytes.toString(pathSegments[0]));
rud.setRowName(Bytes.toString(pathSegments[2]));
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
.newInstance();
docBuilderFactory.setIgnoringComments(true);
DocumentBuilder builder = null;
Document doc = null;
try {
builder = docBuilderFactory.newDocumentBuilder();
ByteArrayInputStream is = new ByteArrayInputStream(input);
doc = builder.parse(is);
} catch (Exception e) {
throw new HBaseRestException(e.getMessage(), e);
}
NodeList cell_nodes = doc.getElementsByTagName(RESTConstants.COLUMN);
System.out.println("cell_nodes.length: " + cell_nodes.getLength());
for (int i = 0; i < cell_nodes.getLength(); i++) {
String columnName = null;
byte[] value = null;
Element cell = (Element) cell_nodes.item(i);
NodeList item = cell.getElementsByTagName(RESTConstants.NAME);
if (item.getLength() > 0) {
columnName = item.item(0).getFirstChild().getNodeValue();
}
NodeList item1 = cell.getElementsByTagName(RESTConstants.VALUE);
if (item1.getLength() > 0) {
value = org.apache.hadoop.hbase.util.Base64.decode(item1
.item(0).getFirstChild().getNodeValue());
}
if (columnName != null && value != null) {
rud.getColVals().put(columnName.getBytes(), value);
}
}
return rud;
}