use of io.milton.http.LockInfo in project lobcder by skoulouzis.
the class WebDataResource method getCurrentLock.
@Override
public LockToken getCurrentLock() {
if (getLogicalData().getLockTokenID() == null) {
return null;
} else {
LockInfo lockInfo = new LockInfo(LockInfo.LockScope.valueOf(getLogicalData().getLockScope()), LockInfo.LockType.valueOf(getLogicalData().getLockType()), getLogicalData().getLockedByUser(), LockInfo.LockDepth.valueOf(getLogicalData().getLockDepth()));
LockTimeout lockTimeOut = new LockTimeout(getLogicalData().getLockTimeout());
return new LockToken(getLogicalData().getLockTokenID(), lockInfo, lockTimeOut);
}
}
use of io.milton.http.LockInfo in project lobcder by skoulouzis.
the class ItemBean method main.
// / test
public static void main(String[] args) {
try {
DatatypeFactory df = DatatypeFactory.newInstance();
GregorianCalendar gregorianCalendar = new GregorianCalendar();
ItemBean ldb = new ItemBean();
ldb.setUid(123L);
ldb.setCreateDate(df.newXMLGregorianCalendar(gregorianCalendar));
ldb.setType(Type.FILE);
ldb.setName("Name");
ldb.setParentRef(45L);
Permissions p = new Permissions();
p.setOwner("Dima");
p.getRead().add("group_read1");
p.getRead().add("group_read2");
p.getWrite().add("group_write1");
ldb.setPermissions(p);
ldb.setParentRef(46L);
ldb.addContentType("application/xml");
ldb.setPath("/qwa/qwe");
List<PDRIDescr> pris = new ArrayList<>();
// pdril.getPdriList().add(new PdriBean("name", "url", "username", "password", false, null, false));
// pdril.getPdriList().add(new PdriBean("name2","url", "username", "password", false, null, false));
// ldb.setPdriList(pdril);
LockInfo lockInfo = new LockInfo(LockInfo.LockScope.EXCLUSIVE, LockInfo.LockType.WRITE, "user", LockInfo.LockDepth.INFINITY);
// LockTokenBean lockToken = new LockTokenBean();
// lockToken.setLocktoken("token-name");
// lockToken.setLockInfo(lockInfo);
// lockToken.setLockedUntil(df.newXMLGregorianCalendar(gregorianCalendar));
// ldb.setLock(lockToken);
DriBean dri = new DriBean();
dri.setStatus(DriBean.Status.unavailable);
ldb.setDri(dri);
JAXBContext context = JAXBContext.newInstance(ItemBean.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m.marshal(ldb, System.err);
} catch (Exception e) {
e.printStackTrace();
}
}
use of io.milton.http.LockInfo in project lobcder by skoulouzis.
the class MemoryLockManagerTest method testLockUnLock.
public void testLockUnLock() throws NotAuthorizedException {
LockTimeout timeout = new LockTimeout(100l);
LockInfo lockInfo = new LockInfo(LockInfo.LockScope.NONE, LockInfo.LockType.READ, "me", LockInfo.LockDepth.ZERO);
SimpleFileContentService contentService = new SimpleFileContentService();
FsResource resource = new FsFileResource(null, null, new File(File.pathSeparator), contentService);
// lock it
LockResult res = lockManager.lock(timeout, lockInfo, resource);
assertNotNull(res);
assertTrue(res.isSuccessful());
// check is locked
LockToken token = lockManager.getCurrentToken(resource);
assertNotNull(token);
assertEquals(token.tokenId, res.getLockToken().tokenId);
// unlock
lockManager.unlock(token.tokenId, resource);
// check removed
token = lockManager.getCurrentToken(resource);
assertNull(token);
}
use of io.milton.http.LockInfo in project lobcder by skoulouzis.
the class SimpleLockManager method getCurrentToken.
public LockToken getCurrentToken(LockableResource r) {
CurrentLock lock = locksByUniqueId.get(r.getUniqueId());
if (lock == null)
return null;
LockToken token = new LockToken();
token.info = new LockInfo(LockInfo.LockScope.EXCLUSIVE, LockInfo.LockType.WRITE, lock.lockedByUser, LockInfo.LockDepth.ZERO);
token.info.lockedByUser = lock.lockedByUser;
token.timeout = lock.token.timeout;
token.tokenId = lock.token.tokenId;
return token;
}
use of io.milton.http.LockInfo in project lobcder by skoulouzis.
the class LockHandler method parseLockInfo.
private LockInfo parseLockInfo(Request request) throws IOException, SAXException {
InputStream in = request.getInputStream();
XMLReader reader = XMLReaderFactory.createXMLReader();
LockInfoSaxHandler handler = new LockInfoSaxHandler();
reader.setContentHandler(handler);
reader.parse(new InputSource(in));
LockInfo info = handler.getInfo();
// todo
info.depth = LockDepth.INFINITY;
info.lockedByUser = null;
if (request.getAuthorization() != null) {
info.lockedByUser = request.getAuthorization().getUser();
}
if (info.lockedByUser == null) {
}
return info;
}
Aggregations