org.hippoecm.repository.api.Document.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(126)

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

Document.<init>介绍

[英]Constructor that should be considered to have a protected signature rather than public and may be used for extending classes to create a new Document.
[中]构造函数,该构造函数应被视为具有受保护的签名而不是公共签名,并可用于扩展类以创建新文档。

代码示例

代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow

private Document createGalleryItem(final Node document) throws RepositoryException {
  final String primaryItemName = getPrimaryItemName(document);
  if (primaryItemName != null) {
    final Node primaryItem;
    if (!document.hasNode(primaryItemName)) {
      primaryItem = document.addNode(primaryItemName);
    } else {
      primaryItem = document.getNode(primaryItemName);
    }
    primaryItem.setProperty(JCR_DATA, "");
    primaryItem.setProperty(JCR_MIME_TYPE, "application/octet-stream");
    primaryItem.setProperty(JCR_LAST_MODIFIED, Calendar.getInstance());
  } else {
    throw new ItemNotFoundException("No primary item definition found");
  }
  rootSession.save();
  return new Document(document);
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow

public Document copy(String relPath, String absPath, Map<String,String> arguments)
  throws WorkflowException, MappingException, RepositoryException, RemoteException {
  Node source = subject.getNode(relPath);
  if(!source.isNodeType(HippoNodeType.NT_DOCUMENT) && !source.isNodeType(NT_HANDLE)) {
    throw new MappingException("copied item is not a document");
  }
  Node target = subject.getSession().getRootNode().getNode(absPath.substring(1, absPath.lastIndexOf('/')));
  if(!target.isNodeType(HippoNodeType.NT_DOCUMENT)) {
    throw new MappingException("copied destination is not a document");
  }
  return copyFrom(new Document(source), new Document(target), absPath.substring(absPath.lastIndexOf('/') + 1), arguments);
}
public Document copy(Document offspring, Document targetFolder, String targetName, Map<String,String> arguments)

代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow

public Document move(String relPath, String absPath, Map<String,String> arguments)
  throws WorkflowException, MappingException, RepositoryException, RemoteException {
  Node source = subject.getNode(relPath);
  if(!source.isNodeType(HippoNodeType.NT_DOCUMENT) && !source.isNodeType(NT_HANDLE)) {
    throw new MappingException("copied item is not a document");
  }
  Node target = subject.getSession().getRootNode().getNode(absPath.substring(1, absPath.lastIndexOf('/')));
  if(!target.isNodeType(HippoNodeType.NT_DOCUMENT)) {
    throw new MappingException("copied destination is not a document");
  }
  return moveFrom(new Document(source), new Document(target), absPath.substring(absPath.lastIndexOf('/') + 1), arguments);
}
public Document move(Document offspring, Document targetFolder, String targetName, Map<String,String> arguments)

代码示例来源:origin: org.onehippo.cms7/hippo-repository-builtin

/**
 * Get the containing folder of a document.
 *
 * @param document either a document, a handle or a folder
 * @param session the session to use to get the containing folder for
 * @return  the folder containing this document or the root document
 * @throws RepositoryException
 */
public static Document getContainingFolder(Document document, Session session) throws RepositoryException {
  return new Document(getContainingFolder(document.getNode(session)));
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow

public DefaultWorkflowImpl(WorkflowContext context, Session userSession, Session rootSession, Node subject) throws RepositoryException {
  this.context = context;
  this.document = new Document(subject);
  this.subject = rootSession.getNodeByIdentifier(subject.getIdentifier());
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow

public Document getReference() throws RepositoryException  {
    if (hasNode() && getNode().hasProperty(HippoStdPubWfNodeType.HIPPOSTDPUBWF_DOCUMENT)) {
      return new Document(getNode().getProperty(HippoStdPubWfNodeType.HIPPOSTDPUBWF_DOCUMENT).getNode());
    }
    return null;
  }
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-testutils

@Override
protected Node doExecute(Node node) throws Exception {
  Node targetFolder = selectRandomDocumentFolderNode(node);
  if (targetFolder != null) {
    String newName = "document";
    do {
      newName += random.nextInt(10);
    } while (targetFolder.hasNode(newName));
    Node handle = node.getParent();
    getDocumentWorkflow(handle).move(new Document(targetFolder), newName);
    node.getSession().refresh(false);
  }
  return targetFolder;
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow

public Document copyFrom(Document offspring, Document targetFolder, String targetName, Map<String,String> arguments)
  throws WorkflowException, MappingException, RepositoryException, RemoteException {
  if (targetName == null || targetName.equals("")) {
    throw new WorkflowException("No target name given");
  }
  String path = subject.getPath().substring(1);
  Node folder = (path.equals("") ? rootSession.getRootNode() : rootSession.getRootNode().getNode(path));
  Node destination = targetFolder.getNode(rootSession);
  Node source = offspring.getNode(rootSession);
  if (folder.isSame(destination)) {
    //throw new WorkflowException("Cannot copy document to same folder, use duplicate instead");
    return duplicate(source, targetName);
  }
  if (source.getAncestor(folder.getDepth()).isSame(folder)) {
    return ((EmbedWorkflow)workflowContext.getWorkflow("embedded", new Document(destination))).copyTo(new Document(subject), offspring, targetName, arguments);
  }
  return null;
}

代码示例来源:origin: org.onehippo.cms7/hippo-cms-translation-frontend

private Document getTranslatedVariant(final Document translatedDocument) throws RepositoryException {
  final Node translatedNode = translatedDocument.getNode(UserSession.get().getJcrSession());
  if (translatedNode.isNodeType(NT_HANDLE)) {
    Node variant = null;
    for (Node node : new NodeIterable(translatedNode.getNodes(translatedNode.getName()))) {
      variant = node;
      final String state = JcrUtils.getStringProperty(translatedNode, HIPPOSTD_STATE, null);
      if (UNPUBLISHED.equals(state)) {
        break;
      }
    }
    return variant != null ? new Document(variant) : null;
  }
  return translatedDocument;
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow

public Document moveFrom(Document offspring, Document targetFolder, String targetName, Map<String,String> arguments)
  throws WorkflowException, MappingException, RepositoryException, RemoteException {
  String path = subject.getPath().substring(1);
  Node folder = (path.equals("") ? rootSession.getRootNode() : rootSession.getRootNode().getNode(path));
  Node destination = targetFolder.getNode(rootSession);
  if (folder.isSame(destination)) {
    throw new WorkflowException("Cannot move document to same folder");
  }
  Node source = offspring.getNode(rootSession);
  if (!folder.isCheckedOut()) {
    folder.checkout();
  }
  if (source.getAncestor(folder.getDepth()).isSame(folder)) {
    ((EmbedWorkflow)workflowContext.getWorkflow("internal", new Document(destination))).moveTo(new Document(subject), offspring, targetName, arguments);
  }
  return null;
}

代码示例来源:origin: org.onehippo.cms7/hippo-cms-workflow-frontend

@Override
  protected String execute(Workflow wf) throws Exception {
    Node document = getModel().getNode();
    Node folder = destination != null ? destination.getChainedModel().getObject()
        : new JcrNodeModel("/").getNode();
    String nodeName = document.getName();
    DocumentWorkflow workflow = (DocumentWorkflow) wf;
    workflow.move(new Document(folder), nodeName);
    browseTo(new JcrNodeModel(folder.getPath() + "/" + nodeName));
    return null;
  }
});

代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow

public void copy(Document destination, String newName) throws MappingException, RemoteException, WorkflowException, RepositoryException {
  Document folder = new Document(getContainingFolder(subject));
  Workflow workflow = getWorkflowContext().getWorkflow(getFolderWorkflowCategory(), destination);
  if(workflow instanceof EmbedWorkflow)
    ((EmbedWorkflow)workflow).copyTo(folder, document, newName, null);
  else
    throw new WorkflowException("cannot copy document which is not contained in a folder");
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow

public void rename(String newName) throws WorkflowException, MappingException, RepositoryException, RemoteException {
  Document folder = new Document(getContainingFolder(subject));
  Workflow workflow = getWorkflowContext().getWorkflow(getFolderWorkflowCategory(), folder);
  if (workflow instanceof FolderWorkflow) {
    ((FolderWorkflow)workflow).rename(document, newName);
  } else {
    throw new WorkflowException("cannot rename document which is not contained in a folder");
  }
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow

public void delete() throws WorkflowException, MappingException, RepositoryException, RemoteException {
  Workflow workflow = getWorkflowContext().getWorkflow(getFolderWorkflowCategory(), new Document(getContainingFolder(subject)));
  if(workflow instanceof FolderWorkflow) {
    ((FolderWorkflow) workflow).delete(document);
  } else {
    throw new WorkflowException("Cannot delete document that is not contained in a folder");
  }
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow

public void archive() throws WorkflowException, MappingException, RepositoryException, RemoteException {
  Document folder = new Document(getContainingFolder(subject));
  Workflow workflow = getWorkflowContext().getWorkflow(getFolderWorkflowCategory(), folder);
  if (workflow instanceof FolderWorkflow) {
    ((FolderWorkflow)workflow).archive(document);
  } else {
    throw new WorkflowException("cannot archive document which is not contained in a folder");
  }
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow

public void move(Document destination, String newName) throws MappingException, RemoteException, WorkflowException, RepositoryException {
  Document folder = new Document(getContainingFolder(subject));
  Workflow workflow = getWorkflowContext().getWorkflow(getFolderWorkflowCategory(), folder);
  if(workflow instanceof FolderWorkflow)
    ((FolderWorkflow)workflow).move(document, destination, newName);
  else
    throw new WorkflowException("cannot move document which is not contained in a folder");
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow

@Override
  public Object doExecute() throws WorkflowException, RepositoryException, RemoteException {

    if (getVariant() == null || !getVariant().hasNode()) {
      throw new WorkflowException("No variant provided");
    }
    final Session workflowSession = getWorkflowContext().getInternalWorkflowSession();
    Node targetNode = getVariant().getNode(workflowSession);

    // ensure no pending changes which would fail the checkin
    workflowSession.save();
    return new Document(targetNode.checkin());
  }
}

代码示例来源:origin: org.onehippo.cms7/hippo-addon-publication-workflow-frontend

@Override
  protected String execute(Workflow wf) throws Exception {
    JcrNodeModel folderModel = new JcrNodeModel("/");
    if (destination != null) {
      folderModel = destination.getNodeModel();
    }
    String nodeName = (((WorkflowDescriptorModel) getDefaultModel()).getNode()).getName();
    FullReviewedActionsWorkflow workflow = (FullReviewedActionsWorkflow) wf;
    workflow.move(new Document(folderModel.getNode().getUUID()), nodeName);
    browseTo(new JcrNodeModel(folderModel.getItemModel().getPath() + "/" + nodeName));
    return null;
  }
});

代码示例来源:origin: org.onehippo.cms7/hippo-cms-workflow-frontend

@Override
protected String execute(Workflow wf) throws Exception {
  Node folder = destination != null ? destination.getChainedModel().getObject() :
      new JcrNodeModel("/").getNode();
  Node document = getModel().getNode();
  String nodeName = getNodeNameCodec(document, folder).encode(name);
  DocumentWorkflow workflow = (DocumentWorkflow) wf;
  workflow.copy(new Document(folder), nodeName);
  JcrNodeModel resultModel = new JcrNodeModel(folder.getPath() + "/" + nodeName);
  Node result = resultModel.getNode();
  WorkflowManager manager = UserSession.get().getWorkflowManager();
  DefaultWorkflow defaultWorkflow = (DefaultWorkflow) manager.getWorkflow("core", result.getNode(nodeName));
  defaultWorkflow.setDisplayName(getLocalizeCodec().encode(name));
  browseTo(resultModel);
  return null;
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow

@Override
  public Object doExecute() throws WorkflowException, RepositoryException, RemoteException {

    if (getVariant() == null || !getVariant().hasNode() || getHistoric() == null) {
      throw new WorkflowException("No variant or date provided");
    }
    Node variant = getVariant().getNode(getWorkflowContext().getInternalWorkflowSession());

    final Version version = lookupVersion(variant, getHistoric());
    if (version != null) {
      return new Document(version.getFrozenNode());
    }
    return null;
  }
}

相关文章

微信公众号

最新文章

更多