Ejemplo n.º 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);
 }
Ejemplo n.º 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
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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);
    }
  }
Ejemplo n.º 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);
 }
Ejemplo n.º 6
0
 protected ACP getACP(Document doc) {
   Node node = ((SQLDocument) doc).getNode();
   ACLRow[] aclrows = (ACLRow[]) node.getCollectionProperty(Model.ACL_PROP).getValue();
   return aclRowsToACP(aclrows);
 }
Ejemplo n.º 7
0
 protected Lock removeLock(Node node, String owner) {
   return session.removeLock(node.getId(), owner, false);
 }
Ejemplo n.º 8
0
 protected Lock setLock(Node node, Lock lock) {
   return session.setLock(node.getId(), lock);
 }
Ejemplo n.º 9
0
 protected Lock getLock(Node node) {
   return session.getLock(node.getId());
 }