%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page import="org.crosswire.community.projects.ntmss.data.ProjectManagement" %>
<%@ page import="org.crosswire.xml.XMLBlock" %>
<%@ page import="org.crosswire.webtools.annotation.*" %>
<%@ page import="javax.validation.constraints.NotNull" %>
<%@ page import="org.crosswire.webtools.*" %>
<%!
@Description(value = "Assign a task to a user.", name = "projectmanagement/task/assign")
public static class MyParameters extends Parameters {
@Description(value = "to which project this assignment is related", defaultValue = "0 (none)", example = "146")
public Integer projectID = 0;
@NotNull
@Description(value = "typically a manuscript id to be assigned", example = "10046")
public Integer objectID;
@NotNull
@Description(value = "type of task to be assigned; 1 - imaging; 2 - indexing; 3 - transcribing", example = "3")
public Integer taskTypeID;
@NotNull
@Description(value = "which user to assign to this task", example = "joe")
public String assignedTo;
@Override
protected void customValidation() {
if (getUser() == null) {
addError(-5, "Must be logged in.");
return;
}
}
}
%>
<%
MyParameters params = new MyParameters().loadFromRequest(request, response, false);
if (params.getErrors().size() == 0) {
String role = "Administrator";
switch (params.taskTypeID) {
case 2: role = "Power User"; break;
case 3: role = "VMR Administrator"; break;
}
ProjectManagement.Project p = ProjectManagement.getProject(params.projectID);
boolean permission = params.getUser().hasRole(role) || (p != null && params.getUser().hasRole("Site Administrator", p.getProjectName()));
if (!permission) {
params.addError(-6, "Permission denied.");
}
else {
ProjectManagement.assignTask(params.objectID, params.taskTypeID, params.assignedTo, params.projectID);
Serializer.output(response, out, params, XMLBlock.createXMLBlock(""));
return;
}
}
else params.format = "html";
Serializer.reportErrors(request, response, out, params, true);
%>