Fixed failing InviteServiceTest

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30024 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
N Smith
2011-08-24 12:56:57 +00:00
parent 2d6e73135f
commit 35f0f3efb0
2 changed files with 0 additions and 72 deletions

View File

@@ -665,7 +665,6 @@
<bean id="webscript.org.alfresco.repository.invite.invite.get"
class="org.alfresco.repo.web.scripts.invite.Invite"
parent="webscript">
<property name="workflowService" ref="WorkflowService"/>
<property name="invitationService" ref="InvitationService"/>
</bean>

View File

@@ -21,14 +21,11 @@ package org.alfresco.repo.web.scripts.invite;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.repo.invitation.InviteHelper;
import org.alfresco.repo.invitation.WorkflowModelNominatedInvitation;
import org.alfresco.service.cmr.invitation.Invitation;
import org.alfresco.service.cmr.invitation.InvitationExceptionForbidden;
import org.alfresco.service.cmr.invitation.InvitationExceptionUserError;
import org.alfresco.service.cmr.invitation.InvitationService;
import org.alfresco.service.cmr.invitation.NominatedInvitation;
import org.alfresco.service.cmr.workflow.WorkflowException;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
@@ -71,14 +68,8 @@ public class Invite extends DeclarativeWebScript
private static final String PARAM_REJECT_URL = "rejectUrl";
// services
private WorkflowService workflowService;
private InvitationService invitationService;
public void setWorkflowService(WorkflowService workflowService)
{
this.workflowService = workflowService;
}
public void setInvitationService(InvitationService invitationService)
{
this.invitationService = invitationService;
@@ -272,7 +263,6 @@ public class Invite extends DeclarativeWebScript
// add model properties for template to render
model.put(MODEL_PROP_KEY_ACTION, ACTION_CANCEL);
model.put(MODEL_PROP_KEY_INVITE_ID, inviteId);
cancelInvite(model, inviteId);
}
catch(InvitationExceptionForbidden fe)
{
@@ -290,65 +280,4 @@ public class Invite extends DeclarativeWebScript
return model;
}
/**
* Cancels pending invite. Note that only a Site Manager of the
* site associated with the pending invite should be able to cancel that
* invite
*
* @param model
* model to add objects to, which will be passed to the template
* for rendering
* @param inviteId
* invite id of the invitation that inviter wishes to
* cancel
*/
private void cancelInvite(Map<String, Object> model, String inviteId)
{
// handle given invite ID null or empty
if ((inviteId == null) || (inviteId.length() == 0))
{
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
"Given invite ID " + inviteId + " null or empty");
}
try
{
// complete the wf:invitePendingTask along the 'cancel' transition because the invitation has been cancelled
InviteHelper.completeInviteTask(inviteId, WorkflowModelNominatedInvitation.WF_TASK_INVITE_PENDING,
WorkflowModelNominatedInvitation.WF_TRANSITION_CANCEL, this.workflowService);
}
catch(InvitationExceptionForbidden fe)
{
throw new WebScriptException(Status.STATUS_FORBIDDEN, "Unable to cancel workflow" , fe);
}
catch (WorkflowException wfe)
{
//
// If the indirect cause of workflow exception is a WebScriptException object
// then throw this directly, otherwise it will not be picked up by unit tests
//
Throwable indirectCause = wfe.getCause().getCause();
if(indirectCause instanceof InvitationExceptionForbidden)
{
throw new WebScriptException(Status.STATUS_FORBIDDEN, "Unable to cancel workflow" , indirectCause);
}
else if (indirectCause instanceof WebScriptException)
{
WebScriptException wse = (WebScriptException) indirectCause;
throw wse;
}
else
{
throw wfe;
}
}
// add model properties for template to render
model.put(MODEL_PROP_KEY_ACTION, ACTION_CANCEL);
model.put(MODEL_PROP_KEY_INVITE_ID, inviteId);
}
}