@Override public void setPathInfo(String parentPath, String name) { path = new Path(parentPath == null ? name : parentPath + '/' + name); ref = new PathRef(parentPath, name); }
@Override public DocumentRef getParentRef() { if (parentRef == null && path != null) { if (path.isAbsolute()) { Path parentPath = path.removeLastSegments(1); parentRef = new PathRef(parentPath.toString()); } // else keep parentRef null } return parentRef; }
@Override public DocumentRef getParentRef() { if (path == null) { return null; } if (!path.isAbsolute()) { return null; } return new PathRef(path.removeLastSegments(1).toString()); }
/** * Constructor to be used by clients. * <p> * A client constructed data model must contain at least the path and the type. */ public DocumentModelImpl(String parentPath, String name, String type) { this(type); String fullPath = parentPath == null ? name : parentPath + (parentPath.endsWith("/") ? "" : "/") + name; path = new Path(fullPath); ref = new PathRef(fullPath); if (getDocumentType() != null) { facets.addAll(getDocumentType().getFacets()); } schemas = computeSchemas(getDocumentType(), instanceFacets, false); schemasOrig = new HashSet<>(schemas); }
public DocumentLocationImpl(DocumentModel doc) { serverName = doc.getRepositoryName(); docRef = doc.getRef(); String id = doc.getId(); if (id != null) { docIdRef = new IdRef(id); } else { docIdRef = null; } String path = doc.getPathAsString(); if (path != null) { docPathRef = new PathRef(path); } else { docPathRef = null; } }
public DocumentModel getDocumentWithPath(String path) { if (StringUtils.isEmpty(path)) { return null; } return documentManager.getDocument(new PathRef(path)); }
public boolean getDocumentExistsAndIsVisibleWithPath(String path) { if (StringUtils.isEmpty(path)) { return false; } PathRef ref = new PathRef(path); return documentManager.exists(ref) && documentManager.hasPermission(ref, SecurityConstants.READ); }
@Override public DocumentRef getParentRef() { if (path != null) { return new PathRef(path.removeLastSegments(1).toString()); } return null; }
public PublicationNode getToutaticeNodeByPath(String path) throws NuxeoException { DocumentRef docRef = new PathRef(path); if (coreSession.hasPermission(docRef, SecurityConstants.READ)) { return new ToutaticeCoreFolderPublicationNode(coreSession.getDocument(new PathRef(path)), getConfigName(), getSessionId(), factory); } else { return new VirtualCoreFolderPublicationNode(coreSession.getSessionId(), path, getConfigName(), sid, factory); } }
protected long syncLogCreationEntries(BaseLogEntryProvider provider, String repoId, String path, Boolean recurs) { provider.removeEntries(DocumentEventTypes.DOCUMENT_CREATED, path); try (CloseableCoreSession session = CoreInstance.openCoreSession(repoId)) { DocumentRef rootRef = new PathRef(path); DocumentModel root = guardedDocument(session, rootRef); long nbAddedEntries = doSyncNode(provider, session, root, recurs); log.debug("synced {} entries on {}", nbAddedEntries, path); return nbAddedEntries; } }
/** * @return configs. */ private DocumentModelList getConfigs() { ConfigurationBeanHelper configHelper = ConfigurationBeanHelper.getBean(); DocumentModel domain = coreSession.getDocument(new PathRef(domainPath)); return configHelper.getConfigs(confType, coreSession, domain); }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel input) { DocumentRef docRef = new PathRef(path); if (!session.exists(docRef)) { throw new NuxeoException(String.format("Destination \"%s\" specified into operation not found", path)); } DocumentModel proxy = session.createProxy(input.getRef(), docRef); return proxy; }
@Override public boolean canPublishTo(PublicationNode publicationNode) throws NuxeoException { if (publicationNode == null || publicationNode.getParent() == null) { // we can't publish in the root node return false; } DocumentRef docRef = new PathRef(publicationNode.getPath()); boolean canAsk = coreSession.hasPermission(docRef, CAN_ASK_FOR_PUBLISHING); DocumentModel document = coreSession.getDocument(docRef); boolean notSectionRoot = !SECTION_ROOT_TYPE.equals(document.getType()); return canAsk && notSectionRoot; }
private DocumentModel getDocumentFromIdOrPath() throws OperationException { if (sourceId != null) { return session.getDocument(new IdRef(sourceId)); } else if (sourcePath != null) { return session.getDocument(new PathRef(sourcePath)); } else { throw new OperationException("No document id or path was provided"); } }
protected boolean cleanTrashPath(DocumentModel parent, String name) { Path checkedPath = new Path(parent.getPathAsString()).append(name); if (getSession().exists(new PathRef(checkedPath.toString()))) { DocumentModel model = getSession().getDocument(new PathRef(checkedPath.toString())); if (model != null && model.isTrashed()) { name = name + "." + System.currentTimeMillis(); getSession().move(model.getRef(), parent.getRef(), name); return true; } } return false; }
@Override public DocumentObject newDocument(String path) { PathRef pathRef = new PathRef(doc.getPath().append(path).toString()); DocumentModel doc = ctx.getCoreSession().getDocument(pathRef); return (DocumentObject) ctx.newObject("Document", doc); }
protected String findFarthestContainerPath(String documentPath) { Path containerPath = new Path(documentPath); String result; do { result = containerPath.toString(); containerPath = containerPath.removeLastSegments(1); } while (!containerPath.isRoot() && documentManager.exists(new PathRef(containerPath.toString()))); return result; }
protected DocumentModel getDocumentationRoot(CoreSession session) { DocumentRef rootRef = new PathRef(Root_PATH + Root_NAME); if (session.exists(rootRef)) { return session.getDocument(rootRef); } UnrestrictedRootCreator creator = new UnrestrictedRootCreator(session); creator.runUnrestricted(); // flush caches session.save(); return session.getDocument(creator.getRootRef()); }
public DocumentModel getDistributionRoot(CoreSession session) { DocumentRef rootRef = new PathRef(Root_PATH + Root_NAME); if (session.exists(rootRef)) { return session.getDocument(rootRef); } UnrestrictedRootCreator creator = new UnrestrictedRootCreator(session, Root_PATH, Root_NAME, true); creator.runUnrestricted(); // flush caches session.save(); return session.getDocument(creator.getRootRef()); }
protected DocumentModel getParentDocument(CoreSession session, DocumentModel doc) { DocumentModel parent; if (session.exists(doc.getRef())) { parent = session.getParentDocument(doc.getRef()); } else { Path parentPath = doc.getPath().removeLastSegments(1); parent = session.getDocument(new PathRef(parentPath.toString())); } return parent; }