Create message part based on attachment upload error details.

@return Message part.
186558
private Part createErrorPart(Attachment a) {
        return Part.builder().setName(String.valueOf(a.hashCode())).setSize(0).setType(Attachment.LOCAL_PART_TYPE_ERROR).setUrl(null).setData(a.getError().getLocalizedMessage()).build();
    }
9282
protected String createDialogErrorMessage() {

        if (getException() != null) {
            StringBuffer result = new StringBuffer(8);
            result.append(dialogBlockStart(""));
            result.append("<table border=\"0\">\n");
            result.append("<tr><td><img src=\"");
            result.append(getSkinUri()).append("commons/");
            result.append("error.png");
            result.append("\" border=\"0\" alt=\"\"></td><td class=\"xmlTdError maxwidth\">");
            Throwable t = getException();
            while (t != null) {
                result.append(t.getLocalizedMessage());
                t = t.getCause();
                if (t != null) {
                    result.append("<br>");
                }
            }
            result.append("</table>\n");
            result.append(dialogBlockEnd());
            return result.toString();
        }
        return "";
    }
524935
public static function getUploadErrorMessages()
    {
        return [
            UPLOAD_ERR_OK => Module::t('upload_err_message_0'),
            UPLOAD_ERR_INI_SIZE => Module::t('upload_err_message_1'),
            UPLOAD_ERR_FORM_SIZE =>  Module::t('upload_err_message_2'),
            UPLOAD_ERR_PARTIAL =>  Module::t('upload_err_message_3'),
            UPLOAD_ERR_NO_FILE =>  Module::t('upload_err_message_4'),
            UPLOAD_ERR_NO_TMP_DIR =>  Module::t('upload_err_message_6'),
            UPLOAD_ERR_CANT_WRITE =>  Module::t('upload_err_message_7'),
            UPLOAD_ERR_EXTENSION =>  Module::t('upload_err_message_8'),
        ];
    }
201444
protected function createErrorString()
    {
        $str = '';
        if ( $this->errorType !== null )
        {
            $str .= ", error='{$this->errorType}'";
        }

        if ( $this->errorMessage !== null )
        {
            $str .= ", error_description='{$this->errorMessage}'";
        }
        return $str;
    }
85167
public static void createErrorMessageFromResourceBundle(String clientId, String messageId, String label) {
		String summary = null;
		String detail = null;
		ResourceBundle bundle;
		String bundleName;

		// see if we have a user-provided bundle
		Application app = FacesContext.getCurrentInstance().getApplication();
		Class<?> appClass = app.getClass();
		Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
		if (null != (bundleName = app.getMessageBundle())) {
			if (null != (bundle = ResourceBundle.getBundle(bundleName, locale, getCurrentLoader(appClass)))) {
				// see if we have a hit
				try {
					summary = bundle.getString(messageId);
					detail = bundle.getString(messageId + "_detail");
				} catch (MissingResourceException e) {
					// ignore
				}
			}
		}

		// we couldn't find a summary in the user-provided bundle
		if (null == summary) {
			// see if we have a summary in the app provided bundle
			bundle = ResourceBundle.getBundle(FacesMessage.FACES_MESSAGES, locale, getCurrentLoader(appClass));
			if (null == bundle) {
				throw new NullPointerException();
			}
			// see if we have a hit
			try {
				summary = bundle.getString(messageId);
				detail = bundle.getString(messageId + "_detail");
			} catch (MissingResourceException e) {
				// ignore
			}
		}

		summary = summary != null ? summary.replace("{0}", label) : "";
		detail = detail != null ? detail.replace("{0}", label) : "";

		// At this point, we have a summary and a bundle.
		FacesMessages.error(clientId, summary, detail);
	}
784240
public String getMessage() {
	StringBuffer buf = new StringBuffer();
	if (code != UNSPECIFIED) {
	    buf.append(getCodeExplanation(code));
	}
	if (customMessage != null) {
	    buf.append(" Custom message: ");
	    buf.append(customMessage);
	}
	if (code != UNSPECIFIED) {
	    buf.append(" (error code ").append(String.valueOf(code)).append(")");
	}
	if (cause != null) {
	    buf.append(" [Nested exception message: ");
	    buf.append(cause.getMessage());
	    buf.append("]");
	}
	return buf.toString();
    }
