From hise-commits-return-267-apmail-incubator-hise-commits-archive=incubator.apache.org@incubator.apache.org Thu Aug 19 17:39:17 2010 Return-Path: Delivered-To: apmail-incubator-hise-commits-archive@minotaur.apache.org Received: (qmail 12197 invoked from network); 19 Aug 2010 17:39:16 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 19 Aug 2010 17:39:16 -0000 Received: (qmail 64138 invoked by uid 500); 19 Aug 2010 17:39:16 -0000 Delivered-To: apmail-incubator-hise-commits-archive@incubator.apache.org Received: (qmail 64119 invoked by uid 500); 19 Aug 2010 17:39:16 -0000 Mailing-List: contact hise-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hise-dev@incubator.apache.org Delivered-To: mailing list hise-commits@incubator.apache.org Received: (qmail 64112 invoked by uid 99); 19 Aug 2010 17:39:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Aug 2010 17:39:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Aug 2010 17:39:09 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E28C22388A02; Thu, 19 Aug 2010 17:37:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r987241 [2/4] - in /incubator/hise/trunk: ./ hise-bundle/src/main/resources/META-INF/spring/ hise-services/src/main/java/org/apache/hise/api/ hise-services/src/main/java/org/apache/hise/engine/ hise-services/src/main/java/org/apache/hise/en... Date: Thu, 19 Aug 2010 17:37:40 -0000 To: hise-commits@incubator.apache.org From: rr@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100819173744.E28C22388A02@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java?rev=987241&r1=987240&r2=987241&view=diff ============================================================================== --- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java (original) +++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java Thu Aug 19 17:37:40 2010 @@ -177,1240 +177,16 @@ import org.apache.xmlbeans.XmlString; */ @Transactional @WebService -public class TaskOperationsImpl implements TaskOperations { - - private static final Log log = LogFactory.getLog(TaskOperationsImpl.class); +public class TaskOperationsImpl extends TaskOperationsBaseImpl implements + TaskOperations { - private HISEEngineImpl hiseEngine; - - private WebServiceContext context; - - /** - * Sets up {@link WebServiceContext} used to lookup authenticated user - * performing operations. - * - * @throws Exception - */ - public void init() throws Exception { - context = (WebServiceContext) Class.forName("org.apache.cxf.jaxws.context.WebServiceContextImpl").newInstance(); - } - - protected String getUserString() { - return context.getUserPrincipal().getName(); - } - - // implementation in progress - - /** - * {@inheritDoc} - */ - public GetMyTasksResponseDocument getMyTasks(GetMyTasksDocument getMyTasks) throws IllegalArgumentFault, IllegalStateFault { -// public List getMyTasks(String taskType, String genericHumanRole, String workQueue, List status, String whereClause, String createdOnClause, -// Integer maxTasks) throws IllegalArgumentFault, IllegalStateFault { - - String taskType = getMyTasks.getGetMyTasks().getTaskType(); - String genericHumanRole = getMyTasks.getGetMyTasks().getGenericHumanRole(); - String workQueue = getMyTasks.getGetMyTasks().getWorkQueue(); - List status = getMyTasks.getGetMyTasks().getStatusList(); - String whereClause = getMyTasks.getGetMyTasks().getWhereClause(); - String createdOnClause = getMyTasks.getGetMyTasks().getCreatedOnClause(); - Integer maxTasks = getMyTasks.getGetMyTasks().getMaxTasks(); - - List result = new ArrayList(); - - String user = getUserString(); - - TaskQuery query = new TaskQuery(); - query.setUser(user); - query.setUserGroups(hiseEngine.getHiseUserDetails().getUserGroups(user)); - query.setTaskType(taskType); - if(genericHumanRole==null) { - query.setGenericHumanRole(null); - } - else { - query.setGenericHumanRole(GenericHumanRole.valueOf(genericHumanRole)); - } - query.setWorkQueue(workQueue); - query.setStatuses(status); - query.setWhereClause(whereClause); - query.setCreatedOnClause(createdOnClause); - - if (maxTasks != null) { - query.setMaxTasks(maxTasks); - } - - List tasks = hiseEngine.getHiseDao().getUserTasks(query); - - for (org.apache.hise.dao.Task u : tasks) { - TTask t = null; - - t = convertTasktoTTask(u); - - result.add(t); - } - - GetMyTasksResponseDocument responseDocument = GetMyTasksResponseDocument.Factory.newInstance(); - GetMyTasksResponseDocument.GetMyTasksResponse response = GetMyTasksResponseDocument.GetMyTasksResponse.Factory.newInstance(); - TTask[] taskArray = new TTask[result.size()]; - taskArray = result.toArray(taskArray); - response.setTaskAbstractArray(taskArray); - responseDocument.setGetMyTasksResponse(response); - - return responseDocument; - } - - private TTask convertTasktoTTask(org.apache.hise.dao.Task t) throws IllegalArgumentFault { - TTask result = convertTask(t.getId()); - result.setDeadlinesInfo(convertToDeadlinesInfo(t)); - - return result; - } - - private TDeadlinesInfo convertToDeadlinesInfo(org.apache.hise.dao.Task t) throws IllegalArgumentFault { - TDeadlinesInfo result = TDeadlinesInfo.Factory.newInstance(); - Set job = t.getDeadlines(); - if (t.getDeadlines() != null && job.size() > 0) { - for (org.apache.hise.dao.Job j : job) { - String details = j.getDetails(); - StringTokenizer st = new StringTokenizer(details, ";", true); - String name = new String(); - String type = new String(); - if (st.countTokens() < 2) { - throw new IllegalArgumentFault("START or COMPLETION information missing in deadine details"); - } - while (st.hasMoreTokens()) { - String token = st.nextToken(); - if (st.hasMoreTokens()) { - name += token; - } else { - type = token; - } - } - if (type.equalsIgnoreCase("START")) { - TDeadlineInfo startBy = result.addNewStartBy(); - Calendar startDate = Calendar.getInstance(); - startDate.setTime(j.getFire()); - startBy.setDate(startDate); - startBy.setName(name); - } else { - TDeadlineInfo completeBy = result.addNewCompleteBy(); - Calendar completeDate = Calendar.getInstance(); - completeDate.setTime(j.getFire()); - completeBy.setDate(completeDate); - completeBy.setName(name); - } - - } - - } - - - return result; - } - - /** - * {@inheritDoc} - */ - public GetInputResponseDocument getInput(GetInputDocument getInput) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public Object getInput(String identifier, String part) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = getInput.getGetInput().getIdentifier(); - String part = getInput.getGetInput().getPart(); - - Task t = Task.load(hiseEngine, Long.parseLong(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.GET_INPUT, getUserString(), t); - t.setCurrentUser(getUserString()); - - GetInputResponseDocument responseDocument = GetInputResponseDocument.Factory.newInstance(); - GetInputResponseDocument.GetInputResponse response = GetInputResponseDocument.GetInputResponse.Factory.newInstance(); - try { - response.setTaskData(XmlObject.Factory.parse(t.getInput(part))); - } catch (XmlException ex) { - throw new IllegalStateFault("", ex); - } - responseDocument.setGetInputResponse(response); - - return responseDocument; - } - - /** - * {@inheritDoc} - */ - public GetOutputResponseDocument getOutput(GetOutputDocument getOutput) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public Object getOutput(String identifier, String part) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = getOutput.getGetOutput().getIdentifier(); - String part = getOutput.getGetOutput().getPart(); - - Task t = Task.load(hiseEngine, Long.parseLong(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.GET_OUTPUT, getUserString(), t); - t.setCurrentUser(getUserString()); - - GetOutputResponseDocument responseDocument = GetOutputResponseDocument.Factory.newInstance(); - GetOutputResponseDocument.GetOutputResponse response = GetOutputResponseDocument.GetOutputResponse.Factory.newInstance(); - try { - response.setTaskData(XmlObject.Factory.parse(t.getOutput(part))); - } catch (XmlException ex) { - throw new IllegalStateFault("", ex); - } - responseDocument.setGetOutputResponse(response); - return responseDocument; - } - - /** - * {@inheritDoc} - */ - public StopResponseDocument stop(StopDocument stop) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void stop(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = stop.getStop().getIdentifier(); - - Task t = Task.load(hiseEngine, Long.parseLong(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.STOP, getUserString(), t); - TaskChecker.checkStatePermission(HumanOperationName.STOP, t); - t.setCurrentUser(getUserString()); - - try { - t.stop(); - } catch (HiseIllegalStateException e) { - throw new IllegalStateFault(e.getMessage()); - } - - StopResponseDocument responseDocument = StopResponseDocument.Factory.newInstance(); - StopResponseDocument.StopResponse response = StopResponseDocument.StopResponse.Factory.newInstance(); - responseDocument.setStopResponse(response); - return responseDocument; - } - - public SuspendResponseDocument suspend(SuspendDocument suspend) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void suspend(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = suspend.getSuspend().getIdentifier(); - - Task t = Task.load(hiseEngine, Long.parseLong(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.SUSPEND, getUserString(), t); - TaskChecker.checkStatePermission(HumanOperationName.SUSPEND, t); - t.setCurrentUser(getUserString()); - - try { - t.suspend(); - } catch (HiseIllegalStateException e) { - throw new IllegalStateFault(e.getMessage()); - } - - SuspendResponseDocument.SuspendResponse response = SuspendResponseDocument.SuspendResponse.Factory.newInstance(); - SuspendResponseDocument responseDocument = SuspendResponseDocument.Factory.newInstance(); - responseDocument.setSuspendResponse(response); - - return responseDocument; - } - - public SuspendUntilResponseDocument suspendUntil(SuspendUntilDocument suspendUntil) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void suspendUntil(String identifier, TTime time) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = suspendUntil.getSuspendUntil().getIdentifier(); - TTime time = suspendUntil.getSuspendUntil().getTime(); - - Task t = Task.load(hiseEngine, Long.parseLong(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.SUSPEND_UNTIL, getUserString(), t); - TaskChecker.checkStatePermission(HumanOperationName.SUSPEND_UNTIL, t); - t.setCurrentUser(getUserString()); - GDate when; - if (time.getPointOfTime() == null) { - GDuration when2 = time.getTimePeriod(); - when = new GDate(new Date()); - - when = when.add(when2); -// when2.addTo(when); - } else { - when = new GDate(time.getPointOfTime().getTime()); - } - - try { - t.suspendUntil(when.getCalendar().getTime()); - } catch (HiseIllegalStateException e) { - throw new IllegalStateFault(e.getMessage()); - } - SuspendUntilResponseDocument responseDocument = SuspendUntilResponseDocument.Factory.newInstance(); - SuspendUntilResponseDocument.SuspendUntilResponse response = SuspendUntilResponseDocument.SuspendUntilResponse.Factory.newInstance(); - responseDocument.setSuspendUntilResponse(response); - - return responseDocument; - } - - public RemoveResponseDocument remove(RemoveDocument remove) throws IllegalArgumentFault, IllegalAccessFault { -// public void remove(String identifier) throws IllegalAccessFault, IllegalArgumentFault { - String identifier = remove.getRemove().getIdentifier(); - - Task t = Task.load(hiseEngine, Long.parseLong(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.REMOVE, getUserString(), t); - t.setCurrentUser(getUserString()); - t.remove(); - - RemoveResponseDocument responseDocument = RemoveResponseDocument.Factory.newInstance(); - RemoveResponseDocument.RemoveResponse response = RemoveResponseDocument.RemoveResponse.Factory.newInstance(); - responseDocument.setRemoveResponse(response); - - return responseDocument; - } - - public ResumeResponseDocument resume(ResumeDocument resume) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void resume(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = resume.getResume().getIdentifier(); - - // OrgEntity user = loadUser(); - Task t = Task.load(hiseEngine, Long.parseLong(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.RESUME, getUserString(), t); - TaskChecker.checkStatePermission(HumanOperationName.RESUME, t); - t.setCurrentUser(getUserString()); - - try { - t.resume(); - } catch (HiseIllegalStateException e) { - throw new IllegalStateFault(e.getMessage()); - } - - ResumeResponseDocument responseDocument = ResumeResponseDocument.Factory.newInstance(); - ResumeResponseDocument.ResumeResponse response = ResumeResponseDocument.ResumeResponse.Factory.newInstance(); - responseDocument.setResumeResponse(response); - - return responseDocument; - } - - public GetTaskInfoResponseDocument getTaskInfo(GetTaskInfoDocument getTaskInfo) throws IllegalArgumentFault { -// public org.apache.hise.lang.xsd.htda.TTask getTaskInfo(String identifier) throws IllegalArgumentFault { - String identifier = getTaskInfo.getGetTaskInfo().getIdentifier(); - - GetTaskInfoResponseDocument responseDocument = GetTaskInfoResponseDocument.Factory.newInstance(); - GetTaskInfoResponseDocument.GetTaskInfoResponse response = GetTaskInfoResponseDocument.GetTaskInfoResponse.Factory.newInstance(); - response.setTask(convertTask(hiseEngine.getHiseDao().find(org.apache.hise.dao.Task.class, Long.parseLong(identifier)).getId())); - responseDocument.setGetTaskInfoResponse(response); - return responseDocument; - } - - public ClaimResponseDocument claim(ClaimDocument claim) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void claim(String identifier) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { - String identifier = claim.getClaim().getIdentifier(); - - Task task = Task.load(hiseEngine, Long.valueOf(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.CLAIM, getUserString(), task); - TaskChecker.checkStatePermission(HumanOperationName.CLAIM, task); - task.setCurrentUser(getUserString()); - - try { - task.claim(); - } catch (HiseIllegalStateException e) { - throw new IllegalStateFault(e.getMessage()); - } catch (HiseIllegalAccessException e) { - throw new IllegalAccessFault(e.getMessage()); - } - - ClaimResponseDocument responseDocument = ClaimResponseDocument.Factory.newInstance(); - ClaimResponseDocument.ClaimResponse response = ClaimResponseDocument.ClaimResponse.Factory.newInstance(); - responseDocument.setClaimResponse(response); - - return responseDocument; - } - - public FailResponseDocument fail(FailDocument fail) throws IllegalArgumentFault, IllegalStateFault, IllegalOperationFault, IllegalAccessFault { -// public void fail(String identifier, String faultName, Object faultData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault, -// IllegalOperationFault { - String identifier = fail.getFail().getIdentifier(); - String faultName = fail.getFail().getFaultName(); - XmlObject faultData = fail.getFail().getFaultData(); - - Task t = Task.load(hiseEngine, Long.parseLong(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.FAIL, getUserString(), t); - t.setCurrentUser(getUserString()); - - try { - t.fail(); - } catch (HiseIllegalStateException e) { - throw new IllegalStateFault(e.getMessage()); - } - - FailResponseDocument responseDocument = FailResponseDocument.Factory.newInstance(); - FailResponseDocument.FailResponse response = FailResponseDocument.FailResponse.Factory.newInstance(); - responseDocument.setFailResponse(response); - - return responseDocument; - } - - public ForwardResponseDocument forward(ForwardDocument forward) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void forward(String identifier, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = forward.getForward().getIdentifier(); - TOrganizationalEntity organizationalEntity = forward.getForward().getOrganizationalEntity(); - - Task t = Task.load(hiseEngine, Long.parseLong(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.FORWARD, getUserString(), t); - TaskChecker.checkStatePermission(HumanOperationName.FORWARD, t); - t.setCurrentUser(getUserString()); - - try { - t.forward(organizationalEntity); - } catch (HiseIllegalStateException e) { - throw new IllegalStateFault(e.getMessage()); - } - - ForwardResponseDocument responseDocument = ForwardResponseDocument.Factory.newInstance(); - ForwardResponseDocument.ForwardResponse response = ForwardResponseDocument.ForwardResponse.Factory.newInstance(); - responseDocument.setForwardResponse(response); - - return responseDocument; - } - - public GetTaskDescriptionResponseDocument getTaskDescription(GetTaskDescriptionDocument getTaskDescription) throws IllegalArgumentFault { -// public String getTaskDescription(String identifier, String contentType) throws IllegalArgumentFault { - String identifier = getTaskDescription.getGetTaskDescription().getIdentifier(); - String contentType = getTaskDescription.getGetTaskDescription().getContentType(); - - Task t = Task.load(hiseEngine, Long.parseLong(identifier)); - t.setCurrentUser(getUserString()); - - GetTaskDescriptionResponseDocument responseDocument = GetTaskDescriptionResponseDocument.Factory.newInstance(); - GetTaskDescriptionResponseDocument.GetTaskDescriptionResponse response = GetTaskDescriptionResponseDocument.GetTaskDescriptionResponse.Factory.newInstance(); - response.setDescription(t.getTaskEvaluator().evalPresentationDescription()); - responseDocument.setGetTaskDescriptionResponse(response); - return responseDocument; - } - - public ReleaseResponseDocument release(ReleaseDocument release) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void release(String identifier) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { - String identifier = release.getRelease().getIdentifier(); - Task t = Task.load(hiseEngine, Long.parseLong(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.RELEASE, getUserString(), t); - t.setCurrentUser(getUserString()); - - try { - t.release(); - } catch (HiseIllegalStateException e) { - throw new IllegalStateFault(e.getMessage()); - } - - ReleaseResponseDocument responseDocument = ReleaseResponseDocument.Factory.newInstance(); - ReleaseResponseDocument.ReleaseResponse response = ReleaseResponseDocument.ReleaseResponse.Factory.newInstance(); - responseDocument.setReleaseResponse(response); - - return responseDocument; - } - - public StartResponseDocument start(StartDocument start) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void start(String identifier) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { - String identifier = start.getStart().getIdentifier(); - - Task t = Task.load(hiseEngine, Long.parseLong(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.START, getUserString(), t); - TaskChecker.checkStatePermission(HumanOperationName.START, t); - t.setCurrentUser(getUserString()); - - try { - t.start(); - } catch (HiseIllegalStateException e) { - throw new IllegalStateFault(e.getMessage()); - } - - StartResponseDocument responseDocument = StartResponseDocument.Factory.newInstance(); - StartResponseDocument.StartResponse response = StartResponseDocument.StartResponse.Factory.newInstance(); - responseDocument.setStartResponse(response); - - return responseDocument; - } - - public CompleteResponseDocument complete(CompleteDocument complete) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void complete(String identifier, Object taskData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = complete.getComplete().getIdentifier(); - XmlObject taskData = complete.getComplete().getTaskData(); - - Task t = Task.load(hiseEngine, Long.parseLong(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.COMPLETE, getUserString(), t); - t.setCurrentUser(getUserString()); - //TODO set output - //t.setOutput(((Node) taskData).getFirstChild()); - - try { - t.complete(); - } catch (HiseIllegalStateException e) { - throw new IllegalStateFault(e.getMessage()); - } - - CompleteResponseDocument.CompleteResponse response = CompleteResponseDocument.CompleteResponse.Factory.newInstance(); - CompleteResponseDocument responseDocument = CompleteResponseDocument.Factory.newInstance(); - responseDocument.setCompleteResponse(response); - return responseDocument; - } - - public SetOutputResponseDocument setOutput(SetOutputDocument setOutput) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void setOutput(String identifier, String part, Object taskData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = setOutput.getSetOutput().getIdentifier(); - String part = setOutput.getSetOutput().getPart(); - XmlObject taskData = setOutput.getSetOutput().getTaskData(); - - Task t = Task.load(hiseEngine, Long.valueOf(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.SET_OUTPUT, getUserString(), t); - t.setCurrentUser(getUserString()); - t.setOutput(((Node) taskData.getDomNode()).getFirstChild()); - - SetOutputResponseDocument responseDocument = SetOutputResponseDocument.Factory.newInstance(); - SetOutputResponseDocument.SetOutputResponse response = SetOutputResponseDocument.SetOutputResponse.Factory.newInstance(); - responseDocument.setSetOutputResponse(response); - - return responseDocument; - } - - /** - * Adds comment to a task. Can be performed by: - * - potential owners - * - actual owner - * - business administrators - * - * @param identifier task's identifier - * @param text comment to add - */ - public AddCommentResponseDocument addComment(AddCommentDocument addComment) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void addComment(String identifier, String text) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = addComment.getAddComment().getIdentifier(); - String text = addComment.getAddComment().getText(); - - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.ADD_COMMENT, getUserString(), task); - org.apache.hise.dao.Task taskDto = task.getTaskDto(); - org.apache.hise.dao.Comment newComment = new Comment(text, taskDto, getUserString()); - taskDto.getComments().add(newComment); - - AddCommentResponseDocument responseDocument = AddCommentResponseDocument.Factory.newInstance(); - AddCommentResponseDocument.AddCommentResponse response = AddCommentResponseDocument.AddCommentResponse.Factory.newInstance(); - responseDocument.setAddCommentResponse(response); - - return responseDocument; - } - - /** - * Gets all comments of a task. - * Can be performed by: - * - potential owners - * - actual owner - * - business administrators - * - * @param identifier task's identifier - */ - public GetCommentsResposneDocument getComments(GetCommentsDocument getComments) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public List getComments(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = getComments.getGetComments().getIdentifier(); - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.GET_COMMENTS, getUserString(), task); - org.apache.hise.dao.Task taskDto = task.getTaskDto(); - List result = convertComments(taskDto.getComments()); - - GetCommentsResposneDocument resposneDocument = GetCommentsResposneDocument.Factory.newInstance(); - GetCommentsResposneDocument.GetCommentsResposne resposne = GetCommentsResposneDocument.GetCommentsResposne.Factory.newInstance(); - TComment[] commentArray = new TComment[result.size()]; - commentArray = result.toArray(commentArray); - resposne.setCommentArray(commentArray); - resposneDocument.setGetCommentsResposne(resposne); - - return resposneDocument; - } - - // not started - - public QueryResponseDocument query(QueryDocument query) throws IllegalArgumentFault, IllegalStateFault { -// public TTaskQueryResultSet query(String selectClause, String whereClause, String orderByClause, Integer maxTasks, Integer taskIndexOffset) -// throws IllegalArgumentFault, IllegalStateFault { - // TODO Auto-generated method stub - return null; - } - - public ActivateResponseDocument activate(ActivateDocument activate) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void activate(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = activate.getActivate().getIdentifier(); - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.ACTIVATE, getUserString(), task); - TaskChecker.checkStatePermission(HumanOperationName.ACTIVATE, task); - - task.activate(); - - try { - task.setStatus(Status.READY); - } catch (HiseIllegalStateException e) { - throw new IllegalStateFault("Illegal State Fault"); - } - task.setCurrentUser(getUserString()); - - ActivateResponseDocument responseDocument = ActivateResponseDocument.Factory.newInstance(); - ActivateResponseDocument.ActivateResponse response = ActivateResponseDocument.ActivateResponse.Factory.newInstance(); - responseDocument.setActivateResponse(response); - - return responseDocument; - } - - public AddAttachmentResponseDocument addAttachment(AddAttachmentDocument addAttachment) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void addAttachment(String identifier, String attachmentName, String accessType, Object attachment) throws IllegalAccessFault, IllegalStateFault, -// IllegalArgumentFault { - - String identifier = addAttachment.getAddAttachment().getIdentifier(); - String attachmentName = addAttachment.getAddAttachment().getName(); - String accessType = addAttachment.getAddAttachment().getAccessType(); - XmlObject attachment = addAttachment.getAddAttachment().getAttachment(); - - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.ADD_ATTACHMENT, getUserString(), task); - - org.apache.hise.dao.Task taskDto = task.getTaskDto(); - org.apache.hise.dao.Attachment newAttachment= new Attachment(); - newAttachment.setAccessType(accessType); - newAttachment.setName(attachmentName); - newAttachment.setAttachedAt(new Date()); - newAttachment.setTask(taskDto); - newAttachment.setUserName(getUserString()); - if(attachment.getDomNode() instanceof org.w3c.dom.Element){ - newAttachment.setAttachment(DOMUtil.getChildText(attachment.getDomNode())); - } - else{ - newAttachment.setAttachment(new String("")); - } - taskDto.getAttachments().add(newAttachment); - - AddAttachmentResponseDocument responseDocument = AddAttachmentResponseDocument.Factory.newInstance(); - AddAttachmentResponseDocument.AddAttachmentResponse response = AddAttachmentResponseDocument.AddAttachmentResponse.Factory.newInstance(); - responseDocument.setAddAttachmentResponse(response); - - return responseDocument; - } - - - public DelegateResponseDocument delegate(DelegateDocument delegate) throws RecipientNotAllowed, IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void delegate(String identifier, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault, IllegalStateFault, RecipientNotAllowed, -// IllegalArgumentFault { - String identifier = delegate.getDelegate().getIdentifier(); - TOrganizationalEntity organizationalEntity = delegate.getDelegate().getOrganizationalEntity(); - - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.DELEGATE, getUserString(), task); - TaskChecker.checkStatePermission(HumanOperationName.DELEGATE, task); - - String userID = task.checkCanDelegate(organizationalEntity); - task.setCurrentUser(getUserString()); - - try { - task.setActualOwner(userID); - task.addGenericHumanRole(userID, GenericHumanRole.POTENTIALOWNERS); - } catch (HiseIllegalStateException e) { - throw new IllegalStateFault(); - } - - DelegateResponseDocument responseDocument = DelegateResponseDocument.Factory.newInstance(); - DelegateResponseDocument.DelegateResponse response = DelegateResponseDocument.DelegateResponse.Factory.newInstance(); - responseDocument.setDelegateResponse(response); - - return responseDocument; - } - - public DeleteAttachmentsResponseDocument deleteAttachments(DeleteAttachmentsDocument deleteAttachments) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void deleteAttachments(String identifier, String attachmentName) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = deleteAttachments.getDeleteAttachments().getIdentifier(); - String attachmentName = deleteAttachments.getDeleteAttachments().getAttachmentName(); - - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.DELETE_ATTACHMENTS, getUserString(), task); - org.apache.hise.dao.Task taskDto = task.getTaskDto(); - List attachments=taskDto.getAttachments(); - Iterator attachemntIterator=attachments.iterator(); - Attachment attachment; - while(attachemntIterator.hasNext()){ - attachment=attachemntIterator.next(); - if(attachment.getName().equals(attachmentName)){ - hiseEngine.getHiseDao().remove(attachment); - attachemntIterator.remove(); - } - } -// TODO Attachments provided by -// the enclosing context are -// not affected by this -// operation. - - - DeleteAttachmentsResponseDocument responseDocument = DeleteAttachmentsResponseDocument.Factory.newInstance(); - DeleteAttachmentsResponseDocument.DeleteAttachmentsResponse response = DeleteAttachmentsResponseDocument.DeleteAttachmentsResponse.Factory.newInstance(); - responseDocument.setDeleteAttachmentsResponse(response); - - return responseDocument; - - - } - - public DeleteFaultResponseDocument deleteFault(DeleteFaultDocument deleteFault) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void deleteFault(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = deleteFault.getDeleteFault().getIdentifier(); - - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.DELELE_FAULT, getUserString(), task); - task.setCurrentUser(getUserString()); - // TODO Auto-generated method stub - - DeleteFaultResponseDocument responseDocument = DeleteFaultResponseDocument.Factory.newInstance(); - DeleteFaultResponseDocument.DeleteFaultResponse response = DeleteFaultResponseDocument.DeleteFaultResponse.Factory.newInstance(); - responseDocument.setDeleteFaultResponse(response); - - return responseDocument; - - } - - public DeleteOutputResponseDocument deleteOutput(DeleteOutputDocument deleteOutput) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void deleteOutput(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = deleteOutput.getDeleteOutput().getIdentifier(); - - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.DELETE_OUTPUT, getUserString(), task); - task.setCurrentUser(getUserString()); - // TODO Auto-generated method stub - - DeleteOutputResponseDocument responseDocument = DeleteOutputResponseDocument.Factory.newInstance(); - DeleteOutputResponseDocument.DeleteOutputResponse response = DeleteOutputResponseDocument.DeleteOutputResponse.Factory.newInstance(); - responseDocument.setDeleteOutputResponse(response); - - return responseDocument; - } - - public GetAttachmentInfosResponseDocument getAttachmentInfos(GetAttachmentInfosDocument getAttachmentInfos) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public List getAttachmentInfos(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = getAttachmentInfos.getGetAttachmentInfos().getIdentifier(); - - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.GET_ATTACHMENT_INFOS, getUserString(), task); - org.apache.hise.dao.Task taskDto = task.getTaskDto(); - List attachments=taskDto.getAttachments(); - List result= new ArrayList(); - for(Attachment a: attachments){ - TAttachmentInfo info=TAttachmentInfo.Factory.newInstance(); - info.setName(a.getName()); - Calendar attachedAt = Calendar.getInstance(); - attachedAt.setTime(a.getAttachedAt()); - info.setAttachedAt(attachedAt); - info.setAccessType(a.getAccessType()); - info.setAttachedBy(a.getuserName()); - - result.add(info); - } - - GetAttachmentInfosResponseDocument responseDocument = GetAttachmentInfosResponseDocument.Factory.newInstance(); - GetAttachmentInfosResponseDocument.GetAttachmentInfosResponse infosResponse = GetAttachmentInfosResponseDocument.GetAttachmentInfosResponse.Factory.newInstance(); - TAttachmentInfo[] attachmentInfos = new TAttachmentInfo[result.size()]; - attachmentInfos = result.toArray(attachmentInfos); - infosResponse.setInfoArray(attachmentInfos); - responseDocument.setGetAttachmentInfosResponse(infosResponse); - return responseDocument; - - } - - public GetAttachmentsResponseDocument getAttachments(GetAttachmentsDocument getAttachments) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public List getAttachments(String identifier, String attachmentName) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - - String identifier = getAttachments.getGetAttachments().getIdentifier(); - String attachmentName = getAttachments.getGetAttachments().getAttachmentName(); - - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.GET_ATTACHMENTS, getUserString(), task); - org.apache.hise.dao.Task taskDto = task.getTaskDto(); - List attachments=taskDto.getAttachments(); - List result= new ArrayList(); - for(Attachment a: attachments){ - if(a.getName().equals(attachmentName)){ - TAttachment ta=TAttachment.Factory.newInstance(); - TAttachmentInfo info=TAttachmentInfo.Factory.newInstance(); - info.setName(a.getName()); - Calendar attachedAt = Calendar.getInstance(); - attachedAt.setTime(a.getAttachedAt()); - info.setAttachedAt(attachedAt); - info.setAccessType(a.getAccessType()); - - info.setAttachedBy(a.getuserName()); - info.setContentType(a.getContentType()); - - ta.setAttachmentInfo(info); - ta.addNewValue().set(XmlString.Factory.newValue(a.getAttachment())); - - result.add(ta); - } - } - GetAttachmentsResponseDocument responseDocument = GetAttachmentsResponseDocument.Factory.newInstance(); - GetAttachmentsResponseDocument.GetAttachmentsResponse response = GetAttachmentsResponseDocument.GetAttachmentsResponse.Factory.newInstance(); - TAttachment[] attachmentsArray = new TAttachment[result.size()]; - attachmentsArray = result.toArray(attachmentsArray); - response.setAttachmentArray(attachmentsArray); - responseDocument.setGetAttachmentsResponse(response); - - return responseDocument; - - } - - /** - * Returns the rendering specified by the type. - * Applies to both tasks and notifications. - * @param identifier task identifier - * @param renderingType rendering type - * @return any type - * @since 0.3.0 - */ - public GetRenderingResponseDocument getRendering(GetRenderingDocument getRendering) throws IllegalArgumentFault { -// public Object getRendering(Object identifier, QName renderingType) throws IllegalArgumentFault { - String identifier = getRendering.getGetRendering().getIdentifier(); - QName renderingType = getRendering.getGetRendering().getRenderingType(); - -// if(identifier.getDomNode() instanceof org.w3c.dom.Element){ -// Long id = new Long(DOMUtil.getChildText(identifier.getDomNode())); - Long id = new Long(identifier); - Task task = Task.load(hiseEngine, id); - TRenderings tr = task.getTaskDefinition().getRenderings(); - TRendering rendering = null; - for(TRendering r: tr.getRenderingList()){ - if(renderingType.equals(r.getType())){ - rendering = r; - break; - } - } - if(rendering == null) return null; - - GetRenderingResponseDocument responseDocument = GetRenderingResponseDocument.Factory.newInstance(); - GetRenderingResponseDocument.GetRenderingResponse response = GetRenderingResponseDocument.GetRenderingResponse.Factory.newInstance(); - try { - response.setRendering(XmlObject.Factory.parse(convertRendering(rendering, task))); - } catch (XmlException ex) { - throw new RuntimeException(ex); - } - responseDocument.setGetRenderingResponse(response); - - return responseDocument; -// } -// return null; - - } - - private Element convertRendering(TRendering rendering, Task task) { - Node rend = DOMUtil.getFirstChildElement(rendering.getDomNode(),"expression"); - TaskEvaluator evaluator = task.getTaskEvaluator(); - String expression = DOMUtil.getChildText(rend); - - List queryResponse = evaluator.buildQueryEvaluator(rend) - .evaluateExpression(expression, null); - - if (queryResponse.get(0) instanceof Node) { - Document result = convertRenderingFromXML((Node) queryResponse.get(0)); - return result == null ? null : result.getDocumentElement(); - } else { - Document result = convertRenderingFromString(queryResponse.get(0).toString()); - return result == null ? null : result.getDocumentElement(); - } + @Override + protected String getUserString() { + return context.getUserPrincipal().getName(); } - - private Document convertRenderingFromString(String response) { - Document resultDocument = DOMUtils.createEmptyDomDocument(); - if(resultDocument==null)//there was problem with create document - return null; - Element element = resultDocument.createElement("root"); - element.appendChild(resultDocument.createTextNode(response)); - resultDocument.appendChild(element); - return resultDocument; - } - - private Document convertRenderingFromXML(Node response) { - Document resultDocument = DOMUtils.createEmptyDomDocument(); - if (resultDocument == null) {//there was problem with create document - return null; - } - resultDocument.appendChild(resultDocument.importNode(response, true)); - return resultDocument; - } - - /** - * Returns the rendering types available for the task or notification. - * @param identifier task identifier - * @return available renderings - * @since 0.3.0 - */ - public GetRenderingTypesResponseDocument getRenderingTypes(GetRenderingTypesDocument getRenderingTypes) throws IllegalArgumentFault { -// public List getRenderingTypes(Object identifier) throws IllegalArgumentFault { - XmlObject identifier = getRenderingTypes.getGetRenderingTypes().getIdentifier(); - - List result=new ArrayList(); - if(identifier.getDomNode() instanceof org.w3c.dom.Element){ -// Long id=DOMUtils.domToLong((org.w3c.dom.Element)identifier); - Long id = new Long(DOMUtil.getChildText(identifier.getDomNode())); - Task task = Task.load(hiseEngine, id); - TRenderings tr = task.getTaskDefinition().getRenderings(); - for(TRendering r: tr.getRenderingList()){ - result.add(r.getType()); - } - } - GetRenderingTypesResponseDocument responseDocument = GetRenderingTypesResponseDocument.Factory.newInstance(); - GetRenderingTypesResponseDocument.GetRenderingTypesResponse response = GetRenderingTypesResponseDocument.GetRenderingTypesResponse.Factory.newInstance(); - QName[] renderingTypeArray = new QName[result.size()]; - renderingTypeArray = result.toArray(renderingTypeArray); - response.setRenderingTypeArray(renderingTypeArray); - responseDocument.setGetRenderingTypesResponse(response); - - return responseDocument; - } - - public NominateResponseDocument nominate(NominateDocument nominate) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void nominate(String identifier, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = nominate.getNominate().getIdentifier(); - TOrganizationalEntity organizationalEntity = nominate.getNominate().getOrganizationalEntity(); - - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.NOMINATE, getUserString(), task); - TaskChecker.checkStatePermission(HumanOperationName.NOMINATE, task); - - TUserlist tUsers = organizationalEntity.getUsers(); - TGrouplist tGroup = organizationalEntity.getGroups(); - try { - //When only one user is nominate, he become ActualOwner - if((tGroup == null)&&(tUsers != null)&&(tUsers.getUserList().size() == 1)){ - task.setActualOwner(tUsers.getUserList().get(0)); - task.addGenericHumanRole(tUsers.getUserList().get(0), GenericHumanRole.POTENTIALOWNERS); - }else{ - if(tGroup != null){ - for(String group: tGroup.getGroupList()) - task.addGenericHumanRole(group, GenericHumanRole.POTENTIALOWNERS); - } - if(tUsers != null){ - for(String user: tUsers.getUserList()) - task.addGenericHumanRole(user,GenericHumanRole.POTENTIALOWNERS); - } - task.setStatus(Status.READY); - } - } catch (HiseIllegalStateException e) { - throw new IllegalStateFault("Illegal State Fault"); - } - - NominateResponseDocument responseDocument = NominateResponseDocument.Factory.newInstance(); - NominateResponseDocument.NominateResponse response = NominateResponseDocument.NominateResponse.Factory.newInstance(); - responseDocument.setNominateResponse(response); - - return responseDocument; - } - - public SetFaultResponseDocument setFault(SetFaultDocument setFault) throws IllegalArgumentFault, IllegalStateFault, IllegalOperationFault, IllegalAccessFault { -// public void setFault(String identifier, String faultName, Object faultData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault, -// IllegalOperationFault { - String identifier = setFault.getSetFault().getIdentifier(); - String faultName = setFault.getSetFault().getFaultName(); - - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.SET_FAULT, getUserString(), task); - task.setCurrentUser(getUserString()); - // TODO Auto-generated method stub - - SetFaultResponseDocument responseDocument = SetFaultResponseDocument.Factory.newInstance(); - SetFaultResponseDocument.SetFaultResponse response = SetFaultResponseDocument.SetFaultResponse.Factory.newInstance(); - responseDocument.setSetFaultResponse(response); - - return responseDocument; - } - - public SetGenericHumanRoleResponseDocument setGenericHumanRole(SetGenericHumanRoleDocument setGenericHumanRole) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void setGenericHumanRole(String identifier, String genericHumanRole, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault, -// IllegalStateFault, IllegalArgumentFault { - - String identifier = setGenericHumanRole.getSetGenericHumanRole().getIdentifier(); - String genericHumanRole = setGenericHumanRole.getSetGenericHumanRole().getGenericHumanRole(); - TOrganizationalEntity organizationalEntity = setGenericHumanRole.getSetGenericHumanRole().getOrganizationalEntity(); - - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.SET_GENERIC_HUMAN_ROLE, getUserString(), task); - - TUserlist tUsers = organizationalEntity.getUsers(); - TGrouplist tGroup = organizationalEntity.getGroups(); - Set orgEntityName = new HashSet(); - if(tUsers != null){ - for(String e: tUsers.getUserList()) - orgEntityName.add(e); - } - if(tGroup != null){ - for(String e: tGroup.getGroupList()) - orgEntityName.add(e); - } - - for(String i: orgEntityName){ - for(TaskOrgEntity e: task.getTaskDto().getPeopleAssignments()){ - if(i.equals(e.getName())){ - hiseEngine.getHiseDao().remove(e); - } - } - task.addGenericHumanRole(i, GenericHumanRole.valueOf(genericHumanRole)); - } - - SetGenericHumanRoleResponseDocument responseDocument = SetGenericHumanRoleResponseDocument.Factory.newInstance(); - SetGenericHumanRoleResponseDocument.SetGenericHumanRoleResponse response = SetGenericHumanRoleResponseDocument.SetGenericHumanRoleResponse.Factory.newInstance(); - responseDocument.setSetGenericHumanRoleResponse(response); - - return responseDocument; - } - - public SetPriorityResponseDocument setPriority(SetPriorityDocument setPriority) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault { -// public void setPriority(String identifier, BigInteger priority) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault { - String identifier = setPriority.getSetPriority().getIdentifier(); - BigInteger priority = setPriority.getSetPriority().getPriority(); - - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.SET_PRIORITY, getUserString(), task); - org.apache.hise.dao.Task taskDto = task.getTaskDto(); - taskDto.setPriority(priority.intValue()); - - SetPriorityResponseDocument responseDocument = SetPriorityResponseDocument.Factory.newInstance(); - SetPriorityResponseDocument.SetPriorityResponse response = SetPriorityResponseDocument.SetPriorityResponse.Factory.newInstance(); - responseDocument.setSetPriorityResponse(response); - - return responseDocument; - } - - public SkipResponseDocument skip(SkipDocument skip) throws IllegalArgumentFault, IllegalStateFault, IllegalOperationFault, IllegalAccessFault { -// public void skip(String identifier) throws -// IllegalAccessFault, IllegalStateFault, IllegalArgumentFault, -// IllegalOperationFault { - String identifier = skip.getSkip().getIdentifier(); - - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.SKIP, getUserString(), task); - task.setCurrentUser(getUserString()); - org.apache.hise.dao.Task taskDto = task.getTaskDto(); - if(taskDto.isSkippable()){ - try { - task.setStatus(Status.OBSOLETE); - } catch (HiseIllegalStateException e) { - throw new IllegalStateFault("Task is not skipable"); - } - } - - SkipResponseDocument responseDocument = SkipResponseDocument.Factory.newInstance(); - SkipResponseDocument.SkipResponse response = SkipResponseDocument.SkipResponse.Factory.newInstance(); - responseDocument.setSkipResponse(response); - - return responseDocument; - - } - - public GetFaultResponseDocument getFault(GetFaultDocument getFault) throws IllegalArgumentFault, IllegalStateFault, IllegalOperationFault, IllegalAccessFault { -// public void getFault(String identifier, Holder faultName, Holder faultData) throws IllegalArgumentFault, IllegalStateFault, -// IllegalOperationFault, IllegalAccessFault { - String identifier = getFault.getGetFault().getIdentifier(); - String faultName = getFault.getGetFault().getFaultName(); - - Task task = Task.load(hiseEngine, new Long(identifier)); - TaskChecker.checkHumanRolePermission(HumanOperationName.GET_FAULT, getUserString(), task); - - // TODO Auto-generated method stub - - GetFaultResponseDocument responseDocument = GetFaultResponseDocument.Factory.newInstance(); - GetFaultResponseDocument.GetFaultResponse response = GetFaultResponseDocument.GetFaultResponse.Factory.newInstance(); - responseDocument.setGetFaultResponse(response); - - return responseDocument; - - } - - public GetMyTaskAbstractsResponseDocument getMyTaskAbstracts(GetMyTaskAbstractsDocument getMyTaskAbstracts) throws IllegalArgumentFault, IllegalStateFault { - //public List getMyTaskAbstracts(String taskType, String genericHumanRole, String workQueue, List status, String whereClause, -// String createdOnClause, Integer maxTasks) throws IllegalArgumentFault, IllegalStateFault { - - String taskType = getMyTaskAbstracts.getGetMyTaskAbstracts().getTaskType(); - String genericHumanRole = getMyTaskAbstracts.getGetMyTaskAbstracts().getGenericHumanRole(); - String workQueue = getMyTaskAbstracts.getGetMyTaskAbstracts().getWorkQueue(); - List status = getMyTaskAbstracts.getGetMyTaskAbstracts().getStatusList(); - String whereClause = getMyTaskAbstracts.getGetMyTaskAbstracts().getWhereClause(); - String createdOnClause = getMyTaskAbstracts.getGetMyTaskAbstracts().getCreatedOnClause(); - Integer maxTasks = getMyTaskAbstracts.getGetMyTaskAbstracts().getMaxTasks(); - - List result = new ArrayList(); - - String user = getUserString(); - - TaskQuery query = new TaskQuery(); - query.setUser(user); - query.setUserGroups(hiseEngine.getHiseUserDetails().getUserGroups(user)); - query.setTaskType(taskType); - query.setGenericHumanRole(GenericHumanRole.valueOf(genericHumanRole)); - query.setWorkQueue(workQueue); - query.setStatuses(status); - query.setWhereClause(whereClause); - query.setCreatedOnClause(createdOnClause); - - if (maxTasks != null) { - query.setMaxTasks(maxTasks); - } - - List tasks = hiseEngine.getHiseDao().getUserTasks(query); - - for (org.apache.hise.dao.Task u : tasks) { - TTaskAbstract t = convertTasktoTTaskAbstract(u.getId()); - result.add(t); - } - - GetMyTaskAbstractsResponseDocument responseDocument = GetMyTaskAbstractsResponseDocument.Factory.newInstance(); - GetMyTaskAbstractsResponseDocument.GetMyTaskAbstractsResponse response = GetMyTaskAbstractsResponseDocument.GetMyTaskAbstractsResponse.Factory.newInstance(); - TTaskAbstract[] taskArray = new TTaskAbstract[result.size()]; - taskArray = result.toArray(taskArray); - response.setTaskAbstractArray(taskArray); - responseDocument.setGetMyTaskAbstractsResponse(response); - - return responseDocument; - } - - private TTaskAbstract convertTasktoTTaskAbstract(Long id) { - Task task = Task.load(hiseEngine, id); - org.apache.hise.dao.Task taskDto = task.getTaskDto(); - - TTaskAbstract result = TTaskAbstract.Factory.newInstance(); - result.setId(taskDto.getId().toString()); - result.setTaskType(taskDto.isNotification() ? "NOTIFICATION" : "TASK"); - Calendar createdOn = Calendar.getInstance(); - createdOn.setTime(taskDto.getCreatedOn()); - result.setCreatedOn(createdOn); - Calendar activationTime = Calendar.getInstance(); - activationTime.setTime(taskDto.getActivationTime()); - result.setActivationTime(activationTime); - result.setPresentationName(task.getTaskEvaluator().getPresentationName()); - result.setPresentationSubject(task.getTaskEvaluator().evalPresentationSubject()); - result.setName(taskDto.getTaskDefinitionName()); - result.setStatus(TStatus.Enum.forString(taskDto.getStatus().toString())); - - - - -// TOrganizationalEntity tOrganizational = new TOrganizationalEntity(); -// TUserlist users=new TUserlist(); -// //TGrouplist groups=new TGrouplist(); -// for(TaskOrgEntity o : taskDto.getPotentialOwners()){ -// if(o.getType()==OrgEntityType.USER) -// users.getUser().add(o.getName()); -// } -// if(!users.getUser().isEmpty()) -// tOrganizational.withUsers(users); -// if(!users.getUser().isEmpty() ) -// result.setPotentialOwners(tOrganizational); - - - result.setPriority(new BigInteger(new Integer(taskDto.getPriority()).toString())); - result.setIsSkipable(taskDto.isSkippable()); - - - result.setPriority(new BigInteger(new Integer(taskDto.getPriority()).toString())); - result.setIsSkipable(taskDto.isSkippable()); - - - return result; - - } - - /** - * TODO extract converters to external class - */ - private TTask convertTask(Long id) { - Task task = Task.load(hiseEngine, id); - org.apache.hise.dao.Task taskDto = task.getTaskDto(); - - TTask result = TTask.Factory.newInstance(); - result.setId(taskDto.getId().toString()); - result.setTaskType(taskDto.isNotification() ? "NOTIFICATION" : "TASK"); - Calendar createdOn = Calendar.getInstance(); - createdOn.setTime(taskDto.getCreatedOn()); - result.setCreatedOn(createdOn); - Calendar activationTime = Calendar.getInstance(); - activationTime.setTime(taskDto.getActivationTime()); - result.setActivationTime(activationTime); - result.setCreatedBy(taskDto.getCreatedBy()); - result.setPresentationName(task.getTaskEvaluator().getPresentationName()); - result.setPresentationSubject(task.getTaskEvaluator().evalPresentationSubject()); - result.setName(taskDto.getTaskDefinitionName()); - result.setStatus(TStatus.Enum.forString(taskDto.getStatus().toString())); - - if (taskDto.getActualOwner() != null) { - result.setActualOwner(taskDto.getActualOwner()); - - } -// Vector temp=new Vector(taskDto.getPeopleAssignments()); -// int k=temp.size(); - TOrganizationalEntity tOrganizational = TOrganizationalEntity.Factory.newInstance(); - TUserlist users=TUserlist.Factory.newInstance(); - for(TaskOrgEntity o : taskDto.getBusinessAdministrators()){ - if(o.getType()==OrgEntityType.USER) - users.getUserList().add(o.getName()); - } - if(!users.getUserList().isEmpty()) - tOrganizational.setUsers(users); - if(!users.getUserList().isEmpty() ) - result.setBusinessAdministrators(tOrganizational); - - - tOrganizational = TOrganizationalEntity.Factory.newInstance(); - users=TUserlist.Factory.newInstance(); - for(TaskOrgEntity o : taskDto.getTaskStakeholders()){ - if(o.getType()==OrgEntityType.USER) - users.getUserList().add(o.getName()); - } - if(!users.getUserList().isEmpty()) - tOrganizational.setUsers(users); - if(!users.getUserList().isEmpty() ) - result.setTaskStakeholders(tOrganizational); - - tOrganizational = TOrganizationalEntity.Factory.newInstance(); - users=TUserlist.Factory.newInstance(); - //TGrouplist groups=new TGrouplist(); - for(TaskOrgEntity o : taskDto.getPotentialOwners()){ - if(o.getType()==OrgEntityType.USER) - users.getUserList().add(o.getName()); - } - if(!users.getUserList().isEmpty()) - tOrganizational.setUsers(users); - if(!users.getUserList().isEmpty() ) - result.setPotentialOwners(tOrganizational); - - - result.setPriority(new BigInteger(new Integer(taskDto.getPriority()).toString())); - result.setIsSkipable(taskDto.isSkippable()); - - - result.setPriority(new BigInteger(new Integer(taskDto.getPriority()).toString())); - result.setIsSkipable(taskDto.isSkippable()); - - //TODO - result.setRenderingMethodExists(true); - - return result; - } - - - - /** - * TODO extract converters to external class - * @param taskDto - * @return - */ - private List convertComments(List comments) { - List result = new ArrayList(); - for(Comment comment : comments){ - result.add(convertComment(comment)); - } - return result; - } - - /** - * - * @param comment - * @return - */ - private TComment convertComment(Comment comment) { - TComment tComment=TComment.Factory.newInstance(); - tComment.setText(comment.getContent()); - Calendar addedAt = new GregorianCalendar(); - addedAt.setTime(comment.getDate()); - tComment.setAddedAt(addedAt); - tComment.setAddedBy(comment.getUserName()); - return tComment; - } - - /** - * IoC setter. - * - * @param hiseEngine - */ - public void setHiseEngine(HISEEngineImpl hiseEngine) { - this.hiseEngine = hiseEngine; + public void init() throws Exception { + context = (WebServiceContext) Class.forName("org.apache.cxf.jaxws.context.WebServiceContextImpl").newInstance(); } } \ No newline at end of file Modified: incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/Test.java URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/Test.java?rev=987241&r1=987240&r2=987241&view=diff ============================================================================== --- incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/Test.java (original) +++ incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/Test.java Thu Aug 19 17:37:40 2010 @@ -2,10 +2,43 @@ package org.apache.hise.test; import javax.jws.WebService; +import org.apache.hise.lang.xsd.htdt.CompleteDocument; +import org.apache.hise.lang.xsd.htdt.CompleteResponseDocument; +import org.apache.hise.lang.xsd.htdt.GetMyTaskAbstractsDocument; +import org.apache.hise.lang.xsd.htdt.GetMyTaskAbstractsResponseDocument; +import org.apache.hise.lang.xsd.htdt.GetTaskInfoDocument; +import org.apache.hise.lang.xsd.htdt.GetTaskInfoResponseDocument; +import org.apache.hise.lang.xsd.htdt.NominateDocument; +import org.apache.hise.lang.xsd.htdt.NominateResponseDocument; +import org.apache.hise.lang.xsd.htdt.ReleaseDocument; +import org.apache.hise.lang.xsd.htdt.ReleaseResponseDocument; +import org.apache.hise.lang.xsd.htdt.StartDocument; +import org.apache.hise.lang.xsd.htdt.StartResponseDocument; +import org.apache.hise.lang.xsd.htdt.StopDocument; +import org.apache.hise.lang.xsd.htdt.StopResponseDocument; + +import org.apache.hise.engine.wsdl.IllegalAccessFault; +import org.apache.hise.engine.wsdl.IllegalArgumentFault; +import org.apache.hise.engine.wsdl.IllegalStateFault; import org.apache.hise.lang.xsd.htd.TOrganizationalEntity; @WebService public interface Test { void cleanup() throws Exception; + void delegateViaApi(final String identifier, final TOrganizationalEntity organizationalEntity); + + StartResponseDocument startViaApi(StartDocument start, String userName) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault ; + + public CompleteResponseDocument completeViaApi(CompleteDocument complete, String name) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault; + + public StopResponseDocument stopViaApi(StopDocument stop, String name) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault; + + public GetTaskInfoResponseDocument getTaskInfo(GetTaskInfoDocument getTaskInfo) throws IllegalArgumentFault; + + public ReleaseResponseDocument release(ReleaseDocument release, String name) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault; + + public GetMyTaskAbstractsResponseDocument getMyTaskAbstracts(GetMyTaskAbstractsDocument getMyTaskAbstracts, String name) throws IllegalArgumentFault, IllegalStateFault; + + public NominateResponseDocument nominate(NominateDocument nominate, String name) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault; } Modified: incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/TestImpl.java URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/TestImpl.java?rev=987241&r1=987240&r2=987241&view=diff ============================================================================== --- incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/TestImpl.java (original) +++ incubator/hise/trunk/hise-test-example-osgi/src/main/java/org/apache/hise/test/TestImpl.java Thu Aug 19 17:37:40 2010 @@ -3,10 +3,27 @@ package org.apache.hise.test; import javax.jws.WebService; +import org.apache.hise.lang.xsd.htdt.CompleteDocument; +import org.apache.hise.lang.xsd.htdt.CompleteResponseDocument; +import org.apache.hise.lang.xsd.htdt.GetMyTaskAbstractsDocument; +import org.apache.hise.lang.xsd.htdt.GetMyTaskAbstractsResponseDocument; +import org.apache.hise.lang.xsd.htdt.GetTaskInfoDocument; +import org.apache.hise.lang.xsd.htdt.GetTaskInfoResponseDocument; +import org.apache.hise.lang.xsd.htdt.NominateDocument; +import org.apache.hise.lang.xsd.htdt.NominateResponseDocument; +import org.apache.hise.lang.xsd.htdt.ReleaseDocument; +import org.apache.hise.lang.xsd.htdt.ReleaseResponseDocument; +import org.apache.hise.lang.xsd.htdt.StartDocument; +import org.apache.hise.lang.xsd.htdt.StartResponseDocument; +import org.apache.hise.lang.xsd.htdt.StopDocument; +import org.apache.hise.lang.xsd.htdt.StopResponseDocument; + import org.apache.hise.api.HISEEngine; import org.apache.hise.api.Management; import org.apache.hise.dao.Job; import org.apache.hise.dao.Task; +import org.apache.hise.engine.wsdl.IllegalAccessFault; +import org.apache.hise.engine.wsdl.IllegalArgumentFault; import org.apache.hise.engine.wsdl.IllegalStateFault; import org.apache.hise.engine.wsdl.RecipientNotAllowed; import org.apache.hise.lang.xsd.htd.TOrganizationalEntity; @@ -67,8 +84,54 @@ public class TestImpl implements Test { public void setManagement(Management management) { this.management = management; } - - + public StartResponseDocument startViaApi(final StartDocument start, + final String userName) throws IllegalArgumentFault, IllegalStateFault, + IllegalAccessFault { + + TransactionTemplate tt = new TransactionTemplate(transactionManager); + Object result=tt.execute(new TransactionCallback() { + public Object doInTransaction(TransactionStatus status) { + try { + return (management).start(start, userName); + } catch (IllegalStateFault e) { + e.printStackTrace(); + } catch (IllegalArgumentFault e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessFault e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + }); + return (StartResponseDocument)result; + + } + + public CompleteResponseDocument completeViaApi(CompleteDocument complete, String name) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault{ + return (management).complete(complete, name); + + } + public StopResponseDocument stopViaApi(StopDocument stop, String name) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault{ + return (management).stop(stop, name); + } + + public GetTaskInfoResponseDocument getTaskInfo(GetTaskInfoDocument getTaskInfo) throws IllegalArgumentFault{ + return management.getTaskInfo(getTaskInfo); + } + + public ReleaseResponseDocument release(ReleaseDocument release, String name) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault{ + return management.release(release, name); + } + + public GetMyTaskAbstractsResponseDocument getMyTaskAbstracts(GetMyTaskAbstractsDocument getMyTaskAbstracts, String name) throws IllegalArgumentFault, IllegalStateFault{ + return management.getMyTaskAbstracts(getMyTaskAbstracts, name); + } + + public NominateResponseDocument nominate(NominateDocument nominate, String name) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault{ + return management.nominate(nominate, name); + } }