Exemple #1
0
 @Override
 public Document getVersion(String versionableId, VersionModel versionModel) {
   Serializable vid = idFromString(versionableId);
   Node versionNode = session.getVersionByLabel(vid, versionModel.getLabel());
   if (versionNode == null) {
     return null;
   }
   versionModel.setDescription(
       versionNode.getSimpleProperty(Model.VERSION_DESCRIPTION_PROP).getString());
   versionModel.setCreated(
       (Calendar) versionNode.getSimpleProperty(Model.VERSION_CREATED_PROP).getValue());
   return newDocument(versionNode);
 }
Exemple #2
0
 protected Document importChild(
     String uuid,
     Node parent,
     String name,
     Long pos,
     String typeName,
     Map<String, Serializable> props) {
   Serializable id = idFromString(uuid);
   Node node = session.addChildNode(id, parent, name, pos, typeName, false);
   for (Entry<String, Serializable> entry : props.entrySet()) {
     node.setSimpleProperty(entry.getKey(), entry.getValue());
   }
   return newDocument(node, false); // not readonly
 }
Exemple #3
0
 @Override
 public void setACP(Document doc, ACP acp, boolean overwrite) {
   if (!overwrite && acp == null) {
     return;
   }
   checkNegativeAcl(acp);
   Node node = ((SQLDocument) doc).getNode();
   ACLRow[] aclrows;
   if (overwrite) {
     aclrows = acp == null ? null : acpToAclRows(acp);
   } else {
     aclrows = (ACLRow[]) node.getCollectionProperty(Model.ACL_PROP).getValue();
     aclrows = updateAclRows(aclrows, acp);
   }
   node.getCollectionProperty(Model.ACL_PROP).setValue(aclrows);
   session.requireReadAclsUpdate();
 }
Exemple #4
0
  // "readonly" meaningful for proxies and versions, used for import
  private Document newDocument(Node node, boolean readonly) {
    if (node == null) {
      // root's parent
      return null;
    }

    Node targetNode = null;
    String typeName = node.getPrimaryType();
    if (node.isProxy()) {
      Serializable targetId = node.getSimpleProperty(Model.PROXY_TARGET_PROP).getValue();
      if (targetId == null) {
        throw new NoSuchDocumentException("Proxy has null target");
      }
      targetNode = session.getNodeById(targetId);
      typeName = targetNode.getPrimaryType();
    }
    SchemaManager schemaManager = Framework.getLocalService(SchemaManager.class);
    DocumentType type = schemaManager.getDocumentType(typeName);
    if (type == null) {
      throw new NoSuchDocumentException("Unknown document type: " + typeName);
    }

    if (node.isProxy()) {
      // proxy seen as a normal document
      Document proxy = new SQLDocumentLive(node, type, this, false);
      Document target = newDocument(targetNode, readonly);
      return new SQLDocumentProxy(proxy, target);
    } else if (node.isVersion()) {
      return new SQLDocumentVersion(node, type, this, readonly);
    } else {
      return new SQLDocumentLive(node, type, this, false);
    }
  }
Exemple #5
0
 @Override
 public Document createProxy(Document doc, Document folder) {
   Node folderNode = ((SQLDocument) folder).getNode();
   Node targetNode = ((SQLDocument) doc).getNode();
   Serializable targetId = targetNode.getId();
   Serializable versionableId;
   if (doc.isVersion()) {
     versionableId = targetNode.getSimpleProperty(Model.VERSION_VERSIONABLE_PROP).getValue();
   } else if (doc.isProxy()) {
     // copy the proxy
     targetId = targetNode.getSimpleProperty(Model.PROXY_TARGET_PROP).getValue();
     versionableId = targetNode.getSimpleProperty(Model.PROXY_VERSIONABLE_PROP).getValue();
   } else {
     // working copy (live document)
     versionableId = targetId;
   }
   String name = findFreeName(folderNode, doc.getName());
   Node proxy = session.addProxy(targetId, versionableId, folderNode, name, null);
   return newDocument(proxy);
 }
Exemple #6
0
 protected ACP getACP(Document doc) {
   Node node = ((SQLDocument) doc).getNode();
   ACLRow[] aclrows = (ACLRow[]) node.getCollectionProperty(Model.ACL_PROP).getValue();
   return aclRowsToACP(aclrows);
 }
Exemple #7
0
 protected Lock removeLock(Node node, String owner) {
   return session.removeLock(node.getId(), owner, false);
 }
Exemple #8
0
 protected Lock setLock(Node node, Lock lock) {
   return session.setLock(node.getId(), lock);
 }
Exemple #9
0
 protected Lock getLock(Node node) {
   return session.getLock(node.getId());
 }