1210697
private FormData createFormData(Message message) {
        FormData formData = new ObjectFactory().createFormData();

        formData.setContentType(getFormContentType(message));
        formData.setAction(getFormAction(message));

        if (message.getPayload() instanceof MultiValueMap) {
            MultiValueMap<String, Object> formValueMap = message.getPayload(MultiValueMap.class);

            for (Map.Entry<String, List<Object>> entry : formValueMap.entrySet()) {
                Control control = new ObjectFactory().createControl();
                control.setName(entry.getKey());
                control.setValue(StringUtils.arrayToCommaDelimitedString(entry.getValue().toArray()));
                formData.addControl(control);
            }
        } else {
            String rawFormData = message.getPayload(String.class);
            if (StringUtils.hasText(rawFormData)) {
                StringTokenizer tokenizer = new StringTokenizer(rawFormData, "&");
                while (tokenizer.hasMoreTokens()) {
                    Control control = new ObjectFactory().createControl();
                    String[] nameValuePair = tokenizer.nextToken().split("=");

                    if (autoDecode) {
                        try {
                            control.setName(URLDecoder.decode(nameValuePair[0], getEncoding()));
                            control.setValue(URLDecoder.decode(nameValuePair[1], getEncoding()));
                        } catch (UnsupportedEncodingException e) {
                            throw new CitrusRuntimeException(String.format("Failed to decode form control value '%s=%s'", nameValuePair[0], nameValuePair[1]), e);
                        }
                    } else {
                        control.setName(nameValuePair[0]);
                        control.setValue(nameValuePair[1]);
                    }
                    formData.addControl(control);
                }
            }
        }

        return formData;
    }
1065636
public function createMessage(): Message
    {
        $message = \Swift_Message::newInstance()
            ->setSubject($this->options['subject'])
            ->setFrom($this->options['from'])
            ->setTo($this->options['recipient'])
            ->setBcc($this->options['bcc']);

        $this->setBody($message, $this->options['template'], $this->options['parameters']);

        foreach ($this->options['attachments'] as $file) {
            $message->attach($this->createAttachment($file));
        }

        return $message;
    }
