gt:         if (activitiUtil == null)
context: /*
   * Copyright (C) 2005-2013 Alfresco Software Limited.
   *
   * This file is part of Alfresco
   *
   * Alfresco is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Lesser General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * Alfresco is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public License
   * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
   */
  package org.alfresco.rest.workflow.api.impl;
  
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Date;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  import java.util.UUID;
  
  import org.activiti.bpmn.model.BpmnModel;
  import org.activiti.engine.ActivitiObjectNotFoundException;
  import org.activiti.engine.RuntimeService;
  import org.activiti.engine.form.StartFormData;
  import org.activiti.engine.history.HistoricProcessInstance;
  import org.activiti.engine.history.HistoricProcessInstanceQuery;
  import org.activiti.engine.history.HistoricVariableInstance;
  import org.activiti.engine.impl.identity.Authentication;
  import org.activiti.engine.repository.ProcessDefinition;
  import org.activiti.engine.repository.ProcessDefinitionQuery;
  import org.activiti.engine.runtime.ProcessInstance;
  import org.activiti.image.ProcessDiagramGenerator;
  import org.activiti.image.impl.DefaultProcessDiagramGenerator;
  import org.alfresco.model.ContentModel;
  import org.alfresco.repo.i18n.MessageService;
  import org.alfresco.repo.model.Repository;
  import org.alfresco.repo.security.authentication.AuthenticationUtil;
  import org.alfresco.repo.security.authority.AuthorityDAO;
  import org.alfresco.repo.tenant.TenantUtil;
  import org.alfresco.repo.workflow.DefaultWorkflowPropertyHandler;
  import org.alfresco.repo.workflow.WorkflowAuthorityManager;
  import org.alfresco.repo.workflow.WorkflowConstants;
  import org.alfresco.repo.workflow.WorkflowModel;
  import org.alfresco.repo.workflow.WorkflowObjectFactory;
  import org.alfresco.repo.workflow.WorkflowPackageImpl;
  import org.alfresco.repo.workflow.WorkflowPropertyHandlerRegistry;
  import org.alfresco.repo.workflow.WorkflowQNameConverter;
  import org.alfresco.repo.workflow.activiti.ActivitiConstants;
  import org.alfresco.repo.workflow.activiti.ActivitiNodeConverter;
  import org.alfresco.repo.workflow.activiti.ActivitiTypeConverter;
  import org.alfresco.repo.workflow.activiti.ActivitiUtil;
  import org.alfresco.repo.workflow.activiti.properties.ActivitiPropertyConverter;
  import org.alfresco.rest.antlr.WhereClauseParser;
  import org.alfresco.rest.framework.core.exceptions.ApiException;
  import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
  import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
  import org.alfresco.rest.framework.resource.content.BinaryResource;
  import org.alfresco.rest.framework.resource.content.FileBinaryResource;
  import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
  import org.alfresco.rest.framework.resource.parameters.Paging;
  import org.alfresco.rest.framework.resource.parameters.Parameters;
  import org.alfresco.rest.framework.resource.parameters.SortColumn;
  import org.alfresco.rest.framework.resource.parameters.where.QueryHelper;
  import org.alfresco.rest.workflow.api.Processes;
  import org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker.QueryVariableHolder;
  import org.alfresco.rest.workflow.api.model.Item;
  import org.alfresco.rest.workflow.api.model.ProcessInfo;
  import org.alfresco.rest.workflow.api.model.Variable;
  import org.alfresco.service.ServiceRegistry;
  import org.alfresco.service.cmr.dictionary.AssociationDefinition;
  import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
  import org.alfresco.service.cmr.dictionary.PropertyDefinition;
  import org.alfresco.service.cmr.dictionary.TypeDefinition;
  import org.alfresco.service.cmr.repository.NodeRef;
  import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
  import org.alfresco.service.cmr.security.PersonService;
  import org.alfresco.service.namespace.InvalidQNameException;
  import org.alfresco.service.namespace.QName;
  import org.alfresco.util.ISO8601DateFormat;
  import org.alfresco.util.TempFileProvider;
  import org.alfresco.util.collections.CollectionUtils;
  import org.apache.commons.io.IOUtils;
  
  public class ProcessesImpl extends WorkflowRestImpl implements Processes
  {
      protected static String PROCESS_STATUS_ANY = "any";
      protected static String PROCESS_STATUS_ACTIVE = "active";
      protected static String PROCESS_STATUS_COMPLETED = "completed";
      protected static String PROCESS_STATUS_DELETED = "deleted";
      
      protected static final Set<String> PROCESS_STATUS_LIST = new HashSet<String>(Arrays.asList(
              PROCESS_STATUS_ANY, PROCESS_STATUS_ACTIVE, PROCESS_STATUS_COMPLETED, PROCESS_STATUS_DELETED
      ));
      
      protected static final Set<String> PROCESS_COLLECTION_EQUALS_QUERY_PROPERTIES = new HashSet<String>(Arrays.asList(
          "processDefinitionId", "businessKey", "processDefinitionKey", "startUserId", "status", "includeVariables"
      ));
      
      protected static final Set<String> PROCESS_COLLECTION_GREATERTHAN_QUERY_PROPERTIES = new HashSet<String>(Arrays.asList(
          "startedAt", "endedAt"
      ));
      
      protected static final Set<String> PROCESS_COLLECTION_LESSTHAN_QUERY_PROPERTIES = new HashSet<String>(Arrays.asList(
          "startedAt", "endedAt"
      ));
      
      protected static final Set<String> PROCESS_COLLECTION_SORT_PROPERTIES = new HashSet<String>(Arrays.asList(
          "processDefinitionId", "businessKey", "id", "startedAt", "endedAt", "durationInMillis"
      ));
      
      protected WorkflowPackageImpl workflowPackageComponent;
      protected ServiceRegistry serviceRegistry;
      protected AuthorityDAO authorityDAO;
      protected PersonService personService;
      protected MessageService messageService;
      protected String engineId;
      protected Repository repositoryHelper;
      protected RestVariableHelper restVariableHelper;
      
      protected ActivitiNodeConverter nodeConverter;
      protected ActivitiUtil activitiUtil;
      protected DefaultWorkflowPropertyHandler defaultPropertyHandler;
      protected WorkflowQNameConverter qNameConverter;
      protected QName defaultStartTaskType = WorkflowModel.TYPE_ACTIVTI_START_TASK;
      protected WorkflowObjectFactory workflowFactory;
      protected WorkflowPropertyHandlerRegistry handlerRegistry;
      protected WorkflowAuthorityManager authorityManager;
      protected ActivitiPropertyConverter propertyConverter;
      protected ActivitiTypeConverter typeConverter;
      
      public void setAuthorityDAO(AuthorityDAO authorityDAO)
      {
          this.authorityDAO = authorityDAO;
      }
  
      public void setServiceRegistry(ServiceRegistry serviceRegistry)
      {
          this.serviceRegistry = serviceRegistry;
      }
  
      public void setWorkflowPackageComponent(WorkflowPackageImpl workflowPackageComponent)
      {
          this.workflowPackageComponent = workflowPackageComponent;
      }
  
      public void setPersonService(PersonService personService)
      {
          this.personService = personService;
      }
  
      public void setRepositoryHelper(Repository repositoryHelper)
      {
          this.repositoryHelper = repositoryHelper;
      }
  
      public void setMessageService(MessageService messageService)
      {
          this.messageService = messageService;
      }
      
      public void setEngineId(String engineId)
      {
          this.engineId = engineId;
      }
      
      public void setRestVariableHelper(RestVariableHelper restVariableHelper)
      {
          this.restVariableHelper = restVariableHelper;
      }
  
      protected ActivitiNodeConverter getNodeConverter()
      {
          if (nodeConverter == null)
          {
              nodeConverter = new ActivitiNodeConverter(serviceRegistry);
          }
          return nodeConverter;
      }
      
      protected DefaultWorkflowPropertyHandler getDefaultPropertyHandler()
      {
          if (defaultPropertyHandler == null)
          {
              defaultPropertyHandler = new DefaultWorkflowPropertyHandler();
              defaultPropertyHandler.setMessageService(messageService);
              defaultPropertyHandler.setNodeConverter(getNodeConverter());
          }
          return defaultPropertyHandler;
      }
          
      protected ActivitiUtil getActivitiUtil()
      {
  