/** {@inheritDoc} */
 @Override
 public void populateContextForView(
     @NotNull Map<String, Object> context, @NotNull TaskDefinition taskDefinition) {
   super.populateContextForView(context, taskDefinition);
   taskConfiguratorHelper.populateContextWithConfiguration(
       context, taskDefinition, FIELDS_TO_COPY);
   context.put(
       CFG_SONAR_SERVER_CONFIGURED,
       Boolean.valueOf(taskDefinition.getConfiguration().get(CFG_SONAR_SERVER_CONFIGURED)));
   context.put(
       CFG_SONAR_PROJECT_CONFIGURED,
       Boolean.valueOf(taskDefinition.getConfiguration().get(CFG_SONAR_PROJECT_CONFIGURED)));
 }
 /** {@inheritDoc} */
 @Override
 public void populateContextForEdit(
     @NotNull Map<String, Object> context, @NotNull TaskDefinition taskDefinition) {
   super.populateContextForEdit(context, taskDefinition);
   taskConfiguratorHelper.populateContextWithConfiguration(
       context, taskDefinition, FIELDS_TO_COPY);
   boolean serverConfig =
       Boolean.valueOf(taskDefinition.getConfiguration().get(CFG_SONAR_SERVER_CONFIGURED));
   boolean projectConfig =
       Boolean.valueOf(taskDefinition.getConfiguration().get(CFG_SONAR_PROJECT_CONFIGURED));
   if (!serverConfig) {
     context.put(CFG_SONAR_SERVER_CONFIGURED, Boolean.FALSE.toString());
   }
   if (!projectConfig) {
     context.put(CFG_SONAR_PROJECT_CONFIGURED, Boolean.FALSE.toString());
   }
 }
  public void populateContextForView(
      final Map<String, Object> context, final TaskDefinition taskDefinition) {
    super.populateContextForView(context, taskDefinition);

    context.put("zs_url", taskDefinition.getConfiguration().get("zs_url"));
    context.put("api_key", taskDefinition.getConfiguration().get("api_key"));
    context.put("api_secret", taskDefinition.getConfiguration().get("api_secret"));
    context.put("base_url", taskDefinition.getConfiguration().get("base_url"));
    context.put("app_name", taskDefinition.getConfiguration().get("app_name"));
    context.put("zsversion", taskDefinition.getConfiguration().get("zsversion"));
    context.put("custom_options", taskDefinition.getConfiguration().get("custom_options"));
    context.put("retry", taskDefinition.getConfiguration().get("retry"));
    context.put("waittime", taskDefinition.getConfiguration().get("waittime"));
  }
 /**
  * Get the new Task Configuration Map
  *
  * @param taskDefinition the current {@link TaskDefinition}
  * @return the new Configuration map
  */
 private Map<String, String> getTaskConfigurationMap(TaskDefinition taskDefinition) {
   Map<String, String> config = Maps.newHashMap();
   for (Entry<String, String> entry : taskDefinition.getConfiguration().entrySet()) {
     if (PASSWORD_FIELDS.contains(entry.getKey()) && StringUtils.isNotBlank(entry.getValue())) {
       // A Password field is set with a value. Encrypt it in the new configuration map
       logger.info("Encrypting field: " + entry.getKey());
       config.put(entry.getKey(), ENCRYPTOR.encrypt(entry.getValue()));
     } else {
       // No need to encrypt this field, just copy it
       config.put(entry.getKey(), entry.getValue());
     }
   }
   return config;
 }
  private File getZpkFromArtifactDownload() throws Exception {
    Iterator<TaskDefinition> taskDefinitionIterator =
        taskContext.getCommonContext().getTaskDefinitions().iterator();

    while (taskDefinitionIterator.hasNext()) {
      TaskDefinition taskDefinition = taskDefinitionIterator.next();
      if (!taskDefinition.getPluginKey().equals(ARTIFACT_DOWNLOADER_KEY)) continue;

      logger.addBuildLogEntry("Artifact Downloader Task found");
      String zpkDir =
          taskDefinition
              .getConfiguration()
              .get("localPath_0")
              .replace("${bamboo.buildNumber}", getBuildNr());
      logger.addBuildLogEntry("ZPK directory configuration found: " + zpkDir);

      String zpk = getWorkingDir() + "/" + zpkDir + "/" + getZpkFileName();

      return new File(zpk);
    }

    throw new Exception("No artifact downloader task found.");
  }