1356589
protected function uploadSingleFile()
    {
        // check if there is error while uploading from error array key.
        if (is_array($this->files[$this->input_file_name]) && array_key_exists('error', $this->files[$this->input_file_name]) && $this->files[$this->input_file_name]['error'] != 0) {
            switch ($this->files[$this->input_file_name]['error']) {
                case 1:
                    $this->setErrorMessage(
                        sprintf(static::__('The uploaded file exceeds the max file size directive. (%s &gt; %s).'), $this->files[$this->input_file_name]['size'], ini_get('upload_max_filesize')),
                        'RDU_' . $this->files[$this->input_file_name]['error'],
                        $this->files[$this->input_file_name]['size'] . ' &gt; ' . ini_get('upload_max_filesize'),
                        $this->files[$this->input_file_name]['name'],
                        $this->files[$this->input_file_name]['size'],
                        $this->files[$this->input_file_name]['type']
                    );
                    return false;
                case 2:
                    $this->setErrorMessage(
                        static::__('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'),
                        'RDU_' . $this->files[$this->input_file_name]['error'],
                        '',
                        $this->files[$this->input_file_name]['name'],
                        $this->files[$this->input_file_name]['size'],
                        $this->files[$this->input_file_name]['type']
                    );
                    return false;
                case 3:
                    $this->setErrorMessage(
                        static::__('The uploaded file was only partially uploaded.'),
                        'RDU_' . $this->files[$this->input_file_name]['error'],
                        '',
                        $this->files[$this->input_file_name]['name'],
                        $this->files[$this->input_file_name]['size'],
                        $this->files[$this->input_file_name]['type']
                    );
                    return false;
                case 4:
                    $this->setErrorMessage(
                        static::__('You did not upload the file.'),
                        'RDU_' . $this->files[$this->input_file_name]['error'],
                        '',
                        $this->files[$this->input_file_name]['name'],
                        $this->files[$this->input_file_name]['size'],
                        $this->files[$this->input_file_name]['type']
                    );
                    return false;
                case 6:
                    $this->setErrorMessage(
                        static::__('Missing a temporary folder.'),
                        'RDU_' . $this->files[$this->input_file_name]['error'],
                        '',
                        $this->files[$this->input_file_name]['name'],
                        $this->files[$this->input_file_name]['size'],
                        $this->files[$this->input_file_name]['type']
                    );
                    return false;
                case 7:
                    $this->setErrorMessage(
                        static::__('Failed to write file to disk.'),
                        'RDU_' . $this->files[$this->input_file_name]['error'],
                        '',
                        $this->files[$this->input_file_name]['name'],
                        $this->files[$this->input_file_name]['size'],
                        $this->files[$this->input_file_name]['type']
                    );
                    return false;
                case 8:
                    $this->setErrorMessage(
                        static::__('A PHP extension stopped the file upload.'),
                        'RDU_' . $this->files[$this->input_file_name]['error'],
                        '',
                        $this->files[$this->input_file_name]['name'],
                        $this->files[$this->input_file_name]['size'],
                        $this->files[$this->input_file_name]['type']
                    );
                    return false;
            }
        }

        // validate that there is file upload.
        if (
            empty($this->files[$this->input_file_name]) || 
            (
                is_array($this->files[$this->input_file_name]) && 
                array_key_exists('name', $this->files[$this->input_file_name]) && 
                $this->files[$this->input_file_name]['name'] == null
            ) ||
            (
                is_array($this->files[$this->input_file_name]) && 
                array_key_exists('tmp_name', $this->files[$this->input_file_name]) && 
                $this->files[$this->input_file_name]['tmp_name'] == null
            )
        ) {
            $this->setErrorMessage(
                static::__('You did not upload the file.'),
                'RDU_4',
                '',
                $this->files[$this->input_file_name]['name'],
                $this->files[$this->input_file_name]['size'],
                $this->files[$this->input_file_name]['type']
            );
            return false;
        }

        // validate allowed extension and its mime types.
        $result = $this->validateExtensionAndMimeType();
        if ($result !== true) {
            return false;
        }
        unset($result);

        // validate max file size.
        $result = $this->validateFileSize();
        if ($result !== true) {
            return false;
        }
        unset($result);

        // validate max image dimension.
        $result = $this->validateImageDimension();
        if ($result !== true) {
            return false;
        }
        unset($result);

        // security scan.
        if ($this->security_scan === true) {
            $result = $this->securityScan();
            if ($result !== true) {
                return false;
            }
            unset($result);
        }

        // set new file name (in case that it was not set) and check for reserved file name.
        $tmp_new_file_name = $this->new_file_name;
        $this->setNewFileName();

        // check for safe web file name if this option was set to true.
        if ($this->web_safe_file_name === true) {
            $this->setWebSafeFileName();
        }

        // now, it should all passed validation. add the uploaded file to move uploaded queue in case that it is upload multiple file and has option to stop on error.
        // get the uploaded file extension.
        $file_name_explode = explode('.', $this->files[$this->input_file_name]['name']);
        $file_extension = null;
        if (is_array($file_name_explode)) {
            $file_extension = '.'.$file_name_explode[count($file_name_explode)-1];
        }
        unset($file_name_explode);
        // add to queue.
        $this->move_uploaded_queue = array_merge(
            $this->move_uploaded_queue, 
            array(
                $this->files[$this->input_file_name]['input_file_key'] => array(
                    'name' => $this->files[$this->input_file_name]['name'],
                    'tmp_name' => $this->files[$this->input_file_name]['tmp_name'],
                    'new_name' => $this->new_file_name.$file_extension,
                )
            )
        );
        // restore temp of new file name to ready for next loop of upload multiple.
        $this->new_file_name = $tmp_new_file_name;
        unset($file_extension, $tmp_new_file_name);

        // done.
        return true;
    }
836325
public function getErrorMessage()
    {
        $baseInternalError = 'An internal error occurred that prevented this file from being uploaded';
        switch ($this->error) {
            case UPLOAD_ERR_INI_SIZE:
            case UPLOAD_ERR_FORM_SIZE:
                return 'The file is too big.';
            break;
            case UPLOAD_ERR_PARTIAL:
                return 'The file upload process was interupted. Please try again.';
            break;
            case UPLOAD_ERR_NO_TMP_DIR:
                return $baseInternalError . ' (TMP_DIR)';
            break;
            case UPLOAD_ERR_CANT_WRITE:
                return $baseInternalError . ' (CANT_WRITE)';
            break;
            case UPLOAD_ERR_EXTENSION:
                return $baseInternalError . ' (PHP_EXTENSION)';
            break;

        }

        return;
    }
