/*
* Most of the forms supply one or more of these values. Since we just
* get null if we try and find something with ID -1, we'll just try and
* find both here to save hassle later on
*/
Community community = Community.find(context, UIUtil.getIntParameter(
request, "community_id"));
Community parentCommunity = Community.find(context, UIUtil
.getIntParameter(request, "parent_community_id"));
Collection collection = Collection.find(context, UIUtil
.getIntParameter(request, "collection_id"));
// Just about every JSP will need the values we received
request.setAttribute("community", community);
request.setAttribute("parent", parentCommunity);
request.setAttribute("collection", collection);
/*
* First we check for a "cancel" button - if it's been pressed, we
* simply return to the main control page
*/
if (request.getParameter("submit_cancel") != null)
{
showControls(context, request, response);
return;
}
// Now proceed according to "action" parameter
switch (action)
{
case START_EDIT_COMMUNITY:
storeAuthorizeAttributeCommunityEdit(context, request, community);
// Display the relevant "edit community" page
JSPManager.showJSP(request, response, "/tools/edit-community.jsp");
break;
case START_DELETE_COMMUNITY:
// Show "confirm delete" page
JSPManager.showJSP(request, response,
"/tools/confirm-delete-community.jsp");
break;
case START_CREATE_COMMUNITY:
// no authorize attribute will be given to the jsp so a "clean" creation form
// will be always supplied, advanced setting on policies and admin group creation
// will be possible after to have completed the community creation
// Display edit community page with empty fields + create button
JSPManager.showJSP(request, response, "/tools/edit-community.jsp");
break;
case START_EDIT_COLLECTION:
HarvestedCollection hc = HarvestedCollection.find(context, UIUtil.
getIntParameter(request, "collection_id"));
request.setAttribute("harvestInstance", hc);
storeAuthorizeAttributeCollectionEdit(context, request, collection);
// Display the relevant "edit collection" page
JSPManager.showJSP(request, response, "/tools/edit-collection.jsp");
break;
case START_DELETE_COLLECTION:
// Show "confirm delete" page
JSPManager.showJSP(request, response,
"/tools/confirm-delete-collection.jsp");
break;
case START_CREATE_COLLECTION:
// Forward to collection creation wizard
response.sendRedirect(response.encodeRedirectURL(request
.getContextPath()
+ "/tools/collection-wizard?community_id="
+ community.getID()));
break;
case CONFIRM_EDIT_COMMUNITY:
// Edit or creation of a community confirmed
processConfirmEditCommunity(context, request, response, community);
break;
case CONFIRM_DELETE_COMMUNITY:
// remember the parent community, if any
Community parent = community.getParentCommunity();
// Delete the community
community.delete();
// if community was top-level, redirect to community-list page
if (parent == null)
{
response.sendRedirect(response.encodeRedirectURL(request
.getContextPath()
+ "/community-list"));
}
else
// redirect to parent community page
{
response.sendRedirect(response.encodeRedirectURL(request
.getContextPath()
+ "/handle/" + parent.getHandle()));
}
// Show main control page
//showControls(context, request, response);
// Commit changes to DB