/** * Obtain the name of the worker, that performed the operation. * @param workerTaskData * @return */ private static String getWorkerName(WorkerTaskData workerTaskData) { final TaskSourceInfo sourceInfo = workerTaskData.getSourceInfo(); if (sourceInfo == null || Strings.isNullOrEmpty(sourceInfo.getName())) { return "Unknown"; } return sourceInfo.getName(); }
/** * Returns the worker name from the source information in the task message or an "Unknown" string if it is * not present. * * @param taskMessage the task message to be examined * @return the name of the worker that created the task message */ private static String getWorkerName(final TaskMessage taskMessage) { final TaskSourceInfo sourceInfo = taskMessage.getSourceInfo(); if (sourceInfo == null) { return "Unknown - no source info"; } final String workerName = sourceInfo.getName(); if (workerName == null) { return "Unknown - worker name not set"; } return workerName; }
/** * Updates the passed in Document metadata with details of the passed in TaskSourceInfo. * * @param document Document to update metadata on. * @param sourceInfo The TaskSourceInfo to use in updating the metadata. */ public static void addProcessingWorkerInformation(DocumentInterface document, TaskSourceInfo sourceInfo) { if (sourceInfo == null) { logger.warn("No TaskSourceInfo was provided, unable to add Processing Worker Version to document."); return; } try { PolicyReprocessingVersionTagging.addProcessingWorkerVersion( document, new WorkerProcessingInfo(sourceInfo.getVersion(), sourceInfo.getName())); } catch (PolicyReprocessingVersionTaggingException e) { logger.warn("Failed to add Processing Worker Version to document.", e); } }