398864
public function getPotentialMessage()
    {
        $message = clone ($this->getErrorMessagePrototype());
        $message->setTemplate($this->getMessageTemplate());
        $message->setVariables($this->options);

        return $message;
    }
1310505
@Override
    public void buildMimeMessage() throws EmailException {
	try {
	    // if the email has attachments then the base type is mixed,
	    // otherwise it should be related
	    if (this.isBoolHasAttachments()) {
		this.buildAttachments();
	    }
	    else {
		this.buildNoAttachments();
	    }

	}
	catch (MessagingException me) {
	    throw new EmailException(me);
	}
	super.buildMimeMessage();
    }
933643
protected String createIssueMessage(Issue issue) {
		final IssueMessageFormatter formatter = getIssueMessageFormatter();
		final org.eclipse.emf.common.util.URI uriToProblem = issue.getUriToProblem();
		if (formatter != null) {
			final String message = formatter.format(issue, uriToProblem);
			if (message != null) {
				return message;
			}
		}
		if (uriToProblem != null) {
			final org.eclipse.emf.common.util.URI resourceUri = uriToProblem.trimFragment();
			return MessageFormat.format(Messages.SarlBatchCompiler_4,
					issue.getSeverity(), resourceUri.lastSegment(),
					resourceUri.isFile() ? resourceUri.toFileString() : "", //$NON-NLS-1$
							issue.getLineNumber(), issue.getColumn(), issue.getCode(), issue.getMessage());
		}
		return MessageFormat.format(Messages.SarlBatchCompiler_5,
				issue.getSeverity(), issue.getLineNumber(), issue.getColumn(), issue.getCode(), issue.getMessage());
	}
883309
final public static function fromLastError()
    {
        $error = error_get_last();
        if ($error !== null) {
            return new ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']);
        }
    }
