protected internal virtual void createJobEntities(BatchEntity batch, DeleteProcessInstanceBatchConfiguration configuration, string deploymentId, IList <string> processInstancesToHandle, int invocationsPerBatchJob) { CommandContext commandContext = Context.CommandContext; ByteArrayManager byteArrayManager = commandContext.ByteArrayManager; JobManager jobManager = commandContext.JobManager; int createdJobs = 0; while (processInstancesToHandle.Count > 0) { int lastIdIndex = Math.Min(invocationsPerBatchJob, processInstancesToHandle.Count); // view of process instances for this job IList <string> idsForJob = processInstancesToHandle.subList(0, lastIdIndex); DeleteProcessInstanceBatchConfiguration jobConfiguration = createJobConfiguration(configuration, idsForJob); ByteArrayEntity configurationEntity = saveConfiguration(byteArrayManager, jobConfiguration); JobEntity job = createBatchJob(batch, configurationEntity); job.DeploymentId = deploymentId; jobManager.insertAndHintJobExecutor(job); createdJobs++; idsForJob.Clear(); } // update created jobs for batch batch.JobsCreated = batch.JobsCreated + createdJobs; // update batch configuration batch.ConfigurationBytes = writeConfiguration(configuration); }
public virtual Void execute(CommandContext commandContext) { ensureNotNull("userId", userId); IdentityInfoEntity pictureInfo = commandContext.IdentityInfoManager.findUserInfoByUserIdAndKey(userId, "picture"); if (pictureInfo != null) { string byteArrayId = pictureInfo.Value; if (!string.ReferenceEquals(byteArrayId, null)) { commandContext.ByteArrayManager.deleteByteArrayById(byteArrayId); } } else { pictureInfo = new IdentityInfoEntity(); pictureInfo.UserId = userId; pictureInfo.Key = "picture"; commandContext.DbEntityManager.insert(pictureInfo); } ByteArrayEntity byteArrayEntity = new ByteArrayEntity(picture.MimeType, picture.Bytes, ResourceTypes.REPOSITORY); commandContext.ByteArrayManager.insertByteArray(byteArrayEntity); pictureInfo.Value = byteArrayEntity.Id; return(null); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testHistoricExceptionStacktraceBinary() public virtual void testHistoricExceptionStacktraceBinary() { // given BpmnModelInstance instance = createFailingProcess(); testRule.deploy(instance); runtimeService.startProcessInstanceByKey("Process"); string jobId = managementService.createJobQuery().singleResult().Id; // when try { managementService.executeJob(jobId); fail(); } catch (Exception) { // expected } HistoricJobLogEventEntity entity = (HistoricJobLogEventEntity)historyService.createHistoricJobLogQuery().failureLog().singleResult(); assertNotNull(entity); ByteArrayEntity byteArrayEntity = configuration.CommandExecutorTxRequired.execute(new GetByteArrayCommand(entity.ExceptionByteArrayId)); checkBinary(byteArrayEntity); }
public override void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { ByteArrayEntity configurationEntity = commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), configuration.ConfigurationByteArrayId); UpdateProcessInstancesSuspendStateBatchConfiguration batchConfiguration = readConfiguration(configurationEntity.Bytes); bool initialLegacyRestrictions = commandContext.RestrictUserOperationLogToAuthenticatedUsers; commandContext.disableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = true; try { if (batchConfiguration.Suspended) { commandContext.ProcessEngineConfiguration.RuntimeService.updateProcessInstanceSuspensionState().byProcessInstanceIds(batchConfiguration.Ids).suspend(); } else { commandContext.ProcessEngineConfiguration.RuntimeService.updateProcessInstanceSuspensionState().byProcessInstanceIds(batchConfiguration.Ids).activate(); } } finally { commandContext.enableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = initialLegacyRestrictions; } }
public override void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { ByteArrayEntity configurationEntity = commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), configuration.ConfigurationByteArrayId); BatchConfiguration batchConfiguration = readConfiguration(configurationEntity.Bytes); bool initialLegacyRestrictions = commandContext.RestrictUserOperationLogToAuthenticatedUsers; commandContext.disableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = true; try { HistoryService historyService = commandContext.ProcessEngineConfiguration.HistoryService; if (batchConfiguration.FailIfNotExists) { historyService.deleteHistoricProcessInstances(batchConfiguration.Ids); } else { historyService.deleteHistoricProcessInstancesIfExists(batchConfiguration.Ids); } } finally { commandContext.enableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = initialLegacyRestrictions; } commandContext.ByteArrayManager.delete(configurationEntity); }
public static ArrayList ExtractDocsFromBulkDocsPost(HttpWebRequest capturedRequest ) { try { if (capturedRequest is HttpPost) { HttpPost capturedPostRequest = (HttpPost)capturedRequest; if (capturedPostRequest.GetURI().GetPath().EndsWith("_bulk_docs")) { ByteArrayEntity entity = (ByteArrayEntity)capturedPostRequest.GetEntity(); InputStream contentStream = entity.GetContent(); IDictionary <string, object> body = Manager.GetObjectMapper().ReadValue <IDictionary >(contentStream); ArrayList docs = (ArrayList)body.Get("docs"); return(docs); } } } catch (IOException e) { throw new RuntimeException(e); } return(null); }
public virtual void setByteArrayValue(sbyte[] bytes, bool isTransient) { if (bytes != null) { // note: there can be cases where byteArrayId is not null // but the corresponding byte array entity has been removed in parallel; // thus we also need to check if the actual byte array entity still exists if (!string.ReferenceEquals(this.byteArrayId, null) && ByteArrayEntity != null) { byteArrayValue.Bytes = bytes; } else { deleteByteArrayValue(); byteArrayValue = new ByteArrayEntity(nameProvider.Name, bytes, type, rootProcessInstanceId, removalTime); // avoid insert of byte array value for a transient variable if (!isTransient) { Context.CommandContext.ByteArrayManager.insertByteArray(byteArrayValue); byteArrayId = byteArrayValue.Id; } } } else { deleteByteArrayValue(); } }
protected internal virtual ByteArrayEntity saveConfiguration(ByteArrayManager byteArrayManager, T jobConfiguration) { ByteArrayEntity configurationEntity = new ByteArrayEntity(); configurationEntity.Bytes = writeConfiguration(jobConfiguration); byteArrayManager.insert(configurationEntity); return(configurationEntity); }
public static string getExceptionStacktrace(ByteArrayEntity byteArray) { string result = null; if (byteArray != null) { result = StringUtil.fromBytes(byteArray.Bytes); } return(result); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testBatchBinary() public virtual void testBatchBinary() { // when helper.migrateProcessInstancesAsync(15); string byteArrayValueId = ((BatchEntity)managementService.createBatchQuery().singleResult()).Configuration; ByteArrayEntity byteArrayEntity = configuration.CommandExecutorTxRequired.execute(new GetByteArrayCommand(byteArrayValueId)); checkBinary(byteArrayEntity); }
/// <summary> /// customized insert behavior for HistoricVariableUpdateEventEntity </summary> protected internal virtual void insertHistoricVariableUpdateEntity(HistoricVariableUpdateEventEntity historyEvent) { DbEntityManager dbEntityManager = DbEntityManager; // insert update only if history level = FULL if (shouldWriteHistoricDetail(historyEvent)) { // insert byte array entity (if applicable) sbyte[] byteValue = historyEvent.ByteValue; if (byteValue != null) { ByteArrayEntity byteArrayEntity = new ByteArrayEntity(historyEvent.VariableName, byteValue, ResourceTypes.HISTORY); byteArrayEntity.RootProcessInstanceId = historyEvent.RootProcessInstanceId; byteArrayEntity.RemovalTime = historyEvent.RemovalTime; Context.CommandContext.ByteArrayManager.insertByteArray(byteArrayEntity); historyEvent.ByteArrayId = byteArrayEntity.Id; } dbEntityManager.insert(historyEvent); } // always insert/update HistoricProcessVariableInstance if (historyEvent.isEventOfType(HistoryEventTypes.VARIABLE_INSTANCE_CREATE)) { HistoricVariableInstanceEntity persistentObject = new HistoricVariableInstanceEntity(historyEvent); dbEntityManager.insert(persistentObject); } else if (historyEvent.isEventOfType(HistoryEventTypes.VARIABLE_INSTANCE_UPDATE) || historyEvent.isEventOfType(HistoryEventTypes.VARIABLE_INSTANCE_MIGRATE)) { HistoricVariableInstanceEntity historicVariableInstanceEntity = dbEntityManager.selectById(typeof(HistoricVariableInstanceEntity), historyEvent.VariableInstanceId); if (historicVariableInstanceEntity != null) { historicVariableInstanceEntity.updateFromEvent(historyEvent); historicVariableInstanceEntity.State = org.camunda.bpm.engine.history.HistoricVariableInstance_Fields.STATE_CREATED; } else { // #CAM-1344 / #SUPPORT-688 // this is a FIX for process instances which were started in camunda fox 6.1 and migrated to camunda BPM 7.0. // in fox 6.1 the HistoricVariable instances were flushed to the DB when the process instance completed. // Since fox 6.2 we populate the HistoricVariable table as we go. HistoricVariableInstanceEntity persistentObject = new HistoricVariableInstanceEntity(historyEvent); dbEntityManager.insert(persistentObject); } } else if (historyEvent.isEventOfType(HistoryEventTypes.VARIABLE_INSTANCE_DELETE)) { HistoricVariableInstanceEntity historicVariableInstanceEntity = dbEntityManager.selectById(typeof(HistoricVariableInstanceEntity), historyEvent.VariableInstanceId); if (historicVariableInstanceEntity != null) { historicVariableInstanceEntity.State = org.camunda.bpm.engine.history.HistoricVariableInstance_Fields.STATE_DELETED; } } }
protected internal virtual bool isHistoricByteArray(DbEntity dbEntity) { if (dbEntity is ByteArrayEntity) { ByteArrayEntity byteArrayEntity = (ByteArrayEntity)dbEntity; return(byteArrayEntity.Type.Equals(ResourceTypes.HISTORY.Value)); } else { return(false); } }
/// <summary> /// create ByteArrayEntity with specified name and payload and make sure it's /// persisted /// /// used in Jobs and ExternalTasks /// </summary> /// <param name="name"> - type\source of the exception </param> /// <param name="byteArray"> - payload of the exception </param> /// <param name="type"> - resource type of the exception </param> /// <returns> persisted entity </returns> public static ByteArrayEntity createExceptionByteArray(string name, sbyte[] byteArray, ResourceType type) { ByteArrayEntity result = null; if (byteArray != null) { result = new ByteArrayEntity(name, byteArray, type); Context.CommandContext.ByteArrayManager.insertByteArray(result); } return(result); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testAttachmentContentBinaries() public virtual void testAttachmentContentBinaries() { // create and save task Task task = taskService.newTask(); taskService.saveTask(task); taskId = task.Id; // when AttachmentEntity attachment = (AttachmentEntity)taskService.createAttachment("web page", taskId, "someprocessinstanceid", "weatherforcast", "temperatures and more", new MemoryStream("someContent".GetBytes())); ByteArrayEntity byteArrayEntity = configuration.CommandExecutorTxRequired.execute(new GetByteArrayCommand(attachment.ContentId)); checkBinary(byteArrayEntity); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testHistoricDetailBinaryForFileValues() public virtual void testHistoricDetailBinaryForFileValues() { // given BpmnModelInstance instance = createProcess(); testRule.deploy(instance); FileValue fileValue = createFile(); runtimeService.startProcessInstanceByKey("Process", Variables.createVariables().putValueTyped("fileVar", fileValue)); string byteArrayValueId = ((HistoricDetailVariableInstanceUpdateEntity)historyService.createHistoricDetailQuery().singleResult()).ByteArrayValueId; // when ByteArrayEntity byteArrayEntity = configuration.CommandExecutorTxRequired.execute(new GetByteArrayCommand(byteArrayValueId)); checkBinary(byteArrayEntity); }
public override void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { ByteArrayEntity configurationEntity = commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), configuration.ConfigurationByteArrayId); RestartProcessInstancesBatchConfiguration batchConfiguration = readConfiguration(configurationEntity.Bytes); bool initialLegacyRestrictions = commandContext.RestrictUserOperationLogToAuthenticatedUsers; commandContext.disableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = true; try { RestartProcessInstanceBuilderImpl builder = (RestartProcessInstanceBuilderImpl)commandContext.ProcessEngineConfiguration.RuntimeService.restartProcessInstances(batchConfiguration.ProcessDefinitionId).processInstanceIds(batchConfiguration.Ids); builder.Instructions = batchConfiguration.Instructions; if (batchConfiguration.InitialVariables) { builder.initialSetOfVariables(); } if (batchConfiguration.SkipCustomListeners) { builder.skipCustomListeners(); } if (batchConfiguration.WithoutBusinessKey) { builder.withoutBusinessKey(); } if (batchConfiguration.SkipIoMappings) { builder.skipIoMappings(); } builder.execute(false); } finally { commandContext.enableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = initialLegacyRestrictions; } commandContext.ByteArrayManager.delete(configurationEntity); }
public virtual Stream execute(CommandContext commandContext) { DbEntityManager dbEntityManger = commandContext.DbEntityManager; AttachmentEntity attachment = dbEntityManger.selectById(typeof(AttachmentEntity), attachmentId); string contentId = attachment.ContentId; if (string.ReferenceEquals(contentId, null)) { return(null); } ByteArrayEntity byteArray = dbEntityManger.selectById(typeof(ByteArrayEntity), contentId); sbyte[] bytes = byteArray.Bytes; return(new MemoryStream(bytes)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testHistoricDecisionInputInstanceBinary() public virtual void testHistoricDecisionInputInstanceBinary() { testRule.deploy(DECISION_PROCESS, DECISION_SINGLE_OUTPUT_DMN); startProcessInstanceAndEvaluateDecision(new JavaSerializable("foo")); HistoricDecisionInstance historicDecisionInstance = engineRule.HistoryService.createHistoricDecisionInstanceQuery().includeInputs().singleResult(); IList <HistoricDecisionInputInstance> inputInstances = historicDecisionInstance.Inputs; assertEquals(1, inputInstances.Count); string byteArrayValueId = ((HistoricDecisionInputInstanceEntity)inputInstances[0]).ByteArrayValueId; // when ByteArrayEntity byteArrayEntity = configuration.CommandExecutorTxRequired.execute(new GetByteArrayCommand(byteArrayValueId)); checkBinary(byteArrayEntity); }
public virtual Picture execute(CommandContext commandContext) { ensureNotNull("userId", userId); IdentityInfoEntity pictureInfo = commandContext.IdentityInfoManager.findUserInfoByUserIdAndKey(userId, "picture"); if (pictureInfo != null) { string pictureByteArrayId = pictureInfo.Value; if (!string.ReferenceEquals(pictureByteArrayId, null)) { ByteArrayEntity byteArray = commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), pictureByteArrayId); return(new Picture(byteArray.Bytes, byteArray.Name)); } } return(null); }
private void SetBody(HttpRequestMessage request) { // set body if appropriate if (body != null && request is HttpEntityEnclosingRequestBase) { byte[] bodyBytes = null; try { bodyBytes = Manager.GetObjectMapper().WriteValueAsBytes(body); } catch (Exception e) { Log.E(Database.Tag, "Error serializing body of request", e); } ByteArrayEntity entity = new ByteArrayEntity(bodyBytes); entity.SetContentType("application/json"); ((HttpEntityEnclosingRequestBase)request).SetEntity(entity); } }
public virtual bool createJobs(BatchEntity batch) { CommandContext commandContext = Context.CommandContext; ByteArrayManager byteArrayManager = commandContext.ByteArrayManager; JobManager jobManager = commandContext.JobManager; T configuration = readConfiguration(batch.ConfigurationBytes); int batchJobsPerSeed = batch.BatchJobsPerSeed; int invocationsPerBatchJob = batch.InvocationsPerBatchJob; IList <string> ids = configuration.Ids; int numberOfItemsToProcess = Math.Min(invocationsPerBatchJob * batchJobsPerSeed, ids.Count); // view of process instances to process IList <string> processIds = ids.subList(0, numberOfItemsToProcess); int createdJobs = 0; while (processIds.Count > 0) { int lastIdIndex = Math.Min(invocationsPerBatchJob, processIds.Count); // view of process instances for this job IList <string> idsForJob = processIds.subList(0, lastIdIndex); T jobConfiguration = createJobConfiguration(configuration, idsForJob); ByteArrayEntity configurationEntity = saveConfiguration(byteArrayManager, jobConfiguration); JobEntity job = createBatchJob(batch, configurationEntity); postProcessJob(configuration, job); jobManager.insertAndHintJobExecutor(job); idsForJob.Clear(); createdJobs++; } // update created jobs for batch batch.JobsCreated = batch.JobsCreated + createdJobs; // update batch configuration batch.ConfigurationBytes = writeConfiguration(configuration); return(ids.Count == 0); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDeleteBatchJobManually() public virtual void testDeleteBatchJobManually() { // given Batch batch = helper.createMigrationBatchWithSize(1); helper.executeSeedJob(batch); JobEntity migrationJob = (JobEntity)helper.getExecutionJobs(batch)[0]; string byteArrayId = migrationJob.JobHandlerConfigurationRaw; ByteArrayEntity byteArrayEntity = engineRule.ProcessEngineConfiguration.CommandExecutorTxRequired.execute(new GetByteArrayCommand(this, byteArrayId)); assertNotNull(byteArrayEntity); // when managementService.deleteJob(migrationJob.Id); // then byteArrayEntity = engineRule.ProcessEngineConfiguration.CommandExecutorTxRequired.execute(new GetByteArrayCommand(this, byteArrayId)); assertNull(byteArrayEntity); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testHistoricVariableBinary() public virtual void testHistoricVariableBinary() { sbyte[] binaryContent = "some binary content".GetBytes(); // given IDictionary <string, object> variables = new Dictionary <string, object>(); variables["binaryVariable"] = binaryContent; Task task = taskService.newTask(); taskService.saveTask(task); taskId = task.Id; taskService.setVariablesLocal(taskId, variables); string byteArrayValueId = ((HistoricVariableInstanceEntity)historyService.createHistoricVariableInstanceQuery().singleResult()).ByteArrayValueId; // when ByteArrayEntity byteArrayEntity = configuration.CommandExecutorTxRequired.execute(new GetByteArrayCommand(byteArrayValueId)); checkBinary(byteArrayEntity); }
public virtual Stream execute(CommandContext commandContext) { AttachmentEntity attachment = (AttachmentEntity)commandContext.AttachmentManager.findAttachmentByTaskIdAndAttachmentId(taskId, attachmentId); if (attachment == null) { return(null); } string contentId = attachment.ContentId; if (string.ReferenceEquals(contentId, null)) { return(null); } ByteArrayEntity byteArray = commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), contentId); sbyte[] bytes = byteArray.Bytes; return(new MemoryStream(bytes)); }
public override void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { ByteArrayEntity configurationEntity = commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), configuration.ConfigurationByteArrayId); SetRetriesBatchConfiguration batchConfiguration = readConfiguration(configurationEntity.Bytes); bool initialLegacyRestrictions = commandContext.RestrictUserOperationLogToAuthenticatedUsers; commandContext.disableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = true; try { commandContext.ProcessEngineConfiguration.ManagementService.setJobRetries(batchConfiguration.Ids, batchConfiguration.Retries); } finally { commandContext.enableUserOperationLog(); commandContext.RestrictUserOperationLogToAuthenticatedUsers = initialLegacyRestrictions; } commandContext.ByteArrayManager.delete(configurationEntity); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testHistoricExternalTaskJobLogStacktraceBinary() public virtual void testHistoricExternalTaskJobLogStacktraceBinary() { // given testRule.deploy("org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml"); runtimeService.startProcessInstanceByKey("oneExternalTaskProcess"); IList <LockedExternalTask> tasks = externalTaskService.fetchAndLock(5, WORKER_ID).topic(TOPIC_NAME, LOCK_TIME).execute(); LockedExternalTask task = tasks[0]; // submitting a failure (after a simulated processing time of three seconds) ClockUtil.CurrentTime = nowPlus(3000L); string errorMessage; string exceptionStackTrace; try { throw new RuntimeSqlException("test cause"); } catch (Exception e) { exceptionStackTrace = ExceptionUtils.getStackTrace(e); errorMessage = e.Message; } assertNotNull(exceptionStackTrace); externalTaskService.handleFailure(task.Id, WORKER_ID, errorMessage, exceptionStackTrace, 5, 3000L); HistoricExternalTaskLogEntity entity = (HistoricExternalTaskLogEntity)historyService.createHistoricExternalTaskLogQuery().errorMessage(errorMessage).singleResult(); assertNotNull(entity); ByteArrayEntity byteArrayEntity = configuration.CommandExecutorTxRequired.execute(new GetByteArrayCommand(entity.ErrorDetailsByteArrayId)); // then checkBinary(byteArrayEntity); }
public override void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { ByteArrayEntity configurationEntity = commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), configuration.ConfigurationByteArrayId); MigrationBatchConfiguration batchConfiguration = readConfiguration(configurationEntity.Bytes); MigrationPlanExecutionBuilder executionBuilder = commandContext.ProcessEngineConfiguration.RuntimeService.newMigration(batchConfiguration.MigrationPlan).processInstanceIds(batchConfiguration.Ids); if (batchConfiguration.SkipCustomListeners) { executionBuilder.skipCustomListeners(); } if (batchConfiguration.SkipIoMappings) { executionBuilder.skipIoMappings(); } // uses internal API in order to skip writing user operation log (CommandContext#disableUserOperationLog // is not sufficient with legacy engine config setting "restrictUserOperationLogToAuthenticatedUsers" = false) ((MigrationPlanExecutionBuilderImpl)executionBuilder).execute(false); commandContext.ByteArrayManager.delete(configurationEntity); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUserPictureBinary() public virtual void testUserPictureBinary() { // when DateTime fixedDate = DateTime.Now; ClockUtil.CurrentTime = fixedDate; User user = identityService.newUser(USER_ID); identityService.saveUser(user); string userId = user.Id; Picture picture = new Picture("niceface".GetBytes(), "image/string"); identityService.setUserPicture(userId, picture); string userInfo = identityService.getUserInfo(USER_ID, "picture"); ByteArrayEntity byteArrayEntity = configuration.CommandExecutorTxRequired.execute(new GetByteArrayCommand(userInfo)); // then assertNotNull(byteArrayEntity); assertEquals(fixedDate.ToString(), byteArrayEntity.CreateTime.ToString()); assertEquals(REPOSITORY.Value, byteArrayEntity.Type); }
public override void execute(BatchJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId) { ByteArrayEntity configurationEntity = commandContext.DbEntityManager.selectById(typeof(ByteArrayEntity), configuration.ConfigurationByteArrayId); ModificationBatchConfiguration batchConfiguration = readConfiguration(configurationEntity.Bytes); ModificationBuilderImpl executionBuilder = (ModificationBuilderImpl)commandContext.ProcessEngineConfiguration.RuntimeService.createModification(batchConfiguration.ProcessDefinitionId).processInstanceIds(batchConfiguration.Ids); executionBuilder.Instructions = batchConfiguration.Instructions; if (batchConfiguration.SkipCustomListeners) { executionBuilder.skipCustomListeners(); } if (batchConfiguration.SkipIoMappings) { executionBuilder.skipIoMappings(); } executionBuilder.execute(false); commandContext.ByteArrayManager.delete(configurationEntity); }
/// <summary> /// Handles the given exception and generates an HTTP response to be sent /// back to the client to inform about the exceptional condition encountered /// in the course of the request processing. /// </summary> /// <remarks> /// Handles the given exception and generates an HTTP response to be sent /// back to the client to inform about the exceptional condition encountered /// in the course of the request processing. /// </remarks> /// <param name="ex">the exception.</param> /// <param name="response">the HTTP response.</param> protected internal virtual void HandleException(HttpException ex, HttpResponse response ) { if (ex is MethodNotSupportedException) { response.SetStatusCode(HttpStatus.ScNotImplemented); } else { if (ex is UnsupportedHttpVersionException) { response.SetStatusCode(HttpStatus.ScHttpVersionNotSupported); } else { if (ex is ProtocolException) { response.SetStatusCode(HttpStatus.ScBadRequest); } else { response.SetStatusCode(HttpStatus.ScInternalServerError); } } } string message = ex.Message; if (message == null) { message = ex.ToString(); } byte[] msg = EncodingUtils.GetAsciiBytes(message); ByteArrayEntity entity = new ByteArrayEntity(msg); entity.SetContentType("text/plain; charset=US-ASCII"); response.SetEntity(entity); }
protected internal virtual void SetBody(HttpRequestMessage request) { // set body if appropriate if (body != null && request is HttpEntityEnclosingRequestBase) { byte[] bodyBytes = null; try { bodyBytes = Manager.GetObjectMapper().WriteValueAsBytes(body); } catch (Exception e) { Log.E(Log.TagRemoteRequest, "Error serializing body of request", e); } ByteArrayEntity entity = new ByteArrayEntity(bodyBytes); entity.SetContentType("application/json"); ((HttpEntityEnclosingRequestBase)request).SetEntity(entity); } }