Search in sources :

Example 56 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class ProcessDiagramLayoutFactory method parseXml.

protected Document parseXml(InputStream bpmnXmlStream) {
    // Initiate DocumentBuilderFactory
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    // Get one that understands namespaces
    factory.setNamespaceAware(true);
    DocumentBuilder builder;
    Document bpmnModel;
    try {
        // Get DocumentBuilder
        builder = factory.newDocumentBuilder();
        // Parse and load the Document into memory
        bpmnModel = builder.parse(bpmnXmlStream);
    } catch (Exception e) {
        throw new ActivitiException("Error while parsing BPMN model.", e);
    }
    return bpmnModel;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Document(org.w3c.dom.Document) ActivitiException(org.activiti.engine.ActivitiException) XPathExpressionException(javax.xml.xpath.XPathExpressionException) IOException(java.io.IOException)

Example 57 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class ProcessDiagramLayoutFactory method getDiagramBoundsFromImage.

protected DiagramNode getDiagramBoundsFromImage(InputStream imageStream, int offsetTop, int offsetBottom) {
    BufferedImage image;
    try {
        image = ImageIO.read(imageStream);
    } catch (IOException e) {
        throw new ActivitiException("Error while reading process diagram image.", e);
    }
    DiagramNode diagramBoundsImage = getDiagramBoundsFromImage(image, offsetTop, offsetBottom);
    return diagramBoundsImage;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) DiagramNode(org.activiti.engine.repository.DiagramNode) IOException(java.io.IOException) BufferedImage(java.awt.image.BufferedImage)

Example 58 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class DeploymentUploadReceiver method deployUploadedFile.

protected void deployUploadedFile() {
    DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().name(fileName);
    DeploymentFilter deploymentFilter = ExplorerApp.get().getComponentFactory(DeploymentFilterFactory.class).create();
    try {
        try {
            if (fileName.endsWith(".bpmn20.xml") || fileName.endsWith(".bpmn")) {
                validFile = true;
                deploymentBuilder.addInputStream(fileName, new ByteArrayInputStream(outputStream.toByteArray()));
            } else if (fileName.endsWith(".bar") || fileName.endsWith(".zip")) {
                validFile = true;
                deploymentBuilder.addZipInputStream(new ZipInputStream(new ByteArrayInputStream(outputStream.toByteArray())));
            } else {
                notificationManager.showErrorNotification(Messages.DEPLOYMENT_UPLOAD_INVALID_FILE, i18nManager.getMessage(Messages.DEPLOYMENT_UPLOAD_INVALID_FILE_EXPLANATION));
            }
            // If the deployment is valid, run it through the beforeDeploy and actually deploy it in Activiti
            if (validFile) {
                deploymentFilter.beforeDeploy(deploymentBuilder);
                deployment = deploymentBuilder.deploy();
            }
        } catch (ActivitiException e) {
            String errorMsg = e.getMessage().replace(System.getProperty("line.separator"), "<br/>");
            notificationManager.showErrorNotification(Messages.DEPLOYMENT_UPLOAD_FAILED, errorMsg);
            throw e;
        }
    } finally {
        if (outputStream != null) {
            try {
                outputStream.close();
            } catch (IOException e) {
                notificationManager.showErrorNotification("Server-side error", e.getMessage());
            }
        }
    }
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) ActivitiException(org.activiti.engine.ActivitiException) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) DeploymentBuilder(org.activiti.engine.repository.DeploymentBuilder)

Example 59 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class IdentityServiceUserDetailsService method loadUserByUsername.

@Override
public UserDetails loadUserByUsername(String userId) throws UsernameNotFoundException {
    User user = null;
    try {
        user = this.identityService.createUserQuery().userId(userId).singleResult();
    } catch (ActivitiException ex) {
    // don't care
    }
    if (null == user) {
        throw new UsernameNotFoundException(String.format("user (%s) could not be found", userId));
    }
    // if the results not null then its active...
    boolean active = true;
    // get the granted authorities
    List<GrantedAuthority> grantedAuthorityList = new ArrayList<GrantedAuthority>();
    List<Group> groupsForUser = identityService.createGroupQuery().groupMember(user.getId()).list();
    for (Group g : groupsForUser) {
        grantedAuthorityList.add(new GroupGrantedAuthority(g));
    }
    return new org.springframework.security.core.userdetails.User(user.getId(), user.getPassword(), active, active, active, active, grantedAuthorityList);
}
Also used : UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) Group(org.activiti.engine.identity.Group) ActivitiException(org.activiti.engine.ActivitiException) User(org.activiti.engine.identity.User) GrantedAuthority(org.springframework.security.core.GrantedAuthority) ArrayList(java.util.ArrayList)

Example 60 with ActivitiException

use of org.activiti.engine.ActivitiException in project midpoint by Evolveum.

the class MiscDataUtil method isAmongCandidates.

// principal != null, principal.getOid() != null, principal.getUser() != null
private boolean isAmongCandidates(MidPointPrincipal principal, String taskId) {
    String currentUserOid = principal.getOid();
    List<IdentityLink> identityLinks;
    try {
        TaskService taskService = activitiEngine.getTaskService();
        identityLinks = taskService.getIdentityLinksForTask(taskId);
    } catch (ActivitiException e) {
        throw new SystemException("Couldn't determine user authorization, because the task candidate users and groups couldn't be retrieved: " + e.getMessage(), e);
    }
    for (IdentityLink identityLink : identityLinks) {
        if (identityLink.getUserId() != null && identityLink.getUserId().equals(currentUserOid)) {
            return true;
        }
        if (identityLink.getGroupId() != null) {
            if (isMemberOfActivitiGroup(principal.getUser(), identityLink.getGroupId())) {
                return true;
            }
        }
    }
    return false;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskService(org.activiti.engine.TaskService) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) IdentityLink(org.activiti.engine.task.IdentityLink)

Aggregations

ActivitiException (org.activiti.engine.ActivitiException)289 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)45 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)44 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)38 IOException (java.io.IOException)35 ArrayList (java.util.ArrayList)25 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)22 ByteArrayOutputStream (java.io.ByteArrayOutputStream)20 FlowElement (org.activiti.bpmn.model.FlowElement)19 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)18 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)17 Expression (org.activiti.engine.delegate.Expression)17 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)17 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)17 ObjectOutputStream (java.io.ObjectOutputStream)15 WorkflowException (org.alfresco.service.cmr.workflow.WorkflowException)15 HashMap (java.util.HashMap)12 ExecutionEntityManager (org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)11 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)11 InputStream (java.io.InputStream)10