<commit_before>/**
 * Copyright (c) 2005-2006 Intalio inc.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Intalio inc. - initial API and implementation
 *
 * $Id: TaskManagementServicesFacade.java 5440 2006-06-09 08:58:15Z imemruk $
 * $Log:$
 */

package org.intalio.tempo.workflow.tms.server;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axis2.AxisFault;
import org.intalio.tempo.workflow.auth.AuthException;
import org.intalio.tempo.workflow.auth.AuthIdentifierSet;
import org.intalio.tempo.workflow.auth.UserRoles;
import org.intalio.tempo.workflow.task.PIPATask;
import org.intalio.tempo.workflow.task.Task;
import org.intalio.tempo.workflow.task.TaskState;
import org.intalio.tempo.workflow.task.attachments.Attachment;
import org.intalio.tempo.workflow.task.xml.TaskMarshaller;
import org.intalio.tempo.workflow.task.xml.TaskUnmarshaller;
import org.intalio.tempo.workflow.task.xml.TaskXMLConstants;
import org.intalio.tempo.workflow.task.xml.attachments.AttachmentMarshaller;
import org.intalio.tempo.workflow.task.xml.attachments.AttachmentUnmarshaller;
import org.intalio.tempo.workflow.tms.InvalidTaskStateException;
import org.intalio.tempo.workflow.tms.TaskIDConflictException;
import org.intalio.tempo.workflow.tms.UnavailableAttachmentException;
import org.intalio.tempo.workflow.tms.UnavailableTaskException;
import org.intalio.tempo.workflow.util.xml.InvalidInputFormatException;
import org.intalio.tempo.workflow.util.xml.OMDOMConvertor;
import org.intalio.tempo.workflow.util.xml.OMElementQueue;
import org.intalio.tempo.workflow.util.xml.OMMarshaller;
import org.intalio.tempo.workflow.util.xml.OMUnmarshaller;
import org.w3c.dom.Document;


public class TMSRequestProcessor extends OMUnmarshaller {

    private abstract class TMSResponseMarshaller extends OMMarshaller {
        public TMSResponseMarshaller(OMFactory omFactory) {
            super(omFactory, omFactory.createOMNamespace(TaskXMLConstants.TASK_NAMESPACE,
                    TaskXMLConstants.TASK_NAMESPACE_PREFIX));
        }
    }

    private ITMSServer _server = null;

    public TMSRequestProcessor() throws Exception {
        super(TaskXMLConstants.TASK_NAMESPACE, TaskXMLConstants.TASK_NAMESPACE_PREFIX);
    }

    public void setServer(ITMSServer server) {
        _server = server;
    }

    public OMElement getTaskList(OMElement requestElement)
            throws AxisFault {
        try {
            OMElementQueue rootQueue = new OMElementQueue(requestElement);
            String participantToken = requireElementValue(rootQueue, "participantToken");

            final UserRoles user = _server.getUserRoles(participantToken);
            Task[] tasks = _server.getTaskList(participantToken);

            OMElement response = new TMSResponseMarshaller(requestElement.getOMFactory()) {
                public OMElement marshalResponse(Task[] tasks) {
                    OMElement response = createElement("getTaskListResponse");
                    for (Task task : tasks) {
                        OMElement taskElement = new TaskMarshaller(getOMFactory()).marshalTaskMetadata(task, user);
                        taskElement.setLocalName("task");
                        response.addChild(taskElement);
                    }
                    return response;
                }
            }.marshalResponse(tasks);

            return response;
        } catch (InvalidInputFormatException e) {
            throw AxisFault.makeFault(e);
        } catch (AuthException e) {
            throw AxisFault.makeFault(e);
        }
    }

