All pastes #447005 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-04-18 19:52 UTC
rendered paste body
	/**
	 * Return an AssetInfo or WorkspaceInfo (or null if not found) for an item contained in a
	 * Collection/Folder specified by wsUuid using the name of the item as the identifier.  This
	 * method is used to map file system paths to assets within EMS.  It will encounter problems
	 * if there are assets or workspaces with the same name in a Collection which is allowed by EMS
	 * but illegal in a typical Filesystem. 
	 * @param wsUuid A String specifying the UUID of the parent workspace.
	 * @param name A String specifying the name of the item to check for in the parent workspace.
	 * @return An Object representing either a WorkspaceInfo or AssetInfo object (or null) of the
	 * named item.
	 */
	public Object getItemByName(String wsUuid, String name) {
		String dirName = "";
		Object item = null;
		
        Collection contents = this.getWorkspaceContents(wsUuid);
		
		Iterator iter = contents.iterator();
		
		while(iter.hasNext()) {
			item = iter.next();
			if(item instanceof WorkspaceInfo)
			    dirName = ((WorkspaceInfo)item).getName();
			else
				dirName = ((AssetInfo)item).getName();
			if(dirName.equals(name))
				return item;
		}
		
		return null;
	}