All pastes #447015 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-04-18 20:00 UTC
rendered paste body
	/**
	 * Return a Collection of objects representing the contents of a Collection or Folder.  The Collection
	 * may contain both AssetInfo and WorkspaceInfo objects stored as type Object.  To iterate over the
	 * contents of the collection without checking item.getClass(), use AbstractInfo to cast both object
	 * types to a common super class.
	 * @param wsUuid A String representing the UUID of the Collection/Folder to return the contents of.
	 * @return A Collection of Objects representing AssetInfo and WorkspaceInfo items within the 
	 * Collection/Folder.
	 */
	public Collection getWorkspaceContents(String wsUuid) {
		Collection<WorkspaceInfo> collections = null;
		Collection<WorkspaceInfo> folders = null;
		Collection<AssetInfo> assets = null;
		Collection<Object> contents = new ArrayList<Object>();
		
		try {
			collections = this.workspaceManager.getChildrenWorkspaceInfo(
					this.userAuth, wsUuid, WorkspaceType.COLLECTION, 0, 0);
		} catch(Exception e) {
			System.out.println("Failed collections!");
			System.out.println(e);
		}
		
		try {
			folders = this.workspaceManager.getChildrenWorkspaceInfo(
					this.userAuth, wsUuid, WorkspaceType.FOLDER, 0, 0);
		} catch(Exception e) {
			System.out.println("Failed folders");
			System.out.println(e);
		}
		
		try {
			assets = this.workspaceManager.getChildrenAssetInfo(
					this.userAuth, wsUuid, 0, 0);
		} catch(Exception e) {
			System.out.println("Failed assets!");
			System.out.println(e);
		}
		
		if(collections != null)
		    contents.addAll(collections);
		if(folders != null)
		    contents.addAll(folders);
		if(assets != null)
		    contents.addAll(assets);
		
		return contents;
	}