protected int createFolders(IFolderSyncManager mgr, UserFolder parent, int numFolders, int depth) throws Exception { if (depth == 0) { return 0; } for (int ix = 0; ix < numFolders; ix++) { UserFolder child = new UserFolder(); child.setCustomerId(parent.getCustomerId()); child.setUserId(parent.getUserId()); String name = String.format(FOLDER_NAME_FORMAT, ix, depth); child.setExchangeFolderKey(RandomStringUtils.randomAlphanumeric(40)); child.setExchangeParentFolderKey(parent.getExchangeFolderKey()); child.setMapiFolderKey(RandomStringUtils.randomAlphanumeric(40)); child.setMapiParentFolderKey(parent.getMapiFolderKey()); child.setDeleted(false); child.setDisplayName(name); child.setExchangeSyncState(""); child.setFolderItemsSyncEnabled(ix != 5); // create at least one that is not enabled for sync mgr.createFolder(child); createFolders(mgr, child, numFolders, depth - 1); } return numFolders; }
protected void createWellKnownFolder( IFolderSyncManager mgr, UserFolder parent, String folderName, String wellKnownFolderName) throws Exception { UserFolder child = new UserFolder(); child.setCustomerId(parent.getCustomerId()); child.setUserId(parent.getUserId()); child.setExchangeFolderKey(RandomStringUtils.randomAlphanumeric(40)); child.setExchangeParentFolderKey(parent.getExchangeFolderKey()); child.setMapiFolderKey(RandomStringUtils.randomAlphanumeric(40)); child.setMapiParentFolderKey(parent.getMapiParentFolderKey()); child.setDeleted(false); child.setDisplayName(folderName); child.setExchangeSyncState("not_synced"); child.setFolderItemsSyncEnabled(false); child.setWellKnownName(wellKnownFolderName); mgr.createFolder(child); }