use of net.sourceforge.processdash.tool.bridge.ResourceListing in project processdash by dtuma.
the class XmlCollectionListing method parseListing.
public static ResourceCollectionInfo parseListing(InputStream in) throws IOException {
try {
Element data = XMLUtils.parse(in).getDocumentElement();
ResourceListing result = new ResourceListing();
NodeList resourceElems = data.getElementsByTagName(RESOURCE_TAG);
if (resourceElems != null) {
for (int i = 0; i < resourceElems.getLength(); i++) {
Element res = (Element) resourceElems.item(i);
String name = res.getAttribute(NAME_ATTR);
long mod = Long.parseLong(res.getAttribute(MOD_TIME_ATTR));
long sum = Long.parseLong(res.getAttribute(CHECKSUM_ATTR));
result.addResource(name, mod, sum);
}
}
return result;
} catch (Exception e) {
IOException ioe = new IOException("Unable to parse collection listing");
ioe.initCause(e);
throw ioe;
}
}
use of net.sourceforge.processdash.tool.bridge.ResourceListing in project processdash by dtuma.
the class ResourceBridgeClient method getDiff.
private ResourceCollectionDiff getDiff() throws IOException {
// start by initiating the HTTP connection to the server
URLConnection conn = makeGetRequest(LIST_ACTION);
conn.connect();
// now, while the server is thinking, do our calculations locally.
localCollection.validate();
ResourceCollectionInfo localList = new ResourceListing(localCollection, ResourceFilterFactory.DEFAULT_FILTER);
// finally, retrieve the list from the server and compare the two.
serverVersion = conn.getHeaderField(VERSION_HEADER);
ResourceCollectionInfo remoteList = XmlCollectionListing.parseListing(new BufferedInputStream(conn.getInputStream()));
return new ResourceCollectionDiff(localList, remoteList);
}
use of net.sourceforge.processdash.tool.bridge.ResourceListing in project processdash by dtuma.
the class BridgedWorkingDirectory method syncTimestampIsRecent.
private boolean syncTimestampIsRecent() {
try {
String timestamp = getMetadata(SYNC_TIMESTAMP);
if (timestamp == null)
return false;
ResourceFilter filter = ResourceFilterFactory.getForRequest(Collections.singletonMap(ResourceFilterFactory.LAST_MOD_PARAM, timestamp));
ResourceCollectionInfo changedFiles = new ResourceListing(client.localCollection, filter);
return changedFiles.listResourceNames().isEmpty();
} catch (Exception e) {
return false;
}
}
Aggregations