Examples of BoxItem


Examples of box.gson.BoxItem

                         from, to);
            return;
        }

        String parent = RuleUtils.getParent(to);
        BoxItem toItem = getItem(parent);
        if (toItem == null) {
            Logger.warn("BoxClient.move: Parent folder missing: %s", parent);
            toItem = mkdirItem(parent);

            if (toItem == null) {
                Logger.error("Cannot move file, failed creating parent.");
                return;
            }
        }

        if (! toItem.isFolder()) {
            Logger.error("Cannot move, parent item is not a folder. Parent: %s Item: %s", parent, toItem);
            return;
        }

        Logger.info("Attempting to move file from: %s(%s) To: %s(%s)", from, fromId, RuleUtils.getParent(to), toItem);
        HttpResponse resp = req("/files/" + fromId)
                .body(new Gson().toJson(new BoxMoveReq(toItem.id, RuleUtils.basename(to))))
                .put();

        if (resp.success()) {
            BoxItem file = new Gson().fromJson(resp.getJson(), BoxItem.class);
            invalidate(RuleUtils.getParent(from));
            invalidate(from);
            invalidate(RuleUtils.getParent(to));
            invalidate(to);
            Logger.info("Successfully moved file from %s to %s. File: %s",
View Full Code Here

Examples of box.gson.BoxItem

    }

    @Override
    public Set<String> listDir(String path, ListingType listingType) throws InvalidTokenException, NotADirectoryException {
        Set<String> ret = Sets.newHashSet();
        BoxItem item = getItem(path);

        if (item != null && item.children != null && item.children.entries != null) {
            addAll(ret, transform(filter(item.children.entries,
                                         new FileOrFolderPredicate(listingType)),
                                  new ItemNameExtractor(path)));
View Full Code Here

Examples of box.gson.BoxItem

    private BoxItem mkdirItem(String path) throws InvalidTokenException {
        Preconditions.checkNotNull(path, "Missing path.");
        Logger.info("BoxClient.mkdir: path %s", path);
        String parent = RuleUtils.getParent(path);
        BoxItem parentItem = getItem(parent);

        if (parentItem ==  null) {
            Logger.warn("Parent folder doesn't exist, creating. Path: %s Parent: %s", path, parent);
            parentItem = mkdirItem(parent);

            if (parentItem == null) {
                Logger.error("Could not create parent directory: %s", parent);
                return null;
            }
        }

        if (! parentItem.isFolder()) {
            Logger.error("Cannot create directory because parent is not a directory. Parent path: %s Item: %s", parent, parentItem);
            return null;
        }

        HttpResponse resp = req("/folders")
                .body(new Gson().toJson(new BoxCreateFolderItem(RuleUtils.basename(path), parentItem)))
                .post();

        if (resp.success()) {
            BoxItem folder = new Gson().fromJson(resp.getJson(), BoxItem.class);
            invalidate(path);
            Logger.info("Successfully created folder at path %s Folder: %s", path, folder);
            return folder;
        }
View Full Code Here

Examples of box.gson.BoxItem

            return null;
        }
    }

    private String getId(String path) throws InvalidTokenException {
        BoxItem item = getItem(path);
        return item == null ? null : item.id;
    }
View Full Code Here

Examples of com.box.boxjavalibv2.dao.BoxItem

    private static final String PATH_PREFIX = BoxApiCollection.getCollection().getApiName(IBoxSharedItemsManagerApiMethod.class).getName();

    @Test
    public void testGetSharedItem() throws Exception {
        // using com.box.restclientv2.requestsbase.BoxDefaultRequestObject message body for single parameter "defaultRequest"
        BoxItem result = requestBody("direct://GETSHAREDITEM", null);

        assertNotNull("getSharedItem result", result);
        LOG.debug("getSharedItem: " + result);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.