use of org.apache.jackrabbit.webdav.property.DavPropertyIterator in project lobcder by skoulouzis.
the class Utils method getResourceUID.
Long getResourceUID(String resource) throws IOException, DavException {
DavPropertyName etag = DavPropertyName.create("getetag", Namespace.getNamespace("DAV:"));
MultiStatus multiStatus = getProperty(resource, etag, true);
MultiStatusResponse[] responses = multiStatus.getResponses();
String value = null;
// for (MultiStatusResponse r : responses) {
DavPropertySet allProp = getProperties(responses[0]);
DavPropertyIterator iter = allProp.iterator();
while (iter.hasNext()) {
DavProperty<?> p = iter.nextProperty();
assertNotNull(p.getValue());
assertEquals(p.getName(), etag);
value = (String) p.getValue();
value = value.replaceAll("\"", "");
break;
}
return Long.valueOf(value.split("_")[0]);
}
use of org.apache.jackrabbit.webdav.property.DavPropertyIterator in project lobcder by skoulouzis.
the class Utils method getAvailableStorageSites.
public String[] getAvailableStorageSites(String testuri1) throws IOException, DavException {
DavPropertyNameSet availableStorageSitesNameSet = new DavPropertyNameSet();
DavPropertyName availableStorageSitesName = DavPropertyName.create("avail-storage-sites", Namespace.getNamespace("custom:"));
availableStorageSitesNameSet.add(availableStorageSitesName);
PropFindMethod propFind = new PropFindMethod(testuri1, availableStorageSitesNameSet, DavConstants.DEPTH_INFINITY);
int status = client.executeMethod(propFind);
assertEquals(HttpStatus.SC_MULTI_STATUS, status);
MultiStatus multiStatus = propFind.getResponseBodyAsMultiStatus();
MultiStatusResponse[] responses = multiStatus.getResponses();
String value = null;
for (MultiStatusResponse r : responses) {
DavPropertySet allProp = getProperties(r);
DavPropertyIterator iter = allProp.iterator();
while (iter.hasNext()) {
DavProperty<?> p = iter.nextProperty();
assertEquals(p.getName(), availableStorageSitesName);
assertNotNull(p.getValue());
value = (String) p.getValue();
}
}
String sites = value.replaceAll("[\\[\\]]", "");
return sites.split(",");
}
use of org.apache.jackrabbit.webdav.property.DavPropertyIterator in project lobcder by skoulouzis.
the class Utils method resourceExists.
boolean resourceExists(String resource) throws IOException, DavException {
try {
MultiStatus multiStatus = this.getProperty(resource, DavPropertyName.DISPLAYNAME, false);
MultiStatusResponse[] responses = multiStatus.getResponses();
String value = null;
// for (MultiStatusResponse r : responses) {
DavPropertySet allProp = getProperties(responses[0]);
DavPropertyIterator iter = allProp.iterator();
while (iter.hasNext()) {
DavProperty<?> p = iter.nextProperty();
assertNotNull(p.getValue());
value = (String) p.getValue();
System.err.println(p.getName() + ":" + p.getValue());
break;
}
if (value != null) {
return true;
} else {
return false;
}
} catch (DavException ex) {
if (ex.getMessage().contains("Not Found")) {
return false;
} else {
throw ex;
}
}
}
use of org.apache.jackrabbit.webdav.property.DavPropertyIterator in project lobcder by skoulouzis.
the class Utils method waitForReplication.
public void waitForReplication(String resource) throws IOException, DavException, InterruptedException {
boolean done = false;
int count = 0;
String[] availStorageSites = getAvailableStorageSites(resource);
while (!done) {
DavPropertyName dataDistributionName = DavPropertyName.create("data-distribution", Namespace.getNamespace("custom:"));
MultiStatus multiStatus = getProperty(resource, dataDistributionName, true);
MultiStatusResponse[] responses = multiStatus.getResponses();
String dataDist = null;
for (MultiStatusResponse r : responses) {
// System.out.println("Response: " + r.getHref());
DavPropertySet allProp = getProperties(r);
DavPropertyIterator iter = allProp.iterator();
while (iter.hasNext()) {
DavProperty<?> p = iter.nextProperty();
assertEquals(p.getName(), dataDistributionName);
assertNotNull(p.getValue());
dataDist = (String) p.getValue();
if (dataDist.contains(availStorageSites[0])) {
done = true;
assertTrue(dataDist.contains(availStorageSites[0]));
break;
} else if (availStorageSites.length > 1 && dataDist.contains(availStorageSites[1])) {
done = true;
assertTrue(dataDist.contains(availStorageSites[1]));
break;
} else {
count++;
}
// System.out.println(p.getName() + " : " + p.getValue());
}
}
if (count > 200) {
fail(resource + " is not replicated in " + availStorageSites[0] + " or " + availStorageSites[1] + " it is in " + dataDist);
break;
}
if (done) {
break;
} else {
Thread.sleep(7000);
}
}
}
Aggregations