@Override public boolean accept(DocumentModel document) { String docType = document.getType(); if (excludedTypes != null && excludedTypes.contains(docType)) { return false; } // exclude trashed documents from tree if (document.isTrashed()) { return false; } // XXX AT: this could have not been copied from FacetFilter if fields // were not private there. if (excludedFacets != null) { for (String exc : excludedFacets) { if (document.hasFacet(exc)) { return false; } } } if (includedFacets != null) { for (String req : includedFacets) { if (!document.hasFacet(req)) { return false; } } } return true; }
protected boolean isTrashDocument(DocumentModel model) { return model == null || model.isTrashed(); }
protected boolean checkDeletedState(DocumentModel doc) { return doc.isTrashed() || doc.getAllowedStateTransitions().contains(LifeCycleConstants.DELETE_TRANSITION); }
@Override public List<DocumentModel> getChildren(DocumentRef ref) { List<DocumentModel> result = new ArrayList<DocumentModel>(); List<DocumentModel> children = getSession(true).getChildren(ref); for (DocumentModel child : children) { if (child.hasFacet(FacetNames.HIDDEN_IN_NAVIGATION)) { continue; } if (child.isTrashed()) { continue; } if (!child.hasSchema("dublincore")) { continue; } if (child.hasFacet(FacetNames.FOLDERISH) || child.getAdapter(BlobHolder.class) != null) { result.add(child); } } return result; }
@Override public DocumentModelList getTemplates(String targetTypeName) { if (documentManager == null) { log.error("Unable to access documentManager"); return null; } String query = "SELECT * FROM Document where ecm:primaryType = '%s' AND ecm:path STARTSWITH %s"; DocumentModelList tl = documentManager.query(String.format(query, TemplateRoot, NXQL.escapeString(navigationContext.getCurrentDomainPath()))); if (tl.isEmpty()) { templates = tl; } else { templates = documentManager.getChildren(tl.get(0).getRef(), targetTypeName); List<DocumentModel> deleted = new ArrayList<>(); for (DocumentModel current : templates) { if (current.isTrashed()) { deleted.add(current); } } templates.removeAll(deleted); } return templates; }
boolean destinationIsDeleted = parent.isTrashed(); List<DocumentRef> docRefs = new ArrayList<>(); List<DocumentRef> proxyRefs = new ArrayList<>();
public static synchronized DocumentModel getOrCreate(CoreSession session, String rootPath, String id, String folderType) { String path = String.format("%s/%s", rootPath, id); DocumentRef pathRef = new PathRef(path); boolean exists = session.exists(pathRef); if (exists) { DocumentModel existing = session.getDocument(pathRef); if (!existing.isTrashed()) { return existing; } } // create it DocumentModel newDocument = session.createDocumentModel(rootPath, IdUtils.generateId(id, "-", true, 24), folderType); newDocument.setPropertyValue(TITLE_PROPERTY_NAME, id); newDocument = session.createDocument(newDocument); return newDocument; }
public List<DocumentModel> moveDocumentsToNewParent(DocumentModel destFolder, List<DocumentModel> docs) { DocumentRef destFolderRef = destFolder.getRef(); boolean destinationIsDeleted = destFolder.isTrashed(); List<DocumentModel> newDocs = new ArrayList<>(); StringBuilder sb = new StringBuilder();
if (doc.isTrashed()) { continue;
protected void getAllTasks() { error = null; errorMessage = null; userTasks = new ArrayList<>(); CoreSession coreSession = getCoreSession(); boolean filterTrashDocs = getFilterDocumentsInTrash(); NuxeoPrincipal pal = coreSession.getPrincipal(); TaskService taskService = Framework.getService(TaskService.class); List<Task> tasks = taskService.getAllCurrentTaskInstances(coreSession, getSortInfos()); if (tasks != null) { for (Task task : tasks) { List<String> targetDocumentsIds = task.getTargetDocumentsIds(); boolean hasTargetDocuments = targetDocumentsIds != null && !targetDocumentsIds.isEmpty(); if (task.hasEnded() || task.isCancelled() || !hasTargetDocuments) { continue; } DocumentModel doc = taskService.getTargetDocumentModel(task, coreSession); if (doc != null) { if (!filterTrashDocs || !doc.isTrashed()) { userTasks.add(new DashBoardItemImpl(task, doc, getLocale())); } } else { log.warn(String.format("User '%s' has a task of type '%s' on a missing or deleted document", pal.getName(), task.getName())); } } } }
jg.writeBooleanField("isTrashed", doc.getRef() != null && doc.isTrashed()); jg.writeStringField("title", doc.getTitle()); if (mustFetch("versionLabel")) {
jg.writeBooleanField("ecm:isTrashed", doc.isTrashed()); jg.writeBooleanField("ecm:isVersion", doc.isVersion()); jg.writeBooleanField("ecm:isLatestVersion", doc.isLatestVersion());
if (checkDeleted && !doc.isTrashed()) { info.forbidden++; continue;
private void addFolderToZip(String path, ZipOutputStream out, DocumentModel doc, byte[] data, CoreSession documentManager, StringBuilder blobList, boolean exportAllBlobs) throws IOException { String title = doc.getTitle(); List<DocumentModel> docList = documentManager.getChildren(doc.getRef()); for (DocumentModel docChild : docList) { // NXP-2334 : skip trashed docs if (doc.isTrashed()) { continue; } BlobHolder bh = docChild.getAdapter(BlobHolder.class); String newPath = null; if (path.length() == 0) { newPath = title; } else { newPath = path + "/" + title; } if (docChild.isFolder() && !isEmptyFolder(docChild, documentManager)) { addFolderToZip(newPath, out, docChild, data, documentManager, blobList, exportAllBlobs); } else if (bh != null) { addBlobHolderToZip(newPath, out, docChild, data, blobList, bh, exportAllBlobs); } } }
if (!sourceTemplateDoc.isTrashed()) { tps.makeTemplateBasedDocument(targetDoc, sourceTemplateDoc, false);
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; }
record.put(AvroConstants.IS_TRASHED, doc.isTrashed()); record.put(AvroConstants.IS_VERSION, doc.isVersion()); record.put(AvroConstants.IS_CHECKEDIN, !doc.isCheckedOut());