Package org.activiti.engine.impl.persistence.entity

Examples of org.activiti.engine.impl.persistence.entity.ResourceEntity


    }
    if(resourceName == null) {
      throw new ActivitiException("resourceName is null");
    }
   
    ResourceEntity resource = commandContext
      .getResourceManager()
      .findResourceByDeploymentIdAndResourceName(deploymentId, resourceName);
    if(resource == null) {
      throw new ActivitiException("no resource found with name '" + resourceName + "' in deployment '" + deploymentId + "'");
    }
    return new ByteArrayInputStream(resource.getBytes());
  }
View Full Code Here


  protected boolean deploymentsDiffer(DeploymentEntity deployment, DeploymentEntity saved) {
    Map<String, ResourceEntity> resources = deployment.getResources();
    Map<String, ResourceEntity> savedResources = saved.getResources();
   
    for (String resourceName: resources.keySet()) {
      ResourceEntity savedResource = savedResources.get(resourceName);
     
      if(savedResource == null) return true;
     
      if(!savedResource.isGenerated()) {
        ResourceEntity resource = resources.get(resourceName);
       
        byte[] bytes = resource.getBytes();
        byte[] savedBytes = savedResource.getBytes();
        if (!Arrays.equals(bytes, savedBytes)) {
          return true;
        }
      }
View Full Code Here

  }

  protected String getFormTemplateString(FormData formInstance, String formKey) {
    String deploymentId = formInstance.getDeploymentId();
   
    ResourceEntity resourceStream = Context
      .getCommandContext()
      .getResourceEntityManager()
      .findResourceByDeploymentIdAndResourceName(deploymentId, formKey);
   
    if (resourceStream == null) {
      throw new ActivitiObjectNotFoundException("Form with formKey '"+formKey+"' does not exist", String.class);
    }
   
    byte[] resourceBytes = resourceStream.getBytes();
    String encoding = "UTF-8";
    String formTemplateString = "";
    try {
      formTemplateString = new String(resourceBytes, encoding);
    } catch (UnsupportedEncodingException e) {
View Full Code Here

    final ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    for (String resourceName : resources.keySet()) {

      LOG.info("Processing resource {}", resourceName);
      if (isBpmnResource(resourceName)) {
        ResourceEntity resource = resources.get(resourceName);
        byte[] bytes = resource.getBytes();
        ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
       
        BpmnParse bpmnParse = bpmnParser
          .createParse()
          .sourceInputStream(inputStream)
View Full Code Here

    }
    return bpmnFileResource;
  }

  protected void createResource(String name, byte[] bytes, DeploymentEntity deploymentEntity) {
    ResourceEntity resource = new ResourceEntity();
    resource.setName(name);
    resource.setBytes(bytes);
    resource.setDeploymentId(deploymentEntity.getId());
   
    // Mark the resource as 'generated'
    resource.setGenerated(true);
   
    Context
      .getCommandContext()
      .getDbSqlSession()
      .insert(resource);
View Full Code Here

      throw new ActivitiObjectNotFoundException("Process definition does not exist: " + processDefinitionId, ProcessDefinitionEntity.class);
    }

    // Fetch the resource
    String resourceName = processDefinitionEntity.getResourceName();
    ResourceEntity resource = commandContext.getResourceEntityManager()
            .findResourceByDeploymentIdAndResourceName(processDefinitionEntity.getDeploymentId(), resourceName);
    if (resource == null) {
      if (commandContext.getDeploymentEntityManager().findDeploymentById(processDefinitionEntity.getDeploymentId()) == null) {
        throw new ActivitiObjectNotFoundException("deployment for process definition does not exist: "
      + processDefinitionEntity.getDeploymentId(), Deployment.class);
      } else {
        throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName
                + "' in deployment '" + processDefinitionEntity.getDeploymentId() + "'", InputStream.class);
      }
    }
   
    // Convert the bpmn 2.0 xml to a bpmn model
    BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
    return bpmnXMLConverter.convertToBpmnModel(new BytesStreamSource(resource.getBytes()), false, false); // no need to validate schema, it was already validated on deploy
  }
View Full Code Here

  public DeploymentBuilder addInputStream(String resourceName, InputStream inputStream) {
    if (inputStream==null) {
      throw new ActivitiIllegalArgumentException("inputStream for resource '"+resourceName+"' is null");
    }
    byte[] bytes = IoUtil.readInputStream(inputStream, resourceName);
    ResourceEntity resource = new ResourceEntity();
    resource.setName(resourceName);
    resource.setBytes(bytes);
    deployment.addResource(resource);
    return this;
  }
View Full Code Here

  public DeploymentBuilder addString(String resourceName, String text) {
    if (text==null) {
      throw new ActivitiIllegalArgumentException("text is null");
    }
    ResourceEntity resource = new ResourceEntity();
    resource.setName(resourceName);
    try {
      resource.setBytes(text.getBytes(DEFAULT_ENCODING));
    } catch (UnsupportedEncodingException e) {
      throw new ActivitiException("Unable to get process bytes.", e);
    }
    deployment.addResource(resource);
    return this;
View Full Code Here

      ZipEntry entry = zipInputStream.getNextEntry();
      while (entry != null) {
        if (!entry.isDirectory()) {
          String entryName = entry.getName();
          byte[] bytes = IoUtil.readInputStream(zipInputStream, entryName);
          ResourceEntity resource = new ResourceEntity();
          resource.setName(entryName);
          resource.setBytes(bytes);
          deployment.addResource(resource);
        }
        entry = zipInputStream.getNextEntry();
      }
    } catch (Exception e) {
View Full Code Here

   
    Map<String, ResourceEntity> resources = deployment.getResources();
    Map<String, ResourceEntity> savedResources = saved.getResources();
   
    for (String resourceName: resources.keySet()) {
      ResourceEntity savedResource = savedResources.get(resourceName);
     
      if(savedResource == null) return true;
     
      if(!savedResource.isGenerated()) {
        ResourceEntity resource = resources.get(resourceName);
       
        byte[] bytes = resource.getBytes();
        byte[] savedBytes = savedResource.getBytes();
        if (!Arrays.equals(bytes, savedBytes)) {
          return true;
        }
      }
View Full Code Here

TOP

Related Classes of org.activiti.engine.impl.persistence.entity.ResourceEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.