You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hise-commits@incubator.apache.org by rr...@apache.org on 2010/07/27 12:06:17 UTC
svn commit: r979658 [1/3] - in /incubator/hise/trunk:
hise-services/src/main/java/org/apache/hise/engine/
hise-services/src/main/java/org/apache/hise/engine/jaxws/
hise-services/src/main/java/org/apache/hise/lang/
hise-services/src/main/java/org/apache...
Author: rr
Date: Tue Jul 27 12:06:16 2010
New Revision: 979658
URL: http://svn.apache.org/viewvc?rev=979658&view=rev
Log:
HISE-55: Implement Administrative Operations (Thanks to Michał Więcław)
Modified:
incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/TaskChecker.java
incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java
incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/lang/TaskDefinition.java
incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java
incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml
incubator/hise/trunk/hise-wsdl/src/main/resources/ws-humantask.xsd
incubator/hise/trunk/itest/hise-soapui-project.xml
incubator/hise/trunk/itest/task_history.xml
Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/TaskChecker.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/TaskChecker.java?rev=979658&r1=979657&r2=979658&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/TaskChecker.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/TaskChecker.java Tue Jul 27 12:06:16 2010
@@ -10,10 +10,13 @@ import org.apache.bcel.generic.GETFIELD;
import org.apache.hise.dao.GenericHumanRole;
import org.apache.hise.dao.HISEDao;
import org.apache.hise.dao.OrgEntity;
+import org.apache.hise.dao.Task.Status;
import org.apache.hise.dao.TaskOrgEntity;
+import org.apache.hise.engine.wsdl.IllegalAccessFault;
+import org.apache.hise.engine.wsdl.IllegalStateFault;
import org.apache.hise.runtime.Task;
/**
- * Check user authorization to use operation method
+ * Check user authorization and task's state to use operation method
*
* @author MichaÅ WiÄcÅaw
*
@@ -62,11 +65,11 @@ public class TaskChecker {
}
/**
- * check user authorization and give permission to action
+ * Check user authorization and give permission to action.
+ * Throws exception if it can't.
*
- * @return true if is permission
*/
- static public boolean checkPermission(TaskChecker.HumanOperationName operaionName, String userID, Task task)
+ static public void checkHumanRolePermission(TaskChecker.HumanOperationName operaionName, String userID, Task task) throws IllegalAccessFault
{
Collection<GenericHumanRole> humanRoles = new HashSet<GenericHumanRole>();
humanRoles = task.getGenericHumanRolesForUser(userID);
@@ -82,20 +85,20 @@ public class TaskChecker {
case SET_FAULT:
case DELELE_FAULT:
if(isActualOwner(humanRoles))
- return true;
- else return false;
+ return;
+ else throw new IllegalAccessFault("Illegal access to operations");
//G2 conditions: user is PotentialOwner or BusinessOwner or TaskStakeholders
case CLAIM:
if(isPotentialOwners(humanRoles) || isBusinessAdministrator(humanRoles) || isTaskStakeholders(humanRoles))
- return true;
- else return false;
+ return;
+ else throw new IllegalAccessFault("Illegal access to operations");
//G3 conditions: user is ActualOwner or (is PotentalOwner and task's state is ready)
case START:
if(isActualOwner(humanRoles) || isPotentialOwnersWithReadyState(humanRoles, task))
- return true;
- else return false;
+ return;
+ else throw new IllegalAccessFault("Illegal access to operations");
//G4 conditions: user is ActualOwner or BusinessOwner or TaskStakeholders
case STOP:
@@ -106,8 +109,8 @@ public class TaskChecker {
case GET_OUTPUT:
case GET_FAULT:
if(isActualOwner(humanRoles) || isBusinessAdministrator(humanRoles) || isTaskStakeholders(humanRoles))
- return true;
- else return false;
+ return;
+ else throw new IllegalAccessFault("Illegal access to operations");
//G5 conditions: user is (PotentalOwner and task's state is ready) or ActualOwner or BusinessOwner or TaskStakeholders
case SUSPEND:
@@ -116,8 +119,8 @@ public class TaskChecker {
case DELEGATE:
if(isPotentialOwnersWithReadyState(humanRoles, task) || isActualOwner(humanRoles) ||
isBusinessAdministrator(humanRoles) || isTaskStakeholders(humanRoles))
- return true;
- else return false;
+ return;
+ else throw new IllegalAccessFault("Illegal access to operations");
//G6 conditions: user is PotentalOwner or ActualOwner or BusinessOwner or TaskStakeholders
case GET_ATTACHMENT_INFOS:
@@ -128,39 +131,79 @@ public class TaskChecker {
case GET_INPUT:
if(isPotentialOwners(humanRoles) || isActualOwner(humanRoles) ||
isBusinessAdministrator(humanRoles) || isTaskStakeholders(humanRoles))
- return true;
- else return false;
+ return;
+ else throw new IllegalAccessFault("Illegal access to operations");
//G7 conditions: user is TaskInitiator or ActualOwner or BusinessOwner or TaskStakeholders
case SKIP:
if(isTaskInitiator(humanRoles) || isActualOwner(humanRoles) ||
isBusinessAdministrator(humanRoles) || isTaskStakeholders(humanRoles))
- return true;
- else return false;
+ return;
+ else throw new IllegalAccessFault("Illegal access to operations");
//G8 conditions: user is Recipients
case REMOVE:
if(isRecipients(humanRoles))
- return true;
- else return false;
+ return;
+ else throw new IllegalAccessFault("Illegal access to operations");
//G9 conditions: user is BusinessOwner or TaskStakeholders
case ACTIVATE:
case NOMINATE:
case SET_GENERIC_HUMAN_ROLE:
if(isBusinessAdministrator(humanRoles) || isTaskStakeholders(humanRoles))
- return true;
- else return false;
+ return;
+ else throw new IllegalAccessFault("Illegal access to operations");
//conditions: none conditions
case GET_RENDERING:
case GET_RENDERING_TYPES:
case GET_TASK_INFO:
case GET_TASK_DESCRIPTION:
- return true;
+ return;
+ }
+ }
+
+ /**
+ * Check task's state and give permission to action.
+ * Throws exception if it can't.
+ */
+ static public void checkStatePermission(TaskChecker.HumanOperationName operaionName, Task task) throws IllegalStateFault{
+ switch(operaionName){
+ case ACTIVATE:
+ case NOMINATE:
+ if(isCreatedState(task))
+ return;
+ else throw new IllegalStateFault("Illegal State Fault");
+
+ case SUSPEND:
+ case SUSPEND_UNTIL:
+ case DELEGATE:
+ case FORWARD:
+ if(isReadyState(task)||isReservedState(task)||isInProgressState(task))
+ return;
+ else throw new IllegalStateFault("Illegal State Fault");
+
+ case RESUME:
+ if(isSuspended(task))
+ return;
+ else throw new IllegalStateFault("Illegal State Fault");
+
+ case START:
+ if(isReadyState(task)||isReservedState(task))
+ return;
+ else throw new IllegalStateFault("Illegal State Fault");
+
+ case STOP:
+ if(isInProgressState(task))
+ return;
+ else throw new IllegalStateFault("Illegal State Fault");
+
+ case CLAIM:
+ if(isReadyState(task))
+ return;
+ else throw new IllegalStateFault("Illegal State Fault");
}
-
- return false;
}
static private boolean isActualOwner(Collection<GenericHumanRole> humanRoles)
@@ -219,4 +262,39 @@ public class TaskChecker {
return false;
}
+
+ static private boolean isCreatedState(Task task){
+ if(task.getTaskDto().getStatus() == Status.CREATED)
+ return true;
+
+ return false;
+ }
+
+ static private boolean isReadyState(Task task){
+ if(task.getTaskDto().getStatus() == Status.READY)
+ return true;
+
+ return false;
+ }
+
+ static private boolean isReservedState(Task task){
+ if(task.getTaskDto().getStatus() == Status.RESERVED)
+ return true;
+
+ return false;
+ }
+
+ static private boolean isInProgressState(Task task){
+ if(task.getTaskDto().getStatus() == Status.IN_PROGRESS)
+ return true;
+
+ return false;
+ }
+
+ static private boolean isSuspended(Task task){
+ if(task.getTaskDto().getStatus() == Status.SUSPENDED)
+ return true;
+
+ return false;
+ }
}
\ No newline at end of file
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=979658&r1=979657&r2=979658&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 Tue Jul 27 12:06:16 2010
@@ -46,6 +46,7 @@ import org.apache.hise.dao.TaskOrgEntity
import org.apache.hise.dao.TaskQuery;
import org.apache.hise.engine.HISEEngineImpl;
import org.apache.hise.engine.TaskChecker;
+import org.apache.hise.engine.TaskChecker.HumanOperationName;
import org.apache.hise.engine.wsdl.IllegalAccessFault;
import org.apache.hise.engine.wsdl.IllegalArgumentFault;
@@ -160,8 +161,7 @@ public class TaskOperationsImpl implemen
*/
public Object getInput(String identifier, String part) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task t = Task.load(hiseEngine, Long.parseLong(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.GET_INPUT, getUserString(), t)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.GET_INPUT, getUserString(), t);
t.setCurrentUser(getUserString());
return t.getInput(part);
}
@@ -171,8 +171,7 @@ public class TaskOperationsImpl implemen
*/
public Object getOutput(String identifier, String part) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task t = Task.load(hiseEngine, Long.parseLong(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.GET_OUTPUT, getUserString(), t)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.GET_OUTPUT, getUserString(), t);
t.setCurrentUser(getUserString());
return t.getOutput(part);
}
@@ -182,8 +181,8 @@ public class TaskOperationsImpl implemen
*/
public void stop(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task t = Task.load(hiseEngine, Long.parseLong(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.STOP, getUserString(), t)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.STOP, getUserString(), t);
+ TaskChecker.checkStatePermission(HumanOperationName.STOP, t);
t.setCurrentUser(getUserString());
try {
@@ -195,8 +194,8 @@ public class TaskOperationsImpl implemen
public void suspend(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task t = Task.load(hiseEngine, Long.parseLong(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.SUSPEND, getUserString(), t)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.SUSPEND, getUserString(), t);
+ TaskChecker.checkStatePermission(HumanOperationName.SUSPEND, t);
t.setCurrentUser(getUserString());
try {
@@ -208,8 +207,8 @@ public class TaskOperationsImpl implemen
public void suspendUntil(String identifier, TTime time) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task t = Task.load(hiseEngine, Long.parseLong(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.SUSPEND_UNTIL, getUserString(), t)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.SUSPEND_UNTIL, getUserString(), t);
+ TaskChecker.checkStatePermission(HumanOperationName.SUSPEND_UNTIL, t);
t.setCurrentUser(getUserString());
Date when = time.getPointOfTime();
if (when == null) {
@@ -227,8 +226,7 @@ public class TaskOperationsImpl implemen
public void remove(String identifier) throws IllegalAccessFault, IllegalArgumentFault {
Task t = Task.load(hiseEngine, Long.parseLong(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.REMOVE, getUserString(), t)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.REMOVE, getUserString(), t);
t.setCurrentUser(getUserString());
t.remove();
}
@@ -236,8 +234,8 @@ public class TaskOperationsImpl implemen
public void resume(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
// OrgEntity user = loadUser();
Task t = Task.load(hiseEngine, Long.parseLong(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.RESUME, getUserString(), t)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.RESUME, getUserString(), t);
+ TaskChecker.checkStatePermission(HumanOperationName.RESUME, t);
t.setCurrentUser(getUserString());
try {
@@ -253,8 +251,8 @@ public class TaskOperationsImpl implemen
public void claim(String identifier) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault {
Task task = Task.load(hiseEngine, Long.valueOf(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.CLAIM, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.CLAIM, getUserString(), task);
+ TaskChecker.checkStatePermission(HumanOperationName.CLAIM, task);
task.setCurrentUser(getUserString());
try {
@@ -269,8 +267,7 @@ public class TaskOperationsImpl implemen
public void fail(String identifier, String faultName, Object faultData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault,
IllegalOperationFault {
Task t = Task.load(hiseEngine, Long.parseLong(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.FAIL, getUserString(), t)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.FAIL, getUserString(), t);
t.setCurrentUser(getUserString());
try {
@@ -283,8 +280,8 @@ public class TaskOperationsImpl implemen
public void forward(String identifier, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task t = Task.load(hiseEngine, Long.parseLong(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.FORWARD, getUserString(), t)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.FORWARD, getUserString(), t);
+ TaskChecker.checkStatePermission(HumanOperationName.FORWARD, t);
t.setCurrentUser(getUserString());
try {
@@ -302,9 +299,7 @@ public class TaskOperationsImpl implemen
public void release(String identifier) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault {
Task t = Task.load(hiseEngine, Long.parseLong(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.RELEASE, getUserString(), t))) {
- throw new IllegalAccessFault("Illegal access to operations");
- }
+ TaskChecker.checkHumanRolePermission(HumanOperationName.RELEASE, getUserString(), t);
t.setCurrentUser(getUserString());
try {
@@ -316,9 +311,8 @@ public class TaskOperationsImpl implemen
public void start(String identifier) throws IllegalArgumentFault, IllegalStateFault, IllegalAccessFault {
Task t = Task.load(hiseEngine, Long.parseLong(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.START, getUserString(), t))) {
- throw new IllegalAccessFault("Illegal access to operations");
- }
+ TaskChecker.checkHumanRolePermission(HumanOperationName.START, getUserString(), t);
+ TaskChecker.checkStatePermission(HumanOperationName.START, t);
t.setCurrentUser(getUserString());
try {
@@ -330,9 +324,7 @@ public class TaskOperationsImpl implemen
public void complete(String identifier, Object taskData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task t = Task.load(hiseEngine, Long.parseLong(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.COMPLETE, getUserString(), t))) {
- throw new IllegalAccessFault("Illegal access to operations");
- }
+ TaskChecker.checkHumanRolePermission(HumanOperationName.COMPLETE, getUserString(), t);
t.setCurrentUser(getUserString());
//TODO set output
//t.setOutput(((Node) taskData).getFirstChild());
@@ -346,9 +338,7 @@ public class TaskOperationsImpl implemen
public void setOutput(String identifier, String part, Object taskData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task t = Task.load(hiseEngine, Long.valueOf(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.SET_OUTPUT, getUserString(), t))) {
- throw new IllegalAccessFault("Illegal access to operations");
- }
+ TaskChecker.checkHumanRolePermission(HumanOperationName.SET_OUTPUT, getUserString(), t);
t.setCurrentUser(getUserString());
t.setOutput(((Node) taskData).getFirstChild());
}
@@ -364,9 +354,7 @@ public class TaskOperationsImpl implemen
*/
public void addComment(String identifier, String text) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.ADD_COMMENT, getUserString(), task))) {
- throw new IllegalAccessFault("Illegal access to operations");
- }
+ 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);
@@ -383,9 +371,7 @@ public class TaskOperationsImpl implemen
*/
public List<TComment> getComments(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.GET_COMMENTS, getUserString(), task))) {
- throw new IllegalAccessFault("Illegal access to operations");
- }
+ TaskChecker.checkHumanRolePermission(HumanOperationName.GET_COMMENTS, getUserString(), task);
org.apache.hise.dao.Task taskDto = task.getTaskDto();
List<TComment> result = convertComments(taskDto.getComments());
return result;
@@ -401,8 +387,10 @@ public class TaskOperationsImpl implemen
public void activate(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.ACTIVATE, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.ACTIVATE, getUserString(), task);
+ TaskChecker.checkStatePermission(HumanOperationName.ACTIVATE, task);
+
+ task.activate();
try {
task.setStatus(Status.READY);
@@ -416,8 +404,8 @@ public class TaskOperationsImpl implemen
IllegalArgumentFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.ADD_ATTACHMENT, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
+ 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);
@@ -439,8 +427,8 @@ public class TaskOperationsImpl implemen
public void delegate(String identifier, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault, IllegalStateFault, RecipientNotAllowed,
IllegalArgumentFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.DELEGATE, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.DELEGATE, getUserString(), task);
+ TaskChecker.checkStatePermission(HumanOperationName.DELEGATE, task);
String userID = task.checkCanDelegate(organizationalEntity);
task.setCurrentUser(getUserString());
@@ -456,8 +444,7 @@ public class TaskOperationsImpl implemen
public void deleteAttachments(String identifier, String attachmentName) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.DELETE_ATTACHMENTS, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.DELETE_ATTACHMENTS, getUserString(), task);
org.apache.hise.dao.Task taskDto = task.getTaskDto();
List<Attachment> attachments=taskDto.getAttachments();
Iterator<Attachment> attachemntIterator=attachments.iterator();
@@ -480,8 +467,7 @@ public class TaskOperationsImpl implemen
public void deleteFault(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.DELELE_FAULT, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.DELELE_FAULT, getUserString(), task);
task.setCurrentUser(getUserString());
// TODO Auto-generated method stub
@@ -489,8 +475,7 @@ public class TaskOperationsImpl implemen
public void deleteOutput(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.DELETE_OUTPUT, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.DELETE_OUTPUT, getUserString(), task);
task.setCurrentUser(getUserString());
// TODO Auto-generated method stub
@@ -499,8 +484,7 @@ public class TaskOperationsImpl implemen
public List<TAttachmentInfo> getAttachmentInfos(String identifier) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.GET_ATTACHMENT_INFOS, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.GET_ATTACHMENT_INFOS, getUserString(), task);
org.apache.hise.dao.Task taskDto = task.getTaskDto();
List<Attachment> attachments=taskDto.getAttachments();
List<TAttachmentInfo> result= new ArrayList<TAttachmentInfo>();
@@ -518,8 +502,7 @@ public class TaskOperationsImpl implemen
public List<TAttachment> getAttachments(String identifier, String attachmentName) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.GET_ATTACHMENTS, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.GET_ATTACHMENTS, getUserString(), task);
org.apache.hise.dao.Task taskDto = task.getTaskDto();
List<Attachment> attachments=taskDto.getAttachments();
List<TAttachment> result= new ArrayList<TAttachment>();
@@ -625,43 +608,36 @@ public class TaskOperationsImpl implemen
public void nominate(String identifier, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.NOMINATE, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
-
-
- if(task.getTaskDto().getStatus()==Status.CREATED){
- TUserlist tUsers = organizationalEntity.getUsers();
- TGrouplist tGroup = organizationalEntity.getGroups();
- try {
- //When only one user is nominate, he become ActualOwner
- if((tGroup == null)&&(tUsers != null)&&(tUsers.getUser().size() == 1)){
- task.setActualOwner(tUsers.getUser().get(0));
- task.addGenericHumanRole(tUsers.getUser().get(0), GenericHumanRole.POTENTIALOWNERS);
- }else{
- if(tGroup != null){
- for(String group: tGroup.getGroup())
- task.addGenericHumanRole(group, GenericHumanRole.POTENTIALOWNERS);
- }
- if(tUsers != null){
- for(String user: tUsers.getUser())
- task.addGenericHumanRole(user,GenericHumanRole.POTENTIALOWNERS);
- }
- task.setStatus(Status.READY);
+ 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.getUser().size() == 1)){
+ task.setActualOwner(tUsers.getUser().get(0));
+ task.addGenericHumanRole(tUsers.getUser().get(0), GenericHumanRole.POTENTIALOWNERS);
+ }else{
+ if(tGroup != null){
+ for(String group: tGroup.getGroup())
+ task.addGenericHumanRole(group, GenericHumanRole.POTENTIALOWNERS);
}
- } catch (HiseIllegalStateException e) {
- throw new IllegalStateFault("Illegal State Fault");
- }
- }
- else{
- throw new IllegalStateFault("Nomination can be performed only in CREATED state");
- }
+ if(tUsers != null){
+ for(String user: tUsers.getUser())
+ task.addGenericHumanRole(user,GenericHumanRole.POTENTIALOWNERS);
+ }
+ task.setStatus(Status.READY);
+ }
+ } catch (HiseIllegalStateException e) {
+ throw new IllegalStateFault("Illegal State Fault");
+ }
}
public void setFault(String identifier, String faultName, Object faultData) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault,
IllegalOperationFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.SET_FAULT, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.SET_FAULT, getUserString(), task);
task.setCurrentUser(getUserString());
// TODO Auto-generated method stub
@@ -670,8 +646,7 @@ public class TaskOperationsImpl implemen
public void setGenericHumanRole(String identifier, String genericHumanRole, TOrganizationalEntity organizationalEntity) throws IllegalAccessFault,
IllegalStateFault, IllegalArgumentFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.SET_GENERIC_HUMAN_ROLE, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.SET_GENERIC_HUMAN_ROLE, getUserString(), task);
TUserlist tUsers = organizationalEntity.getUsers();
TGrouplist tGroup = organizationalEntity.getGroups();
@@ -697,8 +672,7 @@ public class TaskOperationsImpl implemen
public void setPriority(String identifier, BigInteger priority) throws IllegalAccessFault, IllegalStateFault, IllegalArgumentFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.SET_PRIORITY, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.SET_PRIORITY, getUserString(), task);
org.apache.hise.dao.Task taskDto = task.getTaskDto();
taskDto.setPriority(priority.intValue());
@@ -709,8 +683,7 @@ public class TaskOperationsImpl implemen
IllegalAccessFault, IllegalStateFault, IllegalArgumentFault,
IllegalOperationFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.SKIP, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.SKIP, getUserString(), task);
task.setCurrentUser(getUserString());
org.apache.hise.dao.Task taskDto = task.getTaskDto();
if(taskDto.isSkippable()){
@@ -726,8 +699,7 @@ public class TaskOperationsImpl implemen
public void getFault(String identifier, Holder<String> faultName, Holder<Object> faultData) throws IllegalArgumentFault, IllegalStateFault,
IllegalOperationFault, IllegalAccessFault {
Task task = Task.load(hiseEngine, new Long(identifier));
- if(!(TaskChecker.checkPermission(TaskChecker.HumanOperationName.GET_FAULT, getUserString(), task)))
- throw new IllegalAccessFault("Illegal access to operations");
+ TaskChecker.checkHumanRolePermission(HumanOperationName.GET_FAULT, getUserString(), task);
// TODO Auto-generated method stub
Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/lang/TaskDefinition.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/lang/TaskDefinition.java?rev=979658&r1=979657&r2=979658&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/lang/TaskDefinition.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/lang/TaskDefinition.java Tue Jul 27 12:06:16 2010
@@ -378,9 +378,11 @@ public class TaskDefinition {
public void setPortType(PortType portType) {
this.portType = portType;
}
+
public TRenderings getRenderings() {
return tTask.getRenderings();
}
+
public TDelegation getDelegation(){
if(tTask.getDelegation() == null){
TDelegation t = new TDelegation();
@@ -389,8 +391,12 @@ public class TaskDefinition {
}
return tTask.getDelegation();
}
+
public boolean isSavingTaskHistory(){
return tTask.isSavingTaskHistory();
}
-
+
+ public boolean isAutoActivate(){
+ return tTask.isAutoActivate();
+ }
}
Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java?rev=979658&r1=979657&r2=979658&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/runtime/Task.java Tue Jul 27 12:06:16 2010
@@ -176,7 +176,7 @@ public class Task {
return t;
}
- private void tryNominateOwner() throws HiseIllegalStateException {
+ private boolean tryNominateOwner() throws HiseIllegalStateException {
{
int poSize = 0;
TaskOrgEntity selected = null;
@@ -192,7 +192,10 @@ public class Task {
if (poSize == 1 && selected != null) {
//Nominate a single potential owner
setActualOwner(selected.getName());
+ return true;
}
+
+ return false;
}
}
@@ -243,16 +246,13 @@ public class Task {
}
try {
- t.setStatus(Status.READY);
- } catch (HiseIllegalStateException e) {
+ if(t.getTaskDefinition().isAutoActivate()){
+ t.activate();
+ }
+ } catch (IllegalStateFault e) {
throw new IllegalStateException(e);
}
-
- try {
- t.tryNominateOwner();
- } catch (HiseIllegalStateException e) {
- t.__log.warn("Could not nominate owner.");
- }
+
engine.getHiseDao().persist(taskDto);
return t;
@@ -414,12 +414,6 @@ public class Task {
* @return user name (ID)
*/
public String checkCanDelegate(TOrganizationalEntity delegatee) throws RecipientNotAllowed, IllegalStateFault {
-
- Status taskStatus = taskDto.getStatus();
-
- if (!(taskStatus.equals(Status.READY) || taskStatus.equals(Status.RESERVED) || taskStatus.equals(Status.IN_PROGRESS))){
- throw new IllegalStateFault("Only active tasks can be delegated.");
- }
List<String> userList = delegatee.getUsers().getUser();
if(userList.size() != 1){
@@ -1386,4 +1380,22 @@ public class Task {
taskDto.addPeopleAssignments(tList);
return true;
}
+
+ /**
+ * If task have PotentalOwners then task is activated. Task's state transition to REDY or RESERVED
+ */
+ public void activate() throws IllegalStateFault{
+ try {
+ boolean nominateOwner = this.tryNominateOwner();
+ if(!nominateOwner){
+ if(!taskDto.getPeopleAssignments().isEmpty()){
+ setStatus(Status.READY);
+ }else{
+ throw new IllegalStateFault("Illegal State Fault");
+ }
+ }
+ } catch (HiseIllegalStateException e) {
+ throw new IllegalStateFault("Illegal State Fault");
+ }
+ }
}
Modified: incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml?rev=979658&r1=979657&r2=979658&view=diff
==============================================================================
--- incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml (original)
+++ incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml Tue Jul 27 12:06:16 2010
@@ -49,8 +49,8 @@ Business Machines Corporation, Oracle In
htd:getInput("ClaimApprovalRequest")/cla:priority
</htd:priority>
-
-
+ <htd:autoActivate>true</htd:autoActivate>
+
<htd:peopleAssignments>
<htd:potentialOwners>
<htd:from>
@@ -65,6 +65,8 @@ Business Machines Corporation, Oracle In
</htd:from>
</htd:potentialOwners>
+
+
<htd:businessAdministrators>
<htd:from>
<htd:literal>
@@ -249,6 +251,8 @@ xs:double(htd:getInput("ClaimApprovalReq
htd:getInput("ClaimApprovalRequest")/cla:priority
</htd:priority>
+ <htd:autoActivate>true</htd:autoActivate>
+
<htd:peopleAssignments>
<htd:potentialOwners>
@@ -355,6 +359,8 @@ xs:double(htd:getInput("ClaimApprovalReq
<htd:documentation xml:lang="en-US">This task is used to handle claims that require manual approval. </htd:documentation>
<htd:interface portType="tns:ClaimsHandlingPT" operation="approve3"/>
+ <htd:autoActivate>true</htd:autoActivate>
+
<htd:peopleAssignments>
<htd:potentialOwners>
<htd:from>
@@ -488,6 +494,8 @@ xs:double(htd:getInput("ClaimApprovalReq
htd:getInput("ClaimApprovalRequest")/cla:priority
</htd:priority>
+ <htd:autoActivate>true</htd:autoActivate>
+
<htd:savingTaskHistory>
true
</htd:savingTaskHistory>
@@ -616,6 +624,8 @@ xs:double(htd:getInput("ClaimApprovalReq
htd:getInput("ClaimApprovalRequest")/cla:priority
</htd:priority>
+ <htd:autoActivate>true</htd:autoActivate>
+
<htd:peopleAssignments>
<htd:potentialOwners>
<htd:from>
@@ -730,6 +740,8 @@ xs:double(htd:getInput("ClaimApprovalReq
htd:getInput("ClaimApprovalRequest")/cla:priority
</htd:priority>
+ <htd:autoActivate>true</htd:autoActivate>
+
<htd:savingTaskHistory>
true
</htd:savingTaskHistory>
@@ -982,6 +994,8 @@ xs:double(htd:getInput("ClaimApprovalReq
htd:getInput("ClaimApprovalRequest")/cla:priority
</htd:priority>
+ <htd:autoActivate>true</htd:autoActivate>
+
<htd:peopleAssignments>
<htd:potentialOwners>
@@ -1096,6 +1110,8 @@ xs:double(htd:getInput("ClaimApprovalReq
htd:getInput("ClaimApprovalRequest")/cla:priority
</htd:priority>
+ <htd:autoActivate>true</htd:autoActivate>
+
<htd:savingTaskHistory>
true
</htd:savingTaskHistory>
Modified: incubator/hise/trunk/hise-wsdl/src/main/resources/ws-humantask.xsd
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-wsdl/src/main/resources/ws-humantask.xsd?rev=979658&r1=979657&r2=979658&view=diff
==============================================================================
--- incubator/hise/trunk/hise-wsdl/src/main/resources/ws-humantask.xsd (original)
+++ incubator/hise/trunk/hise-wsdl/src/main/resources/ws-humantask.xsd Tue Jul 27 12:06:16 2010
@@ -205,6 +205,7 @@ Business Machines Corporation, Oracle In
minOccurs="0" />
<xsd:element name="deadlines" type="tDeadlines" minOccurs="0" />
<xsd:element name="savingTaskHistory" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="false"/>
+ <xsd:element name="autoActivate" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="false"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:NCName" use="required" />
</xsd:extension>