@Override public Access checkPermission(Document doc, ACP mergedAcp, NuxeoPrincipal principal, String permission, String[] resolvedPermissions, String[] additionalPrincipals) { Access access = Access.UNKNOWN; if (Arrays.asList(resolvedPermissions).contains(SecurityConstants.WRITE_PROPERTIES) && !doc.isVersion() && !doc.isProxy()) { if (!doc.isCheckedOut()) { access = Access.DENY; } } return access; }
@Override public void doPostCreate(Document doc, Map<String, Serializable> options) { if (doc.isVersion() || doc.isProxy()) { return; } setInitialVersion(doc); }
@Override public void removeChildren(DocumentRef docRef) { // TODO: check req permissions with td Document doc = resolveReference(docRef); checkPermission(doc, REMOVE_CHILDREN); List<Document> children = doc.getChildren(); // remove proxies first, otherwise they could become dangling for (Document child : children) { if (child.isProxy()) { if (hasPermission(child, REMOVE)) { removeNotifyOneDoc(child); } } } // then remove regular docs or versions, both of which could be proxies targets for (Document child : children) { if (!child.isProxy()) { if (hasPermission(child, REMOVE)) { removeNotifyOneDoc(child); } } } }
if (!doc.isVersion() && !doc.isProxy() && !doc.isCheckedOut()) { if (!deleteTransitions || Framework.getService(ConfigurationService.class) .isBooleanPropertyFalse(TRASH_KEEP_CHECKED_IN_PROPERTY)) {
@Override public Map<String, String> getBinaryFulltext(DocumentRef ref) { Document doc = resolveReference(ref); checkPermission(doc, READ); // Use an id whether than system properties to avoid to store fulltext properties in cache String id = doc.getUUID(); if (doc.isProxy()) { id = doc.getTargetDocument().getUUID(); } return getSession().getBinaryFulltext(id); }
@Override public void removeVersions(Session session, Document doc, CoreSession coreSession) { Collection<Document> proxies = session.getProxies(doc, null); if (doc.isProxy()) {
@Override public DocumentModel copyProxyAsDocument(DocumentRef src, DocumentRef dst, String name, CopyOption... copyOptions) { Document srcDoc = resolveReference(src); if (!srcDoc.isProxy()) { return copy(src, dst, name); } Document dstDoc = resolveReference(dst); checkPermission(dstDoc, WRITE); // create a new document using the expanded proxy DocumentModel srcDocModel = readModel(srcDoc); String docName = (name != null) ? name : srcDocModel.getName(); DocumentModel docModel = createDocumentModel(dstDoc.getPath(), docName, srcDocModel.getType()); docModel.copyContent(srcDocModel); notifyEvent(DocumentEventTypes.ABOUT_TO_COPY, srcDocModel, null, null, null, true, true); docModel = createDocument(docModel); Document doc = resolveReference(docModel.getRef()); Map<String, Serializable> options = new HashMap<>(); options.put(CoreEventConstants.RESET_LIFECYCLE, CopyOption.isResetLifeCycle(copyOptions)); options.put(CoreEventConstants.RESET_CREATOR, CopyOption.isResetCreator(copyOptions)); // notify document created by copy String comment = srcDoc.getRepositoryName() + ':' + src.toString(); notifyEvent(DocumentEventTypes.DOCUMENT_CREATED_BY_COPY, docModel, options, null, comment, true, false); // notify document copied comment = doc.getRepositoryName() + ':' + docModel.getRef().toString(); notifyEvent(DocumentEventTypes.DOCUMENT_DUPLICATED, srcDocModel, options, null, comment, true, false); return docModel; }
Set<String> docSchemas = DocumentModelImpl.computeSchemas(doc.getType(), refresh.instanceFacets, doc.isProxy());
@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); }