Search in sources :

Example 1 with ATTACHMENT

use of com.enonic.xp.content.ContentPropertyNames.ATTACHMENT in project xp by enonic.

the class ContentDataSerializer method mapValidationError.

private ValidationError mapValidationError(final PropertySet ve) {
    final Object[] args = Optional.ofNullable(ve.getString("args")).map(argsJson -> {
        try {
            return OBJECT_MAPPER.readValue(argsJson, Object[].class);
        } catch (JsonProcessingException e) {
            throw new UncheckedIOException(e);
        }
    }).orElse(null);
    final ValidationErrorCode errorCode = ValidationErrorCode.parse(ve.getString("errorCode"));
    if (ve.hasProperty("propertyPath")) {
        return ValidationError.dataError(errorCode, PropertyPath.from(ve.getString("propertyPath"))).message(ve.getString("message"), true).i18n(ve.getString("i18n")).args(args).build();
    } else if (ve.hasProperty("attachment")) {
        return ValidationError.attachmentError(errorCode, BinaryReference.from(ve.getString("attachment"))).message(ve.getString("message"), true).i18n(ve.getString("i18n")).args(args).build();
    } else {
        return ValidationError.generalError(errorCode).message(ve.getString("message"), true).i18n(ve.getString("i18n")).args(args).build();
    }
}
Also used : OWNER(com.enonic.xp.content.ContentPropertyNames.OWNER) WorkflowInfo(com.enonic.xp.content.WorkflowInfo) CREATOR(com.enonic.xp.content.ContentPropertyNames.CREATOR) AttachmentSerializer(com.enonic.xp.attachment.AttachmentSerializer) Page(com.enonic.xp.page.Page) ValidationErrors(com.enonic.xp.content.ValidationErrors) ContentName(com.enonic.xp.content.ContentName) ContentId(com.enonic.xp.content.ContentId) INHERIT(com.enonic.xp.content.ContentPropertyNames.INHERIT) DataValidationError(com.enonic.xp.content.DataValidationError) Locale(java.util.Locale) Map(java.util.Map) CreateAttachment(com.enonic.xp.attachment.CreateAttachment) ValidationError(com.enonic.xp.content.ValidationError) WORKFLOW_INFO_CHECKS(com.enonic.xp.content.ContentPropertyNames.WORKFLOW_INFO_CHECKS) Thumbnail(com.enonic.xp.icon.Thumbnail) BinaryReference(com.enonic.xp.util.BinaryReference) DISPLAY_NAME(com.enonic.xp.content.ContentPropertyNames.DISPLAY_NAME) ValidationErrorCode(com.enonic.xp.content.ValidationErrorCode) PROCESSED_REFERENCES(com.enonic.xp.content.ContentPropertyNames.PROCESSED_REFERENCES) PUBLISH_TO(com.enonic.xp.content.ContentPropertyNames.PUBLISH_TO) WORKFLOW_INFO_STATE(com.enonic.xp.content.ContentPropertyNames.WORKFLOW_INFO_STATE) Set(java.util.Set) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) Collectors(java.util.stream.Collectors) ExtraDatas(com.enonic.xp.content.ExtraDatas) NodeId(com.enonic.xp.node.NodeId) UncheckedIOException(java.io.UncheckedIOException) TYPE(com.enonic.xp.content.ContentPropertyNames.TYPE) AttachmentNames(com.enonic.xp.attachment.AttachmentNames) VALID(com.enonic.xp.content.ContentPropertyNames.VALID) Optional(java.util.Optional) MODIFIED_TIME(com.enonic.xp.content.ContentPropertyNames.MODIFIED_TIME) UpdateContentTranslatorParams(com.enonic.xp.content.UpdateContentTranslatorParams) ARCHIVED_TIME(com.enonic.xp.content.ContentPropertyNames.ARCHIVED_TIME) CREATED_TIME(com.enonic.xp.content.ContentPropertyNames.CREATED_TIME) BinaryReferences(com.enonic.xp.util.BinaryReferences) Strings.nullToEmpty(com.google.common.base.Strings.nullToEmpty) PUBLISH_FIRST(com.enonic.xp.content.ContentPropertyNames.PUBLISH_FIRST) ORIGINAL_PARENT_PATH(com.enonic.xp.content.ContentPropertyNames.ORIGINAL_PARENT_PATH) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) Attachment(com.enonic.xp.attachment.Attachment) ContentTypeName(com.enonic.xp.schema.content.ContentTypeName) ORIGIN_PROJECT(com.enonic.xp.content.ContentPropertyNames.ORIGIN_PROJECT) ORIGINAL_NAME(com.enonic.xp.content.ContentPropertyNames.ORIGINAL_NAME) LinkedHashMap(java.util.LinkedHashMap) PUBLISH_FROM(com.enonic.xp.content.ContentPropertyNames.PUBLISH_FROM) VALIDATION_ERRORS(com.enonic.xp.content.ContentPropertyNames.VALIDATION_ERRORS) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) PUBLISH_INFO(com.enonic.xp.content.ContentPropertyNames.PUBLISH_INFO) CreateAttachments(com.enonic.xp.attachment.CreateAttachments) Exceptions(com.enonic.xp.util.Exceptions) ATTACHMENT(com.enonic.xp.content.ContentPropertyNames.ATTACHMENT) ProjectName(com.enonic.xp.project.ProjectName) DATA(com.enonic.xp.content.ContentPropertyNames.DATA) StreamSupport(java.util.stream.StreamSupport) PropertyPath(com.enonic.xp.data.PropertyPath) LANGUAGE(com.enonic.xp.content.ContentPropertyNames.LANGUAGE) WORKFLOW_INFO(com.enonic.xp.content.ContentPropertyNames.WORKFLOW_INFO) PropertyTree(com.enonic.xp.data.PropertyTree) ObjectMapperHelper(com.enonic.xp.json.ObjectMapperHelper) PartDescriptorService(com.enonic.xp.region.PartDescriptorService) ContentPropertyNames(com.enonic.xp.content.ContentPropertyNames) ContentPath(com.enonic.xp.content.ContentPath) PropertySet(com.enonic.xp.data.PropertySet) MODIFIER(com.enonic.xp.content.ContentPropertyNames.MODIFIER) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ContentInheritType(com.enonic.xp.content.ContentInheritType) Content(com.enonic.xp.content.Content) ARCHIVED_BY(com.enonic.xp.content.ContentPropertyNames.ARCHIVED_BY) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ContentPublishInfo(com.enonic.xp.content.ContentPublishInfo) AttachmentValidationError(com.enonic.xp.content.AttachmentValidationError) COMPONENTS(com.enonic.xp.core.impl.content.serializer.ComponentDataSerializer.COMPONENTS) PrincipalKey(com.enonic.xp.security.PrincipalKey) Reference(com.enonic.xp.util.Reference) EXTRA_DATA(com.enonic.xp.content.ContentPropertyNames.EXTRA_DATA) ContentIds(com.enonic.xp.content.ContentIds) Attachments(com.enonic.xp.attachment.Attachments) Preconditions(com.google.common.base.Preconditions) CreateContentTranslatorParams(com.enonic.xp.content.CreateContentTranslatorParams) UncheckedIOException(java.io.UncheckedIOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ValidationErrorCode(com.enonic.xp.content.ValidationErrorCode)

Aggregations

Attachment (com.enonic.xp.attachment.Attachment)1 AttachmentNames (com.enonic.xp.attachment.AttachmentNames)1 AttachmentSerializer (com.enonic.xp.attachment.AttachmentSerializer)1 Attachments (com.enonic.xp.attachment.Attachments)1 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)1 CreateAttachments (com.enonic.xp.attachment.CreateAttachments)1 AttachmentValidationError (com.enonic.xp.content.AttachmentValidationError)1 Content (com.enonic.xp.content.Content)1 ContentId (com.enonic.xp.content.ContentId)1 ContentIds (com.enonic.xp.content.ContentIds)1 ContentInheritType (com.enonic.xp.content.ContentInheritType)1 ContentName (com.enonic.xp.content.ContentName)1 ContentPath (com.enonic.xp.content.ContentPath)1 ContentPropertyNames (com.enonic.xp.content.ContentPropertyNames)1 ARCHIVED_BY (com.enonic.xp.content.ContentPropertyNames.ARCHIVED_BY)1 ARCHIVED_TIME (com.enonic.xp.content.ContentPropertyNames.ARCHIVED_TIME)1 ATTACHMENT (com.enonic.xp.content.ContentPropertyNames.ATTACHMENT)1 CREATED_TIME (com.enonic.xp.content.ContentPropertyNames.CREATED_TIME)1 CREATOR (com.enonic.xp.content.ContentPropertyNames.CREATOR)1 DATA (com.enonic.xp.content.ContentPropertyNames.DATA)1