Verifies that the decoded diff is identical to the original diff.

@param task
DiffTask
@param decodedDiff
diff created from encoding the decoded diff information
@param originalDiff
original diff

@throws SQLConsumerException
if an error occurs
13151
private void verify(final Task<Diff> task, final Diff decodedDiff,
			final Diff originalDiff)
		throws SQLConsumerException
	{

		String orig = originalDiff.toString();
		String deco = decodedDiff.toString();

		boolean notEqual = !orig.equals(deco);

		if (notEqual && MODE_SURROGATES == SurrogateModes.REPLACE) {

			char[] origDiff = orig.toCharArray();

			// TODO: test
			if (Surrogates.scan(origDiff)) {

				String repDiff = new String(Surrogates.replace(origDiff));
				notEqual = !repDiff.equals(deco);
			}
		}

		if (notEqual) {

			if (MODE_DEBUG_OUTPUT_ACTIVATED) {

				try {
					// System.out.println("DEBUG\t" + task.toString());

					WikipediaXMLWriter writer = new WikipediaXMLWriter(
							LOGGING_PATH_DIFFTOOL + LOGGING_PATH_DEBUG
									+ task.getHeader().getArticleName()
									+ ".dbg");

					switch (task.getTaskType()) {
					case TASK_FULL:
					case TASK_PARTIAL_FIRST:
						writer.writeDiff(task);
						break;

					case TASK_PARTIAL:
					case TASK_PARTIAL_LAST: {

						int revCount = originalDiff.getRevisionCounter();
						Diff d;
						boolean fullRev = false;

						for (int diffCount = 0; !fullRev
								&& diffCount < originalDiff.size(); diffCount++) {

							d = task.get(diffCount);
							if (d.getRevisionCounter() <= revCount
									&& d.isFullRevision()) {
								fullRev = true;
								writer.writeDiff(task, diffCount);
							}
						}

						if (!fullRev) {
							writer.writeDiffFile(task);
						}

					}
						break;
					default:
						throw new IOException("Unknown TaskType");
						// TODO: Debug output
					}

					writer.close();
				}
				catch (IOException e) {
					ConsumerLogMessages.logException(logger, e);
				}
			}

			throw ErrorFactory
					.createSQLConsumerException(
							ErrorKeys.DIFFTOOL_SQLCONSUMER_ENCODING_VERIFICATION_FAILED,
							"Redecoding of "
									+ task.getHeader().getArticleName()
									+ " failed at revision "
									+ originalDiff.getRevisionCounter() + ".");
		}
	}
758862
public JsonFluentAssert isNotEqualTo(Object expected) {
        Diff diff = createDiff(expected, configuration);
        if (diff.similar()) {
            failWithMessage("JSON is equal.");
        }
        return this;
    }
1072808
def encode_task(task):
    
    # First, clean the task:
    task = task.copy()
    if 'tags' in task:
        task['tags'] = ','.join(task['tags'])
    for k in task:
        for unsafe, safe in six.iteritems(encode_replacements):
            if isinstance(task[k], six.string_types):
                task[k] = task[k].replace(unsafe, safe)

        if isinstance(task[k], datetime.datetime):
            task[k] = task[k].strftime("%Y%m%dT%M%H%SZ")

    # Then, format it as a string
    return "[%s]\n" % " ".join([
        "%s:\"%s\"" % (k, v)
        for k, v in sorted(task.items(), key=itemgetter(0))
    ])
1026966
private void initialDecodeTasks(final ChannelHandlerContext ctx) {
        currentRequest = sentRequestQueue.poll();
        currentDecodingState = DecodingState.STARTED;

        if (currentRequest != null) {
            Long st = sentRequestTimings.poll();
            if (st != null) {
                currentOpTime = System.nanoTime() - st;
            } else {
                currentOpTime = -1;
            }
        }

        if (env().operationTracingEnabled()) {
            Span dispatchSpan = dispatchSpans.poll();
            if (dispatchSpan != null) {
                currentDispatchSpan = dispatchSpan;
            }
        }

        if (traceEnabled) {
            LOGGER.trace("{}Started decoding of {}", logIdent(ctx, endpoint), currentRequest);
        }
    }
