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

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

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

Lock.<init>介绍

暂无

代码示例

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

protected Lock lockFromString(String lockString) {
  if (lockString == null) {
    return null;
  }
  String[] split = lockString.split(":");
  if (split.length != 2 || !StringUtils.isNumeric(split[1])) {
    throw new IllegalArgumentException(
        "Invalid Redis lock : " + lockString + ", should be " + redisNamespace + "<id>");
  }
  Calendar created = Calendar.getInstance();
  created.setTimeInMillis(Long.parseLong(split[1]));
  return new Lock(split[0], created);
}

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

@Override
public void updateImport(CoreSession session, DocumentModel docModel, ExportedDocument xdoc) throws Exception {
  Element lockInfo = xdoc.getDocument().getRootElement().element("lockInfo");
  if (lockInfo != null) {
    String createdMS = lockInfo.element("created").getText();
    String owner = lockInfo.element("owner").getText();
    Calendar created = Calendar.getInstance();
    created.setTimeInMillis(Long.parseLong(createdMS));
    Lock lock = new Lock(owner, created);
    getLockManager(session).setLock(docModel.getId(), lock);
  }
}

代码示例来源: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 getLock(Serializable id) {
  if (log.isDebugEnabled()) {
    try {
      log.debug("getLock " + id + " while autoCommit=" + connection.getAutoCommit());
    } catch (SQLException e) {
      throw new RuntimeException(e);
    }
  }
  RowId rowId = new RowId(Model.LOCK_TABLE_NAME, id);
  Row row = readSimpleRow(rowId);
  return row == null ? null
      : new Lock((String) row.get(Model.LOCK_OWNER_KEY), (Calendar) row.get(Model.LOCK_CREATED_KEY));
}

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

@Override
public synchronized Lock getLock(String id) {
  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 null;
  }
  Calendar created = (Calendar) state.get(KEY_LOCK_CREATED);
  return new Lock(owner, created);
}

代码示例来源: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-storage-mem

@Override
public synchronized Lock removeLock(String id, String owner) {
  State state = states.get(id);
  if (state == null) {
    // document not found
    throw new DocumentNotFoundException(id);
  }
  String oldOwner = (String) state.get(KEY_LOCK_OWNER);
  if (oldOwner == null) {
    // no previous lock
    return null;
  }
  Calendar oldCreated = (Calendar) state.get(KEY_LOCK_CREATED);
  if (!LockManager.canLockBeRemoved(oldOwner, owner)) {
    // existing mismatched lock, flag failure
    return new Lock(oldOwner, oldCreated, true);
  }
  // remove lock
  state.put(KEY_LOCK_OWNER, null);
  state.put(KEY_LOCK_CREATED, null);
  // return old lock
  return new Lock(oldOwner, oldCreated);
}

代码示例来源: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-storage-sql

oldLock = new Lock(oldLock, true);
} else {
  if (oldLock == null) {
  if (oldLock != null && oldLock.getFailed()) {
    lockCache.put(id, new Lock(oldLock, false));
  } else {
    lockCache.put(id, NULL_LOCK);

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

return new Lock(oldOwner, oldCreated);
if (!LockManager.canLockBeRemoved(oldOwner, owner)) {
  return new Lock(oldOwner, oldCreated, true);

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

@Override
public Lock getLock(String id) {
  if (log.isTraceEnabled()) {
    logQuery(id, LOCK_FIELDS);
  }
  Document res = coll.find(Filters.eq(idKey, id)).projection(LOCK_FIELDS).first();
  if (res == null) {
    // document not found
    throw new DocumentNotFoundException(id);
  }
  String owner = res.getString(KEY_LOCK_OWNER);
  if (owner == null) {
    // not locked
    return null;
  }
  Calendar created = (Calendar) converter.scalarToSerializable(res.get(KEY_LOCK_CREATED));
  return new Lock(owner, created);
}

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

Calendar oldCreated = (Calendar) converter.scalarToSerializable(old.get(KEY_LOCK_CREATED));
if (oldOwner != null) {
  return new Lock(oldOwner, oldCreated);

相关文章

微信公众号

最新文章

更多