Validate the Job's JobId by checking name, version, and hash are
not null or empty, don't contain invalid characters.

@param job The Job to check.

@return A set of error Strings
13177
private Set<String> validateJobId(final Job job) {
    final Set<String> errors = Sets.newHashSet();
    final JobId jobId = job.getId();

    if (jobId == null) {
      errors.add("Job id was not specified.");
      return errors;
    }

    final String jobIdVersion = jobId.getVersion();
    final String jobIdHash = jobId.getHash();
    final JobId recomputedId = job.toBuilder().build().getId();

    errors.addAll(validateJobName(jobId, recomputedId));
    errors.addAll(validateJobVersion(jobIdVersion, recomputedId));

    if (this.shouldValidateJobHash) {
      errors.addAll(validateJobHash(jobIdHash, recomputedId));
    }

    return errors;
  }
881968
function validateObject(job, object, callback) {
		if (typeof object.value === 'undefined') {
			var onLoad = function (err, obj) {
				if (err) {
					job.error = err;
					return callback(err);
				}
				object.value = obj;
				doValidateObject(job, object, callback);
			};
			var opts = {
				timeout: (job.context.options.timeout || 5000)
			};
			//TODO verify http:, file: and plain paths all load properly
			if (object.path) {
				loader.loadPath(object.path, opts, onLoad);
			}
			else if (object.url) {
				loader.load(object.url, opts, onLoad);
			}
			else {
				callback(new Error('object missing value, path or url'));
			}
		}
		else {
			doValidateObject(job, object, callback);
		}
	}
101123
private void findSpecNameForGV(String jobnameLL) {
        int maxVersion = 0;
        StringBuilder key = new StringBuilder();

        // alle param-segmente durchlaufen
        Map<String, String> bpd = passport.getBPD();
        for (String path : bpd.keySet()) {
            key.setLength(0);
            key.append(path);

            if (key.indexOf("Params") == 0) {
                key.delete(0, key.indexOf(".") + 1);

                // wenn segment mit namen des aktuellen jobs gefunden wurde
                if (key.indexOf(jobnameLL + "Par") == 0 &&
                    key.toString().endsWith(".SegHead.code")) {
                    key.delete(0, jobnameLL.length() + ("Par").length());

                    // extrahieren der versionsnummer aus dem spez-namen
                    String st = key.substring(0, key.indexOf("."));
                    int version = 0;

                    try {
                        version = Integer.parseInt(st);
                    } catch (Exception e) {
                        log.warn("found invalid job version: key=" + key + ", jobnameLL=" + jobnameLL + " (this is a " +
                            "known, but harmless bug)");
                    }

                    // merken der größten jemals aufgetretenen versionsnummer
                    if (version != 0) {
                        log.debug("task " + jobnameLL + " is supported with segment version " + st);
                        if (version > maxVersion) {
                            maxVersion = version;
                        }
                    }
                }
            }
        }

        if (maxVersion == 0 && !jobnameLL.equals(GVRawSEPA.getLowlevelName())) {
            maxVersion = 1;
            log.warn("Using segment version " + maxVersion + " for job " + jobnameLL + ", although not found in BPD. " +
                "This may fail");
            throw new JobNotSupportedException(jobnameLL);
        }

        // namen+versionsnummer speichern
        this.jobName = jobnameLL;
        this.segVersion = maxVersion;
        this.name = jobnameLL + this.segVersion;
    }
293538
@Restricted(DoNotUse.class) // called from newJob view
    public FormValidation doCheckJobName(@QueryParameter String value) {
        // this method can be used to check if a file exists anywhere in the file system,
        // so it should be protected.
        getOwner().checkPermission(Item.CREATE);

        if (Util.fixEmpty(value) == null) {
            return FormValidation.ok();
        }

        try {
            Jenkins.checkGoodName(value);
            value = value.trim(); // why trim *after* checkGoodName? not sure, but ItemGroupMixIn.createTopLevelItem does the same
            Jenkins.getInstance().getProjectNamingStrategy().checkName(value);
        } catch (Failure e) {
            return FormValidation.error(e.getMessage());
        }

        if (getOwner().getItemGroup().getItem(value) != null) {
            return FormValidation.error(Messages.Hudson_JobAlreadyExists(value));
        }

        // looks good
        return FormValidation.ok();
    }