769869
public void updateTaskDef(TaskDef taskDef) {
        Preconditions.checkNotNull(taskDef, "Task definition cannot be null");
        stub.updateTask(
                MetadataServicePb.UpdateTaskRequest.newBuilder()
                        .setTask(protoMapper.toProto(taskDef))
                        .build()
        );
    }
1043645
private void checkTaskForExecution(ApplicationDefinition appDef, Task task) {
        Tenant tenant = Tenant.getTenant(appDef);
        m_logger.debug("Checking task '{}' in tenant '{}'", task.getTaskID(), tenant);
        synchronized (m_executeLock) {
            Iterator<DColumn> colIter =
                DBService.instance(tenant).getAllColumns(TaskManagerService.TASKS_STORE_NAME, task.getTaskID()).iterator();
            TaskRecord taskRecord = null;
            if (!colIter.hasNext()) {
                taskRecord = storeTaskRecord(tenant, task);
            } else {
                taskRecord = buildTaskRecord(task.getTaskID(), colIter);
            }
            if (taskShouldExecute(task, taskRecord) && canHandleMoreTasks()) {
                attemptToExecuteTask(appDef, task, taskRecord);
            }
        }
    }
823146
private String extractAndConvertTaskType(Task task)
   {
      String activityType = (String) task.getCachedValue(m_activityTypeField);
      if (activityType == null)
      {
         activityType = "Resource Dependent";
      }
      else
      {
         if (ACTIVITY_TYPE_MAP.containsKey(activityType))
         {
            activityType = ACTIVITY_TYPE_MAP.get(activityType);
         }
      }
      return activityType;
   }
756532
@Override
  public int compareTo(TaskDetails otherTask) {
    if (otherTask == null) {
      return -1;
    }

    return new CompareToBuilder().append(this.taskKey, otherTask.getTaskKey())
        .toComparison();
  }
629765
public void updateTask(TaskResult taskResult) {
        Preconditions.checkNotNull(taskResult, "Task result cannot be null");
        stub.updateTask(TaskServicePb.UpdateTaskRequest.newBuilder()
                .setResult(protoMapper.toProto(taskResult))
                .build()
        );
    }
945250
public void checkDeleteHistoricTaskInstance(HistoricTaskInstanceEntity task) {
    // deleting unexisting historic task instance should be silently ignored
    // see javaDoc HistoryService.deleteHistoricTaskInstance
    if (task != null) {
      if (task.getProcessDefinitionKey() != null) {
        getAuthorizationManager().checkAuthorization(DELETE_HISTORY, PROCESS_DEFINITION, task.getProcessDefinitionKey());
      }
    }
  }
735249
public void initializeBufferMetrics(Task task) {
		final MetricGroup buffers = addGroup("buffers");
		buffers.gauge("inputQueueLength", new InputBuffersGauge(task));
		buffers.gauge("outputQueueLength", new OutputBuffersGauge(task));
		buffers.gauge("inPoolUsage", new InputBufferPoolUsageGauge(task));
		buffers.gauge("outPoolUsage", new OutputBufferPoolUsageGauge(task));
	}
654966
protected void transmitPartialTask(final Task<Diff> result)
		throws TimeoutException
	{

		if (this.partCounter == 1) {

			this.result.setTaskType(TaskTypes.TASK_PARTIAL_FIRST);
			this.taskTransmitter.transmitDiff(result);

		}
		else {

			this.result.setTaskType(TaskTypes.TASK_PARTIAL);
			this.taskTransmitter.transmitPartialDiff(result);
		}
	}
