@Test public void testCustomModified_Modified() { final DAVAttributesFinderFeature f = new DAVAttributesFinderFeature(null); final DavResource mock = mock(DavResource.class); Map<QName, String> map = new HashMap<>(); map.put(DAVTimestampFeature.LAST_MODIFIED_CUSTOM_NAMESPACE, "Mon, 29 Oct 2018 21:14:06 UTC"); map.put(DAVTimestampFeature.LAST_MODIFIED_SERVER_CUSTOM_NAMESPACE, "Thu, 01 Nov 2018 15:31:57 UTC"); final Date modified = new DateTime("2018-11-02T15:31:57Z").toDate(); when(mock.getModified()).thenReturn(modified); when(mock.getCustomPropsNS()).thenReturn(map); final PathAttributes attrs = f.toAttributes(mock); assertEquals(modified.getTime(), attrs.getModificationDate()); }
protected 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())) { attributes.setModificationDate( rfc1123.parse(value).getTime()); } else { 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()); } } } 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()); } if(StringUtils.isNotBlank(resource.getDisplayName())) { attributes.setDisplayname(resource.getDisplayName()); } attributes.setLockId(resource.getLockToken()); return attributes; }
DAVAttributesFinderFeature implements AttributesFinder { protected 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())) { attributes.setModificationDate( rfc1123.parse(value).getTime()); } else { 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()); } } } 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()); } if(StringUtils.isNotBlank(resource.getDisplayName())) { attributes.setDisplayname(resource.getDisplayName()); } attributes.setLockId(resource.getLockToken()); return attributes; } }
DAVAttributesFinderFeature implements AttributesFinder { protected 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())) { attributes.setModificationDate( rfc1123.parse(value).getTime()); } else { 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()); } } } 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()); } if(StringUtils.isNotBlank(resource.getDisplayName())) { attributes.setDisplayname(resource.getDisplayName()); } attributes.setLockId(resource.getLockToken()); return attributes; } DAVAttributesFinderFeature(DAVSession session); }
DAVAttributesFinderFeature implements AttributesFinder { protected 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())) { attributes.setModificationDate( rfc1123.parse(value).getTime()); } else { 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()); } } } 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()); } if(StringUtils.isNotBlank(resource.getDisplayName())) { attributes.setDisplayname(resource.getDisplayName()); } attributes.setLockId(resource.getLockToken()); return attributes; } DAVAttributesFinderFeature(DAVSession session); @Override PathAttributes find(final Path file); }
DAVAttributesFinderFeature implements AttributesFinder { protected 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())) { attributes.setModificationDate( rfc1123.parse(value).getTime()); } else { 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()); } } } 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()); } if(StringUtils.isNotBlank(resource.getDisplayName())) { attributes.setDisplayname(resource.getDisplayName()); } attributes.setLockId(resource.getLockToken()); return attributes; } DAVAttributesFinderFeature(DAVSession session); @Override PathAttributes find(final Path file);  }