%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%
/*
* * Copyright (c) 2005 Massachusetts Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
%>
Hierarchy Viewer Using OSID
Available Hierarchies
<%!
org.osid.OsidContext context;
java.util.Properties properties;
org.osid.hierarchy.HierarchyManager hierarchyManager;
org.osid.id.IdManager idManager;
%>
<%
//if this is the first time this user has come to our application, get an instance of the Hierachy and Id managers for our session
if (session.isNew()) {
try {
context = new org.osid.OsidContext();
properties = new java.util.Properties();
hierarchyManager =
(org.osid.hierarchy.HierarchyManager)org.osid.OsidLoader.getManager(
"org.osid.hierarchy.HierarchyManager",
"edu.mit.osidimpl.hierarchy",
context,
properties);
session.setAttribute("HierarchyManager",hierarchyManager);
//idManager isn't used on this page, but it is needed later to retrieve the hierarchy
idManager =
(org.osid.id.IdManager)org.osid.OsidLoader.getManager(
"org.osid.id.IdManager",
"edu.mit.osidimpl.id",
context,
properties);
session.setAttribute("IdManager", idManager);
}
catch (Throwable t) {
out.println("Error Loading Manager:"+ t.getMessage()+"");
throw t;
}
}
else {
hierarchyManager=(org.osid.hierarchy.HierarchyManager)session.getAttribute("HierarchyManager");
}
try
{
org.osid.hierarchy.HierarchyIterator hierarchyIterator = hierarchyManager.getHierarchies();
while (hierarchyIterator.hasNextHierarchy())
{
org.osid.hierarchy.Hierarchy nextHierarchy = hierarchyIterator.nextHierarchy();
out.print("
| ");
out.print(nextHierarchy.getDisplayName()+ " | ");
out.print(nextHierarchy.getDescription()+" |
");
}
}
catch (Throwable t)
{
t.printStackTrace();
}
%>