Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-07-14 19:21:05 +0000
committerrescobar2010-07-14 19:21:05 +0000
commit9df91c581cb3fd9bbf0254519b975832fe555b64 (patch)
treef29d9bae752d32b22ffc6ddcf5d4a54eb4668e5b /plugins/org.eclipse.osee.framework.manager.servlet
parent99505add7850d6dd19f7abd0ba27dc2bae9438b4 (diff)
downloadorg.eclipse.osee-9df91c581cb3fd9bbf0254519b975832fe555b64.tar.gz
org.eclipse.osee-9df91c581cb3fd9bbf0254519b975832fe555b64.tar.xz
org.eclipse.osee-9df91c581cb3fd9bbf0254519b975832fe555b64.zip
Diffstat (limited to 'plugins/org.eclipse.osee.framework.manager.servlet')
-rw-r--r--plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/ats/AtsService.java239
1 files changed, 123 insertions, 116 deletions
diff --git a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/ats/AtsService.java b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/ats/AtsService.java
index 9317ace5250..39ab6ba586e 100644
--- a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/ats/AtsService.java
+++ b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/ats/AtsService.java
@@ -15,6 +15,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.manager.servlet.DataServlet;
import org.eclipse.osee.framework.resource.management.IResource;
import org.w3c.dom.Node;
@@ -23,120 +24,126 @@ import org.w3c.dom.Node;
*/
public class AtsService {
- private static enum DataTypeEnum {
- PROGRAM,
- BUILD,
- WORKFLOW;
-
- public String asFileName() {
- return "ats." + this.name().toLowerCase() + ".data.xml";
- }
- }
-
- public static interface IResourceProvider {
- IResource getResource(String typeName) throws OseeCoreException;
- }
-
- private final IResourceProvider resourceProvider;
- private final AtsXmlSearch xmlSearch;
- private final AtsXmlMessages messages;
-
- public AtsService(IResourceProvider resourceProvider, AtsXmlSearch xmlSearch, AtsXmlMessages messages) {
- super();
- this.xmlSearch = xmlSearch;
- this.messages = messages;
- this.resourceProvider = resourceProvider;
- }
-
- public void performOperation(IResource resource, HttpServletResponse response) {
- try {
- Collection<OperationData> requests = OperationData.fromResource(resource);
- for (OperationData data : requests) {
- switch (data.getOperationType()) {
- case GET_BUILDS_BY_PROGRAM_ID:
- getBuilds(response, data.getProgramId());
- break;
- case GET_CHANGE_REPORTS_BY_IDS:
- getChangeReport(response, data.getItemIds());
- break;
- case GET_PROGRAMS:
- getPrograms(response);
- break;
- case GET_WORKFLOWS_BY_IDS:
- getWorkflowsById(response, data.getItemIds());
- break;
- case GET_WORKFLOWS_BY_PROGRAM_AND_BUILD_ID:
- getWorkflowsByProgramAndBuild(response, data.getProgramId(), data.getBuildId());
- break;
- default:
- throw new UnsupportedOperationException();
- }
- }
- } catch (Exception ex) {
- messages.sendError(response, ex);
- }
- }
-
- private IResource getResource(DataTypeEnum fileType) throws OseeCoreException {
- return getResource(fileType.asFileName());
- }
-
- private IResource getResource(String resource) throws OseeCoreException {
- String urlPath = String.format("%s://%s", AtsResourceLocatorProvider.PROTOCOL, resource);
- return resourceProvider.getResource(urlPath);
- }
-
- public void getPrograms(HttpServletResponse response) throws OseeCoreException {
- IResource resource = getResource(DataTypeEnum.PROGRAM);
- Collection<Node> nodes = xmlSearch.findPrograms(resource);
- messages.sendPrograms(response, nodes);
- }
-
- public void getBuilds(HttpServletResponse response, String programId) throws OseeCoreException {
- IResource resource = getResource(DataTypeEnum.BUILD);
- Collection<Node> nodes = xmlSearch.findBuildsByProgramId(resource, programId);
- messages.sendBuilds(response, nodes);
- }
-
- public void getWorkflowsById(HttpServletResponse response, String idSearch) throws OseeCoreException {
- IResource resource = getResource(DataTypeEnum.WORKFLOW);
- Collection<Node> nodes = xmlSearch.findWorkflowsById(resource, idSearch);
- messages.sendWorkflows(response, nodes);
- }
-
- public void getWorkflowsByProgramAndBuild(HttpServletResponse response, String programId, String buildId) throws OseeCoreException {
- IResource resource = getResource(DataTypeEnum.WORKFLOW);
- Collection<Node> nodes = xmlSearch.findWorkflowsByProgramAndBuild(resource, programId, buildId);
- messages.sendWorkflows(response, nodes);
- }
-
- public void getChangeReport(HttpServletResponse response, String idSearch) throws OseeCoreException {
- IResource resource = getResource(DataTypeEnum.WORKFLOW);
- Collection<Node> nodes = xmlSearch.findWorkflowsById(resource, idSearch);
- messages.sendChangeReports(response, nodes);
- }
-
- public void sendClient(HttpServletRequest request, HttpServletResponse response) {
- String urlPath = request.getParameter("url");
- boolean wasErrorSent = false;
- IResource resource = null;
- try {
- if (Strings.isValid(urlPath)) {
- resource = resourceProvider.getResource(urlPath);
- } else {
- String servletPath = request.getServletPath();
- urlPath = request.getRequestURI().replace(servletPath, "");
- resource = getResource(urlPath);
- }
- } catch (OseeCoreException ex) {
- messages.sendError(response, ex);
- wasErrorSent = true;
- }
-
- if (resource == null && !wasErrorSent) {
- messages.sendError(response, new Exception(String.format("Resource not found - [%s]", urlPath)));
- } else {
- messages.sendResource(response, resource.getName(), resource);
- }
- }
+ private static enum DataTypeEnum {
+ PROGRAM,
+ BUILD,
+ WORKFLOW;
+
+ public String asFileName() {
+ return "ats." + this.name().toLowerCase() + ".data.xml";
+ }
+ }
+
+ public static interface IResourceProvider {
+ IResource getResource(String typeName) throws OseeCoreException;
+ }
+
+ private final IResourceProvider resourceProvider;
+ private final AtsXmlSearch xmlSearch;
+ private final AtsXmlMessages messages;
+
+ public AtsService(IResourceProvider resourceProvider, AtsXmlSearch xmlSearch, AtsXmlMessages messages) {
+ super();
+ this.xmlSearch = xmlSearch;
+ this.messages = messages;
+ this.resourceProvider = resourceProvider;
+ }
+
+ public void performOperation(IResource resource, HttpServletResponse response) {
+ try {
+ Collection<OperationData> requests = OperationData.fromResource(resource);
+ for (OperationData data : requests) {
+ switch (data.getOperationType()) {
+ case GET_BUILDS_BY_PROGRAM_ID:
+ getBuilds(response, data.getProgramId());
+ break;
+ case GET_CHANGE_REPORTS_BY_IDS:
+ getChangeReport(response, data.getItemIds());
+ break;
+ case GET_PROGRAMS:
+ getPrograms(response);
+ break;
+ case GET_WORKFLOWS_BY_IDS:
+ getWorkflowsById(response, data.getItemIds());
+ break;
+ case GET_WORKFLOWS_BY_PROGRAM_AND_BUILD_ID:
+ getWorkflowsByProgramAndBuild(response, data.getProgramId(), data.getBuildId());
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ }
+ } catch (Exception ex) {
+ messages.sendError(response, ex);
+ }
+ }
+
+ private IResource getResource(DataTypeEnum fileType) throws OseeCoreException {
+ return getResource(fileType.asFileName());
+ }
+
+ private IResource getResource(String resource) throws OseeCoreException {
+ String urlPath = String.format("%s://%s", AtsResourceLocatorProvider.PROTOCOL, resource);
+ return resourceProvider.getResource(urlPath);
+ }
+
+ public void getPrograms(HttpServletResponse response) throws OseeCoreException {
+ IResource resource = getResource(DataTypeEnum.PROGRAM);
+ Collection<Node> nodes = xmlSearch.findPrograms(resource);
+ messages.sendPrograms(response, nodes);
+ }
+
+ public void getBuilds(HttpServletResponse response, String programId) throws OseeCoreException {
+ IResource resource = getResource(DataTypeEnum.BUILD);
+ Collection<Node> nodes = xmlSearch.findBuildsByProgramId(resource, programId);
+ messages.sendBuilds(response, nodes);
+ }
+
+ public void getWorkflowsById(HttpServletResponse response, String idSearch) throws OseeCoreException {
+ IResource resource = getResource(DataTypeEnum.WORKFLOW);
+ Collection<Node> nodes = xmlSearch.findWorkflowsById(resource, idSearch);
+ messages.sendWorkflows(response, nodes);
+ }
+
+ public void getWorkflowsByProgramAndBuild(HttpServletResponse response, String programId, String buildId) throws OseeCoreException {
+ IResource resource = getResource(DataTypeEnum.WORKFLOW);
+ Collection<Node> nodes = xmlSearch.findWorkflowsByProgramAndBuild(resource, programId, buildId);
+ messages.sendWorkflows(response, nodes);
+ }
+
+ public void getChangeReport(HttpServletResponse response, String idSearch) throws OseeCoreException {
+ IResource resource = getResource(DataTypeEnum.WORKFLOW);
+ Collection<Node> nodes = xmlSearch.findWorkflowsById(resource, idSearch);
+ messages.sendChangeReports(response, nodes);
+ }
+
+ public void sendClient(HttpServletRequest request, HttpServletResponse response) {
+ String urlPath = request.getParameter("url");
+ boolean wasErrorSent = false;
+ IResource resource = null;
+ try {
+ if (Strings.isValid(urlPath)) {
+ resource = resourceProvider.getResource(urlPath);
+ } else {
+ String servletPath = request.getServletPath();
+ urlPath = request.getRequestURI().replace(servletPath, "");
+
+ if (urlPath.contains("osee/data")) {
+ DataServlet.handleUriRequest(urlPath, response);
+ return;
+ } else {
+ resource = getResource(urlPath);
+ }
+ }
+ } catch (OseeCoreException ex) {
+ messages.sendError(response, ex);
+ wasErrorSent = true;
+ }
+
+ if (resource == null && !wasErrorSent) {
+ messages.sendError(response, new Exception(String.format("Resource not found - [%s]", urlPath)));
+ } else {
+ messages.sendResource(response, resource.getName(), resource);
+ }
+ }
}

Back to the top