@Override
    public PathAttributes toAttributes(final DavResource resource) {
        final PathAttributes attributes = new PathAttributes();
        final Map<QName, String> properties = resource.getCustomPropsNS();
        if(null != properties && properties.containsKey(DAVTimestampFeature.LAST_MODIFIED_CUSTOM_NAMESPACE)) {
            final String value = properties.get(DAVTimestampFeature.LAST_MODIFIED_CUSTOM_NAMESPACE);
            if(StringUtils.isNotBlank(value)) {
                try {
                    if(properties.containsKey(DAVTimestampFeature.LAST_MODIFIED_SERVER_CUSTOM_NAMESPACE)) {
                        final String svalue = properties.get(DAVTimestampFeature.LAST_MODIFIED_SERVER_CUSTOM_NAMESPACE);
                        if(StringUtils.isNotBlank(svalue)) {
                            final Date server = rfc1123.parse(svalue);
                            if(server.equals(resource.getModified())) {
                                // file not touched with a different client
                                attributes.setModificationDate(
                                        rfc1123.parse(value).getTime());
                            }
                            else {
                                // file touched with a different client, use default modified date from server
                                if(resource.getModified() != null) {
                                    attributes.setModificationDate(resource.getModified().getTime());
                                }
                            }
                        }
                        else {
                            if(log.isDebugEnabled()) {
                                log.debug(String.format("Missing value for property %s", DAVTimestampFeature.LAST_MODIFIED_SERVER_CUSTOM_NAMESPACE));
                            }
                            if(resource.getModified() != null) {
                                attributes.setModificationDate(resource.getModified().getTime());
                            }
                        }
                    }
                    else {
                        attributes.setModificationDate(
                                rfc1123.parse(value).getTime());
                    }
                }
                catch(InvalidDateException e) {
                    log.warn(String.format("Failure parsing property %s with value %s", DAVTimestampFeature.LAST_MODIFIED_CUSTOM_NAMESPACE, value));
                    if(resource.getModified() != null) {
                        attributes.setModificationDate(resource.getModified().getTime());
                    }
                }
            }
            else {
                if(log.isDebugEnabled()) {
                    log.debug(String.format("Missing value for property %s", DAVTimestampFeature.LAST_MODIFIED_CUSTOM_NAMESPACE));
                }
                if(resource.getModified() != null) {
                    attributes.setModificationDate(resource.getModified().getTime());
                }
            }
            // Validate value with fallback to server side modified date
            if(attributes.getModificationDate() == 0) {
                if(log.isDebugEnabled()) {
                    log.debug(String.format("Invalid value for property %s", DAVTimestampFeature.LAST_MODIFIED_CUSTOM_NAMESPACE));
                }
                if(resource.getModified() != null) {
                    attributes.setModificationDate(resource.getModified().getTime());
                }
            }
        }
        else if(resource.getModified() != null) {
            attributes.setModificationDate(resource.getModified().getTime());
        }
        if(resource.getCreation() != null) {
            attributes.setCreationDate(resource.getCreation().getTime());
        }
        if(resource.getContentLength() != null) {
            attributes.setSize(resource.getContentLength());
        }
        if(StringUtils.isNotBlank(resource.getEtag())) {
            attributes.setETag(resource.getEtag());
        }
        if(StringUtils.isNotBlank(resource.getDisplayName())) {
            attributes.setDisplayname(resource.getDisplayName());
        }
        attributes.setLockId(resource.getLockToken());
        return attributes;
    }
@Test
    public void testCustomModified_NotSet() {
        final DAVAttributesFinderFeature f = new DAVAttributesFinderFeature(null);
        final DavResource mock = mock(DavResource.class);

        Map<QName, String> map = new HashMap<>();
        final Date modified = new DateTime("2018-11-01T15:31:57Z").toDate();
        when(mock.getModified()).thenReturn(modified);
        when(mock.getCustomPropsNS()).thenReturn(map);

        final PathAttributes attrs = f.toAttributes(mock);
        assertEquals(modified.getTime(), attrs.getModificationDate());
    }