@RequestMapping(value = CREATE_TARGET_URL, method = RequestMethod.POST)
    public ResponseEntity<Result> createTarget(@RequestBody Map<String, Object> params) throws DeployerException, ValidationException {
        String env = "";
        String siteName = "";
        boolean replace = false;
        String templateName = "";
        Map<String, Object> templateParams = new HashMap<>();

        for (Map.Entry<String, Object> param : params.entrySet()) {
            switch (param.getKey()) {
                case ENV_PATH_VAR_NAME:
                    env = Objects.toString(param.getValue(), "");
                    break;
                case SITE_NAME_PATH_VAR_NAME:
                    siteName = Objects.toString(param.getValue(), "");
                    break;
                case REPLACE_PARAM_NAME:
                    replace = BooleanUtils.toBoolean(param.getValue());
                    break;
                case TEMPLATE_NAME_PARAM_NAME:
                    templateName = Objects.toString(param.getValue(), "");
                    break;
                default:
                    templateParams.put(param.getKey(), param.getValue());
                    break;
            }
        }

        ValidationResult validationResult = new ValidationResult();
        
        if (StringUtils.isEmpty(env)) {
            validationResult.addError(ENV_PATH_VAR_NAME, ErrorCodes.FIELD_MISSING_ERROR_CODE);
        }
        if (StringUtils.isEmpty(siteName)) {
            validationResult.addError(SITE_NAME_PATH_VAR_NAME, ErrorCodes.FIELD_MISSING_ERROR_CODE);
        }
        if (validationResult.hasErrors()) {
            throw new ValidationException(validationResult);
        }

        targetService.createTarget(env, siteName, replace, templateName, templateParams);

        return new ResponseEntity<>(Result.OK,
                                    RestServiceUtils.setLocationHeader(new HttpHeaders(), BASE_URL + GET_TARGET_URL, env, siteName),
                                    HttpStatus.CREATED);
    }
@ RequestMapping ( value = CREATE_TARGET_URL , method = RequestMethod . POST ) public ResponseEntity < Result > createTarget ( @ RequestBody Map < String , Object > params ) throws DeployerException , ValidationException { String env = "" ; String siteName = "" ; boolean replace = false ; String templateName = "" ; Map < String , Object > templateParams = new HashMap < > ( ) ; for ( Map . Entry < String , Object > param : params . entrySet ( ) ) { switch ( param . getKey ( ) ) { case ENV_PATH_VAR_NAME : env = Objects . toString ( param . getValue ( ) , "" ) ; break ; case SITE_NAME_PATH_VAR_NAME : siteName = Objects . toString ( param . getValue ( ) , "" ) ; break ; case REPLACE_PARAM_NAME : replace = BooleanUtils . toBoolean ( param . getValue ( ) ) ; break ; case TEMPLATE_NAME_PARAM_NAME : templateName = Objects . toString ( param . getValue ( ) , "" ) ; break ; default : templateParams . put ( param . getKey ( ) , param . getValue ( ) ) ; break ; } } ValidationResult validationResult = new ValidationResult ( ) ; if ( StringUtils . isEmpty ( env ) ) { validationResult . addError ( ENV_PATH_VAR_NAME , ErrorCodes . FIELD_MISSING_ERROR_CODE ) ; } if ( StringUtils . isEmpty ( siteName ) ) { validationResult . addError ( SITE_NAME_PATH_VAR_NAME , ErrorCodes . FIELD_MISSING_ERROR_CODE ) ; } if ( validationResult . hasErrors ( ) ) { throw new ValidationException ( validationResult ) ; } targetService . createTarget ( env , siteName , replace , templateName , templateParams ) ; return new ResponseEntity < > ( Result . OK , RestServiceUtils . setLocationHeader ( new HttpHeaders ( ) , BASE_URL + GET_TARGET_URL , env , siteName ) , HttpStatus . CREATED ) ; }
Creates a Deployer {@link Target}.

@param params the body of the request with the template parameters that will be used to create the target. The body must
contain at least a {@code env} and {@code site_name} parameter. Other required parameters depend on the
template used.

@return the response entity 201 CREATED status

@throws DeployerException   if an error ocurred during target creation
@throws ValidationException if a required parameter is missing