protected String getScxmlId() { final RepositoryMap workflowConfiguration = getWorkflowContext().getWorkflowConfiguration(); // check if a custom scxml-definition identifier is configured for this workflow instance if (workflowConfiguration != null && workflowConfiguration.exists() && workflowConfiguration.get(SCXML_DEFINITION_KEY) instanceof String) { // use custom scxml-definition identifier return (String) workflowConfiguration.get(SCXML_DEFINITION_KEY); } return "documentworkflow"; }
public TranslateWorkflowImpl(WorkflowContext context, Session userSession, Session rootSession, Node subject) throws RemoteException, RepositoryException { this.session = rootSession; this.subject = session.getNodeByIdentifier(subject.getIdentifier()); RepositoryMap config = context.getWorkflowConfiguration(); googleKey = (String) config.get("google.key"); String timeoutParameter = (String) config.get("timeout"); if (timeoutParameter != null) { timeout = Integer.parseInt(timeoutParameter); } }
protected Node copyDocument(String targetName, Map<String, String> arguments, Node source, Node handle) throws WorkflowException, ValueFormatException, RepositoryException { RepositoryMap config = workflowContext.getWorkflowConfiguration(); Object modifyOnCopy = config.get("modify-on-copy"); Map<String, String[]> renames = new TreeMap<>(); if (arguments.containsKey("name")) { log.warn("Arguments key 'name' ({}) is ignored, using targetName ({}) instead", arguments.get("name"), targetName); } renames.put("name", new String[] { targetName }); if (modifyOnCopy != null) { String[] params; if (modifyOnCopy instanceof String[]) { params = (String[]) modifyOnCopy; } else if (modifyOnCopy instanceof String) { params = new String[] {(String) modifyOnCopy}; } else { throw new WorkflowException("Invalid workflow configuration; expected multi-valued String for property modify-on-copy"); } populateRenames(renames, params, handle, arguments); } final ExpandingCopyHandler handler = new ExpandingCopyHandler(handle, renames, rootSession.getValueFactory()); return JcrUtils.copyTo(source, handler); }
private String getFolderWorkflowCategory() { String folderWorkflowCategory = "internal"; RepositoryMap config = getWorkflowContext().getWorkflowConfiguration(); if (config != null && config.exists() && config.get("folder-workflow-category") instanceof String) { folderWorkflowCategory = (String) config.get("folder-workflow-category"); } return folderWorkflowCategory; }
@SuppressWarnings("unchecked") protected DocumentHandle createDocumentHandle(Node node) throws WorkflowException { final RepositoryMap workflowConfiguration = getWorkflowContext().getWorkflowConfiguration(); Object configurationValue; if (workflowConfiguration != null && workflowConfiguration.exists() && (configurationValue = workflowConfiguration.get(DOCUMENT_HANDLE_FACTORY_CLASS_KEY)) != null) { String className = configurationValue.toString().trim(); if (!className.isEmpty()) { try { Class<DocumentHandleFactory> clazz = (Class<DocumentHandleFactory>) Class.forName(className); return clazz.newInstance().createDocumentHandle(node); } catch (ClassNotFoundException|InstantiationException|IllegalAccessException|ClassCastException e) { throw new WorkflowException("Invalid document handle factory class '"+className+"'", e); } } } return new DocumentHandle(node); }
public void archive(Document document) throws WorkflowException, MappingException, RepositoryException, RemoteException { String atticPath = null; RepositoryMap config = workflowContext.getWorkflowConfiguration(); if(config.exists() && config.get(ATTIC) instanceof String) { atticPath = (String) config.get(ATTIC); } if (atticPath == null) { throw new WorkflowException("No attic for archivation defined"); } String path = subject.getPath(); Node folderNode = rootSession.getNode(path); Node documentNode = document.getNode(rootSession); if (documentNode.getPath().startsWith(path + "/")) { if (documentNode.isNodeType(HippoNodeType.NT_DOCUMENT) && documentNode.getParent().isNodeType(NT_HANDLE)) { documentNode = documentNode.getParent(); } if (subject.getPath().equals(atticPath)) { documentNode.remove(); folderNode.save(); } else { doArchive(documentNode, atticPath); } } }
public void archive(String name) throws WorkflowException, MappingException, RepositoryException, RemoteException { String atticPath = null; RepositoryMap config = workflowContext.getWorkflowConfiguration(); if(config.exists() && config.get(ATTIC) instanceof String) { atticPath = (String) config.get(ATTIC); } if (atticPath == null) { throw new WorkflowException("No attic for archivation defined"); } if (!rootSession.nodeExists(atticPath)) { throw new WorkflowException("Attic " + atticPath + " for archivation does not exist"); } if(name.startsWith("/")) { name = name.substring(1); } String path = subject.getPath(); Node folder = rootSession.getNode(path); if (folder.hasNode(name)) { Node offspring = folder.getNode(name); if (offspring.isNodeType(HippoNodeType.NT_DOCUMENT) && offspring.getParent().isNodeType(NT_HANDLE)) { offspring = offspring.getParent(); } if (subject.getPath().equals(atticPath)) { offspring.remove(); folder.save(); } else { doArchive(offspring, atticPath); } } }
public void move(Document destination, String newName) throws MappingException, RemoteException, WorkflowException, RepositoryException { ReviewedActionsWorkflowImpl.log.info("move document"); if(current != null) throw new WorkflowException("cannot move document with pending request"); if(publishedDocument != null) throw new WorkflowException("cannot move published document"); if(draftDocument != null) throw new WorkflowException("cannot move document being edited"); Document folder = getWorkflowContext().getDocument("embedded", unpublishedDocument.getIdentity()); String folderWorkflowCategory = "internal"; RepositoryMap config = getWorkflowContext().getWorkflowConfiguration(); if (config != null && config.exists() && config.get("folder-workflow-category") instanceof String) { folderWorkflowCategory = (String) config.get("folder-workflow-category"); } Workflow workflow = getWorkflowContext().getWorkflow(folderWorkflowCategory, folder); if(workflow instanceof FolderWorkflow) ((FolderWorkflow)workflow).move(unpublishedDocument, destination, newName); else throw new WorkflowException("cannot move document which is not contained in a folder"); }
public void copy(Document destination, String newName) throws MappingException, RemoteException, WorkflowException, RepositoryException { ReviewedActionsWorkflowImpl.log.info("copy document"); if (newName == null || newName.equals("")) { throw new WorkflowException("missing required name to copy document"); } if(publishedDocument == null && unpublishedDocument == null) throw new WorkflowException("cannot copy unsaved document"); String folderWorkflowCategory = "embedded"; RepositoryMap config = getWorkflowContext().getWorkflowConfiguration(); if (config != null && config.exists() && config.get("folder-workflow-category") instanceof String) { folderWorkflowCategory = (String) config.get("folder-workflow-category"); } if (unpublishedDocument == null) { Document folder = getWorkflowContext().getDocument("embedded", publishedDocument.getIdentity()); Workflow workflow = getWorkflowContext(null).getWorkflow(folderWorkflowCategory, destination); if (workflow instanceof EmbedWorkflow) { Document copy = ((EmbedWorkflow)workflow).copyTo(folder, publishedDocument, newName, null); FullReviewedActionsWorkflow copiedDocumentWorkflow = (FullReviewedActionsWorkflow) getWorkflowContext(null).getWorkflow("default", copy); copiedDocumentWorkflow.depublish(); } else throw new WorkflowException("cannot copy document which is not contained in a folder"); } else { Document folder = getWorkflowContext().getDocument("embedded", unpublishedDocument.getIdentity()); Workflow workflow = getWorkflowContext().getWorkflow(folderWorkflowCategory, destination); if(workflow instanceof EmbedWorkflow) ((EmbedWorkflow)workflow).copyTo(folder, unpublishedDocument, newName, null); else throw new WorkflowException("cannot copy document which is not contained in a folder"); } }