<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ page import="org.crosswire.utils.Sessions" %> <%@ page import="org.crosswire.community.RightsAndRoles" %> <%@ page import="org.crosswire.community.projects.ntmss.data.DocumentGroup" %> <% String myUserName = Sessions.getSessionStringValue(request, "userName"); String userName = request.getParameter("userName"); if (userName == null) userName = myUserName; int paramCount = 0; int documentGroupID = -2; try {documentGroupID = Integer.parseInt(request.getParameter("documentGroupID")); ++paramCount; } catch (Exception e){} String name = request.getParameter("name"); if (name != null) {name = new String(name.getBytes("iso8859-1"), "UTF-8"); ++paramCount; } String description = request.getParameter("description"); if (description != null) { description = new String(description.getBytes("iso8859-1"), "UTF-8"); ++paramCount; } String userGroupName = request.getParameter("userGroupName"); if (userGroupName != null) { userGroupName = new String(userGroupName.getBytes("iso8859-1"), "UTF-8"); ++paramCount; } if (paramCount > 0) { response.setContentType("text/xml"); String role = "VMR Administrator"; // let's check to see if we're a privileged user boolean admin = RightsAndRoles.hasRole(request, response, role); // --------------------------------------------- if (userName == null || userName.length() == 0) { out.print(""); return; } DocumentGroup orig = null; DocumentGroup inst = null; if (documentGroupID == -2) { inst = new DocumentGroup(); if (name == null) { %> <% return; } } else { orig = DocumentGroup.getDocumentGroup(documentGroupID); if (orig == null) { %> <% return; } if (!admin && !userName.equals(orig.getUserID())) { out.print(""); return; } inst = (DocumentGroup)orig.clone(); } if (name != null) inst.setName(name); if (description != null) inst.setDescription(description); if (userName != null) inst.setUserID(userName); if (userGroupName != null) inst.setGroupID(userGroupName); if (orig != null) { inst.save(orig); } else { inst = inst.saveNew(); } out.print(""); return; } %>

documentgroup/put

Create a new or update an existing document group.

Parameters

documentGroupIDdocument group id, supply to edit an existing document group; otherwise, do not include when adding a new document group
namename of the document group
descriptiondescription of the document group
userGroupNameoptional, make this document group owned by a user group