935973
public Set<String> configureJob(Job job) throws FileNotFoundException, IOException, TupleMRException {
		Set<String> instanceFiles = new HashSet<String>();
		for(Output output : getNamedOutputs()) {
			try {
				if(output.isDefault) {
					instanceFiles.add(PangoolMultipleOutputs.setDefaultNamedOutput(job, output.outputFormat,
					    output.keyClass, output.valueClass));
				} else {
					instanceFiles.add(PangoolMultipleOutputs.addNamedOutput(job, output.name, output.outputFormat,
					    output.keyClass, output.valueClass));
				}
			} catch(URISyntaxException e1) {
				throw new TupleMRException(e1);
			}
			for(Map.Entry<String, String> contextKeyValue : output.specificContext.entrySet()) {
				PangoolMultipleOutputs.addNamedOutputContext(job, output.name, contextKeyValue.getKey(),
				    contextKeyValue.getValue());
			}
		}
		return instanceFiles;
	}
1285876
@Override
    public JobMeta getJobMeta(String jobType) {
        final Map<String, String> document = map.get(jobType);
        if (document != null) {
            final Map<String, String> meta = document.keySet()
                    .stream()
                    .filter(key -> !key.startsWith("_e_"))
                    .collect(toMap(
                            key -> key,
                            document::get
                    ));
            final boolean isRunning = document.containsKey(KEY_RUNNING);
            final boolean isDisabled = document.containsKey(KEY_DISABLED);
            final String comment = document.get(KEY_DISABLED);
            return new JobMeta(jobType, isRunning, isDisabled, comment, meta);
        } else {
            return new JobMeta(jobType, false, false, "", emptyMap());
        }
    }
307365
protected function validateJobParams(Job $job)
    {
        if (empty($job->getToken())) {
            throw new ResultException(ResultException::ERROR_PARAM_TOKEN);
        }

        if (empty($job->getRoom())) {
            throw new ResultException(ResultException::ERROR_PARAM_ROOM);
        }

        if (empty($job->getFrom())) {
            throw new ResultException(ResultException::ERROR_PARAM_FROM);
        }

        if (empty($job->getMsg())) {
            throw new ResultException(ResultException::ERROR_PARAM_MSG);
        }

    }
1251002
public void waitForJobToComplete(String jobId) {
        while (true) {
            List<Message> messages = sqs.receiveMessage(new ReceiveMessageRequest(queueUrl)).getMessages();
            for (Message message : messages) {
                String messageBody = message.getBody();
                if (!messageBody.startsWith("{")) {
                    messageBody = new String(BinaryUtils.fromBase64(messageBody));
                }

                try {
                    JsonNode json = MAPPER.readTree(messageBody);

                    String jsonMessage = json.get("Message").asText().replace("\\\"", "\"");

                    json = MAPPER.readTree(jsonMessage);
                    String messageJobId = json.get("JobId").asText();
                    String messageStatus = json.get("StatusMessage").asText();

                    // Don't process this message if it wasn't the job we were looking for
                    if (!jobId.equals(messageJobId)) continue;

                    try {
                        if (StatusCode.Succeeded.toString().equals(messageStatus)) return;
                        if (StatusCode.Failed.toString().equals(messageStatus)) {
                            throw new AmazonClientException("Archive retrieval failed");
                        }
                    } finally {
                        deleteMessage(message);
                    }
                } catch (IOException e) {
                    throw new AmazonClientException("Unable to parse status message: " + messageBody, e);
                }
            }

            sleep(1000 * 30);
        }
    }
1254426
public JobReport execute(Job job) {
        try {
            return executorService.submit(job).get();
        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException("Unable to execute job " + job.getName(), e);
        }
    }
750355
public static ErrorCode isIdValid(String id) {
        if (!isMustFieldValid(id, idRegEx)) {
            return ErrorCode.SERVICE_INSTANCE_ID_FORMAT_ERROR;
        }
        return ErrorCode.OK;
    }
400919
public static JobId of(String project, String job) {
    return newBuilder().setProject(checkNotNull(project)).setJob(checkNotNull(job)).build();
  }
