WorkflowDescriptorImpl(WorkflowManagerImpl manager, String category, WorkflowDefinition definition, Document document) throws RepositoryException { this(manager, category, definition, document.getIdentity()); }
/** * Checks if specific privileges (e.g. hippo:editor) are granted to the current workflow context its * {@link WorkflowContext#getSubjectSession()} for a specific {@link org.hippoecm.repository.api.Document}. * <p> Implementation note: previously evaluated privileges are cached against the Document node's identifier * within the SCXMLWorkflowContext instance </p> * * @param document the document to check permission for * @param privileges the privileges (, separated) to check permission for * @return true if the current subject session has been granted all the specified privileges for the document node */ public final boolean isGranted(Document document, String privileges) { if (document == null) { return false; } return isGranted(document.getIdentity(), privileges); }
private String getReturnValue(Object returnObject) { if (returnObject == null) { return null; } if (returnObject instanceof Document) { Document document = (Document) returnObject; StringBuilder sb = new StringBuilder(); sb.append("document[uuid="); sb.append(document.getIdentity()); if (document.getIdentity() != null) { sb.append(",path='"); try { sb.append(document.getNode(session).getPath()); } catch (RepositoryException e) { sb.append("error:").append(e.getMessage()); } } sb.append("']"); return sb.toString(); } else { return returnObject.toString(); } }
private Node getDocumentNode(Session session, Document document) { if (document == null || document.getIdentity() == null) { log.error("Cannot retrieve workflow for null document"); return null; } try { return document.getNode(session); } catch (ItemNotFoundException e) { log.error("Document not found {}", e.getMessage()); } catch (RepositoryException e) { log.error("Unexpected error {}", e.getMessage(), e); } return null; }
public WorkflowDescriptor getWorkflowDescriptor(String category, Document document) throws RepositoryException { WorkflowDefinition workflowDefinition = getWorkflowDefinition(category, getDocumentNode(userSession, document)); if (workflowDefinition != null) { return new WorkflowDescriptorImpl(this, category, workflowDefinition, document); } log.debug("Workflow for category " + category + " on " + document.getIdentity() + " is not available"); return null; }
public WorkflowDescriptor getWorkflowDescriptor(String category, Document document) throws RepositoryException { try { RemoteWorkflowDescriptor remoteDescriptor = remote.getWorkflowDescriptor(category, document.getIdentity()); if (remoteDescriptor != null) { return new ClientWorkflowDescriptor(remoteDescriptor); } else { return null; } } catch(RemoteException ex) { throw new RemoteRuntimeException(ex); } }
public WorkflowDescriptor getWorkflowDescriptor(String category, Document document) throws RepositoryException { try { RemoteWorkflowDescriptor remoteWorkflowDescriptor = remote.getWorkflowDescriptor(category, document.getIdentity()); if (remoteWorkflowDescriptor == null) { return null; } else { return new ClientWorkflowDescriptor(remoteWorkflowDescriptor); } } catch (RemoteException ex) { throw new RepositoryException(ex); } }
public Workflow getWorkflow(String category, Document document) throws MappingException, RepositoryException { try { RemoteWorkflowDescriptor remoteWorkflowDescriptor = remote.getWorkflowDescriptor(category, document.getIdentity()); if (remoteWorkflowDescriptor == null) { return null; } else { return remote.getWorkflow(remoteWorkflowDescriptor); } } catch (RemoteException ex) { throw new RepositoryException(ex); } }
/** * The node model for the nt:version node that corresponds to this revision. */ public IModel<Node> getDocument() { if (versionModel == null) { versionModel = new JcrNodeModel((Node) null); try { DocumentWorkflow workflow = history.getWorkflow(); if (workflow != null) { Document doc = workflow.retrieveVersion(date); if (doc != null) { final Node frozenNode = UserSession.get().getJcrSession().getNodeByIdentifier(doc.getIdentity()); versionModel = new JcrNodeModel(frozenNode.getParent()); } } } catch (ItemNotFoundException e) { log.error("Could not find version", e); } catch (RepositoryException e) { log.error("Repository error", e); } catch (RemoteException e) { log.error("Connection error", e); } catch (WorkflowException e) { log.error("Workflow error", e); } } return versionModel; }
/** * The node model for the nt:version node that corresponds to this revision. */ public IModel<Node> getDocument() { if (versionModel == null) { versionModel = new JcrNodeModel((Node) null); VersionWorkflow workflow = history.getWorkflow(); if (workflow != null) { try { Document doc = workflow.retrieve(date); if (doc != null) { versionModel = new JcrNodeModel(((UserSession) Session.get()).getJcrSession().getNodeByUUID( doc.getIdentity()).getParent()); } } catch (ItemNotFoundException e) { log.error("Could not find version", e); } catch (RepositoryException e) { log.error("Repository error", e); } catch (RemoteException e) { log.error("Connection error", e); } catch (WorkflowException e) { log.error("Workflow error", e); } } } return versionModel; }
Set<String> allTextFields = new TreeSet<>(); String primaryNodeTypeName = session.getNodeByIdentifier( translatedVariant.getIdentity()).getPrimaryNodeType().getName(); collectFields(null, primaryNodeTypeName, plainTextFields, richTextFields); allTextFields.addAll(plainTextFields); IBrowseService<JcrNodeModel> browser = getBrowserService(); if (browser != null) { browser.browse(new JcrNodeModel(session.getNodeByIdentifier(translatedDocument.getIdentity()))); } else { log.warn(
@Override protected String execute(Workflow wf) throws Exception { DocumentWorkflow workflow = (DocumentWorkflow) wf; Document docRef = workflow.obtainEditableInstance(); Session session = UserSession.get().getJcrSession(); session.refresh(true); Node docNode = session.getNodeByIdentifier(docRef.getIdentity()); IEditorManager editorMgr = getPluginContext().getService( getPluginConfig().getString(IEditorManager.EDITOR_ID), IEditorManager.class); if (editorMgr != null) { JcrNodeModel docModel = new JcrNodeModel(docNode); IEditor editor = editorMgr.getEditor(docModel); if (editor == null) { editorMgr.openEditor(docModel); } } else { log.warn("No editor found to edit {}", docNode.getPath()); } return null; } };
@Override protected String execute(Workflow wf) throws Exception { FullReviewedActionsWorkflow workflow = (FullReviewedActionsWorkflow) wf; Document docRef = workflow.obtainEditableInstance(); ((UserSession) getSession()).getJcrSession().refresh(true); Node docNode = ((UserSession) getSession()).getJcrSession().getNodeByUUID(docRef.getIdentity()); IEditorManager editorMgr = getPluginContext().getService( getPluginConfig().getString(IEditorManager.EDITOR_ID), IEditorManager.class); if (editorMgr != null) { JcrNodeModel docModel = new JcrNodeModel(docNode); IEditor editor = editorMgr.getEditor(docModel); if (editor == null) { editorMgr.openEditor(docModel); } } else { log.warn("No editor found to edit {}", docNode.getPath()); } return null; } });
@Override protected String execute(Workflow wf) throws Exception { BasicReviewedActionsWorkflow workflow = (BasicReviewedActionsWorkflow) wf; Document docRef = workflow.obtainEditableInstance(); ((UserSession) getSession()).getJcrSession().refresh(true); Node docNode = ((UserSession) getSession()).getJcrSession().getNodeByUUID(docRef.getIdentity()); IEditorManager editorMgr = getPluginContext().getService( getPluginConfig().getString(IEditorManager.EDITOR_ID), IEditorManager.class); if (editorMgr != null) { JcrNodeModel docModel = new JcrNodeModel(docNode); IEditor editor = editorMgr.getEditor(docModel); if (editor == null) { editorMgr.openEditor(docModel); } } else { log.warn("No editor found to edit {}", docNode.getPath()); } return null; } });
JcrNodeModel unpubModel = new JcrNodeModel(session.getNodeByUUID(doc.getIdentity())); IEditorManager editorMgr = getEditorManager(); IEditor editor = editorMgr.getEditor(unpubModel);
EditableWorkflow ewf = (EditableWorkflow) wf; document = ewf.obtainEditableInstance(); String uuid = document.getIdentity();
GalleryWorkflow workflow = (GalleryWorkflow) manager.getWorkflow("gallery", folderNode); Document document = workflow.createGalleryItem(nodeName, galleryType, filename); node = (HippoNode) UserSession.get().getJcrSession().getNodeByIdentifier(document.getIdentity()); DefaultWorkflow defaultWorkflow = (DefaultWorkflow) manager.getWorkflow("core", node); if (!node.getDisplayName().equals(localName)) {
JcrNodeModel previewModel = new JcrNodeModel(session.getNodeByIdentifier(doc.getIdentity())); IEditorManager editorMgr = getEditorManager(); IEditor editor = editorMgr.getEditor(previewModel);
EditableWorkflow ewf = (EditableWorkflow) wf; document = ewf.obtainEditableInstance(); String uuid = document.getIdentity();
@Override public Object doExecute() throws WorkflowException, RepositoryException, RemoteException { if (getVariant() == null || !getVariant().hasNode() || getTarget() == null || getTarget().getIdentity() == null || getHistoric() == null) { throw new WorkflowException("Variant, target or date not provided"); } Node targetNode = getTarget().getNode(getWorkflowContext().getInternalWorkflowSession()); Node variantNode = getVariant().getNode(getWorkflowContext().getInternalWorkflowSession()); final Version version = lookupVersion(variantNode, getHistoric()); if (version != null) { clear(targetNode); restore(targetNode, version.getFrozenNode()); targetNode.save(); return new DocumentVariant(targetNode); } return null; }