Package com.box.boxjavalibv2.jsonentities

Examples of com.box.boxjavalibv2.jsonentities.MapJSONStringEntity


     *
     * @param parentId
     * @return
     */
    public BoxItemRestoreRequestObject setNewParent(final String parentId) {
        MapJSONStringEntity id = new MapJSONStringEntity();
        id.put(BoxFolder.FIELD_ID, parentId);
        put(BoxItem.FIELD_PARENT, id);
        return this;
    }
View Full Code Here


     * @param email
     *            email address
     * @return
     */
    public BoxFolderRequestObject setUploadEmail(String access, String email) {
        MapJSONStringEntity entity = new MapJSONStringEntity();
        entity.put(BoxEmail.FIELD_ACCESS, access);
        entity.put(BoxEmail.FIELD_EMAIL, email);
        put(BoxFolder.FIELD_FOLDER_UPLOAD_EMAIL, entity);
        return this;
    }
View Full Code Here

     * @param parentId
     *            id of parent
     * @return
     */
    public BoxItemRequestObject setParent(String parentId) {
        MapJSONStringEntity entity = new MapJSONStringEntity();
        entity.put(BoxFolder.FIELD_ID, parentId);
        put(BoxItem.FIELD_PARENT, entity);
        return this;
    }
View Full Code Here

        put(BoxComment.FIELD_ITEM, getItemEntity(type, itemId));
        return this;
    }

    private static MapJSONStringEntity getItemEntity(final BoxResourceType type, final String itemId) {
        MapJSONStringEntity entity = new MapJSONStringEntity();
        entity.put("type", type.toString());
        entity.put("id", itemId);
        return entity;
    }
View Full Code Here

        String role = "testrole789";

        BoxCollabRequestObject obj = BoxCollabRequestObject.createCollabObject(folderId, userId, login, role);

        // String jsonStr = obj.getJSONEntity().toJSONString(new BoxJSONParser(new BoxResourceHub()));
        MapJSONStringEntity item = (MapJSONStringEntity) obj.getFromEntity(ITEM_STR);
        Assert.assertEquals(folderId, item.get(BoxFolder.FIELD_ID));
        Assert.assertEquals(BoxResourceType.FOLDER.toString(), item.get(BoxFolder.FIELD_TYPE));

        MapJSONStringEntity accessible = (MapJSONStringEntity) obj.getFromEntity(ACCESSIBLE_STR);
        Assert.assertEquals(userId, accessible.get(BoxUser.FIELD_ID));
        Assert.assertEquals(login, accessible.get(BoxUser.FIELD_LOGIN));

        Assert.assertEquals(role, obj.getFromEntity(ROLE_STR));
    }
View Full Code Here

        String userId = "testuserid";
        String role = "testrole";
        BoxGroupMembershipRequestObject obj = BoxGroupMembershipRequestObject.addMembershipRequestObject(groupId, userId, role);
        Object groupObj = obj.getFromEntity(BoxGroupMembership.FIELD_GROUP);
        Assert.assertTrue(groupObj instanceof MapJSONStringEntity);
        MapJSONStringEntity groupEntity = (MapJSONStringEntity) groupObj;
        Assert.assertEquals(groupId, groupEntity.get(BoxGroup.FIELD_ID));

        Object userObj = obj.getFromEntity(BoxGroupMembership.FIELD_USER);
        Assert.assertTrue(userObj instanceof MapJSONStringEntity);
        MapJSONStringEntity userEntity = (MapJSONStringEntity) userObj;
        Assert.assertEquals(userId, userEntity.get(BoxUser.FIELD_ID));

        Assert.assertEquals(role, obj.getFromEntity(BoxGroupMembership.FIELD_ROLE));
    }
View Full Code Here

    @Test
    public void testParentInObject() throws BoxRestException, BoxJSONException {
        String parentid = "testid";
        BoxItemRestoreRequestObject obj = BoxItemRestoreRequestObject.restoreItemRequestObject().setNewParent(parentid);

        MapJSONStringEntity entity = (MapJSONStringEntity) obj.getFromEntity(PARENT);

        Assert.assertEquals(parentid, entity.get(BoxFolder.FIELD_ID));
    }
View Full Code Here

        String name = "testname";
        String parentid = "testid";
        BoxItemRestoreRequestObject obj = BoxItemRestoreRequestObject.restoreItemRequestObject().setNewName(name).setNewParent(parentid);

        Assert.assertEquals(name, obj.getFromEntity(NAME));
        MapJSONStringEntity entity = (MapJSONStringEntity) obj.getFromEntity(PARENT);

        Assert.assertEquals(parentid, entity.get(BoxFolder.FIELD_ID));
    }
View Full Code Here

        return me;
    }

    private static IBoxJSONStringEntity getMetadataBody(String parentId, String name) throws UnsupportedEncodingException, BoxRestException, BoxJSONException {
        MapJSONStringEntity parentEntity = new MapJSONStringEntity();
        parentEntity.put(Constants.ID, parentId);

        MapJSONStringEntity entity = new MapJSONStringEntity();
        entity.put(KEY_PARENT, parentEntity);
        entity.put(KEY_NAME, name);
        return entity;
    }
View Full Code Here

    /**
     * This is package protected, any class overriding this should be in a same package.
     */
    HttpEntity getEntity(IBoxJSONParser parser) throws BoxRestException, BoxJSONException, UnsupportedEncodingException {
        MapJSONStringEntity en = getJSONEntity();
        if (en == null) {
            return null;
        }
        try {
            return new StringEntity(en.toJSONString(parser), CharEncoding.UTF_8);
        }
        catch (UnsupportedEncodingException e) {
            throw new BoxRestException(e);
        }
    }
View Full Code Here

TOP

Related Classes of com.box.boxjavalibv2.jsonentities.MapJSONStringEntity

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.