113206
private void readTask(String projectIdentifier, Map<String, Task> map, Document.Projects.Project.Task task)
   {
      Task parentTask = map.get(getParentOutlineNumber(task.getOutlineNumber()));
      Task mpxjTask = parentTask.addTask();

      TimeUnit units = task.getBaseDurationTimeUnit();

      mpxjTask.setCost(task.getActualCost());
      mpxjTask.setDuration(getDuration(units, task.getActualDuration()));
      mpxjTask.setFinish(task.getActualFinishDate());
      mpxjTask.setStart(task.getActualStartDate());
      mpxjTask.setBaselineDuration(getDuration(units, task.getBaseDuration()));
      mpxjTask.setBaselineFinish(task.getBaseFinishDate());
      mpxjTask.setBaselineCost(task.getBaselineCost());
      //      task.getBaselineFinishDate()
      //      task.getBaselineFinishTemplateOffset()
      //      task.getBaselineStartDate()
      //      task.getBaselineStartTemplateOffset()
      mpxjTask.setBaselineStart(task.getBaseStartDate());
      //      task.getCallouts()
      mpxjTask.setPercentageComplete(task.getComplete());
      mpxjTask.setDeadline(task.getDeadlineDate());
      //      task.getDeadlineTemplateOffset()
      //      task.getHyperlinks()
      //      task.getMarkerID()
      mpxjTask.setName(task.getName());
      mpxjTask.setNotes(task.getNote());
      mpxjTask.setPriority(task.getPriority());
      //      task.getRecalcBase1()
      //      task.getRecalcBase2()
      mpxjTask.setType(task.getSchedulingType());
      //      task.getStyleProject()
      //      task.getTemplateOffset()
      //      task.getValidatedByProject()

      if (task.isIsMilestone())
      {
         mpxjTask.setMilestone(true);
         mpxjTask.setDuration(Duration.getInstance(0, TimeUnit.HOURS));
         mpxjTask.setBaselineDuration(Duration.getInstance(0, TimeUnit.HOURS));
      }

      String taskIdentifier = projectIdentifier + "." + task.getID();
      m_taskIdMap.put(task.getID(), mpxjTask);
      mpxjTask.setGUID(UUID.nameUUIDFromBytes(taskIdentifier.getBytes()));

      map.put(task.getOutlineNumber(), mpxjTask);

      for (Document.Projects.Project.Task.ResourceAssignments.ResourceAssignment assignment : task.getResourceAssignments().getResourceAssignment())
      {
         readResourceAssignment(mpxjTask, assignment);
      }
   }
