Search in sources :

Example 6 with PathAttributes

use of ch.cyberduck.core.PathAttributes in project cyberduck by iterate-ch.

the class BrickAttributesFinderFeatureTest method testFindFile.

@Test
public void testFindFile() throws Exception {
    final Path folder = new BrickDirectoryFeature(session).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
    final Path test = new BrickTouchFeature(session).touch(new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
    final BrickAttributesFinderFeature f = new BrickAttributesFinderFeature(session);
    final PathAttributes attributes = f.find(test);
    assertEquals(0L, attributes.getSize());
    assertNotEquals(-1L, attributes.getModificationDate());
    assertNull(attributes.getChecksum().algorithm);
    assertTrue(attributes.getPermission().isReadable());
    assertTrue(attributes.getPermission().isWritable());
    // Test wrong type
    try {
        f.find(new Path(test.getAbsolute(), EnumSet.of(Path.Type.directory)));
        fail();
    } catch (NotfoundException e) {
    // Expected
    }
    new BrickDeleteFeature(session).delete(Collections.singletonList(folder), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) NotfoundException(ch.cyberduck.core.exception.NotfoundException) PathAttributes(ch.cyberduck.core.PathAttributes) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 7 with PathAttributes

use of ch.cyberduck.core.PathAttributes in project cyberduck by iterate-ch.

the class BrickAttributesFinderFeatureTest method testFindRoot.

@Test
public void testFindRoot() throws Exception {
    final BrickAttributesFinderFeature f = new BrickAttributesFinderFeature(session);
    final PathAttributes attributes = f.find(new Path("/", EnumSet.of(Path.Type.volume, Path.Type.directory)));
    assertNotEquals(PathAttributes.EMPTY, attributes);
}
Also used : Path(ch.cyberduck.core.Path) PathAttributes(ch.cyberduck.core.PathAttributes) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 8 with PathAttributes

use of ch.cyberduck.core.PathAttributes in project cyberduck by iterate-ch.

the class BoxAttributesFinderFeatureTest method testFindDirectory.

@Test
public void testFindDirectory() throws Exception {
    final BoxFileidProvider fileid = new BoxFileidProvider(session);
    final Path folder = new BoxDirectoryFeature(session, fileid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
    final Path test = new BoxDirectoryFeature(session, fileid).mkdir(new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
    final BoxAttributesFinderFeature f = new BoxAttributesFinderFeature(session, fileid);
    final PathAttributes attributes = f.find(test);
    assertNotEquals(-1L, attributes.getSize());
    assertNotEquals(-1L, attributes.getModificationDate());
    assertNull(attributes.getChecksum().algorithm);
    assertNull(attributes.getETag());
    assertTrue(attributes.getPermission().isReadable());
    assertTrue(attributes.getPermission().isWritable());
    assertTrue(attributes.getPermission().isExecutable());
    // Test wrong type
    try {
        f.find(new Path(test.getAbsolute(), EnumSet.of(Path.Type.file)));
        fail();
    } catch (NotfoundException e) {
    // Expected
    }
    new BoxDeleteFeature(session, fileid).delete(Collections.singletonList(folder), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) NotfoundException(ch.cyberduck.core.exception.NotfoundException) PathAttributes(ch.cyberduck.core.PathAttributes) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 9 with PathAttributes

use of ch.cyberduck.core.PathAttributes in project cyberduck by iterate-ch.

the class BoxAttributesFinderFeatureTest method testFindFile.

@Test
public void testFindFile() throws Exception {
    final BoxFileidProvider fileid = new BoxFileidProvider(session);
    final Path folder = new BoxDirectoryFeature(session, fileid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
    final Path test = new BoxTouchFeature(session, fileid).touch(new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus().withLength(0L));
    final BoxAttributesFinderFeature f = new BoxAttributesFinderFeature(session, fileid);
    final PathAttributes attributes = f.find(test);
    assertEquals(0L, attributes.getSize());
    assertNotEquals(-1L, attributes.getModificationDate());
    assertNotNull(attributes.getFileId());
    assertNotNull(attributes.getETag());
    assertNotNull(attributes.getChecksum().algorithm);
    assertTrue(attributes.getPermission().isReadable());
    assertTrue(attributes.getPermission().isWritable());
    // Test wrong type
    try {
        f.find(new Path(test.getAbsolute(), EnumSet.of(Path.Type.directory)));
        fail();
    } catch (NotfoundException e) {
    // Expected
    }
    new BoxDeleteFeature(session, fileid).delete(Collections.singletonList(folder), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) NotfoundException(ch.cyberduck.core.exception.NotfoundException) PathAttributes(ch.cyberduck.core.PathAttributes) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 10 with PathAttributes

use of ch.cyberduck.core.PathAttributes in project cyberduck by iterate-ch.

the class PathAttributesDictionary method deserialize.

public <T> PathAttributes deserialize(T serialized) {
    final Deserializer dict = factory.create(serialized);
    final PathAttributes attributes = new PathAttributes();
    final String sizeObj = dict.stringForKey("Size");
    if (sizeObj != null) {
        attributes.setSize(Long.parseLong(sizeObj));
    }
    final String quotaObj = dict.stringForKey("Quota");
    if (quotaObj != null) {
        attributes.setQuota(Long.parseLong(quotaObj));
    }
    final String modifiedObj = dict.stringForKey("Modified");
    if (modifiedObj != null) {
        attributes.setModificationDate(Long.parseLong(modifiedObj));
    }
    final String createdObj = dict.stringForKey("Created");
    if (createdObj != null) {
        attributes.setCreationDate(Long.parseLong(createdObj));
    }
    final String revisionObj = dict.stringForKey("Revision");
    if (revisionObj != null) {
        attributes.setRevision(Long.parseLong(revisionObj));
    }
    final List<T> versionsObj = dict.listForKey("Versions");
    if (versionsObj != null) {
        final AttributedList<Path> versions = new AttributedList<>();
        for (T versionDict : versionsObj) {
            versions.add(new PathDictionary(factory).deserialize(versionDict));
        }
        attributes.setVersions(versions);
    }
    final String etagObj = dict.stringForKey("ETag");
    if (etagObj != null) {
        attributes.setETag(etagObj);
    }
    final Object permissionObj = dict.objectForKey("Permission");
    if (permissionObj != null) {
        attributes.setPermission(new PermissionDictionary().deserialize(permissionObj));
    }
    final Object aclObj = dict.objectForKey("Acl");
    if (aclObj != null) {
        attributes.setAcl(new AclDictionary().deserialize(aclObj));
    }
    if (dict.mapForKey("Link") != null) {
        final Map<String, String> link = dict.mapForKey("Link");
        attributes.setLink(new DescriptiveUrl(URI.create(link.get("Url")), DescriptiveUrl.Type.valueOf(link.get("Type"))));
    } else {
        final String linkObj = dict.stringForKey("Link");
        if (linkObj != null) {
            attributes.setLink(new DescriptiveUrl(URI.create(linkObj), DescriptiveUrl.Type.http));
        }
    }
    if (dict.mapForKey("Checksum") != null) {
        final Map<String, String> checksum = dict.mapForKey("Checksum");
        attributes.setChecksum(new Checksum(HashAlgorithm.valueOf(checksum.get("Algorithm")), checksum.get("Hash")));
    } else {
        attributes.setChecksum(Checksum.parse(dict.stringForKey("Checksum")));
    }
    attributes.setVersionId(dict.stringForKey("Version"));
    attributes.setFileId(dict.stringForKey("File Id"));
    attributes.setLockId(dict.stringForKey("Lock Id"));
    final String duplicateObj = dict.stringForKey("Duplicate");
    if (duplicateObj != null) {
        attributes.setDuplicate(Boolean.parseBoolean(duplicateObj));
    }
    final String hiddenObj = dict.stringForKey("Hidden");
    if (hiddenObj != null) {
        attributes.setHidden(Boolean.parseBoolean(hiddenObj));
    }
    attributes.setMetadata(Collections.emptyMap());
    attributes.setRegion(dict.stringForKey("Region"));
    attributes.setStorageClass(dict.stringForKey("Storage Class"));
    final Object vaultObj = dict.objectForKey("Vault");
    if (vaultObj != null) {
        attributes.setVault(new PathDictionary(factory).deserialize(vaultObj));
    }
    final Map<String, String> customObj = dict.mapForKey("Custom");
    if (customObj != null) {
        attributes.setCustom(customObj);
    }
    return attributes;
}
Also used : Path(ch.cyberduck.core.Path) PathAttributes(ch.cyberduck.core.PathAttributes) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) AttributedList(ch.cyberduck.core.AttributedList) Checksum(ch.cyberduck.core.io.Checksum)

Aggregations

PathAttributes (ch.cyberduck.core.PathAttributes)291 Path (ch.cyberduck.core.Path)233 Test (org.junit.Test)200 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)176 IntegrationTest (ch.cyberduck.test.IntegrationTest)175 Delete (ch.cyberduck.core.features.Delete)153 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)143 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)139 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)74 ByteArrayInputStream (java.io.ByteArrayInputStream)55 StreamCopier (ch.cyberduck.core.io.StreamCopier)49 InputStream (java.io.InputStream)49 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)45 NotfoundException (ch.cyberduck.core.exception.NotfoundException)45 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)41 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)36 AttributedList (ch.cyberduck.core.AttributedList)34 Local (ch.cyberduck.core.Local)32 Host (ch.cyberduck.core.Host)31 OutputStream (java.io.OutputStream)31