本文整理了Java中org.nuxeo.ecm.core.api.Lock.getOwner()
方法的一些代码示例,展示了Lock.getOwner()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lock.getOwner()
方法的具体详情如下:
包路径:org.nuxeo.ecm.core.api.Lock
类名称:Lock
方法名:getOwner
[英]The owner of the lock.
[中]锁的主人。
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core
protected static String getDocumentLocker(DocumentModel doc) {
Lock lock = doc.getLockInfo();
return lock == null ? null : lock.getOwner();
}
代码示例来源:origin: toutatice-services.listeemargement/toutatice-listeemargement-ecm
private boolean isNotLockedOrIsLockOwner(DocumentModel document) throws ClientException {
Lock lockInfo = document.getLockInfo();
return (null != lockInfo) ? lockInfo.getOwner().equals(currentUser.getName()) : true;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-redis
protected String stringFromLock(Lock lock) {
if (lock == null) {
throw new NullPointerException("null lock");
}
return lock.getOwner() + ":" + lock.getCreated().getTimeInMillis();
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core
@Override
public Access checkPermission(Document doc, ACP mergedAcp, NuxeoPrincipal principal, String permission,
String[] resolvedPermissions, String[] additionalPrincipals) {
Access access = Access.UNKNOWN;
// policy only applies on WRITE
if (resolvedPermissions == null || !Arrays.asList(resolvedPermissions).contains(SecurityConstants.WRITE)) {
return access;
}
// check the lock
String username = principal.getName();
Lock lock = doc.getLock();
if (lock != null && !username.equals(lock.getOwner())) {
// locked by another user => deny
access = Access.DENY;
}
return access;
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-webdav
@Override
public String getCheckoutUser(DocumentRef ref) {
Lock lock = getSession().getLockInfo(ref);
if (lock != null) {
return lock.getOwner();
}
return null;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-redis
@Override
public Lock removeLock(final String id, final String owner) {
RedisExecutor redisExecutor = Framework.getService(RedisExecutor.class);
List<String> keys = Collections.singletonList(redisNamespace + id);
List<String> args = Collections.singletonList(owner == null ? "" : owner);
String lockString = (String) redisExecutor.evalsha(scriptRemoveSha, keys, args);
Lock lock = lockFromString(lockString);
if (lock != null && owner != null && !owner.equals(lock.getOwner())) {
lock = new Lock(lock, true); // failed removal
}
return lock;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-sql
@Override
public Lock setLock(final Serializable id, final Lock lock) {
if (log.isDebugEnabled()) {
log.debug("setLock " + id + " owner=" + lock.getOwner());
}
Lock oldLock = getLock(id);
if (oldLock == null) {
Row row = new Row(Model.LOCK_TABLE_NAME, id);
row.put(Model.LOCK_OWNER_KEY, lock.getOwner());
row.put(Model.LOCK_CREATED_KEY, lock.getCreated());
insertSimpleRows(Model.LOCK_TABLE_NAME, Collections.singletonList(row));
}
return oldLock;
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-webapp-core
@Override
public Map<String, Serializable> getLockDetails(DocumentModel document) {
if (lockDetails == null || !StringUtils.equals(documentId, document.getId())) {
lockDetails = new HashMap<String, Serializable>();
documentId = document.getId();
Lock lock = documentManager.getLockInfo(document.getRef());
if (lock == null) {
return lockDetails;
}
lockDetails.put(LOCKER, lock.getOwner());
lockDetails.put(LOCK_CREATED, lock.getCreated());
}
return lockDetails;
}
代码示例来源:origin: opentoutatice-ecm.elasticsearch-customizer/opentoutatice-addon-elasticsearch-customizer-ecm
/**
* Write lock informations of document.
*
* @param jg
* @param doc
* @throws JsonGenerationException
* @throws IOException
*/
// FIXME: create a lock index?
protected void writeLockInfos(JsonGenerator jg, DocumentModel doc) throws JsonGenerationException, IOException {
Lock lock = doc.getLockInfo();
if (lock != null) {
jg.writeStringField("ttc:lockOwner", lock.getOwner());
jg.writeStringField("ttc:lockCreated", ISODateTimeFormat.dateTime().print(new DateTime(lock.getCreated())));
}
}
代码示例来源:origin: org.nuxeo.ecm.routing/nuxeo-routing-core
@Override
public boolean isLockedByCurrentUser(CoreSession session) {
Lock lockInfo = session.getLockInfo(doc.getRef());
if (lockInfo == null) {
return false;
}
String lockOwner = lockInfo.getOwner();
NuxeoPrincipal userName = session.getPrincipal();
return userName.getName().equals(lockOwner);
}
代码示例来源:origin: org.nuxeo.ecm.webengine/nuxeo-webengine-base
@GET
public Object doGet() {
try {
DocumentModel doc = getTarget().getAdapter(DocumentModel.class);
Lock lock = ctx.getCoreSession().getLockInfo(doc.getRef());
return lock.getOwner() + '/' + ISODateTimeFormat.dateTime().print(new DateTime(lock.getCreated()));
} catch (NuxeoException e) {
e.addInfo("Failed to get lock on document");
throw e;
}
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-sql
@Override
public Lock removeLock(final Serializable id, final String owner, final boolean force) {
if (log.isDebugEnabled()) {
log.debug("removeLock " + id + " owner=" + owner + " force=" + force);
}
Lock oldLock = force ? null : getLock(id);
if (!force && owner != null) {
if (oldLock == null) {
// not locked, nothing to do
return null;
}
if (!LockManager.canLockBeRemoved(oldLock.getOwner(), owner)) {
// existing mismatched lock, flag failure
return new Lock(oldLock, true);
}
}
if (force || oldLock != null) {
deleteRows(Model.LOCK_TABLE_NAME, Collections.singleton(id));
}
return oldLock;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io
@Override
public void updateExport(DocumentModel docModel, ExportedDocumentImpl result) throws Exception {
if (docModel.isLocked()) {
Element lockElement = result.getDocument().getRootElement().addElement("lockInfo");
Lock lock = docModel.getLockInfo();
Long created = lock.getCreated().getTimeInMillis();
String owner = lock.getOwner();
lockElement.addElement("created").setText(created.toString());
;
lockElement.addElement("owner").setText(owner.toString());
;
}
}
代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-webdav
@Override
public String lock(DocumentRef ref) {
if (getSession().hasPermission(ref, SecurityConstants.WRITE_PROPERTIES)) {
Lock lock = getSession().setLock(ref);
return lock.getOwner();
}
return ExistingResource.READONLY_TOKEN;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core
@Override
public Lock setLock(DocumentRef docRef) throws LockException {
Document doc = resolveReference(docRef);
// TODO: add a new permission named LOCK and use it instead of
// WRITE_PROPERTIES
checkPermission(doc, WRITE_PROPERTIES);
Lock lock = new Lock(getPrincipal().getName(), new GregorianCalendar());
Lock oldLock = doc.setLock(lock);
if (oldLock != null) {
throw new LockException("Document already locked by " + oldLock.getOwner() + ": " + docRef);
}
DocumentModel docModel = readModel(doc);
Map<String, Serializable> options = new HashMap<>();
options.put("lock", lock);
notifyEvent(DocumentEventTypes.DOCUMENT_LOCKED, docModel, options, null, null, true, false);
return lock;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-mem
@Override
public synchronized Lock setLock(String id, Lock lock) {
State state = states.get(id);
if (state == null) {
// document not found
throw new DocumentNotFoundException(id);
}
String owner = (String) state.get(KEY_LOCK_OWNER);
if (owner != null) {
// return old lock
Calendar created = (Calendar) state.get(KEY_LOCK_CREATED);
return new Lock(owner, created);
}
state.put(KEY_LOCK_OWNER, lock.getOwner());
state.put(KEY_LOCK_CREATED, lock.getCreated());
return null;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core
@Override
public Lock removeLock(DocumentRef docRef) throws LockException {
Document doc = resolveReference(docRef);
String owner;
if (hasPermission(docRef, UNLOCK)) {
// always unlock
owner = null;
} else {
owner = getPrincipal().getName();
}
Lock lock = doc.removeLock(owner);
if (lock == null) {
// there was no lock, we're done
return null;
}
if (lock.getFailed()) {
// lock removal failed due to owner check
throw new LockException("Document already locked by " + lock.getOwner() + ": " + docRef);
}
DocumentModel docModel = readModel(doc);
Map<String, Serializable> options = new HashMap<>();
options.put("lock", lock);
notifyEvent(DocumentEventTypes.DOCUMENT_UNLOCKED, docModel, options, null, null, true, false);
return lock;
}
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io
Lock lock = doc.getLockInfo();
if (lock != null) {
jg.writeStringField("lockOwner", lock.getOwner());
jg.writeStringField("lockCreated", ISODateTimeFormat.dateTime().print(new DateTime(lock.getCreated())));
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-sql
return null;
if (oldLock != null && !LockManager.canLockBeRemoved(oldLock.getOwner(), owner)) {
代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-mongodb
);
Updates.set(KEY_LOCK_OWNER, lock.getOwner()), //
内容来源于网络,如有侵权,请联系作者删除!