public void save(CoreSession session) { session.saveDocument(doc); }
@Override public void mapProperties(CoreSession session, DocumentModel sourceDoc, DocumentModel targetDoc, String mapping) { Map<String, String> properties = getMapping(mapping); for (String keyProp : properties.keySet()) { // verify that mapping can be done Property sourceProperty = sourceDoc.getProperty(keyProp); Property targetProperty = targetDoc.getProperty(properties.get(keyProp)); Type sourceType = sourceProperty.getType(); Type targetType = targetProperty.getType(); if (!compatibleTypes(targetType, sourceType)) { throw new NuxeoException( String.format("Invalid mapping. Cannot map %s on type %s ", sourceType, targetType)); } targetDoc.setPropertyValue(targetProperty.getXPath(), sourceProperty.getValue()); } session.saveDocument(targetDoc); }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { return session.saveDocument(doc); }
@OperationMethod public BusinessAdapter run(BusinessAdapter input) throws ClassNotFoundException { DocumentModel document = input.getDocument(); session.saveDocument(document); return input; }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel input) { input.removeFacet(facet); if (save) { input = session.saveDocument(input); } return input; }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { DocumentHelper.removeProperty(doc, xpath); if (save) { doc = session.saveDocument(doc); } return doc; }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel input) { input.addFacet(facet); if (save) { input = session.saveDocument(input); } return input; }
@Override public void run() { for (Task task : tasks) { DocumentModel taskDoc = task.getDocument(); taskDoc.addFacet(DocumentRoutingConstants.ROUTING_TASK_FACET_NAME); session.saveDocument(taskDoc); } } }.runUnrestricted();
@Override public void run() { DocumentModel doc = session.getSourceDocument(docRef); if (doc != null) { doc.setPropertyValue(xpath, value); session.saveDocument(doc); } }
@PUT @Path("{adapterName}") @Consumes(MediaType.APPLICATION_JSON) public Object doPostAdapter(@PathParam("adapterName") String adapterName, BusinessAdapter input) { ctx.getCoreSession().saveDocument(input.getDocument()); ctx.getCoreSession().save(); return new DefaultJsonAdapter(input); }
@DELETE public Response doDelete() { try { doc.getProperty(xpath).remove(); } catch (PropertyNotFoundException e) { throw new NuxeoException("Failed to delete attached file into property: " + xpath, e, SC_BAD_REQUEST); } CoreSession session = ctx.getCoreSession(); session.saveDocument(doc); session.save(); return Response.noContent().build(); }
@Override public void removeForcedType(String type, boolean save) { List<String> types = getForcedTypes(); if (types.contains(type)) { types.remove(type); String[] typesArray = types.toArray(new String[types.size()]); getAdaptedDoc().setPropertyValue(TemplateSourceDocumentAdapterImpl.TEMPLATE_FORCED_TYPES_PROP, typesArray); if (save) { adaptedDoc = getAdaptedDoc().getCoreSession().saveDocument(getAdaptedDoc()); } } }
@Override public DocumentModel updateDocumentFromBlob(CoreSession documentManager, Blob input, String path, String fullName) { String filename = FileManagerUtils.fetchFileName(fullName); DocumentModel doc = FileManagerUtils.getExistingDocByFileName(documentManager, path, filename); if (doc != null) { doc.setProperty("file", "content", input); documentManager.saveDocument(doc); documentManager.save(); log.debug("Updated the document: {}", doc::getName); } return doc; }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel target) throws OperationException { resetSchemaProperties(target); if (saveDocument) { target = session.saveDocument(target); if (save) { session.save(); } } return target; } }
protected void saveDocument(CoreSession session, DocumentModel doc) { doc.putContextData(VersioningService.DISABLE_AUTO_CHECKOUT, Boolean.TRUE); doc.putContextData(DISABLE_VERSIONING, Boolean.TRUE); doc.putContextData(DISABLE_DUBLINCORE_LISTENER, Boolean.TRUE); doc.putContextData(DISABLE_AUDIT_LOGGER, Boolean.TRUE); session.saveDocument(doc); }
protected void setPermissionOnDocument(CoreSession session, String userOrGroup, String permission) { ACP acp = document.getACP(); ACL routingACL = acp.getOrCreateACL(DocumentRoutingConstants.DOCUMENT_ROUTING_ACL); routingACL.add(new ACE(userOrGroup, permission, true)); document.setACP(acp, true); session.saveDocument(document); }
public void saveLocalConfiguration() { documentManager.saveDocument(navigationContext.getCurrentDocument()); navigationContext.invalidateCurrentDocument(); Events.instance().raiseEvent(EventNames.LOCAL_CONFIGURATION_CHANGED, navigationContext.getCurrentDocument()); facesMessages.add(StatusMessage.Severity.INFO, resourcesAccessor.getMessages().get(LOCAL_CONFIGURATION_CHANGED_LABEL)); }
@Override public void removeSubscriptions(String username, List<String> notifications, DocumentModel doc) { CoreInstance.doPrivileged(doc.getRepositoryName(), (CoreSession session) -> { SubscriptionAdapter sa = doc.getAdapter(SubscriptionAdapter.class); for (String notification : notifications) { sa.removeUserNotificationSubscription(username, notification); } disableEvents(doc); session.saveDocument(doc); restoreEvents(doc); }); }
public static DocumentModel updateDocument(WebContext ctx, DocumentModel doc) { FormData form = ctx.getForm(); form.fillDocument(doc); doc.putContextData(VersioningService.VERSIONING_OPTION, form.getVersioningOption()); doc = ctx.getCoreSession().saveDocument(doc); ctx.getCoreSession().save(); return doc; }
public void toggleConfigurationForCurrentDocument(String configurationFacet) { DocumentModel currentDocument = navigationContext.getCurrentDocument(); if (currentDocument.hasFacet(configurationFacet)) { currentDocument.removeFacet(configurationFacet); } else { currentDocument.addFacet(configurationFacet); } documentManager.saveDocument(currentDocument); navigationContext.invalidateCurrentDocument(); documentManager.save(); Events.instance().raiseEvent(EventNames.LOCAL_CONFIGURATION_CHANGED, navigationContext.getCurrentDocument()); }