org.nuxeo.ecm.core.api.Lock.getOwner()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(224)

本文整理了Java中org.nuxeo.ecm.core.api.Lock.getOwner()方法的一些代码示例,展示了Lock.getOwner()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lock.getOwner()方法的具体详情如下:
包路径:org.nuxeo.ecm.core.api.Lock
类名称:Lock
方法名:getOwner

Lock.getOwner介绍

[英]The owner of the lock.
[中]锁的主人。

代码示例

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core

  1. protected static String getDocumentLocker(DocumentModel doc) {
  2. Lock lock = doc.getLockInfo();
  3. return lock == null ? null : lock.getOwner();
  4. }

代码示例来源:origin: toutatice-services.listeemargement/toutatice-listeemargement-ecm

  1. private boolean isNotLockedOrIsLockOwner(DocumentModel document) throws ClientException {
  2. Lock lockInfo = document.getLockInfo();
  3. return (null != lockInfo) ? lockInfo.getOwner().equals(currentUser.getName()) : true;
  4. }

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-redis

  1. protected String stringFromLock(Lock lock) {
  2. if (lock == null) {
  3. throw new NullPointerException("null lock");
  4. }
  5. return lock.getOwner() + ":" + lock.getCreated().getTimeInMillis();
  6. }

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core

  1. @Override
  2. public Access checkPermission(Document doc, ACP mergedAcp, NuxeoPrincipal principal, String permission,
  3. String[] resolvedPermissions, String[] additionalPrincipals) {
  4. Access access = Access.UNKNOWN;
  5. // policy only applies on WRITE
  6. if (resolvedPermissions == null || !Arrays.asList(resolvedPermissions).contains(SecurityConstants.WRITE)) {
  7. return access;
  8. }
  9. // check the lock
  10. String username = principal.getName();
  11. Lock lock = doc.getLock();
  12. if (lock != null && !username.equals(lock.getOwner())) {
  13. // locked by another user => deny
  14. access = Access.DENY;
  15. }
  16. return access;
  17. }

代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-webdav

  1. @Override
  2. public String getCheckoutUser(DocumentRef ref) {
  3. Lock lock = getSession().getLockInfo(ref);
  4. if (lock != null) {
  5. return lock.getOwner();
  6. }
  7. return null;
  8. }

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-redis

  1. @Override
  2. public Lock removeLock(final String id, final String owner) {
  3. RedisExecutor redisExecutor = Framework.getService(RedisExecutor.class);
  4. List<String> keys = Collections.singletonList(redisNamespace + id);
  5. List<String> args = Collections.singletonList(owner == null ? "" : owner);
  6. String lockString = (String) redisExecutor.evalsha(scriptRemoveSha, keys, args);
  7. Lock lock = lockFromString(lockString);
  8. if (lock != null && owner != null && !owner.equals(lock.getOwner())) {
  9. lock = new Lock(lock, true); // failed removal
  10. }
  11. return lock;
  12. }

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-sql

  1. @Override
  2. public Lock setLock(final Serializable id, final Lock lock) {
  3. if (log.isDebugEnabled()) {
  4. log.debug("setLock " + id + " owner=" + lock.getOwner());
  5. }
  6. Lock oldLock = getLock(id);
  7. if (oldLock == null) {
  8. Row row = new Row(Model.LOCK_TABLE_NAME, id);
  9. row.put(Model.LOCK_OWNER_KEY, lock.getOwner());
  10. row.put(Model.LOCK_CREATED_KEY, lock.getCreated());
  11. insertSimpleRows(Model.LOCK_TABLE_NAME, Collections.singletonList(row));
  12. }
  13. return oldLock;
  14. }

代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-webapp-core

  1. @Override
  2. public Map<String, Serializable> getLockDetails(DocumentModel document) {
  3. if (lockDetails == null || !StringUtils.equals(documentId, document.getId())) {
  4. lockDetails = new HashMap<String, Serializable>();
  5. documentId = document.getId();
  6. Lock lock = documentManager.getLockInfo(document.getRef());
  7. if (lock == null) {
  8. return lockDetails;
  9. }
  10. lockDetails.put(LOCKER, lock.getOwner());
  11. lockDetails.put(LOCK_CREATED, lock.getCreated());
  12. }
  13. return lockDetails;
  14. }

代码示例来源:origin: opentoutatice-ecm.elasticsearch-customizer/opentoutatice-addon-elasticsearch-customizer-ecm

  1. /**
  2. * Write lock informations of document.
  3. *
  4. * @param jg
  5. * @param doc
  6. * @throws JsonGenerationException
  7. * @throws IOException
  8. */
  9. // FIXME: create a lock index?
  10. protected void writeLockInfos(JsonGenerator jg, DocumentModel doc) throws JsonGenerationException, IOException {
  11. Lock lock = doc.getLockInfo();
  12. if (lock != null) {
  13. jg.writeStringField("ttc:lockOwner", lock.getOwner());
  14. jg.writeStringField("ttc:lockCreated", ISODateTimeFormat.dateTime().print(new DateTime(lock.getCreated())));
  15. }
  16. }

代码示例来源:origin: org.nuxeo.ecm.routing/nuxeo-routing-core

  1. @Override
  2. public boolean isLockedByCurrentUser(CoreSession session) {
  3. Lock lockInfo = session.getLockInfo(doc.getRef());
  4. if (lockInfo == null) {
  5. return false;
  6. }
  7. String lockOwner = lockInfo.getOwner();
  8. NuxeoPrincipal userName = session.getPrincipal();
  9. return userName.getName().equals(lockOwner);
  10. }

