use of org.openhab.binding.ihc.ws.datatypes.WSProjectInfo in project openhab1-addons by openhab.
the class IhcClient method LoadProjectFileFromController.
private Document LoadProjectFileFromController() throws IhcExecption {
try {
WSProjectInfo projectInfo = getProjectInfo();
int numberOfSegments = controllerService.getProjectNumberOfSegments();
int segmentationSize = controllerService.getProjectSegmentationSize();
logger.debug("Number of segments: {}", numberOfSegments);
logger.debug("Segmentation size: {}", segmentationSize);
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
for (int i = 0; i < numberOfSegments; i++) {
logger.debug("Downloading segment {}", i);
WSFile data = controllerService.getProjectSegment(i, projectInfo.getProjectMajorRevision(), projectInfo.getProjectMinorRevision());
byteStream.write(data.getData());
}
logger.debug("File size before base64 encoding: {} bytes", byteStream.size());
byte[] decodedBytes = javax.xml.bind.DatatypeConverter.parseBase64Binary(byteStream.toString());
logger.debug("File size after base64 encoding: {} bytes", decodedBytes.length);
GZIPInputStream gzis = new GZIPInputStream(new ByteArrayInputStream(decodedBytes));
InputStreamReader in = new InputStreamReader(gzis, "ISO-8859-1");
InputSource reader = new InputSource(in);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
return db.parse(reader);
} catch (Exception e) {
throw new IhcExecption(e);
}
}
use of org.openhab.binding.ihc.ws.datatypes.WSProjectInfo in project openhab1-addons by openhab.
the class IhcControllerService method getProjectInfo.
/**
* Query project information from the controller.
*
* @return project information.
* @throws IhcExecption
*/
public synchronized WSProjectInfo getProjectInfo() throws IhcExecption {
openConnection(url);
setRequestProperty("SOAPAction", "getProjectInfo");
String response = sendQuery(emptyQuery, timeout);
closeConnection();
WSProjectInfo projectInfo = new WSProjectInfo();
projectInfo.encodeData(response);
return projectInfo;
}
Aggregations