{
// we are dealing with the default service document
// set the title of the workspace as per the name of the DSpace installation
String ws = ConfigurationManager.getProperty("dspace.name");
SwordWorkspace workspace = new SwordWorkspace();
workspace.setTitle(ws);
// next thing to do is determine whether the default is communities or collections
boolean swordCommunities = ConfigurationManager.getBooleanProperty("swordv2-server", "expose-communities");
if (swordCommunities)
{
List<Community> comms = swordAuth.getAllowedCommunities(context);
for (Community comm : comms)
{
SwordCollection scol = comGen.buildCollection(context.getContext(), comm, swordConfig);
workspace.addCollection(scol);
}
}
else
{
List<Collection> cols = swordAuth.getAllowedCollections(context);
for (Collection col : cols)
{
SwordCollection scol = colGen.buildCollection(context.getContext(), col, swordConfig);
workspace.addCollection(scol);
}
}
service.addWorkspace(workspace);
}
else
{
// we are dealing with a partial or sub-service document
DSpaceObject dso = urlManager.extractDSpaceObject(url);
if (dso == null)
{
throw new SwordError(404);
}
if (dso instanceof Community)
{
Community community = (Community) dso;
SwordWorkspace workspace = new SwordWorkspace();
workspace.setTitle(community.getMetadata("name"));
List<Collection> collections = swordAuth.getAllowedCollections(context, community);
for (Collection collection : collections)
{
SwordCollection scol = colGen.buildCollection(context.getContext(), collection, swordConfig);
workspace.addCollection(scol);
}
List<Community> communities = swordAuth.getCommunities(context, community);
for (Community comm : communities)
{
SwordCollection scol = comGen.buildCollection(context.getContext(), comm, swordConfig);
workspace.addCollection(scol);
}
service.addWorkspace(workspace);
}
}