/** * Updates the document (sets its properties). * <p> * Default implementation sets the content. */ protected void updateDocument(DocumentModel doc, Blob content) { doc.getAdapter(BlobHolder.class).setBlob(content); }
public List<DocumentModel> getSelectedConfs(DocumentModel document) throws NuxeoException { List<DocumentModel> selectedWebConfs = new ArrayList<DocumentModel>(0); WebConfsConfiguration webConfsConfiguration = document.getAdapter(WebConfsConfiguration.class); if (webConfsConfiguration != null) { selectedWebConfs.addAll(webConfsConfiguration.getSelectedConfs(document)); } return selectedWebConfs; }
public List<String> getAllowedWebConfs(DocumentModel doc) throws NuxeoException { List<String> allowedWebConfs = new ArrayList<String>(0); WebConfsConfiguration webConfsConfiguration = doc.getAdapter(WebConfsConfiguration.class); if (webConfsConfiguration == null) { return Collections.emptyList(); } allowedWebConfs.addAll(webConfsConfiguration.getAllowedWebConfs(doc)); return allowedWebConfs; }
private boolean isBlobHolder(DocumentModel doc, String xpath) { DocumentBlobHolder bh = (DocumentBlobHolder) doc.getAdapter(BlobHolder.class); return bh != null && bh.getXpath().equals(xpath); } }
protected CommentableDocument getCommentableDoc(DocumentModel doc) { if (doc == null) { doc = navigationContext.getCurrentDocument(); } commentableDoc = doc.getAdapter(CommentableDocument.class); return commentableDoc; }
public static Map<DocumentModel, List<DocumentModel>> getProxyComments(DocumentModel proxy) throws NuxeoException { Map<DocumentModel, List<DocumentModel>> comments = new HashMap<DocumentModel, List<DocumentModel>>(); CommentableDocument commentableDoc = proxy.getAdapter(CommentableDocument.class); List<DocumentModel> rootComments = commentableDoc.getComments(); if (null != rootComments && 0 < rootComments.size()) { for(DocumentModel rootComment : rootComments){ List<DocumentModel> commentsThread = commentableDoc.getComments(rootComment); comments.put(rootComment, commentsThread); } } return comments; }
public List<UIComment> getComments(DocumentModel doc) { List<UIComment> allComments = new ArrayList<>(); commentableDoc = doc.getAdapter(CommentableDocument.class); if (commentableDoc != null) { List<DocumentModel> comments = commentableDoc.getComments(); for (DocumentModel comment : comments) { UIComment uiComment = createUIComment(null, comment); allComments.add(uiComment); } } return allComments; }
@Override public boolean isAvailable(DocumentModel doc, RenditionDefinition definition) { PictureResourceAdapter picture = doc.getAdapter(PictureResourceAdapter.class); return picture != null && picture.getPictureFromTitle(definition.getName()) != null; }
@Override public DocumentModel makeTemplateBasedDocument(DocumentModel targetDoc, DocumentModel sourceTemplateDoc, boolean save) { targetDoc.addFacet(TemplateBasedDocumentAdapterImpl.TEMPLATEBASED_FACET); TemplateBasedDocument tmplBased = targetDoc.getAdapter(TemplateBasedDocument.class); // bind the template return tmplBased.setTemplate(sourceTemplateDoc, save); }
protected List<DocumentRouteElement> getChildrenElement(CoreSession session, DocumentRouteElement element) { DocumentModelList children = session.getChildren(element.getDocument().getRef()); List<DocumentRouteElement> elements = new ArrayList<DocumentRouteElement>(); for (DocumentModel model : children) { elements.add(model.getAdapter(DocumentRouteElement.class)); } return elements; }
@OperationMethod public BusinessAdapter run(BusinessAdapter input) { DocumentModel document = input.getDocument(); // TODO the code intends to copy to a new document with parentPath+name but it's buggy and does not do that // TODO currently we just create a placeless document with an random name // TODO use createDocumentModel instead of document to fix // createDocumentModel.copyContent(document); document = session.createDocument(document); return document.getAdapter(input.getClass()); }
@PUT @Path("{taskId}/{action}") public Response completeTask(@PathParam("taskId") String taskId, @PathParam("action") String action, TaskCompletionRequest taskCompletionRequest) { Map<String, Object> data = taskCompletionRequest.getDataMap(); CoreSession session = getContext().getCoreSession(); Framework.getService(DocumentRoutingService.class).endTask(session, session.getDocument(new IdRef(taskId)).getAdapter(Task.class), data, action); Task completedTask = session.getDocument(new IdRef(taskId)).getAdapter(Task.class); return Response.ok(completedTask).status(Status.OK).build(); }
@OperationMethod public Object run() throws NuxeoException { if (this.document.hasFacet("Commentable")) { CommentableDocument commentableDoc = this.document.getAdapter(CommentableDocument.class); commentableDoc.removeComment(this.comment); } return this.document; } }
@Override public RegistrationRules getRegistrationRules(String configurationName) { RootDocumentGetter rdg = new RootDocumentGetter(configurationName); rdg.runUnrestricted(); return rdg.getDoc().getAdapter(RegistrationRules.class); }
public boolean isCurrentRouteLocked() throws ClientException { LockableDocumentRoute lockableRoute = getRelatedRoute().getDocument().getAdapter( LockableDocumentRoute.class); return lockableRoute.isLocked(documentManager); }
@Override public OperationInfo getOperation(String id) { if (id.startsWith(OperationInfo.ARTIFACT_PREFIX)) { id = id.substring(OperationInfo.ARTIFACT_PREFIX.length()); } String query = QueryHelper.select(OperationInfo.TYPE_NAME, getDoc()) + " AND " + OperationInfo.PROP_NAME + " = " + NXQL.escapeString(id) + " OR " + OperationInfo.PROP_ALIASES + " = " + NXQL.escapeString(id); DocumentModelList docs = getCoreSession().query(query); return docs.isEmpty() ? null : docs.get(0).getAdapter(OperationInfo.class); }
private DocumentBlobHolder getBlobHolderToPreview() { Resource target = getTarget(); if (isBlobTarget()) { return ((BlobObject) target).getBlobHolder(); } else { DocumentModel doc = target.getAdapter(DocumentModel.class); return (DocumentBlobHolder) doc.getAdapter(BlobHolder.class); } }
@Override public void setTemplateBlob(Blob blob, boolean save) { BlobHolder bh = getAdaptedDoc().getAdapter(BlobHolder.class); if (bh != null) { bh.setBlob(blob); initTemplate(false); if (save) { doSave(); } } }
public String goBackToRoute() throws ClientException { DocumentModel currentDocument = navigationContext.getCurrentDocument(); DocumentRouteElement docRouteElement = currentDocument.getAdapter(DocumentRouteElement.class); return webActions.setCurrentTabAndNavigate( docRouteElement.getDocumentRoute(documentManager).getDocument(), "TAB_DOCUMENT_ROUTE_ELEMENTS"); }
@OperationMethod public void run(DocumentModel targetTemplate) { TemplateSourceDocument template = targetTemplate.getAdapter(TemplateSourceDocument.class); TemplateProcessorService tps = Framework.getService(TemplateProcessorService.class); List<TemplateBasedDocument> documents = template.getTemplateBasedDocuments(); documents.forEach(doc -> tps.detachTemplateBasedDocument(doc.getAdaptedDoc(), template.getName(), true)); } }