Package io.fathom.cloud.protobuf.FileModel

Examples of io.fathom.cloud.protobuf.FileModel.BucketData


        return directoryStorage;
    }

    BucketData getBucket(Project project, String bucketName) throws CloudException {
        NamedItemCollection<BucketData> bucketStorage = fileStore.getBuckets(project.getId());
        BucketData bucket = bucketStorage.find(bucketName);
        if (bucket == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }
        return bucket;
    }
View Full Code Here


        // TODO: Should we use the straight hash as the key?
        // Should we include a second hash?
        // Should we prefix the project id?
        getBlobStore(project).put(blob.data);

        BucketData bucket = getBucket(project, bucketName);

        DirectoryData dir = getDirectoryData(project, bucket);

        DirectoryData.Builder newDir = DirectoryData.newBuilder(dir);
View Full Code Here

    }

    @Override
    @Transactional
    public void deleteFile(Project project, String bucketName, String name) throws CloudException {
        BucketData bucket = getBucket(project, bucketName);

        DirectoryData dir = getDirectoryData(project, bucket);

        DirectoryData.Builder newDir = DirectoryData.newBuilder(dir);
View Full Code Here

    @Transactional
    public void append(Project project, String bucketName, String name, Long offset, FileBlob blob)
            throws CloudException, IOException {
        getBlobStore(project).put(blob.data);

        BucketData bucket = getBucket(project, bucketName);

        DirectoryData dir = getDirectoryData(project, bucket);

        DirectoryData.Builder newDir = DirectoryData.newBuilder(dir);
View Full Code Here

    @Override
    @Transactional
    public void deleteBucket(Project project, String bucketName) throws CloudException {
        NamedItemCollection<BucketData> bucketStorage = fileStore.getBuckets(project.getId());

        BucketData bucket = bucketStorage.find(bucketName);
        if (bucket == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        if (bucket.hasRootId()) {
            NumberedItemCollection<DirectoryData> directoryStorage = getDirectoryStorage(project);

            DirectoryData dir = directoryStorage.find(bucket.getRootId());
            if (dir != null) {
                if (!isEmpty(dir)) {
                    throw new WebApplicationException(Status.CONFLICT);
                }
            }
View Full Code Here

    @Transactional
    public Status putBucket(Project project, String bucketName, BucketAttributes bucketAttributes,
            Map<String, String> userAttributes) throws CloudException {
        NamedItemCollection<BucketData> bucketStorage = fileStore.getBuckets(project.getId());

        BucketData oldBucket = bucketStorage.find(bucketName);

        BucketData.Builder newBucket;
        boolean isNew;

        if (oldBucket == null) {
            newBucket = BucketData.newBuilder();
            newBucket.setKey(bucketName);

            newBucket.setCreatedAt(Clock.getTimestamp());

            NumberedItemCollection<DirectoryData> directoryStorage = getDirectoryStorage(project);

            fileStore.getDirectories(project.getId());
            DirectoryData.Builder dir = DirectoryData.newBuilder();

            DirectoryData created = storeDirectory(directoryStorage, dir);

            newBucket.setRootId(created.getId());

            isNew = true;
        } else {
            newBucket = BucketData.newBuilder(oldBucket);

            isNew = false;
        }

        updateAttributes(bucketAttributes, newBucket.getBucketAttributesBuilder());
        updateAttributes(userAttributes, newBucket.getAttributesBuilder());

        BucketData updated;

        if (isNew) {
            try {
                updated = bucketStorage.create(newBucket);
            } catch (DuplicateValueException e) {
View Full Code Here

        return stream;
    }

    @Override
    public FsBucket findBucket(User user, Project project, String bucketName) throws CloudException {
        BucketData bucket = fileStore.getBuckets(project.getId()).find(bucketName);
        if (bucket == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        if (user == null) {
            // Check that the container is public
            boolean allowed = false;

            if (bucket.hasBucketAttributes()) {
                BucketAttributes bucketAttributes = bucket.getBucketAttributes();
                if (bucketAttributes.hasAclRead()) {
                    StorageAcl acl = StorageAcl.parse(AclType.Read, bucketAttributes.getAclRead());

                    // TODO: Do we really care about referer?
                    String referer = "unknown";
View Full Code Here

    public boolean compact(CompactOperation compaction) throws CloudException, IOException {
        Project project = compaction.getProject();
        String bucketName = compaction.getBucketName();
        String name = compaction.getName();

        BucketData bucket = getBucket(project, bucketName);

        DirectoryData dir = getDirectoryData(project, bucket);

        DirectoryData.Builder newDir = DirectoryData.newBuilder(dir);
View Full Code Here

        return UUID.randomUUID().toString();
    }

    @Override
    public FileInfo getFileInfo(Project project, String bucketName, String name) throws CloudException, IOException {
        BucketData bucketData = getBucket(project, bucketName);
        FsBucket fsBucket = new FsBucket(project, bucketData);

        FsFile fsFile = findFileInfo(fsBucket, name);
        return fsFile;
    }
View Full Code Here

    }

    @Override
    public List<? extends FileInfo> listFiles(Project project, String bucketName, String prefix, String delimiter)
            throws CloudException {
        BucketData bucketData = getBucket(project, bucketName);
        FsBucket fsBucket = new FsBucket(project, bucketData);

        String marker = null;
        return listFiles(project, fsBucket, prefix, delimiter, marker);
    }
View Full Code Here

TOP

Related Classes of io.fathom.cloud.protobuf.FileModel.BucketData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.