代码示例来源:origin: org.nuxeo.ecm.webengine/nuxeo-webengine-base

  1. @GET
  2. public Object doGet() {
  3. try {
  4. DocumentModel doc = getTarget().getAdapter(DocumentModel.class);
  5. Lock lock = ctx.getCoreSession().getLockInfo(doc.getRef());
  6. return lock.getOwner() + '/' + ISODateTimeFormat.dateTime().print(new DateTime(lock.getCreated()));
  7. } catch (NuxeoException e) {
  8. e.addInfo("Failed to get lock on document");
  9. throw e;
  10. }
  11. }

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-sql

  1. @Override
  2. public Lock removeLock(final Serializable id, final String owner, final boolean force) {
  3. if (log.isDebugEnabled()) {
  4. log.debug("removeLock " + id + " owner=" + owner + " force=" + force);
  5. }
  6. Lock oldLock = force ? null : getLock(id);
  7. if (!force && owner != null) {
  8. if (oldLock == null) {
  9. // not locked, nothing to do
  10. return null;
  11. }
  12. if (!LockManager.canLockBeRemoved(oldLock.getOwner(), owner)) {
  13. // existing mismatched lock, flag failure
  14. return new Lock(oldLock, true);
  15. }
  16. }
  17. if (force || oldLock != null) {
  18. deleteRows(Model.LOCK_TABLE_NAME, Collections.singleton(id));
  19. }
  20. return oldLock;
  21. }

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io

  1. @Override
  2. public void updateExport(DocumentModel docModel, ExportedDocumentImpl result) throws Exception {
  3. if (docModel.isLocked()) {
  4. Element lockElement = result.getDocument().getRootElement().addElement("lockInfo");
  5. Lock lock = docModel.getLockInfo();
  6. Long created = lock.getCreated().getTimeInMillis();
  7. String owner = lock.getOwner();
  8. lockElement.addElement("created").setText(created.toString());
  9. ;
  10. lockElement.addElement("owner").setText(owner.toString());
  11. ;
  12. }
  13. }

代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-webdav

  1. @Override
  2. public String lock(DocumentRef ref) {
  3. if (getSession().hasPermission(ref, SecurityConstants.WRITE_PROPERTIES)) {
  4. Lock lock = getSession().setLock(ref);
  5. return lock.getOwner();
  6. }
  7. return ExistingResource.READONLY_TOKEN;
  8. }

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core

  1. @Override
  2. public Lock setLock(DocumentRef docRef) throws LockException {
  3. Document doc = resolveReference(docRef);
  4. // TODO: add a new permission named LOCK and use it instead of
  5. // WRITE_PROPERTIES
  6. checkPermission(doc, WRITE_PROPERTIES);
  7. Lock lock = new Lock(getPrincipal().getName(), new GregorianCalendar());
  8. Lock oldLock = doc.setLock(lock);
  9. if (oldLock != null) {
  10. throw new LockException("Document already locked by " + oldLock.getOwner() + ": " + docRef);
  11. }
  12. DocumentModel docModel = readModel(doc);
  13. Map<String, Serializable> options = new HashMap<>();
  14. options.put("lock", lock);
  15. notifyEvent(DocumentEventTypes.DOCUMENT_LOCKED, docModel, options, null, null, true, false);
  16. return lock;
  17. }

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-mem

  1. @Override
  2. public synchronized Lock setLock(String id, Lock lock) {
  3. State state = states.get(id);
  4. if (state == null) {
  5. // document not found
  6. throw new DocumentNotFoundException(id);
  7. }
  8. String owner = (String) state.get(KEY_LOCK_OWNER);
  9. if (owner != null) {
  10. // return old lock
  11. Calendar created = (Calendar) state.get(KEY_LOCK_CREATED);
  12. return new Lock(owner, created);
  13. }
  14. state.put(KEY_LOCK_OWNER, lock.getOwner());
  15. state.put(KEY_LOCK_CREATED, lock.getCreated());
  16. return null;
  17. }

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core

  1. @Override
  2. public Lock removeLock(DocumentRef docRef) throws LockException {
  3. Document doc = resolveReference(docRef);
  4. String owner;
  5. if (hasPermission(docRef, UNLOCK)) {
  6. // always unlock
  7. owner = null;
  8. } else {
  9. owner = getPrincipal().getName();
  10. }
  11. Lock lock = doc.removeLock(owner);
  12. if (lock == null) {
  13. // there was no lock, we're done
  14. return null;
  15. }
  16. if (lock.getFailed()) {
  17. // lock removal failed due to owner check
  18. throw new LockException("Document already locked by " + lock.getOwner() + ": " + docRef);
  19. }
  20. DocumentModel docModel = readModel(doc);
  21. Map<String, Serializable> options = new HashMap<>();
  22. options.put("lock", lock);
  23. notifyEvent(DocumentEventTypes.DOCUMENT_UNLOCKED, docModel, options, null, null, true, false);
  24. return lock;
  25. }

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io

  1. Lock lock = doc.getLockInfo();
  2. if (lock != null) {
  3. jg.writeStringField("lockOwner", lock.getOwner());
  4. jg.writeStringField("lockCreated", ISODateTimeFormat.dateTime().print(new DateTime(lock.getCreated())));

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-sql

  1. return null;
  2. if (oldLock != null && !LockManager.canLockBeRemoved(oldLock.getOwner(), owner)) {

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-mongodb

  1. );
  2. Updates.set(KEY_LOCK_OWNER, lock.getOwner()), //

相关文章