throws WebApplicationException
{
log.info("Adding collection into community(id=" + communityId + ").");
org.dspace.core.Context context = null;
Collection retCollection = null;
try
{
context = createContext(getUser(headers));
org.dspace.content.Community dspaceCommunity = findCommunity(context, communityId, org.dspace.core.Constants.WRITE);
writeStats(dspaceCommunity, UsageEvent.Action.UPDATE, user_ip, user_agent, xforwarderfor,
headers, request, context);
org.dspace.content.Collection dspaceCollection = dspaceCommunity.createCollection();
dspaceCollection.setLicense(collection.getLicense());
// dspaceCollection.setLogo(collection.getLogo()); // TODO Add this option.
dspaceCollection.setMetadata("name", collection.getName());
dspaceCollection.setMetadata(org.dspace.content.Collection.COPYRIGHT_TEXT, collection.getCopyrightText());
dspaceCollection.setMetadata(org.dspace.content.Collection.INTRODUCTORY_TEXT, collection.getIntroductoryText());
dspaceCollection.setMetadata(org.dspace.content.Collection.SHORT_DESCRIPTION, collection.getShortDescription());
dspaceCollection.setMetadata(org.dspace.content.Collection.SIDEBAR_TEXT, collection.getSidebarText());
dspaceCollection.setLicense(collection.getLicense());
dspaceCollection.update();
dspaceCommunity.update();
retCollection = new Collection(dspaceCollection, "", context, 100, 0);
context.complete();
}
catch (SQLException e)
{
processException("Could not add collection into community(id=" + communityId + "), SQLException. Message:" + e,
context);
}
catch (AuthorizeException e)
{
processException("Could not add collection into community(id=" + communityId + "), AuthorizeException. Message:" + e,
context);
}
catch (ContextException e)
{
processException(
"Could not add collection into community(id=" + communityId + "), ContextException. Message:"
+ e.getMessage(), context);
}
finally
{
processFinally(context);
}
log.info("Collection was successfully added into community(id=" + communityId + "). Collection handle="
+ retCollection.getHandle());
return retCollection;
}