933799
public String build()
    {
        this.message_string  = "{";

        if( this.recipient_id != null ){
            this.message_string += "\"recipient\": {\"id\": \"" + this.recipient_id + "\"},";
        }

        if( !this.elements.isEmpty() ){

            this.message_string += "\"message\": {";

                this.message_string += "\"attachment\": {";

                    this.message_string += "\"type\": \"template\",";

                    this.message_string += "\"payload\": {";

                        if( this.element_style.equals("compact") ){
                            this.message_string += "\"top_element_style\":\"" + this.element_style + "\",";
                        }

                        if( !this.elements.isEmpty() ){

                            this.message_string += "\"elements\":[";
                            for ( int j = 0 ; j < this.elements.size(); j++ ) {
                                HashMap<String, Object> element = this.elements.get(j);

                                this.message_string += "{";
                                if( !element.get("title").equals("") ){
                                    this.message_string += "\"title\":\"" + element.get("title") + "\",";
                                }
                                if( !element.get("image_url").equals("") ){
                                    this.message_string += "\"image_url\":\"" + element.get("image_url") + "\",";
                                }
                                if( !element.get("subtitle").equals("") ){
                                    this.message_string += "\"subtitle\":\"" + element.get("subtitle") + "\",";
                                }

                                if( !element.get("default_action_type").equals("") || !element.get("default_action_url").equals("") || !element.get("default_action_messenger_extensions").equals("") || !element.get("default_action_webview_height_ratio").equals("") || !element.get("default_action_fallback_url").equals("") ){
                                    this.message_string += "\"default_action\":{";
                                        if( !element.get("default_action_type").equals("") ){
                                            this.message_string += "\"type\":\"" + element.get("default_action_type") + "\",";
                                        }
                                        if( !element.get("default_action_url").equals("") ){
                                            this.message_string += "\"url\":\"" + element.get("default_action_url") + "\",";
                                        }
                                        if( !element.get("default_action_messenger_extensions").equals("") ){
                                            this.message_string += "\"messenger_extensions\":\"" + element.get("default_action_messenger_extensions") + "\",";
                                        }
                                        if( !element.get("default_action_webview_height_ratio").equals("") ){
                                            this.message_string += "\"webview_height_ratio\":\"" + element.get("default_action_webview_height_ratio") + "\",";
                                        }
                                        if( !element.get("default_action_fallback_url").equals("") ){
                                            this.message_string += "\"fallback_url\":\"" + element.get("default_action_fallback_url") + "\",";
                                        }
                                        this.message_string = this.message_string.replaceAll(",$", "");
                                    this.message_string += "},";
                                }


                                if( element.containsKey("buttons") ){
                                    ArrayList<HashMap<String, String>> buttons = (ArrayList<HashMap<String, String>>) element.get("buttons");
                                    if( !buttons.isEmpty() ){

                                        this.message_string += "\"buttons\": [";

                                            for ( int k = 0 ; k < buttons.size(); k++ ) {
                                                HashMap<String, String> button = buttons.get(k);
                                                this.message_string += "{";
                                                    if( !button.get("title").equals("") ){
                                                        this.message_string += "\"title\":\"" + button.get("title") + "\",";
                                                    }
                                                    if( !button.get("type").equals("") ){
                                                        this.message_string += "\"type\":\"" + button.get("type") + "\",";
                                                    }
                                                    if( !button.get("url").equals("") ){
                                                        this.message_string += "\"url\":\"" + button.get("url") + "\",";
                                                    }
                                                    if( !button.get("messenger_extensions").equals("") ){
                                                        this.message_string += "\"messenger_extensions\":\"" + button.get("messenger_extensions") + "\",";
                                                    }
                                                    if( !button.get("webview_height_ratio").equals("") ){
                                                        this.message_string += "\"webview_height_ratio\":\"" + button.get("webview_height_ratio") + "\",";
                                                    }
                                                    if( !button.get("fallback_url").equals("") ){
                                                        this.message_string += "\"fallback_url\":\"" + button.get("fallback_url") + "\",";
                                                    }
                                                this.message_string = this.message_string.replaceAll(",$", "");
                                                this.message_string += "},";
                                            }

                                            this.message_string = this.message_string.replaceAll(",$", "");
                                        this.message_string += "]";
                                    }
                                }

                                this.message_string = this.message_string.replaceAll(",$", "");
                                this.message_string += "},";
                            }

                            this.message_string = this.message_string.replaceAll(",$", "");
                            this.message_string += "],";
                        }

                        this.message_string += "\"buttons\":[";
                        for ( int j = 0 ; j < this.buttons.size(); j++ ) {
                            HashMap<String, String> button = this.buttons.get(j);

                            this.message_string += "{";
                            if( !button.get("type").equals("") ){
                                this.message_string += "\"type\":\"" + button.get("type") + "\",";
                            }
                            if( !button.get("title").equals("") ){
                                this.message_string += "\"title\":\"" + button.get("title") + "\",";
                            }
                            if( !button.get("url").equals("") ){
                                this.message_string += "\"url\":\"" + button.get("url") + "\",";
                            }
                            if( !button.get("payload").equals("") ){
                                this.message_string += "\"payload\":\"" + button.get("payload") + "\",";
                            }
                            this.message_string = this.message_string.replaceAll(",$", "");
                            this.message_string += "},";
                        }

                        this.message_string = this.message_string.replaceAll(",$", "");
                        this.message_string += "]";

                    this.message_string += "}";

                this.message_string += "}";

            this.message_string += "}";

        }

        this.message_string = this.message_string.replaceAll(",$", "");
        this.message_string += "}";

        return this.message_string;
    }
218627
public String buildErrorMessages() {

        StringBuffer result = new StringBuffer(8);
        String errorMessages = getErrorMessagesString();
        if (!"".equals(errorMessages)) {
            result.append(dialogBlock(HTML_START, key(Messages.GUI_PERMISSION_ERROR_0), true));
            result.append("<font color='red'>").append(errorMessages).append("</font>");
            result.append(dialogBlockEnd());
        }
        return result.toString();
    }
262024
public function toMessage()
    {
        $m = new Message(array(
            $this->getRequestId(),
            $this->getActionName(),
        ));
        $m->append($this->getParameters());

        return $m;
    }