    public OMElement getTask(OMElement requestElement)
            throws AxisFault {
        try {
            OMElementQueue rootQueue = new OMElementQueue(requestElement);
            String taskID = requireElementValue(rootQueue, "taskId");
            String participantToken = requireElementValue(rootQueue, "participantToken");

            final UserRoles user = _server.getUserRoles(participantToken);
            Task task = _server.getTask(taskID, participantToken);
            <commit_msg>- fixing task transfer. namespace was not set properly.<commit_after>/**
 * Copyright (c) 2005-2006 Intalio inc.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Intalio inc. - initial API and implementation
 *
 * $Id: TaskManagementServicesFacade.java 5440 2006-06-09 08:58:15Z imemruk $
 * $Log:$
 */

package org.intalio.tempo.workflow.tms.server;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axis2.AxisFault;
import org.intalio.tempo.workflow.auth.AuthException;
import org.intalio.tempo.workflow.auth.AuthIdentifierSet;
import org.intalio.tempo.workflow.auth.UserRoles;
import org.intalio.tempo.workflow.task.PIPATask;
import org.intalio.tempo.workflow.task.Task;
import org.intalio.tempo.workflow.task.TaskState;
import org.intalio.tempo.workflow.task.attachments.Attachment;
import org.intalio.tempo.workflow.task.xml.TaskMarshaller;
import org.intalio.tempo.workflow.task.xml.TaskUnmarshaller;
import org.intalio.tempo.workflow.task.xml.TaskXMLConstants;
import org.intalio.tempo.workflow.task.xml.attachments.AttachmentMarshaller;
import org.intalio.tempo.workflow.task.xml.attachments.AttachmentUnmarshaller;
import org.intalio.tempo.workflow.tms.InvalidTaskStateException;
import org.intalio.tempo.workflow.tms.TaskIDConflictException;
import org.intalio.tempo.workflow.tms.UnavailableAttachmentException;
import org.intalio.tempo.workflow.tms.UnavailableTaskException;
import org.intalio.tempo.workflow.util.xml.InvalidInputFormatException;
import org.intalio.tempo.workflow.util.xml.OMDOMConvertor;
import org.intalio.tempo.workflow.util.xml.OMElementQueue;
import org.intalio.tempo.workflow.util.xml.OMMarshaller;
import org.intalio.tempo.workflow.util.xml.OMUnmarshaller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;


public class TMSRequestProcessor extends OMUnmarshaller {
    final static Logger _logger = LoggerFactory.getLogger(TMSRequestProcessor.class);

    private abstract class TMSResponseMarshaller extends OMMarshaller {
        public TMSResponseMarshaller(OMFactory omFactory) {
            super(omFactory, omFactory.createOMNamespace(TaskXMLConstants.TASK_NAMESPACE,
                    TaskXMLConstants.TASK_NAMESPACE_PREFIX));
        }
    }

    private ITMSServer _server = null;

    public TMSRequestProcessor() throws Exception {
        super(TaskXMLConstants.TASK_NAMESPACE, TaskXMLConstants.TASK_NAMESPACE_PREFIX);
    }

    public void setServer(ITMSServer server) {
        _server = server;
    }

    public OMElement getTaskList(OMElement requestElement)
            throws AxisFault {
        try {
            OMElementQueue rootQueue = new OMElementQueue(requestElement);
            String participantToken = requireElementValue(rootQueue, "participantToken");

            final UserRoles user = _server.getUserRoles(participantToken);
            Task[] tasks = _server.getTaskList(participantToken);

            OMElement response = new TMSResponseMarshaller(requestElement.getOMFactory()) {
                public OMElement marshalResponse(Task[] tasks) {
                    OMElement response = createElement("getTaskListResponse");
                    for (Task task : tasks) {
                        OMElement taskElement = new TaskMarshaller(getOMFactory()).marshalTaskMetadata(task, user);
                        taskElement.setLocalName("tms:task");
                        response.addChild(taskElement);
                    }
                    return response;
                }
            }.marshalResponse(tasks);
            if(_logger.isDebugEnabled()) _logger.debug(response.toString());

            return response;
        } catch (InvalidInputFormatException e) {
            throw AxisFault.makeFault(e);
        } catch (AuthException e) {
            throw AxisFault.makeFault(e);
        }
    }

    public OMElement getTask(OMElement requestElement)
            throws AxisFault {
        try {
            OMElementQueue rootQueue = new OMElementQueue(requestElement);
            String taskID = requireElementValue(rootQueue, "taskId");
            String participantToken = requireElementValue(rootQueue, "participantToken");

            final UserRoles user = _server.getUserRoles(participantToken);
            Task task = _server.getTask(taskID, participantToken);
            
{'fraction_non_alphanumeric': 0.08824173417998686, 'fraction_numerical': 0.00722574994525947, 'mean_word_length': 3.360381861575179, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 20}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7063926', 'n_tokens_mistral': 2750, 'n_tokens_neox': 2658, 'n_words': 477}