187809
private void processTaskEnterpriseColumns(FieldMap fieldMap, Task task, Var2Data taskVarData)
   {
      byte[] data = null;
      Integer varDataKey = fieldMap.getVarDataKey(TaskField.ENTERPRISE_DATA);

      if (varDataKey != null)
      {
         data = taskVarData.getByteArray(task.getUniqueID(), varDataKey);
      }

      if (data != null)
      {
         PropsBlock props = new PropsBlock(data);
         //System.out.println(props);

         for (Integer key : props.keySet())
         {
            int keyValue = key.intValue() - MPPTaskField.TASK_FIELD_BASE;
            TaskField field = MPPTaskField.getInstance(keyValue);

            if (field != null)
            {
               Object value = null;

               switch (field.getDataType())
               {
                  case CURRENCY:
                  {
                     value = Double.valueOf(props.getDouble(key) / 100);
                     break;
                  }

                  case DATE:
                  {
                     value = props.getTimestamp(key);
                     break;
                  }

                  case WORK:
                  {
                     double durationValueInHours = MPPUtility.getDouble(props.getByteArray(key), 0) / 60000;
                     value = Duration.getInstance(durationValueInHours, TimeUnit.HOURS);
                     break;
                  }

                  case DURATION:
                  {
                     byte[] durationData = props.getByteArray(key);
                     double durationValueInHours = ((double) MPPUtility.getInt(durationData, 0)) / 600;
                     TimeUnit durationUnits;
                     if (durationData.length < 6)
                     {
                        durationUnits = TimeUnit.DAYS;
                     }
                     else
                     {
                        durationUnits = MPPUtility.getDurationTimeUnits(MPPUtility.getShort(durationData, 4));
                     }
                     Duration duration = Duration.getInstance(durationValueInHours, TimeUnit.HOURS);
                     value = duration.convertUnits(durationUnits, m_file.getProjectProperties());
                     break;
                  }

                  case BOOLEAN:
                  {
                     field = null;
                     int bits = props.getInt(key);
                     task.set(TaskField.ENTERPRISE_FLAG1, Boolean.valueOf((bits & 0x00002) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG2, Boolean.valueOf((bits & 0x00004) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG3, Boolean.valueOf((bits & 0x00008) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG4, Boolean.valueOf((bits & 0x00010) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG5, Boolean.valueOf((bits & 0x00020) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG6, Boolean.valueOf((bits & 0x00040) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG7, Boolean.valueOf((bits & 0x00080) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG8, Boolean.valueOf((bits & 0x00100) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG9, Boolean.valueOf((bits & 0x00200) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG10, Boolean.valueOf((bits & 0x00400) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG11, Boolean.valueOf((bits & 0x00800) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG12, Boolean.valueOf((bits & 0x01000) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG13, Boolean.valueOf((bits & 0x02000) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG14, Boolean.valueOf((bits & 0x04000) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG15, Boolean.valueOf((bits & 0x08000) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG16, Boolean.valueOf((bits & 0x10000) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG17, Boolean.valueOf((bits & 0x20000) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG18, Boolean.valueOf((bits & 0x40000) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG19, Boolean.valueOf((bits & 0x80000) != 0));
                     task.set(TaskField.ENTERPRISE_FLAG20, Boolean.valueOf((bits & 0x100000) != 0));
                     break;
                  }

                  case NUMERIC:
                  {
                     value = Double.valueOf(props.getDouble(key));
                     break;
                  }

                  case STRING:
                  {
                     value = props.getUnicodeString(key);
                     break;
                  }

                  case PERCENTAGE:
                  {
                     value = Integer.valueOf(props.getShort(key));
                     break;
                  }

                  default:
                  {
                     break;
                  }
               }

               task.set(field, value);
            }
         }
      }
   }
943971
def update_task(self, differences):
        

        self.log('differences UPDATING: {}'.format(differences))

        object_name = '{} - {}'.format(self.app_label, self.instance.master._meta.verbose_name)
        lang = self.instance.language_code
        object_pk = self.instance.master.pk

        for field in differences:
            value = getattr(self.instance, field)
            if value is None or value == '':
                continue
            try:
                TransTask.objects.filter(
                    language__code=lang, object_field=field, object_name=object_name, object_pk=object_pk
                ).update(done=True, date_modification=datetime.now(), object_field_value_translation=value)
                self.log('MARKED TASK AS DONE')
            except TransTask.DoesNotExist:
                self.log('error MARKING TASK AS DONE: {} - {} - {} - {}'.format(lang, field, object_name, object_pk))
948427
public static boolean isIdentical(final String expected, final String actual) {
        final Diff diff = createDiffResult(expected, actual, false);

        return diff.identical();
    }
1320409
public ResponseFromManager generateUpdateExecuteTask(ParallelTask task) {

        // add to map now; as can only pass final
        ParallelTaskManager.getInstance().addTaskToInProgressMap(
                task.getTaskId(), task);
        logger.info("Added task {} to the running inprogress map...",
                task.getTaskId());

        boolean useReplacementVarMap = false;
        boolean useReplacementVarMapNodeSpecific = false;
        Map<String, StrStrMap> replacementVarMapNodeSpecific = null;
        Map<String, String> replacementVarMap = null;

        ResponseFromManager batchResponseFromManager = null;

        switch (task.getRequestReplacementType()) {
        case UNIFORM_VAR_REPLACEMENT:
            useReplacementVarMap = true;
            useReplacementVarMapNodeSpecific = false;
            replacementVarMap = task.getReplacementVarMap();
            break;
        case TARGET_HOST_SPECIFIC_VAR_REPLACEMENT:
            useReplacementVarMap = false;
            useReplacementVarMapNodeSpecific = true;
            replacementVarMapNodeSpecific = task
                    .getReplacementVarMapNodeSpecific();
            break;
        case NO_REPLACEMENT:
            useReplacementVarMap = false;
            useReplacementVarMapNodeSpecific = false;
            break;
        default:
            logger.error("error request replacement type. default as no replacement");
        }// end switch

        // generate content in nodedata
        InternalDataProvider dp = InternalDataProvider.getInstance();
        dp.genNodeDataMap(task);

        VarReplacementProvider.getInstance()
                .updateRequestWithReplacement(task, useReplacementVarMap,
                        replacementVarMap, useReplacementVarMapNodeSpecific,
                        replacementVarMapNodeSpecific);

        batchResponseFromManager = 
                sendTaskToExecutionManager(task);

        removeTaskFromInProgressMap(task.getTaskId());
        logger.info(
                "Removed task {} from the running inprogress map... "
                        + ". This task should be garbage collected if there are no other pointers.",
                task.getTaskId());
        return batchResponseFromManager;

    }