Search in sources :

Example 1 with RFC1123DateFormatter

use of ch.cyberduck.core.date.RFC1123DateFormatter in project cyberduck by iterate-ch.

the class InfoController method metadataAddExpiresClicked.

@Action
public void metadataAddExpiresClicked(ID sender) {
    final Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    time.add(Calendar.SECOND, preferences.getInteger("s3.cache.seconds"));
    this.addMetadataItem("Expires", new RFC1123DateFormatter().format(time.getTime(), TimeZone.getTimeZone("UTC")));
}
Also used : RFC1123DateFormatter(ch.cyberduck.core.date.RFC1123DateFormatter) Calendar(java.util.Calendar) Action(ch.cyberduck.binding.Action) RegistryBackgroundAction(ch.cyberduck.core.threading.RegistryBackgroundAction) WindowMainAction(ch.cyberduck.core.threading.WindowMainAction) WorkerBackgroundAction(ch.cyberduck.core.threading.WorkerBackgroundAction)

Example 2 with RFC1123DateFormatter

use of ch.cyberduck.core.date.RFC1123DateFormatter in project cyberduck by iterate-ch.

the class DAVAttributesFinderFeatureTest method testCustomModified_NotModified.

@Test
public void testCustomModified_NotModified() throws Exception {
    final DAVAttributesFinderFeature f = new DAVAttributesFinderFeature(null);
    final DavResource mock = mock(DavResource.class);
    Map<QName, String> map = new HashMap<>();
    final String ts = "Mon, 29 Oct 2018 21:14:06 UTC";
    map.put(DAVTimestampFeature.LAST_MODIFIED_CUSTOM_NAMESPACE, ts);
    map.put(DAVTimestampFeature.LAST_MODIFIED_SERVER_CUSTOM_NAMESPACE, "Thu, 01 Nov 2018 15:31:57 UTC");
    when(mock.getModified()).thenReturn(new DateTime("2018-11-01T15:31:57Z").toDate());
    when(mock.getCustomPropsNS()).thenReturn(map);
    final PathAttributes attrs = f.toAttributes(mock);
    assertEquals(new RFC1123DateFormatter().parse(ts).getTime(), attrs.getModificationDate());
}
Also used : DavResource(com.github.sardine.DavResource) HashMap(java.util.HashMap) RFC1123DateFormatter(ch.cyberduck.core.date.RFC1123DateFormatter) QName(javax.xml.namespace.QName) PathAttributes(ch.cyberduck.core.PathAttributes) DateTime(org.joda.time.DateTime) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 3 with RFC1123DateFormatter

use of ch.cyberduck.core.date.RFC1123DateFormatter in project cyberduck by iterate-ch.

the class MicrosoftIISDAVTimestampFeature method getCustomProperties.

protected List<Element> getCustomProperties(final DavResource resource, final Long modified) {
    final List<Element> props = new ArrayList<>();
    final Element element = SardineUtil.createElement(LAST_MODIFIED_WIN32_CUSTOM_NAMESPACE);
    element.setTextContent(new RFC1123DateFormatter().format(modified, TimeZone.getTimeZone("GMT")));
    props.add(element);
    return props;
}
Also used : RFC1123DateFormatter(ch.cyberduck.core.date.RFC1123DateFormatter) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList)

Example 4 with RFC1123DateFormatter

use of ch.cyberduck.core.date.RFC1123DateFormatter in project cyberduck by iterate-ch.

the class DAVTimestampFeature method getCustomProperties.

protected List<Element> getCustomProperties(final DavResource resource, final Long modified) {
    final List<Element> props = new ArrayList<>();
    if (resource.getModified() != null) {
        Element element = SardineUtil.createElement(LAST_MODIFIED_SERVER_CUSTOM_NAMESPACE);
        element.setTextContent(new RFC1123DateFormatter().format(resource.getModified(), TimeZone.getTimeZone("UTC")));
        props.add(element);
    }
    Element element = SardineUtil.createElement(LAST_MODIFIED_CUSTOM_NAMESPACE);
    element.setTextContent(new RFC1123DateFormatter().format(modified, TimeZone.getTimeZone("UTC")));
    props.add(element);
    return props;
}
Also used : RFC1123DateFormatter(ch.cyberduck.core.date.RFC1123DateFormatter) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList)

Example 5 with RFC1123DateFormatter

use of ch.cyberduck.core.date.RFC1123DateFormatter in project cyberduck by iterate-ch.

the class MicrosoftIISDAVAttributesFinderFeatureTest method testCustomModified_PropertyAvailable.

@Test
public void testCustomModified_PropertyAvailable() throws Exception {
    final MicrosoftIISDAVAttributesFinderFeature f = new MicrosoftIISDAVAttributesFinderFeature(null);
    final DavResource mock = mock(DavResource.class);
    Map<QName, String> map = new HashMap<>();
    final String ts = "Mon, 29 Oct 2018 21:14:06 GMT";
    map.put(MicrosoftIISDAVTimestampFeature.LAST_MODIFIED_WIN32_CUSTOM_NAMESPACE, ts);
    when(mock.getModified()).thenReturn(new DateTime("2018-11-01T15:31:57Z").toDate());
    when(mock.getCustomPropsNS()).thenReturn(map);
    final PathAttributes attrs = f.toAttributes(mock);
    assertEquals(new RFC1123DateFormatter().parse(ts).getTime(), attrs.getModificationDate());
}
Also used : DavResource(com.github.sardine.DavResource) HashMap(java.util.HashMap) RFC1123DateFormatter(ch.cyberduck.core.date.RFC1123DateFormatter) QName(javax.xml.namespace.QName) PathAttributes(ch.cyberduck.core.PathAttributes) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

RFC1123DateFormatter (ch.cyberduck.core.date.RFC1123DateFormatter)5 PathAttributes (ch.cyberduck.core.PathAttributes)2 DavResource (com.github.sardine.DavResource)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 QName (javax.xml.namespace.QName)2 DateTime (org.joda.time.DateTime)2 Test (org.junit.Test)2 Element (org.w3c.dom.Element)2 Action (ch.cyberduck.binding.Action)1 RegistryBackgroundAction (ch.cyberduck.core.threading.RegistryBackgroundAction)1 WindowMainAction (ch.cyberduck.core.threading.WindowMainAction)1 WorkerBackgroundAction (ch.cyberduck.core.threading.WorkerBackgroundAction)1 IntegrationTest (ch.cyberduck.test.IntegrationTest)1 Calendar (java.util.Calendar)1