685929
public String[] getJobList() {
        String[] strings = new String[jobMap.keySet().size()];
        int i = 0;
        for (String s : jobMap.keySet()) {
            strings[i++] = s;
        }
        return strings;
    }
1356824
def validate(cls, job_config):
    
    reader_params = job_config.input_reader_params

    # Bucket Name is required
    if cls.BUCKET_NAME_PARAM not in reader_params:
      raise errors.BadReaderParamsError(
          "%s is required for Google Cloud Storage" %
          cls.BUCKET_NAME_PARAM)
    try:
      cloudstorage.validate_bucket_name(
          reader_params[cls.BUCKET_NAME_PARAM])
    except ValueError, error:
      raise errors.BadReaderParamsError("Bad bucket name, %s" % (error))

    # Object Name(s) are required
    if cls.OBJECT_NAMES_PARAM not in reader_params:
      raise errors.BadReaderParamsError(
          "%s is required for Google Cloud Storage" %
          cls.OBJECT_NAMES_PARAM)
    filenames = reader_params[cls.OBJECT_NAMES_PARAM]
    if not isinstance(filenames, list):
      raise errors.BadReaderParamsError(
          "Object name list is not a list but a %s" %
          filenames.__class__.__name__)
    for filename in filenames:
      if not isinstance(filename, basestring):
        raise errors.BadReaderParamsError(
            "Object name is not a string but a %s" %
            filename.__class__.__name__)

    # Delimiter.
    if cls.DELIMITER_PARAM in reader_params:
      delimiter = reader_params[cls.DELIMITER_PARAM]
      if not isinstance(delimiter, basestring):
        raise errors.BadReaderParamsError(
            "%s is not a string but a %s" %
            (cls.DELIMITER_PARAM, type(delimiter)))

    # Buffer size.
    if cls.BUFFER_SIZE_PARAM in reader_params:
      buffer_size = reader_params[cls.BUFFER_SIZE_PARAM]
      if not isinstance(buffer_size, int):
        raise errors.BadReaderParamsError(
            "%s is not an int but a %s" %
            (cls.BUFFER_SIZE_PARAM, type(buffer_size)))

    # Path filter.
    if cls.PATH_FILTER_PARAM in reader_params:
      path_filter = reader_params[cls.PATH_FILTER_PARAM]
      if not isinstance(path_filter, PathFilter):
        raise errors.BadReaderParamsError(
            "%s is not an instance of PathFilter but %s." %
            (cls.PATH_FILTER_PARAM, type(path_filter)))
753958
public java.lang.String getJobName() {
    java.lang.Object ref = jobName_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      jobName_ = s;
      return s;
    }
  }
101785
public static boolean isValidVersion(final String version) {
        return StringUtils.isNotBlank(version)
                && (ALTERNATE_PATTERN.matcher(version).matches() || STANDARD_PATTERN
                        .matcher(version).matches());
    }
681382
public FormValidation doCheckDisplayName(@QueryParameter String displayName,
            @QueryParameter String jobName) {
        displayName = displayName.trim();

        if(LOGGER.isLoggable(Level.FINE)) {
            LOGGER.log(Level.FINE, "Current job name is " + jobName);
        }

        if(!isNameUnique(displayName, jobName)) {
            return FormValidation.warning(Messages.Jenkins_CheckDisplayName_NameNotUniqueWarning(displayName));
        }
        else if(!isDisplayNameUnique(displayName, jobName)){
            return FormValidation.warning(Messages.Jenkins_CheckDisplayName_DisplayNameNotUniqueWarning(displayName));
        }
        else {
            return FormValidation.ok();
        }
    }
159771
public JobProfile readJobProfile(JobID jobId) {
    JobProfile jobProfile = null;
    if (active) {
      try {
        FSDataInputStream dataIn = getJobInfoFile(jobId);
        if (dataIn != null) {
          readJobStatus(dataIn);
          jobProfile = readJobProfile(dataIn);
          dataIn.close();
        }
      } catch (IOException ex) {
        LOG.warn("Could not read [" + jobId + "] job profile : " + ex, ex);
      }
    }
    return jobProfile;
  }