Last active
May 16, 2017 18:16
-
-
Save pmedcraft/e945c2417027592e2e40dadd84759906 to your computer and use it in GitHub Desktop.
Custom Servlet for SDL WorldServer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.worldservertraining; | |
import com.idiominc.wssdk.WSContext; | |
import com.idiominc.wssdk.WSVersion; | |
import com.idiominc.wssdk.component.servlet.WSHttpServlet; | |
import com.idiominc.wssdk.user.WSClient; | |
import com.idiominc.wssdk.workflow.WSProject; | |
import com.idiominc.wssdk.workflow.WSTask; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
public class ProjectInfo extends WSHttpServlet { | |
public boolean handle(WSContext wsContext, HttpServletRequest httpServletRequest, | |
HttpServletResponse httpServletResponse) { | |
PrintWriter out = null; | |
try { | |
out = httpServletResponse.getWriter(); | |
} | |
catch (IOException exception) { | |
return false; | |
} | |
WSVersion wsVersion = wsContext.getVersion(); | |
out.print("<p><b>WorldServer Version: " + | |
wsVersion.getMajorVersion() + "." + | |
wsVersion.getMinorVersion() + | |
"</b></p>"); | |
WSClient[] wsClients = wsContext.getUserManager().getClients(); | |
for (WSClient wsClient : wsClients) { | |
out.print("<p><b>Client:</b> " + wsClient.getName() + "</p>"); | |
WSProject[] wsProjects = wsContext.getWorkflowManager().getProjectsForClient(wsClient); | |
out.print("<table>"); | |
out.print("<tr>"); | |
out.print("<td width=\"40%\"><b>PROJECT:</b></td>"); | |
out.print("<td width=\"25%\"><b>PROJECT TYPE:</b></td>"); | |
out.print("<td width=\"15%\"><b>STATUS:</b></td>"); | |
out.print("<td width=\"20%\"><b>TASK:</b></td>"); | |
out.print("</tr>"); | |
for (WSProject wsProject : wsProjects) { | |
out.print("<tr>"); | |
out.print("<td width=\"40%\">" + wsProject.getDisplayString() + "</td>"); | |
out.print("<td width=\"25%\">" + wsProject.getProjectType().getName() + "</td>"); | |
out.print("<td width=\"15%\">" + wsProject.getProjectStatus().toString() + "</td>"); | |
WSTask[] activeTasks = wsProject.getActiveTasks(); | |
if (activeTasks.length == 0) | |
out.print("<td width=\"20%\"><b>No active tasks</b></td>"); | |
else { | |
WSTask activeTask = activeTasks[0]; | |
out.print("<td width=\"20%\"><b>" + | |
activeTask.getCurrentTaskStep().getWorkflowStep().getName() + | |
"</b></td>"); | |
} | |
out.print("</tr>"); | |
} | |
out.print("</table>"); | |
} | |
return true; | |
} | |
public String getName() { | |
return "project_info"; | |
} | |
public String getDescription() { | |
return "Lists existing projects including some basic information"; | |
} | |
public String getVersion() { | |
return "1.0"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment