use of org.apache.jackrabbit.webdav.client.methods.DeleteMethod in project lobcder by skoulouzis.
the class WebDAVTest method testGetSetDRICheckSumProp.
@Test
public void testGetSetDRICheckSumProp() throws UnsupportedEncodingException, IOException, DavException {
System.out.println("testGetSetDRICheckSumProp");
String testcol1 = root + "testResourceForGetSetDRICheckSumProp/";
String testuri1 = testcol1 + "file1";
String testuri2 = testcol1 + "file2";
String testuri3 = testcol1 + "file3";
String testcol2 = testcol1 + "folder4/";
String testuri4 = testcol2 + "file5";
try {
DeleteMethod delete = new DeleteMethod(testcol1);
int status = client.executeMethod(delete);
MkColMethod mkcol = new MkColMethod(testcol1);
status = client.executeMethod(mkcol);
assertEquals(HttpStatus.SC_CREATED, status);
PutMethod put = new PutMethod(testuri1);
put.setRequestEntity(new StringRequestEntity("foo", "text/plain", "UTF-8"));
status = client.executeMethod(put);
assertEquals(HttpStatus.SC_CREATED, status);
put = new PutMethod(testuri2);
put.setRequestEntity(new StringRequestEntity("dar", "text/plain", "UTF-8"));
status = client.executeMethod(put);
assertEquals(HttpStatus.SC_CREATED, status);
put = new PutMethod(testuri3);
put.setRequestEntity(new StringRequestEntity("foo", "text/plain", "UTF-8"));
status = client.executeMethod(put);
assertEquals(HttpStatus.SC_CREATED, status);
mkcol = new MkColMethod(testcol2);
status = client.executeMethod(mkcol);
assertEquals(HttpStatus.SC_CREATED, status);
put = new PutMethod(testuri4);
put.setRequestEntity(new StringRequestEntity(TestSettings.TEST_DATA, "text/plain", "UTF-8"));
status = client.executeMethod(put);
assertEquals(HttpStatus.SC_CREATED, status);
DavPropertyNameSet driSupervisedNameSet = new DavPropertyNameSet();
DavPropertyName driChecksumName = DavPropertyName.create("dri-checksum-MD5", Namespace.getNamespace("custom:"));
driSupervisedNameSet.add(driChecksumName);
PropFindMethod propFind = new PropFindMethod(testcol1, driSupervisedNameSet, DavConstants.DEPTH_INFINITY);
status = client.executeMethod(propFind);
assertEquals(HttpStatus.SC_MULTI_STATUS, status);
MultiStatus multiStatus = propFind.getResponseBodyAsMultiStatus();
MultiStatusResponse[] responses = multiStatus.getResponses();
for (MultiStatusResponse r : responses) {
// System.out.println("Response: " + r.getHref());
DavPropertySet allProp = utils.getProperties(r);
DavPropertyIterator iter = allProp.iterator();
while (iter.hasNext()) {
DavProperty<?> p = iter.nextProperty();
assertEquals(p.getName(), driChecksumName);
}
}
DavPropertySet driSuper = new DavPropertySet();
Long checksum = Long.valueOf(10000);
DavProperty<Long> driProp = new DefaultDavProperty<Long>(driChecksumName, checksum);
driSuper.add(driProp);
PropPatchMethod proPatch = new PropPatchMethod(testcol1, driSuper, driSupervisedNameSet);
status = client.executeMethod(proPatch);
assertEquals(HttpStatus.SC_MULTI_STATUS, status);
propFind = new PropFindMethod(testcol1, driSupervisedNameSet, DavConstants.DEPTH_INFINITY);
status = client.executeMethod(propFind);
assertEquals(HttpStatus.SC_MULTI_STATUS, status);
multiStatus = propFind.getResponseBodyAsMultiStatus();
responses = multiStatus.getResponses();
for (MultiStatusResponse r : responses) {
DavPropertySet allProp = utils.getProperties(r);
DavPropertyIterator iter = allProp.iterator();
while (iter.hasNext()) {
DavProperty<?> p = iter.nextProperty();
assertEquals(p.getName(), driChecksumName);
// assertNotNull(p.getValue());
if (new URL(testcol1).getPath().equals(r.getHref())) {
Long val = Long.valueOf(p.getValue().toString());
assertEquals(checksum, val);
}
}
}
} finally {
utils.deleteResource(testcol1, true);
}
}
use of org.apache.jackrabbit.webdav.client.methods.DeleteMethod in project lobcder by skoulouzis.
the class WebDAVTest method testGetSetDriLastValidationdateProp.
@Test
public void testGetSetDriLastValidationdateProp() throws UnsupportedEncodingException, IOException, DavException {
System.out.println("testGetSetDriLastValidationdateProp");
String testcol1 = root + "testResourceForGetSetDriLastValidationdateProp/";
String testuri1 = testcol1 + "file1";
String testuri2 = testcol1 + "file2";
String testuri3 = testcol1 + "file3";
String testcol2 = testcol1 + "folder4/";
String testuri4 = testcol2 + "file5";
try {
DeleteMethod delete = new DeleteMethod(testcol1);
int status = client.executeMethod(delete);
MkColMethod mkcol = new MkColMethod(testcol1);
status = client.executeMethod(mkcol);
assertEquals(HttpStatus.SC_CREATED, status);
PutMethod put = new PutMethod(testuri1);
put.setRequestEntity(new StringRequestEntity("foo", "text/plain", "UTF-8"));
status = client.executeMethod(put);
assertEquals(HttpStatus.SC_CREATED, status);
put = new PutMethod(testuri2);
put.setRequestEntity(new StringRequestEntity("dar", "text/plain", "UTF-8"));
status = client.executeMethod(put);
assertEquals(HttpStatus.SC_CREATED, status);
put = new PutMethod(testuri3);
put.setRequestEntity(new StringRequestEntity("foo", "text/plain", "UTF-8"));
status = client.executeMethod(put);
assertEquals(HttpStatus.SC_CREATED, status);
mkcol = new MkColMethod(testcol2);
status = client.executeMethod(mkcol);
assertEquals(HttpStatus.SC_CREATED, status);
put = new PutMethod(testuri4);
put.setRequestEntity(new StringRequestEntity(TestSettings.TEST_DATA, "text/plain", "UTF-8"));
status = client.executeMethod(put);
assertEquals(HttpStatus.SC_CREATED, status);
DavPropertyNameSet driSupervisedNameSet = new DavPropertyNameSet();
DavPropertyName driLastValidationName = DavPropertyName.create("dri-last-validation-date-ms", Namespace.getNamespace("custom:"));
driSupervisedNameSet.add(driLastValidationName);
PropFindMethod propFind = new PropFindMethod(testcol1, driSupervisedNameSet, DavConstants.DEPTH_INFINITY);
status = client.executeMethod(propFind);
assertEquals(HttpStatus.SC_MULTI_STATUS, status);
MultiStatus multiStatus = propFind.getResponseBodyAsMultiStatus();
MultiStatusResponse[] responses = multiStatus.getResponses();
for (MultiStatusResponse r : responses) {
// System.out.println("Response: " + r.getHref());
DavPropertySet allProp = utils.getProperties(r);
DavPropertyIterator iter = allProp.iterator();
while (iter.hasNext()) {
DavProperty<?> p = iter.nextProperty();
// System.out.println(p.getName() + " : " + p.getValue());
assertEquals(p.getName(), driLastValidationName);
}
}
DavPropertySet driSuper = new DavPropertySet();
Long date = System.currentTimeMillis();
DavProperty<Long> driProp = new DefaultDavProperty<Long>(driLastValidationName, date);
driSuper.add(driProp);
PropPatchMethod proPatch = new PropPatchMethod(testcol1, driSuper, driSupervisedNameSet);
status = client.executeMethod(proPatch);
assertEquals(HttpStatus.SC_MULTI_STATUS, status);
propFind = new PropFindMethod(testcol1, driSupervisedNameSet, DavConstants.DEPTH_INFINITY);
status = client.executeMethod(propFind);
assertEquals(HttpStatus.SC_MULTI_STATUS, status);
multiStatus = propFind.getResponseBodyAsMultiStatus();
responses = multiStatus.getResponses();
for (MultiStatusResponse r : responses) {
// System.out.println("Response: " + r.getHref());
DavPropertySet allProp = utils.getProperties(r);
DavPropertyIterator iter = allProp.iterator();
while (iter.hasNext()) {
DavProperty<?> p = iter.nextProperty();
assertEquals(p.getName(), driLastValidationName);
// System.out.println(p.getName() + " : " + p.getValue());
assertNotNull(p.getValue());
if (new URL(testcol1).getPath().equals(r.getHref())) {
Long val = Long.valueOf(p.getValue().toString());
assertEquals(date, val);
}
}
}
} finally {
utils.deleteResource(testcol1, true);
}
}
Aggregations