Exemple #1
0
        public async Task <NodeEntry> Register(NodeUpdate body, EmailOrDataboxEnum type)
        {
            var nodeInfo = await _alfrescoHttpClient.GetNodeInfo(body.NodeId, ImmutableList <Parameter> .Empty
                                                                 .Add(new Parameter(AlfrescoNames.Headers.Include, AlfrescoNames.Includes.Path, ParameterType.QueryString)));

            var archiveFolder = string.Empty;
            var nodeType      = string.Empty;

            switch (type)
            {
            case EmailOrDataboxEnum.Email:
                archiveFolder = SpisumNames.Paths.MailRoomEmailArchived;
                nodeType      = SpisumNames.NodeTypes.Email;
                break;

            case EmailOrDataboxEnum.Databox:
                archiveFolder = SpisumNames.Paths.MailRoomDataBoxArchived;
                nodeType      = SpisumNames.NodeTypes.DataBox;
                break;
            }

            var pathRegex = new Regex($"({SpisumNames.Paths.MailRoomUnfinished})$", RegexOptions.IgnoreCase);

            if (pathRegex.IsMatch(nodeInfo?.Entry?.Path?.Name ?? ""))
            {
                return(await CreateArhiveAndMoveAllFiles(body, archiveFolder, nodeType));
            }
            throw new BadRequestException("", "Node is not in expected path");
        }
Exemple #2
0
        public async Task DontRegister(DontRegister parameters, EmailOrDataboxEnum type)
        {
            var emlNode = await _alfrescoHttpClient.GetNodeInfo(parameters.NodeId, ImmutableList <Parameter> .Empty
                                                                .Add(new Parameter(AlfrescoNames.Headers.Include, AlfrescoNames.Includes.Path, ParameterType.QueryString)));

            if (parameters.Body.Reason.Length < 4)
            {
                throw new BadRequestException(ErrorCodes.V_MIN_TEXT);
            }

            if (parameters.Body.Reason.Length > 30)
            {
                parameters.Body.Reason = parameters.Body.Reason.Substring(0, 30);
            }

            var body = new NodeBodyUpdate();
            var path = string.Empty;

            switch (type)
            {
            case EmailOrDataboxEnum.Email:

                if (emlNode?.Entry?.Path?.Name.StartsWith(AlfrescoNames.Prefixes.Path + SpisumNames.Paths.MailRoomEmail, StringComparison.OrdinalIgnoreCase) == false)
                {
                    throw new BadRequestException("", "Node is not in Mailbox");
                }

                body = new NodeBodyUpdate
                {
                    Properties = new Dictionary <string, object>
                    {
                        { SpisumNames.Properties.EmailNotRegisteredReason, parameters.Body.Reason }
                    }
                };
                path = SpisumNames.Paths.MailRoomEmailNotRegistered;
                break;

            case EmailOrDataboxEnum.Databox:
                if (emlNode?.Entry?.Path?.Name.StartsWith(AlfrescoNames.Prefixes.Path + SpisumNames.Paths.MailRoomDataBox, StringComparison.OrdinalIgnoreCase) == false)
                {
                    throw new BadRequestException("", "Node is not in Databox");
                }

                body = new NodeBodyUpdate
                {
                    Properties = new Dictionary <string, object>
                    {
                        { SpisumNames.Properties.DataBoxNotRegisteredReason, parameters.Body.Reason }
                    }
                };
                path = SpisumNames.Paths.MailRoomDataBoxNotRegistered;
                break;
            }

            await _alfrescoHttpClient.UpdateNode(parameters.NodeId, body);

            await _nodesService.MoveChildrenByPath(parameters.NodeId, path);
        }